int main(int argc, char **argv) { ptable_s table; supermach_s *machine; printf("reading: %s\n",argv[1]); machine = build_smachine (_COMPINITID_, MACH_ARGS); if (argc < 2) read_lines(machine, "samples/workingtest"); else read_lines(machine, argv[1]); populate_reserved (machine, "keywords"); run_machine (machine); //cleanup(machine) table = build_ptable("samples/commandlinegrammar", machine); synan (machine, table); fprintlistingfile(machine); fprinttokenfile(machine); printlistingfile(machine); fprint_ptable (&table); //printtokenfile(machine); cleanup(machine); return 0; }
apr_status_t serf_bucket_response_status( serf_bucket_t *bkt, serf_status_line *sline) { response_context_t *ctx = bkt->data; apr_status_t status; if (ctx->state != STATE_STATUS_LINE) { /* We already read it and moved on. Just return it. */ *sline = ctx->sl; return APR_SUCCESS; } /* Running the state machine once will advance the machine, or state * that the stream isn't ready with enough data. There isn't ever a * need to run the machine more than once to try and satisfy this. We * have to look at the state to tell whether it advanced, though, as * it is quite possible to advance *and* to return APR_EAGAIN. */ status = run_machine(bkt, ctx); if (ctx->state == STATE_HEADERS) { *sline = ctx->sl; } else { /* Indicate that we don't have the information yet. */ sline->version = 0; } return status; }
int main(int argc,char **argv) { int i,list,log,success; list = 0; for (i = 1;i < argc;i++) { if (stricmp(argv[i],"-list") == 0) list = 1; } if (list) { printf("\nMAME currently supports the following games:\n\n"); i = 0; while (drivers[i]) { printf("%10s",drivers[i]->name); i++; if (!(i % 7)) printf("\n"); } if (i % 7) printf("\n"); printf("\nTotal games supported: %4d\n", i); return 0; } success = 1; log = 0; for (i = 1;i < argc;i++) { if (stricmp(argv[i],"-log") == 0) log = 1; } if (log) errorlog = fopen("error.log","wa"); if (init_machine(argc > 1 && argv[1][0] != '-' ? argv[1] : DEFAULT_NAME,argc,argv) == 0) { if (osd_init(argc,argv) == 0) { if (run_machine(argc > 1 && argv[1][0] != '-' ? argv[1] : DEFAULT_NAME) == 0) success = 0; else printf("Unable to start emulation\n"); osd_exit(); } else printf("Unable to initialize system\n"); shutdown_machine(); } else printf("Unable to initialize machine emulation\n"); if (errorlog) fclose(errorlog); return success; }
int main(void) { init_environment(); MACHINE *mach = make_machine(); for (int i = 0; i < 23; i++) printf("ins %d: %08x\n", i, factorial_ins[i]); printf("\n"); init_machine(mach); load_memory(factorial_ins, 100, mach, 0); run_machine(mach); free_machine(mach); return 0; }
static apr_status_t wait_for_body(serf_bucket_t *bkt, response_context_t *ctx) { apr_status_t status; /* Keep reading and moving through states if we aren't at the BODY */ while (ctx->state != STATE_BODY) { status = run_machine(bkt, ctx); /* Anything other than APR_SUCCESS means that we cannot immediately * read again (for now). */ if (status) return status; } /* in STATE_BODY */ return APR_SUCCESS; }
int main(int argc, const char *argv[]) { int i = 1000; struct timespec t1; struct timespec t2; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1); while(--i) { run_machine(); } clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t2); printf("%ld %ld\n", t2.tv_sec - t1.tv_sec, t2.tv_nsec - t1.tv_nsec); return 0; }
void startMachine(struct program *program) { initscr(); atexit(exit_handle); raw(); curs_set(0); noecho(); cbreak(); start_color(); init_pair(1, COLOR_RED, COLOR_BLACK); MESSAGE_HEIGHT = 5; MESSAGE_WIDTH = COLS / 2; status = newwin(6, COLS, 1, 0); output = newwin((LINES - 6) / 3, COLS, 7, 0); context = newwin(2 * (LINES - 6) / 3, COLS, (LINES - 6) / 3 + 7, 0); box(status, 0, 0); box(context, 0, 0); keypad(context, 1); scrollok(output, 1); if (NULL == program->objectfile) { program->objectfile = malloc(sizeof(char) * (size_t) MESSAGE_WIDTH); prompt(NULL, "Enter the .obj file: ", program->objectfile); } program->simulator = init_state; if (!init_machine(program)) { run_machine(program); } delwin(status); delwin(output); delwin(context); endwin(); }
int run_game(int game) { int err; /* copy some settings into easier-to-handle variables */ record = options.record; playback = options.playback; mame_debug = options.mame_debug; Machine->gamedrv = gamedrv = drivers[game]; Machine->drv = drv = gamedrv->drv; /* copy configuration */ if (options.color_depth == 16 || (options.color_depth != 8 && (Machine->gamedrv->flags & GAME_REQUIRES_16BIT))) Machine->color_depth = 16; else Machine->color_depth = 8; //if (options.vector_width == 0) options.vector_width = 640; //if (options.vector_height == 0) options.vector_height = 480; if (options.vector_width == 0) options.vector_width = 320; if (options.vector_height == 0) options.vector_height = 240; Machine->sample_rate = options.samplerate; /* get orientation right */ Machine->orientation = gamedrv->flags & ORIENTATION_MASK; Machine->ui_orientation = ROT0; if (options.norotate) Machine->orientation = ROT0; if (options.ror) { /* if only one of the components is inverted, switch them */ if ((Machine->orientation & ROT180) == ORIENTATION_FLIP_X || (Machine->orientation & ROT180) == ORIENTATION_FLIP_Y) Machine->orientation ^= ROT180; Machine->orientation ^= ROT90; /* if only one of the components is inverted, switch them */ if ((Machine->ui_orientation & ROT180) == ORIENTATION_FLIP_X || (Machine->ui_orientation & ROT180) == ORIENTATION_FLIP_Y) Machine->ui_orientation ^= ROT180; Machine->ui_orientation ^= ROT90; } if (options.rol) { /* if only one of the components is inverted, switch them */ if ((Machine->orientation & ROT180) == ORIENTATION_FLIP_X || (Machine->orientation & ROT180) == ORIENTATION_FLIP_Y) Machine->orientation ^= ROT180; Machine->orientation ^= ROT270; /* if only one of the components is inverted, switch them */ if ((Machine->ui_orientation & ROT180) == ORIENTATION_FLIP_X || (Machine->ui_orientation & ROT180) == ORIENTATION_FLIP_Y) Machine->ui_orientation ^= ROT180; Machine->ui_orientation ^= ROT270; } if (options.flipx) { Machine->orientation ^= ORIENTATION_FLIP_X; Machine->ui_orientation ^= ORIENTATION_FLIP_X; } if (options.flipy) { Machine->orientation ^= ORIENTATION_FLIP_Y; Machine->ui_orientation ^= ORIENTATION_FLIP_Y; } set_pixel_functions(); /* Do the work*/ err = 1; bailing = 0; #ifdef MESS if (get_filenames()) return err; #endif if (osd_init() == 0) { if (init_machine() == 0) { if (run_machine() == 0) err = 0; else if (!bailing) { bailing = 1; printf("Unable to start machine emulation\n"); } shutdown_machine(); } else if (!bailing) { bailing = 1; printf("Unable to initialize machine emulation\n"); } osd_exit(); } else if (!bailing) { bailing = 1; printf ("Unable to initialize system\n"); } return err; }