3. res

The res command will return the information of a particular resource, given a UUID.

<<available_commands>>=
fprintf(stderr, "res: prints resource info given UUID\n");
<<function_declarations>>=
static int get_res(int argc, char *argv[]);
<<functions>>=
static int get_res(int argc, char *argv[])
{
    wmp_core core;
    int rc;
    wmp_resource res;
    unsigned int id;
    int err;
    int prog;

    err = 0;
    if (argc < 2) {
        fprintf(stderr, "Usage: %s UUID\n", argv[0]);
        return 1;
    }
    rc = wmp_core_open(&core, wmp_filename_get());
    if (!rc) return 0;
    id = atoi(argv[1]);
    prog = 0;
    rc = wmp_find_resource(&core, id, &res, prog);

    if (!rc) {
        fprintf(stderr,
                "Could not find resource with id %d\n",
                id);
        err = 1;
    } else {
        printf("%d %d %s\n",
               res.id,
               res.type,
               wmp_resource_typestring(&res));
    }

    wmp_core_close(&core);
    return err;
}
<<command_parsing>>=
else if (match(argv[1], len, "res", 3)) {
    argv++;
    argc--;
    get_res(argc, argv);
}



prev | home | next