📄 ckuusx.c
字号:
variables.*/#endif /* OSK */#ifdef NTSIG PostCtrlCSem();#else /* NTSIG */#ifdef NT cklongjmp(ckjaddr(cmjbuf),1);#else /* NT */ cklongjmp(cmjbuf,1);#endif /* NT */#endif /* NTSIG */#else /* NOCCTRAP *//* No Ctrl-C trap, just exit. */#ifdef CK_CURSES /* Curses support? */ screen(SCR_CW,0,0L,""); /* Close curses window */#endif /* CK_CURSES */ doexit(BAD_EXIT,what); /* Exit poorly */#endif /* NOCCTRAP */ SIGRETURN;}/* C K _ T I M E -- Returns pointer to current time. */char *ck_time() { static char tbuf[10]; char *p; int x; ztime(&p); /* "Thu Feb 8 12:00:00 1990" */ if (!p) /* like asctime()! */ return(""); if (*p) { for (x = 11; x < 19; x++) /* copy hh:mm:ss */ tbuf[x - 11] = p[x]; /* to tbuf */ tbuf[8] = NUL; /* terminate */ } return(tbuf); /* and return it */}/* C C _ C L E A N -- Cleanup after terminal interrupt handler */#ifdef GEMDOSintcc_clean() { zclose(ZIFILE); /* If we were transferring a file, */ zclose(ZOFILE); /* close it. */ printf("^C...\n"); /* Not VMS, no problem... */}#endif /* GEMDOS *//* S T P T R A P -- Handle SIGTSTP (suspend) signals */SIGTYP#ifdef CK_ANSICstptrap(int sig)#else stptrap(sig) int sig;#endif /* CK_ANSIC *//* stptrap */ {#ifndef NOJC int x; extern int cmflgs; debug(F101,"stptrap() caught signal","",sig); if (!suspend) { printf("\r\nsuspend disabled\r\n");#ifndef NOICP if (what == W_COMMAND) { /* If we were parsing commands */ prompt(xxstring); /* reissue the prompt and partial */ if (!cmflgs) /* command (if any) */ printf("%s",cmdbuf); }#endif /* NOICP */ } else { conres(); /* Reset the console */#ifndef OS2 /* Flush pending output first, in case we are continued */ /* in the background, which could make us block */ fflush(stdout); x = psuspend(suspend); /* Try to suspend. */ if (x < 0)#endif /* OS2 */ printf("Job control not supported\r\n"); conint(trap,stptrap); /* Rearm the trap. */ debug(F100,"stptrap back from suspend","",0); switch (what) { case W_CONNECT: /* If suspended during CONNECT? */ conbin((char)escape); /* put console back in binary mode */ debug(F100,"stptrap W_CONNECT","",0); break;#ifndef NOICP case W_COMMAND: /* Suspended in command mode */ debug(F101,"stptrap W_COMMAND pflag","",pflag); concb((char)escape); /* Put back CBREAK tty mode */ if (pflag) { /* If command parsing was */ prompt(xxstring); /* reissue the prompt and partial */ if (!cmflgs) /* command (if any) */ printf("%s",cmdbuf); } break;#endif /* NOICP */ default: /* All other cases... */ debug(F100,"stptrap default","",0); concb((char)escape); /* Put it back in CBREAK mode */ break; } }#endif /* NOJC */ SIGRETURN;}#ifdef TLOG#define TBUFL 300/* T L O G -- Log a record in the transaction file *//* Call with a format and 3 arguments: two strings and a number: f - Format, a bit string in range 0-7, bit x is on, arg #x is printed. s1,s2 - String arguments 1 and 2. n - Int, argument 3.*/VOID#ifdef CK_ANSICtlog(int f, char *s1, char *s2, long n)#elsetlog(f,s1,s2,n) int f; long n; char *s1, *s2;#endif /* CK_ANSIC *//* tlog */ { static char s[TBUFL]; char *sp = s; int x; if (!tralog) return; /* If no transaction log, don't */ switch (f) { case F000: /* 0 (special) "s1 n s2" */ if ((int)strlen(s1) + (int)strlen(s2) + 15 > TBUFL) sprintf(sp,"?T-Log string too long"); else sprintf(sp,"%s %ld %s",s1,n,s2); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; case F001: /* 1, " n" */ sprintf(sp," %ld",n); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; case F010: /* 2, "[s2]" */ x = (int)strlen(s2); if (s2[x] == '\n') s2[x] = '\0'; if (x + 6 > TBUFL) sprintf(sp,"?String too long"); else sprintf(sp,"[%s]",s2); if (zsoutl(ZTFILE,"") < 0) tralog = 0; break; case F011: /* 3, "[s2] n" */ x = (int)strlen(s2); if (s2[x] == '\n') s2[x] = '\0'; if (x + 6 > TBUFL) sprintf(sp,"?String too long"); else sprintf(sp,"[%s] %ld",s2,n); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; case F100: /* 4, "s1" */ if (zsoutl(ZTFILE,s1) < 0) tralog = 0; break; case F101: /* 5, "s1: n" */ if ((int)strlen(s1) + 15 > TBUFL) sprintf(sp,"?String too long"); else sprintf(sp,"%s: %ld",s1,n); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; case F110: /* 6, "s1 s2" */ x = (int)strlen(s2); if (s2[x] == '\n') s2[x] = '\0'; if ((int)strlen(s1) + x + 4 > TBUFL) sprintf(sp,"?String too long"); else sprintf(sp,"%s %s",s1,s2); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; case F111: /* 7, "s1 s2: n" */ x = (int)strlen(s2); if (s2[x] == '\n') s2[x] = '\0'; if ((int)strlen(s1) + x + 15 > TBUFL) sprintf(sp,"?String too long"); else sprintf(sp,"%s %s: %ld",s1,s2,n); if (zsoutl(ZTFILE,s) < 0) tralog = 0; break; default: sprintf(sp,"?Invalid format for tlog() - %ld",n); if (zsoutl(ZTFILE,s) < 0) tralog = 0; }}#endif /* TLOG */#ifndef MAC/* The rest of this file is for all implementations but the Macintosh.*//* C H K I N T -- Check for console interrupts */#ifdef CK_CURSESstatic int repaint = 0; /* Transfer display needs repainting */#endif /* CK_CURSES */intchkint() { int ch, cn, ofd; long zz; 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 */ screen(SCR_TN,0,0l,"Status report:"); screen(SCR_TN,0,0l," file type: "); if (binary) { switch(binary) { case XYFT_L: screen(SCR_TZ,0,0l,"labeled"); break; case XYFT_I: screen(SCR_TZ,0,0l,"image"); break; case XYFT_U: screen(SCR_TZ,0,0l,"binary undefined"); break; default: case XYFT_B: screen(SCR_TZ,0,0l,"binary"); break; } } else {#ifdef NOCSETS screen(SCR_TZ,0,0l,"text");#else screen(SCR_TU,0,0l,"text, "); if (tcharset == TC_TRANSP) { screen(SCR_TZ,0,0l,"transparent"); } else { if (what == W_SEND) { screen(SCR_TZ,0,0l,tcsinfo[tcharset].keyword); screen(SCR_TU,0,0l," => "); screen(SCR_TZ,0,0l,fcsinfo[fcharset].keyword); } else { screen(SCR_TZ,0,0l,fcsinfo[fcharset].keyword); screen(SCR_TU,0,0l," => "); screen(SCR_TZ,0,0l,tcsinfo[tcharset].keyword); } }#endif /* NOCSETS */ } screen(SCR_QE,0,filcnt," file number"); if (fsize) screen(SCR_QE,0,fsize," size"); screen(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 */ screen(SCR_QE,0,zz, " percent done"); } if (bctu == 4) { /* Block check */ screen(SCR_TU,0,0L," block check: "); screen(SCR_TZ,0,0L,"blank-free-2"); } else screen(SCR_QE,0,(long)bctu, " block check"); screen(SCR_QE,0,(long)rptflg," compression"); screen(SCR_QE,0,(long)ebqflg," 8th-bit prefixing"); screen(SCR_QE,0,(long)lscapu," locking shifts"); if (!network) screen(SCR_QE,0, speed, " speed"); if (what == W_SEND) screen(SCR_QE,0,(long)spsiz, " packet length"); else if (what == W_RECV || what == W_REMO) screen(SCR_QE,0,(long)urpsiz," packet length"); screen(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: screen(SCR_ST,ST_MSG,0l, (what == W_RECV && wslots > 1) ? "Canceling batch, wait... " : "Canceling batch... " ); czseen = 1; return(0); case 'F': case 'f': case 0006: /* Cancel file */ case 'X': case 'x': case 0030: screen(SCR_ST,ST_MSG,0l, (what == W_RECV && wslots > 1) ? "Canceling file, wait... " : "Canceling file... " ); cxseen = 1; return(0); case 'R': case 'r': case 0022: /* Resend packet */ case 0015: case 0012: screen(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: 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 sprintf(buf,"Type escape character (%s) followed by:",dbchr(escape)); screen(SCR_TN,0,0l,buf);#endif /* CK_NEED_SIG */ if ( protocol == PROTO_K ) { screen(SCR_TN,0,0l,"X to cancel file, CR to resend current packet"); screen(SCR_TN,0,0l,"Z to cancel group, A for status report"); screen(SCR_TN,0,0l,"E to send Error packet, Ctrl-C to quit immediately: "); } else { screen(SCR_TN,0,0l,"Ctrl-C to cancel file transfer: "); }/* if (server) */ screen(SCR_TN,0,0l,""); } else screen(SCR_TU,0,0l," ");}static int newdpy = 0; /* New display flag */static char fbuf[80]; /* Filename buffer */static char abuf[80]; /* As-name buffer */static long oldffc = 0L;static long dots = 0L;static int hpos = 0;static VOID /* Initialize Serial or CTR display */dpyinit() { 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) conol("Sending: "); /* Action */ else if (what == W_RECV) conol("Receiving: "); conol(fbuf); if (*abuf) conol(" => "); conoll(abuf); /* Names */ *fbuf = NUL; *abuf = NUL; 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. Original by: Kai Uwe Rommel.*/VOID#ifdef CK_ANSICshowpkt(char c)#elseshowpkt(c) char c;#endif /* CK_ANSIC */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -