📄 ckuusx.c
字号:
*/intaskmore() { char c; int rv;#ifdef IKSD int cx; extern int timelimit;#endif /* IKSD */#ifdef NOICP return(1);#else if (!xaskmore) return(1);#ifdef VMS if (batch) return(1);#else#ifdef UNIX if (backgrd) return(1);#endif /* UNIX */#endif /* VMS */ concb((char)escape); /* Force CBREAK mode. */ rv = -1; while (rv < 0) {#ifndef OS2 printf("more? ");#ifdef UNIX#ifdef NOSETBUF fflush(stdout);#endif /* NOSETBUF */#endif /* UNIX */#else printf("more? (Y or space-bar for yes, N for no) "); fflush(stdout);#endif /* OS2 */#ifdef IKSD if (inserver) { cx = cmdgetc(timelimit); if (cx < -1 && timelimit) { printf("\n?IKS idle timeout - Goodbye.\n"); doexit(GOOD_EXIT,0); } c = (char) cx; } else#endif /* IKSD */ c = (char) cmdgetc(0); switch (c) { /* Yes */ case SP: case 'y': case 'Y': case 012: case 015:#ifdef OSK write(1, "\015 \015", sizeof "\015 \015" - 1);#else printf("\015 \015");#endif /* OSK */ rv = 1; break; /* No */ case 'n': case 'N': case 'q': case 'Q':#ifdef OSK printf("\n");#else printf("\015\012");#endif /* OSK */ rv = 0; break; /* Invalid answer */ default: debug(F111,"askmore","invalid answer",c); printf("Y or space-bar for yes, N for no\n"); continue; }#ifdef OS2 printf("\r \r"); fflush(stdout);#endif /* OS2 */ } return(rv);#endif /* NOICP */}/* T R A P -- Terminal interrupt handler */SIGTYP#ifdef CK_ANSICtrap(int sig)#elsetrap(sig) int sig;#endif /* CK_ANSIC *//* trap */ { extern int b_save, f_save;#ifndef NOICP extern int timelimit;#endif /* NOICP */#ifdef OS2 extern int os2gks; int i;#endif /* OS2 */#ifndef NOSPL extern int i_active, instatus;#endif /* NOSPL */#ifdef VMS int i; FILE *f;#endif /* VMS */ extern int zchkod, zchkid;#ifdef NTSIG connoi();#endif /* NTSIG */#ifdef __EMX__ signal(SIGINT, SIG_ACK);#endif#ifdef GEMDOS/* GEM is not reentrant, no i/o from interrupt level */ cklongjmp(cmjbuf,1); /* Jump back to parser now! */#endif /* GEMDOS */ debug(F101,"trap signal","",sig);#ifndef NOICP timelimit = 0; /* In case timed ASK interrupted */#endif /* NOICP */ zchkod = 0; /* Or file expansion interrupted... */ zchkid = 0; interrupted = 1; if (what == W_CONNECT) { /* Are we in CONNECT mode? *//* The HP workstation Reset key sends some kind of ueber-SIGINT that can not be SIG_IGNored, so we wind up here somehow (even though this is *not* the current SIGINT handler). Just return.*/ debug(F101,"trap: SIGINT caught during CONNECT","",sig); SIGRETURN; }#ifndef NOSPL if (i_active) { /* INPUT command was active? */ i_active = 0; /* Not any more... */ instatus = INP_UI; /* INPUT status = User Interrupted */ }#endif /* NOSPL */#ifndef NOXFER ftreset(); /* Restore global protocol settings */ binary = b_save; /* Then restore these */ fncnv = f_save; bye_active = 0;#endif /* NOXFER */ zclose(ZIFILE); /* If we were transferring a file, */ zclose(ZOFILE); /* close it. */#ifndef NOICP cmdsquo(cmd_quoting); /* If command quoting was turned off */ if (saveask > -1) { xaskmore = saveask; saveask = -1; }#endif /* NOICP */#ifdef CK_APC delmac("_apc_commands"); apcactive = APC_INACTIVE;#endif /* CK_APC */#ifdef VMS/* Fix terminal.*/ if (ft_win) { /* If curses window open */ debug(F100,"^C trap() curses","",0); xxscreen(SCR_CW,0,0L,""); /* Close it */ conres(); /* Restore terminal */ i = printf("^C..."); /* Echo ^C to standard output */ } else { conres(); i = printf("^C...\n"); /* Echo ^C to standard output */ } if (i < 1 && ferror(stdout)) { /* If there was an error */ debug(F100,"^C trap() error","",0); fclose(stdout); /* close standard output */ f = fopen(dftty, "w"); /* open the controlling terminal */ if (f) stdout = f; /* and make it standard output */ printf("^C...\n"); /* and echo the ^C again. */ }#else /* Not VMS */#ifdef STRATUS conres(); /* Set console back to normal mode */#endif /* STRATUS */#ifndef NOXFER if (ft_win) { /* If curses window open, */ debug(F100,"^C trap() curses","",0); xxscreen(SCR_CW,0,0L,""); /* close it. */ printf("^C..."); /* Echo ^C to standard output */ } else {#endif /* NOXFER */ printf("^C...\n");#ifndef NOXFER }#endif /* NOXFER */#endif /* VMS */#ifdef datageneral connoi_mt(); /* Kill asynch task that listens to */ ttimoff(); conres(); /* the keyboard */#endif /* datageneral */#ifndef NOCCTRAP/* This is stupid -- every version should have ttimoff()... */#ifdef UNIX ttimoff(); /* Turn off any timer interrupts */#else#ifdef OSK ttimoff(); /* Turn off any timer interrupts */#else#ifdef STRATUS ttimoff(); /* Turn off any timer interrupts */#else#ifdef OS2 os2gks = 1; /* Turn back on keycode mapping */ for (i = 0; i < VNUM; i++) VscrnResetPopup(i);#ifdef TCPSOCKET#ifdef NT /* WSAIsBlocking() returns FALSE in Win95 during a blocking accept call */ if ( WSASafeToCancel /* && WSAIsBlocking() */ ) { WSACancelBlockingCall(); }#endif /* NT */#endif /* TCPSOCKET */#ifdef CK_NETBIOS NCBCancelOutstanding();#endif /* CK_NETBIOS */ ttimoff(); /* Turn off any timer interrupts */#else#ifdef VMS ttimoff(); /* Turn off any timer interrupts */#endif /* VMS */#endif /* OS2 */#endif /* STRATUS */#endif /* OSK */#endif /* UNIX */#ifdef OSK sigmask(-1);/* We are in an intercept routine but do not perform a F$RTE (done implicitly but rts). We have to decrement the sigmask as F$RTE does. Warning: longjump only restores the cpu registers, NOT the fpu registers. So don't use fpu at all or at least don't use common fpu (double or float) register 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? */ xxscreen(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)#elsestptrap(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_ANSICdotlog(int f, char *s1, char *s2, long n)#elsedotlog(f,s1,s2,n) int f; long n; char *s1, *s2;#endif /* CK_ANSIC *//* dotlog */ { static char s[TBUFL]; char *sp = s; int x; if (!s1) s1 = ""; if (!s2) s2 = ""; 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; }}/* D O X L O G This is the transaction-log writer for BRIEF format. The idea is produce one record (line) per file. Each record has the following delimited fields: Date (yyyymmdd) Time (hh:mm:ss) Action: SEND or RECV File name File size Transfer mode (text, binary, image, labeled, etc). Status: OK or FAILED Free-form comments in doublequotes The default separator is comma.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -