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

📄 ckuus3.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
};int nls = (sizeof(lstab) / sizeof(struct keytab));/* SET TELNET table */#ifdef TNCODEextern int tn_duplex, tn_nlm;extern char *tn_term;struct keytab tntab[] = {    "echo",          CK_TN_EC,   0,    "newline-mode",  CK_TN_NL,   0,    "terminal-type", CK_TN_TT,   0};int ntn = (sizeof(tntab) / sizeof(struct keytab));#endif /* TNCODE */struct keytab ftrtab[] = {		/* Feature table */#ifndef NOCSETS				/* 0 = we have it, 1 = we don't */"character-sets",	0, 0,#else"character-sets",	1, 0,#endif /* NOCSETS */#ifndef NOCYRIL"cyrillic",		0, 0,#else"cyrillic",		1, 0,#endif /* NOCYRIL */#ifndef NODEBUG"debug",		0, 0,#else"debug",		1, 0,#endif /* NODEBUG */#ifndef NODIAL"dial",			0, 0,#else"dial",			1, 0,#endif /* NODIAL */#ifdef DYNAMIC"dynamic-memory",       0, 0,#else"dynamic-memory",       1, 0,#endif /* DYNAMIC */#ifdef CK_CURSES"fullscreen-display",	0, 0,#else"fullscreen-display",	1, 0,#endif /* CK_CURSES */#ifndef NOHELP"help",			0, 0,#else"help",			1, 0,#endif /* NOHELP */#ifndef NOSPL"if-command",		0, 0,#else"if-command",		1, 0,#endif /* NOSPL */#ifndef NOJC#ifdef UNIX"job-control",		0, 0,#else"job-control",		1, 0,#endif /* UNIX */#else"job-control",		1, 0,#endif /* NOJC */#ifdef KANJI"kanji",		0, 0,#else"kanji",		1, 0,#endif /* KANJI */#ifndef NOCSETS"latin1",		0, 0,#else"latin1",		1, 0,#endif /* NOCSETS */#ifdef LATIN2"latin2",		0, 0,#else"latin2",		1, 0,#endif /* LATIN2 */#ifdef NETCONN"network",		0, 0,#else"network",		1, 0,#endif /* NETCONN */#ifndef NOPUSH"push",			0, 0,#else"push",			1, 0,#endif /* PUSH */#ifndef NOSCRIPT"script-command",	0, 0,#else"script-command",	1, 0,#endif /* NOSCRIPT */#ifndef NOSERVER"server-mode",		0, 0,#else"server-mode",		1, 0,#endif /* NOSERVER */#ifndef NOSHOW"show-command",		0, 0,#else"show-command",		1, 0,#endif /* NOSHOW */#ifndef NOXMIT"transmit",		0, 0,#else"transmit",		1, 0#endif /* NOXMIT */};int nftr = (sizeof(ftrtab) / sizeof(struct keytab));int					/* CHECK command */dochk() {    int x, y;    if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    if (msgflg)				/* If at top level... */      printf(" %svailable\n", y ? "Not a" : "A"); /* Print a message */    else if (y && !backgrd)		/* Or if not available and in */      printf(" CHECK: feature not available\n"); /* command file or macro */    return(success = 1 - y);}#ifndef MAC#ifndef NOSETKEYintset_key() {				/* SET KEY */    int y;    int kc;				/* Key code */    char *bind;				/* Key binding */    if ((y = cmnum("numeric key code","",10,&kc,xxstring)) < 0)      return(y);    if (kc < 0 || kc >= KMSIZE) {	printf("?key code must be between 0 and %d\n", KMSIZE - 1);	return(-9);    }#ifdef OS2    wideresult = -1;#endif /* OS2 */    if ((y = cmtxt("key definition","",&bind,xxstring)) < 0)      return(y);    if (macrotab[kc]) {			/* Possibly free old macro from key */	free(macrotab[kc]);	macrotab[kc] = NULL;    }    switch (strlen(bind)) {		/* Action depends on length */#ifdef OS2      case 0:				/* Reset to default binding */        keymap[kc] = wideresult == -1 ? kc : 0;   /* or bind to NUL */	break;      case 1:				/* Single character */	keymap[kc] = wideresult == -1 ? (CHAR) *bind : wideresult;	break;#else /* Not OS/2 */      case 0:				/* Reset to default binding */	keymap[kc] = kc;	break;      case 1:				/* Single character */  	keymap[kc] = (CHAR) *bind;  	break;#endif /* OS2 */      default:				/* Character string */	keymap[kc] = kc;	macrotab[kc] = (MACRO) malloc(strlen(bind)+1);	if (macrotab[kc])	  strcpy((char *) macrotab[kc], bind);	break;    }    return(1);}#endif /* NOSETKEY */#endif /* MAC *//*  D O P R M  --  Set a parameter.  *//* Returns:  -2: illegal input  -1: reparse needed   0: success*/intdoprm(xx,rmsflg) int xx, rmsflg; {    int i, x, y = 0, z;    long zz;    char *s; switch (xx) { #ifdef SUNX25				/* SET X25 ... */case XYX25:    return(setx25());case XYPAD:				/* SET PAD ... */    return(setpadp());#endif /* SUNX25 */case XYEOL:	/* These have all been moved to set send/receive... */case XYLEN: 	/* Let the user know what to do. */case XYMARK:case XYNPAD:case XYPADC:case XYTIMO:    printf("...Use SET SEND or SET RECEIVE instead.\n");    printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n");    return(success = 0);case XYATTR:				/* File Attribute packets */    return(setat(rmsflg));case XYIFD:				/* Incomplete file disposition */    if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    if (rmsflg) {	sstate = setgen('S', "310", y ? "1" : "0", "");	return((int) sstate);    } else {	keep = y;	return(success = 1);    } #ifndef NOSPLcase XYINPU:				/* SET INPUT */    return(setinp());#endif /* NOSPL */#ifdef NETCONNcase XYNET:				/* SET NETWORK */    if ((z = cmkey(netcmd,nnets,"","tcp/ip",xxstring)) < 0)      return(z);    if ((x = cmcfm()) < 0) return(x);    nettype = z;    if (	(nettype != NET_DEC) &&	(nettype != NET_SX25) &&        (nettype != NET_TCPB)) {	printf("?Network type not supported\n");	return(success = 0);    } else {	return(success = 1);    }#endif /* NETCONN */case XYHOST:				/* SET HOST or SET LINE */case XYLINE:    return(setlin(xx,1)); #ifndef MAC#ifndef NOSETKEYcase XYKEY:				/* SET KEY */    return(set_key());#endif /* NOSETKEY */#endif /* MAC */#ifndef NOCSETScase XYLANG: 				/* Language */    if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0) /* language code */      return(y);    if ((x = cmcfm()) < 0) return(x);	/* And confirmation of command */    /* Look up language and get associated character sets */    for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ;    if (i >= nlangs) {	printf("?internal error, sorry\n");	return(success = 0);    }    language = i;			/* All good, set the language, */    return(success = 1);#endif /* NOCSETS */#ifndef MACcase XYBACK:				/* BACKGROUND */    if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);    if ((y = cmcfm()) < 0) return(y);    bgset = z;    success = 1;    bgchk();    return(success);#endif /* MAC */case XYQUIE:				/* QUIET */    return(success = seton(&quiet));case XYBUF: {				/* BUFFERS */#ifdef DYNAMIC    int sb, rb;    if ((y = cmnum("send buffer size","",10,&sb,xxstring)) < 0) {	if (y == -3) printf("?two numbers required\n");	return(y);    }    if (sb < 80) {	printf("?too small");	return(-2);    }    if ((y = cmnum("receive buffer size","",10,&rb,xxstring)) < 0)  {	if (y == -3) printf("?receive buffer size required\n");	return(y);    }    if (rb < 80) {	printf("?too small");	return(-2);    }    if ((y = cmcfm()) < 0) return(y);    if ((y = inibufs(sb,rb)) < 0) return(y);    y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */    if (y != urpsiz) urpsiz = y;    y = adjpkl(spsiz,wslotr,bigsbsiz);    if (y != spsiz) spsiz = spmax = spsizr = y;    return(success = 1);#else    printf("?Sorry, not available\n");    return(success = 0);#endif /* DYNAMIC */}case XYCHKT:				/* BLOCK-CHECK */    if ((x = cmkey(chktab,4,"","1",xxstring)) < 0) return(x);    if ((y = cmcfm()) < 0) return(y);    bctr = x;			     /* Set locally too, even if REMOTE SET */    if (rmsflg) {	if (x == 4) {	    tmpbuf[0] = 'B';	    tmpbuf[1] = '\0';	} else sprintf(tmpbuf,"%d",x);	sstate = setgen('S', "400", tmpbuf, "");	return((int) sstate);    } else {	return(success = 1);    } #ifndef MAC/*  The Mac has no carrier...*/case XYCARR:				/* CARRIER */    if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);    if (y == CAR_ON) {	x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring);	if (x < 0) return(z);    }    if ((x = cmcfm()) < 0) return(x);    carrier = ttscarr(y);    cdtimo = z;    return(success = 1);#endif /* MAC */#ifdef TNCODEcase XYTEL:				/* TELNET */    if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "",		   xxstring)) < 0) return(z);    switch (z) {      case CK_TN_EC:			/* ECHO */	if ((x = cmkey(rltab,nrlt,		       "initial TELNET echoing state","local",xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);	tn_duplex = x;	return(success = 1);      case CK_TN_TT:			/* TERMINAL TYPE */	if ((y = cmtxt("terminal type for TELNET connections","",		       &s,xxstring)) < 0)	  return(y);	if (tn_term) free(tn_term);	/* Free any previous storage */	if (s == NULL || *s == NUL) {	/* If none given */	    tn_term = NULL;		/* remove the override string */	    return(success = 1);	} else if (tn_term = malloc(strlen(s)+1)) { /* Make storage for new */	    strcpy(tn_term,s);		/* Copy string into new storage */	    return(success = 1);	} else return(success = 0);      case CK_TN_NL:			/* NEWLINE-MODE */	return(success = seton(&tn_nlm));      default:	return(-2);    }#endif /* TNCODE */default:    break;}switch (xx) {#ifndef NOSPLcase XYCOUN:				/* SET COUNT */    x = cmnum("Positive number","0",10,&z,xxstring);    if (x < 0) return(x);    if ((x = cmcfm()) < 0) return(x);    if (z < 0) {	printf("?A positive number, please\n");	return(0);    }    debug(F101,"XYCOUN: z","",z);    return(success = setnum(&count[cmdlvl],z,0,10000));#endif /* NOSPL */#ifndef NOSPLcase XYCASE:    return(success = seton(&incase));#endif /* NOSPL */case XYCMD:				/* COMMAND ... */    if ((y = cmkey(byttab,nbytt,"","bytesize",xxstring)) < 0) return(y);    if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x,		   xxstring)) < 0)	  return(y);    if (x != 7 && x != 8) {	printf("\n?The choices are 7 and 8\n");	return(success = 0);    }    if ((y = cmcfm()) < 0) return(y);    if (x == 7) cmdmsk = 0177;    else if (x == 8) cmdmsk = 0377;    return(success = 1);    case XYDFLT:				/* SET DEFAULT = CD */    return(success = docd());case XYDEBU:				/* SET DEBUG { on, off, session } */

⌨️ 快捷键说明

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