PRIVATE int cmd_load(struct comal_line *line) { char *fn; if (!line->lc.str && !curenv->name) run_error(CMD_ERR, "Missing program name (to LOAD)"); else if (check_changed()) { if (line->lc.str) fn = line->lc.str->s; else { fn = curenv->name; my_printf(MSG_DIALOG, 1, fn); } fn = my_strdup(MISC_POOL, fn); prog_load(fn); curenv->name = fn; prog_structure_scan(); mem_freepool(PARSE_POOL); longjmp(RESTART, JUST_RESTART); } return 0; }
PUBLIC void clean_runenv(struct comal_env *env) { struct file_rec *fwalk = curenv->fileroot; if (comal_debug) my_printf(MSG_DEBUG, 1, "Cleaning runenv"); env->lasterr = 0; mem_free(env->lasterrmsg); env->lasterrmsg = my_strdup(MISC_POOL, copyright); env->errline = 0; env->escallowed = 1; env->nrtraps = 0; env->running = 0; env->datalptr = NULL; env->dataeptr = NULL; while (fwalk) { if (comal_debug) my_printf(MSG_DEBUG, 1, "Closing comal file %ld", fwalk->cfno); close(fwalk->hfno); fwalk = fwalk->next; } curenv->fileroot = NULL; seg_allfree(); mem_freepool(RUN_POOL); trace_reset(); }
PRIVATE int cmd_run(struct comal_line *line) { mem_freepool(PARSE_POOL); longjmp(RESTART, RUN); return 0; }
PRIVATE int cmd_new(struct comal_line *line) { if (check_changed()) { prog_new(); mem_freepool(PARSE_POOL); longjmp(RESTART, JUST_RESTART); } return 0; }
PUBLIC int pars_handle_error() { int i = pars_error_happened; if (i) { my_printf(MSG_ERROR, 1, pars_errtxt); mem_freepool(PARSE_POOL); pars_error_happened = 0; } return i; }
/** module free callback. ldr_mutex is captured at this time */ void _std mod_freeexps(module *mh) { mh->exports=0; // free exports, not used below if (mh->exps) { free(mh->exps); mh->exps=0; } /* unchain ordinals first, because it rebuild thunks internally, then free thunks ;) */ mod_apiunchain((u32t)mh,0,0,0); if (mh->thunks) { free(mh->thunks); mh->thunks=0; } // free trace info trace_unload_hook(mh); // free other possible function thunks mod_freethunk((u32t)mh,0); // free heap blocks, belonging to this module mem_freepool(QSMEMOWNER_COLIB, (u32t)mh); }
PRIVATE int cmd_enter(struct comal_line *line) { FILE *yyenter; char tline[MAX_LINELEN]; int stoppen = 0; struct comal_line *aline; yyenter = fopen(line->lc.str->s, "rt"); if (!yyenter) run_error(OPEN_ERR, "File open error: %s", sys_errlist[errno]); setvbuf(yyenter, NULL, _IOFBF, TEXT_BUFSIZE); ++entering; while (!stoppen) { stoppen = (fgets(tline, MAX_LINELEN - 1, yyenter) == NULL); if (stoppen) { if (!feof(yyenter)) run_error(CMD_ERR, "Error when reading ENTER file: %s", sys_errlist[errno]); } else { aline = crunch_line(tline); if (!aline) { my_nl(MSG_DIALOG); my_printf(MSG_DIALOG, 1, "Ignored line: %s", tline); mem_freepool(PARSE_POOL); } else process_comal_line(aline); } } fclose(yyenter); --entering; prog_structure_scan(); return 0; }