void node_testimgtool(xml_data_node *node) { xml_data_node *child_node; xml_attribute_node *attr_node; struct imgtooltest_state state; imgtool_init(FALSE, messtest_warn); attr_node = xml_get_attribute(node, "name"); report_testcase_begin(attr_node ? attr_node->value : NULL); memset(&state, 0, sizeof(state)); for (child_node = node->child; child_node; child_node = child_node->next) { if (!strcmp(child_node->name, "createimage")) node_createimage(&state, child_node); else if (!strcmp(child_node->name, "checkfile")) node_checkfile(&state, child_node); else if (!strcmp(child_node->name, "checkdirectory")) node_checkdirectory(&state, child_node); else if (!strcmp(child_node->name, "putfile")) node_putfile(&state, child_node); else if (!strcmp(child_node->name, "deletefile")) node_deletefile(&state, child_node); else if (!strcmp(child_node->name, "createdirectory")) node_createdirectory(&state, child_node); else if (!strcmp(child_node->name, "deletedirectory")) node_deletedirectory(&state, child_node); else if (!strcmp(child_node->name, "recordfreespace")) node_recordfreespace(&state, child_node); else if (!strcmp(child_node->name, "checkfreespace")) node_checkfreespace(&state, child_node); else if (!strcmp(child_node->name, "setattr")) node_setattr(&state, child_node); else if (!strcmp(child_node->name, "checkattr")) node_checkattr(&state, child_node); } report_testcase_ran(state.failed); /* close out any existing partition */ if (state.partition) { imgtool_partition_close(state.partition); state.partition = NULL; } /* close out any existing image */ if (state.image) { imgtool_image_close(state.image); state.image = NULL; } imgtool_exit(); }
int CLIB_DECL main(int argc, char *argv[]) { int i; int result; const struct command *c; const char *sample_format = "coco_jvc_rsdos"; #ifdef MAME_DEBUG if (imgtool_validitychecks()) return -1; #endif /* MAME_DEBUG */ putchar('\n'); if (argc > 1) { /* figure out what command they are running, and run it */ for (i = 0; i < ARRAY_LENGTH(cmds); i++) { c = &cmds[i]; if (!core_stricmp(c->name, argv[1])) { /* check argument count */ if (c->minargs > (argc - 2)) goto cmderror; /* initialize the imgtool core */ imgtool_init(TRUE, NULL); if (c->lastargrepeats && (argc > c->maxargs)) { for (i = c->maxargs+1; i < argc; i++) { argv[c->maxargs+1] = argv[i]; result = c->cmdproc(c, c->maxargs, argv + 2); if (result) goto done; } result = 0; goto done; } else { if ((c->maxargs > 0) && (c->maxargs < (argc - 2))) goto cmderror; result = c->cmdproc(c, argc - 2, argv + 2); goto done; } } } } /* Usage */ fprintf(stderr, "imgtool - Generic image manipulation tool for use with MESS\n\n"); for (i = 0; i < ARRAY_LENGTH(cmds); i++) { writeusage(stdout, (i == 0), &cmds[i], argv); } fprintf(stderr, "\n<format> is the image format, e.g. %s\n", sample_format); fprintf(stderr, "<imagename> is the image filename; can specify a ZIP file for image name\n"); fprintf(stderr, "\nExample usage:\n"); fprintf(stderr, "\t%s dir %s myimageinazip.zip\n", imgtool_basename(argv[0]), sample_format); fprintf(stderr, "\t%s get %s myimage.dsk myfile.bin mynewfile.txt\n", imgtool_basename(argv[0]), sample_format); fprintf(stderr, "\t%s getall %s myimage.dsk\n", imgtool_basename(argv[0]), sample_format); result = 0; goto done; cmderror: writeusage(stdout, 1, &cmds[i], argv); result = -1; done: imgtool_exit(); return result; }