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

📄 ckuusr.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	y = (x & CLR_DEV) ? ttflui() : 0;#ifndef NOSPL	/* Clear INPUT command buffer if requested */	if (x & CLR_INP) {	    for (x = 0; x < INPBUFSIZ; x++)	      inpbuf[x] = 0;	    inpbp = inpbuf;	}#endif /* NOSPL */	return(success = (y == 0));    }#endif /* NOFRILLS */    if (cx == XXCOM) {			/* COMMENT */	if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)	  return(x);	/* Don't change SUCCESS flag for this one */	return(0);    }     if (cx == XXCON) {			/* CONNECT */	if ((x = cmcfm()) < 0)	  return(x);	return(success = doconect());    }    if (cx == XXCWD)			/* CWD */      return(success = docd());    if (cx == XXCHK)			/* CHECK */      return(success = dochk());    if (cx == XXCLO) {			/* CLOSE */	x = cmkey(clstab,ncls,"Which log or file to close","",xxstring);	if (x == -3) {	    printf("?You must say which file or log\n");	    return(-9);	}	if (x < 0) return(x);	if ((y = cmcfm()) < 0) return(y);	y = doclslog(x);	success = (y == 1);	return(success);    }#ifndef NOSPL    if (cx == XXDEC || cx == XXINC)	/* DECREMENT, INCREMENT */      return(doincr(cx));#endif /* NOSPL */#ifndef NOSPL    if (cx == XXDEF || cx == XXASS || cx == XXASX || cx == XXDFX)      return(dodef(cx));		/* DEFINE, ASSIGN */#endif /* NOSPL */#ifndef NOSPL        if (cx == XXDCL) {			/* DECLARE an array */	if ((y = cmfld("Array name","",&s,NULL)) < 0) {	    if (y == -3) {		printf("?Array name required\n");		return(-9);	    } else return(y);	}	if ((y = arraynam(s,&x,&z)) < 0) return(y);	if ((y = cmcfm()) < 0) return(y);	if (dclarray((char)x,z) < 0) {	    printf("?Declare failed\n");	    return(success = 0);	}	return(success = 1);    }#endif /* NOSPL */#ifndef NODIAL    if (cx == XXRED || cx == XXDIAL)	/* DIAL or REDIAL */      return(dodial(cx));#endif /* NODIAL */ #ifndef NOFRILLS    if (cx == XXDEL)			/* DELETE */      return(dodel());#endif /* NOFRILLS */#ifndef MAC    if (cx == XXDIR)			/* DIRECTORY */      return(dodir());#endif /* MAC */ #ifndef NOSPL    if (cx == XXELS)			/* ELSE */      return(doelse());#endif /* NOSPL */#ifndef NOFRILLS    if (cx == XXENA || cx == XXDIS) {	/* ENABLE, DISABLE */	s = (cx == XXENA) ?	  "Server function to enable" :	    "Server function to disable";	if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {	    if (x == -3) {		printf("?Name of server function required\n");		return(-9);	    } else return(x);	}	if ((y = cmcfm()) < 0) return(y);	return(doenable(cx,x));    }#endif /* NOFRILLS */#ifndef NOSPL    if (cx == XXRET) {			/* RETURN */	if (cmdlvl == 0) {		/* At top level, nothing happens... */	    if ((x = cmcfm()) < 0)	      return(x);	    return(success = 1);	} else if (cmdstk[cmdlvl].src == CMD_TF) { /* In TAKE file, like POP */	    if ((x = cmtxt("optional return value","",&s,NULL)) < 0)	      return(x);		/* Allow trailing text, but ignore. */	    if ((x = cmcfm()) < 0)	      return(x);	    popclvl();			/* pop command level */	    return(success = 1);	/* always succeeds */	} else if (cmdstk[cmdlvl].src == CMD_MD) { /* Within macro */  	    if ((x = cmtxt("optional return value","",&s,NULL)) < 0)	      return(x);	    return(doreturn(s));	/* Trailing text is return value. */	} else return(-2);    }#endif /* NOSPL */#ifndef NOSPL    if (cx == XXDO) {			/* DO (a macro) */	if (nmac == 0) {	    printf("\n?No macros defined\n");	    return(-2);	}	for (y = 0; y < nmac; y++) {	/* copy the macro table */	    mackey[y].kwd = mactab[y].kwd; /* into a regular keyword table */	    mackey[y].kwval = y;	/* with value = pointer to macro tbl */	    mackey[y].flgs = mactab[y].flgs;	}	/* parse name as keyword */	if ((x = cmkey(mackey,nmac,"macro","",xxstring)) < 0) {	    if (x == -3) {		printf("?Macro name required\n");		return(-9);	    } else return(x);	}	if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0)	  return(y);			/* get args */	return(dodo(x,s) < 1 ? (success = 0) : 1);    }#endif /* NOSPL */    if (cx == XXECH) {			/* ECHO */	if ((x = cmtxt("Material to be echoed","",&s,xxstring)) < 0)	  return(x);	if (*s == '{') {		/* Strip enclosing braces */	    x = (int)strlen(s);	    if (s[x-1] == '}') {		s[x-1] = NUL;		s++;	    }	}	printf("%s\n",s);	return(1);			/* Always succeeds */    }#ifndef NOSPL    if (cx == XXOPE)			/* OPEN */      return(doopen());#endif /* NOSPL */#ifndef NOSPL    if (cx == XXOUT) {			/* OUTPUT */	if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)	  return(x);	debug(F110,"OUTPUT 1",s,0);	if (*s == '{') {		/* Strip enclosing braces, */	    x = (int)strlen(s);		/* if any. */	    if (s[x-1] == '}') {		s[x-1] = NUL;		s++;	    }	}	debug(F110,"OUTPUT 2",s,0);	for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \B, \L to \\B, \\L */	    if (x > 0 &&		(s[x] == 'B' || s[x] == 'b' || s[x] == 'L' || s[x] == 'l'))	      if ((x == 1 && s[x-1] == CMDQ) ||		  (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ))		line[y++] = CMDQ;	    line[y] = s[x];	}	line[y++] = '\0';		/* Now expand variables, etc. */	debug(F110,"OUTPUT 3",line,0);	s = line+y+1;	x = LINBUFSIZ - strlen(line) - 1;	debug(F101,"OUTPUT size","",x);	if (xxstring(line,&s,&x) < 0)	  return(success = 0);	s = line+y+1;	debug(F110,"OUTPUT 4",s,0);	return(success = dooutput(s));    }#endif /* NOSPL */#ifdef SUNX25    if (cx == XXPAD) {			/* PAD commands */	x = cmkey(padtab,npadc,"PAD command","",xxstring);	if (x == -3) {	    printf("?You must specify a PAD command to execute\n");	    return(-2);	}	if (x < 0) return(x);    	switch (x) {	  case XYPADL: 	    if (x25stat() < 0)	      printf("Sorry, you must 'set network' & 'set host' first\r\n");	    else {		x25clear();		initpad();	    }	    break;	  case XYPADS:	    if (x25stat() < 0)	      printf("Not connected\r\n");	    else {		extern int linkid, lcn;		conol("Connected thru ");		conol(ttname);		printf(", Link id %d, Logical channel number %d\r\n",		       linkid,lcn);	    }	    break;	  case XYPADR:	    if (x25stat() < 0)	      printf("Sorry, you must 'set network' & 'set host' first\r\n");	    else	      x25reset(0,0);	    break;	  case XYPADI:	    if (x25stat() < 0)	      printf("Sorry, you must 'set network' & 'set host' first\r\n");	    else 	      x25intr(0);	}	return(0);}#endif /* SUNX25 */#ifndef NOSPL    if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */      return(dopaus(cx));#endif /* NOSPL */#ifndef NOFRILLS    if (cx == XXPRI) {	if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {	    if (x == -3) {		printf("?A file specification is required\n");		return(-9);	    } else return(x);	}	if (y != 0) {	    printf("?Wildcards not allowed\n");	    return(-9);	}	strcpy(line,s);	if ((x = cmtxt("Local print command options, or carriage return","",&s,		       xxstring)) < 0) return(x);	return(success = (zprint(s,line) == 0) ? 1 : 0);    }#ifdef TCPSOCKET    if (cx == XXPNG) 			/* PING an IP host */      return(doping());#endif /* TCPSOCKET */#ifndef MAC    if (cx == XXPWD) {			/* PWD */	if ((x = cmcfm()) < 0) return(x);	xsystem(PWDCMD);	return(success = 1);		/* blind faith */    }#endif /* MAC */#endif /* NOFRILLS */    if (cx == XXQUI || cx == XXEXI) {	/* EXIT, QUIT */	if ((y = cmnum("exit status code","",10,&x,xxstring)) < 0) {	    if (y == -3)	      x = xitsta;	    else return(y);	}	if ((y = cmcfm()) < 0) return(y);#ifdef VMS	doexit(GOOD_EXIT,x);#else#ifdef OSK/* Returning any codes here makes the OS-9 shell print an error message. */	doexit(GOOD_EXIT,-1);#else#ifdef datageneral        doexit(GOOD_EXIT,x);#else	doexit(x,-1);#endif /* datageneral */#endif /* OSK */#endif /* VMS */    }#ifndef NOFRILLS    if (cx == XXERR) {			/* ERROR */	if ((x = cmcfm()) < 0) return(x);	ttflui();	sstate = 'a';	return(0);    }#endif /* NOFRILLS */    if (cx == XXFIN) {			/* FINISH */	if ((x = cmcfm()) < 0) return(x);	sstate = setgen('F',"","","");	if (local) ttflui();		/* If local, flush tty input buffer */	return(0);    }#ifndef NOSPL    if (cx == XXFOR)			/* FOR loop */      return(dofor());#endif /* NOSPL */    if (cx == XXGET) {			/* GET */	x = cmtxt("Name of remote file(s), or carriage return","",&cmarg,		  xxstring);#ifndef NOFRILLS	if ((x == -2) || (x == -1)) return(x);#else	if (x < 0) return(x);#endif /* NOFRILLS */	if (*cmarg == '{') {		/* Strip any enclosing braces */	    x = (int)strlen(cmarg);	/* This allows preservation of */	    if (cmarg[x-1] == '}') {	/* leading and/or trailing */		cmarg[x-1] = NUL;	/* spaces. */		cmarg++;	    }	}	x = doget();#ifdef MAC	if (sstate == 'r')	    scrcreate();#endif /* MAC */	return(x);    }#ifndef NOSPL#ifndef NOFRILLS    if (cx == XXGOK) {			/* GETOK */	return(success = doask(cx));    }#endif /* NOFRILLS */#endif /* NOSPL */    if (cx == XXHLP) {			/* HELP */#ifdef NOHELP	return(dohlp(XXHLP));        #else	x = cmkey2(cmdtab,ncmd,"C-Kermit command","help",toktab,xxstring);	debug(F101,"HELP command x","",x);	if (x == -5) {	    y = chktok(toktab);	    debug(F101,"top-level cmkey token","",y);	    ungword();	    switch (y) {#ifndef NOPUSH	      case '!': x = XXSHE; break;#endif /* NOPUSH */	      case '#': x = XXCOM; break;	      case ';': x = XXCOM; break;#ifndef NOSPL	      case ':': x = XXLBL; break;#endif /* NOSPL */	      case '&': x = XXECH; break;	      default:		printf("\n?Invalid - %s\n",cmdbuf);		x = -2;	    }	}	return(dohlp(x));#endif /* NOHELP */    } #ifndef NOHELP    if (cx == XXINT)			/* INTRO */      return(hmsga(introtxt));#endif /* NOHELP */    if (cx == XXHAN) {			/* HANGUP */	if ((x = cmcfm()) < 0) return(x);#ifndef NODIAL	if ((x = mdmhup()) < 1)#endif /* NODIAL */	  x = (tthang() > -1);	return(success = x);    }#ifndef NOSPL    if (cx == XXGOTO) {			/* GOTO *//* Note, here we don't set SUCCESS/FAILURE flag */	if ((y = cmfld("label","",&s,xxstring)) < 0) {	    if (y == -3) {		printf("?Label name required\n");		return(-9);	    } else return(y);	}	strcpy(lblbuf,s);	if ((x = cmcfm()) < 0) return(x);	s = lblbuf;	return(dogoto(s));    }#endif /* NOSPL */#ifndef NOSPL/* IF, Extended IF, WHILE */    if (cx == XXIF || cx == XXIFX || cx == XXWHI) {	return(doif(cx));    }#endif /* NOSPL */#ifndef NOSPL    if (cx == XXINP || cx == XXREI) {	/* INPUT and REINPUT */	y = cmnum("seconds to wait for input","1",10,&x,xxstring);	if (y < 0) {	    return(y);	}	if (x <= 0) x = 1;	if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)	  return(y);#ifdef COMMENT/*  Now it's ok -- null argument means wait for any character.*/	if (*s == '\0') {	    printf("?Text required\n");	    return(-9);	}#endif /* COMMENT */	if (*s == '{') {	    y = (int)strlen(s);	    if (s[y-1] == '}') {		s[y-1] = NUL;		s++;	    }	}	if (cx == XXINP) {		/* INPUT */	    debug(F110,"calling doinput",s,0);	    success = doinput(x,s);	/* Go try to input the search string */	} else {			/* REINPUT */	    debug(F110,"xxrei line",s,0);	    success = doreinp(x,s);	}	if (intime && !success) {	/* TIMEOUT-ACTION = QUIT? */	    popclvl();			/* If so, pop command level. */	    if (pflag && cmdlvl == 0) {		if (cx == XXINP) printf("?Input timed out\n");		if (cx == XXREI) printf("?Reinput failed\n");	    }	}	return(success);		/* Return do(re)input's return code */    }#endif /* NOSPL */#ifndef NOSPL    if (cx == XXLBL) {			/* LABEL */	if ((x = cmfld("label","",&s,xxstring)) < 0) {	    if (x == -3) {		printf("?Label name required\n");		return(-9);	    } else return(x);	}	if ((x = cmcfm()) < 0) return(x);	return(0);    }#endif /* NOSPL */    if (cx == XXLOG) {			/* LOG */	x = cmkey(logtab,nlog,"What to log","",xxstring);	if (x == -3) {	    printf("?Type of log required\n");	    return(-9);	}	if (x < 0) return(x);	x = dolog(x);	if (x < 0)	  return(x);	else	  return(success = x);    } #ifndef NOSCRIPT    if (cx == XXLOGI) {			/* UUCP-style script */	if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)	  return(x);#ifdef VMS	conres();			/* For Ctrl-C to work... */#endif /* VMS */

⌨️ 快捷键说明

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