4. block
The block
command will return the information of
block with a particular UUID.
<<available_commands>>=
fprintf(stderr, "blk: prints block info given UUID\n");
<<utils>>=
static void print_block(wmp_block *blk)
{
printf("id = %d\nhead_segment = %d\nname = %s\n"
"nblocks = %d\nnsegs = %d\n",
blk->id,
blk->head_segment,
blk->name,
blk->nblocks,
blk->nsegs);
}
<<function_declarations>>=
static int get_blk(int argc, char *argv[]);
<<functions>>=
static int get_blk(int argc, char *argv[])
{
wmp_core core;
int rc;
wmp_block blk;
unsigned int id;
int err;
int prog;
prog = 0;
err = 0;
if (argc < 2) {
fprintf(stderr, "Usage: %s UUID [prog]\n", argv[0]);
return 1;
}
rc = wmp_core_open(&core, wmp_filename_get());
if (!rc) return 0;
wmp_block_init(&blk);
id = atoi(argv[1]);
if (argc > 2) prog = atoi(argv[2]);
rc = wmp_find_block(&core, id, &blk, prog);
if(!rc) {
fprintf(stderr,
"Could not find block in program %d "
"with id %d\n",
prog,
id);
err = 1;
} else {
print_block(&blk);
}
wmp_block_free(&blk);
wmp_core_close(&core);
return err;
}
<<command_parsing>>=
else if (match(argv[1], len, "blk", 3)) {
argv++;
argc--;
get_blk(argc, argv);
}
prev | home | next