📄 ckuus5.c
字号:
extern char toktab[], ttname[], psave[];extern CHAR sstate, feol;extern int cmflgs, techo, repars, ncmd;extern struct keytab cmdtab[];#ifndef NOSETKEYKEY *keymap;#ifndef OS2#define mapkey(x) keymap[x]#endif /* OS2 */MACRO *macrotab;_PROTOTYP( VOID shostrdef, (CHAR *) );#endif /* NOSETKEY */extern int cmdlvl;#ifndef NOSPLextern struct mtab *mactab;extern struct keytab mackey[];extern struct keytab vartab[], fnctab[], iftab[];extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;#endif /* NOSPL */FILE *tfile[MAXTAKE]; /* TAKE file stack */char *tfnam[MAXTAKE];int tfline[MAXTAKE];int topcmd = -1; /* cmdtab index of current command */int havetoken = 0;extern int dblquo; /* Doublequoting enabled */#ifdef DCMDBUF /* Initialization filespec */char *kermrc = NULL;#elsechar kermrcb[KERMRCL];char *kermrc = kermrcb;#endif /* DCMDBUF */int noherald = 0;int cm_retry = 1; /* Command retry enabled */xx_strp xxstring = zzstring;#ifndef NOXFERextern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs, keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim, srvdis, query, retrans, streamed, reliable, crunched, timeouts, fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;#ifdef CK_AUTODLextern int inautodl, cmdadl;#endif /* CK_AUTODL */#ifndef NOSERVERextern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret, en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who, en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;#endif /* NOSERVER */extern int atcapr, atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko, attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;#ifdef STRATUSextern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;#endif /* STRATUS */#ifdef CK_PERMSextern int atlpri, atlpro, atgpri, atgpro;#endif /* CK_PERMS */#ifdef CK_LOGINextern char * anonfile; /* Anonymous login init file */extern char * anonroot; /* Anonymous file-system root */extern char * userfile; /* Forbidden user file */extern int isguest; /* Flag for anonymous user */#endif /* CK_LOGIN */#endif /* NOXFER */#ifdef DCMDBUFint *xquiet = NULL;#elseint xquiet[CMDSTKL];#endif /* DCMDBUF */char * prstring[CMDSTKL];#ifndef NOSPLextern long ck_alarm;extern char alrm_date[], alrm_time[];/* Local declarations */static int nulcmd = 0; /* Flag for next cmd to be ignored *//* Definitions for predefined macros *//* First, the single-line macros, installed with addmac()... *//* IBM-LINEMODE macro */char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";/* FATAL macro */char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";#ifdef CK_SPEED#ifdef IRIX65char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";#else#ifdef IRIX/* Because of bug in telnet server */char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\ set pref cautious";#else#ifdef pdp11char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";#else#ifdef BIGBUFOKchar *m_fast = "set win 30, set rec pack 4000, set prefix cautious";#elsechar *m_fast = "set win 4, set rec pack 2200, set prefix cautious";#endif /* BIGBUFOK */#endif /* IRIX */#endif /* IRIX65 */#endif /* pdp11 */#ifdef pdp11char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";#elsechar *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";#endif /* pdp11 */char *m_robust = "set win 1, set rec pack 90, set prefixing all, \set reliable off, set clearchannel off";#else#ifdef BIGBUFOK#ifdef IRIX65char *m_fast = "set win 30, set rec pack 4000";#else#ifdef IRIXchar *m_fast = "set win 30, set rec pack 4000, set send pack 4000";#elsechar *m_fast = "set win 30, set rec pack 4000";#endif /* IRIX */#endif /* IRIX65 */#else /* Not BIGBUFOK */char *m_fast = "set win 4, set rec pack 2200";#endif /* BIGBUFOK */char *m_cautious = "set win 4, set rec pack 1000";char *m_robust = "set win 1, set rec pack 90, set reliable off";#endif /* CK_SPEED */#ifdef VMSchar *m_purge = "run purge \\%*";#endif /* VMS */#ifdef OS2char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";#endif /* OS2 *//* Now the multiline macros, defined with addmmac()... *//* FOR macro for \%i-style loop variables (see dofor()...) */char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,","def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,","\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},","def break goto _..bot, def continue goto _..inc,","do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",""};/* This is the FOR macro when the loop variable is itself a macro */char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,","def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,","\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},","def break goto _..bot, def continue goto _..inc,","do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",""};/* WHILE macro */char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},","_def break goto _..bot, _def continue goto _..inc,","do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",""};/* SWITCH macro */char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,","_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,","do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",""};/* XIF macro */char *xif_def[] = {"_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},","do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",""};/* Variables declared here for use by other ckuus*.c modules. Space is allocated here to save room in ckuusr.c.*/#ifdef DCMDBUFstruct cmdptr *cmdstk;int *ifcmd = NULL, *count = NULL, *iftest = NULL, *intime = NULL, *inpcas = NULL, *takerr = NULL, *merror = NULL;#elsestruct cmdptr cmdstk[CMDSTKL];int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL], inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];#endif /* DCMDBUF *//* Macro stack */#ifdef COMMENTchar *topline = NULL; /* Program invocation arg line */char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */#endif /* COMMENT */char **m_xarg[MACLEVEL]; /* Pointers to arg vector arrays */int n_xarg[MACLEVEL]; /* Sizes of arg vector arrays */char *m_arg[MACLEVEL][NARGS]; /* Args of each level */int macargc[MACLEVEL]; /* Argc of each level */char *macp[MACLEVEL]; /* Current position in each macro */char *macx[MACLEVEL]; /* Beginning of each macro def */char *mrval[MACLEVEL]; /* RETURN value at each level */int lastcmd[MACLEVEL]; /* Last command at each level */int topargc = 0; /* Argc at top level */char **topxarg = NULL; /* Argv at top level */char *toparg[MAXARGLIST+2];/* Global Variables */char *g_var[GVARS+1]; /* Global \%a..z pointers */extern char varnam[]; /* \%x variable name buffer *//* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 *//* Note: a_link[x] < 0 means no link; >= 0 is a link */char **a_ptr[32]; /* Array pointers, for arrays a-z */int a_dim[32]; /* Dimensions for each array */int a_link[32]; /* Link (index of linked-to-array) */char **aa_ptr[CMDSTKL][32]; /* Array stack for automatic arrays */int aa_dim[CMDSTKL][32]; /* Dimensions for each array *//* INPUT command buffers and variables */char * inpbuf = NULL; /* Buffer for INPUT and REINPUT */extern char * inpbp; /* Global/static pointer to it */char inchar[2] = { NUL, NUL }; /* Last character that was INPUT */int incount = 0; /* INPUT character count */extern int instatus; /* INPUT status */static char * i_text[] = { /* INPUT status text */ "success", "timeout", "interrupted", "internal error", "i/o error"};char lblbuf[LBLSIZ]; /* Buffer for labels */#else /* NOSPL */int takerr[MAXTAKE];#endif /* NOSPL */static char *prevdir = NULL;int pacing = 0; /* OUTPUT pacing */char *tp; /* Temporary buffer pointer */int timelimit = 0, asktimer = 0; /* Timers for time-limited commands */#ifdef CK_APC /* Application Program Command (APC) */int apcactive = APC_INACTIVE;int apcstatus = APC_OFF; /* OFF by default everywhere */#ifdef DCMDBUFchar *apcbuf;#elsechar apcbuf[APCBUFLEN];#endif /* DCMDBUF */#endif /* CK_APC */extern char pktfil[],#ifdef DEBUG debfil[],#endif /* DEBUG */#ifdef TLOG trafil[],#endif /* TLOG */ sesfil[];#ifndef NOFRILLSextern int rmailf, rprintf; /* REMOTE MAIL & PRINT items */extern char optbuf[];#endif /* NOFRILLS */extern int noinit; /* Flat to skip init file */#ifndef NOSPLstatic struct keytab kcdtab[] = { /* Symbolic directory names */#ifdef NT { "appdata", VN_APPDATA, 0 }, { "common", VN_COMMON, 0 }, { "desktop", VN_DESKTOP, 0 },#endif /* NT */ { "download", VN_DLDIR, 0 },#ifdef OS2ORUNIX { "exedir", VN_EXEDIR, 0 },#endif /* OS2ORUNIX */ { "home", VN_HOME, 0 }, { "inidir", VN_INI, 0 },#ifdef UNIX { "lockdir", VN_LCKDIR, 0 },#endif /* UNIX */#ifdef NT { "personal", VN_PERSONAL, 0 },#endif /* NT */ { "startup", VN_STAR, 0 }, { "textdir", VN_TXTDIR, 0 }, { "tmpdir", VN_TEMP, 0 }};static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));#endif /* NOSPL */#ifndef NOSPL_PROTOTYP( VOID freelocal, (int) );_PROTOTYP( static long expon, (long, long) );_PROTOTYP( static long gcd, (long, long) );_PROTOTYP( static long fact, (long) );int /* Initialize macro data structures. */macini() { /* Allocate mactab and preset the first element. */ int i; if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX))) return(-1); mactab[0].kwd = NULL; mactab[0].mval = NULL; mactab[0].flgs = 0; for (i = 0; i < MACLEVEL; i++) localhead[i] = NULL; return(0);}#endif /* NOSPL *//* C M D S R C -- Returns current command source *//* 0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) *//* As of 19 Aug 2000 this routine is obsolete. The scalar global variable xcmdsrc can be checked instead to save the overhead of a function call.*/intcmdsrc() {#ifdef COMMENT return(xcmdsrc);#else#ifndef NOSPL if (cmdlvl == 0) return(0); else if (cmdstk[cmdlvl].src == CMD_MD) return(2); else if (cmdstk[cmdlvl].src == CMD_TF) return(1); else return(-1);#else if (tlevel < 0) return(0); else return(1);#endif /* NOSPL */#endif /* COMMENT */}/* C M D I N I -- Initialize the interactive command parser */static int cmdinited = 0; /* Command parser initialized */extern int cmdint; /* Interrupts are allowed */#ifdef CK_AUTODLint cmdadl = 1; /* Autodownload */#elseint cmdadl = 0;#endif /* CK_AUTODL */char * k_info_dir = NULL; /* Where to find text files */#ifdef UNIXstatic char * txtdir[] = { "/usr/local/doc/", /* Linux, SunOS, ... */ "/usr/share/lib/", /* HP-UX 10.xx... */ "/usr/share/doc/", /* Other possibilities... */ "/usr/local/lib/", /* NOTE: Each of these is tried */ "/usr/local/share/", /* as is, and also with a kermit */ "/usr/local/share/doc/", /* subdirectory. */ "/usr/local/share/lib/", "/opt/kermit/", /* Solaris */ "/opt/kermit/doc/", "/opt/", "/usr/doc/", "/doc/", ""};#endif /* UNIX *//* lookup() cache to speed up script execution. This is a static cache. Items are stored in decreasing frequency of reference based on statistics from a range of scripts. This gives better performance than a dynamic cache, which would require a lot more code and also would require system-dependent elements including system calls (e.g. to get subsecond times for entry aging).*/#ifdef USE_LUCACHE /* Set in ckuusr.h */#define LUCACHE 32 /* Change this to reduce cache size */int lusize = 0;char * lucmd[LUCACHE];int luval[LUCACHE];int luidx[LUCACHE];struct keytab * lutab[LUCACHE];#endif /* USE_LUCACHE */static VOIDluinit() { /* Initialize lookup() cache */ int x, y;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -