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

📄 ckuus4.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
    int i;/* Misleading... */    printf("\nAvailable Languages:\n");    for (i = 0; i < MAXLANG; i++) {	printf(" %s\n",langs[i].description);    }#else    printf("\nLanguage-specific translation rules: %s\n",	   language == L_USASCII ? "none" : langs[language].description);    shocharset();    printf("\n\n");#endif /* COMMENT */}VOIDshocharset() {    int x;    printf("\n File Character-Set: %s (",fcsinfo[fcharset].name);    if ((x = fcsinfo[fcharset].size) == 128) printf("7-bit)");    else if (x == 256) printf("8-bit)");    else printf("(multibyte)");    printf("\n Transfer Character-Set");#ifdef COMMENT    if (tslevel == TS_L2)      printf(": (international)");    else#endif /* COMMENT */    if (tcharset == TC_TRANSP)      printf(": Transparent");    else      printf(": %s",tcsinfo[tcharset].name);}#endif /* NOCSETS */VOIDshopar() {#ifndef MAC    printf("\n%s,%s\n",versio,ckxsys);#endif /* MAC */    shoparc();    shoparp();    shoparf();}#endif /* NOSHOW *//*  D O S T A T  --  Display file transfer statistics.  */intdostat() {    printf("\nMost recent transaction --\n");    printf("\n files: %ld\n",filcnt);    printf(" characters last file   : %ld\n",ffc);    printf(" total file characters  : %ld\n",tfc);    printf(" communication line in  : %ld\n",tlci);    printf(" communication line out : %ld\n",tlco);    printf(" packets sent           : %d\n", spackets);    printf(" packets received       : %d\n", rpackets);    printf(" damaged packets rec'd  : %d\n", crunched);    printf(" timeouts               : %d\n", timeouts);    printf(" retransmissions        : %d\n", retrans);    if (filcnt > 0) {	printf(" parity                 : %s",parnam((char)parity));	if (autopar) printf(" (detected automatically)");	printf("\n 8th bit prefixing      : ");	if (ebqflg) printf("yes [%c]\n",ebq); else printf("no\n");	printf(" locking shifts         : %s\n", lscapu ? "yes" : "no");	printf(" window slots used      : %d of %d\n", wmax, wslotr);	printf(" packet length          : %d (send), %d (receive)\n",	       spmax, urpsiz);	printf(" compression            : ");	if (rptflg) printf("yes [%c] (%d)\n",rptq,rptn); else printf("no\n");	if (bctu == 4)	  printf(" block check type used  : blank-free-2\n");	else	  printf(" block check type used  : %d\n",bctu);	printf(" elapsed time           : %d sec\n",tsecs);	if (speed <= 0L) speed = ttgspd();	if (speed > 0L) {	    if (speed == 8880)	      printf(" transmission rate      : 75/1200 bps\n");	    else	      printf(" transmission rate      : %ld bps\n",speed);	}	if (tsecs > 0) {	    long lx;	    lx = (tfc * 10L) / (long) tsecs;	    printf(" effective data rate    : %ld cps\n",lx/10L);	    if (speed > 0L && speed != 8880L && network == 0) {		lx = (lx * 100L) / speed;		printf(" efficiency (percent)   : %ld\n",lx);	    }#ifdef COMMENT	    lx = (tlci * 10L) / (long) tsecs;	    printf(" throughput (in)        : %ld cps\n",lx/10l);	    lx = (tlco * 10L) / (long) tsecs;	    printf(" throughput (out)       : %ld cps\n",lx/10l);#endif /* COMMENT */	}    }    return(1);}/*  D O C O N E C T  --  Do the connect command  *//*  Note, we don't call this directly from dial, because we need to give *//*  the user a chance to change parameters (e.g. parity) after the *//*  connection is made. */intdoconect() {    int x;    conres();				/* Put console back to normal */    x = conect();			/* Connect */    concb((char)escape);		/* Put console into cbreak mode, */    return(x);				/* for more command parsing. */}#ifndef NOSPL/* The INPUT command */#ifdef NETCONNextern int tn_init;#ifndef IAC#define IAC 255#endif /* IAC */#endif /* NETCONN */intdoinput(timo,s) int timo; char *s; {    int x, y, i, t, icn, anychar;    int lastchar = 0;    char *xp, *xq = (char *)0;    CHAR c;    if (local) {			/* Put line in "ttvt" mode */	y = ttvt(speed,flow);		/* if not already. */	if (y < 0) {	    printf("?Can't condition line for INPUT\n");	    return(0);			/* Watch out for failure. */	}    }    if (!s) s = "";    y = (int)strlen(s);			/* If search string is empty */    anychar = (y < 1);			/* any input character will do. */    debug(F111,"doinput",s,y);    if (timo <= 0) timo = 1;		/* Give at least 1 second timeout */    x = 0;				/* Return code, assume failure */    i = 0;				/* String pattern match position */    if (!incase) {			/* INPUT CASE = IGNORE?  */	xp = malloc(y+2);		/* Make a separate copy of the */	if (!xp) {			/* input string for editing. */	    printf("?malloc error 5\n");	    return(x);	} else xq = xp;			/* Save pointer to beginning */	while (*s) {			/* Convert to lowercase */	    *xp = *s;	    if (isupper(*xp)) *xp = tolower(*xp);	    xp++; s++;	}	*xp = NUL;			/* Terminate the search string. */	s = xq;				/* Point back to beginning. */    }    inpbps = inpbp;			/* Save current pointer. */    rtimer();				/* Reset timer. */    t = 0;				/* Time is 0. */    incount = 0;			/* Character counter */    while (1) {				/* Character-getting loop */	if (local) {			/* One case for local */	    y = ttinc(1);		/* Get character from comm line. */	    debug(F101,"input ttinc(1) returns","",y);	    if (icn = conchk()) {	/* Interrupted from keyboard? */		debug(F101,"input interrupted from keyboard","",icn);		while (icn--) coninc(0); /* Yes, read what was typed. */		break;			/* And fail. */	    }	} else {			/* Another for remote */	    y = coninc(1);	    debug(F101,"input coninc(1) returns","",y);	}	if (y > -1) {			/* A character arrived */#ifdef TNCODE/* Check for telnet protocol negotiation */	    if (network && (ttnproto == NP_TELNET) && ((y & 0xff) == IAC)) {		switch (tn_doop((CHAR)(y & 0xff),duplex,ttinc)) {		  case 2: duplex = 0; continue;		  case 1: duplex = 1;		  default: continue;		}	    }#endif /* TNCODE */	    /* Real input character to be checked */	    c = cmask & (CHAR) y;	/* Mask off parity */	    inchar[0] = c;		/* Remember character for \v(inchar) */	    lastchar = gtimer();	/* Remember when it came. */	    if (c == '\0') {		/* NUL, we can't use it */		if (anychar) {		/* Any character will do? */		    x = 1;		/* Yes, done. */		    incount = 1;	/* This must be the first and only. */		    break;		} else continue;	/* Otherwise continue INPUTting */	    }	    *inpbp++ = c;		/* Store char in circular buffer */	    incount++;			/* Count it for \v(incount) */	    if (inpbp >= inpbuf + INPBUFSIZ) { /* Time to wrap around? */		inpbp = inpbuf;		/* Yes. */		*(inpbp+INPBUFSIZ) = NUL; /* Make sure it's null-terminated. */	    }#ifdef MAC	    {		extern char *ttermw;	/* fake pointer cast */		if (inecho) {		    outchar(ttermw, c);	/* echo to terminal window */		    /* this might be too much overhead to do here ? */		    updatecommand(ttermw);		}	    }#else /* Not MAC */	    if (inecho) conoc(c);	/* Echo and log the input character */#endif /* MAC */	    if (seslog) {#ifdef UNIX		if (sessft != 0 || c != '\r')#endif /* UNIX */		  if (zchout(ZSFILE,c) < 0) seslog = 0;	    }	    if (anychar) {		/* Any character will do? */		x = 1;		break;	    }	    if (!incase) {		/* Ignore alphabetic case? */		if (isupper(c)) c = tolower(c); /* Yes */	    }	    debug(F000,"doinput char","",c);	    debug(F000,"compare char","",s[i]);	    if (c == s[i]) {		/* Check for match */		i++;			/* Got one, go to next character */	    } else {			/* Don't have a match */   		int j, size;   		for (j = i; i-- > 0; ) { /* [jrs] search backwards */   		    if (c == s[i]) {   			size = j - i;   			if (strncmp(s,&s[j-i],i-size)== 0)			  break;   		    }   		}   		i++;			/* [jrs] count last char matched    */   	    }				/* [jrs] or return to zero from -1  */	    if (s[i] == '\0') {		/* Matched all the way to end? */		x = 1;			/* Yes, */		break;			/* done. */	    }	}	if ((t = gtimer()) > timo)	/* Did not match, timer exceeded? */	  break;	else if (insilence > 0 && (t - lastchar) > insilence)	  break;    }					/* Still have time left, continue. */    if (!incase) if (xq) free(xq);	/* Done, free dynamic memory. */    return(x);				/* Return the return code. */}#endif /* NOSPL */#ifndef NOSPL/* REINPUT Command *//* Note, the timeout parameter is required, but ignored. *//* Syntax is compatible with MS-DOS Kermit except timeout can't be omitted. *//* This function only looks at the characters already received *//* and does not read any new characters from the communication line. */intdoreinp(timo,s) int timo; char *s; {    int x, y, i;    char *xx, *xp, *xq = (char *)0;    CHAR c;    y = (int)strlen(s);    debug(F111,"doreinput",s,y);    x = 0;				/* Return code, assume failure */    i = 0;				/* String pattern match position */    if (!incase) {			/* INPUT CASE = IGNORE?  */	xp = malloc(y+2);		/* Make a separate copy of the */	if (!xp) {			/* search string. */	    printf("?malloc error 6\n");	    return(x);	} else xq = xp;			/* Keep pointer to beginning. */	while (*s) {			/* Yes, convert to lowercase */	    *xp = *s;	    if (isupper(*xp)) *xp = tolower(*xp);	    xp++; s++;	}	*xp = NUL;			/* Terminate it! */	s = xq;				/* Move search pointer to it. */    }    xx = inpbp;				/* Current INPUT buffer pointer */    do {	c = *xx++;			/* Get next character */	if (xx >= inpbuf + INPBUFSIZ) xx = inpbuf; /* Wrap around */	if (!incase) {			/* Ignore alphabetic case? */	    if (isupper(c)) c = tolower(c); /* Yes */	}	debug(F000,"doreinp char","",c);	debug(F000,"compare char","",s[i]);	if (c == s[i]) {		/* Check for match */	    i++;			/* Got one, go to next character */	} else {			/* Don't have a match */   	    int j, size;   	    for (j = i; i-- > 0; ) { /* [jrs] search backwards for it  */   		if (c == s[i]) {		    size = j - i;		    if (strncmp(s,&s[j-i],i-size)== 0)		      break;		}   	    }   	    i++;			/* [jrs] count last char matched */   	}				/* [jrs] or return to zero from -1 */	if (s[i] == '\0') {		/* Matched all the way to end? */	    x = 1;			/* Yes, */	    break;			/* done. */	}    } while (xx != inpbp);		/* Until back where we started. */    if (!incase) if (xq) free(xq);	/* Free this if it was malloc'd. */    return(x);				/* Return search result. */}#ifndef NOSPL#endif /* NOSPL *//*  X X S T R I N G  --  Interpret strings containing backslash escapes  *//* Copies result to new string.  strips enclosing braces or doublequotes.  interprets backslash escapes.  returns 0 on success, nonzero on failure.  tries to be compatible with MS-DOS Kermit. Syntax of input string:  string = chars | "chars" | {chars}  chars = (c*e*)*  where c = any printable character, ascii 32-126  and e = a backslash escape  and * means 0 or more repetitions of preceding quantity  backslash escape = \operand  operand = {number} | number | fname(operand) | v(name) | $(name) | m(name)  number = [r]n[n[n]]], i.e. an optional radix code followed by 1-3 digits  radix code is oO (octal), hHxX (hex), dD or none (decimal).*/#ifndef NOFRILLSintyystring(s,s2) char *s; char **s2; {	/* Reverse a string */    int x;    static char *new;    new = *s2;    if (!s || !new) return(-1);		/* Watch out for null pointers. */    if ((x = (int)strlen(s)) == 0) {	/* Recursion done. */	*new = '\0';	return(0);    }    x--;				/* Otherwise, call self */    *new++ = s[x];			/* to reverse rest of string. */    s[x] = 0;    return(yystring(s,&new));}#endif /* NOFRILLS */#define FNVALL 1000char fnval[FNVALL+2];			/* Return value */char *					/* Evaluate builtin function */fneval(fn,argp,argn) char *fn, *argp[]; int argn; {    int i, j, k, len1, len2, n, x, y;    char *bp[FNARGS];			/* Pointers to malloc'd strings */    char *p, *s;    if (!fn) fn = "";			/* Paranoia */    debug(F111,"fneval",fn,argn);    debug(F110,"fneval",argp[0],0);    y = lookup(fnctab,fn,nfuncs,&x);    if (y < 0)				/* bad function name */      return("");			/* so value is null */#ifdef DEBUG    if (deblog) {	int j;	for (j = 0; j < argn; j++)	  debug(F111,"fneval function arg",argp[j],j);    }#endif /* DEBUG */    if (y == FN_LIT)			/* literal(arg1) */      return(argp[0] ? argp[0] : "");	/* return a pointer to arg itself */    if (y == FN_CON) {			/* Contents of variable, unexpanded. */	char c;	if (!(p = argp[0]) || !*p) return("");	if (*p == CMDQ) p++;	if ((c = *p) == '%') {		/* Scalar variable. */	    c = *++p;			/* Get ID character. */	    p = "";			/* Assume definition is empty */	    if (!c) return(p);		/* Double paranoia */	    if (c >= '0' && c <= '9') { /* Digit for macro arg */		c -= '0';		/* convert character to integer */		if (maclvl < 0)		/* Digit variables are global */		  p = g_var[c];		/* if no macro is active */		else			/* otherwise */		  p = m_arg[maclvl][c]; /* they're on the stack */	    } else {		if (isupper(c)) c -= ('a'-'A');		p = g_var[c];		/* Letter for global variable */	    }	    return(p ? p : "");	}	if (c == '&') {			/* Array reference. */	    int vbi, d;	    if (arraynam(p,&vbi,&d) < 0) /* Get name and subscript */	      return("");	    if (chkarray(vbi,d) > 0) {	/* Array is declared? */		vbi -= 'a';		/* Convert name to index */		if (a_dim[vbi] >= d) {	/* If subscript in range */		    char **ap;		    ap = a_ptr[vbi];	/* get data pointer */		    if (ap) {		/* and if there is one */			return(ap[d]);	/* return what it points to */		    }		}	    }	    return(p ? p : "");		/* Otherwise its enexpanded value. */	}    }    for (i = 0; i < argn; i++) {	/* Not literal, expand the args */	n = 1024;			/* allow 1K per expanded arg, yow! */	bp[i] = s = malloc(n);		/* get the new space */	if (bp[i] == NULL) {		/* handle failure to get space */	    for (k = 0; k < i; k++) if (bp[k]) free(bp[k]);	    debug(F101,"fneval malloc failure, arg","",i);	    return("");	}	p = argp[i] ? argp[i] : "";	/* Point to this argument *//*  Trim leading and trailing spaces from the original argument, before  evaluation.  This code new to edit 184.*/	if (y != FN_REP || i != 0) {	/* Don't trim 1st REPEAT argument */	    int j;			/* All others... */	    while (*p == SP || *p == HT) /* Point past leading whitespace */	      p++;	    j = (int) strlen(p) - 1;	/* Trim trailing whitespace */	    while (j > 0 && (*(p + j) == SP || *(p + j) == HT))	      *(p + j--) = NUL;	}/* Now evaluate the argument */	if (xxstring(p,&s,&n) < 0) {	/* Expand arg into new space */	    debug(F101,"fneval xxstring fails, arg","",i);	    for (k = 0; k <= i; k++)	/* Free up previous space on error */

⌨️ 快捷键说明

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