void errout_s_NL(UCHAR *s, UCHAR *t) { msgout(s); msgout(t); msgout(NL); GOLD_exit(1); }
void mainCRTStartup(void) { struct stack_alloc *pwork, work_image; struct str_works works; UCHAR *p0; int i; pwork = (struct stack_alloc *) ((((int) &work_image) + 0x0f) & ~0x0f); works.label = works.label0 = pwork->label; works.label1 = &pwork->label[sizeof (pwork->label) / sizeof(*pwork->label)]; works.objs = works.objs0 = pwork->objs; works.objs1 = &pwork->objs[sizeof (pwork->objs) / sizeof(*pwork->objs)]; works.filebuf = works.filebuf0 = pwork->filebuf; works.filebuf1 = &pwork->filebuf[sizeof (pwork->filebuf) / sizeof(*pwork->filebuf)]; works.iobuf0 = pwork->iobuf; works.iobuf1 = &pwork->iobuf[sizeof (pwork->iobuf) / sizeof(*pwork->iobuf)]; works.libname = works.extname = NULL; works.flags = 0; p0 = GetCommandLineA(); while (*p0 > ' ') p0++; cmdline(p0, p0 + GO_strlen(p0), &works); libout(&works); GOLD_exit(0); }
void GOL_sysabort(UCHAR termcode) { static const UCHAR *termmsg[] = { "", "[TERM_WORKOVER]\n", "[TERM_OUTOVER]\n", "[TERM_ERROVER]\n", "[TERM_BUGTRAP]\n", "[TERM_SYSRESOVER]\n", "[TERM_ABORT]\n" }; GO_stderr.p1 += 128; /* 予備に取っておいた分を復活 */ /* バッファを出力 */ if (GO_stdout.p - GO_stdout.p0) { if (GOLD_write_t(GOL_outname, GO_stdout.p - GO_stdout.p0, GO_stdout.p0)) { GO_fputs("GOL_sysabort:output error!\n", &GO_stderr); termcode = 6; } } if (termcode <= 6) GO_fputs(termmsg[termcode], &GO_stderr); if (GO_stderr.p - GO_stderr.p0) GOLD_write_t(NULL, GO_stderr.p - GO_stderr.p0, GO_stderr.p0); GOLD_exit((termcode == 0) ? GOL_retcode : 1); }
/* 系统退出函数 */ void GOL_sysabort(UCHAR termcode) { static const UCHAR *termmsg[] = { "", "[TERM_WORKOVER]\n", "[TERM_OUTOVER]\n", "[TERM_ERROVER]\n", "[TERM_BUGTRAP]\n", "[TERM_SYSRESOVER]\n", "[TERM_ABORT]\n" }; GO_stderr.p1 += 128; /* Resurrect minute that was set aside in reserve */ /* The output buffer */ /* 将p0到p的数据写入GOL_outname指定的文件 */ if (writefile(GOL_outname, GO_stdout.p0, GO_stdout.p)) { GO_fputs("GOL_sysabort:output error!\n", &GO_stderr); termcode = 6; } /* 将termcode指定的termmsg字符串数组中的信息字符串输出 */ if (termcode <= 6) GO_fputs(termmsg[termcode], &GO_stderr); /* 如果还有数据没写完,将其写入标准输出(stdout) */ if (GO_stderr.p > GO_stderr.p0) writefile(NULL, GO_stderr.p0, GO_stderr.p); /* 退出 */ GOLD_exit((termcode == 0) ? GOL_retcode : 1); }
void mainCRTStartup(void) { struct stack_alloc work_image, *pwork; UCHAR *p0, *f, *src1, i = 0; struct STR_FLAGS flags; pwork = (struct stack_alloc *) ((((int) &work_image) + 0x0f) & ~0x0f); flags.opt[FLAG_E] = flags.opt[FLAG_S] = 0; p0 = GetCommandLineA(); while (*p0 > ' ') p0++; for (;;) { while (*p0 != '\0' && *p0 <= ' ') p0++; if (*p0 == '\0') break; if (*p0 == '-') { do { p0++; if (*p0 == 's') flags.opt[FLAG_S] = 1; if (*p0 == 'e') flags.opt[FLAG_E] = 1; } while (*p0 > ' '); continue; } f = pwork->filename; do { *f++ = *p0++; } while (*p0 > ' '); *f = '\0'; if (i == 0) src1 = readfile(pwork->filename, pwork->ibuf, pwork->ibuf + sizeof (pwork->ibuf)); i++; } if (i != 2) { errout("\"sjisconv\" Copyright(C) 2003 H.Kawai" NL "usage : >sjisconv [-e] [-s] input-file output-file" NL ); } src1 = convmain(pwork->ibuf, src1, pwork->obuf, pwork->obuf + sizeof (pwork->obuf), flags); if (src1 == NULL) errout("output filebuf over!" NL); if (GOLD_write_t(pwork->filename, src1 - pwork->obuf, pwork->obuf)) errout_s_NL("can't write file: ", pwork->filename); GOLD_exit(0); }
int gas2nask_main(struct STR_GAS2NASK *params) { UCHAR *p0, *f, *src0, i = 0; static UCHAR filename[1000]; struct STR_FLAGS flags; int j, size; errflag = 0; DRVOSA_errcode = 0; msgptr = params->err0; msgptr1 = params->err1; params->outname = NULL; for (j = 0; j < 8; j++) flags.opt[j] = 0; if (setjmp(setjmp_env)) { params->err0 = msgptr; params->errcode = DRVOSA_errcode; return GOL_abortcode; } p0 = params->cmdlin; while (*p0 > ' ') p0++; for (;;) { while (*p0 != '\0' && *p0 <= ' ') p0++; if (*p0 == '\0') break; if (*p0 == '-') { do { p0++; if (*p0 == 'a') flags.opt[FLAG_a] = 1; if (*p0 == 'e') flags.opt[FLAG_e] = 1; if (*p0 == 'd') { j = FLAG_d; getparam: do { p0++; } while (*p0 != '\0' && *p0 <= ' '); param_p[j] = p0; while ('0' <= *p0 && *p0 <= '9') p0++; flags.opt[j] = p0 - param_p[j]; p0--; /* 次のループのため */ } if (*p0 == 'b') { j = FLAG_b; goto getparam; } if (*p0 == 't') { j = FLAG_t; goto getparam; } if (*p0 == 'D') { j = FLAG_D; goto getparam; } if (*p0 == 'B') { j = FLAG_B; goto getparam; } if (*p0 == 'T') { j = FLAG_T; goto getparam; } } while (*p0 > ' '); continue; } f = filename; do { *f++ = *p0++; } while (*p0 > ' '); *f = '\0'; if (i == 0) { src0 = osain(filename, &size); if (src0 == NULL) errout_s_NL("can't open file: ", filename); } i++; } if (i != 2) { errout("\"gas2nask\" Copyright(C) 2004 H.Kawai" NL "usage : >gas2nask [-a] [-e] input-file output-file" NL ); } src0 = convmain(src0, src0 + size, params->dest0, params->dest1, flags); if (src0 == NULL) GOL_sysabort(GO_TERM_OUTOVER); params->outname = filename; params->dest0 = src0; GOLD_exit(errflag); }
void errout(UCHAR *s) { msgout(s); GOLD_exit(1); }