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

📄 ckuus7.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	x = strlen(s);	if (s[x-1] == '}') {	    s[x-1] = NUL;	    s++;	}    }    if (*p) {				/* Free any previous string. */	free(*p);	*p = (char *) 0;    }	    if ((x = strlen(s)) > 0) {	*p = malloc(x + 1);		/* Allocate space for it */	strcpy(*p,s);			/* and make a safe copy. */    } else *p = (char *) 0;    return(success = 1);}int					/* Set DIAL command options */setdial() {    if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0) return(y);    switch (y) {      case XYDHUP:			/* DIAL HANGUP */	return(success = seton(&dialhng));      case XYDINI:			/* DIAL INIT-STRING */	return(dialstr(&dialini,"Modem dialer initialization string"));      case XYDNPR:			/* DIAL NUMBER-PREFIX */	return(dialstr(&dialnpr,"Modem dialer telephone number prefix"));      case XYDDIA:			/* DIAL DIAL-COMMAND */	x = cmtxt("Dialing command for modem,\n\ include \"%s\" to stand for phone number,\n\ for example, \"set dial dial-command ATDT%s\\13\"",		  "",		  &s,		  xxstring);	if (x < 0 && x != -3)		/* Handle parse errors */	  return(x);	y = x = strlen(s);		/* Get length of text */	if (x > 0 && *s == '{') {	/* Strip enclosing braces, */	    if (s[x-1] == '}') {	/* if any. */		s[x-1] = NUL;		s++;		y -= 2;	    }	}	if (y > 0) {			/* If there is any text (left), */	    for (x = 0; x < y; x++) {	/* make sure they included "%s" */		if (s[x] != '%') continue;		if (s[x+1] == 's') break;	    }	    if (x == y) {		printf("?Dial-command must contain \"%cs\" for phone number.\n",'%');		return(-9);	    }	}	if (dialcmd) {			/* Free any previous string. */	    free(dialcmd);	    dialcmd = (char *) 0;	}		if (y > 0) {	    dialcmd = malloc(y + 1);	/* Allocate space for it */	    strcpy(dialcmd,s);		/* and make a safe copy. */	}	return(success = 1);      case XYDKSP:			/* DIAL KERMIT-SPOOF */	return(success = seton(&dialksp));      case XYDTMO:			/* DIAL TIMEOUT */	y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);	return(success = setnum(&dialtmo,x,y,10000));      case XYDDPY:			/* DIAL DISPLAY */	return(success = seton(&dialdpy));      case XYDSPD:			/* DIAL SPEED-MATCHING */					/* used to be speed-changing */	if ((y = seton(&mdmspd)) < 0) return(y);#ifdef COMMENT	mdmspd = 1 - mdmspd;		/* so here we reverse the meaning */#endif /* COMMENT */	return(success = 1);      case XYDMNP:			/* DIAL MNP-ENABLE */	return(success = seton(&dialmnp));#ifdef MDMHUP      case XYDMHU:			/* DIAL MODEM-HANGUP */	return(success = seton(&dialmhu));#endif /* MDMHUP */      case XYDDIR:			/* DIAL DIRECTORY */	if ((y = cmifi("Name of dialing directory file","",&s,&y,		       xxstring)) < 0) {	    if (y == -3) {		if (dialdir) free(dialdir);	/* Free any previous storage */		dialdir = NULL;		return(success = 1);	    } else return(y);	}	if (y) {	    printf("?Wildcards not allowed\n");	    return(-9);	}	strcpy(line,s);			/* Make safe copy of dial string */	if ((y = cmcfm()) < 0) return(y); /* Confirm the command */	if (dialdir) free(dialdir);	/* Free previous filename storage */	if (dialfd) {			/* Close previous file, if any */	    fclose(dialfd);	    dialfd = NULL;	}	s = line;			/* Point back to dial string */	if (s == NULL || *s == NUL) {	/* If no name given */	    dialdir = NULL;		/* remove the name string */	    return(success = 1);	} else if ((dialdir = malloc(strlen(s)+1)) == NULL) {	    return(success = 0);	/* Can't malloc storage for name */	} else {			/* Have storage for name */	    strcpy(dialdir,s);		/* Copy string into new storage */	    if ((dialfd = fopen(dialdir,"r")) == NULL) { /* Open the file */		perror(dialdir);	/* Can't, print message saying why */		success = 0;		/* We didn't succeed */		return(-9);		/* Fail, message already printed */	    }	    return(success = 1);	/* Everything is OK */	}      default:	printf("?Unexpected SET DIAL parameter\n");	return(-2);    }}#endif /* NODIAL */intsetfil(rmsflg) int rmsflg; {    if (rmsflg) {	if ((y = cmkey(rfiltab,nrfilp,"Remote file parameter","",		       xxstring)) < 0) {	    if (y == -3) {		printf("?Remote file parameter required\n");		return(-9);	    } else return(y);	}    } else {	if ((y = cmkey(filtab,nfilp,"File parameter","",xxstring)) < 0)	  return(y);    }    switch (y) {#ifdef COMMENT				/* Not needed */      case XYFILB:			/* Blocksize */	sprintf(tmpbuf,"%d",DBLKSIZ);	if ((y = cmnum("file block size",tmpbuf,10,&z,xxstring)) < 0)	  return(y);	if ((x = cmcfm()) < 0) return(x);	if (rmsflg) {	    sprintf(tmpbuf,"%d",z);	    sstate = setgen('S', "311", tmpbuf, "");	    return((int) sstate);	} else {	    fblksiz = z;	    return(success = 1);	}#endif /* COMMENT */      case XYFILS:			/* Byte size */	if ((y = cmnum("file byte size (7 or 8)","8",10,&z,xxstring)) < 0)	  return(y);	if (z != 7 && z != 8) {	    printf("\n?The choices are 7 and 8\n");	    return(0);	}	if ((y = cmcfm()) < 0) return(y);	if (z == 7) fmask = 0177;	else if (z == 8) fmask = 0377;	return(success = 1);#ifndef NOCSETS      case XYFILC:			/* Character set */	if ((x = cmkey(fcstab,nfilc,"local file code","ascii", xxstring)) < 0)	  return(x);	if ((z = cmcfm()) < 0) return(z);	fcharset = x;	return(success = 1);#endif /* NOCSETS */      case XYFILD:			/* Display */	if ((x = cmkey(fdtab,nfdtab,"file transfer display style","",		       xxstring)) < 0)	  return(x);	if ((z = cmcfm()) < 0) return(z);#ifdef CK_CURSES	if (x == XYFD_C) {#ifdef VMS	    lp = line;#else	    lp = trmbuf;#endif /* VMS */#ifndef MYCURSES	    s = getenv("TERM");	    if (tgetent(lp,s) < 1) {#ifdef VMS		printf("Sorry, terminal type not supported: %s\n",s);#else		printf("Sorry, terminal type unknown: %s\n",s);#endif /* VMS */		return(success = 0);	    }#endif /* MYCURSES */	    line[0] = '\0';	}#endif /* CK_CURSES */	fdispla = x;			/* It's OK. */	return(success = 1);      case XYFILN:			/* Names */	if ((x = cmkey(fntab,2,"how to handle filenames","converted",		       xxstring)) < 0)	  return(x);	if ((z = cmcfm()) < 0) return(z);	fncnv = x;	return(success = 1);      case XYFILR:			/* Record length */	sprintf(tmpbuf,"%d",DLRECL);	if ((y = cmnum("file record length",tmpbuf,10,&z,xxstring)) < 0)	  return(y);	if ((x = cmcfm()) < 0) return(x);	if (rmsflg) {	    sprintf(tmpbuf,"%d",z);	    sstate = setgen('S', "312", tmpbuf, "");	    return((int) sstate);	} else {	    frecl = z;	    return(success = 1);	}#ifdef COMMENT      case XYFILO:			/* Organization */	if ((x = cmkey(forgtab,nforg,"file organization","sequential",		       xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);	if (rmsflg) {	    sprintf(tmpbuf,"%d",x);	    sstate = setgen('S', "314", tmpbuf, "");	    return((int) sstate);	} else {	    forg = x;	    return(success = 1);	}	#endif /* COMMENT */#ifdef COMMENT				/* Not needed */      case XYFILF:			/* Format */	if ((x = cmkey(frectab,nfrec,"file record format","stream",		       xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);	if (rmsflg) {	    sprintf(tmpbuf,"%d",x);	    sstate = setgen('S', "313", tmpbuf, "");	    return((int) sstate);	} else {	    frecfm = x;	    return(success = 1);	}#endif /* COMMENT */#ifdef COMMENT      case XYFILP:			/* Printer carriage control */	if ((x = cmkey(fcctab,nfcc,"file carriage control","newline",		       xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);	if (rmsflg) {	    sprintf(tmpbuf,"%d",x);	    sstate = setgen('S', "315", tmpbuf, "");	    return((int) sstate);	} else {	    fcctrl = x;	    return(success = 1);	}	#endif /* COMMENT */      case XYFILT:			/* Type */	if ((x = cmkey(fttab,nfttyp,"type of file","text",xxstring)) < 0)	  return(x);#ifdef COMMENT	if ((y = cmnum("file byte size (7 or 8)","8",10,&z,xxstring)) < 0)	  return(y);	if (z != 7 && z != 8) {	    printf("\n?The choices are 7 and 8\n");	    return(0);	}#endif /* COMMENT */#ifdef VMS        /* Allow VMS users to choose record format for binary files */        if ((x == XYFT_B) && (rmsflg == 0)) {	    if ((x = cmkey(fbtab,nfbtyp,"VMS record format","fixed",			   xxstring)) < 0)	      return(x);	}#endif /* VMS */	if ((y = cmcfm()) < 0) return(y);	if (rmsflg) {	    sstate = setgen('S', "300", x ? "1" : "0", "");	    return((int) sstate);	} else {	    binary = x;#ifdef COMMENT	    if (z == 7) fmask = 0177;	    else if (z == 8) fmask = 0377;#endif /* COMMENT */	    return(success = 1);	}      case XYFILX:			/* Collision Action */	if ((x = cmkey(colxtab,ncolx,"Filename collision action","backup",		       xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);	fncact = x;	if (rmsflg) {	    sprintf(tmpbuf,"%d",fncact);	    sstate = setgen('S', "302", tmpbuf, "");	    return((int) sstate);	} else {	    if (fncact == XYFX_R) warn = 1; /* SET FILE WARNING implications */	    if (fncact == XYFX_X) warn = 0; /* ... */	    return(success = 1);	}      case XYFILW:			/* Warning/Write-Protect */	seton(&warn);	if (warn)	  fncact = XYFX_R;	else	  fncact = XYFX_X;	return(success = 1);#ifdef VMS      case XYFILL:			/* LABELED FILE parameters */	if ((x = cmkey(lbltab,nlblp,"VMS labeled file feature","",		       xxstring)) < 0)	  return(x);	if ((success = seton(&y)) < 0)	  return(success);	if (y)				/* Set or reset the selected bit */	  lf_opts |= x;			/* in the options bitmask. */	else	  lf_opts &= ~x;	return(success);#endif /* VMS */      case XYFILI:			/* INCOMPLETE */	return(doprm(XYIFD,rmsflg));      default:	printf("?unexpected file parameter\n");	return(-2);    }}intsettrm() {    if ((y = cmkey(trmtab,ntrm,"","",xxstring)) < 0) return(y);#ifdef MAC    printf("\n?Sorry, not implemented yet.  Please use the Settings menu.\n");    return(-9);#else    switch (y) {      case XYTBYT:			/* SET TERMINAL BYTESIZE */	if ((y = cmnum("bytesize for terminal connection","8",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) cmask = 0177;	else if (x == 8) cmask = 0377;        return(success = 1);      case XYTSO:			/* SET TERMINAL LOCKING-SHIFT */	return(success = seton(&sosi));      case XYTNL:			/* SET TERMINAL NEWLINE-MODE */	return(success = seton(&tnlm)); #ifdef OS2      case XYTCOL:			/* SET TERMINAL COLOR */	if ((x = cmkey(ttycoltab,ncolors,"","normal",xxstring)) < 0) {	    return(x);        } else {	    extern int colornormal, colorreverse, colorunderline,	      colorstatus, colorhelp, scrninitialised;	    int fg, bg;	    if ((fg = cmkey(ttyclrtab,nclrs,			    "foreground color","black",xxstring)) < 0)	      return(fg);	    if ((bg = cmkey(ttyclrtab,nclrs,			    "background color","cyan",xxstring)) < 0)	      return(bg);	    if ((y = cmcfm()) < 0)	      return(y);	    switch (x) {	      case 0:		colornormal = fg | bg << 4;		break;	      case 1:		colorreverse = fg | bg << 4;		break;	      case 2:		colorunderline = fg | bg << 4;		break;	      case 3:		colorstatus = fg | bg << 4;		break;	      case 4:		colorhelp = fg | bg << 4;		break;	      default:		printf("%s - invalid\n",cmdbuf);		return(-9);		break;	    }	    scrninitialised = 0;        }	return(success = 1);      case XYTCUR:			/* SET TERMINAL CURSOR */	if ((x = cmkey(ttycurtab,ncursors,"","underline",xxstring)) < 0)	  return(x);	if ((y = cmcfm()) < 0) return(y);        tt_cursor = x;	return(success = 1);      case XYTTYP:			/* SET TERMINAL TYPE */	if ((x = cmkey(ttyptab,nttyp,"","vt102",xxstring)) < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	tt_type = x;	return(success = 1);      case XYTARR:			/* SET TERMINAL ARROW-KEYS */	if ((x = cmkey(akmtab,2,"","",xxstring)) < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	tt_arrow = x;			/* 0 = application, 1 = cursor */	return(success = 1);      case XYTKPD:			/* SET TERMINAL KEYPAD-MODE */	if ((x = cmkey(kpmtab,2,"","",xxstring)) < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	tt_keypad = x;			/* 0 = application, 1 = numeric */	return(success = 1);      case XYTWRP:			/* SET TERMINAL WRAP */	seton(&tt_wrap);	return(success = 1);	#endif /* OS2 */#ifndef NOCSETS      case XYTCS:			/* SET TERMINAL CHARACTER-SET */	/* set terminal character-set <remote> <local> */	if ((x = cmkey(ttcstab,ntermc,		       "remote terminal character-set","",xxstring)) < 0) 	  return(x);	if (x == FC_TRANSP) {		/* TRANSPARENT? */	    if ((x = cmcfm()) < 0) return(x); /* Confirm the command */	    tcsr = tcsl = FC_USASCII;	/* Make them both the same */	    return(success = 1);	}/* Not transparent, so get local set to translate it into */	s = "";				/* Make current file char set */	for (y = 0; y <= nfilc; y++)	/* be the default... */	  if (fcstab[y].kwval == fcharset) {	      s = fcstab[y].kwd;	      break;	    }	if ((y = cmkey(fcstab,nfilc,		       "local character-set",s,xxstring)) < 0)	  return(y);	if ((z = cmcfm()) < 0) return(z); /* Confirm the command */	tcsr = x;			/* Remote character set */	tcsl = y;			/* Local character set */	return(success = 1);#endif /* NOCSETS */      case XYTEC:			/* SET TERMINAL ECHO */	if ((x = cmkey(rltab,nrlt,"which side echos during CONNECT",		       "remote", xxstring)) < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	duplex = x;	return(success = 1);       case XYTCRD:			/* SET TERMINAL CR-DISPLAY */	if ((x = cmkey(crdtab,2,"", "normal", xxstring)) < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	tt_crd = x;	return(success = 1);       default:				/* Shouldn't get here. */	return(-2);    }    #endif /* MAC */}int					/* SET SEND/RECEIVE */setsr(xx, rmsflg) int xx; int rmsflg; {    if (xx == XYRECV)    	strcpy(line,"Parameter for inbound packets");    else    	strcpy(line,"Parameter for outbound packets");     if (rmsflg) {	if ((y = cmkey(rsrtab,nrsrtab,line,"",xxstring)) < 0) {	    if (y == -3) {		printf("?Remote receive parameter required\n");		return(-9);	    } else return(y);	}    } else {	if ((y = cmkey(srtab,nsrtab,line,"",xxstring)) < 0) return(y);    }    switch (y) {       case XYEOL:	y = cmnum("Decimal ASCII code for packet terminator","13",10,&x,		  xxstring);	if ((y = setcc(&z,x,y)) < 0) return(y);	if (xx == XYRECV) eol = z; else seol = z;	return(success = y);

⌨️ 快捷键说明

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