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

📄 ckuusr.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	return(success = 1);    }#endif /* NOSPL */#ifndef NODIAL    if (cx == XXRED  || cx == XXDIAL || cx == XXPDIA ||	cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */	x = dodial(cx);	debug(F101,"dodial returns","",x);	if ((cx == XXDIAL || cx == XXRED) &&	    (x > 0) &&			/* If DIAL or REDIAL succeeded */	    (dialcon > 0)) {	    if ( dialcon == 1 ||	/* And DIAL CONNECT is ON, */		(dialcon == 2 &&	/* or DIAL CONNECT is AUTO */#ifndef NOSPL				/* and we're at top level... */		 cmdlvl == 0#else		 tlevel == -1		 #endif /* NOSPL */		 )) /* Or AUTO */	      x = doconect(dialcq);	/* Then also CONNECT */	}	return(success = x);    }#endif /* NODIAL */#ifndef NOPUSH#ifdef CK_REXX    if (cx == XXREXX) {			/* REXX */        extern int nopush;        if ( nopush )          return(success=0);        return(dorexx());    }#endif /* CK_REXX */#endif /* NOPUSH */#ifndef NOFRILLS    if (cx == XXDEL) {			/* DELETE */#ifdef CK_APC	if (apcactive == APC_LOCAL ||         apcactive == APC_REMOTE && apcstatus != APC_UNCH) return(success = 0);#endif /* CK_APC */	return(dodel());    }#endif /* NOFRILLS */    if (cx == XXDIR)			/* DIRECTORY */      return(dodir());#ifndef NOSPL    if (cx == XXELS)			/* ELSE */      return(doelse());#endif /* NOSPL */#ifndef NOSERVER#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 = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {	    if (y == -3) {		printf("?Please specify remote, local, or both\n");		return(-9);	    } else return(y);	}	if (cx == XXDIS)		/* Disabling, not enabling */	  y = 3 - y; 	if ((z = cmcfm()) < 0) return(z);#ifdef CK_APC	if (apcactive == APC_LOCAL ||         apcactive == APC_REMOTE && apcstatus != APC_UNCH)	  return(success = 0);#endif /* CK_APC */	return(doenable(y,x));    }#endif /* NOFRILLS */#endif /* NOSERVER */#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,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);    }#endif /* NOSPL */    if (cx == XXECH || cx == XXXECH#ifndef NOSPL	|| cx == XXAPC#endif /* NOSPL */	) {				/* ECHO or APC */	if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?		       "Text to be echoed" :		       "Application Program Command text",		       "",&s,xxstring)) < 0)	  return(x);	s = brstrip(s);			/* Strip braces */	if (cx == XXECH) {		/* ECHO */	    printf("%s\n",s);	} else if (cx == XXXECH) {	/* XECHO */	    printf("%s",s);	} else {			/* APC */#ifdef CK_APC	    if (apcactive == APC_LOCAL ||             apcactive == APC_REMOTE && apcstatus != APC_UNCH)	      return(success = 0);#endif /* CK_APC */	    if (!local) {		printf("%c_%s%c\\",ESC,s,ESC);#ifdef UNIX		fflush(stdout);#endif /* UNIX */	    } else {#ifndef NOSPL		sprintf(tmpbuf,"%c_%s%c\\",ESC,s,ESC);		return(success = dooutput(tmpbuf));#else		printf("%c_%s%c\\",ESC,s,ESC);#endif /* NOSPL */	    }	}	return(1);			/* Always succeeds */    }#ifndef NOSPL    if (cx == XXOPE)			/* OPEN */      return(doopen());#endif /* NOSPL */#ifndef NOSPL    if (cx == XXOUT) {			/* OUTPUT */	int i;	if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)	  return(x);#ifdef CK_APC	if (apcactive == APC_LOCAL ||         apcactive == APC_REMOTE && apcstatus != APC_UNCH)	  return(success = 0);#endif /* CK_APC */	debug(F110,"OUTPUT 1",s,0);	s = brstrip(s);			/* Strip enclosing braces, */	debug(F110,"OUTPUT 2",s,0);/*  I don't think I could ever fully explain this in a million years...  We have read the user's string without calling the variable-expander  function.  Now, before we call it, we have to double backslashes that  appear before \N, \B, \L, and \ itself, so the expander function will  reduce them back to single backslashes, so when we call dooutput()...  But it's more complicated than that.*/	if (cmdgquo()) {		/* Only if COMMAND QUOTING ON ... */	    for (x = 0, y = 0; s[x]; x++, y++) {		if (s[x] == CMDQ) {		    char c = s[x+1];		    if (c == 'n' || c == 'N' ||			c == 'b' || c == 'B' ||			c == 'l' || c == 'L' ||			c == 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 - (int) strlen(line) - 1;	    debug(F101,"OUTPUT size","",x);	    if (zzstring(line,&s,&x) < 0)	      return(success = 0);	    s = line+y+1;	    debug(F110,"OUTPUT 4",s,0);	}	success = dooutput(s);	return(success);    }#endif /* NOSPL */#ifdef ANYX25    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 /* ANYX25 */#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);	s = "";#ifndef NT	if ((x = cmtxt("Local print command options, or carriage return","",&s,		       xxstring)) < 0)	  return(x);#endif /* NT */	if ((x = cmcfm()) < 0)	  return(x);	return(success = (zprint(s,line) == 0) ? 1 : 0);    }#ifdef TCPSOCKET    if (cx == XXPNG) 			/* PING an IP host */      return(doping());   if ( cx == XXFTP )			/* FTP an IP host */      return(doftp());#endif /* TCPSOCKET */    if (cx == XXPWD) {			/* PWD */#ifdef MAC	char *pwp;#else#ifdef OS2	char *pwp;#endif#endif /* MAC */	if ((x = cmcfm()) < 0)	  return(x);#ifndef MAC#ifndef OS2	xsystem(PWDCMD);	return(success = 1);		/* blind faith */#else	if (pwp = zgtdir()) {	    printf("%s\n",pwp);	    return(success = ((int)strlen(pwp) > 0));	} else return(success = 0);#endif#else	if (pwp = zgtdir()) {	    printf("%s\n",pwp);	    return(success = ((int)strlen(pwp) > 0));	} else return(success = 0);#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);	if (!hupok(0))			/* Check if connection still open */	  return(success = 0);#ifdef COMMENT#ifndef NODIAL	mdmhup();#endif /* NODIAL */#endif /* COMMENT */#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 */#ifdef CK_XYZ	if (protocol != PROTO_K) {	    printf("Sorry, E-PACKET only works with Kermit protocol\n");	    return(-9);	}#endif /* CK_XYZ */	if ((x = cmcfm()) < 0) return(x);	ttflui();	epktflg = 1;	sstate = 'a';	return(0);    }#endif /* NOFRILLS */    if (cx == XXFIN) {			/* FINISH */#ifdef CK_XYZ	if (protocol != PROTO_K) {	    printf("Sorry, FINISH only works with Kermit protocol\n");	    return(-9);	}#endif /* CK_XYZ */	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 */    /* GET MGET REGET RETRIEVE etc */    if (cx == XXGET || cx == XXREGET || cx == XXRETR) {#ifdef CK_XYZ	if (protocol != PROTO_K) {	    printf("Sorry, \"%s\" only works with Kermit protocol\n", atmbuf);	    return(-9);	}#endif /* CK_XYZ */	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 */	cmarg = brstrip(cmarg);		/* Strip braces */	x = doget(cx);#ifdef MAC	what = W_RECV;	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,1);	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));    if (cx == XXNEW)			/* NEWS */      return(hmsga(newstxt));#ifdef OS2ONLY    if (cx == XXUPD) {			/* View UPDATE file */        extern char exedir[];        char * pTopic;        char updstr[2048];        if ((x = cmtxt("topic n

⌨️ 快捷键说明

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