static int config_handle_arg(char *arg) { int i; /* notice: for MESS game means system */ if (got_gamename) { fprintf(stderr, "error: duplicate gamename: %s\n", arg); return -1; } rompath_extra = osd_dirname(arg); if (rompath_extra && !strlen(rompath_extra)) { free(rompath_extra); rompath_extra = NULL; } gamename = arg; /* do we have a driver for this? */ for (i = 0; drivers[i]; i++) { if (mame_stricmp(gamename, drivers[i]->name) == 0) { game_index = i; break; } } #ifdef MESS if (game_index >= 0) add_mess_device_options(rc, drivers[game_index]); #endif /* MESS */ got_gamename = 1; return 0; }
int messtest(const struct messtest_options *opts, int *test_count, int *failure_count) { char saved_directory[1024]; FILE *file; int result = -1; char *script_directory; xml_parse_options parse_options; xml_parse_error parse_error; xml_data_node *root_node; xml_data_node *tests_node; mess_pile pile; const char *xml; size_t sz; char buf[256]; *test_count = 0; *failure_count = 0; pile_init(&pile); /* open the script file */ file = fopen(opts->script_filename, "r"); if (!file) { fprintf(stderr, "%s: Cannot open file\n", opts->script_filename); goto done; } /* read the file */ while(!feof(file)) { sz = fread(buf, 1, sizeof(buf), file); pile_write(&pile, buf, sz); } pile_writebyte(&pile, '\0', 1); xml = (const char *) pile_getptr(&pile); /* save the current working directory, and change to the test directory */ saved_directory[0] = '\0'; if (!opts->preserve_directory) { script_directory = osd_dirname(opts->script_filename); if (script_directory) { osd_getcurdir(saved_directory, sizeof(saved_directory) / sizeof(saved_directory[0])); osd_setcurdir(script_directory); free(script_directory); } } /* set up parse options */ memset(&parse_options, 0, sizeof(parse_options)); parse_options.init_parser = parse_init; parse_options.flags = XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT; parse_options.error = &parse_error; /* do the parse */ root_node = xml_string_read(xml, &parse_options); if (!root_node) { fprintf(stderr, "%s:%d:%d: %s\n", opts->script_filename, parse_error.error_line, parse_error.error_column, parse_error.error_message); goto done; } /* find the tests node */ tests_node = xml_get_sibling(root_node->child, "tests"); if (!tests_node) goto done; node_tests(tests_node, test_count, failure_count); result = 0; done: /* restore the directory */ if (saved_directory[0]) osd_setcurdir(saved_directory); pile_delete(&pile); return result; }