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

📄 ckuusr.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	    if (tralog == 0) {		printf("?Transaction log wasn't open\n");		return(0);	    }	    *trafil = '\0';	    tralog = 0;	    return(zclose(ZTFILE)); 	default:	    printf("\n?Unexpected log designator - %ld\n", x);	    return(0);    }case XXDIAL:				/* dial number */    if ((x = cmtxt("Number to be dialed","",&s)) < 0) return(x);    return(ckdial(s)); case XXDIR:				/* directory */#ifdef AMIGA    if ((x = cmtxt("Directory/file specification","",&s)) < 0) return(x);#else#ifdef datageneral    if ((x = cmtxt("Directory/file specification","+",&s)) < 0) return(x);#else    if ((x = cmtxt("Directory/file specification",".",&s)) < 0) return(x);#endif#endif    lp = line;    sprintf(lp,"%s %s",DIRCMD,s);    system(line);    return(0);  case XXECH: 				/* echo */    if ((x = cmtxt("Material to be echoed","",&s)) < 0) return(x);    for ( ; *s; s++) {	if ((x = *s) == 0134) {		/* Convert octal escapes */	    s++;			/* up to 3 digits */	    for (x = y = 0; *s >= '0' && *s <= '7' && y < 3; s++,y++) {	    	x = x * 8 + (int) *s - 48;	    }	    s--;        }	putchar(x);    }    printf("\n");    return(0); case XXQUI:				/* quit, exit */case XXEXI:    if ((x = cmcfm()) > -1) doexit(GOOD_EXIT);    else return(x); case XXFIN:				/* finish */    if ((x = cmcfm()) < 0) return(x);    if (!local) {	printf("You have to 'set line' first\n");	return(0);    }    sstate = setgen('F',"","","");    return(0);case XXGET:				/* get */    if (!local) {	printf("\nYou have to 'set line' first\n");	return(0);    }    x = cmtxt("Name of remote file(s), or carriage return","",&cmarg);    if ((x == -2) || (x == -1)) return(x); /* If foreign file name omitted, get foreign and local names separately */     x = 0;				/* For some reason cmtxt returns 1 */    if (*cmarg == NUL) { 	if (tlevel > -1) {		/* Input is from take file */ 	    if (fgets(line,100,tfile[tlevel]) == NULL)	    	fatal("take file ends prematurely in 'get'");debug(F110,"take-get 2nd line",line,0);	    stripq(line);	    for (x = strlen(line);	     	 x > 0 && (line[x-1] == '\n' || line[x-1] == '\r');		 x--)		line[x-1] = '\0';	    cmarg = line;	    if (fgets(cmdbuf,CMDBL,tfile[tlevel]) == NULL)	    	fatal("take file ends prematurely in 'get'");	    stripq(cmdbuf);	    for (x = strlen(cmdbuf);	     	 x > 0 && (cmdbuf[x-1] == '\n' || cmdbuf[x-1] == '\r');		 x--)		cmdbuf[x-1] = '\0';	    if (*cmdbuf == NUL) cmarg2 = line; else cmarg2 = cmdbuf;            x = 0;			/* Return code */        } else {			/* Input is from terminal */ 	    char psave[40];		/* Save old prompt */	    cmsavp(psave,40);	    cmsetp(" Remote file specification: "); /* Make new one */	    cmini(ckxech);	    x = -1;	    if (!backgrd) prompt();	    while (x == -1) {		/* Prompt till they answer */	    	x = cmtxt("Name of remote file(s)","",&cmarg);		debug(F111," cmtxt",cmarg,x);	    }	    if (x < 0) {		cmsetp(psave);		return(x);	    }	    if (*cmarg == NUL) { 	/* If user types a bare CR, */		printf("(cancelled)\n"); /* Forget about this. */	    	cmsetp(psave);		/* Restore old prompt, */		return(0);		/* and return. */	    }	    strcpy(line,cmarg);		/* Make a safe copy */	    cmarg = line;	    cmsetp(" Local name to store it under: ");	/* New prompt */	    cmini(ckxech);	    x = -1;	    if (!backgrd) prompt();	    while (x == -1) {		/* Again, parse till answered */	    	x = cmofi("Local file name","",&cmarg2);	    }	    if (x == -3) {	    	    	/* If bare CR, */		printf("(cancelled)\n");	/* escape from this... */	    	cmsetp(psave);		        /* Restore old prompt, */		return(0);		    	/* and return. */	    } else if (x < 0) return(x);        /* Handle parse errors. */	    	    x = -1;			/* Get confirmation. */	    while (x == -1) x = cmcfm();	    cmsetp(psave);		/* Restore old prompt. */        }    }    if (x == 0) {			/* Good return from cmtxt or cmcfm, */	sstate = 'r';			/* set start state. */	if (local) displa = 1;    }    return(x);case XXHLP:				/* Help */    x = cmkey(cmdtab,ncmd,"C-Kermit command","help");    return(dohlp(x)); case XXLOG:				/* Log */    x = cmkey(logtab,nlog,"What to log","");    if (x == -3) {	printf("?You must specify what is to be logged\n");	return(-2);    }    if (x < 0) return(x);    return(dolog(x)); case XXLOGI:				/* Send script remote system */    if ((x = cmtxt("Text of login script","",&s)) < 0) return(x);    return( login(s) );			/* Return 0=completed, -2=failed */ case XXREC:				/* Receive */    cmarg2 = "";    x = cmofi("Name under which to store the file, or CR","",&cmarg2);    if ((x == -1) || (x == -2)) return(x);    debug(F111,"cmofi cmarg2",cmarg2,x);    if ((x = cmcfm()) < 0) return(x);    sstate = 'v';    if (local) displa = 1;    return(0); case XXREM:				/* Remote */    if (!local) {	printf("\nYou have to 'set line' first\n");	return(-2);    }    x = cmkey(remcmd,nrmt,"Remote Kermit server command","");    if (x == -3) {	printf("?You must specify a command for the remote server\n");	return(-2);    }    return(dormt(x));case XXSEN:				/* Send */    cmarg = cmarg2 = "";    if ((x = cmifi("File(s) to send","",&s,&y)) < 0) {	if (x == -3) {	    printf("?A file specification is required\n");	    return(-2);	}	return(x);    }    nfils = -1;				/* Files come from internal list. */    strcpy(line,s);			/* Save copy of string just parsed. */    debug(F101,"Send: wild","",y);    *cmarg2 = '\0';			/* Initialize send-as name */    if (y == 0) {	if ((x = cmtxt("Name to send it with","",&cmarg2)) < 0) return(x);    } else {	if ((x = cmcfm()) < 0) return(x);    }    cmarg = line;			/* File to send */    debug(F110,"Sending:",cmarg,0);    if (*cmarg2 != '\0') debug(F110," as:",cmarg2,0);    sstate = 's';			/* Set start state */    if (local) displa = 1;    return(0); case XXSER:				/* Server */    if ((x = cmcfm()) < 0) return(x);    sstate = 'x';    if (local) displa = 1;#ifdef AMIGA    reqoff();				/* no DOS requestors while server */#endif    return(0); case XXSET:				/* Set */    x = cmkey(prmtab,nprm,"Parameter","");    if (x == -3) {	printf("?You must specify a parameter to set\n");	return(-2);    }    if (x < 0) return(x);    return(doprm(x));    /* XXSHE code by H. Fischer; copyright rights assigned to Columbia Univ *//* Adapted to use getpwuid to find login shell because many systems do not have SHELL in environment, and to use direct calling of shell rather than intermediate system() call. -- H. Fischer*/case XXSHE:				/* Local shell command */    {    int pid;#ifdef AMIGA    if (cmtxt("Command to execute","",&s) < 0) return(-1);#else    if (cmtxt("Unix shell command to execute","",&s) < 0) return(-1);#endif    conres();				/* Make console normal  */#ifdef AMIGA    system(s);#else#ifdef MSDOS    zxcmd(s);#else#ifdef vax11c     system(s);				/* Best we can do for VMS? */#else					/* All Unix systems... */#ifdef datageneral    if (*s == NUL)			/* Interactive shell requested? */#ifdef mvux	system("/bin/sh ");#else        system("x :cli prefix Kermit_Baby:");#endif    else				/* Otherwise, */        system(s);			/* Best for aos/vs?? */ #else					/* All Unix systems... */#ifdef apollo    if ((pid = vfork()) == 0) {		/* Make child quickly */	char *shpath, *shname, *shptr;	/* For finding desired shell */        if ((shpath = getenv("SHELL")) == NULL) shpath = "/com/sh";#else     if ((pid = fork()) == 0) {		/* Make child */	char *shpath, *shname, *shptr;	/* For finding desired shell */	struct passwd *p;	extern struct passwd * getpwuid();	extern int getuid();	char *defShel = "/bin/sh";	/* Default */ 	p = getpwuid( getuid() );	/* Get login data */	if ( p == (struct passwd *) NULL || !*(p->pw_shell) )	    shpath = defShel;	else	    shpath = p->pw_shell;#endif	shptr = shname = shpath;	while (*shptr != '\0')	    if (*shptr++ == '/') shname = shptr;/* Remove following uid calls if they cause trouble */#ifdef BSD4	setegid(getgid());		/* Override 4.3BSD csh security */	seteuid(getuid());		/*  checks. */#endif	if (*s == NUL)			/* Interactive shell requested? */	    execl(shpath,shname,"-i",(char *)NULL);    /* Yes, do that */	else				/* Otherwise, */	    execl(shpath,shname,"-c",s,(char *)NULL); /* exec the given command */	exit(BAD_EXIT); }		/* Just punt if it didn't work */     else {				/* Parent */     	int wstat;			/* Kermit must wait for child */	SIGTYP (*istat)(), (*qstat)(); 	istat = signal(SIGINT,SIG_IGN);	/* Let the fork handle keyboard */	qstat = signal(SIGQUIT,SIG_IGN); /* interrupts itself... */     	while (((wstat = wait((int *)0)) != pid) && (wstat != -1))	                                /* Wait for fork */	signal(SIGINT,istat);		/* Restore interrupts */	signal(SIGQUIT,qstat);    }#endif#endif#endif#endif    concb(escape);			/* Console back in cbreak mode */    return(0);}case XXSHO:				/* Show */    x = cmkey(shotab,2,"","parameters");    if (x < 0) return(x);    if ((y = cmcfm()) < 0) return(y);    switch (x) { 	case SHPAR:	    shopar();	    break; 	case SHVER:	    printf("\nVersions:\n %s\n %s\n",versio,protv);	    printf(" %s\n",fnsv);	    printf(" %s\n %s\n",cmdv,userv);	    printf(" %s for%s\n",ckxv,ckxsys);	    printf(" %s for%s\n",ckzv,ckzsys);	    printf(" %s\n",connv);	    printf(" %s\n %s\n\n",dialv,loginv);	    break; 	default:	    printf("\nNothing to show...\n");	    break;    }    return(0); case XXSPA:				/* space */#ifdef datageneral    /* The DG can take an argument after its "space" command. */    if ((x = cmtxt("Confirm, or local directory name","",&s)) < 0) return(x);    if (*s == NULL) system(SPACMD);    else {    	char *cp;    	cp = alloc(strlen(s) + 7);      /* For "space *s" */    	strcpy(cp,"space "), strcat(cp,s);    	system(cp);    	free(cp);    }#else    if ((x = cmcfm()) < 0) return(x);    system(SPACMD);#endif    return(0); case XXSTA:				/* statistics */    if ((x = cmcfm()) < 0) return(x);    return(dostat());case XXTAK:				/* take */    if (tlevel > MAXTAKE-1) {	printf("?Take files nested too deeply\n");	return(-2);    }    if ((y = cmifi("C-Kermit command file","",&s,&x)) < 0) { 	if (y == -3) {	    printf("?A file specification is required\n");	    return(-2);	} else return(y);    }    if (x != 0) {	printf("?Wildcards not allowed in command file name\n");	return(-2);    }    strcpy(line,s);			/* Make a safe copy of the string */    if ((y = cmcfm()) < 0) return(y);    if ((tfile[++tlevel] = fopen(line,"r")) == NULL) {	perror(line);	debug(F110,"Failure to open",line,0);	tlevel--;    }    return(0); default:    printf("Not available - %s\n",cmdbuf);    return(-2);    }}/*  D O C O N E C T  --  Do the connect command  */ /*  Note, we don't call this directly from dial, because we need to give *//*  the user a chance to change parameters (e.g. parity) after the *//*  connection is made. */ doconect() {    int x;    conres();				/* Put console back to normal */    x = conect();			/* Connect */    concb(escape);			/* Put console into cbreak mode, */    return(x);				/* for more command parsing. */}

⌨️ 快捷键说明

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