⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckuusx.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifdef OS2				/* OS/2 */    g = getenv("SYSTEMNAME");    if (!g) g = getenv("HOSTNAME");    if (g) strncpy(vvbuf,g,vvlen);#endif /* OS2 */#endif /* datageneral */#endif /* VMS */#endif /* BSD4 */#endif /* ATTSV */    if (*vvbuf == NUL) {		/* If it's still empty */        g = getenv("HOST");		/* try this */        if (g) strncpy(vvbuf,g,vvlen);    }    vvbuf[vvlen-1] = NUL;		/* Make sure result is terminated. */}#ifdef BSD44#undef BSD4#define ATTSV#endif /* BSD44 */#ifndef NOSPL#define ASKMORE#endif /* NOSPL */#ifndef NOHELP#ifndef ASKMORE#define ASKMORE#endif /* ASKMORE */#endif /* NOHELP */#ifdef ASKMORE/*  A S K M O R E  --  Poor person's "more".  Returns 0 if no more, 1 if more wanted.  Presently used by SHO MAC, SHO GLOB, SHO VAR, and HELP, so compiled out if  those options are also compiled out.*/intaskmore() {    char c; int rv;    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 */	c = coninc(0);	switch (c) {	  /* Yes */	  case SP: case 'y': case 'Y': case 012:  case 015:	    printf("\015      \015");	    rv = 1;	    break;          /* No */	  case 'n': case 'N': case 'q': case 'Q':	    printf("\015\012");	    rv = 0;	    break;	  /* Invalid answer */	  default:	    printf("Y or space-bar for yes, N for no\n");	    continue;	}#ifdef OS2	printf("\r                                         \r");	fflush(stdout);#endif /* OS2 */    }    return(rv);}#endif /* ASKMORE *//*  T R A P  --  Terminal interrupt handler */SIGTYPtrap(sig) int sig; {#ifdef VMS    int i; FILE *f;#endif /* VMS */#ifdef __EMX__  signal(SIGINT, SIG_ACK);#endif#ifdef GEMDOS/* GEM is not reentrant, no i/o from interrupt level */    longjmp(cmjbuf,1);			/* Jump back to parser now! */#endif /* GEMDOS */    debug(F101,"^C trap() caught signal","",sig);    zclose(ZIFILE);			/* If we were transferring a file, */    zclose(ZOFILE);			/* close it. */#ifdef VMS/*  Fix terminal.*/    if (ft_win) {			/* If curses window open */	screen(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 */	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 */    if (ft_win) {			/* If curses window open, */	screen(SCR_CW,0,0L,"");		/* close it. */	printf("^C...");		/* Echo ^C to standard output */    } else {	printf("^C...\n");    }#endif /* VMS */#ifdef datageneral    connoi_mt(); 			/* Kill asynch task that listens to */    ttimoff();				/* the keyboard */    conres();#endif /* datageneral */#ifndef NOCCTRAP#ifdef UNIX    ttimoff();				/* Turn off any timer interrupts */#endif /* UNIX */#ifdef OSK    ttimoff();				/* Turn off any timer interrupts */    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 */    longjmp(cmjbuf,1);			/* Jump back to parser */#else/* 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 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 */SIGTYPstptrap(sig) int sig; {#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;}#ifndef MAC/*  The rest of this file is for all implementations but the Macintosh.*//*  C H K I N T  --  Check for console interrupts  */intchkint() {    int ch, cn; 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    cn = conchk();			/* Any input waiting? */    debug(F101,"conchk","",cn);    if (cn < 1) return(0);    if ((ch = coninc(5)) < 0) return(0);#endif /* datageneral */    switch (ch & 0177) {      case 'A': case 'a': case 0001:		/* Status report */	if (fdispla != XYFD_R && fdispla != XYFD_S)	  return(0);	                        /* Only for serial or simple */	screen(SCR_TN,0,0l,"Status report:");	screen(SCR_TN,0,0l," file type: ");	if (binary) {#ifdef VMS	    if (binary == XYFT_I)		/* VMS-only file types */	      screen(SCR_TZ,0,0l,"image");	    else if (binary == XYFT_L)	      screen(SCR_TZ,0,0l,"labeled");	    else screen(SCR_TZ,0,0l,"binary");#else	    screen(SCR_TZ,0,0l,"binary");#endif /* VMS */	} else {	    screen(SCR_TZ,0,0l,"text");	}	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) {	    zz = ( ffc * 100L ) / fsize;	    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");	return(0);      case 'B': case 'b': case 0002:	/* Cancel batch */      case 'Z': case 'z': case 0032:	screen(SCR_TN,0,0l,"Cancelling Batch ");	czseen = 1;	return(0);      case 'F': case 'f': case 0006:	/* Cancel file */      case 'X': case 'x': case 0030:	screen(SCR_TN,0,0l,"Cancelling File ");	cxseen = 1;	return(0);      case 'R': case 'r': case 0022:	/* Resend */      case 0015: case 0012:	screen(SCR_TN,0,0l,"Resending packet ");	numerrs++;	resend(winlo);	return(1);      case 'E': case 'e':		/* Send error packet */      case 0005:	return(-1);#ifdef datageneral      case '\03':                       /* We're not trapping ^C's with */        trap(0);                        /* signals, so we check here    */#endif /* datageneral */      default:				/* Anything else, print message */	intmsg(1);	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 */ {    char buf[80];    if (!displa || quiet)		/* Not if we're being quiet */      return;    if (server && (!srvdis || n > -1L))	/* Special for server */      return;    buf[0] = NUL;			/* Keep compilers happy */#ifdef SVORPOSIX    conchk();				/* Clear out pending escape-signals */#endif /* SVORPOSIX */#ifdef VMS    conres();				/* So Ctrl-C will work */#endif /* VMS */    if ((!server && n == 1L) || (server && n < 0L)) {#ifdef SVORPOSIX			/* We need to signal before kb input */#ifndef aegis#ifndef datageneral	sprintf(buf,"Type escape character (%s) followed by:",dbchr(escape));	screen(SCR_TN,0,0l,buf);#endif /* datageneral */#endif /* aegis */#endif /* SVORPOSIX */ 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: ");/* 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.. */    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 */#ifdef VMS	if (binary == XYFT_I)		/* VMS-only file types */	  conoll("image");	else if (binary == XYFT_L)	  conoll("labeled");	else#endif /* VMS */	  conoll("binary");    } else conoll("text");    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 *//* showpkt */ {    if (newdpy)				/* Put up filenames, etc, */      dpyinit();			/* if they're not there already. */    if (fdispla == XYFD_S) {		/* CRT display */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -