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

📄 ckuus7.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
    if ((y = cmkey(padx3tab,npadx3,"PAD X.3 parameter name","",xxstring)) < 0)      return(y);    x = y;    switch (x) {      case PAD_BREAK_CHARACTER:	if ((y = cmnum("PAD break character value","",10,&z,xxstring)) < 0)	  return(y);	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_ESCAPE:	if ((y = cmnum("PAD escape","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_ECHO: 	if ((y = cmnum("PAD echo","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_DATA_FORWARD_CHAR: 	if ((y = cmnum("PAD data forward char","",10,&z,xxstring)) < 0)	  return(y);	if (z != 0 && z != 2) {	    printf("?The choices are 0 or 2\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_DATA_FORWARD_TIMEOUT: 	if ((y = cmnum("PAD data forward timeout","",10,&z,xxstring)) < 0)	    return(y);	if (z < 0 || z > 255) {	    printf("?The choices are 0 or 1 <= timeout <= 255\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_FLOW_CONTROL_BY_PAD: 	if ((y = cmnum("PAD pad flow control","",10,&z,xxstring)) < 0)	  return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_SUPPRESSION_OF_SIGNALS: 	if ((y = cmnum("PAD service","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_BREAK_ACTION: 	if ((y = cmnum("PAD break action","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1 && z != 2 && z != 5 && z != 8 && z != 21) {	    printf("?The choices are 0, 1, 2, 5, 8 or 21\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_SUPPRESSION_OF_DATA: 	if ((y = cmnum("PAD data delivery","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_PADDING_AFTER_CR: 	if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);	if (z < 0 || z > 7) {	    printf("?The choices are 0 or 1 <= crpad <= 7\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_LINE_FOLDING: 	if ((y = cmnum("PAD linefold","",10,&z,xxstring)) < 0) return(y);	if (z < 0 || z > 255) {	    printf("?The choices are 0 or 1 <= linefold <= 255\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_LINE_SPEED: 	if ((y = cmnum("PAD baudrate","",10,&z,xxstring)) < 0) return(y);	if (z < 0 || z > 18) {	    printf("?The choices are 0 <= baudrate <= 18\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_FLOW_CONTROL_BY_USER: 	if ((y = cmnum("PAD terminal flow control","",10,&z,xxstring)) < 0)	    return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_LF_AFTER_CR: 	if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);	if (z < 0 || z == 3 || z > 7) {	    printf("?The choices are 0, 1, 2, 4, 5, 6 or 7\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_PADDING_AFTER_LF: 	if ((y = cmnum("PAD lfpad","",10,&z,xxstring)) < 0) return(y);	if (z < 0 || z > 7) {	    printf("?The choices are 0 or 1 <= lfpad <= 7\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_EDITING: 	if ((y = cmnum("PAD edit control","",10,&z,xxstring)) < 0) return(y);	if (z != 0 && z != 1) {	    printf("?The choices are 0 or 1\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_CHAR_DELETE_CHAR: 	if ((y = cmnum("PAD char delete char","",10,&z,xxstring)) < 0)	    return(y);	if (z < 0 || z > 127) {	    printf("?The choices are 0 or 1 <= chardelete <= 127\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_BUFFER_DELETE_CHAR: 	if ((y = cmnum("PAD buffer delete char","",10,&z,xxstring)) < 0)	    return(y);	if (z < 0 || z > 127) {	    printf("?The choices are 0 or 1 <= bufferdelte <= 127\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;      case PAD_BUFFER_DISPLAY_CHAR: 	if ((y = cmnum("PAD display line char","",10,&z,xxstring)) < 0)	    return(y);	if (z < 0 || z > 127) {	    printf("?The choices are 0 or 1 <= displayline <= 127\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	break;    }    padparms[x] = z;    return(success = 1);}#endif /* SUNX25 */ intsetat(rmsflg) int rmsflg; {    int xx;    if ((y = cmkey(attrtab,natr,"File Attribute packets","",xxstring)) < 0)      return(y);        if (y == AT_XALL) {			/* ATTRIBUTES ALL ON or ALL OFF */	if ((z = seton(&xx)) < 0) return(z);	if (rmsflg) {	    printf("Sorry, command not available\n");	    return(-9);	} else {	    atenci = xx;		/* Encoding in */	    atenco = xx;		/* Encoding out */	    atdati = xx;		/* Date in */	    atdato = xx;		/* Date out */	    atdisi = xx;		/* Disposition in/out */	    atdiso = xx;	    atleni = xx;		/* Length in/out (both kinds) */	    atleno = xx;	    atblki = xx;		/* Blocksize in/out */	    atblko = xx;	    attypi = xx;		/* File type in/out */	    attypo = xx;	    atsidi = xx;		/* System ID in/out */	    atsido = xx;	    atsysi = xx;		/* System-dependent params in/out */	    atsyso = xx;	}	return(z);    } else if (y == AT_ALLY || y == AT_ALLN) { /* ATTRIBUTES ON or OFF */	if ((x = cmcfm()) < 0) return(x);	atcapr = (y == AT_ALLY) ? 1 : 0;	if (rmsflg) {	    sstate = setgen('S', "132", atcapr ? "1" : "0", "");	    return((int) sstate);	} else return(success = 1);    }    /* Otherwise, it's an individual attribute that wants turning off/on */    if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);    if ((x = cmcfm()) < 0) return(x);/* There are better ways to do this... *//* The real problem is that we're not separating the in and out cases *//* and so we have to arbitrarily pick the "in" case, i.e tell the remote *//* server to ignore incoming attributes of the specified type, rather *//* than telling it not to send them.  The protocol does not (yet) define *//* codes for "in-and-out-at-the-same-time". */    switch(y) {      case AT_DISP:	if (rmsflg) {	    sstate = setgen('S', "142", z ? "1" : "0", "");	    return((int) sstate);	}	atdisi = atdiso = z; break;      case AT_ENCO:	if (rmsflg) {	    sstate = setgen('S', "141", z ? "1" : "0", "");	    return((int) sstate);	}	atenci = atenco = z; break;      case AT_DATE:	if (rmsflg) {	    sstate = setgen('S', "135", z ? "1" : "0", "");	    return((int) sstate);	}	atdati = atdato = z; break;      case AT_LENB:      case AT_LENK:	if (rmsflg) {	    sstate = setgen('S', "133", z ? "1" : "0", "");	    return((int) sstate);	}	atleni = atleno = z; break;      case AT_BLKS:	if (rmsflg) {	    sstate = setgen('S', "139", z ? "1" : "0", "");	    return((int) sstate);	}	atblki = atblko = z; break;      case AT_FTYP:	if (rmsflg) {	    sstate = setgen('S', "134", z ? "1" : "0", "");	    return((int) sstate);	}	attypi = attypo = z; break;      case AT_SYSI:	if (rmsflg) {	    sstate = setgen('S', "145", z ? "1" : "0", "");	    return((int) sstate);	}	atsidi = atsido = z; break;      case AT_SYSP:	if (rmsflg) {	    sstate = setgen('S', "147", z ? "1" : "0", "");	    return((int) sstate);	}	atsysi = atsyso = z; break;      default:	printf("?Not available\n");	return(-2);    }    return(1);}#ifndef NOSPLintsetinp() {    if ((y = cmkey(inptab,ninp,"","",xxstring)) < 0) return(y);    switch (y) {      case IN_DEF:			/* SET INPUT DEFAULT-TIMEOUT */	z = cmnum("Positive number","",10,&x,xxstring);	return(success = setnum(&indef,x,z,94));      case IN_TIM:			/* SET INPUT TIMEOUT-ACTION */	if ((z = cmkey(intimt,2,"","",xxstring)) < 0) return(z);	if ((x = cmcfm()) < 0) return(x);	intime = z;	return(success = 1);      case IN_CAS:			/* SET INPUT CASE */	if ((z = cmkey(incast,2,"","",xxstring)) < 0) return(z);	if ((x = cmcfm()) < 0) return(x);	incase = z;	return(success = 1);      case IN_ECH:			/* SET INPUT ECHO */	return(success = seton(&inecho));      case IN_SIL:			/* SET INPUT SILENCE */	z = cmnum("Positive number","",10,&x,xxstring);	return(success = setnum(&insilence,x,z,-1));    }    return(0);}#endif /* NOSPL *//*  setlin -- parse name of and then open a communication device.  Call with:    xx == XXLINE for a serial (tty) line, XXHOST for a network host,    zz == 0 means if user doesn't give a device name, continue current            active connection (if any);    zz != 0 means if user doesn't give a device name, then close the            current connection and restore the default communication device.*/intsetlin(xx, zz) int xx, zz; {    if (xx == XYHOST) {			/* SET HOST <hostname> */#ifndef NETCONN        printf("?Network connections not supported\n");	return(-9);#else	if (	    (nettype != NET_DEC) &&	    (nettype != NET_SX25) &&            (nettype != NET_TCPB)) {	    printf("?Network type not supported\n");	    return(-9);	  }	if (nettype != NET_TCPB) {	/* Not a TCP/IP connection */					/* Just get a text string */	    if ((x = cmtxt( zz ?    "Network host name,\n or carriage return to close an open connection" :   "Network host name,\n or carriage return to resume an open connection",			   "",&s,xxstring)) < 0)	      return(x);	} else {			/* TCP/IP connection... */	    /* Parse for host and service separately. */	    if ((x = cmfld( zz ?   "IP host name or number,\n or carriage return to close an open connection" :   "IP host name or number,\n or carriage return to resume an open connection",			   "",&s,xxstring)) < 0) {		if (x != -3)		/* Parse error */		  return(x);		/* return it */		else if (!zz)		/* No hostname given */		  return(1);		/* and none required, */	    }				/* continue current connection. */	    if (*s) {			/* If they gave a host name... */		strcpy(line,s);		/* make a copy */		/* Check for "host:service" */		for ( ; (*s != '\0') && (*s != ':'); s++) ;		/* If no service given, let them type one now. */		if (!*s) {		    if ((x = cmfld(    "TCP service name or number,\n or carriage return for telnet (23)",				   "23",&s,xxstring)) < 0 && x != -3)		      return(x);		    if (*s) {		/* If they gave a service, */			strcat(line,":"); /* concatenate it to the hostname */			strcat(line,s);	/* separated by a colon, because */		    }			/* this is how ttopen() wants it. */		}		if ((x = cmcfm()) < 0) return(x); /* Confirm the command */		s = line;	    }	}	/* New connection wanted. */	ttflui();			/* Clear away buffered up junk */	ttclos(0);			/* Close old connection, if any */	if (oldplex > -1)		/* Restore duplex setting. */	  duplex = oldplex;	if (*s) {			/* They gave a hostname */	    x = 1;			/* Network connection always local */	    mdmsav = mdmtyp;		/* Remember old modem type */	    mdmtyp = -nettype;		/* Special code for network */	    if (nettype == NET_TCPB) {	/* For TCP/IP telnet connections */		oldplex = duplex;	/* Remember previous duplex */		duplex = 0;		/* Set full duplex and let */	  }				/* negotiations change if necessary. */	} else {			/* They just said "set host" */	    if (network && msgflg)	      printf(" Closing connection\n");	    s = dftty;			/* So go back to normal */	    x = dfloc;			/* default tty, location, */	    network = 0;		/* No more network connection. */	    duplex = oldplex;		/* Restore old duplex setting. */	    if (mdmtyp < 0) {		/* Switching from net to async? */		if (mdmsav > -1)	/* Restore modem type from last */		  mdmtyp = mdmsav;	/* SET MODEM command, if any. */		else		  mdmtyp = 0;	    }	}#endif /* NETCONN */    }/* Serial tty device, possibly modem, connection... */    if (xx == XYLINE) {			/* SET LINE */#ifdef OS2				/* or SET PORT */	if ((x = cmkey(os2devtab,nos2dev,"serial communication device name",		       "com1", xxstring)) < 0) {	    debug(F101,"OS2 SET PORT x","",x);	    if (x != -9) return(x);	    s = atxbuf;			/* Doesn't match keyword */	    if (*s == '_') s++;		/* Secret notation for file handle */	    else return(-9);	} else if (x >= 1 && x <= 8) {	/* Regular COM port */	    s = os2devtab[x+7].kwd;	/* Use its real name */	} else s = atxbuf;		/* Something else, believe it */#else	if ((x = cmtxt("Communication device name",dftty,&s,xxstring)) < 0)	  return(x);#endif /* OS2 */	if (local) ttflui();		/* Clear away buffered up junk */	ttclos(0);			/* Close old line, if any was open */	if (*s) {			/* They gave a device name */	    x = -1;			/* Let ttopen decide about it */	} else {			/* They just said "set line" */	    s = dftty;			/* so go back to normal tty */	    x = dfloc;			/* and mode. */	}	if (mdmtyp < 0) {		/* Switching from net to async? */	    if (mdmsav > -1)		/* Restore modem type from last */	      mdmtyp = mdmsav;		/* SET MODEM command, if any. */	    else	      mdmtyp = 0;	    mdmsav = -1;	}	if (oldplex > -1) {		/* Restore previous duplex setting. */	    duplex = oldplex;	    oldplex = -1;	}	network = 0;			/* No more network. */    }#ifdef COMMENT/*  The following is removed, not so much because it's a horrible hack, but  because it only works if the SET FLOW command was given *before* the SET  LINE command, whereas normally these commands can be given in any order.*/#ifdef NEXT/*  This is a horrible hack, but it's nice for users.  On the NeXT, you select  RTS/CTS hardware flow control not by system calls, but by referring to the  device with a different name.  If the user has asked for RTS/CTS flow  control on a NeXT, but used the non-RTS/CTS device name in the SET LINE  command, we make the appropriate substitute here.  I wonder how much bigger  this section of code will grow as the years go by... */    if ((flow == FLO_RTSC) &&		/* RTS/CTS flow control selected */	strcmp(s,dftty)) {		/*  ...on external port? */	y = strlen(s);			/* Yes, insert "f" as next-to-last */	if (s[y-2] != 'f') {		/* character in device name if not */	    strcpy(line,s);		/* already there... */	    line[y] = line[y-1];	/* So /dev/cua => /dev/cufa, etc. */	    line[y-1] = 'f';	    line[y+1] = '\0';	    s = line;	}    }#endif /* NEXT */#endif /* COMMENT */    if ((y = ttopen(s,&x,mdmtyp,cdtimo)) < 0 ) { /* Open the new line */	if (y == -2) {	    printf("?Timed out, no carrier.\n");	    printf("Try SET CARRIER OFF and SET LINE again, or else\n");	    printf("SET MODEM, SET LINE, and then DIAL.\n");	} else if (y == -3) {	    printf("Sorry, access to lock denied: %s\n",s);	} else if (y == -4) {	    printf("Sorry, access to device denied: %s\n",s);	} else if (y == -5) {#ifdef VMS	    printf("Sorry, device is in use or otherwise unavailable: %s\n",s);#else	    printf("Sorry, device is in use: %s\n",s);#endif /* VMS */        } else {			/* Other error. */#ifndef VMS	    if (errno) {		tp = tmpbuf;		sprintf(tp,"Sorry, can't open connection: %s",s);		perror(tp);	    } else#endif /* VMS */	      printf("Sorry, can't open connection: %s\n",s);	}    	local = dfloc;			/* Go back to normal */#ifndef MAC	strcpy(ttname,dftty);		/* Restore default tty name */#endif /* MAC */	speed = ttgspd();	network = 0;			/* No network connection active */	return(success = 0);		/* Return failure */    }    if (x > -1) local = x;		/* Opened ok, set local/remote. */    network = (mdmtyp < 0);		/* Remember connection type. */#ifdef TNCODE    if (network) tn_init = 0;		/* Say telnet not init'd yet. */#endif /* TNCODE */    strcpy(ttname,s);			/* Copy name into real place. */    speed = ttgspd();			/* Get the current speed. */    debug(F111,"set line ",ttname,local);#ifdef NETCONN#ifdef SUNX25    if (nettype == NET_SX25) duplex = 1; /* Duplex half */#endif /* SUNX25 */#endif /* NETCONN */    return(success = 1);}#endif /* NOICP */

⌨️ 快捷键说明

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