📄 ckuus4.c
字号:
oldsig = signal(SIGINT, trtrap); /* Save current interrupt trap. */#endif /* AMIGA */#endif /* MAC */ tr_int = 0; /* Have not been interrupted (yet). */ z = 1; /* Return code presumed good. */#ifdef VMS conres();#endif /* VMS */ c = 0; /* Initial condition */ while (c > -1) { /* Loop for all characters in file */#ifdef MAC /* * It is expensive to run the miniparser so don't do it for * every character. */ if (--count < 0) { count = 100; miniparser(1); if (sstate == 'a') { sstate = '\0'; z = 0; break; } }#else /* Not MAC */ if (tr_int) { /* Interrupted? */ printf("^C...\n"); /* Print message */ z = 0; break; }#endif /* MAC */ c = zminchar(); /* Get a file character */ debug(F101,"transmit char","",c); if (c == -1) /* Test for end-of-file */ break; c &= fmask; /* Apply SET FILE BYTESIZE mask */ if (binary) { /* If binary file, */ if (ttoc(dopar((char) c)) < 0) { /* else just send the char */ printf("?Can't transmit character\n"); z = 0; break; } if (xmitw) msleep(xmitw); /* Pause if requested */ if (xmitx) { /* SET TRANSMIT ECHO ON? */ if (duplex) { /* Yes, for half duplex */ conoc((char)(c & cmdmsk)); /* echo locally. */ } else { /* For full duplex, */ int i, n; /* display whatever is there. */ n = ttchk(); /* How many chars are waiting? */ for (i = 0; i < n; i++) { /* Read and echo that many. */ x = ttinc(1); /* Timed read just in case. */ if (x > -1) { /* If no timeout */ if (parity) x &= 0x7f; conoc((char)(x & cmdmsk)); /* display the char, */ } else break; /* otherwise stop reading. */ } } } else ttflui(); /* Not echoing, just flush input. */ } else { /* Text mode, line at a time. */ if (c == '\n') { /* Got a line */ if (i == 0) { /* Blank line? */ if (xmitf) /* Yes, insert fill if asked. */ line[i++] = dopar((char) xmitf); } if (i == 0 || line[i-1] != dopar(CR)) line[i++] = dopar(CR); /* Terminate it with CR */ if ( xmitl#ifdef TNCODE || (network && ttnproto == NP_TELNET && tn_nlm)#endif /* TNCODE */ ) line[i++] = dopar(LF); /* Include LF if asked */ } else if (c != -1) { /* Not a newline, regular character */ csave = c; /* Remember untranslated version */#ifndef NOCSETS /* Translate character sets */ if (sxo) c = (*sxo)((CHAR)c); /* From local to intermediate */ if (rxo) c = (*rxo)((CHAR)c); /* From intermediate to remote */#endif /* NOCSETS */ if (xmits && parity && (c & 0200)) { /* If shifting */ line[i++] = dopar(SO); /* needs to be done, */ line[i++] = dopar((char)c); /* do it here, */ line[i++] = dopar(SI); /* crudely. */ } else { line[i++] = dopar((char)c); /* else, just char itself */ } }/* Send characters if buffer full, or at end of line, or at end of file */ if (i >= XMBUFS || c == '\n' || c == -1) { p = line; line[i] = '\0'; debug(F111,"transmit buf",p,i); if (ttol((CHAR *)p,i) < 0) { /* try to send it. */ printf("Can't send buffer\n"); z = 0; break; } i = 0; /* Reset buffer pointer. *//* Worry about echoing here. "xmitx" is SET TRANSMIT ECHO flag. */ if (duplex && xmitx) { /* If local echo, echo it */ if (parity || cmdmsk == 0x7f) { /* Strip off high bits */ char *s = p; /* if necessary */ while (*s) { *s &= 0x7f; s++; } conoll(p); } } if (xmitw) /* Give receiver time to digest. */ msleep(xmitw); if (t != 0 && c == '\n') { /* Want a turnaround character */ x = 0; /* Wait for it */ while (x != t) { if ((x = ttinc(1)) < 0) break; if (xmitx && !duplex) { /* Echo any echoes */ if (parity) x &= 0x7f;#ifndef NOCSETS if (sxi) x = (*sxi)((CHAR)x); /* But translate */ if (rxi) x = (*rxi)((CHAR)x); /* them first... */#endif /* NOCSETS */ conoc((char) x); } } } else if (xmitx && !duplex) { /* Otherwise, */ while (ttchk() > 0) { /* echo for as long as */ if ((x = ttinc(0)) < 0) break; /* anything is there. */ if (parity) x &= 0x7f;#ifndef NOCSETS if (sxi) x = (*sxi)((CHAR)x); /* Translate first */ if (rxi) x = (*rxi)((CHAR)x);#endif /* NOCSETS */ conoc((char)x); } } else ttflui(); /* Otherwise just flush input buffer */ } /* End of buffer-dumping block */ } /* End of text mode */ } /* End of character-reading loop */ if (*xmitbuf) { /* Anything to send at EOF? */ p = xmitbuf; /* Yes, point to string. */ while (*p) /* Send it. */ ttoc(dopar(*p++)); /* Don't worry about echo here. */ }#ifndef AMIGA#ifndef MAC signal(SIGINT,oldsig); /* Put old signal action back. */#endif /* MAC */#endif /* AMIGA */#ifdef VMS concb(escape); /* Put terminal back, */#endif /* VMS */ zclose(ZIFILE); /* Close file, */#ifndef NOCSETS language = langsv; /* restore language, */#endif /* NOCSETS */ return(z); /* and return successfully. */}#endif /* NOXMIT */#ifdef MAC/* This code is not used any more, except on the Macintosh. Instead we call system to do the typing. Revive this code if your system can't be called to do this.*//* D O T Y P E -- Type a file */intdotype(s) char *s; {#ifdef MAC extern char sstate; int count = 100;#else SIGTYP (* oldsig)(); /* For saving old interrupt trap. */#endif /* MAC */ int z; /* Return code. */ int c; /* Worker. */ if (zopeni(ZIFILE,s) == 0) { /* Open the file to be typed */ printf("?Can't open %s\n",s); return(0); }#ifndef AMIGA#ifndef MAC oldsig = signal(SIGINT, trtrap); /* Save current interrupt trap. */#endif /* MAC */#endif /* AMIGA */ tr_int = 0; /* Have not been interrupted (yet). */ z = 1; /* Return code presumed good. */#ifdef VMS conoc(CR); /* On VMS, display blank line first */ conoc(LF); conres(); /* So Ctrl-C/Y will work */#endif /* VMS */ while ((c = zminchar()) != -1) { /* Loop for all characters in file */#ifdef MAC /* * It is expensive to run the miniparser so don't do it for * every character. */ if (--count < 0) { count = 100; miniparser(1); if (sstate == 'a') { sstate = '\0'; z = 0; break; } } putchar(c);#else /* Not MAC */ if (tr_int) { /* Interrupted? */ printf("^C...\n"); /* Print message */ z = 0; break; } conoc(c); /* Echo character on screen */#endif /* MAC */ }#ifndef AMIGA#ifndef MAC signal(SIGINT,oldsig); /* put old signal action back. */#endif /* MAC */#endif /* AMIGA */ tr_int = 0;#ifdef VMS concb(escape); /* Get back in command-parsing mode, */#endif /* VMS */ zclose(ZIFILE); /* close file, */ return(z); /* and return successfully. */}#endif /* MAC */#ifndef NOCSETS_PROTOTYP( CHAR (*sxx), (CHAR) ); /* Local translation function */_PROTOTYP( CHAR (*rxx), (CHAR) ); /* Local translation function */_PROTOTYP( CHAR zl1as, (CHAR) ); /* Latin-1 to ascii */_PROTOTYP( CHAR xl1as, (CHAR) ); /* ditto *//* X L A T E -- Translate a local file from one character set to another *//* Translates input file (fin) from character set csin to character set csout and puts the result in the output file (fout). The two character sets are file character sets from fcstab.*/intxlate(fin, fout, csin, csout) char *fin, *fout; int csin, csout; {#ifndef MAC SIGTYP (* oldsig)(); /* For saving old interrupt trap. */#endif /* MAC */ int filecode; /* Code for output file */ int z = 1; /* Return code. */ int c, tcs; /* Workers */ if (zopeni(ZIFILE,fin) == 0) { /* Open the file to be translated */ printf("?Can't open input file %s\n",fin); return(0); }#ifdef MAC/* If user specified no output file, it goes to the screen. For the Mac, this must be done a special way (result goes to a new window); the Mac doesn't have a "controlling terminal" device name.*/ filecode = !strcmp(fout,CTTNAM) ? ZCTERM : ZOFILE;#else filecode = ZOFILE;#endif /* MAC */ if (zopeno(filecode,fout,NULL,NULL) == 0) { /* And the output file */ printf("?Can't open output file %s\n",fout); return(0); }#ifndef AMIGA#ifndef MAC oldsig = signal(SIGINT, trtrap); /* Save current interrupt trap. */#endif /* MAC */#endif /* AMIGA */ tr_int = 0; /* Have not been interrupted (yet). */ z = 1; /* Return code presumed good. */ tcs = gettcs(csin,csout); /* Get intermediate set. */ printf("%s (%s) => %s (%s)\n", /* Say what we're doing. */ fin, fcsinfo[csin].name, fout,fcsinfo[csout].name ); printf("via %s", tcsinfo[tcs].name); if (language) printf(", language: %s\n",langs[language].description); printf("\n\n"); if (csin == csout) { /* Input and output sets the same? */ sxx = rxx = NULL; /* If so, no translation. */ } else { /* Otherwise, set up */ sxx = xls[tcs][csin]; /* translation function */ rxx = xlr[tcs][csout]; /* pointers. */ if (rxx == zl1as) rxx = xl1as; } while ((c = zminchar()) != -1) { /* Loop for all characters in file */ if (tr_int) { /* Interrupted? */ printf("^C...\n"); /* Print message */ z = 0; break; } if (sxx) c = (*sxx)((CHAR)c); /* From fcs1 to tcs */ if (rxx) c = (*rxx)((CHAR)c); /* from tcs to fcs2 */ if (zchout(ZOFILE,(char)c) < 0) { /* Output the translated character */ printf("File output error\n"); z = 0; break; } }#ifndef AMIGA#ifndef MAC signal(SIGINT,oldsig); /* put old signal action back. */#endif /* MAC */#endif /* AMIGA */ tr_int = 0; zclose(ZIFILE); /* close files, */ zclose(ZOFILE); return(z); /* and return successfully. */}#endif /* NOCSETS *//* D O L O G -- Do the log command */intdolog(x) int x; { int y, disp; char *s; switch (x) {#ifdef DEBUG case LOGD: y = cmofi("Name of debugging log file","debug.log",&s,xxstring); break;#endif /* DEBUG */ case LOGP: y = cmofi("Name of packet log file","packet.log",&s,xxstring); break; case LOGS: y = cmofi("Name of session log file","session.log",&s,xxstring); break;#ifdef TLOG case LOGT: y = cmofi("Name of transaction log file","transact.log",&s, xxstring); break;#endif /* TLOG */ default: printf("\n?Unknown log designator - %d\n",x); return(-2); } if (y < 0) return(y); strcpy(line,s); s = line; if ((y = cmkey(disptb,2,"Disposition","new",xxstring)) < 0) return(y); disp = y; if ((y = cmcfm()) < 0) return(y); switch (x) {#ifdef DEBUG case LOGD: return(deblog = debopn(s,disp));#endif /* DEBUG */ case LOGP: return(pktlog = pktopn(s,disp)); case LOGS: return(seslog = sesopn(s,disp));#ifdef TLOG case LOGT: return(tralog = traopn(s,disp));#endif /* TLOG */ default: return(-2); }}intpktopn(s,disp) char *s; int disp; { extern char pktfil[]; static struct filinfo xx; int y; zclose(ZPFILE); if(s[0] == '\0') return(0); if (disp) { xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0; xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = '\0'; xx.lblopts = 0; y = zopeno(ZPFILE,s,NULL,&xx); } else y = zopeno(ZPFILE,s,NULL,NULL); if (y > 0) strcpy(pktfil,s); else *pktfil = '\0'; return(y);}inttraopn(s,disp) char *s; int disp; {#ifdef TLOG extern char trafil[]; static struct filinfo xx; int y; zclose(ZTFILE); if(s[0] == '\0') return(0); if (disp) { xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0; xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = '\0'; xx.lblopts = 0; y = zopeno(ZTFILE,s,NULL,&xx); } else y = zopeno(ZTFILE,s,NULL,NULL); if (y > 0) { strcpy(trafil,s); tlog(F110,"Transaction Log:",versio,0L);#ifndef MAC tlog(F100,ckxsys,"",0L);#endif /* MAC */ ztime(&s); tlog(F100,s,"",0L); } else *trafil = '\0'; return(y);#else return(0);#endif}intsesopn(s,disp) char * s; int disp; { extern char sesfil[]; static struct filinfo xx;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -