📄 ckuusx.c
字号:
If a field contains the separator, it is enclosed in doublequotes.*/VOID#ifdef CK_ANSICdoxlog(int x, char * fn, long fs, int fm, int status, char * msg)#elsedoxlog(x, fn, fs, fm, status, msg) int x; char * fn; long fs; int fm; int status; char * msg;#endif /* CK_ANSIC *//* doxlog */ { extern int tlogsep; char sep[2]; char buf[CKMAXPATH+256]; char tmpbuf[32]; char * s, * p; int len; if (!tralog) return; /* If no transaction log, don't */ if (!fn) fn = ""; /* Protect against null pointers */ if (!msg) msg = ""; sep[0] = (char) tlogsep; sep[1] = NUL; if (!sep[0]) sep[0] = ','; p = zzndate(); /* Date and time */ if (p) { ckstrncpy(buf,p,CKMAXPATH); /* Shouldn't be more than 30 chars */ } else { strcpy(buf,"00000000"); } ztime(&p); strcat(buf,sep); strncat(buf,p+11,8); strcat(buf,sep); debug(F110,"doxlog 1",buf,0); strcat(buf, (x == W_SEND) ? "SEND" : "RECV"); /* What */ strcat(buf,sep); debug(F110,"doxlog 2",buf,0); if (ckstrchr(fn,sep[0])) { /* Filename */ strcat(buf,"\""); /* Might contain separator */ strcat(buf,fn); strcat(buf,"\""); } else strcat(buf,fn); strcat(buf,sep); debug(F110,"doxlog 3",buf,0); sprintf(tmpbuf,"%ld",fs); /* Size */ strcat(buf,tmpbuf); strcat(buf,sep); debug(F110,"doxlog 4",buf,0);#ifdef NOICP strcpy(tmpbuf, (binary ? "binary" : "text")); /* Transfer mode */#else strcpy(tmpbuf,gfmode(fm,0)); /* Transfer mode */#endif /* NOICP */ if (ckstrchr(tmpbuf,sep[0])) { /* Might contain spaces */ strcat(buf,"\""); strcat(buf,tmpbuf); strcat(buf,"\""); } else strcat(buf,tmpbuf); strcat(buf,sep); debug(F110,"doxlog 5",buf,0); strcat(buf, status ? "FAILED" : "OK"); len = strlen(buf); debug(F110,"doxlog buf 1", buf, len); s = buf + len; if (status == 0) { long cps;#ifdef GFTIMER cps = (long)((CKFLOAT) fs / fpxfsecs); sprintf(s,"%s\"%0.3fsec %ldcps\"",sep,fpxfsecs,cps);#else cps = fs / xfsecs; sprintf(s,"%s\"%ldsec %ldcps\"",sep,xfsecs,cps);#endif /* GFTIMER */ } else { sprintf(s,"%s\"%s\"",sep,msg); } debug(F110,"doxlog 5",buf,0); x = zsoutl(ZTFILE,buf); debug(F101,"doxlog zsoutl","",x); if (x < 0) tralog = 0;}#endif /* TLOG */#ifndef MAC/* The rest of this file is for all implementations but the Macintosh.*/#ifndef NOXFER/* C H K I N T -- Check for console interrupts *//* Used during file transfer in local mode only: . If user has not touched the keyboard, returns 0 with no side effects. . If user typed S or A (etc, see below) prints status message and returns 0. . If user typed X or F (etc, see below) returns 0 with cxseen set to 1. . If user typed Z or B (etc, see below) returns 0 with czseen set to 1. . If user typed E or C (etc, see below) returns -1.*/#ifdef CK_CURSESstatic int repaint = 0; /* Transfer display needs repainting */#endif /* CK_CURSES */intchkint() { int ch, cn, ofd; long zz; if (!xfrint) return(0); if ((!local) || (quiet)) return(0); /* Only do this if local & not quiet */#ifdef datageneral if (con_reads_mt) /* if conint_mt task is active */ if (conint_avl) { /* and there's an interrupt pending */ cn = 1; /* process it */ ch = conint_ch; conint_avl = 0; /* turn off flag so conint_mt can */ } else /* proceed */ return(0); else /* if conint_mt not active */ if ((ch = coninc(2)) < 0) /* try to get char manually */ return(0); /* I/O error, or no data */ else /* if successful, set cn so we */ cn = 1; /* know we got one */ debug(F101,"chkint got keyboard character",ch,cn);#else /* !datageneral */#ifdef NTSIG { extern int TlsIndex; struct _threadinfo * threadinfo; threadinfo = (struct _threadinfo *) TlsGetValue(TlsIndex); if (threadinfo) { if (!WaitSem(threadinfo->DieSem,0)) return -1; /* Cancel Immediately */ } }#endif /* NTSIG */ cn = conchk(); /* Any input waiting? */ debug(F101,"conchk","",cn); if (cn < 1) return(0); ch = coninc(5) ; debug(F101,"coninc","",ch); if (ch < 0) return(0);#endif /* datageneral */ switch (ch & 0177) { case 'A': case 'a': case 0001: /* Status report */ case 'S': case 's': if (fdispla != XYFD_R && fdispla != XYFD_S && fdispla != XYFD_N) return(0); /* Only for serial, simple or none */ ofd = fdispla; /* [MF] Save file display type */ if (fdispla == XYFD_N) fdispla = XYFD_R; /* [MF] Pretend serial if no display */ xxscreen(SCR_TN,0,0l,"Status report:"); xxscreen(SCR_TN,0,0l," file type: "); if (binary) { switch(binary) { case XYFT_L: xxscreen(SCR_TZ,0,0l,"labeled"); break; case XYFT_I: xxscreen(SCR_TZ,0,0l,"image"); break; case XYFT_U: xxscreen(SCR_TZ,0,0l,"binary undefined"); break; default: case XYFT_B: xxscreen(SCR_TZ,0,0l,"binary"); break; } } else {#ifdef NOCSETS xxscreen(SCR_TZ,0,0l,"text");#else xxscreen(SCR_TU,0,0l,"text, "); if (tcharset == TC_TRANSP) { xxscreen(SCR_TZ,0,0l,"transparent"); } else { if (what == W_SEND) { xxscreen(SCR_TZ,0,0l,tcsinfo[tcharset].keyword); xxscreen(SCR_TU,0,0l," => "); xxscreen(SCR_TZ,0,0l,fcsinfo[fcharset].keyword); } else { xxscreen(SCR_TZ,0,0l,fcsinfo[fcharset].keyword); xxscreen(SCR_TU,0,0l," => "); xxscreen(SCR_TZ,0,0l,tcsinfo[tcharset].keyword); } }#endif /* NOCSETS */ } xxscreen(SCR_QE,0,filcnt," file number"); if (fsize) xxscreen(SCR_QE,0,fsize," size"); xxscreen(SCR_QE,0,ffc," characters so far"); if (fsize > 0L) {#ifdef CK_RESEND zz = what == W_SEND ? sendstart : what == W_RECV ? rs_len : 0; zz = ( (ffc + zz) * 100L ) / fsize;#else zz = ( ffc * 100L ) / fsize;#endif /* CK_RESEND */ xxscreen(SCR_QE,0,zz, " percent done"); } if (bctu == 4) { /* Block check */ xxscreen(SCR_TU,0,0L," block check: "); xxscreen(SCR_TZ,0,0L,"blank-free-2"); } else xxscreen(SCR_QE,0,(long)bctu, " block check"); xxscreen(SCR_QE,0,(long)rptflg," compression"); xxscreen(SCR_QE,0,(long)ebqflg," 8th-bit prefixing"); xxscreen(SCR_QE,0,(long)lscapu," locking shifts"); if (!network) xxscreen(SCR_QE,0, speed, " speed"); if (what == W_SEND) xxscreen(SCR_QE,0,(long)spsiz, " packet length"); else if (what == W_RECV || what == W_REMO) xxscreen(SCR_QE,0,(long)urpsiz," packet length"); xxscreen(SCR_QE,0,(long)wslots, " window slots"); fdispla = ofd; /* [MF] Restore file display type */ return(0); case 'B': case 'b': case 0002: /* Cancel batch */ case 'Z': case 'z': case 0032: czseen = 1; interrupted = 1; xxscreen(SCR_ST,ST_MSG,0l, (((what == W_RECV) && (wslots > 1)) ? "Canceling batch, wait... " : "Canceling batch... ") ); return(0); case 'F': case 'f': case 0006: /* Cancel file */ case 'X': case 'x': case 0030: cxseen = 1; interrupted = 1; xxscreen(SCR_ST,ST_MSG,0l, (((what == W_RECV) && (wslots > 1)) ? "Canceling file, wait... " : "Canceling file... ") ); return(0); case 'R': case 'r': case 0022: /* Resend packet */ case 0015: case 0012:#ifdef STREAMING if (streaming) return(0);#endif /* STREAMING */ xxscreen(SCR_ST,ST_MSG,0l,"Resending packet... "); numerrs++; resend(winlo); return(0);#ifdef datageneral case '\03': /* We're not trapping ^C's with */ trap(0); /* signals, so we check here */#endif /* datageneral */ case 'C': case 'c': /* Ctrl-C */#ifndef datageneral case '\03':#endif /* datageneral */ case 'E': case 'e': /* Send error packet */ case 0005: interrupted = 1; return(-1);#ifdef CK_CURSES case 0014: /* Ctrl-L to refresh screen */ case 'L': case 'l': /* Also accept L (upper, lower) */ case 0027: /* Ctrl-W synonym for VMS & Ingres */ repaint = 1; return(0);#endif /* CK_CURSES */ default: /* Anything else, print message */ intmsg(1L); return(0); }}/* I N T M S G -- Issue message about terminal interrupts */VOID#ifdef CK_ANSICintmsg(long n)#elseintmsg(n) long n;#endif /* CK_ANSIC *//* intmsg */ {#ifdef CK_NEED_SIG char buf[80];#endif /* CK_NEED_SIG */ if (!displa || quiet) /* Not if we're being quiet */ return; if (server && (!srvdis || n > -1L)) /* Special for server */ return;#ifdef CK_NEED_SIG buf[0] = NUL; /* Keep compilers happy */#endif /* CK_NEED_SIG */#ifndef OXOS#ifdef SVORPOSIX conchk(); /* Clear out pending escape-signals */#endif /* SVORPOSIX */#endif /* ! OXOS */#ifdef VMS conres(); /* So Ctrl-C will work */#endif /* VMS */ if ((!server && n == 1L) || (server && n < 0L)) {#ifdef CK_NEED_SIG if (xfrint) { sprintf(buf, "Type escape character (%s) followed by:", dbchr(escape) ); xxscreen(SCR_TN,0,0l,buf); }#endif /* CK_NEED_SIG */ if (xfrint) { if (protocol == PROTO_K) { xxscreen(SCR_TN,0,0l,"X to cancel file, CR to resend current packet"); xxscreen(SCR_TN,0,0l,"Z to cancel group, A for status report"); xxscreen(SCR_TN,0,0l,"E to send Error packet, Ctrl-C to quit immediately: "); } else { xxscreen(SCR_TN,0,0l,"Ctrl-C to cancel file transfer: "); } } else { xxscreen(SCR_TN,0,0l,"Transfer interruption disabled. "); } } else xxscreen(SCR_TU,0,0l," ");}#ifndef NODISPLAYstatic int newdpy = 0; /* New display flag */static char fbuf[80]; /* Filename buffer */static char abuf[80]; /* As-name buffer */static char a2buf[80]; /* Second As-name buffer */static long oldffc = 0L;static long dots = 0L;static int hpos = 0;static VOID /* Initialize Serial or CRT display */dpyinit() { int m = 0, n = 0; char * s = ""; newdpy = 0; /* Don't do this again */ oldffc = 0L; /* Reset this */ dots = 0L; /* and this.. */ oldcps = cps = 0L; conoll(""); /* New line */ if (what == W_SEND) s = "Sending: "; /* Action */ else if (what == W_RECV) s = "Receiving: "; n = (int)strlen(s) + (int)strlen(fbuf); conol(fbuf); m = (int)strlen(abuf) + 4; if (n + m > cmd_cols) { conoll(""); n = 0; } else n += m; if (*abuf) { conol(" => "); conol(abuf); } m = (int)strlen(a2buf) + 4; if (n + m > cmd_cols) { conoll(""); n = 0; } else n += m; if (*a2buf) { conol(" => "); conol(a2buf); } *fbuf = NUL; *abuf = NUL; *a2buf = NUL; conoll(""); if (fsize > -1L) { /* Size */ sprintf(fbuf,"Size: %ld, Type: ",fsize); conol(fbuf); *fbuf = NUL; } else conol("Size: unknown, Type: "); if (binary) { /* Type */ switch(binary) { case XYFT_L: conoll("labeled"); break; case XYFT_I: conoll("image"); break; case XYFT_U: conoll("binary undefined"); break; default: case XYFT_B: conoll("binary"); break; } } else {#ifdef NOCSETS conoll("text");#else conol("text, "); if (tcharset == TC_TRANSP) { conoll("transparent"); } else { if (what == W_SEND) { conol(fcsinfo[fcharset].keyword); conol(" => "); conoll(tcsinfo[tcharset].keyword); } else { conol(tcsinfo[tcharset].keyword); conol(" => "); conoll(fcsinfo[fcharset].keyword); } }#endif /* NOCSETS */ } if (fdispla == XYFD_S) { /* CRT field headings *//* Define CK_CPS to show current transfer rate. Leave it undefined to show estimated time remaining. Estimated-time-remaining code from Andy Fyfe, not tested on pathological cases.*/#define CK_CPS#ifdef CK_CPS conoll(" File Percent Packet"); conoll(" Bytes Done CPS Length");#else conoll(" File Percent Secs Packet"); conoll(" Bytes Done Left Length");#endif /* CK_CPS */ newdpy = 0; } hpos = 0;}/* showpkt(c) c = completion code: 0 means transfer in progress, nonzero means it's done. Show the file transfer progress counter and perhaps verbose packet type.*/VOID#ifdef CK_ANSICshowpkt(char c)#elseshowpkt(c) char c;#endif /* CK_ANSIC *//* showpkt */ { long howfar; /* How far into file */ long et; /* Elapsed time, entire batch */ long pd; /* Percent done, this file */ long tp; /* Transfer rate, entire batch */ long ps; /* Packet size, current packet */ long mytfc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -