📄 ckuusr.c
字号:
} cmsetp(psave); /* Restore old prompt. */ if ((x == cmcfm()) < 0) return(-2); } } sstate = 'r'; /* All ok, set start state. */ if (local) displa = 1; return(0);/* Form Feed */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));/* Form Feed */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; 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));/* Form Feed *//* 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; if (cmtxt("Unix shell command to execute","",&s) < 0) return(-1); conres(); /* Make console normal */#ifdef MSDOS zxcmd(s);#else#ifdef AMIGA zxcmd(s);#else#ifdef vax11c system(s); /* Best we can do for VMS? */#else /* All Unix systems... */ 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; shptr = shname = shpath; while (*shptr != '\0') if (*shptr++ == '/') shname = shptr; if (*s == NUL) /* Interactive shell requested? */ execl(shpath,shname,"-i",NULL); /* Yes, do that */ else /* Otherwise, */ execl(shpath,shname,"-c",s,NULL); /* exec the given command */ exit(GOOD_EXIT); } /* Just punt if it didnt work */ else { /* Parent */ int wstat; /* Kermit must wait for child */ int (*istat)(), (*qstat)(); istat = signal(SIGINT,SIG_IGN); /* Let the fork handle keyboard */ qstat = signal(SIGQUIT,SIG_IGN); /* interrupts itself... */ while (((wstat = wait(0)) != pid) && (wstat != -1)) /* Wait for fork */ ; signal(SIGINT,istat); /* Restore interrupts */ signal(SIGQUIT,qstat); }#endif#endif#endif concb(escape); /* Console back in cbreak mode */ return(0);}/* Form Feed */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: printf3("\nVersions:\n %s\n %s\n",versio,protv); printf2(" %s\n",fnsv); printf3(" %s\n %s\n",cmdv,userv); printf3(" %s for%s\n",ckxv,ckxsys); printf3(" %s for%s\n",ckzv,ckzsys); printf2(" %s\n",connv); printf3(" %s\n %s\n\n",dialv,loginv); break; default: printf("\nNothing to show...\n"); break; } return(0);case XXSPA: /* space */ if ((x = cmcfm()) < 0) return(x); system(SPACMD); return(0);case XXSTA: /* statistics */ if ((x = cmcfm()) < 0) return(x); printf("\nMost recent transaction --\n"); printf2(" files: %ld\n",filcnt); printf2(" total file characters : %ld\n",tfc); printf2(" communication line in : %ld\n",tlci); printf2(" communication line out : %ld\n",tlco); printf2(" elapsed time : %d sec\n",tsecs); if (filcnt > 0) { if (tsecs > 0) { long lx; lx = (tfc / tsecs) * 10; printf2(" effective baud rate : %ld\n",lx); if (speed > 0) { lx = (lx * 100) / speed; printf2(" efficiency : %ld %%\n",lx); } } printf2(" block check type used : %d\n",bctu); printf(" compression : "); if (rptflg) printf2("yes [%c]\n",rptq); else printf("no\n"); printf(" 8th bit prefixing : "); if (ebqflg) printf2("yes [%c]\n",ebq); else printf("no\n\n"); } else printf("\n"); return(0);/* Form Feed */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: printf2("Not available - %s\n",cmdbuf); return(-2); }}/* Form Feed *//* S H O P A R -- Show Parameters */shopar() { int i; extern struct keytab mdmtab[]; extern int nmdm; puts("\nCommunications Parameters:"); printf3(" Line: %s, speed: %d, mode: ",ttname,speed); if (local) printf("local"); else printf("remote"); for (i = 0; i < nmdm; i++) { if (mdmtab[i].val == mdmtyp) { printf2(", modem-dialer: %s",mdmtab[i].kwd); break; } } printf("\n Parity: "); switch (parity) { case 'e': printf("even"); break; case 'o': printf("odd"); break; case 'm': printf("mark"); break; case 's': printf("space"); break; case 0: printf("none"); break; default: printf2("invalid - %d",parity); break; } printf(", duplex: "); if (duplex) printf("half, "); else printf("full, "); printf("flow: "); if (flow == 1) printf("xon/xoff"); else if (flow == 0) printf("none"); else printf2("%d",flow); printf(", handshake: "); if (turn) printf2("%d\n",turnch); else printf("none\n"); printf("\nProtocol Parameters: Send Receive"); if (timef || spsizf) printf(" (* = override)"); printf3("\n Timeout: %11d%9d", rtimo, timint); if (timef) printf("*"); printf3("\n Padding: %11d%9d\n", npad, mypadn); printf3( " Pad Character:%11d%9d\n", padch, mypadc); printf3( " Packet Start: %11d%9d\n", mystch, stchr); printf3( " Packet End: %11d%9d\n", seol, eol); printf2( " Packet Length:%11d", spsiz); printf( spsizf ? "*" : " " ); printf2("%8d\n", rpsiz); printf3("\nBlock Check Type: %d, Delay: %d\n",bctr,delay); if (ebqflg) printf2("8th-Bit Prefix: '%c'\n",ebq); if (rptflg) printf2("Repeat-Count Prefix: '%c'\n",rptq); printf("\nFile parameters:\n File Names: "); if (fncnv) printf2("%-12s","converted"); else printf2("%-12s","literal");#ifdef DEBUG printf(" Debugging Log: "); if (deblog) printf2("%s",debfil); else printf("none");#endif printf("\n File Type: "); if (binary) printf2("%-12s","binary"); else printf2("%-12s","text"); printf(" Packet Log: "); if (pktlog) printf(pktfil); else printf("none"); printf("\n File Warning: "); if (warn) printf2("%-12s","on"); else printf2("%-12s","off"); printf(" Session Log: "); if (seslog) printf(sesfil); else printf("none"); printf("\n File Display: "); if (quiet) printf2("%-12s","off"); else printf2("%-12s","on");#ifdef TLOG printf(" Transaction Log: "); if (tralog) printf(trafil); else printf("none");#endif printf("\n\nIncomplete File Disposition: "); if (keep) printf("keep"); else printf("discard");#ifdef KERMRC printf2(", Init file: %s",KERMRC);#endif puts("\n");}/* Form Feed *//* 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. */}/* D O L O G -- Do the log command */dolog(x) int x; { int y; char *s; switch (x) { case LOGD:#ifdef DEBUG y = cmofi("Name of debugging log file","debug.log",&s);#else y = -2; s = ""; printf2("%s","- Sorry, debug log not available\n");#endif break; case LOGP: y = cmofi("Name of packet log file","packet.log",&s); break; case LOGS: y = cmofi("Name of session log file","session.log",&s); break; case LOGT:#ifdef TLOG y = cmofi("Name of transaction log file","transact.log",&s);#else y = -2; s = ""; printf2("%s","- Sorry, transaction log not available\n");#endif break; default: printf2("\n?Unexpected log designator - %d\n",x); return(-2); } if (y < 0) return(y); strcpy(line,s); s = line; if ((y = cmcfm()) < 0) return(y);/* cont'd... *//* Form Feed *//* ...dolog, cont'd */ switch (x) { case LOGD: return(deblog = debopn(s)); case LOGP: zclose(ZPFILE); y = zopeno(ZPFILE,s); if (y > 0) strcpy(pktfil,s); else *pktfil = '\0'; return(pktlog = y); case LOGS: zclose(ZSFILE); y = zopeno(ZSFILE,s); if (y > 0) strcpy(sesfil,s); else *sesfil = '\0'; return(seslog = y); case LOGT: zclose(ZTFILE); tralog = zopeno(ZTFILE,s); if (tralog > 0) { strcpy(trafil,s); tlog(F110,"Transaction Log:",versio,0l); tlog(F100,ckxsys,"",0); ztime(&s); tlog(F100,s,"",0l); } else *trafil = '\0'; return(tralog); default: return(-2); }}/* D E B O P N -- Open a debugging file */debopn(s) char *s; {#ifdef DEBUG char *tp; zclose(ZDFILE); deblog = zopeno(ZDFILE,s); if (deblog > 0) { strcpy(debfil,s); debug(F110,"Debug Log ",versio,0); debug(F100,ckxsys,"",0); ztime(&tp); debug(F100,tp,"",0); } else *debfil = '\0'; return(deblog);#else return(0);#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -