4. DONE File
CLOSED: [2019-11-14 Thu 18:19] Creates a graph given, a filename.
<<available_commands>>=
fprintf(stderr, "file: Creates graph from file.\n");
<<function_declarations>>=
static int dot_file(int argc, char *argv[]);
<<functions>>=
static int dot_file(int argc, char *argv[])
{
wmp_core core;
int rc;
wmp_file file;
wmp_block blk;
if (argc < 2) {
fprintf(stderr, "Usage: %s FILE [prog]\n", argv[0]);
return 1;
}
rc = wmp_core_open(&core, wmp_filename_get());
if (!rc) return 0;
wmp_file_init(&file);
rc = wmp_lookup_file(&core, argv[1], &file);
if (!rc) {
printf("Could not find file %s\n", argv[1]);
return 1;
}
wmp_block_init(&blk);
rc = wmp_find_block(&core, file.top, &blk, 0);
if (!rc) {
printf("Could not find block with id %d\n", file.id);
return 1;
}
printf("digraph {\n");
print_tree(&core, blk.name, 0);
printf("}\n");
wmp_file_free(&file);
wmp_core_close(&core);
return 0;
}
<<command_parsing>>=
else if (match(argv[1], len, "file", 4)) {
argv++;
argc--;
dot_file(argc, argv);
}
prev | home | next