void init_map_font(int font_number) { unsigned i=0; while (i<no_fonts) { if (font_number == font_table[i].font_number) { warning_1("MAPFONT index (D %d) previously defined; " "old definition ignored", font_number); cur_font = &font_table[i]; if (cur_font->font_area != NULL) free(cur_font->font_area); if (cur_font->font_name != NULL) free(cur_font->font_name); if (cur_font->ovf_packet != NULL) free(cur_font->ovf_packet); clear_map_font(font_number); break; } i++; } if (i==no_fonts) { font_no_incr(); cur_font = &font_table[i]; clear_map_font(font_number); } packet_table_init(); append_command(DVI_FNT_DEF_1, i); cur_font_index = i; cur_font = &font_table[i]; cur_font->ovf_packet = cur_packet; cur_font->ovf_packet_length = packet_ptr; packet_table_end(); }
static void node_imageverify(xml_data_node *node) { void *new_buffer; mess_pile pile; /* <imageverify> - verifies that an image contains specific data */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_VERIFY_IMAGE; /* 'tag', 'type', 'slot' attributes */ if (!get_device_identity_tags(node, &new_command.u.verify_args.device_ident)) return; pile_init(&pile); messtest_get_data(node, &pile); new_buffer = pool_malloc_lib(command_pool, pile_size(&pile)); memcpy(new_buffer, pile_getptr(&pile), pile_size(&pile)); new_command.u.verify_args.verify_data = new_buffer; new_command.u.verify_args.verify_data_size = pile_size(&pile); pile_delete(&pile); if (!append_command()) { error_outofmemory(); return; } }
static void node_image(xml_data_node *node, messtest_command_type_t command) { xml_attribute_node *attr_node; int preload; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = command; /* 'preload' attribute */ attr_node = xml_get_attribute(node, "preload"); preload = attr_node ? atoi(attr_node->value) : 0; if (preload) new_command.command_type = (messtest_command_type_t) (new_command.command_type + 2); /* 'filename' attribute */ attr_node = xml_get_attribute(node, "filename"); new_command.u.image_args.filename = attr_node ? attr_node->value : NULL; /* 'tag', 'type', 'slot' attributes */ if (!get_device_identity_tags(node, &new_command.u.image_args.device_ident)) return; /* 'format' attribute */ attr_node = xml_get_attribute(node, "format"); new_command.u.image_args.format = attr_node ? attr_node->value : NULL; if (!append_command()) { error_outofmemory(); return; } }
static void command_end_handler(const void *buffer, size_t size) { if (!append_command()) { error_outofmemory(); return; } }
static void node_image(xml_data_node *node, messtest_command_type_t command) { xml_attribute_node *attr_node; const char *s2; int preload, device_type; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = command; /* 'preload' attribute */ attr_node = xml_get_attribute(node, "preload"); preload = attr_node ? atoi(attr_node->value) : 0; if (preload) new_command.command_type += 2; /* 'filename' attribute */ attr_node = xml_get_attribute(node, "filename"); new_command.u.image_args.filename = attr_node ? attr_node->value : NULL; /* 'type' attribute */ attr_node = xml_get_attribute(node, "type"); if (!attr_node) { error_missingattribute("type"); return; } s2 = attr_node->value; device_type = device_typeid(s2); if (device_type < 0) { error_baddevicetype(s2); return; } new_command.u.image_args.device_type = device_type; /* 'slot' attribute */ attr_node = xml_get_attribute(node, "slot"); new_command.u.image_args.device_slot = attr_node ? atoi(attr_node->value) : 0; /* 'format' attribute */ format_index = 0; attr_node = xml_get_attribute(node, "format"); new_command.u.image_args.format = attr_node ? attr_node->value : NULL; /* 'tag' attribute */ attr_node = xml_get_attribute(node, "tag"); new_command.u.image_args.device_tag = attr_node ? attr_node->value : NULL; if (!append_command()) { error_outofmemory(); return; } }
static void node_memverify(xml_data_node *node) { xml_attribute_node *attr_node; const char *s1; const char *s2; const char *s3; int region; void *new_buffer; mess_pile pile; /* <memverify> - verifies that a range of memory contains specific data */ attr_node = xml_get_attribute(node, "start"); s1 = attr_node ? attr_node->value : NULL; if (!s1) { error_missingattribute("start"); return; } attr_node = xml_get_attribute(node, "end"); s2 = attr_node ? attr_node->value : NULL; if (!s2) s2 = "0"; attr_node = xml_get_attribute(node, "region"); s3 = attr_node ? attr_node->value : NULL; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_VERIFY_MEMORY; new_command.u.verify_args.start = parse_offset(s1); new_command.u.verify_args.end = parse_offset(s2); if (s3) { region = memory_region_from_string(s3); if (region == REGION_INVALID) error_invalidmemregion(s3); new_command.u.verify_args.mem_region = region; } pile_init(&pile); messtest_get_data(node, &pile); new_buffer = pool_malloc(&command_pool, pile_size(&pile)); memcpy(new_buffer, pile_getptr(&pile), pile_size(&pile)); new_command.u.verify_args.verify_data = new_buffer; new_command.u.verify_args.verify_data_size = pile_size(&pile); pile_delete(&pile); if (!append_command()) { error_outofmemory(); return; } }
void append_command_2(unsigned cmd_0, unsigned max_n, unsigned cmd_1, unsigned actual) { if ((actual < 0) || (actual > 0x7fffffff)) internal_error_1("append_command (actual=%d)", actual); if ((cmd_0 + actual) <= max_n) append_to_packet(cmd_0 + actual); else append_command(cmd_1, actual); }
static void node_checkblank(xml_data_node *node) { /* <checkblank> - checks to see if the screen is blank */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_CHECKBLANK; if (!append_command()) { error_outofmemory(); return; } }
static void node_screenshot(xml_data_node *node) { /* <screenshot> - dumps a screenshot */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_SCREENSHOT; if (!append_command()) { error_outofmemory(); return; } }
static void node_trace(xml_data_node *node) { /* <trace> - emit a trace file */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_TRACE; if (!append_command()) { error_outofmemory(); return; } }
static void node_rawinput(xml_data_node *node) { /* <rawinput> - inputs raw data into a system */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_RAWINPUT; if (!append_command()) { error_outofmemory(); return; } }
static void node_hard_reset(xml_data_node *node) { /* <hardreset> - perform a hard reset */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_HARD_RESET; if (!append_command()) { error_outofmemory(); return; } }
static void verify_end_handler(const void *buffer, size_t size) { void *new_buffer; new_buffer = pool_malloc(&command_pool, size); memcpy(new_buffer, buffer, size); new_command.u.verify_args.verify_data = new_buffer; new_command.u.verify_args.verify_data_size = size; command_end_handler(NULL, 0); if (!append_command()) { error_outofmemory(); return; } }
static void node_input(xml_data_node *node) { /* <input> - inputs natural keyboard data into a system */ xml_attribute_node *attr_node; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_INPUT; attr_node = xml_get_attribute(node, "rate"); new_command.u.input_args.rate = atof(attr_node->value); new_command.u.input_args.input_chars = node->value; if (!append_command()) { error_outofmemory(); return; } }
static void node_imageverify(xml_data_node *node) { xml_attribute_node *attr_node; const char *s; iodevice_t device_type; void *new_buffer; mess_pile pile; /* <imageverify> - verifies that an image contains specific data */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_VERIFY_IMAGE; /* 'type' attribute */ attr_node = xml_get_attribute(node, "type"); s = attr_node ? attr_node->value : NULL; if (!s) { error_missingattribute("type"); return; } device_type = device_typeid(s); if (device_type < 0) { error_baddevicetype(s); return; } new_command.u.verify_args.device_type = device_type; pile_init(&pile); messtest_get_data(node, &pile); new_buffer = pool_malloc(&command_pool, pile_size(&pile)); memcpy(new_buffer, pile_getptr(&pile), pile_size(&pile)); new_command.u.verify_args.verify_data = new_buffer; new_command.u.verify_args.verify_data_size = pile_size(&pile); pile_delete(&pile); if (!append_command()) { error_outofmemory(); return; } }
static void node_wait(xml_data_node *node) { xml_attribute_node *attr_node; attr_node = xml_get_attribute(node, "time"); if (!attr_node) { error_missingattribute("time"); return; } memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_WAIT; new_command.u.wait_time = mame_time_to_double(parse_time(attr_node->value)); if (!append_command()) { error_outofmemory(); return; } }
static void node_switch(xml_data_node *node) { xml_attribute_node *attr_node; const char *s1; const char *s2; /* <switch> - switches a DIP switch/config setting */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_SWITCH; /* 'name' attribute */ attr_node = xml_get_attribute(node, "name"); if (!attr_node) { error_missingattribute("name"); return; } s1 = attr_node->value; /* 'value' attribute */ attr_node = xml_get_attribute(node, "value"); if (!attr_node) { error_missingattribute("value"); return; } s2 = attr_node->value; new_command.u.switch_args.name = s1; new_command.u.switch_args.value = s2; if (!append_command()) { error_outofmemory(); return; } }
void node_testmess(xml_data_node *node) { xml_data_node *child_node; xml_attribute_node *attr_node; int result; pile_init(&command_pile); pool_init(&command_pool); memset(&new_command, 0, sizeof(new_command)); command_count = 0; /* 'driver' attribute */ attr_node = xml_get_attribute(node, "driver"); if (!attr_node) { error_missingattribute("driver"); return; } current_testcase.driver = attr_node->value; /* 'name' attribute */ attr_node = xml_get_attribute(node, "name"); current_testcase.name = attr_node ? attr_node->value : current_testcase.driver; /* 'ramsize' attribute */ attr_node = xml_get_attribute(node, "ramsize"); current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0; /* 'wavwrite' attribute */ attr_node = xml_get_attribute(node, "wavwrite"); current_testcase.wavwrite = attr_node && (atoi(attr_node->value) != 0); /* report the beginning of the test case */ report_testcase_begin(current_testcase.name); current_testcase.commands = NULL; for (child_node = node->child; child_node; child_node = child_node->next) { if (!strcmp(child_node->name, "wait")) node_wait(child_node); else if (!strcmp(child_node->name, "input")) node_input(child_node); else if (!strcmp(child_node->name, "rawinput")) node_rawinput(child_node); else if (!strcmp(child_node->name, "switch")) node_switch(child_node); else if (!strcmp(child_node->name, "screenshot")) node_screenshot(child_node); else if (!strcmp(child_node->name, "checkblank")) node_checkblank(child_node); else if (!strcmp(child_node->name, "imagecreate")) node_imagecreate(child_node); else if (!strcmp(child_node->name, "imageload")) node_imageload(child_node); else if (!strcmp(child_node->name, "memverify")) node_memverify(child_node); else if (!strcmp(child_node->name, "imageverify")) node_imageverify(child_node); else if (!strcmp(child_node->name, "trace")) node_trace(child_node); } memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_END; if (!append_command()) { error_outofmemory(); return; } result = run_test(0, NULL); report_testcase_ran(result); pile_delete(&command_pile); pool_exit(&command_pool); }
int main(void) { entry* entry_head = calloc(sizeof(entry), 1); snapshot* snapshot_head = calloc(sizeof(snapshot), 1); int latest_snapshotID = 1; char buffer[MAX_LINE_LENGTH]; printf("> "); while(fgets(buffer, sizeof(buffer), stdin)) { struct command_struct *command = get_command_struct(buffer); if(!command) continue; if(strcmp(command->args_malloc_ptr[0], "bye") == 0) { bye_command(snapshot_head, entry_head); free_command(command); printf("bye"); return 0; } else if(strcmp(command->args_malloc_ptr[0], "help") == 0) { print_help_string(); } else if(strcmp(command->args_malloc_ptr[0], "list") == 0) { list_command(command, entry_head, snapshot_head); } else if(strcmp(command->args_malloc_ptr[0], "get") == 0) { get_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "del") == 0) { del_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "purge") == 0) { purge_command(command, entry_head, snapshot_head); } else if(strcmp(command->args_malloc_ptr[0], "set") == 0) { set_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "push") == 0) { push_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "append") == 0) { append_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "pick") == 0) { pick_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "pluck") == 0) { pluck_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "pop") == 0) { pop_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "drop") == 0) { drop_command(command, snapshot_head); } else if(strcmp(command->args_malloc_ptr[0], "rollback") == 0) { rollback_command(command, snapshot_head, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "checkout") == 0) { checkout_command(command, snapshot_head, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "snapshot") == 0) { snapshot_command(snapshot_head, entry_head, &latest_snapshotID); } else if(strcmp(command->args_malloc_ptr[0], "min") == 0) { min_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "max") == 0) { max_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "sum") == 0) { sum_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "len") == 0) { len_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "rev") == 0) { rev_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "uniq") == 0) { uniq_command(command, entry_head); } else if(strcmp(command->args_malloc_ptr[0], "sort") == 0) { sort_command(command, entry_head); } printf("\n> "); free_command(command); } bye_command(snapshot_head, entry_head); return 0; }
int main(int argc, char *argv[]) { STARTUPINFO startup; PROCESS_INFORMATION process; char *current; const char *user; char newenv[64]; int dirsize, i, rc; memset((void *)&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); // Passing STD_OUTPUT etc down seems to behave well when I am under mintty // or an xterm, but if I am running in a Windows console (eg as in the // earlier way that cygwin was set up) this is a mess in that output // does not appear on my console. I can go // cyg64 "whoami > xxx" // and the information ends up in the file xxx in the way it should, so // this is perhaps a case where I need to create a pipe to pass down // as each of stdout and stderr. Once I have launched the program I then need // to read from both of those and transfer anything I get back to my own // standard outputs. It also seems that STD_INPUT is passed OK here if it is // a pipe, but not if it is interactive... Ah well maybe this is still good // enough for IMMEDIATE purposes even without the upgrades needed to sort // out the problems described here! startup.hStdInput = GetStdHandle(STD_INPUT_HANDLE); startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); startup.hStdError = GetStdHandle(STD_ERROR_HANDLE); startup.wShowWindow = SW_HIDE; startup.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; memset((void *)&process, 0, sizeof(process)); // Now set up a command line dirsize = GetCurrentDirectory(0, NULL); current = (char *)malloc(dirsize); rc = GetCurrentDirectory(dirsize, current); if (rc > dirsize) { printf("Getting directory failed\n"); return; } // Under cygwin the shell variable USER gives the effective user name. A // second variable USERNAME holds the name of the user that Windows believes // is active: eg when I am linked in over ssh that may be "cyg_server". // If I fail to read USER I will default to the name "unknown". user = getenv("USER"); if (user == NULL) user = "******"; memset(newenv, 0, sizeof(newenv)); sprintf(newenv, "USER=%s", user); for (i=0; i<dirsize; i++) if (current[i] == '\\') current[i] = '/'; sprintf(command, "%s\\bin\\bash --login -c \"cd ", scygwin); append_command(current); strcat(command, " ; "); for (i=1; i<argc; i++) { append_command(argv[i]); strcat(command, " "); } strcat(command, "\""); // printf("Command is <%s>", command); rc = CreateProcess( NULL, // ApplicationName command, // Command line NULL, // Process attributes NULL, // Security attributes 1, // Inherit handles? CREATE_NEW_CONSOLE, // Process creation flags newenv, // environment scygwin "\\bin", // Current Directory &startup, // Startup Info &process); // process info if (rc == 0) { printf("Process creation failed\n"); return; } WaitForSingleObject(process.hThread, INFINITE); WaitForSingleObject(process.hProcess, INFINITE); FlushFileBuffers(startup.hStdOutput); FlushFileBuffers(startup.hStdError); CloseHandle(startup.hStdInput); CloseHandle(startup.hStdOutput); CloseHandle(startup.hStdError); CloseHandle(process.hProcess); CloseHandle(process.hThread); return 0; }