int prun(FAR char *exepath, size_t varsize, size_t strsize) { FAR struct pexec_s *st; int errcode; int ret = OK; /* Load the POFF file into memory */ st = pload(exepath, varsize, varsize); if (!st) { bdbg("ERROR: Could not load %s\n", exepath); return -ENOEXEC; } bvdbg("Loaded %s\n", exepath); /* Execute the P-Code program until a stopping condition occurs */ for (;;) { /* Execute the instruction; Check for exceptional conditions */ errcode = pexec(st); if (errcode != eNOERROR) { break; } } if (errcode != eEXIT) { /* REVISIT: Select a more appropriated return errocode */ bdbg("ERROR: Runtime error 0x%02x -- Execution Stopped\n", errcode); ret = -ENOEXEC; } /* Clean up resources used by the interpreter */ bvdbg("Execution terminated\n"); pexec_release(st); return ret; }
int main(int argc, char *argv[]) { if (argc < 2) { usage(argv[0]); } else { char *fname = argv[1]; FILE *file = fopen(fname, "r"); if (file == NULL) { printf ("invalid file: %s\n", fname); return -1; } program p; ploadret ret = pload(&p, file); if (ret.type == SUCCESS) { printf("%d instructions loaded successfully\n", p.length); } else { printf("error loading source: "); switch (ret.type) { case SUCCESS: printf("SUCCESS"); break; case INVALID_INSTRUCTION: printf("INVALID_INSTRUCTION"); break; case INVALID_INTEGER: printf("INVALID_INTEGER"); break; case INVALID_ESCAPE: printf("INVALID_ESCAPE"); break; } printf(" in %s:%d:%d: '%c'(%d)\n", fname, ret.line, ret.column, ret.symbol, ret.symbol); return ret.type; } fclose(file); printf("\nprogram output:\n"); progstate state = progstatenew(); int r = prun(&state, p); putchar('\n'); pfree(p); return r; } }
void probability_remove(aClient *ac) { pload(ac->name, -1); pload(ac->user->username, -1); pload(ac->info, -1); }
void probability_add(aClient *ac) { pload(ac->name, 1); pload(ac->user->username, 1); pload(ac->info, 1); }