📄 fileio.c
字号:
writeToMemory(__G__ transbuf, (unsigned)outroom); else#endif if (!uO.cflag && WriteError(transbuf, (unsigned)outroom, G.outfile)) return disk_error(__G); else if (uO.cflag && (*G.message)((zvoid *)&G, transbuf, (ulg)outroom, 0)) return 0; q = transbuf; p += outroom; G.VMS_line_length -= outroom; /* fall through to normal case */ }/* GRR: need to change this to *q++ = native(*p++); loop or something */ memcpy(q, p, G.VMS_line_length); q += G.VMS_line_length; p += G.VMS_line_length; G.VMS_line_length = 0; /* necessary?? */ G.VMS_line_state = 3; } else { /* remaining input is less than full line */ int remaining = rawbuf+(unsigned)size-p; if (remaining < transbuf+(unsigned)transbufsiz-q) { int outroom = transbuf+(unsigned)transbufsiz-q;/* GRR: need to change this to *q++ = native(*p++); loop or something */ memcpy(q, p, outroom);#ifdef DLL if (G.redirect_data) writeToMemory(__G__ transbuf, (unsigned)(outroom)); else#endif if (!uO.cflag && WriteError(transbuf, (unsigned)outroom, G.outfile)) return disk_error(__G); else if (uO.cflag && (*G.message)((zvoid *)&G, transbuf, (ulg)outroom, 0)) return 0; q = transbuf; p += outroom; remaining -= outroom; }/* GRR: need to change this to *q++ = native(*p++); loop or something */ memcpy(q, p, remaining); q += remaining; p += remaining; G.VMS_line_length -= remaining; /* no change in G.VMS_line_state */ } break; /* 3: ready to PutNativeEOL */ case 3: if (q > transbuf+(unsigned)transbufsiz-lenEOL) {#ifdef DLL if (G.redirect_data) writeToMemory(__G__ transbuf, (unsigned)(q-transbuf)); else#endif if (!uO.cflag && WriteError(transbuf, (unsigned)(q-transbuf), G.outfile)) return disk_error(__G); else if (uO.cflag && (*G.message)((zvoid *)&G, transbuf, (ulg)(q-transbuf), 0)) return 0; q = transbuf; } PutNativeEOL if (G.VMS_line_pad) if (p < rawbuf+(unsigned)size) { ++p; G.VMS_line_state = 0; } else G.VMS_line_state = 4; else G.VMS_line_state = 0; break; /* 4: ready to read pad byte */ case 4: ++p; G.VMS_line_state = 0; break; } } /* end while */ } else#endif /* VMS_TEXT_CONV */ /*----------------------------------------------------------------------- Algorithm: CR/LF => native; lone CR => native; lone LF => native. This routine is only for non-raw-VMS, non-raw-VM/CMS files (i.e., stream-oriented files, not record-oriented). -----------------------------------------------------------------------*/ /* else not VMS text */ { p = rawbuf; if (*p == LF && G.didCRlast) ++p; G.didCRlast = FALSE; for (q = transbuf; p < rawbuf+(unsigned)size; ++p) { if (*p == CR) { /* lone CR or CR/LF: EOL either way */ PutNativeEOL if (p == rawbuf+(unsigned)size-1) /* last char in buffer */ G.didCRlast = TRUE; else if (p[1] == LF) /* get rid of accompanying LF */ ++p; } else if (*p == LF) /* lone LF */ PutNativeEOL else#ifndef DOS_FLX_OS2_W32 if (*p != CTRLZ) /* lose all ^Z's */#endif *q++ = native(*p);#if (defined(SMALL_MEM) || defined(MED_MEM))# if (lenEOL == 1) /* don't check unshrink: both buffers small but equal */ if (!unshrink)# endif /* check for danger of buffer overflow and flush */ if (q > transbuf+(unsigned)transbufsiz-lenEOL) { Trace((stderr, "p - rawbuf = %u q-transbuf = %u size = %lu\n", (unsigned)(p-rawbuf), (unsigned)(q-transbuf), size)); if (!uO.cflag && WriteError(transbuf, (unsigned)(q-transbuf), G.outfile)) return disk_error(__G); else if (uO.cflag && (*G.message)((zvoid *)&G, transbuf, (ulg)(q-transbuf), 0)) return 0; q = transbuf; continue; }#endif /* SMALL_MEM || MED_MEM */ } } /*----------------------------------------------------------------------- Done translating: write whatever we've got to file (or screen). -----------------------------------------------------------------------*/ Trace((stderr, "p - rawbuf = %u q-transbuf = %u size = %lu\n", (unsigned)(p-rawbuf), (unsigned)(q-transbuf), size)); if (q > transbuf) {#ifdef DLL if (G.redirect_data) writeToMemory(__G__ transbuf, (unsigned)(q-transbuf)); else#endif if (!uO.cflag && WriteError(transbuf, (unsigned)(q-transbuf), G.outfile)) return disk_error(__G); else if (uO.cflag && (*G.message)((zvoid *)&G, transbuf, (ulg)(q-transbuf), 0)) return 0; } } return 0;} /* end function flush() *//*************************//* Function disk_error() *//*************************/static int disk_error(__G) __GDEF{ /* OK to use slide[] here because this file is finished regardless */ Info(slide, 0x4a1, ((char *)slide, LoadFarString(DiskFullQuery), FnFilter1(G.filename)));#ifndef WINDLL fgets(G.answerbuf, 9, stdin); if (*G.answerbuf == 'y') /* stop writing to this file */ G.disk_full = 1; /* (outfile bad?), but new OK */ else#endif G.disk_full = 2; /* no: exit program */ return PK_DISK;} /* end function disk_error() */#endif /* !VMS *//*****************************//* Function UzpMessagePrnt() *//*****************************/int UZ_EXP UzpMessagePrnt(pG, buf, size, flag) zvoid *pG; /* globals struct: always passed */ uch *buf; /* preformatted string to be printed */ ulg size; /* length of string (may include nulls) */ int flag; /* flag bits */{ /* IMPORTANT NOTE: * The name of the first parameter of UzpMessagePrnt(), which passes * the "Uz_Globs" address, >>> MUST <<< be identical to the string * expansion of the __G__ macro in the REENTRANT case (see globals.h). * This name identity is mandatory for the LoadFarString() macro * (in the SMALL_MEM case) !!! */ int error; uch *q=buf, *endbuf=buf+(unsigned)size;#ifdef MORE uch *p=buf-1;#endif FILE *outfp;/*--------------------------------------------------------------------------- These tests are here to allow fine-tuning of UnZip's output messages, but none of them will do anything without setting the appropriate bit in the flag argument of every Info() statement which is to be turned *off*. That is, all messages are currently turned on for all ports. To turn off *all* messages, use the UzpMessageNull() function instead of this one. ---------------------------------------------------------------------------*/#if (defined(OS2) && defined(DLL)) if (MSG_NO_DLL2(flag)) /* if OS/2 DLL bit is set, do NOT print this msg */ return 0;#endif#ifdef WINDLL if (MSG_NO_WDLL(flag)) return 0;#endif#ifdef WINDLL if (MSG_NO_WGUI(flag)) return 0;#endif/*#ifdef ACORN_GUI if (MSG_NO_AGUI(flag)) return 0;#endif */#ifdef DLL /* don't display message if data is redirected */ if (((Uz_Globs *)pG)->redirect_data && !((Uz_Globs *)pG)->redirect_text) return 0;#endif if (MSG_STDERR(flag) && !((Uz_Globs *)pG)->UzO.tflag) outfp = (FILE *)stderr; else outfp = (FILE *)stdout;#ifdef QUERY_TRNEWLN /* some systems require termination of query prompts with '\n' to force * immediate display */ if (MSG_MNEWLN(flag)) { /* assumes writable buffer (e.g., slide[]) */ *endbuf++ = '\n'; /* with room for one more char at end of buf */ ++size; /* (safe assumption: only used for four */ } /* short queries in extract.c and fileio.c) */#endif if (MSG_TNEWLN(flag)) { /* again assumes writable buffer: fragile... */ if ((!size && !((Uz_Globs *)pG)->sol) || (size && (endbuf[-1] != '\n'))) { *endbuf++ = '\n'; ++size; } }#ifdef MORE /* room for --More-- and one line of overlap: */ ((Uz_Globs *)pG)->height = SCREENLINES - 2;#endif if (MSG_LNEWLN(flag) && !((Uz_Globs *)pG)->sol) { /* not at start of line: want newline */#ifdef OS2DLL if (!((Uz_Globs *)pG)->redirect_text) {#endif putc('\n', outfp); fflush(outfp);#ifdef MORE if (((Uz_Globs *)pG)->M_flag) { ++((Uz_Globs *)pG)->numlines; if (((Uz_Globs *)pG)->numlines % ((Uz_Globs *)pG)->height == 0L) /* GRR: fix */ (*((Uz_Globs *)pG)->mpause)((zvoid *)pG, LoadFarString(MorePrompt), 1); }#endif /* MORE */ if (MSG_STDERR(flag) && ((Uz_Globs *)pG)->UzO.tflag && !isatty(1) && isatty(2)) { /* error output from testing redirected: also send to stderr */ putc('\n', stderr); fflush(stderr); }#ifdef OS2DLL } else REDIRECTC('\n');#endif ((Uz_Globs *)pG)->sol = TRUE; } /* put zipfile name, filename and/or error/warning keywords here */#ifdef MORE if (((Uz_Globs *)pG)->M_flag#ifdef OS2DLL && !((Uz_Globs *)pG)->redirect_text#endif ) { while (++p < endbuf) { if (*p == '\n') { ++((Uz_Globs *)pG)->numlines; if (((Uz_Globs *)pG)->numlines % ((Uz_Globs *)pG)->height == 0L) /* GRR: fix */ { if ((error = WriteError(q, p-q+1, outfp)) != 0) return error; fflush(outfp); ((Uz_Globs *)pG)->sol = TRUE; q = p + 1; (*((Uz_Globs *)pG)->mpause)((zvoid *)pG, LoadFarString(MorePrompt), 1); } } } /* end while */ size = (ulg)(p - q); /* remaining text */ }#endif /* MORE */ if (size) {#ifdef OS2DLL if (!((Uz_Globs *)pG)->redirect_text) {#endif if ((error = WriteError(q, size, outfp)) != 0) return error; fflush(outfp); if (MSG_STDERR(flag) && ((Uz_Globs *)pG)->UzO.tflag && !isatty(1) && isatty(2)) { /* error output from testing redirected: also send to stderr */ if ((error = WriteError(q, size, stderr)) != 0) return error; fflush(stderr); }#ifdef OS2DLL } else { /* GRR: this is ugly: hide with macro */ if ((error = REDIRECTPRINT(q, size)) != 0) return error; }#endif ((Uz_Globs *)pG)->sol = (endbuf[-1] == '\n'); } return 0;} /* end function UzpMessagePrnt() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -