6 int cmdsrc() { return(0); }
9 /* C K U U S 5 -- "User Interface" for C-Kermit, part 5 */
13 Frank da Cruz <fdc@columbia.edu>,
14 The Kermit Project, Columbia University, New York City
15 Jeffrey E Altman <jaltman@secure-endpoints.com>
16 Secure Endpoints Inc., New York City
18 Copyright (C) 1985, 2004,
19 Trustees of Columbia University in the City of New York.
20 All rights reserved. See the C-Kermit COPYING.TXT file or the
21 copyright text in the ckcmai.c module for disclaimer and permissions.
32 char *line; /* Character buffer for anything */
35 char line[LINBUFSIZ+1];
36 char tmpbuf[TMPBUFSIZ+1]; /* Temporary buffer */
56 #define INCL_VIO /* Needed for ckocon.h */
61 #define TAPI_CURRENT_VERSION 0x00010004
66 extern int DialerHandle;
67 extern int StartedFromDialer;
77 #define putchar(x) conoc(x)
78 extern int cursor_save ;
79 extern bool cursorena[] ;
82 /* For formatted screens, "more?" prompting, etc. */
85 #define isxdigit(c) isdigit(c)
88 #ifdef STRATUS /* Stratus Computer, Inc. VOS */
92 #define putchar(x) conoc(x)
96 #define getchar(x) coninc(0)
99 /* External variables */
101 extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
102 binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
103 inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
104 zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
105 debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
106 rcdactive, keepallchars;
109 extern int locus, autolocus;
117 extern int prefixing;
118 #endif /* CK_SPEED */
120 extern int g_matchdot;
123 extern int recursive;
124 #endif /* RECURSIVE */
125 extern int xfiletype;
128 extern char * iksdconf;
130 #endif /* IKSDCONF */
133 extern int on_recall;
134 #endif /* CK_RECALL */
136 extern int ngetpath, exitonclose;
137 extern char * getpath[];
138 extern CHAR * epktmsg;
140 extern char * snd_move;
141 extern char * snd_rename;
142 extern char * rcv_move;
143 extern char * rcv_rename;
144 extern char * g_snd_move;
145 extern char * g_snd_rename;
146 extern char * g_rcv_move;
147 extern char * g_rcv_rename;
152 extern char unm_mch[];
153 extern char unm_mod[];
154 extern char unm_nam[];
155 extern char unm_rel[];
156 extern char unm_ver[];
157 #endif /* CK_UTSNAME */
161 extern char editor[];
162 extern char editfile[];
163 extern char editopts[];
165 extern char browser[];
166 extern char browsopts[];
167 extern char browsurl[];
169 #endif /* NOFRILLS */
173 extern char * x_user, * x_passwd, * x_acct;
174 #endif /* NOSERVER */
178 extern char diafil[];
179 #endif /* CKLOGDIAL */
182 extern int ckrooterr;
186 extern int cfilef, xxdot;
187 extern char cmdfil[];
189 struct localvar * localhead[CMDSTKL];
190 struct localvar * localtail = NULL;
191 struct localvar * localnext = NULL;
193 _PROTOTYP( VOID shosexp, (void) );
194 _PROTOTYP( static VOID shoinput, (void) );
195 _PROTOTYP( static char gettok, (void) );
196 _PROTOTYP( static VOID factor, (void) );
197 _PROTOTYP( static VOID term, (void) );
198 _PROTOTYP( static VOID termp, (void) );
199 _PROTOTYP( static VOID exprp, (void) );
200 _PROTOTYP( static VOID expr, (void) );
201 _PROTOTYP( static VOID simple, (void) );
202 _PROTOTYP( static VOID simpler, (void) );
203 _PROTOTYP( static VOID simplest, (void) );
204 _PROTOTYP( static long xparse, (void) );
207 _PROTOTYP( int sho_iks, (void) );
211 char * ckprompt = "Mac-Kermit>"; /* Default prompt for Macintosh */
212 char * ikprompt = "IKSD>";
216 char * ckprompt = "K-95> "; /* Default prompt for Win32 */
217 char * ikprompt = "IKSD> ";
219 char * ckprompt = "C-Kermit>";
220 char * ikprompt = "IKSD>";
224 /* Default prompt for OS/2 and Win32 */
226 char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
227 char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
229 char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
230 char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
234 char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
235 char * ikprompt = "\\v(dir) IKSD>";
237 char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
238 char * ikprompt = "(\\v(dir)) IKSD>";
245 #define CCHMAXPATH 257
246 #endif /* CCHMAXPATH */
247 char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
250 extern int tn_b_nlm; /* TELNET BINARY newline mode */
254 extern struct keytab kverbs[]; /* Table of \Kverbs */
255 extern int nkverbs; /* Number of \Kverbs */
256 #endif /* NOKVERBS */
263 extern int cm_recall;
264 #endif /* CK_RECALL */
266 extern char *ccntab[];
270 extern char *printername;
271 extern int printpipe;
273 extern int printbidi, pportparity, pportflow;
274 extern long pportspeed;
278 _PROTOTYP (int os2getcp, (void) );
279 _PROTOTYP (int os2getcplist, (int *, int) );
282 #endif /* OS2MOUSE */
283 extern int tt_update, tt_updmode, updmode, tt_utf8;
285 extern int tt_status[];
286 #endif /* IKSDONLY */
288 extern struct keytab term_font[];
291 extern struct keytab * term_font;
294 extern int ntermfont, tt_font, tt_font_size;
295 extern unsigned char colornormal, colorunderline, colorstatus,
296 colorhelp, colorselect, colorborder, colorgraphic, colordebug,
297 colorreverse, colorcmd, coloritalic;
299 extern struct keytab prtytab[];
301 char * cmdmac = NULL;
305 _PROTOTYP (int zkermini, (char *, int, char *) );
309 extern int inecho, insilence, inbufsize, nvars, inintr;
310 extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
315 #ifdef CK_AUTHENTICATION
316 extern char * ckathv;
317 #endif /* CK_AUTHENTICATION */
319 extern char * cksslv;
323 extern char * ckcrpv;
324 #endif /* CRYPT_DLL */
325 #endif /* CK_ENCRYPTION */
330 extern char *cksftpv;
331 #endif /* SFTP_BUILTIN */
332 #endif /* SSHBUILTIN */
339 extern char * ckftpv;
346 extern char *ckonetv;
349 extern char *ckonbiv;
350 #endif /* CK_NETBIOS */
352 extern char *ckomouv;
353 #endif /* OS2MOUSE */
365 #endif /* NOSCRIPT */
368 extern int nmdm, dirline;
369 extern struct keytab mdmtab[];
372 extern int network, nettype, ttnproto;
376 /* SET TERMINAL items... */
377 extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
378 extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
379 extern char answerback[];
380 extern struct tt_info_rec tt_info[]; /* Indexed by terminal type */
385 _PROTOTYP( VOID shotrm, (void) );
386 _PROTOTYP( int shofea, (void) );
389 extern int tt_rows[], tt_cols[];
391 extern int tt_rows, tt_cols;
393 extern int cmd_rows, cmd_cols;
396 extern int f_tmpdir; /* Directory changed temporarily */
397 extern char savdir[]; /* Temporary directory */
398 #endif /* CK_TMPDIR */
401 extern int tt_crd, tt_escape;
405 extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
406 extern struct keytab fcstab[];
407 extern struct csinfo fcsinfo[];
409 extern struct keytab ttcstab[];
416 extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
417 extern char xmitbuf[];
420 extern char **xargv, *versio, *ckxsys, *dftty, *lp;
423 extern char *cmdbuf, *atmbuf; /* Command buffers */
425 extern char *savbuf; /* Command buffers */
428 extern char cmdbuf[], atmbuf[]; /* Command buffers */
430 extern char savbuf[]; /* Command buffers */
434 extern char toktab[], ttname[], psave[];
435 extern CHAR sstate, feol;
436 extern int cmflgs, techo, repars, ncmd;
437 extern struct keytab cmdtab[];
442 #define mapkey(x) keymap[x]
445 _PROTOTYP( VOID shostrdef, (CHAR *) );
446 #endif /* NOSETKEY */
451 extern struct mtab *mactab;
452 extern struct keytab mackey[];
453 extern struct keytab vartab[], fnctab[], iftab[];
454 extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
457 FILE *tfile[MAXTAKE]; /* TAKE file stack */
458 char *tfnam[MAXTAKE];
461 int topcmd = -1; /* cmdtab index of current command */
463 extern int dblquo; /* Doublequoting enabled */
465 #ifdef DCMDBUF /* Initialization filespec */
468 char kermrcb[KERMRCL];
469 char *kermrc = kermrcb;
473 int cm_retry = 1; /* Command retry enabled */
474 xx_strp xxstring = zzstring;
477 extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
478 keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
479 srvdis, query, retrans, streamed, reliable, crunched, timeouts,
480 fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
483 extern int inautodl, cmdadl;
484 #endif /* CK_AUTODL */
487 extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
488 en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
489 en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
490 #endif /* NOSERVER */
493 atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
494 attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
497 extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
501 extern int atlpri, atlpro, atgpri, atgpro;
502 #endif /* CK_PERMS */
505 extern char * anonfile; /* Anonymous login init file */
506 extern char * anonroot; /* Anonymous file-system root */
507 extern char * userfile; /* Forbidden user file */
508 extern int isguest; /* Flag for anonymous user */
509 #endif /* CK_LOGIN */
518 char * prstring[CMDSTKL];
522 extern long ck_alarm;
523 extern char alrm_date[], alrm_time[];
525 /* Local declarations */
527 static int nulcmd = 0; /* Flag for next cmd to be ignored */
529 /* Definitions for predefined macros */
531 /* First, the single-line macros, installed with addmac()... */
533 /* IBM-LINEMODE macro */
534 char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
537 char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
541 char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
544 /* Because of bug in telnet server */
545 char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
549 char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
552 char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
554 char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
555 #endif /* BIGBUFOK */
560 char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
562 char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
564 char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
565 set reliable off, set clearchannel off";
569 char *m_fast = "set win 30, set rec pack 4000";
572 char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
574 char *m_fast = "set win 30, set rec pack 4000";
577 #else /* Not BIGBUFOK */
578 char *m_fast = "set win 4, set rec pack 2200";
579 #endif /* BIGBUFOK */
580 char *m_cautious = "set win 4, set rec pack 1000";
581 char *m_robust = "set win 1, set rec pack 90, set reliable off";
582 #endif /* CK_SPEED */
585 char *m_purge = "run purge \\%*";
589 char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
592 /* Now the multiline macros, defined with addmmac()... */
594 /* FOR macro for \%i-style loop variables (see dofor()...) */
596 char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
597 "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
598 "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
599 "def break goto _..bot, def continue goto _..inc,",
600 "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
603 /* This is the FOR macro when the loop variable is itself a macro */
605 char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
606 "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
607 "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
608 "def break goto _..bot, def continue goto _..inc,",
609 "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
613 char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
614 ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
615 "_def break goto _..bot, _def continue goto _..inc,",
616 "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
620 char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
621 "_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
622 "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
627 "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
628 "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
632 Variables declared here for use by other ckuus*.c modules.
633 Space is allocated here to save room in ckuusr.c.
636 struct cmdptr *cmdstk;
646 struct cmdptr cmdstk[CMDSTKL];
647 int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
648 inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
654 char *topline = NULL; /* Program invocation arg line */
655 char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
658 char **m_xarg[MACLEVEL]; /* Pointers to arg vector arrays */
659 int n_xarg[MACLEVEL]; /* Sizes of arg vector arrays */
660 char *m_arg[MACLEVEL][NARGS]; /* Args of each level */
661 int macargc[MACLEVEL]; /* Argc of each level */
662 char *macp[MACLEVEL]; /* Current position in each macro */
663 char *macx[MACLEVEL]; /* Beginning of each macro def */
664 char *mrval[MACLEVEL]; /* RETURN value at each level */
665 int lastcmd[MACLEVEL]; /* Last command at each level */
666 int topargc = 0; /* Argc at top level */
667 char **topxarg = NULL; /* Argv at top level */
668 char *toparg[MAXARGLIST+2];
670 /* Global Variables */
672 char *g_var[GVARS+1]; /* Global \%a..z pointers */
673 extern char varnam[]; /* \%x variable name buffer */
675 /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
676 /* Note: a_link[x] < 0 means no link; >= 0 is a link */
678 char **a_ptr[32]; /* Array pointers, for arrays a-z */
679 int a_dim[32]; /* Dimensions for each array */
680 int a_link[32]; /* Link (index of linked-to-array) */
682 char **aa_ptr[CMDSTKL][32]; /* Array stack for automatic arrays */
683 int aa_dim[CMDSTKL][32]; /* Dimensions for each array */
685 /* INPUT command buffers and variables */
687 char * inpbuf = NULL; /* Buffer for INPUT and REINPUT */
688 extern char * inpbp; /* Global/static pointer to it */
689 char inchar[2] = { NUL, NUL }; /* Last character that was INPUT */
690 int incount = 0; /* INPUT character count */
691 extern int instatus; /* INPUT status */
692 static char * i_text[] = { /* INPUT status text */
693 "success", "timeout", "interrupted", "internal error", "i/o error"
696 char lblbuf[LBLSIZ]; /* Buffer for labels */
703 static char *prevdir = NULL;
705 int pacing = 0; /* OUTPUT pacing */
707 char *tp; /* Temporary buffer pointer */
709 int timelimit = 0, asktimer = 0; /* Timers for time-limited commands */
711 #ifdef CK_APC /* Application Program Command (APC) */
712 int apcactive = APC_INACTIVE;
713 int apcstatus = APC_OFF; /* OFF by default everywhere */
717 char apcbuf[APCBUFLEN];
721 extern char pktfil[],
731 extern int rmailf, rprintf; /* REMOTE MAIL & PRINT items */
732 extern char optbuf[];
733 #endif /* NOFRILLS */
735 extern int noinit; /* Flat to skip init file */
738 static struct keytab kcdtab[] = { /* Symbolic directory names */
740 { "appdata", VN_APPDATA, 0 },
741 { "common", VN_COMMON, 0 },
742 { "desktop", VN_DESKTOP, 0 },
744 { "download", VN_DLDIR, 0 },
746 { "exedir", VN_EXEDIR, 0 },
747 #endif /* OS2ORUNIX */
748 { "home", VN_HOME, 0 },
749 { "inidir", VN_INI, 0 },
751 { "lockdir", VN_LCKDIR, 0 },
754 { "personal", VN_PERSONAL, 0 },
756 { "startup", VN_STAR, 0 },
757 { "textdir", VN_TXTDIR, 0 },
758 { "tmpdir", VN_TEMP, 0 }
760 static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
764 _PROTOTYP( VOID freelocal, (int) );
765 _PROTOTYP( static long expon, (long, long) );
766 _PROTOTYP( static long gcd, (long, long) );
767 _PROTOTYP( static long fact, (long) );
769 int /* Initialize macro data structures. */
770 macini() { /* Allocate mactab and preset the first element. */
772 if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
774 mactab[0].kwd = NULL;
775 mactab[0].mval = NULL;
777 for (i = 0; i < MACLEVEL; i++)
783 /* C M D S R C -- Returns current command source */
785 /* 0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
788 As of 19 Aug 2000 this routine is obsolete. The scalar global variable
789 xcmdsrc can be checked instead to save the overhead of a function call.
799 else if (cmdstk[cmdlvl].src == CMD_MD)
801 else if (cmdstk[cmdlvl].src == CMD_TF)
814 /* C M D I N I -- Initialize the interactive command parser */
816 static int cmdinited = 0; /* Command parser initialized */
817 extern int cmdint; /* Interrupts are allowed */
819 int cmdadl = 1; /* Autodownload */
822 #endif /* CK_AUTODL */
824 char * k_info_dir = NULL; /* Where to find text files */
826 static char * txtdir[] = {
827 "/usr/local/doc/", /* Linux, SunOS, ... */
828 "/usr/share/lib/", /* HP-UX 10.xx... */
829 "/usr/share/doc/", /* Other possibilities... */
830 "/usr/local/lib/", /* NOTE: Each of these is tried */
831 "/usr/local/share/", /* as is, and also with a kermit */
832 "/usr/local/share/doc/", /* subdirectory. */
833 "/usr/local/share/lib/",
834 "/opt/kermit/", /* Solaris */
844 lookup() cache to speed up script execution.
846 This is a static cache. Items are stored in decreasing frequency of
847 reference based on statistics from a range of scripts. This gives
848 better performance than a dynamic cache, which would require a lot more
849 code and also would require system-dependent elements including system
850 calls (e.g. to get subsecond times for entry aging).
852 #ifdef USE_LUCACHE /* Set in ckuusr.h */
853 #define LUCACHE 32 /* Change this to reduce cache size */
855 char * lucmd[LUCACHE];
858 struct keytab * lutab[LUCACHE];
859 #endif /* USE_LUCACHE */
862 luinit() { /* Initialize lookup() cache */
866 x = lookup(cmdtab,"if",ncmd,&y);
867 lucmd[lusize] = "if";
870 lutab[lusize] = cmdtab;
871 if (++lusize > LUCACHE) return;
873 x = lookup(iftab,"not",nif,&y);
874 lucmd[lusize] = "not";
877 lutab[lusize] = iftab;
878 if (++lusize > LUCACHE) return;
880 x = lookup(vartab,"cmdlevel",nvars,&y);
881 lucmd[lusize] = "cmdlevel";
884 lutab[lusize] = vartab;
885 if (++lusize > LUCACHE) return;
887 x = lookup(cmdtab,"goto",ncmd,&y);
888 lucmd[lusize] = "goto";
891 lutab[lusize] = cmdtab;
892 if (++lusize > LUCACHE) return;
894 x = lookup(iftab,">",nif,&y);
898 lutab[lusize] = iftab;
899 if (++lusize > LUCACHE) return;
901 x = lookup(cmdtab,"incr",ncmd,&y);
902 lucmd[lusize] = "incr";
905 lutab[lusize] = cmdtab;
906 if (++lusize > LUCACHE) return;
908 x = lookup(cmdtab,"def",ncmd,&y);
909 lucmd[lusize] = "def";
912 lutab[lusize] = cmdtab;
913 if (++lusize > LUCACHE) return;
915 x = lookup(cmdtab,"_assign",ncmd,&y);
916 lucmd[lusize] = "_assign";
919 lutab[lusize] = cmdtab;
920 if (++lusize > LUCACHE) return;
922 x = lookup(cmdtab,"echo",ncmd,&y);
923 lucmd[lusize] = "echo";
926 lutab[lusize] = cmdtab;
927 if (++lusize > LUCACHE) return;
929 x = lookup(fnctab,"eval",nfuncs,&y);
930 lucmd[lusize] = "eval";
933 lutab[lusize] = fnctab;
934 if (++lusize > LUCACHE) return;
936 x = lookup(fnctab,"lit",nfuncs,&y);
937 lucmd[lusize] = "lit";
940 lutab[lusize] = fnctab;
941 if (++lusize > LUCACHE) return;
943 x = lookup(cmdtab,"do",ncmd,&y);
944 lucmd[lusize] = "do";
947 lutab[lusize] = cmdtab;
948 if (++lusize > LUCACHE) return;
950 x = lookup(cmdtab,"_getargs",ncmd,&y);
951 lucmd[lusize] = "_getargs";
954 lutab[lusize] = cmdtab;
955 if (++lusize > LUCACHE) return;
957 x = lookup(iftab,"<",nif,&y);
961 lutab[lusize] = iftab;
962 if (++lusize > LUCACHE) return;
964 x = lookup(cmdtab,"_putargs",ncmd,&y);
965 lucmd[lusize] = "_putargs";
968 lutab[lusize] = cmdtab;
969 if (++lusize > LUCACHE) return;
971 x = lookup(cmdtab,"asg",ncmd,&y);
972 lucmd[lusize] = "asg";
975 lutab[lusize] = cmdtab;
976 if (++lusize > LUCACHE) return;
978 x = lookup(cmdtab,"else",ncmd,&y);
979 lucmd[lusize] = "else";
982 lutab[lusize] = cmdtab;
983 #endif /* USE_LUCACHE */
988 int i = 0, x = 0, y = 0, z = 0, skip = 0;
993 extern struct keytab * spdtab;
994 #endif /* TTSPDLIST */
998 On stack to allow recursion!
1000 char vnambuf[VNAML]; /* Buffer for variable names */
1003 if (cmdinited) /* Already initialized */
1004 return; /* Don't do it again */
1006 for (i = 0; i < CMDSTKL; i++) /* Prompt strings for each */
1007 prstring[i] = NULL; /* command level */
1010 p = getenv("K_CHARSET"); /* Set default file character set */
1011 if (p) { /* from environment */
1012 x = lookup(fcstab,p,nfilc,&y);
1016 #endif /* NOCSETS */
1018 p = getenv("K_INFO_DIRECTORY"); /* Find Kermit info directory */
1019 if (p && *p && strlen(p) <= CKMAXPATH)
1020 makestr(&k_info_dir,p);
1022 p = getenv("K_INFO_DIR");
1023 if (p && *p && strlen(p) <= CKMAXPATH)
1024 makestr(&k_info_dir,p);
1027 if (k_info_dir) { /* Look for Kermit docs directory */
1028 if (zchki(k_info_dir) == -2) {
1029 char xbuf[CKMAXPATH+32], *s = "";
1030 if (ckrchar(k_info_dir) != '/')
1032 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
1033 if (zchki(xbuf) < 0)
1034 makestr(&k_info_dir,NULL);
1038 char xbuf[CKMAXPATH+32];
1040 for (i = 0; *(txtdir[i]); i++) {
1041 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
1042 if (zchki(xbuf) > 0) {
1043 makestr(&k_info_dir,txtdir[i]);
1044 debug(F110,"k_info_dir 1",k_info_dir,0);
1047 ckmakmsg(xbuf,CKMAXPATH+32,
1048 txtdir[i],"kermit/","ckubwr.txt",NULL);
1049 if (zchki(xbuf) > 0) {
1050 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
1051 makestr(&k_info_dir,xbuf);
1052 debug(F110,"k_info_dir 2",k_info_dir,0);
1055 ckmakmsg(xbuf,CKMAXPATH+32,
1056 txtdir[i],"ckermit/","ckubwr.txt",NULL);
1057 if (zchki(xbuf) > 0) {
1058 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
1059 makestr(&k_info_dir,xbuf);
1060 debug(F110,"k_info_dir 3",k_info_dir,0);
1064 if (k_info_dir) { /* Make sure it ends with "/" */
1065 if (ckrchar(k_info_dir) != '/') {
1066 char xbuf[CKMAXPATH+32];
1067 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
1068 makestr(&k_info_dir,xbuf);
1075 char xdir[CKMAXPATH+8], *s = "";
1076 extern char startupdir[];
1078 if (ckrchar(startupdir) != '/')
1080 if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
1081 ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
1082 makestr(&k_info_dir,xdir);
1088 if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
1089 int j, k, m = 0, n; /* Create sorted keyword table */
1093 (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
1094 for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
1095 if (ss[i] < 1L) break; /* Shouldn't happen */
1096 buf[0] = NUL; /* Make string */
1097 sprintf(buf,"%ld",ss[i]); /* SAFE */
1099 ckstrncpy(buf,"75/1200",sizeof(buf));
1101 ckstrncat(buf,".5",16);
1103 if ((n > 0) && (p = (char *)malloc(n+1))) {
1104 if (m > 0) { /* Have at least one in list */
1105 for (j = 0; /* Find slot */
1106 j < m && strcmp(buf,spdtab[j].kwd) > 0;
1110 if (j < m) { /* Must insert */
1111 for (k = m-1; k >= j; k--) { /* Move others down */
1112 spdtab[k+1].kwd = spdtab[k].kwd;
1113 spdtab[k+1].flgs = spdtab[k].flgs;
1114 spdtab[k+1].kwval = spdtab[k].kwval;
1117 } else /* First one */
1119 ckstrncpy(p,buf,n+1); /* Add new speed */
1122 spdtab[j].kwval = (int) ss[i] / 10;
1123 m++; /* Count this one */
1129 #endif /* TTSPDLIST */
1132 /* Allocate INPUT command buffer */
1134 if (!(inpbuf = (char *) malloc(INPBUFSIZ+1)))
1135 fatal("cmdini: no memory for INPUT buffer");
1137 for (x = 0; x < INPBUFSIZ; x++) /* Initialize it */
1139 inpbp = inpbuf; /* Initialize pointer */
1140 inbufsize = INPBUFSIZ; /* and size. */
1144 if (cmsetup() < 0) fatal("Can't allocate command buffers!");
1147 /* Allocate command stack allowing command parser to call itself */
1149 if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
1150 fatal("cmdini: no memory for cmdstk");
1151 if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
1152 fatal("cmdini: no memory for ifcmd");
1153 if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
1154 fatal("cmdini: no memory for count");
1155 if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
1156 fatal("cmdini: no memory for iftest");
1157 if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
1158 fatal("cmdini: no memory for intime");
1159 if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
1160 fatal("cmdini: no memory for inpcas");
1161 if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
1162 fatal("cmdini: no memory for takerr");
1163 if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
1164 fatal("cmdini: no memory for merror");
1165 if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
1166 fatal("cmdini: no memory for xquiet");
1168 if (!(kermrc = (char *) malloc(KERMRCL+1)))
1169 fatal("cmdini: no memory for kermrc");
1171 /* Application Program Command buffer */
1172 if (!(apcbuf = malloc(APCBUFLEN + 1)))
1173 fatal("cmdini: no memory for apcbuf");
1177 /* line[] and tmpbuf[] are the two string buffers used by the command parser */
1179 if (!(line = malloc(LINBUFSIZ + 1)))
1180 fatal("cmdini: no memory for line");
1181 if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
1182 fatal("cmdini: no memory for tmpbuf");
1183 #endif /* DCMDBUF */
1187 { /* Initialize MINPUT pointers */
1190 for (i = 0; i < MINPMAX; i++)
1193 #endif /* CK_MINPUT */
1195 if (macini() < 0) /* Allocate macro buffers */
1196 fatal("Can't allocate macro buffers!");
1198 ifcmd[0] = 0; /* Command-level related variables. */
1199 iftest[0] = 0; /* Initialize variables at top level */
1200 count[0] = 0; /* of stack... */
1209 cmdlvl = 0; /* Initialize the command stack */
1211 cmdstk[cmdlvl].src = CMD_KB; /* Source is console */
1212 cmdstk[cmdlvl].lvl = 0; /* Level is 0 */
1213 cmdstk[cmdlvl].ccflgs = 0; /* No flags */
1216 tlevel = -1; /* Take file level = keyboard */
1217 for (i = 0; i < MAXTAKE; i++) /* Initialize command file names */
1220 cmsetp(ckprompt); /* Set up C-Kermit's prompt */
1221 /* Can't set IKSD prompt here since */
1222 /* we do not yet know if we are IKSD */
1225 initmac(); /* Initialize macro table */
1227 /* Predefine built-in one-line macros */
1229 addmac("ibm-linemode",m_ibm); /* IBM-LINEMODE */
1230 addmac("fatal",m_fat); /* FATAL macro */
1231 y = addmac("fast",m_fast); /* FAST macro */
1232 addmac("cautious",m_cautious); /* CAUTIOUS macro */
1233 addmac("robust",m_robust); /* ROBUST macro */
1235 addmac("manual",m_manual); /* MANUAL macro */
1238 addmac("purge",m_purge); /* PURGE macro */
1242 Predefine built-in multiline macros; these are top-level commands
1243 that are implemented internally as macros. NOTE: When adding a new
1244 one of these, remember to update the END and RETURN commands to
1245 account for it, or else END and RETURN from within it won't work right.
1247 x = addmmac("_forx",for_def); /* FOR macro */
1248 if (x > -1) mactab[x].flgs = CM_INV;
1249 x = addmmac("_forz",foz_def); /* Other FOR macro */
1250 if (x > -1) mactab[x].flgs = CM_INV;
1251 x = addmmac("_xif",xif_def); /* XIF macro */
1252 if (x > -1) mactab[x].flgs = CM_INV;
1253 x = addmmac("_while",whil_def); /* WHILE macro */
1254 if (x > -1) mactab[x].flgs = CM_INV;
1255 x = addmmac("_switx",sw_def); /* SWITCH macro */
1256 if (x > -1) mactab[x].flgs = CM_INV;
1258 /* Fill in command-line argument vector */
1260 sprintf(vnambuf,"\\&@[%d]",xargs); /* SAFE */
1261 if (inserver) { /* But hidden in IKSD */
1265 y = arraynam(vnambuf,&x,&z); /* goes in array \&@[] */
1271 dclarray((char)x,z); /* Declare the array */
1273 /* Macro argument vector */
1274 sprintf(vnambuf,"\\&_[%d]",z); /* SAFE */
1275 yy = arraynam(vnambuf,&x,&z); /* goes in array \&_[] */
1276 if (yy > -1) /* Name is OK */
1277 dclarray((char)x,z); /* Declare the array */
1278 #endif /* NOTAKEARGS */
1280 for (i = 0; i < xargs; i++) { /* Fill the arrays */
1281 sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
1282 addmac(vnambuf,xargv[i]);
1283 if (cfilef && i == 0)
1291 #endif /* KERBANG */
1292 if (j < 0 && /* Assign items after "=" or "--"*/
1293 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
1295 j = 0; /* to \%1..\%9 */
1298 (!strcmp(xargv[i],"+") ||
1299 !strncmp(xargv[i],"+ ",2) ||
1300 !strncmp(xargv[i],"+\t",2))
1304 #endif /* KERBANG */
1305 } else if (j > -1) {
1310 vnambuf[2] = (char)(j+'0');
1312 addmac(vnambuf,xargv[i]);
1318 makestr(&(toparg[j]),p);
1319 while ((c = *p++)) { if (c == SP) { flag++; break; } }
1321 ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
1322 ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
1324 ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
1325 ckstrncat(tmpbuf," ",TMPBUFSIZ);
1330 addmac("\\%0",cmdfil);
1332 makestr(&(toparg[0]),cmdfil);
1334 addmac("\\%0",xargv[0]);
1336 makestr(&(toparg[0]),xargv[0]);
1339 topargc = (j < 0) ? 1 : j + 1;
1342 /* This needs work */
1344 makestr(&topline,tmpbuf);
1345 #endif /* COMMENT */
1350 a_dim[0] = topargc - 1;
1352 debug(F111,"a_dim[0]","A",a_dim[0]);
1357 luinit(); /* Initialize lookup() cache */
1359 /* Get our home directory now. This needed in lots of places. */
1365 _PROTOTYP(char * GetAppData,(int));
1371 extern int ckrooterr;
1382 return; /* Mac Kermit has no init file */
1386 /* If skipping init file ('-Y' on Kermit command line), return now. */
1392 But returning from here results in inidir[] never being set to anything.
1393 Instead it should be set to wherever the init file *would* have been
1394 executed from. So this bit of code should be removed, and then we should
1395 sprinkle "if (noinit)" tests throughout the following code until we have
1396 set inidir[], and then return without actually taking the init file.
1403 The -y init file must be fully specified or in the current directory.
1404 KERMRC is looked for via INIT, DPATH and PATH in that order. Finally, our
1405 own executable file path is taken and the .EXE suffix is replaced by .INI
1406 and this is tried as the initialization file.
1409 debug(F101,"doinit inserver","",inserver);
1410 debug(F101,"doinit isguest","",isguest);
1411 debug(F110,"doinit anonfile",anonfile,0);
1413 if (isguest && anonfile) {
1414 ckstrncpy(line, anonfile, LINBUFSIZ+1);
1416 #endif /* CK_LOGIN */
1418 ckstrncpy(line,kermrc,LINBUFSIZ+1);
1420 } else if (inserver) {
1421 char * appdata = NULL;
1423 appdata = GetAppData(1);
1425 ckmakmsg(line,LINBUFSIZ+1,appdata,
1426 "Kermit 95/k95.ini",NULL,NULL);
1427 if ( zchki(line) < 0 )
1431 appdata = GetAppData(0);
1433 ckmakmsg(line,LINBUFSIZ+1,appdata,
1434 "Kermit 95/k95.ini",NULL,NULL);
1435 if ( zchki(line) < 0 )
1443 ckmakmsg(line,LINBUFSIZ+1,appdata,
1450 if ( zchki(line) < 0 )
1454 debug(F110,"doinit inserver inifile",line,0);
1455 #endif /* CK_LOGIN */
1459 env = getenv("K95.KSC");
1461 env = getenv("K2.KSC");
1465 env = getenv("K95.INI");
1467 env = getenv("K2.INI");
1471 env = getenv("CKERMIT.INI");
1473 env = getenv("CKERMIT_INI");
1476 debug(F110,"doinit env",env,0);
1478 ckstrncpy(line,env,LINBUFSIZ+1);
1482 env = GetAppData(1);
1484 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
1485 if ( zchki(line) < 0 )
1490 env = GetAppData(0);
1492 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
1493 if ( zchki(line) < 0 )
1502 ckmakmsg(line,LINBUFSIZ+1,env,
1509 if ( zchki(line) < 0 )
1515 _searchenv(kermrc,"INIT",line);
1517 _searchenv(kermrc,"DPATH",line);
1519 _searchenv(kermrc,"PATH",line);
1521 char *pgmptr = GetLoadPath();
1522 if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
1523 lp = strrchr(pgmptr, '\\');
1525 strncpy(line, pgmptr, lp - pgmptr);
1527 strcpy(line + (lp - pgmptr), "/k95.ini");
1529 strcpy(line + (lp - pgmptr), "/k2.ini");
1532 lp = strrchr(pgmptr, '.');
1534 strncpy(line, pgmptr, lp - pgmptr);
1535 strcpy(line + (lp - pgmptr), ".ini");
1543 if (!zinroot(line)) {
1544 debug(F110,"doinit setroot violation",line,0);
1549 debug(F110,"doinit fopen()",line,0);
1550 if ((tfile[0] = fopen(line,"r")) != NULL) {
1554 if (tfnam[tlevel] = malloc(strlen(line)+1))
1555 strcpy(tfnam[tlevel],line); /* safe */
1559 cmdstk[cmdlvl].src = CMD_TF;
1560 cmdstk[cmdlvl].lvl = tlevel;
1561 cmdstk[cmdlvl].ccflgs = 0;
1564 count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
1565 intime[cmdlvl] = intime[cmdlvl-1];
1566 inpcas[cmdlvl] = inpcas[cmdlvl-1];
1567 takerr[cmdlvl] = takerr[cmdlvl-1];
1568 merror[cmdlvl] = merror[cmdlvl-1];
1569 xquiet[cmdlvl] = quiet;
1571 debug(F110,"doinit init file",line,0);
1573 debug(F100,"doinit no init file","",0);
1575 ckstrncpy(kermrc,line,KERMRCL);
1576 for (ptr = kermrc; *ptr; ptr++) /* Convert backslashes to slashes */
1582 debug(F101,"doinit rcflag","",rcflag);
1584 zkermini(line, rcflag, kermrc);
1589 x = zkermini(line,LINBUFSIZ,kermrc);
1590 debug(F111,"CUSTOM zkermini",line,x);
1596 debug(F101,"doinit isguest","",isguest);
1598 ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
1600 #endif /* CK_LOGIN */
1601 if (rcflag) { /* If init file name from cmd line */
1602 ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
1603 } else { /* otherwise... */
1604 #ifdef CK_INI_A /* If we've a system-wide init file */
1605 /* And it takes precedence over the user's... */
1606 ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
1607 if (zchki(lp) < 0) { /* (if it exists...) */
1608 #endif /* CK_INI_A */
1613 /* Add support for environment variable */
1614 env = getenv("CKERMIT.INI");
1616 env = getenv("CKERMIT_INI");
1618 ckstrncpy(lp,env,KERMRCL);
1622 if (homdir) { /* Home directory for init file. */
1623 ckstrncpy(lp,homdir,KERMRCL);
1625 ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
1627 if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
1628 #endif /* STRATUS */
1630 ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
1634 #endif /* CK_INI_A */
1635 #ifdef CK_INI_B /* System-wide init defined? */
1636 /* But user's ini file takes precedence */
1637 if (zchki(lp) < 0) /* If user doesn't have her own, */
1638 ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
1639 #endif /* CK_INI_B */
1645 reqoff(); /* Disable requestors */
1649 /* If no init file was found, execute the customization file */
1650 debug(F110,"CUSTOM 1",line,0);
1651 if (!line[0] || zchki(line) < 0) {
1654 x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
1655 debug(F111,"CUSTOM 2",line,x);
1656 if (zchki(line) < 0) {
1657 x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
1658 debug(F111,"CUSTOM 3",line,x);
1661 x = ckstrncpy(line,zhome(),LINBUFSIZ);
1663 /* VMS zhome() returns "SYS$LOGIN:" */
1664 if (line[x-1] != DIRSEP) {
1669 x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
1670 debug(F111,"CUSTOM 4",line,x);
1673 debug(F110,"CUSTOM 5",line,0);
1674 #endif /* USE_CUSTOM */
1677 if (!zinroot(line)) {
1678 debug(F110,"doinit setroot violation",line,0);
1683 debug(F110,"doinit ini file is",line,0);
1684 if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
1688 if ((tfnam[tlevel] = malloc(strlen(line)+1)))
1689 strcpy(tfnam[tlevel],line); /* safe */
1691 ckstrncpy(kermrc,line,KERMRCL);
1697 count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
1698 intime[cmdlvl] = intime[cmdlvl-1];
1699 inpcas[cmdlvl] = inpcas[cmdlvl-1];
1700 takerr[cmdlvl] = takerr[cmdlvl-1];
1701 merror[cmdlvl] = merror[cmdlvl-1];
1702 xquiet[cmdlvl] = quiet;
1703 debug(F101,"doinit open ok","",cmdlvl);
1705 cmdstk[cmdlvl].src = CMD_TF;
1706 cmdstk[cmdlvl].lvl = tlevel;
1707 cmdstk[cmdlvl].ccflgs = 0;
1709 } else if (rcflag) {
1710 /* Print an error message only if a specific file was asked for. */
1711 printf("?%s - %s\n", ck_errstr(), line);
1715 /* If CKERMIT.INI not found in home directory, look in searchlist */
1716 if (/* homdir && */ (tlevel < 0)) {
1717 ckstrncpy(lp,kermrc,LINBUFSIZ);
1718 if ((tfile[0] = fopen(line,"r")) != NULL) {
1722 if (tfnam[tlevel] = malloc(strlen(line)+1))
1723 strcpy(tfnam[tlevel],line); /* safe */
1727 cmdstk[cmdlvl].src = CMD_TF;
1728 cmdstk[cmdlvl].lvl = tlevel;
1729 cmdstk[cmdlvl].ccflgs = 0;
1732 count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
1733 intime[cmdlvl] = intime[cmdlvl-1];
1734 inpcas[cmdlvl] = inpcas[cmdlvl-1];
1735 takerr[cmdlvl] = takerr[cmdlvl-1];
1736 merror[cmdlvl] = merror[cmdlvl-1];
1737 xquiet[cmdlvl] = quiet;
1741 #endif /* datageneral */
1743 #ifdef AMIGA /* Amiga... */
1744 reqpop(); /* Restore requestors */
1749 /* Assign value to inidir */
1754 ckstrncpy(inidir, kermrc, CCHMAXPATH);
1758 for (i = x - 1; i > 0; i-- ) {
1759 if (ISDIRSEP(inidir[i])) {
1766 GetShortPathName(inidir,inidir,CCHMAXPATH);
1774 /* IKSD doesn't request client certs */
1775 ssl_verify_flag = SSL_VERIFY_NONE;
1784 _searchenv(iksdconf,"INIT",line);
1786 _searchenv(iksdconf,"DPATH",line);
1788 _searchenv(iksdconf,"PATH",line);
1790 char *pgmptr = GetLoadPath();
1791 if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
1792 lp = strrchr(pgmptr, '\\');
1794 strncpy(line, pgmptr, lp - pgmptr);
1795 strcpy(line + (lp - pgmptr), "\\");
1796 strcpy(line + (lp - pgmptr + 1), iksdconf);
1798 lp = strrchr(pgmptr, '.');
1800 strncpy(line, pgmptr, lp - pgmptr);
1801 strcpy(line + (lp - pgmptr), ".ksc");
1806 debug(F110,"doiksdinit() line",line,0);
1807 tfile[0] = fopen(line,"r");
1809 tfile[0] = fopen(iksdconf,"r");
1811 if (tfile[0] != NULL) {
1815 if (tfnam[tlevel] = malloc(strlen(line)+1))
1816 strcpy(tfnam[tlevel],line);
1818 if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
1819 strcpy(tfnam[tlevel],iksdconf);
1824 cmdstk[cmdlvl].src = CMD_TF;
1825 cmdstk[cmdlvl].lvl = tlevel;
1826 cmdstk[cmdlvl].ccflgs = 0;
1829 count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
1830 intime[cmdlvl] = intime[cmdlvl-1];
1831 inpcas[cmdlvl] = inpcas[cmdlvl-1];
1832 takerr[cmdlvl] = takerr[cmdlvl-1];
1833 merror[cmdlvl] = merror[cmdlvl-1];
1834 xquiet[cmdlvl] = quiet;
1836 debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
1838 debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
1840 #endif /* IKSDCONF */
1847 Get next command from current macro definition. Command is copied
1848 into string pointed to by argument s, max length n. Returns:
1849 0 if a string was copied;
1850 -1 if there was no string to copy.
1853 getncm(s,n) char *s; int n; {
1854 int y = 0; /* Character counter */
1856 int kp = 0; /* Brace up-down counter */
1857 int pp = 0; /* Parenthesis up-down counter */
1859 int dq = 0; /* Doublequote counter */
1860 #endif /* NODQMACRO */
1861 char *s2; /* Copy of destination pointer */
1863 s2 = s; /* Initialize string pointers */
1864 *s = NUL; /* and destination buffer */
1866 /* debug(F010,"getncm entry",macp[maclvl],0); */
1868 for (y = 0; /* Loop for n bytes max */
1869 macp[maclvl] && *macp[maclvl] && y < n;
1870 y++, s++, macp[maclvl]++) {
1872 *s = *macp[maclvl]; /* Get next char from macro def */
1876 This is to allow quoting of parentheses, commas, etc, in function
1877 arguments, but it breaks just about everything else. DON'T REMOVE THIS
1878 COMMENT! (Otherwise you'll wind up adding the same code again and breaking
1879 everything again.) <-- The preceding warning should be obsolete since the
1880 statements below have been fixed, but in case of fire, remove the "n" from
1881 the <#>ifndef above. NEW WARNING: code added 12 Apr 2002 to exempt the
1882 opening brace in \{nnn} from being treated as a quoted brace.
1884 if (!quote && *s == CMDQ) {
1891 if (*s == '{') { /* Check for \{nnn} (8.0.203) */
1893 p = macp[maclvl] + 1;
1894 while ((c = *p++)) {
1897 else if (c == '}') {
1908 #endif /* COMMENT */
1911 Allow braces around macro definition to prevent commas from being turned to
1912 end-of-lines and also treat any commas within parens as text so that
1913 multiple-argument functions won't cause the command to break prematurely.
1914 19 Oct 2001: Similar treatment was added for doublequotes, so
1916 define foo { echo "one, two, three" }
1918 would work as expected. This doesn't seem to have broken anything but
1919 if something comes up later, rebuild with NODQMACRO defined.
1921 if (*s == '{') kp++; /* Count braces */
1922 if (*s == '}' && kp > 0) kp--;
1923 if (*s == '(') pp++; /* Count parentheses. */
1924 if (*s == ')' && pp > 0) pp--;
1927 /* Too many false positives */
1928 /* No, not really -- this is indeed the best we can do */
1929 /* Reverted to this method Sun May 11 18:43:45 2003 */
1930 if (*s == '"') dq = 1 - dq; /* Account for doublequotes */
1931 #else /* Fri Apr 4 13:21:29 2003 */
1932 /* The code below breaks the SWITCH statement */
1933 /* There is no way to make this work -- it would require */
1934 /* building in all the knowledge of command parser. */
1935 if (dblquo && (*s == '"')) { /* Have doublequote */
1936 if (dq == 1) { /* Close quote only if... */
1937 if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
1938 (!*(macp[maclvl]+1)) || /* at end or ... */
1939 /* Next char is command separator... */
1940 /* Sun May 11 17:24:12 2003 */
1941 (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
1943 dq = 0; /* Close the quote */
1944 } else if (dq == 0) {
1945 /* Open quote only if at beginning or preceded by space */
1949 } else if (s == s2) {
1954 #endif /* COMMENT */
1955 #endif /* NODQMACRO */
1956 if (*s == ',' && pp <= 0 && kp <= 0
1959 #endif /* NODQMACRO */
1961 macp[maclvl]++; /* Comma not in {} or () */
1962 /* debug(F110,"next cmd",s,0); */
1963 kp = pp = 0; /* so we have the next command */
1966 } /* Reached end. */
1968 /* DON'T DO THIS - IT BREAKS EVERYTHING */
1970 #endif /* COMMENT */
1971 if (*s2 == NUL) { /* If nothing was copied, */
1972 /* debug(F100,"XXX getncm eom","",0); */
1973 popclvl(); /* pop command level. */
1975 } else { /* otherwise, tack CR onto end */
1978 /* debug(F110,"XXX getncm OK",s,0); */
1979 if (mecho && pflag) /* If MACRO ECHO ON, echo the cmd */
1985 /* D O M A C -- Define and then execute a macro */
1988 domac(name, def, flags) char *name, *def; int flags; {
1993 int term_io_sav = term_io;
1994 term_io = 0; /* Disable Terminal Emulator I/O */
1996 #endif /* NOLOCAL */
1997 m = maclvl; /* Current macro stack level */
1998 x = addmac(name, def); /* Define a new macro */
1999 if (x > -1) { /* If successful, */
2000 dodo(x,NULL,flags); /* start it (increments maclvl). */
2001 while (maclvl > m) { /* Keep going till done with it, */
2002 debug(F101,"domac loop maclvl 1","",maclvl);
2003 sstate = (CHAR) parser(1); /* parsing & executing each command, */
2004 debug(F101,"domac loop maclvl 2","",maclvl);
2005 if (sstate) proto(); /* including protocol commands. */
2007 debug(F101,"domac loop exit maclvl","",maclvl);
2011 term_io = term_io_sav;
2013 #endif /* NOLOCAL */
2021 Get next command from TAKE (command) file.
2024 s Pointer to buffer to read into
2026 f File descriptor of file to read from
2027 flag 0 == keep line terminator on and allow continuation
2028 1 == discard line terminator and don't allow continuation
2030 Call with flag == 0 to read a command from a TAKE file;
2031 Call with flag != 0 to read a line from a dialing or network directory.
2033 In both cases, trailing comments and/or trailing whitespace is/are stripped.
2034 If flag == 0, continued lines are combined into one line. A continued line
2035 is one that ends in hypen, or any line in a "block", which starts with "{"
2036 at the end of a line and ends with a matching "}" at the beginning of a
2037 subsequent line; blocks may be nested.
2040 0 if a string was copied,
2042 -2 on malloc failure
2043 -3 if line is not properly terminated
2044 -4 if (possibly continued) line is too long.
2046 static int lpxlen = 0;
2049 getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
2050 int i = 0, len = 0, buflen = 0;
2051 char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
2052 char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
2054 int bc = 0; /* Block counter */
2056 s2 = s; /* Remember original pointer */
2058 buflen = n; /* Remember original buffer length */
2063 /* Allocate a line buffer only if we don't have one that's big enough */
2065 debug(F111,"getnct",ckitoa(lpxlen),n);
2067 if (lpx && (n > lpxlen)) { /* Have one already */
2068 debug(F101,"getnct new buffer","",lpxlen);
2069 free(lpx); /* But it's not big enough */
2070 lpx = NULL; /* Free current one */
2073 if (!lpx) { /* Get new one */
2074 if (!(lpx = (char *) malloc(n))) {
2075 debug(F101,"getnct malloc failure","",0);
2076 printf("?Memory allocation failure [getnct]\n");
2083 /* NOTE: No longer used as of 14 Aug 2000 */
2087 while (1) { /* Loop to read lines from file */
2088 debug(F101,"getnct while (1)","",n);
2089 if (fgets(lp2,n,f) == NULL) { /* Read a line into lp2 */
2090 debug(F110,"getnct EOF",s2,0); /* EOF */
2091 free(lpx); /* Free temporary storage */
2093 *s = NUL; /* Make destination be empty */
2094 return(-1); /* Return failure code */
2097 if (flag) /* Count this line */
2102 len = strlen(lp2) - 1; /* Position of line terminator */
2103 if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
2104 lp2[++len] = '\n'; /* that is not a newline */
2107 debug(F010,"getnct",lp2,0);
2110 if (techo && pflag) /* If TAKE ECHO ON, */
2111 printf("%3d. %s", /* echo it this line. */
2118 lp3 = lp2; /* Working pointer */
2119 i = len; /* Get first nonwhitespace character */
2120 while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
2124 if (i == 0 && bc > 0) /* Blank line in {...} block */
2127 /* Isolate, remove, and check terminator */
2129 c = lp2[len]; /* Value of line terminator */
2130 /* debug(F101,"getnct terminator","",c); */
2131 if (c < LF || c > CR) { /* It's not a terminator */
2132 /* debug(F111,"getnct bad line",lp2,c); */
2133 if (feof(f) && len > 0 && len < n) {
2134 /* Kludge Alert... */
2136 printf("WARNING: Last line of %s lacks terminator\n",
2137 s2 == cmdbuf ? "command file" : "directory file");
2138 c = lp2[++len] = '\n'; /* No big deal - supply one. */
2139 } else { /* Something's wrong, fail. */
2145 /* Trim trailing whitespace */
2147 for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
2149 /* debug(F101,"getnct i","",i); */
2150 lp2[i+1] = NUL; /* Terminate the string */
2151 /* debug(F110,"getnct lp2",lp2,0); */
2152 lp = lp2; /* Make a working pointer */
2154 /* Remove trailing or full-line comment */
2156 while ((cc = *lp)) {
2157 if (cc == ';' || cc == '#') { /* Comment introducer? */
2158 if (lp == lp2) { /* First char on line */
2161 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
2163 *lp = NUL; /* Or preceded by whitespace */
2170 lp--; /* Back up over the NUL */
2172 /* Now trim any space that preceded the comment */
2174 while ((*lp == SP || *lp == HT) && lp >= lp2) {
2180 /* debug(F110,"getnct comment trimmed",lp2,0); */
2182 len = strlen(lp2); /* Length after trimming */
2184 if (n - len < 2) { /* Check remaining space */
2185 debug(F111,"getnct command too long",s2,buflen);
2186 printf("?Line too long, maximum length: %d.\n",buflen);
2190 ccl = (len > 0) ? lp2[len-1] : 0; /* Last character in line */
2191 ccx = (len > 1) ? lp2[len-2] : 0; /* Penultimate char in line */
2194 /* Line containing only whitespace and ,- */
2195 if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
2197 #endif /* COMMENT */
2201 If it is a command and it begins with a token (like ! or .) that is not
2202 followed by a space, insert a space now; otherwise cmkey() can get mighty
2205 if (s == s2 && !flag) {
2208 if (*p == *lp3 && *(p+1) != SP) {
2209 debug(F110,"getnct token",p,0);
2224 while ((*s++ = *lp++)) /* Copy result to target buffer */
2225 n--; /* accounting for length */
2226 s--; /* Back up over the NUL */
2228 /* Check whether this line is continued */
2230 if (flag) /* No line continuation when flag=1 */
2231 break; /* So break out of read-lines loop */
2234 debug(F000,"getnct first char","",*lp3);
2235 debug(F000,"getnct last char","",ccl);
2236 debug(F000,"getnct next-to-last char","",ccx);
2237 #endif /* COMMENT */
2239 if (bc > 0 && *lp3 == '}') { /* First char on line is '}' */
2240 bc--; /* Decrement block counter */
2243 if (bc == 0 && /* Line is continued if bc > 0 */
2245 /* Not supported as of C-Kermit 6.0 */
2246 ccl != CMDQ && /* or line ends with CMDQ */
2247 #endif /* COMMENT */
2248 ccl != '-' && /* or line ends with dash */
2249 ccl != '{') /* or line ends with opening brace */
2250 break; /* None of those, we're done. */
2252 if (ccl == '-' || ccl == '{') /* Continuation character */
2253 if (ccx == CMDQ) /* But it's quoted */
2254 break; /* so ignore it */
2256 if (ccl == '{') { /* Last char on line is '{'? */
2257 bc++; /* Count the block opener. */
2258 } else if (ccl == '-') { /* Explicit continue? */
2261 s--; /* Yes, back up over terminators */
2262 n++; /* and over continuation character */
2263 nn = n; /* Save current count */
2264 ss = s; /* and pointer */
2265 s--; /* Back up over dash */
2267 while (state < 2 && s >= prev) { /* Check for "{,-" */
2272 if (c != ',' && c != '{')
2275 case 0: /* Looking for comma */
2279 case 1: /* Looking for left brace */
2289 if (state != 2) { s = ss; n = nn; }
2291 } else { /* None of those but (bc > 0) */
2293 *s++ = ','; /* and insert a comma */
2297 debug(F101,"getnct bc","",bc);
2298 debug(F100,"getnct continued","",0);
2299 #endif /* COMMENT */
2304 } /* read-lines while loop */
2308 if (!flag) /* Tack line terminator back on */
2310 *s++ = NUL; /* Terminate the string */
2311 untab(s2); /* Done, convert tabs to spaces */
2314 debug(F010,"CMD(F)",s2,0);
2317 free(lpx); /* Free temporary storage */
2318 return(0); /* Return success */
2322 shostack() { /* Dump the command stack */
2326 for (i = cmdlvl; i > 0; i--) {
2327 if (cmdstk[i].src == CMD_TF) {
2328 p = tfnam[cmdstk[i].lvl];
2329 if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
2331 printf(" %2d. File : %s (line %d)\n",
2334 tfline[cmdstk[i].lvl]
2336 } else if (cmdstk[i].src == CMD_MD) {
2338 m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
2339 if (i > 0) { /* Special handling for 2-level */
2340 char *s; /* built-in macros... */
2341 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
2342 if (s && cmdstk[i-1].src == CMD_MD) {
2343 if (!strcmp(s,"_forx"))
2345 else if (!strcmp(s,"_xif"))
2347 else if (!strcmp(s,"_while"))
2349 else if (!strcmp(s,"_switx"))
2353 printf(" %2d. Macro : %s\n",i,m);
2354 } else if (cmdstk[i].src == CMD_KB) {
2355 printf(" %2d. Prompt:\n",i);
2357 printf(" %2d. ERROR : Command source unknown\n",i);
2361 for (i = tlevel; i > -1; i--) {
2363 if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
2365 printf(" %2d. File : %s (line %d)\n",
2373 printf(" %2d. Prompt: (top level)\n",0);
2377 /* P A R S E R -- Top-level interactive command parser. */
2381 m = 0 for normal behavior: keep parsing and executing commands
2382 until an action command is parsed, then return with a
2383 Kermit start-state as the value of this function.
2384 m = 1 to parse only one command, can also be used to call parser()
2386 m = 2 to read but do not execute one command.
2387 In all cases, parser() returns:
2388 0 if no Kermit protocol action required
2389 > 0 with a Kermit protocol start-state.
2394 int tfcode, xx, yy, zz; /* Workers */
2399 int inlevel; /* Level we were called at */
2402 char *cbp; /* Command buffer pointer */
2404 extern char *lfiles; /* Fake extern cast */
2406 extern int interrupted;
2408 extern int sndcmd, getcmd, fatalio, clearrq;
2411 debok = 1; /* Undisable debugging */
2414 reqres(); /* Restore AmigaDOS requestors */
2418 if (cursor_save > -1) { /* Restore cursor if it was */
2419 cursorena[VCMD] = cursor_save; /* turned off during file transfer */
2425 if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
2428 is_tn = (local && network && IS_TELNET()) ||
2429 (!local && sstelnet);
2431 if (!xcmdsrc) /* If at top (interactive) level ... */
2432 concb((char)escape); /* put console in 'cbreak' mode. */
2435 /* If we were cd'd temporarily to another device or directory ... */
2438 x = zchdir((char *) savdir); /* ... restore previous directory */
2439 f_tmpdir = 0; /* and remember we did it. */
2440 debug(F111,"parser tmpdir restoring",savdir,x);
2442 #endif /* CK_TMPDIR */
2445 inlevel = cmdlvl; /* Current macro level */
2448 debug(F101,"&parser entry maclvl","",maclvl);
2449 debug(F101,"&parser entry inlevel","",inlevel);
2450 debug(F101,"&parser entry tlevel","",tlevel);
2451 debug(F101,"&parser entry cmdlvl","",cmdlvl);
2452 debug(F101,"&parser entry m","",m);
2458 ftreset(); /* Reset global file settings */
2461 sstate becomes nonzero when a command has been parsed that requires some
2462 action from the protocol module. Any non-protocol actions, such as local
2463 directory listing or terminal emulation, are invoked directly from below.
2465 sstate = 0; /* Start with no start state. */
2469 query = 0; /* QUERY not active */
2473 if (local && !network && carrier != CAR_OFF) {
2474 int x; /* Serial connection */
2475 x = ttgmdm(); /* with carrier checking */
2477 if (!(x & BM_DCD)) {
2486 debug(F101,"parser top what","",what);
2487 debug(F101,"parser top interrupted","",interrupted);
2488 debug(F101,"parser top cdlost","",cdlost);
2489 debug(F101,"parser top sndcmd","",sndcmd);
2490 debug(F101,"parser top getcmd","",getcmd);
2493 if (cdlost && !interrupted && (sndcmd || getcmd)) {
2494 printf("?Connection broken (carrier signal lost)\n");
2496 if (sndcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
2498 printf("\n*************************\n");
2499 printf("SEND-class command failed.\n");
2500 printf(" Packets sent: %d\n", spackets);
2501 printf(" Retransmissions: %d\n",retrans);
2502 printf(" Timeouts: %d\n", timeouts);
2503 printf(" Damaged packets: %d\n", crunched);
2505 printf(" Transfer canceled by receiver.\n");
2506 printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
2509 if (epktmsg) if (*epktmsg) {
2510 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
2514 if (local && !network && carrier != CAR_OFF) {
2515 int xx; /* Serial connection */
2516 xx = ttgmdm(); /* with carrier checking */
2527 printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
2531 "\nHINTS... If the preceding error message%s not explain the failure:\n",
2532 (n > 1) ? "s do" : " does"
2536 if (rpackets == 0) {
2537 printf(" . Did you start a Kermit receiver on the far end?\n");
2540 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
2541 if (!network && mdmtyp > 0)
2542 if ((3 * crunched) > spackets)
2544 " . Try placing a new call to get a cleaner connection.\n");
2546 } else if (rpackets > 0) {
2547 if (flow == FLO_NONE)
2548 printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
2550 printf(" . Give me a SET FLOW NONE command and try again.\n");
2553 #endif /* NOLOCAL */
2555 if ((3 * timeouts) > spackets)
2556 printf(" . Adjust the timeout method (see HELP SET SEND).\n");
2557 if ((3 * retrans) > spackets)
2558 printf(" . Increase the retry limit (see HELP SET RETRY).\n");
2561 if (prefixing != PX_ALL && rpackets > 2) {
2562 printf(" . Try it again with SET PREFIXING ALL.\n");
2565 #endif /* CK_SPEED */
2568 printf(" . Try it again with SET STREAMING OFF.\n");
2570 } else if (reliable) {
2571 printf(" . Try it again with SET RELIABLE OFF.\n");
2574 #endif /* STREAMING */
2577 if (clearrq > 0 && prefixing == PX_NON) {
2578 printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");
2581 #endif /* CK_SPEED */
2583 printf(" . Try it again with SET PARITY SPACE.\n");
2586 printf(" . %sive a ROBUST command and try again.\n",
2587 (x > 0) ? "As a last resort, g" : "G"
2590 printf(" . Be sure the source file has read permission.\n");
2591 printf(" . Be sure the target directory has write permission.\n");
2592 printf("(Use SET HINTS OFF to suppress hints.)\n");
2593 printf("*************************\n\n");
2595 debug(F101,"topcmd","",topcmd);
2596 if (getcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
2598 extern int urpsiz, wslotr;
2599 printf("\n*************************\n");
2600 printf("RECEIVE- or GET-class command failed.\n");
2601 printf(" Packets received: %d\n", rpackets);
2602 printf(" Damaged packets: %d\n", crunched);
2603 printf(" Timeouts: %d\n", timeouts);
2605 printf(" Packet length: %d\n", urpsiz);
2607 printf(" Transfer canceled by sender.\n");
2608 printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
2613 printf(" Most recent local error: \"%s\"\n",ck_errstr());
2615 "\nHINTS... If the preceding error message%s not explain the failure:\n",
2616 epktrcvd ? "s do" : " does"
2620 if (topcmd == XXGET)
2621 printf(" . Did you start a Kermit SERVER on the far end?\n");
2622 if (rpackets == 0) {
2623 if (topcmd != XXGET)
2624 printf(" . Did you start a Kermit SENDer on the far end?\n");
2627 " . Choose a different FLOW-CONTROL setting and try again.\n");
2629 } else if (topcmd == XXGET)
2630 printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
2631 if (rpackets > 0 && urpsiz > 90)
2632 printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
2633 if (rpackets > 0 && wslotr > 1 && !streamed)
2634 printf(" . Try a smaller window size (SET WINDOW).\n");
2635 if (!local && rpackets > 0) {
2636 if (flow == FLO_NONE)
2637 printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
2639 printf(" . Give me a SET FLOW NONE command and try again.\n");
2642 #endif /* NOLOCAL */
2645 printf(" . Try it again with SET STREAMING OFF.\n");
2647 } else if (reliable && local) {
2648 printf(" . Try it again with SET RELIABLE OFF.\n");
2651 #endif /* STREAMING */
2653 printf(" . Try it again with SET PARITY SPACE.\n");
2657 " . As a last resort, give a ROBUST command and try again.\n" :
2658 " . Give a ROBUST command and try again.\n"
2661 printf(" . Be sure the target directory has write permission.\n");
2662 printf(" . Try telling the %s to SET PREFIXING ALL.\n",
2663 topcmd == XXGET ? "server" : "sender"
2665 printf(" . Try giving a ROBUST command to the %s.\n",
2666 topcmd == XXGET ? "server" : "sender"
2668 printf("(Use SET HINTS OFF to suppress hints.)\n");
2669 printf("*************************\n\n");
2671 #endif /* NOHINTS */
2677 while (sstate == 0) { /* Parse cmds until action requested */
2678 debug(F100,"parse top","",0);
2679 what = W_COMMAND; /* Now we're parsing commands. */
2680 rcdactive = 0; /* REMOTE CD not active */
2681 keepallchars = 0; /* MINPUT not active */
2684 if (apcactive == APC_INACTIVE)
2685 WaitCommandModeSem(-1);
2691 TELOPT_ME(TELOPT_KERMIT) &&
2692 TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
2695 TELOPT_ME(TELOPT_KERMIT) &&
2696 TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
2698 tn_siks(KERMIT_STOP);
2700 #endif /* IKS_OPTION */
2704 fnrpath = PATH_AUTO;
2707 remfile = 0; /* Clear these in case REMOTE */
2708 remappd = 0; /* command was interrupted... */
2710 makestr(&snd_move,g_snd_move); /* Restore these */
2711 makestr(&rcv_move,g_rcv_move);
2712 makestr(&snd_rename,g_snd_rename);
2713 makestr(&rcv_rename,g_rcv_rename);
2715 xaskmore = saveask; /* Restore global more-prompting */
2723 /* Take requested action if there was an error in the previous command */
2726 debug(F101,"parser tlevel","",tlevel);
2727 debug(F101,"parser cmd_rows","",cmd_rows);
2730 debug(F101,"parser wasclosed","",wasclosed);
2731 if (wasclosed) { /* If connection was just closed */
2734 k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
2735 if (k >= 0) { /* If found, */
2736 /* printf("ON_CLOSE CMD LOOP\n"); */
2737 dodo(k,ckitoa(whyclosed),0); /* Set it up */
2740 whyclosed = WC_REMO;
2743 #endif /* NOLOCAL */
2746 xxdot = 0; /* Clear this... */
2748 debug(F101,"parser success","",success);
2750 if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
2751 printf("Command file terminated by error.\n");
2753 if (cmdlvl == 0) return(0);
2755 if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
2756 printf("Command error: macro terminated.\n");
2758 if (m && (cmdlvl < inlevel))
2759 return((int) sstate);
2763 debug(F101,"parser nulcmd","",nulcmd);
2765 if (success == 0 && tlevel > -1 && takerr[tlevel]) {
2766 printf("Command file terminated by error.\n");
2768 cmini(ckxech); /* Clear the cmd buffer. */
2769 if (tlevel < 0) /* Just popped out of cmd files? */
2770 return(0); /* End of init file or whatever. */
2775 /* Check for TAKE initiated by menu. */
2776 if ((tlevel == -1) && lfiles)
2780 /* If in TAKE file, check for EOF */
2787 ((cmdstk[cmdlvl].src == CMD_TF) /* If end of take file */
2789 && feof(tfile[tlevel])) {
2790 popclvl(); /* pop command level */
2791 cmini(ckxech); /* and clear the cmd buffer. */
2792 if (cmdlvl == 0) { /* Just popped out of all cmd files? */
2793 return(0); /* End of init file or whatever. */
2798 if (sstate == 'a') { /* if cmd-. cancel */
2799 debug(F100, "parser: cancel take due to sstate", "", sstate);
2802 return(0); /* End of init file or whatever. */
2807 if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
2808 popclvl(); /* Pop up one level. */
2809 cmini(ckxech); /* and clear the cmd buffer. */
2810 if (tlevel < 0) /* Just popped out of cmd files? */
2811 return(0); /* End of init file or whatever. */
2817 debug(F101,"parser cmdlvl","",cmdlvl);
2818 debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
2820 if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
2821 debug(F100,"parser macro","",0);
2822 maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
2823 debug(F101,"parser maclvl","",maclvl);
2824 cbp = cmdbuf; /* Copy next cmd to command buffer. */
2826 if (*savbuf) { /* In case then-part of 'if' command */
2827 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
2829 } else { /* Else get next cmd from macro def */
2830 if (getncm(cbp,CMDBL) < 0) {
2833 debug(F101,"parser end of macro m","",m);
2834 debug(F101,"parser end of macro cmdlvl","",cmdlvl);
2835 debug(F101,"parser end of macro inlevel","",inlevel);
2838 if (m && (cmdlvl < inlevel))
2839 return((int) sstate);
2840 else /* if (!m) */ continue;
2843 debug(F010,"CMD(M)",cmdbuf,0);
2845 } else if (cmdstk[cmdlvl].src == CMD_TF)
2851 debug(F111,"parser savbuf",savbuf,tlevel);
2852 if (*savbuf) { /* In case THEN-part of IF command */
2853 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
2858 /* Get next line from TAKE file */
2860 if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
2861 debug(F111,"parser tfcode",tfile[tlevel],tfcode);
2862 if (tfcode < -1) { /* Error */
2863 printf("?Error in TAKE command file: %s\n",
2864 (tfcode == -2) ? "Memory allocation failure" :
2865 "Line too long or contains NUL characters"
2869 continue; /* -1 means EOF */
2872 /* If interactive, get next command from user. */
2874 } else { /* User types it in. */
2875 if (pflag) prompt(xxstring);
2879 /* Now we know where next command is coming from. Parse and execute it. */
2881 repars = 1; /* 1 = command needs parsing */
2883 displa = 0; /* Assume no file transfer display */
2886 while (repars) { /* Parse this cmd until entered. */
2888 debug(F101,"parser top of while loop","",0);
2891 /* In case of "send /recursive ./?<Ctrl-U>" etc */
2892 recursive = 0; /* This is never sticky */
2893 #endif /* RECURSIVE */
2894 xfiletype = -1; /* Reset this between each command */
2897 #endif /* NOMSEND */
2900 #endif /* CK_RECALL */
2901 /* This might have been changed by a switch */
2902 if (g_matchdot > -1) {
2903 matchdot = g_matchdot;
2906 cmres(); /* Reset buffer pointers. */
2910 /* we check to see if a macro is waiting to be executed */
2911 /* if so, we call domac on it */
2913 ckstrncpy(cmdbuf, cmdmac, CMDBL);
2917 #endif /* COMMENT */
2923 xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
2924 debug(F101,"top-level cmkey2","",xx);
2926 yy = chktok(toktab);
2927 debug(F101,"top-level cmkey token","",yy);
2929 /* Either way makes absolutely no difference */
2930 debug(F110,"NO UNGWORD",atmbuf,0);
2933 debug(F110,"TOKEN UNGWORD",atmbuf,0);
2935 #endif /* COMMENT */
2937 case '#': xx = XXCOM; break; /* Comment */
2938 case ';': xx = XXCOM; break; /* Comment */
2940 case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
2941 case ':': xx = XXLBL; break; /* GOTO label */
2947 #endif /* CK_REDIR */
2952 if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
2959 case '<': xx = XXFUN; break; /* REDIRECT */
2960 #endif /* CK_REDIR */
2962 case '!': xx = XXSHE; break; /* Shell escape */
2968 case '^': xx = XXREDO; break;
2969 #endif /* CK_RECALL */
2971 case '{': xx = XXMACRO; break;
2972 case '(': xx = XXSEXP; break;
2977 printf("\n?Invalid - \"%s\"\n",cmdbuf);
2980 if (maclvl > -1 && xcmdsrc == 2)
2981 printf("Macro: %s; ",
2983 m_arg[maclvl][0] : "");
2986 printf("Command file: %s, line %d\n",
2987 tfnam[tlevel] ? tfnam[tlevel] : "",
2993 printf("Command stack:\n");
2996 #endif /* COMMENT */
3002 debug(F101,"HAVE TOKEN","",xx);
3005 topcmd = xx; /* Top-level command index */
3008 lastcmd[maclvl] = xx;
3010 debug(F101,"topcmd","",topcmd);
3011 debug(F101,"cmflgs","",cmflgs);
3015 /* Special handling for IF..ELSE */
3017 debug(F101,"cmdlvl","",cmdlvl);
3018 debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
3020 if (ifcmd[cmdlvl]) /* Count stmts after IF */
3022 if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
3025 /* Execute the command and take action based on return code. */
3027 if (nulcmd) { /* Ignoring this command? */
3028 xx = XXCOM; /* Make this command a comment. */
3030 fnsuccess = 1; /* For catching \function() errors */
3033 debug(F101,"calling docmd()","",xx);
3034 zz = docmd(xx); /* Parse rest of command & execute. */
3037 if (fnerror && !fnsuccess)
3040 debug(F101,"docmd returns","",zz);
3041 /* debug(F011,"cmdbuf",cmdbuf,30); */
3042 /* debug(F011,"atmbuf",atmbuf,30); */
3045 if (sstate == 'a') { /* if cmd-. cancel */
3046 debug(F110, "parser: cancel take, sstate:", "a", 0);
3049 return(0); /* End of init file or whatever. */
3054 case -4: /* EOF (e.g. on redirected stdin) */
3055 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
3056 case -1: /* Reparse needed */
3057 repars = 1; /* Just set reparse flag and... */
3060 case -7: /* They typed a disk letter */
3061 if (!zchdir((char *)cmdbuf)) {
3062 perror((char *)cmdbuf);
3069 case -6: /* Invalid command given w/no args */
3070 case -2: /* Invalid command given w/args */
3073 /* This is going to be really ugly... */
3074 yy = mlook(mactab,atmbuf,nmac); /* Look in macro table */
3075 if (yy > -1) { /* If it's there */
3076 if (zz == -2) { /* insert "do" */
3078 mp = malloc((int)strlen(cmdbuf) + 5);
3080 printf("?malloc error 1\n");
3083 sprintf(mp,"do %s ",cmdbuf); /* SAFE (checked) */
3084 ckstrncpy(cmdbuf,mp,CMDBL);
3088 if (((int)strlen(atmbuf) + 5) < CMDBL)
3089 sprintf(cmdbuf,"do %s %c",atmbuf, CR); /* SAFE */
3091 ckstrncpy(cmdbuf,"echo ?Too long\r",CMDBL);
3093 if (ifcmd[cmdlvl] == 2) /* This one doesn't count! */
3095 debug(F111,"stuff cmdbuf",cmdbuf,zz);
3096 repars = 1; /* Go for reparse */
3104 if (cmflgs == 0) printf("\n");
3105 if (zzstring(p,&lp,&n) > -1)
3106 printf("?Invalid: %s\n",line);
3108 printf("?Invalid: %s\n",cmdbuf);
3109 } /* (fall thru...) */
3111 printf("?Invalid: %s\n",cmdbuf);
3113 #else /* Not COMMENT */
3114 printf("?Invalid: %s\n",cmdbuf);
3115 #endif /* COMMENT */
3117 case -9: /* Bad, error message already done */
3119 debug(F110,"top-level cmkey failed",cmdbuf,0);
3120 /* If in background w/ commands coming stdin, terminate */
3121 if (pflag == 0 && tlevel < 0)
3122 fatal("Kermit command error in background execution");
3124 Command retry feature, edit 190. If we're at interactive prompting level,
3125 reprompt the user with as much of the command as didn't fail.
3128 if (cm_retry && !xcmdsrc) { /* If at top level */
3131 len = strlen(cmdbuf); /* Length of command buffer */
3132 p = malloc(len + 1); /* Allocate space for copy */
3133 if (p) { /* If we got the space copy */
3134 strcpy(p,cmdbuf); /* the command buffer (SAFE). */
3135 /* Chop off final field, the one that failed. */
3136 s = p + len - 1; /* Point to end */
3137 while (*s == SP && s > p) /* Trim blanks */
3139 while (*s != SP && s > p) /* Trim last field */
3141 if (s > p) /* Keep the space */
3142 s++; /* after last good field */
3143 if (s >= p) /* Cut off remainder */
3145 cmini(ckxech); /* Reinitialize the parser */
3146 ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
3147 free(p); /* Free temporary storage */
3149 prompt(xxstring); /* Reprint the prompt */
3150 printf("%s",cmdbuf); /* Reprint partial command */
3151 repars = 1; /* Force reparse */
3155 #endif /* CK_RECALL */
3160 printf("Macro: %s; ",
3162 m_arg[maclvl][0] : "");
3165 printf("Command file: %s, line %d\n",
3166 tfnam[tlevel] ? tfnam[tlevel] : "",
3171 printf("Command stack:\n");
3174 #endif /* COMMENT */
3176 cmini(ckxech); /* (fall thru) */
3178 case -3: /* Empty command OK at top level */
3179 repars = 0; /* Don't need to reparse. */
3180 continue; /* Go back and get another command. */
3182 default: /* Command was successful. */
3184 debug(F101,"parser preparing to continue","",maclvl);
3186 debug(F101,"parser success","",success);
3187 repars = 0; /* Don't need to reparse. */
3188 continue; /* Go back and get another command. */
3192 debug(F101,"parser breaks out of while loop","",maclvl);
3193 if (m && (cmdlvl < inlevel)) return((int) sstate);
3197 /* Got an action command, return start state. */
3199 return((int) sstate);
3205 Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
3207 #define OBSIZE 80 /* Size of local character buffer */
3209 static int obn; /* Buffer offset (high water mark) */
3210 static char obuf[OBSIZE+1]; /* OUTPUT buffer. */
3211 static char *obp; /* Pointer to output buffer. */
3212 _PROTOTYP( static int oboc, (char) );
3213 _PROTOTYP( static int xxout, (char *, int) );
3217 xxout(char *obuf, int obsize)
3219 xxout(obuf, obsize) char *obuf; int obsize;
3220 #endif /* CK_ANSIC */
3221 /* xxout */ { /* OUTPUT command's output function */
3224 debug(F101,"xxout obsize","",obsize);
3225 debug(F101,"xxout pacing","",pacing);
3226 debug(F111,"xxout string",obuf,strlen(obuf));
3228 rc = 0; /* Initial return code. */
3229 if (!obuf || (obsize <= 0)) /* Nothing to output. */
3230 goto xxout_x; /* Return successfully */
3232 rc = -1; /* Now assume failure */
3233 if (pacing == 0) { /* Is pacing enabled? */
3234 if ((local ? /* No, write entire string at once */
3235 ttol((CHAR *)obuf, obsize) : /* to communications device */
3236 conxo(obsize, obuf)) /* or to console */
3240 for (i = 0; i < obsize; i++) { /* Write individual chars */
3241 if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
3248 if (inecho && local) {
3250 for (i = 0; i < obsize; i++) { /* Write to emulator */
3251 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
3253 #endif /* NOLOCAL */
3255 } else if (seslog) { /* or log session here */
3256 logstr((char *) obuf, obsize);
3260 logstr((char *) obuf, obsize);
3262 if (inecho && local) {
3267 rc = 0; /* Success */
3269 obn = 0; /* Reset count */
3270 obp = obuf; /* and pointers */
3271 return(rc); /* return our return code */
3276 Macros for OUTPUT command execution, to make it go faster.
3278 #define obfls() ((xxout(obuf,obn)<0)?-1:0)
3279 #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
3281 #else /* The macros cause some compilers to generate bad code. */
3288 #endif /* CK_ANSIC */
3289 /* oboc */ { /* OUTPUT command's output function */
3291 *obp++ = c; /* Deposit character */
3292 *obp = NUL; /* Flush buffer if it's now full */
3294 return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
3296 #endif /* COMMENT */
3298 /* Routines for handling local variables -- also see popclvl(). */
3301 freelocal(m) int m; { /* Free local variables */
3302 struct localvar * v, * tv; /* at macro level m... */
3303 debug(F101,"freelocal level","",m);
3305 v = localhead[m]; /* List head for level m */
3307 if (v->lv_name) /* Variable name */
3309 if (v->lv_value) /* Value */
3311 tv = v; /* Save pointer to this node */
3312 v = v->lv_next; /* Get next one */
3313 if (tv) /* Free this one */
3316 localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
3319 #define MAXLOCALVAR 64
3321 /* Return a pointer to the definition of a user-defined variable */
3324 vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
3328 if (!s) return(NULL);
3329 if (!*s) return(NULL);
3335 if ((c = *p) == '%') { /* Scalar variable. */
3336 c = *++p; /* Get ID character. */
3337 p = ""; /* Assume definition is empty */
3340 if (c >= '0' && c <= '9') { /* Digit for macro arg */
3341 if (maclvl < 0) /* Digit variables are global */
3342 return(g_var[c]); /* if no macro is active */
3343 else /* otherwise */
3344 return(m_arg[maclvl][c - '0']); /* they're on the stack */
3345 } else if (isalpha(c)) {
3346 if (isupper(c)) c -= ('a'-'A');
3347 return(g_var[c]); /* Letter for global variable */
3350 } else if (c == '&') { /* Array reference. */
3352 x = arraynam(p,&vbi,&d); /* Get name and subscript */
3353 if (x > -1 || d == -17) {
3356 *x2 = (d == -17) ? 0 : d;
3360 if (chkarray(vbi,d) > 0) { /* Array is declared? */
3361 vbi -= ARRAYBASE; /* Convert name to index */
3362 if (a_dim[vbi] >= d) { /* If subscript in range */
3365 return((ap) ? ap[d] : NULL);
3372 k = mxlook(mactab,s,nmac);
3373 return((k > -1) ? mactab[k].mval : NULL);
3379 addlocal(p) char * p; {
3380 int x, z, isarray = 0;
3382 struct localvar * v, *prev = (struct localvar *)NULL;
3383 extern int tra_asg; int tra_tmp;
3387 s = vardef(p,&isarray,&x,&z); /* Get definition of variable */
3388 if (isarray) { /* Arrays are handled specially */
3393 if ((v = localhead[cmdlvl])) { /* Already have some at this level? */
3394 while (v) { /* Find end of list */
3399 v = (struct localvar *) malloc(sizeof(struct localvar));
3401 printf("?Failure to allocate storage for local variables");
3404 if (!localhead[cmdlvl]) /* If first, set list head */
3405 localhead[cmdlvl] = v;
3406 else /* Otherwise link previous to this */
3408 prev = v; /* And make this previous */
3409 v->lv_next = (struct localvar *) NULL; /* No next yet */
3411 if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
3413 strcpy(v->lv_name, p); /* Copy name into new node (SAFE) */
3416 if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
3418 strcpy(v->lv_value, s); /* Copy value into new node (SAFE) */
3423 delmac(p,1); /* Delete the original macro */
3429 dolocal() { /* Do the LOCAL command */
3432 char * list[MAXLOCALVAR+2]; /* Up to 64 variables per line */
3434 if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
3437 xwords(s,MAXLOCALVAR,list,0); /* Break up line into "words" */
3439 /* Note: Arrays do not use the localhead list, but have their own stack */
3441 for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
3442 if (addlocal(list[i]) < 0)
3445 return(success = 1);
3448 printf("?Failure to allocate storage for local variables");
3453 /* D O O U T P U T -- Returns 0 on failure, 1 on success */
3457 #define SEND_BUFLEN 255
3458 #define sendbufd(x) { osendbuf[sendndx++] = x;\
3459 if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
3460 #endif /* NOKVERBS */
3462 int outesc = 1; /* Process special OUTPUT escapes */
3465 dooutput(s, cx) char *s; int cx; {
3468 extern char * ssh_cmd;
3469 #endif /* SSHBUILTIN */
3470 int x, xx, y, quote; /* Workers */
3473 is_tn = (local && network && IS_TELNET()) ||
3474 (!local && sstelnet);
3476 debug(F111,"dooutput s",s,(int)strlen(s));
3478 if (local) { /* Condition external line */
3483 printf("?Connection %s %s is not open.\n",
3484 network ? "to" : "on",
3489 if (ttvt(speed,flow) < 0) {
3490 printf("?OUTPUT initialization error\n");
3493 #endif /* NOLOCAL */
3496 if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd &&
3497 !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
3499 printf("?SSH Subsystem active: %s\n", ssh_cmd);
3502 #endif /* SSHBUILTIN */
3504 if (!cmdgquo()) { /* COMMAND QUOTING OFF */
3505 x = strlen(s); /* Just send the string literally */
3506 xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
3507 return(success = (xx == x) ? 1 : 0);
3509 quote = 0; /* Initialize backslash (\) quote */
3510 obn = 0; /* Reset count */
3511 obp = obuf; /* and pointers */
3514 while ((x = *s++)) { /* Loop through the string */
3515 y = 0; /* Error code, 0 = no error. */
3516 debug(F000,"dooutput","",x);
3517 if (quote) { /* This character is quoted */
3519 if (x == 'k' || x == 'K') { /* \k or \K */
3520 extern struct keytab kverbs[];
3522 extern char * keydefptr;
3525 int x, y, brace = 0;
3528 char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
3529 char osendbuf[SEND_BUFLEN +1];
3532 if (xxout(obuf,obn) < 0) /* Flush buffer */
3534 debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
3535 { /* Have K verb? */
3540 We assume that the verb name is {braced}, or it extends to the end of the
3541 string, s, or it ends with a space, control character, or backslash.
3543 p = kbuf; /* Copy verb name into local buffer */
3545 while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
3546 if (brace && *s == '}') {
3551 if (*s && !brace) /* If we broke because of \, etc, */
3552 s--; /* back up so we get another look. */
3554 *p = NUL; /* Terminate. */
3555 p = kbuf; /* Point back to beginning */
3556 debug(F110,"dooutput kverb",p,0);
3557 y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
3558 debug(F101,"dooutput lookup",0,y);
3561 dooutput(osendbuf,cx);
3566 } else { /* Is it a macro? */
3567 y = mxlook(mactab,p,nmac);
3570 keymac = 1; /* Flag for key macro active */
3571 keymacx = y; /* Key macro index */
3572 keydefptr = s; /* Where to resume next time */
3573 debug(F111,"dooutput mxlook",keydefptr,y);
3583 #endif /* NOKVERBS */
3584 if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
3585 if (xxout(obuf,obn) < 0) /* Flush buffer */
3587 debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
3595 } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
3597 if (xxout(obuf,obn) < 0) /* Flush buffer first */
3599 debug(F100,"OUTPUT BREAK","",0);
3601 ttsndb(); /* Send BREAK signal */
3607 #endif /* NOLOCAL */
3608 quote = 0; /* Turn off quote flag */
3609 continue; /* and not the b or B */
3611 } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
3612 if (xxout(obuf,obn) < 0) /* Flush buffer first */
3614 debug(F100,"OUTPUT Long BREAK","",0);
3616 ttsndlb(); /* Send Long BREAK signal */
3622 #endif /* NOLOCAL */
3623 quote = 0; /* Turn off quote flag */
3624 continue; /* and not the l or L */
3625 #endif /* CK_LBRK */
3627 } else if (x == CMDQ) { /* Backslash itself */
3628 debug(F100,"OUTPUT CMDQ","",0);
3629 xx = oboc(dopar(CMDQ)); /* Output the backslash. */
3635 } else { /* if \ not followed by special esc */
3636 /* Note: Atari ST compiler won't allow macro call in "if ()" */
3637 xx = oboc(dopar(CMDQ)); /* Output the backslash. */
3640 quote = 0; /* Turn off quote flag */
3642 } else if (x == CMDQ) { /* This is the quote character */
3643 quote = 1; /* Go back and get next character */
3644 continue; /* which is quoted */
3646 xx = oboc(dopar((char)x)); /* Output this character */
3647 debug(F111,"dooutput",obuf,obn);
3651 if (seslog && duplex) { /* Log the character if log is on */
3654 #endif /* COMMENT */
3655 if (x == '\015') { /* String contains carriage return */
3656 int stuff = -1, stuff2 = -1;
3657 if (tnlm) { /* TERMINAL NEWLINE ON */
3658 stuff = LF; /* Stuff LF */
3661 /* TELNET NEWLINE ON/OFF/RAW */
3663 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
3680 if (stuff > -1) { /* Stuffing another character... */
3681 xx = oboc(dopar((CHAR)stuff));
3685 if (seslog && duplex) { /* Log stuffed char if appropriate */
3686 logchar((char)stuff);
3688 #endif /* COMMENT */
3690 if (stuff2 > -1) { /* Stuffing another character... */
3691 xx = oboc(dopar((CHAR)stuff2));
3695 if (seslog && duplex) { /* Log stuffed char if appropriate */
3696 logchar((char)stuff2);
3698 #endif /* COMMENT */
3700 if (xxout(obuf,obn) < 0) /* Flushing is required here! */
3704 if (cx == XXLNOUT) {
3709 if (quote == 1) /* String ended with backslash */
3710 xx = oboc(dopar(CMDQ));
3712 if (obn > 0) /* OUTPUT done */
3713 if (xxout(obuf,obn) < 0) /* Flush the buffer if necessary. */
3717 outerr: /* OUTPUT command error handler */
3718 if (msgflg) printf("?OUTPUT execution error\n");
3721 /* Remove "local" OUTPUT macro defininitions */
3724 /* No more macros ... */
3727 #endif /* COMMENT */
3731 /* Display version herald and initial prompt */
3736 extern int srvcdmsg;
3737 extern char * cdmsgfile[];
3739 extern char * bannerfile;
3740 debug(F110,"herald bannerfile",bannerfile,0);
3742 concb((char)escape);
3743 if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
3744 debug(F111,"herald","srvcdmsg",srvcdmsg);
3746 for (i = 0; i < 8; i++) {
3747 debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
3748 if (zchki(cdmsgfile[i]) > -1) {
3750 dotype(cdmsgfile[i],
3751 xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
3762 /* The following generates bad code in SCO compilers. */
3763 /* Observed in both OSR5 and Unixware 2 -- after executing this */
3764 /* statement when all conditions are false, x has a value of -32. */
3765 if (noherald || bgset > 0 || (bgset != 0 && backgrd != 0)) x = 1;
3772 else if (bgset < 0 && backgrd > 0)
3774 #endif /* COMMENT */
3778 printf("%s, for%s\n",versio,ckxsys);
3781 printf("%s, for%s\n",versio,ckxsys);
3783 printf("%s, for%s\n\r",versio,ckxsys);
3785 #endif /* datageneral */
3786 printf(" Copyright (C) 1985, 2004,\n");
3787 printf(" Trustees of Columbia University in the City of New York.\n");
3792 if (!quiet && !backgrd) {
3794 /* "Default file-transfer mode is AUTOMATIC" is useless information... */
3796 extern int xfermode;
3800 if (xfermode == XMODE_A) {
3803 s = gfmode(binary,1);
3808 printf("Default file-transfer mode is %s\n", s);
3809 #endif /* COMMENT */
3811 debug(F111,"herald","srvcdmsg",srvcdmsg);
3813 for (i = 0; i < 8; i++) {
3814 debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
3815 if (zchki(cdmsgfile[i]) > -1) {
3817 dotype(cdmsgfile[i],
3818 xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
3823 printf("Type ? or HELP for help.\n");
3828 /* G F M O D E -- Get File (transfer) Mode */
3831 gfmode(binary,upcase) int binary, upcase; {
3834 case XYFT_T: s = upcase ? "TEXT" : "text"; break;
3836 case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
3837 case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
3838 case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
3839 case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
3842 case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
3843 case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
3845 case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
3847 case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
3848 #endif /* CK_LABELED */
3851 case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
3859 isaa(s) char * s; { /* Is associative array */
3865 while ((c = *s++)) {
3868 return ((*(s+x-1) == '>') ? 1 : 0);
3874 /* M L O O K -- Lookup the macro name in the macro table */
3877 Call this way: v = mlook(table,word,n);
3879 table - a 'struct mtab' table.
3880 word - the target string to look up in the table.
3881 n - the number of elements in the table.
3883 The keyword table must be arranged in ascending alphabetical order, and
3884 all letters must be lowercase.
3886 Returns the table index, 0 or greater, if the name was found, or:
3888 -3 if nothing to look up (target was null),
3892 A match is successful if the target matches a keyword exactly, or if
3893 the target is a prefix of exactly one keyword. It is ambiguous if the
3894 target matches two or more keywords from the table.
3897 mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
3899 int v, w, cmdlen = 0;
3900 char c = 0, c1, * s;
3903 for (s = cmd; *s; s++) cmdlen++; /* (instead of strlen) */
3904 debug(F111,"MLOOK",cmd,cmdlen);
3912 /* Not null, look it up */
3914 if (n < 12) { /* Not worth it for small tables */
3916 } else { /* Binary search for where to start */
3920 while (lo+2 < hi && ++count < 12) {
3921 i = lo + ((hi - lo) / 2);
3922 c = *(table[i].kwd);
3923 if (isupper(c)) c = tolower(c);
3930 i = (c < c1) ? lo+1 : lo;
3932 for ( ; i < n-1; i++) {
3935 if (!*s) continue; /* Empty table entry */
3937 if (isupper(c)) c = tolower(c);
3938 if (c1 != c) continue; /* First char doesn't match */
3939 if (!ckstrcmp(s,cmd,-1,0)) /* Have exact match? */
3941 v = !ckstrcmp(s,cmd,cmdlen,0);
3942 w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
3943 if (v && w) /* Have abbreviated match? */
3945 if (v) /* Ambiguous? */
3947 if (w > 0) /* Past our alphabetic area? */
3951 /* Last (or only) element */
3953 if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
3959 /* mxlook is like mlook, but an exact full-length match is required */
3962 mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
3964 int w, cmdlen = 0, one = 0;
3965 register char c = 0, c1, * s;
3967 if (!cmd) cmd = ""; /* Check args */
3969 for (s = cmd; *s; s++) cmdlen++; /* (instead of strlen) */
3970 debug(F111,"MXLOOK",cmd,cmdlen);
3972 c1 = *cmd; /* First char of string to look up */
3975 if (!*(cmd+1)) /* Special handling for 1-char names */
3978 if (cmdlen < 1) /* Nothing to look up */
3981 if (n < 12) { /* Not worth it for small tables */
3983 } else { /* Binary search for where to start */
3987 while (lo+2 < hi && ++count < 12) {
3988 i = lo + ((hi - lo) / 2);
3989 c = *(table[i].kwd);
3990 if (isupper(c)) c = tolower(c);
3997 i = (c < c1) ? lo+1 : lo;
3999 for ( ; i < n; i++) { /* Look thru table */
4000 s = table[i].kwd; /* This entry */
4002 if (!*s) continue; /* Empty table entry */
4004 if (isupper(c)) c = tolower(c);
4005 if (c1 != c) continue; /* First char doesn't match */
4006 if (one) { /* Name is one char long */
4008 return(i); /* So is table entry */
4011 if (((int)strlen(s) == cmdlen) &&
4012 (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
4014 w = ckstrcmp(s,cmd,-1,0);
4016 if (w > 0) return(-1);
4017 #endif /* COMMENT */
4022 /* mxxlook is like mxlook, but case-sensitive */
4025 mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
4028 if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
4029 /* debug(F111,"mxxlook target",cmd,n); */
4030 for (i = 0; i < n; i++) {
4031 if (((int)strlen(table[i].kwd) == cmdlen) &&
4032 (!strncmp(table[i].kwd,cmd,cmdlen)))
4039 traceval(nam, val) char * nam, * val; { /* For TRACE command */
4041 printf(">>> %s: \"%s\"\n", nam, val);
4043 printf(">>> %s: (undef)\n", nam);
4047 #ifdef USE_VARLEN /* Not used */
4049 /* V A R L E N -- Get length of variable's value.
4051 Given a variable name, return the length of its definition or 0 if the
4052 variable is not defined. If it is defined, set argument s to point to its
4053 definition. Otherwise set s to NULL.
4056 varlen(nam,s) char *nam; char **s; { /* Length of value of variable */
4061 if (!nam) return(0); /* Watch out for null pointer */
4064 if (*nam == '%') { /* If it's a variable name */
4065 if (!(c = *(nam+1))) return(0); /* Get letter or digit */
4066 p = (char *)0; /* Initialize value pointer */
4067 if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
4068 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
4069 } else { /* It's a global variable */
4070 if (c < 33 || c > GVARS) return(0);
4071 p = g_var[c]; /* Get pointer from global-var table */
4073 } else if (*nam == '&') { /* An array reference? */
4075 if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
4076 return(-1); /* return -1. */
4077 x -= ARRAYBASE; /* Convert name to number. */
4078 if ((q = a_ptr[x]) == NULL) /* If array not declared, */
4079 return(0); /* return -2. */
4080 if (z > a_dim[x]) /* If subscript out of range, */
4081 return(0); /* return -3. */
4084 } else { /* Macro */
4086 x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
4095 return((int)strlen(p));
4097 #endif /* USE_VARLEN */
4100 This routine is for the benefit of those compilers that can't handle
4101 long string constants or continued lines within them. Long predefined
4102 macros like FOR, WHILE, and XIF have their contents broken up into
4103 arrays of string pointers. This routine concatenates them back into a
4104 single string again, and then calls the real addmac() routine to enter
4105 the definition into the macro table.
4108 addmmac(nam,s) char *nam, *s[]; { /* Add a multiline macro definition */
4109 int i, x, y; char *p;
4110 x = 0; /* Length counter */
4111 for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
4112 debug(F111,"addmmac line",s[i],y);
4115 debug(F101,"addmmac lines","",i);
4116 debug(F101,"addmmac loop exit","",y);
4117 debug(F111,"addmmac length",nam,x);
4118 if (x < 0) return(-1);
4120 p = malloc(x+1); /* Allocate space for all of it. */
4122 printf("?addmmac malloc error: %s\n",nam);
4123 debug(F110,"addmmac malloc error",nam,0);
4126 *p = '\0'; /* Start off with null string. */
4127 for (i = 0; *s[i]; i++) /* Concatenate them all together. */
4128 ckstrncat(p,s[i],x+1);
4129 y = (int)strlen(p); /* Final precaution. */
4130 debug(F111,"addmmac constructed string",p,y);
4132 y = addmac(nam,p); /* Add result to the macro table. */
4134 debug(F100,"addmmac length mismatch","",0);
4135 printf("\n!addmmac internal error!\n");
4138 free(p); /* Free the temporary copy. */
4142 /* Here is the real addmac routine. */
4144 /* Returns -1 on failure, macro table index >= 0 on success. */
4149 addmac(nam,def) char *nam, *def; { /* Add a macro to the macro table */
4150 int i, x, y, z, namlen, deflen, flag = 0;
4151 int replacing = 0, deleting = 0;
4152 char * p = NULL, c, *s;
4153 extern int tra_asg; int tra_tmp;
4155 if (!nam) return(-1);
4156 if (!*nam) return(-1);
4162 #else /* IKSDCONF */
4164 #endif /* IKSDCONF */
4166 if (!ckstrcmp("on_exit",nam,-1,0) ||
4167 !ckstrcmp("on_logout",nam,-1,0))
4174 while (*p++) namlen++; /* (instead of strlen) */
4176 tra_tmp = tra_asg; /* trace... */
4177 debug(F111,"addmac nam",nam,namlen);
4178 if (!def) { /* Watch out for null pointer */
4180 debug(F111,"addmac def","(null pointer)",deflen);
4184 while (*p++) deflen++; /* (instead of strlen) */
4185 debug(F010,"addmac def",def,0);
4187 #ifdef USE_VARLEN /* NOT USED */
4188 /* This does not boost performance much because varlen() does a lot */
4190 if (x > 0 && x >= deflen) {
4191 strcpy(s,def); /* NOT USED */
4195 #endif /* USE_VARLEN */
4197 if (*nam == CMDQ) nam++; /* Backslash quote? */
4198 if (*nam == '%') { /* Yes, if it's a variable name, */
4199 if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
4202 delmac(nam,0); /* Delete any old value. */
4205 if (deflen < 1) { /* Null definition */
4206 p = NULL; /* Better not malloc or strcpy! */
4207 } else if (!flag) { /* A substantial definition */
4208 p = malloc(deflen + 1); /* Allocate space for it */
4210 printf("?addmac malloc error 2\n");
4212 } else strcpy(p,def); /* Copy def into new space (SAFE) */
4215 /* Now p points to the definition, or is a null pointer */
4217 if (c >= '0' && c <= '9') { /* \%0-9 variable */
4218 if (maclvl < 0) { /* Are we calling or in a macro? */
4219 g_var[c] = p; /* No, it's top level one */
4220 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
4221 } else { /* Yes, it's a macro argument */
4222 m_arg[maclvl][c - '0'] = p; /* Assign the value */
4223 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
4225 } else { /* It's a \%a-z variable */
4226 if (c < 33 || (unsigned int)c > GVARS) return(-1);
4227 if (isupper(c)) c = (char) tolower(c);
4228 g_var[c] = p; /* Put pointer in global-var table */
4230 if (tra_asg) traceval(nam,p);
4232 } else if (*nam == '&') { /* An array reference? */
4235 if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
4236 return(-1); /* return -1. */
4237 if (chkarray(x,z) < 0) /* If array not declared or */
4238 rc = -2; /* subscript out of range, ret -2 */
4241 delmac(nam,0); /* Delete any old value. */
4244 x -= ARRAYBASE; /* Convert name letter to index. */
4245 if (x > 'z' - ARRAYBASE + 1)
4248 if ((q = a_ptr[x]) == NULL) /* If array not declared, */
4249 return(-3); /* return -3. */
4255 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
4256 printf("addmac macro error 7: %s\n",nam);
4257 return(-4); /* for new def, return -4 on fail. */
4259 strcpy(p,def); /* Copy def into new space (SAFE). */
4262 q[z] = p; /* Store pointer to it. */
4263 if (x == 0) { /* Arg vector array */
4264 if (z >= 0 && z <= 9) { /* Copy values to corresponding */
4265 if (maclvl < 0) { /* \%1..9 variables. */
4266 makestr(&(toparg[z]),p);
4268 makestr(&(m_arg[maclvl][z]),p);
4272 if (tra_asg) traceval(nam,p);
4273 return(0); /* Done. */
4276 /* Not a macro argument or a variable, so it's a macro definition */
4280 if (tra_asg) traceval(nam,p);
4283 #endif /* USE_VARLEN */
4284 x = isaa(nam) ? /* If it's an associative array */
4285 mxxlook(mactab,nam,nmac) : /* look it up this way */
4286 mxlook(mactab,nam,nmac); /* otherwise this way. */
4287 if (x > -1) { /* If found... */
4288 if (deflen > 0) /* and a new definition was given */
4289 replacing = 1; /* we're replacing */
4290 else /* otherwise */
4291 deleting = 1; /* we're deleting */
4293 if (deleting) { /* Deleting... */
4294 if (delmac(nam,0) < 0)
4297 if (tra_asg) traceval(nam,p);
4299 } else if (deflen < 1) /* New macro with no definition */
4300 return(0); /* Nothing to do. */
4302 if (replacing) { /* Replacing an existing macro */
4303 if (mactab[x].mval) { /* If it currently has a definition, */
4304 free(mactab[x].mval); /* free it. */
4305 mactab[x].mval = NULL;
4308 y = x; /* Replacement index. */
4310 } else { /* Adding a new macro... */
4311 char c1, c2; /* Use fast lookup to find the */
4312 c1 = *nam; /* alphabetical slot. */
4313 if (isupper(c1)) c1 = (char) tolower(c1);
4315 if (nmac < 5) { /* Not worth it for small tables */
4317 } else { /* First binary search to find */
4318 int lo = 0; /* where to start */
4322 while (lo+2 < hi && ++count < 12) {
4323 y = lo + ((hi - lo) / 2);
4324 c = *(mactab[y].kwd);
4325 if (isupper(c)) c = (char) tolower(c);
4332 y = (c < c1) ? lo+1 : lo;
4334 /* Now search linearly from starting location */
4335 for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
4336 c2 = *(mactab[y].kwd);
4337 if (isupper(c2)) c2 = (char) tolower(c2);
4342 if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
4345 if (y == MAC_MAX) { /* Macro table is full. */
4346 debug(F101,"addmac table overflow","",y);
4347 printf("?Macro table overflow\n");
4350 if (mactab[y].kwd != NULL) { /* Must insert */
4351 for (i = nmac; i > y; i--) { /* Move the rest down one slot */
4352 mactab[i].kwd = mactab[i-1].kwd;
4353 mactab[i].mval = mactab[i-1].mval;
4354 mactab[i].flgs = mactab[i-1].flgs;
4358 p = malloc(namlen + 1); /* Allocate space for name */
4360 printf("?Addmac: Out of memory - \"%s\"\n",nam);
4363 strcpy(p,nam); /* Copy name into new space (SAFE) */
4364 mactab[y].kwd = p; /* Add pointer to table */
4366 if (deflen > 0) { /* If we have a definition */
4367 p = malloc(deflen + 1); /* Get space */
4369 printf("?Space exhausted - \"%s\"\n", nam);
4370 if (mactab[y].kwd) {
4371 free(mactab[y].kwd);
4372 mactab[y].kwd = NULL;
4376 strcpy(p,def); /* Copy the definition (SAFE) */
4378 } else { /* definition is empty */
4381 mactab[y].mval = p; /* Macro points to definition */
4382 mactab[y].flgs = 0; /* No flags */
4383 if (!replacing) /* If new macro */
4384 nmac++; /* count it */
4385 if (tra_asg) traceval(nam,p);
4390 xdelmac(x) int x; { /* Delete a macro given its index */
4393 if (x < 0) return(x);
4395 traceval(mactab[x].kwd,NULL);
4397 if (mactab[x].kwd) { /* Free the storage for the name */
4398 free(mactab[x].kwd);
4399 mactab[x].kwd = NULL;
4401 if (mactab[x].mval) { /* and for the definition */
4402 free(mactab[x].mval);
4403 mactab[x].mval = NULL;
4405 for (i = x; i < nmac; i++) { /* Now move up the others. */
4406 mactab[i].kwd = mactab[i+1].kwd;
4407 mactab[i].mval = mactab[i+1].mval;
4408 mactab[i].flgs = mactab[i+1].flgs;
4410 nmac--; /* One less macro */
4412 mactab[nmac].kwd = NULL; /* Delete last item from table */
4413 mactab[nmac].mval = NULL;
4414 mactab[nmac].flgs = 0;
4420 delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
4425 if (!nam) return(0); /* Watch out for null pointer */
4426 debug(F110,"delmac nam",nam,0);
4431 #else /* IKSDCONF */
4433 #endif /* IKSDCONF */
4435 if (!ckstrcmp("on_exit",nam,-1,0) ||
4436 !ckstrcmp("on_logout",nam,-1,0))
4441 if (*nam == CMDQ) nam++;
4442 if (*nam == '%') { /* If it's a variable name */
4443 if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
4444 p = (char *)0; /* Initialize value pointer */
4445 if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
4446 p = toparg[c - '0'];
4447 if (p) if (p != g_var[c]) {
4449 toparg[c - '0'] = NULL;
4452 g_var[c] = NULL; /* Zero the table entry */
4453 } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
4454 p = m_xarg[maclvl][c - '0'];
4455 if (p) if (p != g_var[c]) {
4457 m_xarg[maclvl][c - '0'] = NULL;
4459 p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
4460 m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
4461 } else { /* It's a global variable */
4462 if (c < 33 || (unsigned int)c > GVARS) return(0);
4463 p = g_var[c]; /* Get pointer from global-var table */
4464 g_var[c] = NULL; /* Zero the table entry */
4467 debug(F010,"delmac def",p,0);
4468 free(p); /* Free the storage */
4470 } else debug(F110,"delmac def","(null pointer)",0);
4471 if (tra_asg) traceval(nam,NULL);
4474 if (*nam == '&') { /* An array reference? */
4476 if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
4477 return(-1); /* return -1. */
4478 x -= ARRAYBASE; /* Convert name to number. */
4479 if ((q = a_ptr[x]) == NULL) /* If array not declared, */
4480 return(-2); /* return -2. */
4481 if (z > a_dim[x]) /* If subscript out of range, */
4482 return(-3); /* return -3. */
4483 if (q[z]) { /* If there is an old value, */
4484 debug(F010,"delmac def",q[z],0);
4485 if (x != 0) /* Macro arg vector is just a copy */
4486 free(q[z]); /* Others are real so free them */
4488 if (x == 0) { /* Arg vector array */
4489 if (z >= 0 && z <= 9) { /* Copy values to corresponding */
4490 if (maclvl < 0) { /* \%1..9 variables. */
4491 makestr(&(toparg[z]),NULL);
4493 makestr(&(m_arg[maclvl][z]),NULL);
4497 if (tra_asg) traceval(nam,NULL);
4498 } else debug(F010,"delmac def","(null pointer)",0);
4501 /* Not a variable or an array, so it must be a macro. */
4504 debug(F111,"delmac isaa",nam,z);
4505 debug(F111,"delmac exact",nam,exact);
4506 x = z ? mxxlook(mactab,nam,nmac) :
4507 exact ? mxlook(mactab,nam,nmac) :
4508 mlook(mactab,nam,nmac);
4510 debug(F111,"delmac mlook",nam,x);
4517 initmac() { /* Init macro & variable tables */
4520 nmac = 0; /* No macros */
4521 for (i = 0; i < MAC_MAX; i++) { /* Initialize the macro table */
4522 mactab[i].kwd = NULL;
4523 mactab[i].mval = NULL;
4527 x = (MAXARGLIST + 1) * sizeof(char **);
4528 for (i = 0; i < MACLEVEL; i++) { /* Init the macro argument tables */
4529 m_xarg[i] = (char **) malloc(x);
4530 mrval[i] = NULL; /* Macro return value */
4531 /* Pointer to entire argument vector, level i, for \&_[] array */
4532 for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
4533 if (j < 10) /* For the \%0..\%9 variables */
4534 m_arg[i][j] = NULL; /* Pointer to arg j, level i. */
4535 if (m_xarg[i]) /* For \&_[] - all args. */
4536 m_xarg[i][j] = NULL;
4539 for (i = 0; i < GVARS; i++) { /* And the global variables table */
4542 /* And the table of arrays */
4543 for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
4544 a_ptr[i] = (char **) NULL; /* Null pointer for each */
4545 a_dim[i] = 0; /* and a dimension of zero */
4547 for (j = 0; j < CMDSTKL; j++) {
4548 aa_ptr[j][i] = (char **) NULL;
4555 popclvl() { /* Pop command level, return cmdlvl */
4557 struct localvar * v;
4559 debug(F101,"popclvl cmdlvl","",cmdlvl);
4561 if ((v = localhead[cmdlvl])) { /* Did we save any variables? */
4562 while (v) { /* Yes */
4563 if (v->lv_value) /* Copy old ones back */
4564 addmac(v->lv_name,v->lv_value);
4566 delmac(v->lv_name,1);
4569 freelocal(cmdlvl); /* Free local storage */
4571 /* Automatic arrays do not use the localhead list */
4573 for (i = 0; i < 28; i++) { /* Free any local arrays */
4574 if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
4575 dclarray((char)(i+ARRAYBASE),0); /* Destroy global one */
4576 a_ptr[i] = aa_ptr[cmdlvl][i];
4577 a_dim[i] = aa_dim[cmdlvl][i];
4578 aa_ptr[cmdlvl][i] = (char **)NULL;
4579 aa_dim[cmdlvl][i] = 0;
4580 } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
4581 dclarray((char)(i+ARRAYBASE),0); /* (see pusharray()) */
4582 aa_ptr[cmdlvl][i] = (char **)NULL;
4583 aa_dim[cmdlvl][i] = 0;
4586 /* Otherwise do nothing - it is a local array that was declared */
4587 /* at a level above this one so leave it alone. */
4590 if (cmdlvl < 1) { /* If we're already at top level */
4591 cmdlvl = 0; /* just make sure all the */
4592 tlevel = -1; /* stack pointers are set right */
4593 maclvl = -1; /* and return */
4594 } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
4595 debug(F101,"popclvl tlevel","",tlevel);
4596 if (tlevel > -1) { /* Yes, */
4597 fclose(tfile[tlevel]); /* close it */
4600 printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
4601 debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
4602 if (tfnam[tlevel]) { /* free storage for name */
4603 free(tfnam[tlevel]);
4604 tfnam[tlevel] = NULL;
4606 tlevel--; /* and pop take level */
4607 cmdlvl--; /* and command level */
4608 quiet = xquiet[cmdlvl];
4611 } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
4612 topcmd = lastcmd[maclvl];
4613 debug(F101,"popclvl maclvl","",maclvl);
4614 if (maclvl > -1) { /* Yes, */
4618 #endif /* COMMENT */
4619 macp[maclvl] = ""; /* set macro pointer to null string */
4620 *cmdbuf = '\0'; /* clear the command buffer */
4622 if ((maclvl > 0) && /* 2 May 1999 */
4623 (m_arg[maclvl-1][0]) &&
4624 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
4625 !strncmp(m_arg[maclvl-1][0],"_for",4) ||
4626 !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
4627 !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
4629 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
4631 if (maclvl+1 < MACLEVEL) {
4632 if (mrval[maclvl+1]) { /* Free any deeper return values. */
4633 free(mrval[maclvl+1]);
4634 mrval[maclvl+1] = NULL;
4638 printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
4639 debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
4641 maclvl--; /* Pop macro level */
4642 cmdlvl--; /* and command level */
4643 debug(F101,"popclvl mac new maclvl","",maclvl);
4644 debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
4646 quiet = xquiet[cmdlvl];
4648 a_ptr[0] = m_xarg[maclvl];
4649 a_dim[0] = n_xarg[maclvl] - 1;
4650 debug(F111,"a_dim[0]","B",a_dim[0]);
4653 a_dim[0] = topargc - 1;
4654 debug(F111,"a_dim[0]","C",a_dim[0]);
4660 debug(F101,"popclvl topcmd","",topcmd);
4661 if (topcmd == XXSEXP) {
4662 extern char * sexpval;
4663 makestr(&(mrval[maclvl+1]),sexpval);
4669 debug(F101,"popclvl cmdlvl","",cmdlvl);
4670 if (prstring[cmdlvl]) {
4671 cmsetp(prstring[cmdlvl]);
4672 makestr(&(prstring[cmdlvl]),NULL);
4675 if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
4677 concb((char)escape); /* Go into cbreak mode */
4680 xcmdsrc = cmdstk[cmdlvl].src;
4681 debug(F101,"popclvl xcmdsrc","",xcmdsrc);
4682 debug(F101,"popclvl tlevel","",tlevel);
4683 return(cmdlvl < 1 ? 0 : cmdlvl); /* Return command level */
4685 #else /* No script programming language */
4686 int popclvl() { /* Just close current take file. */
4687 if (tlevel > -1) { /* if any... */
4688 if (tfnam[tlevel]) {
4689 free(tfnam[tlevel]);
4690 tfnam[tlevel] = NULL;
4692 fclose(tfile[tlevel--]);
4694 if (tlevel == -1) { /* And if back at top level */
4696 concb((char)escape); /* and go back into cbreak mode. */
4698 xcmdsrc = tlevel > -1 ? CMD_TF : 0;
4706 iseom(m) char * m; { /* Test if at end of macro def */
4709 debug(F111,"iseom",m,maclvl);
4711 /* Anything but Space and Comma means more macro is left */
4712 if ((*m > SP) && (*m != ',')) {
4713 debug(F111,"iseom return",m,0);
4718 debug(F111,"iseom return",m,1);
4719 return(1); /* Nothing left */
4723 /* Pop all command levels that can be popped */
4727 if (cmdlvl > 0) { /* If command level is > 0 and... */
4730 ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
4733 feof(tfile[tlevel])) /* And at end of file... */
4735 /* Or command source is macro... */
4736 || ((cmdstk[cmdlvl].src == CMD_MD) &&
4738 iseom(macp[maclvl]))) /* and at end of macro, then... */
4741 popclvl(); /* pop command level. */
4744 return(cmdlvl < 1 ? 0 : cmdlvl); /* Return command level */
4747 /* STOP - get back to C-Kermit prompt, no matter where from. */
4752 while (popclvl()) ; /* Pop all macros & take files */
4754 if (cmddep > -1) /* And all recursive cmd pkg invocations */
4755 while (cmpop() > -1) ;
4757 cmini(ckxech); /* Clear the command buffer. */
4761 /* Close the given log */
4764 doclslog(x) int x; {
4770 printf("?Debugging log wasn't open\n");
4773 debug(F100,"Debug Log Closed","",0L);
4776 return(zclose(ZDFILE));
4782 printf("?Packet log wasn't open\n");
4787 return(zclose(ZPFILE));
4793 printf("?Session log wasn't open\n");
4798 return(zclose(ZSFILE));
4799 #endif /* NOLOCAL */
4804 extern int iklogopen, xferlog;
4812 printf("?Transaction log wasn't open\n");
4816 if (iklogopen && !inserver) {
4822 tlog(F100,"Transaction Log Closed","",0L);
4834 if (msgflg) printf("?Connection log wasn't open\n");
4839 return(zclose(ZDIFIL));
4840 #endif /* CKLOGDIAL */
4843 case LOGW: /* WRITE file */
4844 case LOGR: /* READ file */
4845 y = (x == LOGR) ? ZRFILE : ZWFILE;
4846 if (chkfn(y) < 1) /* If no file to close */
4847 return(1); /* succeed silently. */
4848 return(zclose(y)); /* Otherwise, close the file. */
4852 printf("\n?Unexpected log designator - %d\n", x);
4857 static int slc = 0; /* Screen line count */
4860 showstring(s) char * s; {
4861 return(s ? s : "(null)");
4866 return(x ? "on" : "off");
4872 case SET_OFF: return("off");
4873 case SET_ON: return("on");
4874 case SET_AUTO: return("automatic");
4875 default: return("(unknown)");
4880 isxdigit(c) int c; {
4881 return(isdigit(c) ||
4882 (c >= 'a' && c <= 'f') ||
4883 (c >= 'A' && c <= 'F'));
4889 static struct keytab shokeytab[] = { /* SHOW KEY modes */
4893 static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
4895 #define SHKEYDEF TT_MAX+5
4896 struct keytab shokeymtab[] = {
4897 "aaa", TT_AAA, CM_INV, /* AnnArbor */
4898 "adm3a", TT_ADM3A, 0, /* LSI ADM-3A */
4899 "adm5", TT_ADM5, 0, /* LSI ADM-5 */
4900 "aixterm", TT_AIXTERM, 0, /* IBM AIXterm */
4901 "annarbor", TT_AAA, 0, /* AnnArbor */
4902 "ansi-bbs", TT_ANSI, 0, /* ANSI.SYS (BBS) */
4903 "at386", TT_AT386, 0, /* Unixware ANSI */
4904 "avatar/0+", TT_ANSI, 0, /* AVATAR/0+ */
4905 "ba80", TT_BA80, 0, /* Nixdorf BA80 */
4906 "be", TT_BEOS, CM_INV|CM_ABR,
4907 "beos-ansi", TT_BEOS, CM_INV, /* BeOS ANSI */
4908 "beterm", TT_BEOS, 0, /* BeOS Console */
4909 "d200", TT_DG200, CM_INV|CM_ABR, /* Data General DASHER 200 */
4910 "d210", TT_DG210, CM_INV|CM_ABR, /* Data General DASHER 210 */
4911 "d217", TT_DG217, CM_INV|CM_ABR, /* Data General DASHER 217 */
4912 "default", SHKEYDEF, 0,
4913 "dg200", TT_DG200, 0, /* Data General DASHER 200 */
4914 "dg210", TT_DG210, 0, /* Data General DASHER 210 */
4915 "dg217", TT_DG217, 0, /* Data General DASHER 217 */
4916 "emacs", TT_KBM_EMACS, 0, /* Emacs mode */
4917 "h19", TT_H19, CM_INV, /* Heath-19 */
4918 "heath19", TT_H19, 0, /* Heath-19 */
4919 "hebrew", TT_KBM_HEBREW, 0, /* Hebrew mode */
4920 "hft", TT_HFT, 0, /* IBM HFT */
4921 "hp2621a", TT_HP2621, 0, /* HP 2621A */
4922 "hpterm", TT_HPTERM, 0, /* HP TERM */
4923 "hz1500", TT_HZL1500, 0, /* Hazeltine 1500 */
4924 "ibm3151", TT_IBM31, 0, /* IBM 3101-xx,3161 */
4925 "linux", TT_LINUX, 0, /* Linux */
4926 "qansi", TT_QANSI, 0, /* QNX ANSI */
4927 "qnx", TT_QNX, 0, /* QNX */
4928 "russian", TT_KBM_RUSSIAN, 0, /* Russian mode */
4929 "scoansi", TT_SCOANSI, 0, /* SCO ANSI */
4930 "sni-97801", TT_97801, 0, /* Sinix 97801 */
4931 "sun", TT_SUN, 0, /* Sun Console */
4934 "tek4014", TT_TEK40, 0,
4935 #endif /* COMMENT */
4938 "tvi910+", TT_TVI910, 0,
4939 "tvi925", TT_TVI925, 0,
4940 "tvi950", TT_TVI950, 0,
4941 "vc404", TT_VC4404, 0,
4942 "vc4404", TT_VC4404, CM_INV,
4943 "vip7809", TT_VIP7809, 0,
4944 "vt100", TT_VT100, 0,
4945 "vt102", TT_VT102, 0,
4946 "vt220", TT_VT220, 0,
4947 "vt220pc", TT_VT220PC, 0,
4948 "vt320", TT_VT320, 0,
4949 "vt320pc", TT_VT320PC, 0,
4952 "wy160", TT_WY160, 0,
4954 "wy370", TT_WY370, 0,
4957 "wyse30", TT_WY30, CM_INV,
4958 "wyse370", TT_WY370, CM_INV,
4959 "wyse50", TT_WY50, CM_INV,
4960 "wyse60", TT_WY60, CM_INV
4962 int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
4967 shokeycode(c,m) int c, m;
4969 shokeycode(c) int c;
4990 printf(" Key code \\%d => ", c);
4997 if (IS_KVERB(km)) { /* \Kverb? */
4999 kv = km & ~(F_KVERB);
5001 for (i = 0; i < nkverbs; i++)
5002 if (kverbs[i].kwval == kv) {
5003 printf("\\K%s",kverbs[i].kwd);
5008 #endif /* NOKVERBS */
5010 int xkm = km & 0xFF;
5011 if (xkm <= 32 || xkm >= 127)
5012 printf("String: \\{27}[\\{%d}\n",xkm);
5014 printf("String: \\{27}[%c\n",xkm);
5015 } else if (IS_ESC(km)) {
5016 int xkm = km & 0xFF;
5017 if (xkm <= 32 || xkm >= 127)
5018 printf("String: \\{27}\\{%d}\n",xkm);
5020 printf("String: \\{27}%c\n",xkm);
5021 } else if (macrotab[c]) { /* See if there's a macro */
5022 printf("String: "); /* If so, display its definition */
5027 } else if (km >= 0x100) { /* This means "undefined" */
5028 printf("Undefined\n");
5029 #endif /* NOKVERBS */
5030 } else { /* No macro, show single character */
5031 printf("Character: ");
5033 if (ch < 32 || ch == 127
5041 || (ch > 127 && ch < 160)
5048 These used to be %d, but gcc 1.93 & later complain about type mismatches.
5049 %u is supposed to be totally portable.
5051 printf("\\%u",(unsigned int) ch);
5052 else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
5054 printf(" (self, no translation)\n");
5063 km = maptermkey(c,m);
5064 for (i = 0; i < nshokeym; i++) {
5065 if (m == shokeymtab[i].kwval) {
5066 mstr = shokeymtab[i].kwd;
5072 debug(F111,"shokeycode mstr",mstr,m);
5073 debug(F111,"shokeycode keyname",s,c);
5074 printf(" %sKey code \\%d %s (%s) => ",
5075 mskkeys ? "mskermit " : "",
5076 mskkeys ? cktomsk(c) : c,
5077 s == NULL ? "" : s, mstr);
5083 kv = km.kverb.id & ~(F_KVERB);
5085 for (i = 0; i < nkverbs; i++) {
5086 if (kverbs[i].kwval == kv) {
5087 printf("\\K%s",kverbs[i].kwd);
5094 #endif /* NOKVERBS */
5096 int xkm = km.csi.key & 0xFF;
5097 if (xkm <= 32 || xkm >= 127)
5098 printf("String: \\{27}[\\{%d}\n",xkm);
5100 printf("String: \\{27}[%c\n",xkm);
5104 int xkm = km.esc.key & 0xFF;
5105 if (xkm <= 32 || xkm >= 127)
5106 printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
5108 printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
5112 printf("String: "); /* Macro, display its definition */
5113 shostrdef(km.macro.string);
5118 printf("Literal string: "); /* Literal, display its definition */
5119 shostrdef(km.literal.string);
5125 printf("Undefined\n");
5127 printf("Character: ");
5129 if (ch < 32 || ch == 127 || ch > 255
5134 || (ch > 127 && ch < 160)
5141 These used to be %d, but gcc 1.93 & later complain about type mismatches.
5142 %u is supposed to be totally portable.
5144 printf("\\%u",(unsigned int) ch);
5145 else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
5146 printf(" (self, no translation)\n");
5151 printf("Character: ");
5152 ch = km.key.scancode;
5153 if (ch < 32 || ch == 127 || ch > 255
5158 || (ch > 127 && ch < 160)
5167 These used to be %d, but gcc 1.93 & later complain about type mismatches.
5168 %u is supposed to be totally portable.
5170 printf("\\%u",(unsigned int) ch);
5171 else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
5173 printf(" (self, no translation)\n");
5181 #endif /* NOSETKEY */
5184 shostrdef(s) CHAR * s; {
5186 if (!s) s = (CHAR *)"";
5187 while ((ch = *s++)) {
5188 if (ch < 32 || ch == 127 || ch == 255
5190 Systems whose native character sets have graphic characters in C1...
5192 #ifndef NEXT /* NeXT */
5193 #ifndef AUX /* Macintosh */
5194 #ifndef XENIX /* IBM PC */
5197 It doesn't matter whether the local host can display 8-bit characters;
5198 they are not portable among character-sets and fonts. Who knows what
5199 would be displayed...
5203 || (ch > 127 && ch < 160)
5209 printf("\\{%d}",ch); /* Display control characters */
5210 else putchar((char) ch); /* in backslash notation */
5214 #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
5220 extern char ckxsystem[];
5222 extern char *ck_patch, * cklibv;
5223 printf("\nVersions:\n %s\n",versio);
5224 printf(" Numeric: %ld\n",vernum);
5226 printf(" Operating System: %s\n", ckxsystem);
5228 printf(" Built for: %s\n", ckxsys);
5231 printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
5232 #endif /* CK_UTSNAME */
5233 printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
5235 if (xxdiff(ckxv,ckxsys))
5236 printf(" %s for%s\n",ckxv,ckxsys);
5238 printf(" %s\n",ckxv);
5239 if (xxdiff(ckzv,ckzsys))
5240 printf(" %s for%s\n",ckzv,ckzsys);
5242 printf(" %s\n",ckzv);
5243 printf(" %s\n",cklibv);
5244 printf(" %s\n",protv);
5245 printf(" %s\n",fnsv);
5246 printf(" %s\n %s\n",cmdv,userv);
5248 printf(" %s\n",xlav);
5249 #endif /* NOCSETS */
5252 printf(" %s\n",connv);
5254 printf(" %s\n",ckyv);
5256 #endif /* NOLOCAL */
5259 printf(" %s\n",dialv);
5262 printf(" %s\n",loginv);
5263 #endif /* NOSCRIPT */
5265 printf(" %s\n",cknetv);
5267 printf(" %s\n",ckonetv);
5269 printf(" %s\n",ckonbiv);
5270 #endif /* CK_NETBIOS */
5272 #endif /* NETCONN */
5274 printf(" %s\n",cktelv);
5277 printf(" %s\n",cksshv);
5279 printf(" %s\n",cksftpv);
5280 #endif /* SFTP_BUILTIN */
5281 #endif /* SSHBUILTIN */
5284 printf(" %s\n",ckomouv);
5285 #endif /* OS2MOUSE */
5288 printf(" %s\n",ckftpv);
5290 #ifdef CK_AUTHENTICATION
5291 printf(" %s\n",ckathv);
5292 #endif /* CK_AUTHENTICATION */
5293 #ifdef CK_ENCRYPTION
5295 printf(" %s\n",ck_crypt_dll_version());
5296 #else /* CRYPT_DLL */
5297 printf(" %s\n",ckcrpv);
5298 #endif /* CRYPT_DLL */
5299 #endif /* CK_ENCRYPTION */
5301 printf(" %s\n",cksslv);
5310 printf("VMS Labeled File Features:\n");
5311 printf(" acl %s (ACL info %s)\n",
5312 showoff(lf_opts & LBL_ACL),
5313 lf_opts & LBL_ACL ? "preserved" : "discarded");
5314 printf(" backup-date %s (backup date/time %s)\n",
5315 showoff(lf_opts & LBL_BCK),
5316 lf_opts & LBL_BCK ? "preserved" : "discarded");
5317 printf(" name %s (original filename %s)\n",
5318 showoff(lf_opts & LBL_NAM),
5319 lf_opts & LBL_NAM ? "preserved" : "discarded");
5320 printf(" owner %s (original file owner id %s)\n",
5321 showoff(lf_opts & LBL_OWN),
5322 lf_opts & LBL_OWN ? "preserved" : "discarded");
5323 printf(" path %s (original file's disk:[directory] %s)\n",
5324 showoff(lf_opts & LBL_PTH),
5325 lf_opts & LBL_PTH ? "preserved" : "discarded");
5328 printf("OS/2 Labeled File features (attributes):\n");
5329 printf(" archive: %s\n", showoff(lf_opts & LBL_ARC));
5330 printf(" extended: %s\n", showoff(lf_opts & LBL_EXT));
5331 printf(" hidden: %s\n", showoff(lf_opts & LBL_HID));
5332 printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
5333 printf(" system: %s\n", showoff(lf_opts & LBL_SYS));
5337 #endif /* CK_LABELED */
5340 shotcs(csl,csr) int csl, csr; { /* Show terminal character set */
5344 extern struct _vtG G[4], *GL, *GR;
5345 extern int decnrcm, sni_chcode;
5346 extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
5349 printf(" Terminal character-sets:\n");
5350 if (IS97801(tt_type_mode)) {
5352 printf(" Mode: 8-bit Mode\n");
5354 printf(" Mode: 7-bit Mode\n");
5355 printf(" CH.CODE is %s\n",sni_chcode?"On":"Off");
5356 } else if (ISVT100(tt_type_mode)) {
5358 printf(" Mode: 7-bit National Mode\n");
5360 printf(" Mode: 8-bit Multinational Mode\n");
5363 printf(" Local: Unicode display / %s input\n",
5364 csl == TX_TRANSP ? "transparent" :
5365 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
5367 printf(" Local: %s\n",
5368 csl == TX_TRANSP ? "transparent" :
5369 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
5372 printf(" Remote: UTF-8\n");
5374 printf(" Remote: %sG0: %s (%s)\n",
5375 GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : " ",
5376 txrinfo[G[0].designation]->keywd,
5377 G[0].designation == TX_TRANSP ? "" :
5378 G[0].size == cs94 ? "94 chars" :
5379 G[0].size == cs96 ? "96 chars" : "multi-byte");
5380 printf(" %sG1: %s (%s)\n",
5381 GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : " ",
5382 txrinfo[G[1].designation]->keywd,
5383 G[1].designation == TX_TRANSP ? "" :
5384 G[1].size == cs94 ? "94 chars" :
5385 G[1].size == cs96 ? "96 chars" : "multi-byte");
5386 printf(" %sG2: %s (%s)\n",
5387 GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : " ",
5388 txrinfo[G[2].designation]->keywd,
5389 G[2].designation == TX_TRANSP ? "" :
5390 G[2].size == cs94 ? "94 chars" :
5391 G[2].size == cs96 ? "96 chars" : "multi-byte");
5392 printf(" %sG3: %s (%s)\n",
5393 GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : " ",
5394 txrinfo[G[3].designation]->keywd,
5395 G[3].designation == TX_TRANSP ? "" :
5396 G[3].size == cs94 ? "94 chars" :
5397 G[3].size == cs96 ? "96 chars" : "multi-byte");
5400 printf(" Keyboard character-sets:\n");
5401 printf(" Multinational: %s\n",txrinfo[dec_kbd]->keywd);
5402 printf(" National: %s\n",txrinfo[dec_nrc]->keywd);
5404 printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
5410 debug(F101,"TERM LOCAL CSET","",csl);
5411 debug(F101,"TERM REMOTE CSET","",csr);
5412 printf(" Terminal character-set: ");
5413 if (tcs_transp) { /* No translation */
5414 printf("transparent\n");
5415 } else { /* Translation */
5416 printf("%s (remote) %s (local)\n",
5417 fcsinfo[csr].keyword,fcsinfo[csl].keyword);
5419 switch(gettcs(csr,csl)) {
5420 case TC_USASCII: s = "ascii"; break;
5421 case TC_1LATIN: s = "latin1-iso"; break;
5422 case TC_2LATIN: s = "latin2-iso"; break;
5423 case TC_CYRILL: s = "cyrillic-iso"; break;
5424 case TC_JEUC: s = "japanese-euc"; break;
5425 case TC_HEBREW: s = "hebrew-iso"; break;
5426 case TC_GREEK: s = "greek-iso"; break;
5427 case TC_9LATIN: s = "latin9-iso"; break;
5428 default: s = "transparent"; break;
5430 if (strcmp(s,fcsinfo[csl].keyword) &&
5431 strcmp(s,fcsinfo[csr].keyword))
5432 printf(" (via %s)\n",s);
5437 #endif /* NOCSETS */
5447 printf("Tab Stops:\n\n");
5448 for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
5450 printf("%c",htab[++i]=='T'?'T':'-');
5451 } while (i % k && i < MAXTERMCOL);
5453 for ( ; j <= i; j++) {
5456 printf("%c",j == 1 ? '1' : '.');
5490 for (i = 1; i <= 70; i++)
5491 printf("%c",htab[i]=='T'?'T':'-');
5492 printf("\n1.......10........20........30........40........50........60\
5494 for (; i <= 140; i++)
5495 printf("%c",htab[i]=='T'?'T':'-');
5496 printf("\n........80........90.......100.......110.......120.......130\
5498 for (; i <= 210; i++)
5499 printf("%c",htab[i]=='T'?'T':'-');
5500 printf("\n.......150.......160.......170.......180.......190.......200\
5502 for (; i <= 255; i++)
5503 printf("%c",htab[i]=='T'?'T':'-');
5504 printf("\n.......220.......230.......240.......250..255\n");
5509 #endif /* NOLOCAL */
5514 int button, event, id, i;
5517 printf("Mouse settings:\n");
5518 printf(" Button Count: %d\n",mousebuttoncount());
5519 printf(" Active: %s\n\n",showoff(tt_mouse));
5521 for (button = 0; button < MMBUTTONMAX; button++)
5522 for (event = 0; event < MMEVENTSIZE; event++)
5523 if (mousemap[button][event].type != error)
5524 switch (mousemap[button][event].type) {
5526 printf(" %s = Character: %c \\%d\n",
5527 mousename(button,event),
5528 mousemap[button][event].key.scancode,
5529 mousemap[button][event].key.scancode );
5532 id = mousemap[button][event].kverb.id & ~(F_KVERB);
5533 if (id != K_IGNORE) {
5534 for (i = 0; i< nkverbs; i++)
5535 if (id == kverbs[i].kwval) {
5536 name = kverbs[i].kwd;
5539 printf(" %s = Kverb: \\K%s\n",
5540 mousename(button,event),
5546 printf(" %s = Macro: ",
5547 mousename(button,event) );
5548 shostrdef(mousemap[button][event].macro.string);
5553 #endif /* OS2MOUSE */
5559 extern char * getiact();
5560 extern int tt_print, adl_err;
5562 extern char * tt_trigger[];
5563 #endif /* NOTRIGGER */
5565 extern char * tt_idlesnd_str;
5566 extern int tt_idlesnd_tmo;
5567 extern int tt_idlelimit, tt_idleact;
5568 #endif /* CKTIDLE */
5570 extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
5571 decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
5572 wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
5575 extern CKFLOAT tt_linespacing[];
5581 if (IsOS2FullScreen()) { /* Determine the font name */
5582 if (!os2LoadPCFonts()) {
5583 for (i = 0; i < ntermfont; i++) {
5584 if (tt_font == term_font[i].kwval) {
5585 font = term_font[i].kwd;
5590 font = "(DLL not available)";
5593 font = "(full screen only)";
5595 #endif /* PCFONTS */
5597 char font[64] = "(unknown)";
5598 if ( ntermfont > 0 ) {
5600 for (i = 0; i < ntermfont; i++) {
5601 if (tt_font == term_font[i].kwval) {
5602 ckstrncpy(font,term_font[i].kwd,59);
5603 ckstrncat(font," ",64);
5604 ckstrncat(font,ckitoa(tt_font_size/2),64);
5605 if ( tt_font_size % 2 )
5606 ckstrncat(font,".5",64);
5613 printf("Terminal parameters:\n");
5614 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5615 printf(" %19s: %1d%-12s %13s: %1d%-14s\n",
5616 "Bytesize: Command",
5617 (cmdmsk == 0377) ? 8 : 7,
5619 (cmask == 0377) ? 8 : 7," bits");
5620 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5621 printf(" %19s: %-13s","Type",
5622 (tt_type >= 0 && tt_type <= max_tt) ?
5623 tt_info[tt_type].x_name :
5625 if (tt_type >= 0 && tt_type <= max_tt)
5626 if (strlen(tt_info[tt_type].x_id))
5627 printf(" %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
5629 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5630 printf(" %19s: %-13s %13s: %-15s\n","Echo",
5631 duplex ? "local" : "remote","Locking-shift",showoff(sosi));
5632 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5633 printf(" %19s: %-13s %13s: %-15s\n","Newline-mode",
5634 showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
5635 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5636 printf(" %19s: %-13s %13s: %-15s\n","Cursor",
5637 (tt_cursor == 2) ? "full" :
5638 (tt_cursor == 1) ? "half" : "underline",
5640 "autodownload",autodl == TAD_ON ?
5641 (adl_err ? "on, error stop" : "on, error continue") :
5643 (adl_err ? "ask, error stop" : "ask, error continue") :
5645 #else /* CK_AUTODL */
5647 #endif /* CK_AUTODL */
5649 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5650 printf(" %19s: %-13s %13s: %-15s\n","Arrow-keys",
5651 tt_arrow ? "application" : "cursor",
5652 "Keypad-mode", tt_keypad ? "application" : "numeric"
5655 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5657 /* Just to make sure we are using current info */
5661 This line doesn't end with '\n' because the answerback string
5662 is terminated with a newline
5664 printf(" %19s: %-13s %13s: %-15s","Answerback",
5665 showoff(tt_answer),"response",answerback);
5673 case XYB_AUD | XYB_BEEP:
5676 case XYB_AUD | XYB_SYS:
5682 printf(" %19s: %-13s %13s: %-15s\n","Bell",s,
5683 "Wrap",showoff(tt_wrap));
5684 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5685 printf(" %19s: %-13s %13s: %-15s\n","Autopage",showoff(wy_autopage),
5686 "Autoscroll",showoff(autoscroll));
5687 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5688 printf(" %19s: %-13s %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
5689 "ESC[0m color",colorreset?"default-color":"current-color");
5690 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5691 printf(" %19s: %-13s %13s: %-15s\n",
5692 "Erase color",user_erasemode?"default-color":"current-color",
5693 "Screen mode",decscnm?"reverse":"normal");
5694 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5696 printf(" %19s: %-13d %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
5697 "Output-pacing",tt_pacing);
5698 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5700 printf(" %19s: %-13d %13s: %s\n","Idle-timeout",tt_idlelimit,
5701 "Idle-action", getiact());
5703 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5704 printf(" %19s: %-13s %13s: %-15s\n","Send data",
5705 showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
5706 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5708 printf(" %19s: %-13s %13s: %d seconds\n","Auto-exit trigger",
5709 tt_trigger[0],"Output pacing",tt_pacing );
5710 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5711 #endif /* NOTRIGGER */
5712 printf(" %19s: %-13s %13s: %-15d\n","Margin bell",
5713 showoff(marginbell),"at column", marginbellcol);
5714 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5715 switch (tt_modechg) {
5716 case TVC_DIS: s = "disabled"; break;
5717 case TVC_ENA: s = "enabled"; break;
5718 case TVC_W95: s = "win95-restricted"; break;
5719 default: s = "(unknown)";
5721 printf(" %19s: %-13s %13s: %-15s\n","DG Unix mode",
5722 showoff(dgunix),"Video change", s);
5723 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5726 if (apcstatus == APC_ON) s = "on";
5727 else if (apcstatus == APC_OFF) s = "off";
5728 else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
5729 else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
5730 else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
5731 printf(" %19s: %-13s %13s: %-15s\n",
5739 "Font","(not supported)"
5741 #endif /* PCFONTS */
5745 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5747 #ifdef CK_TTGWSIZ /* Console terminal screen size */
5748 if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
5749 ttgwsiz(); /* Try to get latest size */
5750 #endif /* CK_TTGWSIZ */
5751 printf(" %19s: %-13d %13s: %-15d\n","Height",tt_rows[VTERM],
5752 "Width",tt_cols[VTERM]);
5753 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5755 printf(" %19s: %-13f %13s: %-15d\n","Line spacing",tt_linespacing[VTERM],
5756 "Display Height",VscrnGetDisplayHeight(VTERM));
5757 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5759 printf(" %19s: %-13s %13s: %d lines\n","Roll-mode",
5760 tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
5761 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5763 if (updmode == tt_updmode)
5764 if (updmode == TTU_FAST)
5767 s = "smooth (smooth)";
5769 if (updmode == TTU_FAST)
5770 s = "fast (smooth)";
5772 s = "smooth (fast)";
5774 printf(" %19s: %-13s %13s: %d ms\n","Screen-update: mode",s,
5775 "interval",tt_update);
5776 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5777 printf(" %19s: %-13s %13s: %-15s\n",
5778 "Screen-optimization",showoff(tt_diff_upd),
5779 "Status line",showoff(tt_status[VTERM]));
5780 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5781 printf(" %19s: %-13s %13s: %-15s\n","Debug",
5782 showoff(debses),"Session log", seslog? sesfil : "(none)" );
5783 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5785 /* Display colors (should become SHOW COLORS) */
5788 char * colors[16] = {
5789 "black","blue","green","cyan","red","magenta","brown","lgray",
5790 "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
5793 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5797 GetCurPos(&row, &col);
5798 WrtCharStrAtt("border", 6, row, 9, &colorborder );
5799 WrtCharStrAtt("debug", 5, row, 17, &colordebug );
5800 WrtCharStrAtt("helptext", 8, row, 25, &colorhelp );
5801 WrtCharStrAtt("reverse", 7, row, 34, &colorreverse );
5802 WrtCharStrAtt("select", 6, row, 42, &colorselect );
5803 WrtCharStrAtt("status", 6, row, 50, &colorstatus );
5804 WrtCharStrAtt("terminal", 8, row, 58, &colornormal );
5805 WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
5806 #endif /* ONETERMUPD */
5807 row = VscrnGetCurPos(VCMD)->y+1;
5808 VscrnWrtCharStrAtt(VCMD, "border", 6, row, 9, &colorborder );
5809 VscrnWrtCharStrAtt(VCMD, "debug", 5, row, 17, &colordebug );
5810 VscrnWrtCharStrAtt(VCMD, "helptext", 8, row, 25, &colorhelp );
5811 VscrnWrtCharStrAtt(VCMD, "reverse", 7, row, 34, &colorreverse );
5812 VscrnWrtCharStrAtt(VCMD, "select", 6, row, 42, &colorselect );
5813 VscrnWrtCharStrAtt(VCMD, "status", 6, row, 50, &colorstatus );
5814 VscrnWrtCharStrAtt(VCMD, "terminal", 8, row, 58, &colornormal );
5815 VscrnWrtCharStrAtt(VCMD, "underline", 9, row, 67, &colorunderline );
5817 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5819 /* Foreground color names */
5820 printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
5822 colors[colordebug&0x0F],
5823 colors[colorhelp&0x0F],
5824 colors[colorreverse&0x0F],
5825 colors[colorselect&0x0F],
5826 colors[colorstatus&0x0F],
5827 colors[colornormal&0x0F],
5828 colors[colorunderline&0x0F]);
5829 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5831 /* Background color names */
5832 printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
5833 colors[colorborder],
5834 colors[colordebug>>4],
5835 colors[colorhelp>>4],
5836 colors[colorreverse>>4],
5837 colors[colorselect>>4],
5838 colors[colorstatus>>4],
5839 colors[colornormal>>4],
5840 colors[colorunderline>>4] );
5841 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5843 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5846 GetCurPos(&row, &col);
5847 WrtCharStrAtt("graphic", 7, row, 9, &colorgraphic );
5848 WrtCharStrAtt("command", 7, row, 17, &colorcmd );
5849 WrtCharStrAtt("italic", 6, row, 26, &coloritalic );
5850 #endif /* ONETERMUPD */
5851 row = VscrnGetCurPos(VCMD)->y+1;
5852 VscrnWrtCharStrAtt(VCMD, "graphic", 7, row, 9, &colorgraphic );
5853 VscrnWrtCharStrAtt(VCMD, "command", 7, row, 17, &colorcmd );
5854 VscrnWrtCharStrAtt(VCMD, "italic", 6, row, 26, &coloritalic );
5856 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5858 /* Foreground color names */
5859 printf("%6s: %-8s%-8s%-8s\n","fore",
5860 colors[colorgraphic&0x0F],
5861 colors[colorcmd&0x0F],
5862 colors[coloritalic&0x0F]);
5863 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5865 /* Background color names */
5866 printf("%6s: %-8s%-8s%-8s\n","back",
5867 colors[colorgraphic>>4],
5868 colors[colorcmd>>4],
5869 colors[coloritalic>>4]);
5870 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5873 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5875 extern int trueblink, truereverse, trueunderline, trueitalic;
5877 " Attribute: blink: %-3s reverse: %-3s underline: %-3s italic: %-3s\n",
5878 trueblink?"on":"off", truereverse?"on":"off",
5879 trueunderline?"on":"off", trueitalic?"on":"off");
5880 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5883 extern vtattrib WPattrib;
5884 printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
5885 WPattrib.blinking?"blink ":"",
5886 WPattrib.italic?"italic ":"",
5887 WPattrib.reversed?"reverse ":"",
5888 WPattrib.underlined?"underline ":"",
5889 WPattrib.bold?"bold ":"",
5890 WPattrib.dim?"dim ":"",
5891 WPattrib.invisible?"invisible ":"");
5892 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5896 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5897 (VOID) shoesc(escape);
5898 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5899 printf(" See SHOW CHARACTER-SETS for character-set info\n");
5900 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
5902 #else /* OS2 */ /* Beginning of new non-OS2 version */
5905 printf("Terminal parameters:\n");
5906 printf(" %19s: %1d%-12s %13s: %1d%-14s\n",
5907 "Bytesize: Command",
5908 (cmdmsk == 0377) ? 8 : 7,
5910 (cmask == 0377) ? 8 : 7," bits");
5913 printf(" %19s: %-13s %13s: %-15s\n",
5915 s ? s : "(unknown)",
5920 printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
5922 printf(" %19s: %-13s %13s: %-15s\n","Echo",
5923 duplex ? "local" : "remote","Locking-shift",showoff(sosi));
5924 printf(" %19s: %-13s %13s: %-15s\n","Newline-mode",
5925 showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
5928 if (apcstatus == APC_ON) s = "on";
5929 else if (apcstatus == APC_OFF) s = "off";
5930 else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
5931 else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
5932 else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
5933 printf(" %19s: %-13s %13s: %-15s\n",
5936 "Autodownload", autodl ?
5937 (adl_err ? "on, error stop" : "on, error continue") : "off"
5940 #endif /* CK_AUTODL */
5944 #ifdef CK_TTGWSIZ /* Console terminal screen size */
5945 ttgwsiz(); /* Try to get latest size */
5946 printf(" %19s: %-13d %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
5947 #endif /* CK_TTGWSIZ */
5949 printf(" %19s: %-13s %13s: %-15s\n","Debug",
5950 showoff(debses),"Session log", seslog? sesfil : "(none)" );
5953 printf(" %19s: %-13d %13s: %s\n","Idle-timeout",tt_idlelimit,
5954 "Idle-action", getiact());
5955 #endif /* CKTIDLE */
5958 printf(" %19s: %-13s\n","Trigger",
5959 tt_trigger[0] ? tt_trigger[0] : "(none)");
5960 #endif /* NOTRIGGER */
5963 printf(" %19s: %-13s\n\n","Suspend", showoff(xsuspend));
5968 (VOID) shoesc(escape);
5970 shotcs(tcsl,tcsr); /* Show terminal character sets */
5971 #endif /* NOCSETS */
5977 shmdmlin() { /* Briefly show modem & line */
5982 _PROTOTYP( char * gtbmodel, (void) );
5983 #endif /* OLDTBCODE */
5984 #endif /* MINIDIAL */
5988 printf(" Port: %s, Modem type: ",ttname);
5990 printf(" Line: %s, Modem type: ",ttname);
5995 " Communication device not yet selected with SET PORT\n Modem type: "
5997 " Communication device not yet selected with SET LINE\n Modem type: "
6001 printf("%s",gmdmtyp());
6004 if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
6005 #endif /* OLDTBCODE */
6006 #endif /* MINIDIAL */
6008 printf("(disabled)");
6014 shotapi(int option) {
6017 LPDEVCFG lpDevCfg = NULL;
6018 LPCOMMCONFIG lpCommConfig = NULL;
6019 LPMODEMSETTINGS lpModemSettings = NULL;
6021 extern struct keytab * tapiloctab; /* Microsoft TAPI Locations */
6022 extern int ntapiloc;
6023 extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
6024 extern int ntapiline;
6025 extern int tttapi; /* TAPI in use */
6026 extern int tapipass; /* TAPI Passthrough mode */
6027 extern int tapiconv; /* TAPI Conversion mode */
6028 extern int tapilights;
6029 extern int tapipreterm;
6030 extern int tapipostterm;
6031 extern int tapimanual;
6032 extern int tapiinactivity;
6033 extern int tapibong;
6034 extern int tapiusecfg;
6035 extern char tapiloc[];
6036 extern int tapilocid;
6037 extern int TAPIAvail;
6040 printf("TAPI Support not enabled\r\n");
6045 printf("TAPI Settings:\n");
6046 printf(" Line: %s\n",
6047 tttapi ? ttname : "(none in use)");
6049 cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
6050 if (tapilocid == -1)
6051 tapilocid = cktapiGetCurrentLocationID();
6053 /* Find the current tapiloc entry */
6054 /* and use it as the default. */
6055 for (k = 0; k < ntapiloc; k++) {
6056 if (tapiloctab[k].kwval == tapilocid)
6059 if (k >= 0 && k < ntapiloc)
6060 s = tapiloctab[k].kwd;
6063 printf(" Location: %s\n",s);
6064 printf(" Modem-dialing: %s\n",tapipass?"off":"on");
6065 printf(" Phone-number-conversions: %s\n",
6066 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
6067 printf(" Modem-lights: %s %s\n",tapilights?"on ":"off",
6068 tapipass?"(n/a)":"");
6069 printf(" Predial-terminal: %s %s\n",tapipreterm?"on ":"off",
6070 tapipass?"(n/a)":"");
6071 printf(" Postdial-terminal: %s %s\n",tapipostterm?"on ":"off",
6072 tapipass?"(n/a)":"");
6073 printf(" Manual-dial: %s %s\n",tapimanual?"on ":"off",
6074 tapipass?"(n/a)":"");
6075 printf(" Inactivity-timeout: %d seconds %s\n",tapiinactivity,
6076 tapipass?"(n/a)":"");
6077 printf(" Wait-for-bong: %d seconds %s\n",tapibong,
6078 tapipass?"(n/a)":"");
6079 printf(" Use-windows-configuration: %s %s\n",
6080 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
6085 printf("K-95 uses the TAPI Line in an exclusive mode. Other applications\n");
6086 printf("may open the device but may not place calls nor answer calls.\n");
6087 printf("Dialing is performed using the K-95 dialing procedures. SET MODEM\n");
6088 printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
6089 printf("definition associated with the active TAPI LINE device.\n\n");
6093 printf("K-95 uses the TAPI Line in a cooperative mode. Other applications\n");
6094 printf("may open the device, place and answer calls. Dialing is performed\n");
6095 printf("by TAPI. K-95 SET MODEM commands are not used.\n\n");
6098 if (tapiconv == CK_ON ||
6099 tapiconv == CK_AUTO && !tapipass) {
6101 "Phone numbers are converted from canonical to dialable form by TAPI\n");
6102 printf("using the dialing rules specified in the TAPI Dialing Properties\n");
6103 printf("dialog.\n\n");
6108 "Phone numbers are converted from canonical to dialable form by K-95\n");
6110 "using the dialing rules specified with the SET DIAL commands. TAPI\n");
6112 "Dialing Properties are imported automaticly upon startup and whenever\n");
6113 printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
6114 printf("is changed.\n\n");
6116 #endif /* BETATEST */
6119 printf("Type SHOW MODEM to see MODEM configuration.\n");
6120 if (tapiconv == CK_ON)
6121 printf("Type SHOW DIAL to see DIAL-related items.\n");
6123 if (tapiconv == CK_ON || tapiconv == CK_AUTO)
6124 printf("Type SHOW DIAL to see DIAL-related items.\n");
6128 cktapiDisplayTapiLocationInfo();
6131 rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
6132 &lpCommConfig,&lpDCB);
6134 cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
6135 lpCommConfig,lpDCB);
6137 printf("?Unable to retrieve Modem Settings\n");
6141 HANDLE hModem = GetModemHandleFromLine((HLINE)0);
6143 DisplayCommProperties(hModem);
6145 printf("?Unable to retrieve a valid Modem Handle\n");
6146 CloseHandle(hModem);
6152 #endif /* CK_TAPI */
6153 #endif /* NOLOCAL */
6158 extern char * binpatterns[], * txtpatterns[];
6159 extern int patterns, filepeek;
6161 int i, j, k, n, flag, width;
6163 ttgwsiz(); /* Try to get latest size */
6165 width = tt_cols[VCMD];
6170 #endif /* CK_TTGWSIZ */
6173 printf(" Set file type: %s\n",gfmode(binary,1));
6174 printf(" Set file patterns: %s", showooa(patterns));
6176 if (binary == XYFT_L)
6177 printf(" (but SET FILE TYPE LABELED overrides)\n");
6179 #endif /* CK_LABELED */
6181 if (binary == XYFT_I)
6182 printf(" (but SET FILE TYPE IMAGE overrides)\n");
6186 printf(" (but SET FILE SCAN ON overrides)\n");
6189 printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
6190 for (k = 0; k < 2; k++) { /* For each kind of patter */
6192 if (k == 0) { /* binary... */
6193 printf(" File binary-patterns: ");
6195 } else { /* text... */
6196 printf(" File text-patterns: ");
6204 for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
6205 if (!p[i]) /* Done */
6207 s = p[i]; /* Look for embedded space */
6208 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
6211 n += j + flag; /* Length of this line */
6212 if (n >= width - 1) {
6216 printf(flag == 3 ? " {%s}" : " %s", p[i]);
6224 #endif /* PATTERNS */
6229 printf(" Output pacing: %d (milliseconds)\n",pacing);
6230 printf(" Output special-escapes: %s\n", showoff(outesc));
6236 extern char * inpscale;
6237 #endif /* CKFLOAT */
6240 printf(" Input autodownload: %s\n", showoff(inautodl));
6241 #endif /* CK_AUTODL */
6242 printf(" Input cancellation: %s\n", showoff(inintr));
6243 printf(" Input case: %s\n", inpcas[cmdlvl] ?
6244 "observe" : "ignore");
6245 printf(" Input buffer-length: %d\n", inbufsize);
6246 printf(" Input echo: %s\n", showoff(inecho));
6247 printf(" Input silence: %d (seconds)\n", insilence);
6249 printf(" Input terminal: %s\n", showoff(interm));
6251 printf(" Input timeout: %s\n", intime[cmdlvl] ?
6252 "quit" : "proceed");
6254 printf(" Input scale-factor: %s\n", inpscale ? inpscale : "1.0");
6255 #endif /* CKFLOAT */
6258 printf(" Last INPUT: -1 (INPUT command not yet given)\n");
6260 printf(" Last INPUT: %d (%s)\n", instatus,i_text[instatus]);
6268 char * p, * q, ** ap;
6270 #endif /* COMMENT */
6271 char *s; int x = 0, y;
6274 if ((y = cmfld("Array name","",&s,NULL)) < 0)
6277 ckstrncpy(line,s,LINBUFSIZ);
6279 if ((y = cmcfm()) < 0)
6283 if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
6284 printf("?Bad array: %s\n",s);
6289 printf("Array not declared: %s\n", s);
6290 return(success = 1);
6293 max = (range[1] > 0) ?
6295 ((range[0] > 0) ? range[0] : a_dim[x]);
6301 printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
6303 printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
6305 for (i = range[0]; i <= max; i++) {
6307 printf("%3d. %s\n",i,ap[i]);
6310 x = strlen(ap[i]) + 5;
6311 y = (x % cmd_cols) ? 1 : 0;
6312 n += (x / cmd_cols) + y;
6316 if (n > (cmd_rows - 3)) {
6329 /* All arrays - just show name and dimension */
6331 for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
6333 if (x == 0) printf("Declared arrays:\n");
6335 printf(" \\&%c[%d]",
6336 (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
6338 printf(" => \\&%c[]",arrayitoa(a_link[y]));
6341 if (!x) printf(" No arrays declared\n");
6349 int y, z, i; long zz;
6350 extern int optlines;
6354 extern int tt_kb_mode;
6356 extern int srvcdmsg;
6357 extern char * cdmsgstr, * ckcdpath;
6360 if (x == SHKEY) { /* SHOW KEY */
6363 if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
6364 "one",xxstring)) < 0) return(x);
6365 switch (tt_kb_mode) {
6380 if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
6381 s,xxstring)) < 0) return(z);
6385 if ((y = cmcfm()) < 0) return(y);
6388 printf("Sorry, command disabled.\r\n");
6389 return(success = 0);
6394 printf("Not implemented\n");
6400 for (c = 0; c < KMSIZE; c++) {
6401 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
6402 if (evt.type != error) {
6408 printf(" Press key: ");
6412 #endif /* NOSETBUF */
6414 conbin((char)escape); /* Put terminal in binary mode */
6416 os2gks = 0; /* Raw scancode processing */
6418 c = congks(0); /* Get character or scan code */
6420 os2gks = 1; /* Cooked scancode processing */
6422 concb((char)escape); /* Restore terminal to cbreak mode */
6423 if (c < 0) { /* Check for error */
6424 printf("?Error reading key\n");
6429 Do NOT mask when it can be a raw scan code, perhaps > 255
6431 c &= cmdmsk; /* Apply command mask */
6446 if (x == SHKVB) { /* SHOW KVERBS */
6447 if ((y = cmcfm()) < 0) return(y);
6450 printf("Sorry, command disabled.\r\n");
6451 return(success = 0);
6454 printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
6455 kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
6460 if (x == SHUDK) { /* SHOW UDKs */
6461 extern void showudk(void);
6462 if ((y = cmcfm()) < 0) return(y);
6465 printf("Sorry, command disabled.\r\n");
6466 return(success = 0);
6473 #endif /* NOKVERBS */
6474 #endif /* NOSETKEY */
6477 if (x == SHMAC) { /* SHOW MACRO */
6478 struct FDB kw, fl, cm;
6479 int i, k, n = 0, left, flag, confirmed = 0;
6481 for (i = 0; i < nmac; i++) { /* copy the macro table */
6482 mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
6483 mackey[i].kwval = i; /* with value = pointer to macro tbl */
6484 mackey[i].flgs = mactab[i].flgs;
6488 while (!confirmed && n < 64) {
6489 cmfdbi(&kw, /* First FDB - macro table */
6491 "Macro name", /* hlpmsg */
6493 "", /* addtl string data */
6494 nmac, /* addtl numeric data 1: tbl size */
6495 0, /* addtl numeric data 2: 4 = cmswi */
6496 xxstring, /* Processing function */
6497 mackey, /* Keyword table */
6498 &fl /* Pointer to next FDB */
6500 cmfdbi(&fl, /* 2nd FDB - something not in mactab */
6504 "", /* addtl string data */
6505 0, /* addtl numeric data 1 */
6506 0, /* addtl numeric data 2 */
6511 cmfdbi(&cm, /* 3rd FDB - Confirmation */
6515 "", /* addtl string data */
6516 0, /* addtl numeric data 1 */
6517 0, /* addtl numeric data 2 */
6522 x = cmfdb(&kw); /* Parse something */
6525 s = atmbuf; /* What the user typed */
6526 switch (cmresult.fcode) {
6527 case _CMKEY: /* If it was a keyword */
6528 y = mlook(mactab,atmbuf,nmac); /* get full name */
6530 s = mactab[y].kwd; /* (fall thru on purpose...) */
6532 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
6538 q[n++] = p; /* Point to this item */
6539 p += k; /* Move buffer pointer past it */
6541 case _CMCFM: /* End of command */
6548 printf("Macros:\n");
6550 for (y = 0; y < nmac; y++)
6551 if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
6555 for (i = 0; i < n; i++) {
6560 if (iswild(s)) { /* Pattern match */
6561 for (k = 0, x = 0; x < nmac; x++) {
6562 if (ckmatch(s,mactab[x].kwd,0,1)) {
6563 shomac(mactab[x].kwd,mactab[x].mval);
6571 } else { /* Exact match */
6572 x = mxlook(mactab,s,nmac);
6575 if (flag && x == -1)
6576 x = mlook(mactab,s,nmac);
6578 case -3: /* Nothing to look up */
6579 case -1: /* Not found */
6580 printf("%s - (not defined)\n",s);
6582 case -2: /* Ambiguous, matches more than one */
6583 printf("%s - ambiguous\n",s);
6585 default: /* Matches one exactly */
6586 shomac(mactab[x].kwd,mactab[x].mval);
6595 Other SHOW commands only have two fields. Get command confirmation here,
6596 then handle with big switch() statement.
6599 if (x != SHBUI && x != SHARR)
6601 if ((y = cmcfm()) < 0)
6605 /* This restriction is too general. */
6612 #endif /* CK_LOGIN */
6614 printf("Sorry, command disabled.\r\n");
6615 return(success = 0);
6618 #endif /* COMMENT */
6632 printf(" No network support in this version of C-Kermit.\n");
6635 printf(" No network support in this version of C-Kermit.\n");
6638 #endif /* NETCONN */
6639 #endif /* NOLOCAL */
6654 printf(" %d\n",count[cmdlvl]);
6659 case SHSER: /* Show Server */
6662 printf("Function: Status:\n");
6664 printf(" GET %s\n",nm[en_get]);
6666 printf(" SEND %s\n",nm[en_sen]);
6668 printf(" MAIL %s\n",nm[inserver ? 0 : en_mai]);
6670 printf(" PRINT %s\n",nm[inserver ? 0 : en_pri]);
6673 printf(" REMOTE ASSIGN %s\n",nm[en_asg]);
6676 printf(" REMOTE CD/CWD %s\n",nm[en_cwd]);
6679 printf(" REMOTE COPY %s\n",nm[en_cpy]);
6682 printf(" REMOTE DELETE %s\n",nm[en_del]);
6683 printf(" REMOTE DIRECTORY %s\n",nm[en_dir]);
6684 printf(" REMOTE HOST %s\n",nm[inserver ? 0 : en_hos]);
6687 printf(" REMOTE QUERY %s\n",nm[en_que]);
6690 printf(" REMOTE MKDIR %s\n",nm[en_mkd]);
6691 printf(" REMOTE RMDIR %s\n",nm[en_rmd]);
6692 printf(" REMOTE RENAME %s\n",nm[en_ren]);
6693 printf(" REMOTE SET %s\n",nm[en_set]);
6694 printf(" REMOTE SPACE %s\n",nm[en_spa]);
6695 printf(" REMOTE TYPE %s\n",nm[en_typ]);
6696 printf(" REMOTE WHO %s\n",nm[inserver ? 0 : en_who]);
6697 printf(" BYE %s\n",nm[en_bye]);
6698 printf(" FINISH %s\n",nm[en_fin]);
6699 printf(" EXIT %s\n",nm[en_xit]);
6700 printf(" ENABLE %s\n",nm[en_ena]);
6702 #endif /* NOFRILLS */
6703 if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6704 printf("Server timeout: %d\n",srvtim);
6705 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6706 printf("Server idle-timeout: %d\n",srvidl);
6707 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6708 printf("Server keepalive %s\n", showoff(srvping));
6709 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6710 printf("Server cd-message %s\n", showoff(srvcdmsg));
6711 if (srvcdmsg && cdmsgstr)
6712 printf("Server cd-message %s\n", cdmsgstr);
6713 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6714 printf("Server display: %s\n", showoff(srvdis));
6715 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6716 printf("Server login: ");
6720 printf("\"%s\", \"%s\", \"%s\"\n",
6722 x_passwd ? x_passwd : "",
6723 x_acct ? x_acct : ""
6726 if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
6727 printf("Server get-path: ");
6728 if (ngetpath == 0) {
6729 printf(" (none)\n");
6733 for (x = 0; x < ngetpath; x++) {
6734 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
6735 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
6744 #endif /* NOSERVER */
6746 case SHSTA: /* Status of last command */
6747 printf(" %s\n", success ? "SUCCESS" : "FAILURE");
6748 return(0); /* Don't change it */
6750 case SHSTK: { /* Stack for MAC debugging */
6754 loadA0 ((char *)&sp); /* set destination address */
6755 SPtoaA0(); /* move SP to destination */
6756 printf("Stack at 0x%x\n", sp);
6757 show_queue(); /* more debugging */
6768 case SHTAB: /* SHOW TABS */
6771 printf("Sorry, command disabled.\r\n");
6772 return(success = 0);
6779 case SHTER: /* SHOW TERMINAL */
6782 printf("Sorry, command disabled.\r\n");
6783 return(success = 0);
6790 case SHVSCRN: /* SHOW Virtual Screen - for debug */
6794 #endif /* NOLOCAL */
6797 case SHMOU: /* SHOW MOUSE */
6800 printf("Sorry, command disabled.\r\n");
6801 return(success = 0);
6806 #endif /* OS2MOUSE */
6812 #endif /* NOFRILLS */
6815 case SHBUI: /* Built-in variables */
6816 if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
6818 ckstrncpy(line,s,LINBUFSIZ);
6819 /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
6821 case SHFUN: /* or built-in functions */
6824 if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
6827 if (ttgwsiz() > 0) { /* Get current screen size */
6828 if (tt_rows > 0 && tt_cols > 0) {
6834 #endif /* CK_TTGWSIZ */
6836 if (x == SHFUN) { /* Functions */
6837 printf("\nThe following functions are available:\n\n");
6838 kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
6842 "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
6846 } else { /* Variables */
6847 int j, flag = 0, havearg = 0;
6848 struct stringarray * q = NULL;
6850 if (line[0]) { /* Have something to search for */
6851 havearg = 1; /* Maybe a list of things */
6852 q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
6857 for (y = 0; y < nvars; y++) {
6858 if ((vartab[y].flgs & CM_INV))
6860 if (havearg) { /* If I have something to match */
6862 for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
6863 s2 = pp[j] ? pp[j] : "";
6865 /* This is not needed because it's what the 4 arg does in ckmatch() */
6868 if (s2[len-1] != '$') {/* To allow anchors */
6869 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
6873 #endif /* COMMENT */
6874 if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
6875 flag = 1; /* Matches */
6879 if (!flag) /* Doesn't match */
6882 s = nvlook(vartab[y].kwd);
6883 printf(" \\v(%s) = ",vartab[y].kwd);
6884 if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
6885 while (*s) /* Show control chars symbolically */
6886 printf("\\{%d}",*s++);
6888 } else if (vartab[y].kwval == VN_IBUF || /* \v(input) */
6889 vartab[y].kwval == VN_QUE || /* \v(query) */
6891 vartab[y].kwval == VN_SELCT || /* \v(select) */
6893 (vartab[y].kwval >= VN_M_AAA && /* modem ones */
6894 vartab[y].kwval <= VN_M_ZZZ)
6896 int r = 12; /* This one can wrap around */
6904 sprintf(buf,"\\{%d}",*s); /* SAFE */
6905 r += (int) strlen(buf);
6907 if (r >= cmd_cols - 1) {
6918 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
6919 if ((y >= nvars - 1) || !askmore())
6928 case SHVAR: /* Global variables */
6929 x = 0; /* Variable count */
6930 slc = 1; /* Screen line count for "more?" */
6931 for (y = 33; y < GVARS; y++)
6933 if (x++ == 0) printf("Global variables:\n");
6934 sprintf(line," \\%%%c",y); /* SAFE */
6935 if (shomac(line,g_var[y]) < 0) break;
6937 if (!x) printf(" No variables defined\n");
6940 case SHARG: { /* Args */
6943 printf("Macro arguments at level %d (\\v(argc) = %d):\n",
6947 for (y = 0; y < macargc[maclvl]; y++) {
6948 s1 = m_arg[maclvl][y];
6949 if (!s1) s1 = "(NULL)";
6950 s2 = m_xarg[maclvl][y];
6951 if (!s2) s2 = "(NULL)";
6953 printf(" \\%%%d = %s\n",y,s1);
6955 printf(" \\&_[%d] = %s\n",y,s2);
6958 printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
6959 for (y = 0; y < topargc; y++) {
6960 s1 = g_var[y + '0'];
6961 if (!s1) s1 = "(NULL)";
6963 if (!s2) s2 = "(NULL)";
6964 if (y < 10 && g_var[y])
6965 printf(" \\%%%d = %s\n",y,s1);
6967 printf(" \\&_[%d] = %s\n",y,s2);
6973 case SHARR: /* Arrays */
6974 return(showarray());
6978 case SHPRO: /* Protocol parameters */
6985 case SHCOM: /* Communication parameters */
6991 char *s = "(unknown)";
6992 for (i = 0; i < nprty; i++)
6993 if (prtytab[i].kwval == priority) {
6997 printf(" Priority: %s\n", s );
7008 #endif /* NETCONN */
7013 #endif /* NETCONN */
7020 printf("Type SHOW DIAL to see DIAL-related items.\n");
7021 printf("Type SHOW MODEM to see modem-related items.\n");
7023 printf("Type SHOW TAPI to see TAPI-related items.\n");
7024 #endif /* CK_TAPI */
7029 #endif /* NOLOCAL */
7031 case SHFIL: /* File parameters */
7033 /* printf("\n"); */ /* (out o' space) */
7037 case SHLNG: /* Languages */
7040 #endif /* NOCSETS */
7043 case SHSCR: /* Scripts */
7044 printf(" Command quoting: %s\n", showoff(cmdgquo()));
7045 printf(" Take echo: %s\n", showoff(techo));
7046 printf(" Take error: %s\n", showoff(takerr[cmdlvl]));
7047 printf(" Macro echo: %s\n", showoff(mecho));
7048 printf(" Macro error: %s\n", showoff(merror[cmdlvl]));
7049 printf(" Quiet: %s\n", showoff(quiet));
7050 printf(" Function diagnostics: %s\n", showoff(fndiags));
7051 printf(" Function error: %s\n", showoff(fnerror));
7054 extern char * learnfile;
7055 extern int learning;
7057 printf(" LEARN file: %s (%s)\n",
7059 learning ? "ON" : "OFF"
7062 printf(" LEARN file: (none)\n");
7064 #endif /* CKLEARN */
7068 printf(" Script echo: %s\n", showoff(secho));
7069 #endif /* NOSCRIPT */
7070 printf(" Command buffer length: %d\n", CMDBL);
7071 printf(" Atom buffer length: %d\n", ATMBL);
7078 printf(" File type: %s\n",
7079 binary ? "binary" : "text");
7081 printf(" File character-set: %s\n",
7082 fcsinfo[fcharset].keyword);
7084 if ( isunicode() ) {
7085 printf(" Terminal Character (remote): %s\n",
7086 tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
7087 tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
7088 printf(" Terminal Character (local): %s\n",
7089 tcsl == TX_TRANSP ? "transparent" :
7090 tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
7092 printf(" Terminal Character (remote): %s\n",
7093 tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
7094 tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
7095 printf(" Terminal Character (local): %s\n",
7096 tcsl == TX_TRANSP ? "transparent" :
7097 tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
7100 printf(" Terminal character-set (remote): %s\n",
7101 fcsinfo[tcsr].keyword);
7102 printf(" Terminal character-set (local): %s\n",
7103 fcsinfo[tcsl].keyword);
7105 #endif /* NOCSETS */
7106 printf(" Terminal bytesize: %d\n",
7107 (cmask == 0xff) ? 8 : 7);
7108 printf(" Terminal echo: %s\n",
7109 duplex ? "local" : "remote");
7110 printf(" Transmit EOF: ");
7111 if (*xmitbuf == NUL) {
7118 printf("^%c",ctl(*p));
7126 printf(" Transmit Fill: %d\n", xmitf);
7128 printf(" Transmit Fill: (none)\n");
7129 printf(" Transmit Linefeed: %s\n",showoff(xmitl));
7131 printf(" Transmit Prompt: %d (%s)\n",
7136 printf(" Transmit Prompt: (none)\n");
7137 printf(" Transmit Echo: %s\n", showoff(xmitx));
7138 printf(" Transmit Locking-Shift: %s\n", showoff(xmits));
7139 printf(" Transmit Pause: %d (millisecond%s)\n",
7141 (xmitw == 1) ? "" : "s"
7143 printf(" Transmit Timeout: %d (second%s)\n",
7145 (xmitt == 1) ? "" : "s"
7152 case SHMOD: /* SHOW MODEM */
7155 printf("Sorry, command disabled.\r\n");
7156 return(success = 0);
7159 shomodem(); /* Show SET MODEM items */
7165 printf("%s\n",zgtdir());
7173 printf("Sorry, command disabled.\r\n");
7174 return(success = 0);
7177 return(shoesc(escape));
7180 case SHDIA: /* SHOW DIAL */
7183 printf("Sorry, command disabled.\r\n");
7184 return(success = 0);
7188 printf(", speed: ");
7189 if ((zz = ttgspd()) < 0) {
7192 if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
7194 if (carrier == CAR_OFF) s = "off";
7195 else if (carrier == CAR_ON) s = "on";
7196 else if (carrier == CAR_AUT) s = "auto";
7198 printf(", carrier: %s", s);
7199 if (carrier == CAR_ON) {
7200 if (cdtimo) printf(", timeout: %d sec", cdtimo);
7201 else printf(", timeout: none");
7208 #endif /* NETCONN */
7210 printf("Type SHOW MODEM to see modem settings.\n");
7212 printf("Type SHOW TAPI to see TAPI-related items\n");
7213 #endif /* CK_TAPI */
7214 printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
7218 #endif /* NOLOCAL */
7222 case SHLBL: /* Labeled file info */
7225 #endif /* CK_LABELED */
7228 case SHCSE: /* Character sets */
7231 " Character set translation is not supported in this version of C-Kermit\n");
7235 printf("\n Unknown-Char-Set: %s\n",
7236 unkcs ? "Keep" : "Discard");
7244 /* PC Code Page information */
7247 int cplist[16], cps;
7249 cps = os2getcplist(cplist, sizeof(cplist));
7251 sprintf(cpbuf, /* SAFE */
7252 "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
7253 cps > 1 ? cplist[1] : 0,
7254 cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
7255 cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
7256 cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
7257 cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
7258 cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
7259 cps > 12 ? cplist[12] : 0
7261 printf(" Code Pages:\n");
7262 activecp = os2getcp();
7264 printf(" Active: %d\n",activecp);
7266 printf(" Available: %s\n",cpbuf);
7268 printf(" Active: n/a\n");
7272 #endif /* NOCSETS */
7275 case SHFEA: /* Features */
7280 case SHCTL: /* Control-Prefix table */
7283 #endif /* CK_SPEED */
7286 extern int exithangup;
7287 printf("\n Exit warning %s\n", xitwarn ?
7288 (xitwarn == 1 ? "on" : "always") : "off");
7289 printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
7290 printf(" Exit hangup: %s\n", showoff(exithangup));
7291 printf(" Current exit status: %d\n\n", xitsta);
7296 extern int printtimo, printertype, noprinter;
7297 extern char * printterm, * printsep;
7299 extern int printbidi;
7301 #endif /* PRINTSWI */
7307 #else /* CK_LOGIN */
7309 #endif /* CK_LOGIN */
7311 printf("Sorry, command disabled.\r\n");
7312 return(success = 0);
7317 printf("Printer: (none)\n\n");
7320 #endif /* PRINTSWI */
7322 printf("Printer: %s%s\n",
7324 printpipe ? "| " : "",
7325 printername ? printername :
7335 printf(" /BIDIRECTIONAL\n");
7337 printf(" /SPEED:%ld\n",pportspeed);
7338 printf(" /PARITY:%s\n",parnam((char)pportparity));
7339 printf(" /FLOW:%s\n",
7340 pportflow == FLO_NONE ? "NONE" :
7341 (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
7344 printf(" /OUTPUT-ONLY\n");
7346 switch (printertype) {
7347 case PRT_NON: printf(" /NONE\n"); break;
7348 case PRT_FIL: printf(" /FILE\n"); break;
7349 case PRT_PIP: printf(" /PIPE\n"); break;
7350 case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
7351 case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
7353 printf(" /TIMEOUT:%d\n",printtimo);
7355 printf(" /END-OF-JOB-STRING:");
7356 shostrdef(printterm);
7359 printf(" /END-OF-JOB-STRING:(none)\n");
7360 printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
7361 #endif /* PRINTSWI */
7367 #ifdef DOUBLEQUOTING
7369 #endif /* DOUBLEQUOTING */
7371 printf(" Command autodownload: %s\n",showoff(cmdadl));
7373 printf(" Command autodownload: (not available)\n");
7374 #endif /* CK_AUTODL */
7375 printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
7377 printf(" Command recall-buffer-size: %d\n",cm_recall);
7379 printf(" Command recall-buffer not available in this version\n");
7380 #endif /* CK_RECALL */
7382 printf(" Command retry: %s\n",showoff(cm_retry));
7384 printf(" Command retry not available in this version\n");
7385 #endif /* CK_RECALL */
7386 printf(" Command interruption: %s\n", showoff(cmdint));
7387 printf(" Command quoting: %s\n", showoff(cmdgquo()));
7388 #ifdef DOUBLEQUOTING
7389 printf(" Command doublequoting: %s\n", showoff(dblquo));
7390 #endif /* DOUBLEQUOTING */
7391 printf(" Command more-prompting: %s\n", showoff(xaskmore));
7392 printf(" Command height: %d\n", cmd_rows);
7393 printf(" Command width: %d\n", cmd_cols);
7396 printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
7398 #endif /* IKSDONLY */
7400 printf(" Locus: %s",
7401 autolocus ? (autolocus == 2 ? "ask" : "auto") :
7402 (locus ? "local" : "remote"));
7404 printf(" (%s)", locus ? "local" : "remote");
7407 printf(" Hints: %s\n", showoff(hints));
7408 printf(" Quiet: %s\n", showoff(quiet));
7409 printf(" Maximum command length: %d\n", CMDBL);
7414 printf(" Maximum number of macros: %d\n", MAC_MAX);
7415 printf(" Macros defined: %d\n", nmac);
7416 printf(" Maximum macro depth: %d\n", MACLEVEL);
7417 printf(" Maximum TAKE depth: %d\n", MAXTAKE);
7418 s = "(not defined)";
7419 k = mlook(mactab,"on_unknown_command",nmac);
7420 if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
7421 printf(" ON_UNKNOWN_COMMAND: %s\n",s);
7426 printf(" Suspend: %s\n", showoff(xsuspend));
7429 printf(" Access to external commands and programs%s allowed\n",
7440 printf("Alarm at %s %s\n",alrm_date,alrm_time);
7442 printf("(no alarm set)\n");
7448 extern struct filelist * filehead;
7450 printf("send-list is empty\n");
7452 struct filelist * flp;
7457 if (!s) s = "(none)";
7458 printf("%s, mode: %s, alias: %s\n",
7460 gfmode(flp->fl_mode,0),
7468 #endif /* NOMSEND */
7474 #endif /* CKXXCHAR */
7480 s = getenv("EDITOR");
7481 if (s) ckstrncpy(editor,s,CKMAXPATH);
7483 printf("\n editor: %s\n", editor[0] ? editor : "(none)");
7485 printf(" options: %s\n", editopts[0] ? editopts : "(none)");
7486 printf(" file: %s\n", editfile[0] ? editfile : "(none)");
7494 s = getenv("BROWSER");
7495 if (s) ckstrncpy(browser,s,CKMAXPATH);
7497 printf("\n browser: %s\n", browser[0] ? browser : "(none)");
7499 printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
7500 printf(" url: %s\n", browsurl[0] ? browsurl : "(none)");
7504 #endif /* BROWSER */
7505 #endif /* NOFRILLS */
7510 case SHTAPI: /* TAPI options */
7513 printf("Sorry, command disabled.\r\n");
7514 return(success = 0);
7519 case SHTAPI_L: /* TAPI Locations */
7522 printf("Sorry, command disabled.\r\n");
7523 return(success = 0);
7528 case SHTAPI_M: /* TAPI Modem */
7531 printf("Sorry, command disabled.\r\n");
7532 return(success = 0);
7537 case SHTAPI_C: /* TAPI Comm */
7540 printf("Sorry, command disabled.\r\n");
7541 return(success = 0);
7546 #endif /* CK_TAPI */
7548 case SHTCP: /* SHOTCP */
7555 case SHTEL: /* TELNET */
7561 case SHTOPT: /* TELNET OPTIONS */
7570 extern char * tt_trigger[], * triggerval;
7572 if (!tt_trigger[0]) {
7573 printf(" Triggers: (none)\n");
7575 printf(" Triggers:\n");
7576 for (i = 0; i < TRIGGERS; i++) {
7579 printf(" \"%s\"\n",tt_trigger[i]);
7581 printf(" Most recent trigger encountered: ");
7583 printf("\"%s\"\n",triggerval);
7589 #endif /* CK_TRIGGER */
7590 #endif /* NOLOCAL */
7604 #else /* CK_LOGIN */
7606 #endif /* CK_LOGIN */
7608 printf("Sorry, command disabled.\r\n");
7609 return(success = 0);
7613 printf("\n Debug log: %s\n", deblog ? debfil : "(none)");
7616 printf(" Packet log: %s\n", pktlog ? pktfil : "(none)");
7619 printf(" Session log: %s\n", seslog ? sesfil : "(none)");
7620 #endif /* NOLOCAL */
7622 printf(" Transaction log: %s (%s)\n",
7623 (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
7624 (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
7628 printf(" Connection log: %s\n", dialog ? diafil : "(none)");
7629 #endif /* CKLOGDIAL */
7636 case SHOUTP: /* OUTPUT */
7642 case SHOPAT: /* PATTERNS */
7645 #endif /* PATTERNS */
7648 case SHOSTR: { /* STREAMING */
7649 extern int streamrq, clearrq, cleared;
7651 debug(F101,"SHOW RELIABLE reliable","",reliable);
7652 printf("\n Reliable: %s\n",showooa(reliable));
7653 printf(" Clearchannel: %s\n",showooa(clearrq));
7654 printf(" Streaming: %s\n\n",showooa(streamrq));
7655 if ((!local && (streamrq == SET_ON)) ||
7656 (streamrq == SET_AUTO && reliable))
7657 printf(" Streaming will be done if requested.\n");
7658 else if ((streamrq == SET_OFF) ||
7659 ((streamrq == SET_AUTO) && !reliable))
7660 printf(" Streaming will not be requested and will not be done.\n");
7661 else if ((streamrq == SET_ON) ||
7662 ((streamrq == SET_AUTO) && reliable))
7664 " Streaming will be requested and will be done if the other Kermit agrees.\n");
7665 printf(" Last transfer: %sstreaming%s, %ld cps.\n",
7666 streamed > 0 ? "" : "no ",
7667 cleared ? ", clearchannel" : "",
7673 #endif /* STREAMING */
7679 #ifdef CK_AUTHENTICATION
7681 return(sho_auth(0));
7682 #endif /* CK_AUTHENTICATION */
7688 printf("Sorry, command disabled.\r\n");
7689 return(success = 0);
7694 extern char ftpapp[], ftpopts[];
7695 printf(" ftp-client: %s\n", ftpapp[0] ? ftpapp : "(none)");
7697 printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
7703 printf("(No FTP client included in this version of Kermit.)\n");
7713 extern int dbenabled;
7714 extern char * dbfile, * dbdir;
7718 extern char * wtmpfile;
7721 extern int ckxanon, xferlog, logintimo;
7722 extern char * xferfile;
7727 extern int ckxperms;
7728 #endif /* CK_PERMS */
7729 #endif /* CK_LOGIN */
7730 extern char * bannerfile, * helpfile;
7736 #else /* CK_LOGIN */
7738 #endif /* CK_LOGIN */
7740 printf("Sorry, command disabled.\r\n");
7741 return(success = 0);
7746 printf(" --nointerrupts\n");
7747 printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
7748 printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
7749 printf(" --cdmessage:%d\n",srvcdmsg);
7750 printf(" --helpfile:%d\n",helpfile);
7757 printf(" --syslog:%d (forced)\n",ckxsyslog);
7759 printf(" --syslog:%d\n",ckxsyslog);
7760 #endif /* SYSLOGLEVEL */
7761 #endif /* CKSYSLOG */
7763 printf(" --wtmplog:%d\n",ckxwtmp);
7764 printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
7768 printf(" --anonymous:%d\n",ckxanon);
7770 printf(" --privid:%d\n",ckxpriv);
7773 printf(" --permission:%04o\n",ckxperms);
7774 #endif /* CK_PERMS */
7775 printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
7776 printf(" --userfile:%s\n",userfile ? userfile : "(null)");
7777 printf(" --root:%s\n",anonroot ? anonroot : "(null)");
7778 printf(" --xferlog=%d\n",xferlog);
7779 printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
7780 printf(" --timeout=%d\n",logintimo);
7781 #endif /* CK_LOGIN */
7783 printf(" --database=%d\n",dbenabled);
7784 printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
7786 printf(" (db directory=[%s])\n",dbdir);
7789 printf(" IKSD conf=%s\n",iksdconf);
7790 #endif /* IKSDCONF */
7798 extern char * myhome;
7799 s = getenv("CDPATH");
7800 if (!s) s = "(none)";
7801 printf("\n current directory: %s\n", zgtdir());
7802 printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
7803 printf(" cd home: %s\n", homepath());
7804 printf(" cd path: %s\n", ckcdpath ? ckcdpath : s);
7805 printf(" cd message: %s\n", showoff(srvcdmsg & 2));
7806 printf(" server cd-message: %s\n", showoff(srvcdmsg & 1));
7807 printf(" cd message file: %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
7814 #endif /* NOCSETS */
7819 if (ftpisconnected()) {
7820 extern char cxlogbuf[];
7821 dologshow(W_FTP | 1);
7831 #endif /* CKLOGDIAL */
7836 (VOID) showdelopts();
7837 #endif /* NOFRILLS */
7839 (VOID) showdiropts();
7840 #endif /* DOMYDIR */
7842 (VOID) showpurgopts();
7843 #endif /* CKPURGE */
7844 (VOID) showtypopts();
7851 #endif /* NOLOCAL */
7863 #endif /* CK_RECALL */
7886 printf("\nNothing to show...\n");
7889 return(success = 1);
7895 printf("Attributes: %s\n", showoff(atcapr));
7896 if (!atcapr) return(0);
7897 printf(" Blocksize: %s\n", showoff(atblki));
7898 printf(" Date: %s\n", showoff(atdati));
7899 printf(" Disposition: %s\n", showoff(atdisi));
7900 printf(" Encoding (Character Set): %s\n", showoff(atenci));
7901 printf(" Length: %s\n", showoff(atleni));
7902 printf(" Type (text/binary): %s\n", showoff(attypi));
7903 printf(" System ID: %s\n", showoff(atsidi));
7904 printf(" System Info: %s\n", showoff(atsysi));
7906 printf(" Permissions In: %s\n", showoff(atlpri));
7907 printf(" Permissions Out: %s\n", showoff(atlpro));
7908 #endif /* CK_PERMS */
7910 printf(" Format: %s\n", showoff(atfrmi));
7911 printf(" Creator: %s\n", showoff(atcrei));
7912 printf(" Account: %s\n", showoff(atacti));
7913 #endif /* STRATUS */
7919 int /* SHOW MACROS */
7920 shomac(s1, s2) char *s1, *s2; {
7922 pp = 0; /* Parenthesis counter */
7924 debug(F110,"shomac s1",s1,0);
7925 debug(F110,"shomac s2",s2,0);
7931 #else /* IKSDCONF */
7933 #endif /* IKSDCONF */
7935 if (!ckstrcmp("on_exit",s1,-1,0) ||
7936 !ckstrcmp("on_logout",s1,-1,0))
7944 printf("%s = ",s1); /* Print blank line and macro name */
7945 n = (int)strlen(s1) + 4; /* Width of current line */
7946 if (!s2) s2 = "(not defined)";
7948 while ((x = *s2++)) { /* Loop thru definition */
7949 if (x == '(') pp++; /* Treat commas within parens */
7950 if (x == ')') pp--; /* as ordinary text */
7951 if (pp < 0) pp = 0; /* Outside parens, */
7952 if (x == ',' && pp == 0) { /* comma becomes comma-dash-NL. */
7957 if (inserver && (x == '\n')) /* Send CR before LF */
7959 putchar((CHAR)x); /* Output the character */
7960 if (x == '\n') { /* If it was a newline */
7964 #endif /* NOSETBUF */
7966 putchar(' '); /* Indent the next line 1 space */
7967 while(*s2 == ' ') s2++; /* skip past leading blanks */
7968 n = 2; /* restart the character counter */
7969 slc++; /* and increment the line counter. */
7970 } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
7971 putchar('-'); /* output a dash */
7973 putchar(CR); /* and a carriage return */
7974 putchar(NL); /* and a newline */
7978 #endif /* NOSETBUF */
7980 n = 1; /* and restart the char counter */
7981 slc++; /* and increment the line counter */
7983 if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
7984 if (!askmore()) return(-1); /* ask if they want more. */
7985 n = 1; /* They do, start a new line */
7986 slc = 0; /* and restart line counter */
7991 putchar(NL); /* End of definition */
7992 if (++slc > (cmd_rows - 3)) {
7993 if (!askmore()) return(-1);
8001 int x_ifnum = 0; /* Flag for IF NUMERIC active */
8004 /* Evaluate an arithmetic expression. */
8005 /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
8007 static int xerror = 0;
8014 #define LONGBITS (8*sizeof (long))
8019 Replacement for strchr() and index(), neither of which seem to be universal.
8024 windex(char * s, char c)
8026 windex(s,c) char *s, c;
8027 #endif /* CK_ANSIC */
8029 while (*s != NUL && *s != c) s++;
8030 if (*s == c) return(s); else return(NULL);
8037 Returns the next token. If token is a NUMBER, sets tokval appropriately.
8041 char tbuf[80] /* ,*tp */ ; /* Buffer to accumulate number */
8043 while (isspace(*cp)) /* Skip past leading spaces */
8046 debug(F110,"GETTOK",cp,0);
8051 case '-': /* Subtract or Negate */
8052 case '@': /* Greatest Common Divisor */
8053 case '*': /* Multiply */
8054 case '/': /* Divide */
8055 case '%': /* Modulus */
8056 case '<': /* Left shift */
8057 case '>': /* Right shift */
8060 case '#': /* Exclusive Or */
8062 case '^': /* Exponent */
8063 case '!': /* Factorial */
8064 case '(': /* Parens for grouping */
8065 case ')': return(*cp++); /* operator, just return it */
8067 case '\0': return(N_EOT); /* End of line, return that */
8070 /* This is the original code, which allows only integer numbers. */
8072 if (isxdigit(*cp)) { /* Digit, must be a number */
8073 int radix = 10; /* Default radix */
8074 for (tp = tbuf; isxdigit(*cp); cp++)
8075 *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
8076 *tp = '\0'; /* End number */
8077 switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
8079 case 'x': radix = 16; cp++; break; /* if radix signifier... */
8081 case 'q': radix = 8; cp++; break;
8082 case 't': radix = 2; cp++; break;
8084 for (tp = tbuf, tokval = 0; *tp != '\0'; tp++) {
8086 dig = *tp - '0'; /* Convert number */
8087 if (dig > 10) dig -= 'a'-'0'-10;
8089 if (cmdlvl == 0 && !x_ifnum && !xerror)
8090 printf("?Invalid digit '%c' in number\n",*tp);
8094 tokval = radix*tokval + dig;
8098 if (cmdlvl == 0 && !x_ifnum && !xerror)
8099 printf("Invalid character '%c' in input\n",*cp);
8104 /* This code allows non-numbers to be treated as macro names */
8110 for (i = 0; i < 80; i++) {
8111 /* Look ahead to next break character */
8112 /* pretty much anything that is not in the switch() above. */
8113 if (isalpha(*cp) || isdigit(*cp) ||
8114 *cp == '_' || *cp == ':' || *cp == '.' ||
8115 *cp == '[' || *cp == ']' ||
8116 *cp == '{' || *cp == '}'
8123 printf("Too long - \"%s\"\n", cp1);
8128 if (xerror) return(NUMBER);
8132 if (!isdigit(tbuf[0])) {
8134 x = mxlook(mactab,tbuf,nmac);
8135 debug(F111,"gettok mxlook",tbuf,x);
8137 if (cmdlvl == 0 && !x_ifnum && !xerror)
8138 printf("Bad number - \"%s\"\n",tbuf);
8143 s2 = mactab[x].mval;
8151 #endif /* CKFLOAT */
8155 if (cmdlvl == 0 && !x_ifnum && !xerror)
8156 printf("Bad number - \"%s\"\n",tbuf);
8163 #endif /* COMMENT */
8168 expon(long x, long y)
8170 expon(x,y) long x,y;
8171 #endif /* CK_ANSIC */
8175 if (y < 0) return(0);
8178 if (y & 1) sign = -1;
8181 if (y & 1) result *= x;
8185 return(result * sign);
8189 * factor ::= simple | simple ^ factor
8196 if (curtok == '^') {
8200 expval = expon(oldval,expval);
8205 * termp ::= NULL | {*,/,%,&} factor termp
8210 while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
8214 curtok = gettok(); /* skip past operator */
8218 case '*': expval = oldval * expval; break;
8223 printf("?Divide by zero\n");
8228 expval = (op == '/') ? (oldval / expval) : (oldval % expval);
8231 expval = oldval & expval; break;
8241 #endif /* CK_ANSIC */
8242 /* fact */ { /* factorial */
8250 * term ::= factor termp
8264 #endif /* CK_ANSIC */
8265 /* gcd */ { /* Greatest Common Divisor */
8268 if (y < 0) y = -y; /* validate arguments */
8269 if (x == 0 || y == 0) return(x + y); /* this is bogus */
8271 while (!((x & 1) | (y & 1))) { /* get rid of powers of 2 */
8276 while (x != 1 && y != 1 && x != 0 && y != 0) {
8277 while (!(x & 1)) x >>= 1; /* eliminate unnecessary */
8278 while (!(y & 1)) y >>= 1; /* powers of 2 */
8279 if (x < y) { /* force x to be larger */
8287 if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
8288 else return((long) 1 << nshift); /* else gcd is 1 */
8292 * exprp ::= NULL | {+,-,|,...} term exprp
8297 while (windex("+-|<>#@",curtok) != NULL) {
8301 curtok = gettok(); /* skip past operator */
8305 case '+' : expval = oldval + expval; break;
8306 case '-' : expval = oldval - expval; break;
8307 case '|' : expval = oldval | expval; break;
8308 case '#' : expval = oldval ^ expval; break;
8309 case '@' : expval = gcd(oldval,expval); break;
8310 case '<' : expval = oldval << expval; break;
8311 case '>' : expval = oldval >> expval; break;
8317 * expr ::= term exprp
8331 if (curtok == '$') {
8333 if (curtok != NUMBER) {
8334 if (cmdlvl == 0 && !x_ifnum)
8335 printf("?Illegal radix\n");
8341 #endif /* COMMENT */
8342 if (curtok != N_EOT) {
8343 if (cmdlvl == 0 && !x_ifnum && !xerror)
8344 printf("?Extra characters after expression\n");
8350 char * /* Silent front end for evala() */
8363 long v; /* Numeric value */
8365 xerror = 0; /* Start out with no error */
8367 cp = s; /* Make the argument global */
8368 v = xparse(); /* Parse the string */
8369 return(xerror ? "" : ckltoa(v)); /* Return empty string on error */
8373 * simplest ::= NUMBER | ( expr )
8380 if (curtok == NUMBER)
8382 else if (curtok == '(') {
8383 curtok = gettok(); /* skip over paren */
8385 if (curtok != ')') {
8386 if (cmdlvl == 0 && !x_ifnum && !xerror)
8387 printf("?Missing right parenthesis\n");
8390 debug(F110,"GETTOK SIMPLEST ()",p,0);
8393 if (cmdlvl == 0 && !x_ifnum && !xerror)
8394 printf("?Operator unexpected\n");
8401 * simpler ::= simplest | simplest !
8407 if (curtok == '!') {
8409 expval = fact(expval);
8414 * simple ::= {-,~,!} simpler | simpler
8420 if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
8422 curtok = gettok(); /* skip over - sign */
8423 simpler(); /* parse the factor again */
8425 expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
8429 /* D C L A R R A Y -- Declare an array */
8432 char a = single character designator for the array, e.g. "a".
8433 int n = size of array.
8435 0 or greater on success, having created the requested array with
8436 with n+1 elements, 0..n. If an array of the same name existed
8437 previously, it is destroyed. The new array has all its elements
8438 initialized to NULL pointers.
8439 -1 on failure (because 'a' out of range or malloc failure).
8443 dclarray(char a, int n)
8445 dclarray(a,n) char a; int n;
8446 #endif /* CK_ANSIC */
8448 char c, **p; int i, n2, rc;
8450 if (a > 63 && a < 91) a += 32; /* Convert letters to lowercase */
8451 if (a < ARRAYBASE || a > 122) /* Verify name */
8454 if (n < 0) /* Check arg */
8456 if (n+1 < 0) /* MAXINT+1 wraps around */
8460 a -= ARRAYBASE; /* Convert name to number */
8462 if ((p = a_ptr[a]) != NULL) { /* Delete old array of same name */
8463 if (a_link[a] > -1) { /* Is it a link? */
8464 if (n == 0) { /* If we're just deleting it */
8465 a_ptr[a] = (char **) NULL; /* clear all the info. */
8469 } /* Not deleting */
8470 a = a_link[a]; /* Switch to linked-to array */
8472 n2 = a_dim[a]; /* Real array */
8473 for (i = 0; i <= n2; i++) { /* First delete its elements */
8479 free((char *)a_ptr[a]); /* Then the element list */
8480 if (n == 0) { /* If undeclaring this array... */
8481 for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
8482 if (i != a && a_link[i] == a) { /* Find them */
8483 a_ptr[i] = (char **) NULL; /* and remove them */
8489 a_ptr[a] = (char **) NULL; /* Remove pointer to element list */
8490 a_dim[a] = 0; /* Set dimension at zero. */
8491 a_link[a] = -1; /* Unset link word */
8493 return(0); /* If dimension 0, just deallocate. */
8495 p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
8496 if (p == NULL) return(-1); /* Check */
8497 a_ptr[a] = p; /* Save pointer to member list */
8498 a_dim[a] = n; /* Save dimension */
8499 for (i = 0; i <= n; i++) /* Initialize members to null */
8501 for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
8502 if (i != a && a_link[i] == a) { /* Find and update them */
8510 /* X A R R A Y -- Convert array name to array index */
8513 xarray(s) char * s; {
8519 debug(F110,"xarray",s,0);
8527 buf[3] = (x > 0) ? s[1] : NUL;
8528 buf[4] = (x > 1) ? s[2] : NUL;
8529 buf[5] = (x > 2) ? s[3] : NUL;
8535 } else if (*s != CMDQ) {
8545 x = (int)c - ARRAYBASE;
8548 return((x < 0 || x > 'z' - ARRAYBASE || *(s+3)) ? -1 : x);
8551 /* A R R A Y B O U N D S -- Parse array segment notation \&a[n:m] */
8554 Call with s = array reference, plus two pointers to ints.
8555 Returns -1 on error, or array index, with the two ints set as follows:
8559 The array need not be declared -- this routine is just for parsing.
8562 arraybounds(s,lo,hi) char * s; int * lo, * hi; {
8563 int i, x, y, range[2];
8564 char buf[256], * p, * q;
8567 *lo = -1; /* Default bounds */
8570 if (!s) s = ""; /* Defense de null args */
8574 x = xarray(s); /* Check basic structure */
8575 debug(F111,"arraybounds xarray",s,x);
8577 if (x < 0) /* Not OK, fail. */
8579 range[0] = -1; /* It's OK -- get contents */
8580 range[1] = -1; /* of subscript brackets */
8581 makestr(&tmp,s); /* Make a pokeable copy */
8584 for (p = s, q = NULL; *p; p++) { /* First find the brackets */
8587 } else if (*p == ']')
8590 if (q && *p == ']') { /* If we have brackets... */
8592 for (i = 0; i < 2 && !quitnow; i++) { /* Loop thru their contents */
8593 for (p = q; *p; p++) {
8594 if ((i == 0 && *p == ':') || *p == ']') {
8598 if (*q) { /* We have something */
8599 y = 255; /* Expand variables, etc. */
8602 s = evalx(buf); /* Evaluate it arithmetically */
8604 ckstrncpy(buf,s,256);
8605 if (!chknum(buf)) { /* Did we get a number? */
8606 makestr(&tmp,NULL); /* No, fail. */
8609 q = (i == 0) ? p+1 : NULL; /* Point to next if any */
8610 range[i] = atoi(buf); /* Set this one */
8617 makestr(&tmp,NULL); /* Free temporary poked string */
8618 *lo = range[0]; /* Return what we got */
8620 debug(F101,"arraybounds lo","",*lo);
8621 debug(F101,"arraybounds hi","",*hi);
8625 /* A R R A Y N A M -- Parse an array name */
8628 Call with pointer to string that starts with the array reference.
8629 String may begin with either \& or just &.
8631 Returns letter ID (always lowercase) in argument c,
8632 which can also be accent grave (` = 96; '@' is converted to grave);
8633 Dimension or subscript in argument n;
8634 IMPORTANT: These arguments must be provided by the caller as addresses
8635 of ints (not chars), for example:
8638 On failure, returns a negative number, with args n and c set to zero.
8641 arraynam(ss,c,n) char *ss; int *c; int *n; {
8644 char *s, *p, *sx, *vnp;
8645 /* On stack to allow for recursive calls... */
8646 char vnbuf[ARRAYREFLEN+1]; /* Entire array reference */
8647 char ssbuf[ARRAYREFLEN+1]; /* Subscript in "plain text" */
8648 char sxbuf[16]; /* Evaluated subscript */
8650 *c = *n = 0; /* Initialize return values */
8652 for (pp = 0,i = 0; i < len; i++) { /* Check length */
8655 } else if (ss[i] == ']') {
8660 if (i > ARRAYREFLEN) {
8661 printf("?Array reference too long - %s\n",ss);
8664 ckstrncpy(vnbuf,ss,ARRAYREFLEN);
8666 if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
8668 printf("?Not an array - %s\n",vnbuf);
8671 x = *(vnp + 1); /* Fold case of array name */
8673 /* We don't use isupper & tolower here on purpose because these */
8674 /* would produce undesired effects with accented letters. */
8675 if (x > 63 && x < 91) x = *(vnp + 1) = (char) (x + 32);
8676 if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
8678 printf("?Invalid format for array name - %s\n",vnbuf);
8683 *c = x; /* Return the array name */
8684 s = vnp+3; /* Get dimension */
8686 pp = 1; /* Bracket counter */
8687 for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
8688 if (*s == '[') pp++;
8689 if (*s == ']' && --pp == 0) break;
8693 printf("?No closing bracket on array dimension - %s\n",vnbuf);
8696 p--; /* Trim whitespace from end */
8697 while (*p == SP || *p == HT)
8700 *p = NUL; /* Terminate subscript with null */
8701 p = ssbuf; /* Point to beginning of subscript */
8702 while (*p == SP || *p == HT) /* Trim whitespace from beginning */
8704 sx = sxbuf; /* Where to put expanded subscript */
8706 zzstring(p,&sx,&y); /* Convert variables, etc. */
8708 while (*sx == SP) sx++;
8709 debug(F110,"arraynam sx","",sx);
8710 if (!*sx) { /* Empty brackets... */
8711 *n = -17; /* (Secret code :-) */
8714 p = evala(sx); /* Run it thru \fneval()... */
8715 if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
8717 if (!chknum(sxbuf)) { /* Make sure it's all digits */
8719 printf("?Array dimension or subscript missing or not numeric\n");
8724 if ((y = atoi(sxbuf)) < 0) {
8725 if (cmflgs == 0) printf("\n");
8727 printf("?Array dimension or subscript not positive or zero\n");
8732 *n = y; /* Return the subscript or dimension */
8737 chkarray(a,i) int a, i; { /* Check if array is declared */
8738 int x; /* and if subscript is in range */
8739 if (a == 64) a = 96; /* Convert atsign to grave accent */
8740 x = a - ARRAYBASE; /* Values must be in range 95-122 */
8742 if (x == 0 && maclvl < 0) /* Macro arg vector but no macro */
8744 #endif /* COMMENT */
8745 if (x < 0 || x > 'z' - ARRAYBASE) /* Not in range */
8747 if (a_ptr[x] == NULL) return(-1); /* Not declared */
8748 if (i > a_dim[x]) return(-2); /* Declared but out of range. */
8749 return(a_dim[x]); /* All ok, return dimension */
8752 #ifdef COMMENT /* This isn't used. */
8754 arrayval(a,i) int a, i; { /* Return value of \&a[i] */
8755 int x; char **p; /* (possibly NULL) */
8756 if (a == 64) a = 96; /* Convert atsign to grave accent */
8757 x = a - ARRAYBASE; /* Values must be in range 95-122 */
8758 if (x < 0 || x > 27) return(NULL); /* Not in range */
8759 if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
8761 if (i > a_dim[x]) /* Subscript out of range. */
8763 return(p[i]); /* All ok, return pointer to value. */
8765 #endif /* COMMENT */
8768 pusharray() is called when an array name is included in a LOCAL statement.
8769 It moves the pointers from the global definition to the stack, and removes
8770 the global definition. Later, if the same array is declared in the local
8771 context, it occupies the global definition in the normal way. But when
8772 popclvl() is called, it replaces the global definition with the one saved
8773 here. The "secret code" is used to indicate to popclv() that it should
8774 remove the global array when popping through this level -- otherwise if a
8775 local array were declared that had no counterpart at any higher level, it
8776 would never be deleted. This allows Algol-like inheritance to work both
8777 on the way down and on the way back up.
8780 pusharray(x,z) int x, z; {
8782 debug(F000,"pusharray x","",x);
8783 debug(F101,"pusharray z","",z);
8785 debug(F101,"pusharray y","",y);
8786 x -= ARRAYBASE; /* Convert name letter to index. */
8787 if (x < 0 || x > 27)
8790 aa_ptr[cmdlvl][x] = (char **) NULL;
8791 aa_dim[cmdlvl][x] = -23; /* Secret code (see popclvl()) */
8793 aa_ptr[cmdlvl][x] = a_ptr[x];
8794 aa_dim[cmdlvl][x] = y;
8796 a_ptr[x] = (char **) NULL;
8801 /* P A R S E V A R -- Parse a variable name or array reference. */
8804 s = pointer to candidate variable name or array reference.
8805 *c = address of integer in which to return variable ID.
8806 *i = address of integer in which to return array subscript.
8808 -2: syntax error in variable name or array reference.
8809 1: successful parse of a simple variable, with ID in c.
8810 2: successful parse of an array reference, w/ID in c and subscript in i.
8813 parsevar(s,c,i) char *s; int *c, *i; {
8818 if (*s == CMDQ) s++; /* Point after backslash */
8820 if (*s != '%' && *s != '&') { /* Make sure it's % or & */
8821 printf("?Not a variable name - %s\n",p);
8824 if ((int)strlen(s) < 2) {
8825 printf("?Incomplete variable name - %s\n",p);
8828 if (*s == '%' && *(s+2) != '\0') {
8829 printf("?Only one character after '%%' in variable name, please\n");
8832 if (*s == '&' && *(s+2) != '[') {
8833 printf("?Array subscript expected - %s\n",p);
8836 if (*s == '%') { /* Simple variable. */
8837 y = *(s+1); /* Get variable ID letter/char */
8838 if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
8839 *c = y; /* Set the return values. */
8840 *i = -1; /* No array subscript. */
8841 return(1); /* Return 1 = simple variable */
8843 if (*s == '&') { /* Array reference. */
8844 y = arraynam(s,&x,&z); /* Go parse it. */
8845 debug(F101,"parsevar arraynam","",y);
8848 return(pusharray(x,z));
8850 printf("?Invalid array reference - %s\n",p);
8853 if (chkarray(x,z) < 0) { /* Check if declared, etc. */
8854 printf("?Array not declared or subscript out of range\n");
8857 *c = x; /* Return array letter */
8858 *i = z; /* and subscript. */
8861 return(-2); /* None of the above. */
8867 /* Get the numeric value of a variable */
8869 Call with pointer to variable name, pointer to int for return value.
8871 0 on success with second arg containing the value.
8872 -1 on failure (bad variable syntax, variable not defined or not numeric).
8875 varval(s,v) char *s; int *v; {
8876 char valbuf[VALN+1]; /* s is pointer to variable name */
8881 if (*s != CMDQ) { /* Handle macro names too */
8882 ckmakmsg(name,256,"\\m(",s,")",NULL);
8885 p = valbuf; /* Expand variable into valbuf. */
8887 if (zzstring(s,&p,&y) < 0) return(-1);
8888 p = valbuf; /* Make sure value is numeric */
8889 if (!*p) { /* Be nice -- let an undefined */
8890 valbuf[0] = '0'; /* variable be treated as 0. */
8893 if (chknum(p)) { /* Convert numeric string to int */
8894 *v = atoi(p); /* OK */
8895 } else { /* Not OK */
8896 p = evala(p); /* Maybe it's an expression */
8897 if (!chknum(p)) /* Did it evaluate? */
8898 return(-1); /* No, failure. */
8900 *v = atoi(p); /* success */
8905 /* Increment or decrement a variable */
8906 /* Returns -1 on failure, 0 on success */
8909 incvar(s,x,z) char *s; int x; int z; { /* Increment a numeric variable */
8910 int n; /* s is pointer to variable name */
8911 /* x is amount to increment by */
8912 /* z != 0 means add */
8913 /* z = 0 means subtract */
8914 if (varval(s,&n) < 0) /* Convert numeric string to int */
8916 if (z) /* Increment it by the given amount */
8918 else /* or decrement as requested. */
8920 addmac(s,ckitoa(n)); /* Replace old variable */
8924 /* D O D O -- Do a macro */
8927 Call with x = macro table index, s = pointer to arguments.
8928 Returns 0 on failure, 1 on success.
8932 dodo(x,s,flags) int x; char *s; int flags; {
8934 extern int tra_asg, tra_cmd; int tra_tmp;
8938 int term_io_sav = term_io;
8940 #endif /* NOLOCAL */
8942 if (x < 0) /* It can happen! */
8947 if (++maclvl >= MACLEVEL) { /* Make sure we have storage */
8948 debug(F101,"dodo maclvl too deep","",maclvl);
8950 printf("Macros nested too deeply\n");
8953 macp[maclvl] = mactab[x].mval; /* Point to the macro body */
8954 macx[maclvl] = mactab[x].mval; /* Remember where the beginning is */
8957 makestr(&(m_line[maclvl]),s); /* Entire arg string for "\%*" */
8958 #endif /* COMMENT */
8960 cmdlvl++; /* Entering a new command level */
8961 if (cmdlvl >= CMDSTKL) { /* Too many macros + TAKE files? */
8962 debug(F101,"dodo cmdlvl too deep","",cmdlvl);
8964 printf("?TAKE files and DO commands nested too deeply\n");
8969 debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
8970 debug(F010,"CMD ->",s,0);
8975 conres(); /* So Ctrl-C, etc, will work. */
8979 term_io = 0; /* Disable terminal emulator I/O */
8981 #endif /* NOLOCAL */
8984 count[cmdlvl] = count[cmdlvl-1]; /* Inherit COUNT from previous level */
8985 intime[cmdlvl] = intime[cmdlvl-1]; /* Inherit previous INPUT TIMEOUT */
8986 inpcas[cmdlvl] = inpcas[cmdlvl-1]; /* and INPUT CASE */
8987 takerr[cmdlvl] = takerr[cmdlvl-1]; /* and TAKE ERROR */
8988 merror[cmdlvl] = merror[cmdlvl-1]; /* and MACRO ERROR */
8989 xquiet[cmdlvl] = quiet;
8991 cmdstk[cmdlvl].src = CMD_MD; /* Say we're in a macro */
8992 cmdstk[cmdlvl].lvl = maclvl; /* and remember the macro level */
8993 cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
8995 /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
8997 if (!(flags & CF_IMAC) && mrval[maclvl]) {
8998 free(mrval[maclvl]);
8999 mrval[maclvl] = NULL;
9002 /* Clear old %0..%9 arguments */
9004 addmac("%0",mactab[x].kwd); /* Define %0 = name of macro */
9005 makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
9009 for (y = 1; y < 10; y++) { /* Clear args %1..%9 */
9010 if (m_arg[maclvl][y]) { /* Don't call delmac() unless */
9011 varnam[1] = (char) (y + '0'); /* we have to... */
9017 /* Assign the new args one word per arg, allowing braces to group words */
9019 xwords(s,MAXARGLIST,NULL,0);
9023 term_io = term_io_sav;
9025 #endif /* NOLOCAL */
9027 printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
9031 /* Insert "literal" quote around each comma-separated command to prevent */
9032 /* its premature expansion. Only do this if object command is surrounded */
9035 static char* flit = "\\flit(";
9038 litcmd(src,dest,n) char **src, **dest; int n; {
9040 char c, *s, *lp, *ss;
9045 debug(F010,"litcmd",s,0);
9047 while (*s == SP) s++; /* Strip extra leading spaces */
9049 if (*s == '{') { /* Starts with brace */
9050 pp = 0; /* Paren counter */
9051 bc = 1; /* Count leading brace */
9052 *lp++ = *s++; /* Copy it */
9053 if (--n < 1) return(-1); /* Check space */
9054 while (*s == SP) s++; /* Strip interior leading spaces */
9055 ss = flit; /* Point to "\flit(" */
9056 while ((*lp++ = *ss++)) /* Copy it */
9057 if (--n < 1) /* and check space */
9059 lp--; /* Back up over null */
9061 while (*s) { /* Go thru rest of text */
9063 if (c == '{') bc++; /* Count brackets */
9064 if (c == '(') pp++; /* and parens */
9065 if (c == ')') { /* Right parenthesis. */
9066 pp--; /* Count it. */
9067 if (pp < 0) { /* An unbalanced right paren... */
9070 The problem here is that "\{" appears to be a quoted brace and therefore
9071 isn't counted; then the "}" matches an earlier opening brace, causing
9072 (e.g.) truncation of macros by getncm().
9074 if (n < 5) /* Out of space in dest buffer? */
9075 return(-1); /* If so, give up. */
9076 *lp++ = CMDQ; /* Must be quoted to prevent */
9077 *lp++ = '}'; /* premature termination of */
9078 *lp++ = '4'; /* \flit(...) */
9083 /* Here we rely on the fact the \nnn never takes more than 3 digits */
9084 if (n < 4) /* Out of space in dest buffer? */
9085 return(-1); /* If so, give up. */
9086 *lp++ = CMDQ; /* Must be quoted to prevent */
9087 *lp++ = '0'; /* premature termination of */
9088 *lp++ = '4'; /* \flit(...) */
9091 #endif /* COMMENT */
9092 pp++; /* Uncount it. */
9097 if (c == '}') { /* Closing brace. */
9098 if (--bc == 0) { /* Final one? */
9099 *lp++ = ')'; /* Add closing paren for "\flit()" */
9100 if (--n < 1) return(-1);
9102 if (--n < 1) return(-1);
9107 *lp++ = c; /* General case */
9108 if (--n < 1) return(-1);
9112 } else { /* No brackets around, */
9113 while ((*lp++ = *s++)) /* just copy. */
9118 *src = s; /* Return updated source */
9119 *dest = lp; /* and destination pointers */
9120 if (bc) /* Fail if braces unbalanced */
9122 else /* Otherwise succeed. */
9127 /* Functions moved here from ckuusr.c to even out the module sizes... */
9130 Breaks up string s -- IN PLACE! -- into a list of up to max words.
9131 Pointers to each word go into the array list[].
9132 max is the maximum number of words (pointers).
9133 If list is NULL, then they are added to the macro table.
9134 flag = 0 means the last field is to be one word, like all the other fields,
9135 so anything after it is discarded.
9136 flag = 1 means the last field extends to the end of the string, even if
9137 there are lots of words left, so the last field contains the
9138 remainder of the string.
9141 xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
9143 int b, i, k, q, y, z;
9146 macro = (list == NULL);
9147 debug(F010,"xwords",s,0);
9151 printf("XWORDS string=%s\n",s);
9152 printf("XWORDS max=%d\n",max);
9153 #endif /* XWORDSDEBUG */
9154 p = s; /* Pointer to beginning of string */
9155 q = 0; /* Flag for doublequote removal */
9156 b = 0; /* Flag for outer brace removal */
9157 k = 0; /* Flag for in-word */
9158 y = 0; /* Brace nesting level */
9159 z = 0; /* "Word" counter, 0 thru max */
9162 for (i = 0; i <= max; i++) /* Initialize pointers */
9167 while (1) { /* Go thru word list */
9168 if (!s || (*s == '\0')) { /* No more characters? */
9169 if (k != 0) { /* Was I in a word? */
9170 if (z == max) break; /* Yes, only go up to max. */
9171 z++; /* Count this word. */
9173 printf("1 z++ = %d\n", z);
9174 #endif /* XWORDSDEBUG */
9176 if (macro) { /* Doing macro args */
9178 varnam[1] = (char) (z + '0'); /* Assign last arg */
9186 #endif /* COMMENT */
9187 makestr(&(m_xarg[maclvl][z]),p);
9189 } else { /* Not doing macro args */
9191 list[z] = p; /* Assign pointer. */
9193 printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
9194 #endif /* XWORDSDEBUG */
9198 break; /* And get out. */
9199 } else break; /* Was not in a word */
9201 if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
9204 } else if (q == 0 && *s == '{') { /* An opening brace */
9205 if (k == 0 && y == 0) { /* If leading brace */
9206 p = s+1; /* point past it */
9207 b = 1; /* and flag that we did this */
9209 k = 1; /* Flag that we're in a word */
9210 y++; /* Count the brace. */
9211 } else if (q == 0 && *s == '}') { /* A closing brace. */
9212 y--; /* Count it. */
9213 if (y <= 0 && b != 0) { /* If it matches the leading brace */
9216 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
9217 *s = SP; /* change it to a space */
9218 b = 0; /* and we're not in braces any more */
9221 #ifdef DOUBLEQUOTING
9222 /* Opening doublequote */
9223 } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
9225 p = s+1; /* point past it */
9226 q = 1; /* and flag that we did this */
9227 k = 1; /* Flag that we're in a word */
9228 /* Closing double quote */
9229 } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
9232 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
9234 *s = SP; /* change it to a space */
9235 q = 0; /* and we're not in quotes any more */
9237 #endif /* DOUBLEQUOTING */
9239 } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
9240 if (k == 0) { /* If we weren't in a word before, */
9241 p = s; /* Mark the beginning */
9242 if (flag && z == max) { /* Want last word to be remainder? */
9245 printf("1 z++ = %d\n", z);
9246 #endif /* XWORDSDEBUG */
9247 list[z] = p; /* Yes, point to it */
9249 printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
9250 #endif /* XWORDSDEBUG */
9251 break; /* and quit */
9253 k = 1; /* Set in-word flag */
9256 /* If we're not inside a braced quantity, and we are in a word, and */
9257 /* we have hit whitespace, then we have a word. */
9258 if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
9259 if (!flag || z < max) /* if we don't want to keep rest */
9260 *s = '\0'; /* terminate the arg with null */
9261 k = 0; /* say we're not in a word any more */
9262 y = 0; /* start braces off clean again */
9263 if (z == max) break; /* Only go up to max. */
9264 z++; /* count this arg */
9266 printf("1 z++ = %d\n", z);
9267 #endif /* XWORDSDEBUG */
9272 varnam[1] = (char) (z + '0'); /* compute its name */
9273 addmac(varnam,p); /* add it to the macro table */
9280 #endif /* COMMENT */
9281 makestr(&(m_xarg[maclvl][z]),p);
9287 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
9288 #endif /* XWORDSDEBUG */
9294 s++; /* Point past this character */
9296 if ((z == 0) && (y > 1)) { /* Extra closing brace(s) at end */
9301 varnam[1] = z + '0'; /* compute its name */
9302 addmac(varnam,p); /* Add rest of line to last arg */
9309 #endif /* COMMENT */
9310 makestr(&(m_xarg[maclvl][z]),p);
9316 printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
9317 #endif /* XWORDSDEBUG */
9323 if (macro) { /* Macro */
9325 a_dim[0] = z; /* Array dimension is one less */
9326 topargc = z + 1; /* than \v(argc) */
9327 debug(F111,"a_dim[0]","D",a_dim[0]);
9329 macargc[maclvl] = z + 1; /* Set \v(argc) variable */
9330 n_xarg[maclvl] = z + 1; /* This is the actual number */
9331 a_ptr[0] = m_xarg[maclvl]; /* Point \&_[] at the args */
9332 a_dim[0] = z; /* And give it this dimension */
9333 debug(F111,"a_dim[0]","E",a_dim[0]);
9342 /* D O S H I F T -- Do the SHIFT Command; shift macro args left by n */
9344 /* Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
9347 doshift(n) int n; { /* n = shift count */
9349 char /* *s, *m, */ buf[6]; /* Buffer to build scalar names */
9353 debug(F101,"SHIFT count","",n);
9354 debug(F101,"SHIFT topargc","",topargc);
9356 if (n < 1) /* Stay in range */
9357 return(n == 0 ? 1 : 0);
9360 top = (level < 0) ? topargc : macargc[level];
9367 debug(F101,"SHIFT count 2","",n);
9368 debug(F101,"SHIFT level","",level);
9370 debug(F101,"SHIFT macargc[level]","",macargc[level]);
9374 buf[0] = '\\'; /* Initialize name template */
9379 for (i = 1; i <= n; i++) { /* Free shifted-over args */
9381 makestr(&(toparg[i]),NULL);
9383 makestr(&(m_xarg[level][i]),NULL);
9385 if (i < 10) { /* Is this necessary? */
9386 buf[2] = (char)(i+'0');
9390 for (i = 1; i <= top-n; i++) { /* Shift remaining args */
9393 toparg[i] = toparg[i+n]; /* Full vector */
9395 makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
9396 #endif /* COMMENT */
9397 if (i < 10) /* Scalars... */
9398 makestr(&(g_var[i+'0']),toparg[i+n]);
9401 m_xarg[level][i] = m_xarg[level][i+n];
9403 makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
9404 #endif /* COMMENT */
9406 buf[2] = (char)(i+'0');
9407 debug(F010,"SHIFT buf",buf,0);
9408 addmac(buf,m_xarg[level][i+n]);
9412 for (i = top-n; i <= top; i++) { /* Clear n args from the end */
9417 makestr(&(toparg[i]),NULL);
9418 #endif /* COMMENt */
9420 makestr(&(g_var[i+'0']),NULL);
9423 m_xarg[level][i] = NULL;
9425 makestr(&(m_xarg[level][i]),NULL);
9426 #endif /* COMMENt */
9428 buf[2] = (char)(i+'0');
9433 if (level > -1) { /* Macro args */
9434 macargc[level] -= n; /* Adjust count */
9435 n_xarg[maclvl] = macargc[level]; /* Here too */
9436 a_dim[0] = macargc[level] - 1; /* Adjust array dimension */
9437 debug(F111,"a_dim[0]","F",a_dim[0]);
9438 zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
9440 makestr(&(m_line[level]),tmpbuf);
9441 #endif /* COMMENT */
9442 } else { /* Ditto for top level */
9444 a_dim[0] = topargc - 1;
9445 debug(F111,"a_dim[0]","G",a_dim[0]);
9446 zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
9448 makestr(&topline,tmpbuf);
9449 #endif /* COMMENT */
9456 docd(cx) int cx; { /* Do the CD command */
9458 extern int server, srvcdmsg, cdactive;
9459 extern char * cdmsgfile[], * ckcdpath;
9466 #endif /* IKSDCONF */
9470 if ((x = cmcfm()) < 0)
9474 if (!zchdir(prevdir)) {
9478 makestr(&prevdir,s);
9483 #endif /* NOFRILLS */
9493 #endif /* datageneral */
9495 ckstrncpy(line,s,LINBUFSIZ);
9499 if (cx == XXKCD) { /* Symbolic (Kermit) CD */
9502 x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
9505 x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
9507 printf("?Lookup error\n"); /* shouldn't happen */
9510 if ((x = cmcfm()) < 0)
9512 if (k == VN_HOME) { /* HOME: allow SET HOME to override */
9513 ckstrncpy(line,homepath(),LINBUFSIZ);
9514 } else { /* Other symbolic name */
9515 /* Convert to variable syntax */
9516 ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
9517 p = line; /* Expand the variable */
9519 zzstring(tmpbuf,&p,&n);
9520 if (!line[0]) { /* Fail if variable not defined */
9521 printf("?%s - not defined\n",tmpbuf);
9522 return(success = 0);
9525 s = line; /* All OK, go try to CD... */
9532 if ((x = cmdir("Name of local directory, or carriage return",
9541 if ((x = cmdirp("Name of PC disk and/or directory,\n\
9542 or press the Enter key for the default",
9545 ckcdpath ? ckcdpath : getenv("CDPATH"),
9552 x = ckstrncpy(temp,homepath(),32);
9553 if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
9554 if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
9555 or press the Return key for the desktop on the boot disk",
9556 temp,&s, xxstring)) < 0 )
9559 if ((x = cmdirp("Carriage return for home directory,\n\
9560 or name of directory on this computer",
9562 "SYS$LOGIN", /* With no colon */
9564 homepath(), /* In VMS this is "SYS$LOGIN:" */
9567 ckcdpath ? ckcdpath : getenv("CDPATH"),
9574 ckstrncpy(line,s,LINBUFSIZ); /* Make a safe copy */
9577 if (ckmatch("*.DIR;1$",s,0,0))
9578 if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
9581 debug(F110,"docd",s,0);
9583 if ((x = cmcfm()) < 0) /* Get confirmation */
9590 x = strlen(line); /* homdir ends in colon, */
9591 if (x > 1 && line[x-1] == ':') /* and "dir" doesn't like that... */
9593 #endif /* datageneral */
9599 if (*s != ':') { /* If it failed, */
9600 char *p; /* supply leading colon */
9601 int len = (int)strlen(s) + 2;
9602 p = malloc(len); /* and try again... */
9604 strcpy(p,":"); /* safe */
9605 strcat(p,s); /* safe */
9621 printf("?Off limits: \"%s\"\n",s);
9630 makestr(&prevdir,p);
9631 debug(F111,"docd","srvcdmsg",srvcdmsg);
9634 && !(inserver && !iksdcf)
9635 #endif /* IKSDCONF */
9638 for (i = 0; i < 8; i++) {
9639 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
9640 if (zchki(cdmsgfile[i]) > -1) {
9642 dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
9649 if (!x && srvcdmsg && !server
9651 && !(inserver && !iksdcf)
9652 #endif /* IKSDCONF */
9653 && !quiet && !xcmdsrc)
9654 printf("%s\n", zgtdir());
9659 static int on_ctrlc = 0;
9662 fixcmd() { /* Fix command parser after interruption */
9665 if (nmac) { /* Any macros defined? */
9667 char * s = "on_ctrlc"; /* Name of Ctrl-C handling macro */
9668 k = mlook(mactab,s,nmac); /* Look it up. */
9669 if (k >= 0) { /* If found, */
9670 if (on_ctrlc++ == 0) { /* if not already executing, */
9671 if (dodo(k,"",0) > -1) /* set it up, */
9672 parser(1); /* execute it, */
9674 delmac(s,1); /* and undefine it. */
9678 #endif /* NOONCTRLC */
9680 dostop(); /* Back to top level (also calls conint()). */
9681 bgchk(); /* Check background status */
9682 if (*psave) { /* If old prompt saved, */
9683 cmsetp(psave); /* restore it. */
9686 success = 0; /* Tell parser last command failed */
9689 #ifndef NOSHOW /* SHOW FEATURES */
9691 Note, presently optlist[] index overflow is not checked.
9692 There is plenty of room (less than 360 entries for 1000 slots).
9693 When space starts to get tight, check for noptlist >= NOPTLIST
9694 every time noptlist is incremented.
9696 #define NOPTLIST 1024
9697 static int noptlist = 0;
9698 static char * optlist[NOPTLIST+1];
9699 static int hpos = 0;
9702 prtopt(lines,s) int * lines; char *s; { /* Print an option */
9703 int y, i; /* Does word wrap. */
9706 if (!*s) { /* Empty argument */
9707 if (hpos > 0) { /* means to end this line. */
9708 printf("\n"); /* Not needed if already at */
9709 if (++i > (cmd_rows - 3)) { /* beginning of new line. */
9716 printf("\n"); /* And then make a blank line */
9717 if (++i > (cmd_rows - 3)) {
9727 y = (int)strlen(s) + 1;
9729 debug(F101,"prtopt hpos","",hpos);
9730 debug(F101,"prtopt cmd_cols","",cmd_cols);
9734 hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
9736 hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
9740 if (++i > (cmd_rows - 3)) {
9759 for (i = 0; i < NOPTLIST; i++)
9764 makestr(&(optlist[noptlist++]),"MPW");
9770 makestr(&(optlist[noptlist++]),"THINK_C");
9771 #endif /* THINK_C */
9775 makestr(&(optlist[noptlist++]),"__386__");
9776 #endif /* __386__ */
9778 /* Memory models... */
9781 makestr(&(optlist[noptlist++]),"__FLAT__");
9782 #endif /* __FLAT__ */
9784 makestr(&(optlist[noptlist++]),"__SMALL__");
9785 #endif /* __SMALL__ */
9787 makestr(&(optlist[noptlist++]),"__MEDIUM__");
9788 #endif /* __MEDIUM__ */
9790 makestr(&(optlist[noptlist++]),"__COMPACT__");
9791 #endif /* __COMPACT__ */
9793 makestr(&(optlist[noptlist++]),"__LARGE__");
9794 #endif /* __LARGE__ */
9798 makestr(&(optlist[noptlist++]),"IFDEBUG");
9800 makestr(&(optlist[noptlist++]),"DEBUG");
9801 #endif /* IFDEBUG */
9804 makestr(&(optlist[noptlist++]),"TLOG");
9807 makestr(&(optlist[noptlist++]),"BIGBUFOK");
9808 #endif /* BIGBUFOK */
9810 sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
9811 makestr(&(optlist[noptlist++]),line);
9812 #endif /* INPBUFSIZE */
9814 sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
9815 makestr(&(optlist[noptlist++]),line);
9816 #endif /* INBUFSIZE */
9818 sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
9819 makestr(&(optlist[noptlist++]),line);
9820 #endif /* OBUFSIZE */
9822 sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
9823 makestr(&(optlist[noptlist++]),line);
9824 #endif /* FD_SETSIZE */
9826 makestr(&(optlist[noptlist++]),"XFRCAN");
9829 makestr(&(optlist[noptlist++]),"XPRINT");
9832 makestr(&(optlist[noptlist++]),"PIPESEND");
9833 #endif /* PIPESEND */
9835 makestr(&(optlist[noptlist++]),"CK_SPEED");
9836 #endif /* CK_SPEED */
9838 makestr(&(optlist[noptlist++]),"CK_FAST");
9839 #endif /* CK_FAST */
9841 makestr(&(optlist[noptlist++]),"CK_APC");
9844 makestr(&(optlist[noptlist++]),"CK_AUTODL");
9845 #endif /* CK_AUTODL */
9847 makestr(&(optlist[noptlist++]),"CK_MKDIR");
9848 #endif /* CK_MKDIR */
9850 makestr(&(optlist[noptlist++]),"NOMKDIR");
9851 #endif /* NOMKDIR */
9853 makestr(&(optlist[noptlist++]),"CK_LABELED");
9854 #endif /* CK_LABELED */
9856 makestr(&(optlist[noptlist++]),"NODIAL");
9859 makestr(&(optlist[noptlist++]),"MINIDIAL");
9860 #endif /* MINIDIAL */
9862 makestr(&(optlist[noptlist++]),"WHATAMI");
9863 #endif /* WHATAMI */
9865 makestr(&(optlist[noptlist++]),"DYNAMIC");
9866 #endif /* IFDEBUG */
9868 sprintf(line,"CMDDEP=%d",CMDDEP); /* SAFE */
9869 makestr(&(optlist[noptlist++]),line);
9873 sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
9874 makestr(&(optlist[noptlist++]),line);
9875 #endif /* MAXPATHLEN */
9878 sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
9879 makestr(&(optlist[noptlist++]),line);
9880 #endif /* DEVNAMLEN */
9883 makestr(&(optlist[noptlist++]),"NO_PARAM_H");
9884 #endif /* NO_PARAM_H */
9887 makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
9888 #endif /* INCL_PARAM_H */
9890 sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
9891 makestr(&(optlist[noptlist++]),line);
9893 sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
9894 makestr(&(optlist[noptlist++]),line);
9896 sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
9897 makestr(&(optlist[noptlist++]),line);
9900 sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
9901 makestr(&(optlist[noptlist++]),line);
9902 #endif /* OPEN_MAX */
9904 #ifdef _POSIX_OPEN_MAX
9905 sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
9906 makestr(&(optlist[noptlist++]),line);
9907 #endif /* _POSIX_OPEN_MAX */
9911 extern int z_maxchan;
9913 extern int ckmaxfiles;
9914 sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
9915 makestr(&(optlist[noptlist++]),line);
9917 sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
9918 makestr(&(optlist[noptlist++]),line);
9920 #endif /* CKCHANNELIO */
9923 sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
9924 makestr(&(optlist[noptlist++]),line);
9925 #endif /* FOPEN_MAX */
9928 sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
9929 makestr(&(optlist[noptlist++]),line);
9930 #endif /* MAXGETPATH */
9933 sprintf(line,"CMDBL=%d",CMDBL); /* SAFE */
9934 makestr(&(optlist[noptlist++]),line);
9938 sprintf(line,"VNAML=%d",VNAML); /* SAFE */
9939 makestr(&(optlist[noptlist++]),line);
9943 sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
9944 makestr(&(optlist[noptlist++]),line);
9945 #endif /* ARRAYREFLEN */
9948 sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
9949 makestr(&(optlist[noptlist++]),line);
9950 #endif /* UIDBUFLEN */
9953 sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
9954 makestr(&(optlist[noptlist++]),line);
9955 #endif /* FORDEPTH */
9958 sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
9959 makestr(&(optlist[noptlist++]),line);
9960 #endif /* MAXTAKE */
9963 sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
9964 makestr(&(optlist[noptlist++]),line);
9965 #endif /* MACLEVEL */
9968 sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
9969 makestr(&(optlist[noptlist++]),line);
9970 #endif /* MAC_MAX */
9973 sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
9974 makestr(&(optlist[noptlist++]),line);
9975 #endif /* MINPUTMAX */
9978 sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
9979 makestr(&(optlist[noptlist++]),line);
9982 makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
9987 sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
9988 makestr(&(optlist[noptlist++]),line);
9989 #endif /* MSENDMAX */
9992 sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
9993 makestr(&(optlist[noptlist++]),line);
9994 #endif /* MAXDDIR */
9997 sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
9998 makestr(&(optlist[noptlist++]),line);
9999 #endif /* MAXDNUMS */
10002 makestr(&(optlist[noptlist++]),"UNIX");
10005 makestr(&(optlist[noptlist++]),"VMS");
10007 sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
10008 makestr(&(optlist[noptlist++]),line);
10009 #endif /* __VMS_VER */
10011 makestr(&(optlist[noptlist++]),"VMSV70");
10012 #endif /* VMSV70 */
10015 makestr(&(optlist[noptlist++]),"OLD_VMS");
10016 #endif /* OLD_VMS */
10018 makestr(&(optlist[noptlist++]),"vms");
10021 makestr(&(optlist[noptlist++]),"VMSV60");
10022 #endif /* VMSV60 */
10024 makestr(&(optlist[noptlist++]),"VMSV80");
10025 #endif /* VMSV80 */
10027 makestr(&(optlist[noptlist++]),"VMSSHARE");
10028 #endif /* VMSSHARE */
10030 makestr(&(optlist[noptlist++]),"NOVMSSHARE");
10031 #endif /* NOVMSSHARE */
10033 makestr(&(optlist[noptlist++]),"datageneral");
10034 #endif /* datageneral */
10036 makestr(&(optlist[noptlist++]),"apollo");
10037 #endif /* apollo */
10039 makestr(&(optlist[noptlist++]),"aegis");
10042 makestr(&(optlist[noptlist++]),"A986");
10045 makestr(&(optlist[noptlist++]),"AMIGA");
10048 makestr(&(optlist[noptlist++]),"CONVEX9");
10049 #endif /* CONVEX9 */
10051 makestr(&(optlist[noptlist++]),"CONVEX10");
10052 #endif /* CONVEX9 */
10054 makestr(&(optlist[noptlist++]),"MAC");
10057 makestr(&(optlist[noptlist++]),"AUX");
10060 makestr(&(optlist[noptlist++]),"OS2");
10062 makestr(&(optlist[noptlist++]),"NT");
10066 makestr(&(optlist[noptlist++]),"OS9");
10069 makestr(&(optlist[noptlist++]),"MSDOS");
10072 makestr(&(optlist[noptlist++]),"DIRENT");
10073 #endif /* DIRENT */
10075 makestr(&(optlist[noptlist++]),"SDIRENT");
10076 #endif /* SDIRENT */
10078 makestr(&(optlist[noptlist++]),"NDIR");
10081 makestr(&(optlist[noptlist++]),"XNDIR");
10084 makestr(&(optlist[noptlist++]),"SAVEDUID");
10085 #endif /* SAVEDUID */
10087 makestr(&(optlist[noptlist++]),"RENAME");
10088 #endif /* RENAME */
10090 makestr(&(optlist[noptlist++]),"CK_TMPDIR");
10091 #endif /* CK_TMPDIR */
10093 makestr(&(optlist[noptlist++]),"NOCCTRAP");
10094 #endif /* NOCCTRAP */
10096 makestr(&(optlist[noptlist++]),"NOCOTFMC");
10097 #endif /* NOCOTFMC */
10099 makestr(&(optlist[noptlist++]),"NOFRILLS");
10100 #endif /* NOFRILLS */
10102 makestr(&(optlist[noptlist++]),"PARSENSE");
10103 #endif /* PARSENSE */
10105 makestr(&(optlist[noptlist++]),"TIMEH");
10108 makestr(&(optlist[noptlist++]),"TIMEH");
10109 #endif /* NOTIMEH */
10112 makestr(&(optlist[noptlist++]),"SYSTIMEH");
10113 #endif /* SYSTIMEH */
10115 makestr(&(optlist[noptlist++]),"SYSTIMEH");
10116 #endif /* NOSYSTIMEH */
10119 makestr(&(optlist[noptlist++]),"SYSTIMEBH");
10120 #endif /* SYSTIMEBH */
10122 makestr(&(optlist[noptlist++]),"SYSTIMEBH");
10123 #endif /* NOSYSTIMEBH */
10125 makestr(&(optlist[noptlist++]),"UTIMEH");
10126 #endif /* UTIMEH */
10128 makestr(&(optlist[noptlist++]),"SYSUTIMEH");
10129 #endif /* SYSUTIMEH */
10132 makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
10133 #endif /* CK_NEED_SIG */
10135 makestr(&(optlist[noptlist++]),"CK_TTYFD");
10136 #endif /* CK_TTYFD */
10138 makestr(&(optlist[noptlist++]),"NETCONN");
10139 #endif /* NETCONN */
10141 makestr(&(optlist[noptlist++]),"TCPSOCKET");
10143 makestr(&(optlist[noptlist++]),"NOTCPOPTS");
10144 #endif /* NOTCPOPTS */
10146 makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
10147 #endif /* CK_DNS_SRV */
10149 makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
10150 #endif /* NO_DNS_SRV */
10152 makestr(&(optlist[noptlist++]),"CKGHNLHOST");
10153 #endif /* CKGHNLHOST */
10155 makestr(&(optlist[noptlist++]),"NOLISTEN");
10156 #endif /* NOLISTEN */
10158 makestr(&(optlist[noptlist++]),"SOL_SOCKET");
10159 #endif /* SOL_SOCKET */
10160 #ifdef SO_OOBINLINE
10161 makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
10162 #endif /* SO_OOBINLNE */
10163 #ifdef SO_DONTROUTE
10164 makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
10165 #endif /* SO_DONTROUTE */
10166 #ifdef SO_KEEPALIVE
10167 makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
10168 #endif /* SO_KEEPALIVE */
10170 makestr(&(optlist[noptlist++]),"SO_LINGER");
10171 #endif /* SO_LINGER */
10173 makestr(&(optlist[noptlist++]),"TCP_NODELAY");
10174 #endif /* TCP_NODELAY */
10176 makestr(&(optlist[noptlist++]),"SO_SNDBUF");
10177 #endif /* SO_SNDBUF */
10179 makestr(&(optlist[noptlist++]),"SO_RCVBUF");
10180 #endif /* SO_RCVBUF */
10182 makestr(&(optlist[noptlist++]),"h_addr");
10183 #endif /* h_addr */
10185 makestr(&(optlist[noptlist++]),"HADDRLIST");
10186 #endif /* HADDRLIST */
10188 makestr(&(optlist[noptlist++]),"CK_SOCKS");
10190 makestr(&(optlist[noptlist++]),"CK_SOCKS5");
10191 #endif /* CK_SOCKS5 */
10193 makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
10194 #endif /* CK_SOCKS_NS */
10195 #endif /* CK_SOCKS */
10197 makestr(&(optlist[noptlist++]),"RLOGCODE");
10198 #endif /* RLOGCODE */
10200 makestr(&(optlist[noptlist++]),"NETCMD");
10201 #endif /* NETCMD */
10203 makestr(&(optlist[noptlist++]),"NONETCMD");
10204 #endif /* NONETCMD */
10206 makestr(&(optlist[noptlist++]),"NETPTY");
10207 #endif /* NETPTY */
10208 #ifdef CK_ENVIRONMENT
10209 makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
10210 #endif /* CK_ENVIRONMENT */
10211 #endif /* TCPSOCKET */
10213 makestr(&(optlist[noptlist++]),"TNCODE");
10214 #endif /* TNCODE */
10215 #ifdef CK_FORWARD_X
10216 makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
10217 #endif /* CK_FORWARD_X */
10219 makestr(&(optlist[noptlist++]),"TN_COMPORT");
10220 #endif /* TN_COMPORT */
10222 makestr(&(optlist[noptlist++]),"MULTINET");
10223 #endif /* MULTINET */
10225 makestr(&(optlist[noptlist++]),"DEC_TCPIP");
10226 #endif /* DEC_TCPIP */
10228 makestr(&(optlist[noptlist++]),"TCPWARE");
10229 #endif /* TCPWARE */
10231 makestr(&(optlist[noptlist++]),"UCX50");
10234 makestr(&(optlist[noptlist++]),"CMU_TCPIP");
10235 #endif /* CMU_TCPIP */
10237 makestr(&(optlist[noptlist++]),"TTLEBUF");
10238 #endif /* TTLEBUF */
10240 makestr(&(optlist[noptlist++]),"NETLEBUF");
10241 #endif /* NETLEBUF */
10243 makestr(&(optlist[noptlist++]),"IKS_OPTION");
10244 #endif /* IKS_OPTION */
10246 makestr(&(optlist[noptlist++]),"IKSDB");
10249 makestr(&(optlist[noptlist++]),"IKSDCONF");
10250 #endif /* IKSDCONF */
10252 makestr(&(optlist[noptlist++]),"CK_LOGIN");
10253 #endif /* CK_LOGIN */
10255 makestr(&(optlist[noptlist++]),"CK_PAM");
10256 #endif /* CK_PAM */
10258 makestr(&(optlist[noptlist++]),"CK_SHADOW");
10259 #endif /* CK_SHADOW */
10261 makestr(&(optlist[noptlist++]),"CONGSPD");
10262 #endif /* CONGSPD */
10264 makestr(&(optlist[noptlist++]),"SUNX25");
10265 #endif /* SUNX25 */
10267 makestr(&(optlist[noptlist++]),"IBMX25");
10268 #endif /* IBMX25 */
10270 makestr(&(optlist[noptlist++]),"HPX25");
10273 makestr(&(optlist[noptlist++]),"DECNET");
10274 #endif /* DECNET */
10276 makestr(&(optlist[noptlist++]),"SUPERLAT");
10277 #endif /* SUPERLAT */
10279 makestr(&(optlist[noptlist++]),"NPIPE");
10282 makestr(&(optlist[noptlist++]),"CK_NETBIOS");
10283 #endif /* CK_NETBIOS */
10285 makestr(&(optlist[noptlist++]),"ATT7300");
10286 #endif /* ATT7300 */
10288 makestr(&(optlist[noptlist++]),"ATT6300");
10289 #endif /* ATT6300 */
10291 makestr(&(optlist[noptlist++]),"HDBUUCP");
10292 #endif /* HDBUUCP */
10294 makestr(&(optlist[noptlist++]),"USETTYLOCK");
10295 #endif /* USETTYLOCK */
10297 makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
10298 #endif /* USE_UU_LOCK */
10299 #ifdef HAVE_BAUDBOY
10300 makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
10301 #endif /* HAVE_BAUDBOY */
10303 makestr(&(optlist[noptlist++]),"NOUUCP");
10304 #endif /* NOUUCP */
10306 makestr(&(optlist[noptlist++]),"LONGFN");
10307 #endif /* LONGFN */
10309 makestr(&(optlist[noptlist++]),"RDCHK");
10312 makestr(&(optlist[noptlist++]),"SELECT");
10313 #endif /* SELECT */
10315 makestr(&(optlist[noptlist++]),"USLEEP");
10316 #endif /* USLEEP */
10318 makestr(&(optlist[noptlist++]),"NAP");
10321 makestr(&(optlist[noptlist++]),"NAPHACK");
10322 #endif /* NAPHACK */
10324 makestr(&(optlist[noptlist++]),"CK_POLL");
10325 #endif /* CK_POLL */
10327 makestr(&(optlist[noptlist++]),"NOIEXTEN");
10328 #endif /* NOIEXTEN */
10330 makestr(&(optlist[noptlist++]),"EXCELAN");
10331 #endif /* EXCELAN */
10333 makestr(&(optlist[noptlist++]),"INTERLAN");
10334 #endif /* INTERLAN */
10336 makestr(&(optlist[noptlist++]),"NOFILEH");
10337 #endif /* NOFILEH */
10339 makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
10340 #endif /* NOSYSIOCTLH */
10342 makestr(&(optlist[noptlist++]),"DCLPOPEN");
10343 #endif /* DCLPOPEN */
10345 makestr(&(optlist[noptlist++]),"NOSETBUF");
10346 #endif /* NOSETBUF */
10348 makestr(&(optlist[noptlist++]),"NOXFER");
10349 #endif /* NOXFER */
10351 makestr(&(optlist[noptlist++]),"NOCURSES");
10352 #endif /* NOCURSES */
10354 makestr(&(optlist[noptlist++]),"NOSERVER");
10355 #endif /* NOSERVER */
10357 makestr(&(optlist[noptlist++]),"NOPATTERNS");
10360 makestr(&(optlist[noptlist++]),"PATTERNS");
10361 #endif /* PATTERNS */
10362 #endif /* NOPATTERNS */
10364 makestr(&(optlist[noptlist++]),"NOCKEXEC");
10367 makestr(&(optlist[noptlist++]),"CKEXEC");
10368 #endif /* CKEXEC */
10369 #endif /* NOCKEXEC */
10371 makestr(&(optlist[noptlist++]),"NOAUTODL");
10372 #endif /* NOAUTODL */
10374 makestr(&(optlist[noptlist++]),"NOMSEND");
10375 #endif /* NOMSEND */
10377 makestr(&(optlist[noptlist++]),"NOFDZERO");
10378 #endif /* NOFDZERO */
10380 makestr(&(optlist[noptlist++]),"NOPOPEN");
10381 #endif /* NOPOPEN */
10383 makestr(&(optlist[noptlist++]),"NOPARTIAL");
10384 #endif /* NOPARTIAL */
10386 makestr(&(optlist[noptlist++]),"NOKVERBS");
10387 #endif /* NOKVERBS */
10389 makestr(&(optlist[noptlist++]),"NOSETREU");
10390 #endif /* NOSETREU */
10392 makestr(&(optlist[noptlist++]),"LCKDIR");
10393 #endif /* LCKDIR */
10395 makestr(&(optlist[noptlist++]),"ACUCNTRL");
10396 #endif /* ACUCNTRL */
10398 makestr(&(optlist[noptlist++]),"BSD4");
10401 makestr(&(optlist[noptlist++]),"BSD44");
10404 makestr(&(optlist[noptlist++]),"BSD41");
10407 makestr(&(optlist[noptlist++]),"BSD43");
10410 makestr(&(optlist[noptlist++]),"BSD29");
10413 makestr(&(optlist[noptlist++]),"BSDI");
10416 makestr(&(optlist[noptlist++]),"__bsdi__");
10417 #endif /* __bsdi__ */
10419 makestr(&(optlist[noptlist++]),"__NetBSD__");
10420 #endif /* __NetBSD__ */
10422 makestr(&(optlist[noptlist++]),"__OpenBSD__");
10423 #endif /* __OpenBSD__ */
10425 makestr(&(optlist[noptlist++]),"__FreeBSD__");
10426 #endif /* __FreeBSD__ */
10428 makestr(&(optlist[noptlist++]),"__linux__");
10429 #endif /* __linux__ */
10430 #ifdef LINUX_HI_SPD
10431 makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
10432 #endif /* LINUX_HI_SPD */
10434 makestr(&(optlist[noptlist++]),"LYNXOS");
10435 #endif /* LYNXOS */
10437 makestr(&(optlist[noptlist++]),"V7");
10440 makestr(&(optlist[noptlist++]),"AIX370");
10441 #endif /* AIX370 */
10443 makestr(&(optlist[noptlist++]),"RTAIX");
10446 makestr(&(optlist[noptlist++]),"HPUX");
10449 makestr(&(optlist[noptlist++]),"HPUXPRE65");
10450 #endif /* HPUXPRE65 */
10452 makestr(&(optlist[noptlist++]),"DGUX");
10455 makestr(&(optlist[noptlist++]),"DGUX430");
10456 #endif /* DGUX430 */
10458 makestr(&(optlist[noptlist++]),"DGUX540");
10459 #endif /* DGUX540 */
10461 makestr(&(optlist[noptlist++]),"DGUX543");
10462 #endif /* DGUX543 */
10464 makestr(&(optlist[noptlist++]),"DGUX54410");
10465 #endif /* DGUX54410 */
10467 makestr(&(optlist[noptlist++]),"DGUX54411");
10468 #endif /* DGUX54411 */
10470 makestr(&(optlist[noptlist++]),"sony_news");
10471 #endif /* sony_news */
10473 makestr(&(optlist[noptlist++]),"CIE");
10476 makestr(&(optlist[noptlist++]),"XENIX");
10479 makestr(&(optlist[noptlist++]),"SCO_XENIX");
10480 #endif /* SCO_XENIX */
10482 makestr(&(optlist[noptlist++]),"ISIII");
10485 makestr(&(optlist[noptlist++]),"I386IX");
10486 #endif /* I386IX */
10488 makestr(&(optlist[noptlist++]),"RTU");
10491 makestr(&(optlist[noptlist++]),"PROVX1");
10492 #endif /* PROVX1 */
10494 makestr(&(optlist[noptlist++]),"PYRAMID");
10495 #endif /* PYRAMID */
10497 makestr(&(optlist[noptlist++]),"TOWER1");
10498 #endif /* TOWER1 */
10500 makestr(&(optlist[noptlist++]),"UTEK");
10503 makestr(&(optlist[noptlist++]),"ZILOG");
10506 makestr(&(optlist[noptlist++]),"TRS16");
10509 makestr(&(optlist[noptlist++]),"MINIX");
10512 makestr(&(optlist[noptlist++]),"C70");
10515 makestr(&(optlist[noptlist++]),"AIXPS2");
10516 #endif /* AIXPS2 */
10518 makestr(&(optlist[noptlist++]),"AIXRS");
10521 makestr(&(optlist[noptlist++]),"UTSV");
10524 makestr(&(optlist[noptlist++]),"ATTSV");
10527 makestr(&(optlist[noptlist++]),"SVR3");
10530 makestr(&(optlist[noptlist++]),"SVR4");
10533 makestr(&(optlist[noptlist++]),"DELL_SVR4");
10534 #endif /* DELL_SVR4 */
10536 makestr(&(optlist[noptlist++]),"ICL_SVR4");
10537 #endif /* ICL_SVR4 */
10539 makestr(&(optlist[noptlist++]),"OSF");
10542 makestr(&(optlist[noptlist++]),"OSF1");
10545 makestr(&(optlist[noptlist++]),"__OSF");
10548 makestr(&(optlist[noptlist++]),"__OSF__");
10549 #endif /* __OSF__ */
10551 makestr(&(optlist[noptlist++]),"__osf__");
10552 #endif /* __osf__ */
10554 makestr(&(optlist[noptlist++]),"__OSF1");
10555 #endif /* __OSF1 */
10557 makestr(&(optlist[noptlist++]),"__OSF1__");
10558 #endif /* __OSF1__ */
10560 makestr(&(optlist[noptlist++]),"PTX");
10563 makestr(&(optlist[noptlist++]),"POSIX");
10565 #ifdef BSD44ORPOSIX
10566 makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
10567 #endif /* BSD44ORPOSIX */
10569 makestr(&(optlist[noptlist++]),"SVORPOSIX");
10570 #endif /* SVORPOSIX */
10572 makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
10573 #endif /* SVR4ORPOSIX */
10575 makestr(&(optlist[noptlist++]),"OS2ORVMS");
10576 #endif /* OS2ORVMS */
10578 makestr(&(optlist[noptlist++]),"OS2ORUNIX");
10579 #endif /* OS2ORUNIX */
10581 makestr(&(optlist[noptlist++]),"VMSORUNIX");
10582 #endif /* VMSORUNIX */
10584 makestr(&(optlist[noptlist++]),"VMS64BIT"); /* VMS on Alpha or IA64 */
10585 #endif /* VMS64BIT */
10587 makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
10588 #endif /* VMSI64 */
10589 #ifdef _POSIX_SOURCE
10590 makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
10591 #endif /* _POSIX_SOURCE */
10592 #ifdef _XOPEN_SOURCE
10593 makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
10596 makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
10599 makestr(&(optlist[noptlist++]),"_SVID3");
10600 #endif /* _SVID3 */
10602 makestr(&(optlist[noptlist++]),"Plan9");
10605 makestr(&(optlist[noptlist++]),"SOLARIS");
10607 makestr(&(optlist[noptlist++]),"SOLARIS24");
10608 #endif /* SOLARIS24 */
10610 makestr(&(optlist[noptlist++]),"SOLARIS25");
10611 #endif /* SOLARIS25 */
10613 makestr(&(optlist[noptlist++]),"SOLARIS26");
10614 #endif /* SOLARIS26 */
10616 makestr(&(optlist[noptlist++]),"SOLARIS7");
10617 #endif /* SOLARIS7 */
10619 makestr(&(optlist[noptlist++]),"SOLARIS8");
10620 #endif /* SOLARIS8 */
10621 #endif /* SOLARIS */
10624 makestr(&(optlist[noptlist++]),"SUNOS4");
10625 #endif /* SUNOS4 */
10627 makestr(&(optlist[noptlist++]),"SUN4S5");
10628 #endif /* SUN4S5 */
10630 makestr(&(optlist[noptlist++]),"IRIX");
10633 makestr(&(optlist[noptlist++]),"ENCORE");
10634 #endif /* ENCORE */
10636 makestr(&(optlist[noptlist++]),"ultrix");
10639 makestr(&(optlist[noptlist++]),"sxaE50");
10642 makestr(&(optlist[noptlist++]),"mips");
10645 makestr(&(optlist[noptlist++]),"MIPS");
10648 makestr(&(optlist[noptlist++]),"vax");
10651 makestr(&(optlist[noptlist++]),"VAX");
10654 makestr(&(optlist[noptlist++]),"alpha");
10657 makestr(&(optlist[noptlist++]),"ALPHA");
10660 makestr(&(optlist[noptlist++]),"__ALPHA");
10663 makestr(&(optlist[noptlist++]),"__alpha");
10666 makestr(&(optlist[noptlist++]),"__AXP");
10669 makestr(&(optlist[noptlist++]),"AXP");
10672 makestr(&(optlist[noptlist++]),"axp");
10675 makestr(&(optlist[noptlist++]),"__ALPHA__");
10678 makestr(&(optlist[noptlist++]),"__alpha__");
10681 makestr(&(optlist[noptlist++]),"sun");
10684 makestr(&(optlist[noptlist++]),"sun3");
10687 makestr(&(optlist[noptlist++]),"sun386");
10690 makestr(&(optlist[noptlist++]),"_SUN");
10693 makestr(&(optlist[noptlist++]),"sun4");
10696 makestr(&(optlist[noptlist++]),"sparc");
10699 makestr(&(optlist[noptlist++]),"_CRAY");
10702 makestr(&(optlist[noptlist++]),"NEXT33");
10705 makestr(&(optlist[noptlist++]),"NEXT");
10708 makestr(&(optlist[noptlist++]),"NeXT");
10711 makestr(&(optlist[noptlist++]),"MACH");
10715 makestr(&(optlist[noptlist++]),"MACOSX");
10718 makestr(&(optlist[noptlist++]),"MACOSX10");
10721 makestr(&(optlist[noptlist++]),"MACOSX103");
10725 makestr(&(optlist[noptlist++]),"sgi");
10728 makestr(&(optlist[noptlist++]),"M_SYS5");
10730 #ifdef __SYSTEM_FIVE
10731 makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
10734 makestr(&(optlist[noptlist++]),"sysV");
10736 #ifdef M_XENIX /* SCO Xenix V and UNIX/386 */
10737 makestr(&(optlist[noptlist++]),"M_XENIX");
10739 #ifdef M_UNIX /* SCO UNIX */
10740 makestr(&(optlist[noptlist++]),"M_UNIX");
10742 #ifdef _M_UNIX /* SCO UNIX 3.2v4 = ODT 2.0 */
10743 makestr(&(optlist[noptlist++]),"_M_UNIX");
10746 makestr(&(optlist[noptlist++]),"CK_SCOV5");
10749 makestr(&(optlist[noptlist++]),"SCO_OSR504");
10752 makestr(&(optlist[noptlist++]),"M_IA64");
10755 makestr(&(optlist[noptlist++]),"_M_IA64");
10758 makestr(&(optlist[noptlist++]),"ia64");
10761 makestr(&(optlist[noptlist++]),"_ia64");
10764 makestr(&(optlist[noptlist++]),"_ia64_");
10767 makestr(&(optlist[noptlist++]),"__ia64");
10770 makestr(&(optlist[noptlist++]),"M_I686");
10773 makestr(&(optlist[noptlist++]),"_M_I686");
10776 makestr(&(optlist[noptlist++]),"i686");
10779 makestr(&(optlist[noptlist++]),"M_I586");
10782 makestr(&(optlist[noptlist++]),"_M_I586");
10785 makestr(&(optlist[noptlist++]),"i586");
10788 makestr(&(optlist[noptlist++]),"M_I486");
10791 makestr(&(optlist[noptlist++]),"_M_I486");
10794 makestr(&(optlist[noptlist++]),"i486");
10797 makestr(&(optlist[noptlist++]),"M_I386");
10800 makestr(&(optlist[noptlist++]),"_M_I386");
10803 makestr(&(optlist[noptlist++]),"i386");
10806 makestr(&(optlist[noptlist++]),"i286");
10809 makestr(&(optlist[noptlist++]),"M_I286");
10812 makestr(&(optlist[noptlist++]),"mc68000");
10815 makestr(&(optlist[noptlist++]),"mc68010");
10818 makestr(&(optlist[noptlist++]),"mc68020");
10821 makestr(&(optlist[noptlist++]),"mc68030");
10824 makestr(&(optlist[noptlist++]),"mc68040");
10827 makestr(&(optlist[noptlist++]),"M_68000");
10830 makestr(&(optlist[noptlist++]),"M_68010");
10833 makestr(&(optlist[noptlist++]),"M_68020");
10836 makestr(&(optlist[noptlist++]),"M_68030");
10839 makestr(&(optlist[noptlist++]),"M_68040");
10842 makestr(&(optlist[noptlist++]),"m68k");
10845 makestr(&(optlist[noptlist++]),"m88k");
10848 makestr(&(optlist[noptlist++]),"pdp11");
10851 makestr(&(optlist[noptlist++]),"iAPX");
10854 makestr(&(optlist[noptlist++]),"hpux");
10857 makestr(&(optlist[noptlist++]),"__hpux");
10859 #ifdef __hp9000s800
10860 makestr(&(optlist[noptlist++]),"__hp9000s800");
10862 #ifdef __hp9000s700
10863 makestr(&(optlist[noptlist++]),"__hp9000s700");
10865 #ifdef __hp9000s500
10866 makestr(&(optlist[noptlist++]),"__hp9000s500");
10868 #ifdef __hp9000s300
10869 makestr(&(optlist[noptlist++]),"__hp9000s300");
10871 #ifdef __hp9000s200
10872 makestr(&(optlist[noptlist++]),"__hp9000s200");
10875 makestr(&(optlist[noptlist++]),"AIX");
10878 makestr(&(optlist[noptlist++]),"_AIXFS");
10881 makestr(&(optlist[noptlist++]),"u370");
10884 makestr(&(optlist[noptlist++]),"u3b");
10887 makestr(&(optlist[noptlist++]),"u3b2");
10890 makestr(&(optlist[noptlist++]),"multimax");
10893 makestr(&(optlist[noptlist++]),"balance");
10896 makestr(&(optlist[noptlist++]),"ibmrt");
10899 makestr(&(optlist[noptlist++]),"_IBMRT");
10902 makestr(&(optlist[noptlist++]),"ibmrs6000");
10905 makestr(&(optlist[noptlist++]),"_AIX");
10908 makestr(&(optlist[noptlist++]),"_IBMR2");
10911 makestr(&(optlist[noptlist++]),"UNIXWARE");
10914 makestr(&(optlist[noptlist++]),"QNX");
10916 makestr(&(optlist[noptlist++]),"__QNX__");
10918 makestr(&(optlist[noptlist++]),"__16BIT__");
10921 makestr(&(optlist[noptlist++]),"CK_QNX16");
10924 makestr(&(optlist[noptlist++]),"__32BIT__");
10927 makestr(&(optlist[noptlist++]),"CK_QNX32");
10929 #endif /* __QNX__ */
10933 makestr(&(optlist[noptlist++]),"QNX6");
10937 makestr(&(optlist[noptlist++]),"NEUTRINO");
10938 #endif /* NEUTRINO */
10940 #ifdef __STRICT_BSD__
10941 makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
10943 #ifdef __STRICT_ANSI__
10944 makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
10946 #ifdef _ANSI_C_SOURCE
10947 makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
10950 makestr(&(optlist[noptlist++]),"__STDC__");
10953 makestr(&(optlist[noptlist++]),"__DECC");
10955 sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
10956 makestr(&(optlist[noptlist++]),line);
10957 #endif /* __DECC_VER */
10958 #endif /* __DECC */
10960 sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
10961 makestr(&(optlist[noptlist++]),line);
10962 #endif /* __CRTL_VER */
10963 #ifdef __GNUC__ /* gcc in ansi mode */
10964 makestr(&(optlist[noptlist++]),"__GNUC__");
10966 #ifdef GNUC /* gcc in traditional mode */
10967 makestr(&(optlist[noptlist++]),"GNUC");
10969 #ifdef __EGCS__ /* egcs in ansi mode */
10970 makestr(&(optlist[noptlist++]),"__EGCS__");
10972 #ifdef __egcs__ /* egcs in ansi mode */
10973 makestr(&(optlist[noptlist++]),"__egcs__");
10976 makestr(&(optlist[noptlist++]),"__WATCOMC__");
10979 makestr(&(optlist[noptlist++]),"CK_ANSIC");
10982 makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
10984 #ifdef CKCONINTB4CB
10985 makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
10986 #endif /* CKCONINTB4CB */
10988 makestr(&(optlist[noptlist++]),"NOTERMCAP");
10989 #endif /* NOTERMCAP */
10991 makestr(&(optlist[noptlist++]),"__GLIBC__");
10993 #ifdef _SC_JOB_CONTROL
10994 makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
10996 #ifdef _POSIX_JOB_CONTROL
10997 makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
11000 makestr(&(optlist[noptlist++]),"SIG_I");
11003 makestr(&(optlist[noptlist++]),"SIG_V");
11005 #ifdef CK_POSIX_SIG
11006 makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
11009 makestr(&(optlist[noptlist++]),"SVR3JC");
11012 makestr(&(optlist[noptlist++]),"_386BSD");
11015 makestr(&(optlist[noptlist++]),"_BSD");
11018 makestr(&(optlist[noptlist++]),"USE_MEMCPY");
11019 #endif /* USE_MEMCPY */
11021 makestr(&(optlist[noptlist++]),"USE_LSTAT");
11022 #endif /* USE_LSTAT */
11024 makestr(&(optlist[noptlist++]),"TERMIOX");
11025 #endif /* TERMIOX */
11027 makestr(&(optlist[noptlist++]),"STERMIOX");
11028 #endif /* STERMIOX */
11030 makestr(&(optlist[noptlist++]),"CK_CURSES");
11031 #endif /* CK_CURSES */
11033 makestr(&(optlist[noptlist++]),"CK_NEWTERM");
11034 #endif /* CK_NEWTERM */
11036 makestr(&(optlist[noptlist++]),"CK_WREFRESH");
11037 #endif /* CK_WREFRESH */
11039 makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
11040 #endif /* CK_PCT_BAR */
11042 makestr(&(optlist[noptlist++]),"CK_DTRCD");
11043 #endif /* CK_DTRCD */
11045 makestr(&(optlist[noptlist++]),"CK_DTRCTS");
11046 #endif /* CK_DTRCTS */
11048 makestr(&(optlist[noptlist++]),"CK_RTSCTS");
11049 #endif /* CK_RTSCTS */
11050 #ifdef POSIX_CRTSCTS
11051 makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
11052 #endif /* POSIX_CRTSCTS */
11054 makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
11055 #endif /* FIXCRTSCTS */
11057 makestr(&(optlist[noptlist++]),"HWPARITY");
11058 #endif /* HWPARITY */
11061 makestr(&(optlist[noptlist++]),"CK_INI_A");
11062 ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
11063 makestr(&(optlist[noptlist++]),line);
11066 makestr(&(optlist[noptlist++]),"CK_INI_B");
11067 ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
11068 makestr(&(optlist[noptlist++]),line);
11070 makestr(&(optlist[noptlist++]),"CK_SYSINI");
11071 #endif /* CK_INI_B */
11072 #endif /* CK_INI_A */
11073 #endif /* CK_DSYSINI */
11075 makestr(&(optlist[noptlist++]),"CK_DSYSINI");
11076 #endif /* CK_DSYSINI */
11078 makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
11079 #endif /* CK_TTGWSIZ */
11081 makestr(&(optlist[noptlist++]),"CK_NAWS");
11082 #endif /* CK_NAWS */
11084 makestr(&(optlist[noptlist++]),"MDMHUP");
11085 #endif /* MDMHUP */
11086 #ifdef HUP_CLOSE_POSIX
11087 makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
11088 #endif /* HUP_CLOSE_POSIX */
11089 #ifdef NO_HUP_CLOSE_POSIX
11090 makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
11091 #endif /* NO_HUP_CLOSE_POSIX */
11093 makestr(&(optlist[noptlist++]),"DCMDBUF");
11094 #endif /* DCMDBUF */
11096 makestr(&(optlist[noptlist++]),"CK_RECALL");
11097 #endif /* CK_RECALL */
11099 makestr(&(optlist[noptlist++]),"BROWSER");
11100 #endif /* BROWSER */
11102 makestr(&(optlist[noptlist++]),"CLSOPN");
11103 #endif /* CLSOPN */
11105 makestr(&(optlist[noptlist++]),"STRATUS");
11106 #endif /* STRATUS */
11108 makestr(&(optlist[noptlist++]),"__VOS__");
11109 #endif /* __VOS__ */
11111 makestr(&(optlist[noptlist++]),"STRATUSX25");
11112 #endif /* STRATUSX25 */
11114 makestr(&(optlist[noptlist++]),"OS2MOUSE");
11115 #endif /* OS2MOUSE */
11117 makestr(&(optlist[noptlist++]),"CK_REXX");
11118 #endif /* CK_REXX */
11120 makestr(&(optlist[noptlist++]),"CK_TIMERS");
11121 #endif /* CK_TIMERS */
11123 makestr(&(optlist[noptlist++]),"TTSPDLIST");
11124 #endif /* TTSPDLIST */
11126 makestr(&(optlist[noptlist++]),"CK_PERMS");
11127 #endif /* CK_PERMS */
11129 makestr(&(optlist[noptlist++]),"CKTUNING");
11130 #endif /* CKTUNING */
11132 makestr(&(optlist[noptlist++]),"NEWFTP");
11133 #endif /* NEWFTP */
11135 makestr(&(optlist[noptlist++]),"SYSFTP");
11136 #endif /* SYSFTP */
11138 makestr(&(optlist[noptlist++]),"NOFTP");
11141 makestr(&(optlist[noptlist++]),"CKHTTP");
11142 #endif /* CKHTTP */
11144 makestr(&(optlist[noptlist++]),"NOHTTP");
11145 #endif /* NOHTTP */
11147 makestr(&(optlist[noptlist++]),"CKROOT");
11148 #endif /* CKROOT */
11150 makestr(&(optlist[noptlist++]),"CKREALPATH");
11151 #endif /* CKREALPATH */
11153 makestr(&(optlist[noptlist++]),"STREAMING");
11154 #endif /* STREAMING */
11155 #ifdef UNPREFIXZERO
11156 makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
11157 #endif /* UNPREFIXZERO */
11159 makestr(&(optlist[noptlist++]),"CKREGEX");
11160 #endif /* CKREGEX */
11162 makestr(&(optlist[noptlist++]),"ZXREWIND");
11163 #endif /* ZXREWIND */
11165 makestr(&(optlist[noptlist++]),"CKSYSLOG");
11166 #endif /* CKSYSLOG */
11168 sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
11169 makestr(&(optlist[noptlist++]),line);
11170 #endif /* SYSLOGLEVEL */
11172 makestr(&(optlist[noptlist++]),"NOSEXP");
11173 #endif /* NOSEXP */
11175 makestr(&(optlist[noptlist++]),"CKLEARN");
11178 makestr(&(optlist[noptlist++]),"NOLOEARN");
11179 #endif /* NOLOEARN */
11180 #endif /* CKLEARN */
11182 makestr(&(optlist[noptlist++]),"NOFLOAT");
11185 makestr(&(optlist[noptlist++]),"FNFLOAT");
11186 #endif /* FNFLOAT */
11189 makestr(&(optlist[noptlist++]),"GFTIMER");
11190 #endif /* GFTIMER */
11192 ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
11193 makestr(&(optlist[noptlist++]),line);
11195 makestr(&(optlist[noptlist++]),"CKFLOAT");
11196 #endif /* CKFLOAT_S */
11197 #endif /* CKFLOAT */
11198 #endif /* NOFLOAT */
11201 makestr(&(optlist[noptlist++]),"SSH");
11204 makestr(&(optlist[noptlist++]),"NETDLL");
11205 #endif /* NETDLL */
11207 makestr(&(optlist[noptlist++]),"NETFILE");
11208 #endif /* NETFILE */
11210 makestr(&(optlist[noptlist++]),"CK_TAPI");
11211 #endif /* CK_TAPI */
11213 makestr(&(optlist[noptlist++]),"CK_SSL");
11214 #endif /* CK_SSL */
11216 debug(F101,"initoptlist noptlist","",noptlist);
11217 sh_sort(optlist,NULL,noptlist,0,0,0);
11226 extern int fp_digits, fp_rounding;
11227 #endif /* FNFLOAT */
11228 extern int byteorder;
11229 printf("%s\n",versio);
11232 debug(F101,"shofea NOPTLIST","",NOPTLIST);
11234 debug(F101,"shofea noptlist","",noptlist);
11238 printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
11239 #else /* _M_ALPHA */
11241 printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
11244 printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
11245 #else /* _M_MRX000 */
11247 printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
11248 #else /* _M_IX86 */
11249 UNKNOWN WINDOWS PLATFORM
11250 #endif /* _M_IX86 */
11251 #endif /* _M_MRX000 */
11252 #endif /* _M_PPC */
11253 #endif /* _M_ALPHA */
11256 printf("IBM OS/2 16-bit.\n");
11258 printf("IBM OS/2 32-bit.\n");
11259 #endif /* M_I286 */
11264 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11265 printf("Major optional features included:\n");
11266 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11269 printf(" Network support (type SHOW NET for further info)\n");
11270 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11272 printf(" Telnet Kermit Option\n");
11273 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11274 #endif /* IKS_OPTION */
11275 #ifdef CK_AUTHENTICATION
11276 printf(" Telnet Authentication Option\n");
11277 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11281 printf(" Kerberos(TM) IV and Kerberos V authentication\n");
11282 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11284 printf(" Kerberos(TM) IV authentication\n");
11285 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11289 printf(" Kerberos(TM) V authentication\n");
11290 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11293 #endif /* CK_KERBEROS */
11295 printf(" SRP(TM) (Secure Remote Password) authentication\n");
11296 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11297 #endif /* CK_SRP */
11299 printf(" Secure Sockets Layer (SSL)\n");
11300 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11301 printf(" Transport Layer Security (TLS)\n");
11302 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11303 #endif /* CK_SSL */
11305 printf(" Secure Shell (SSH) [internal]\n");
11306 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11307 #endif /* SSHBUILTIN */
11309 printf(" Secure Shell (SSH) [external]\n");
11310 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11311 #endif /* SSHCMD */
11312 #ifdef CK_ENCRYPTION
11313 printf(" Telnet Encryption Option\n");
11314 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11316 printf(" Telnet DES Encryption\n");
11317 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11318 #endif /* CK_DES */
11320 printf(" Telnet CAST Encryption\n");
11321 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11322 #endif /* CK_CAST */
11325 #ifdef ALLOW_KRB_3DES_ENCRYPT
11326 printf(" Kerberos 3DES/AES Telnet Encryption\n");
11327 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11328 #endif /* ALLOW_KRB_3DES_ENCRYPT */
11330 #endif /* CK_KERBEROS */
11331 #endif /* CK_ENCRYPTION */
11332 #endif /* CK_AUTHENTICATION */
11333 #ifdef CK_FORWARD_X
11334 printf(" X Windows forwarding\n");
11335 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11336 #endif /* CK_FORWARD_X */
11338 printf(" Telnet Remote Com Port Control Option\n");
11339 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11340 #endif /* TN_COMPORT */
11343 printf(" SOCKS 5\n");
11344 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11345 #else /* CK_SOCKS5 */
11346 printf(" SOCKS 4\n");
11347 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11348 #endif /* CK_SOCKS5 */
11349 #endif /* CK_SOCKS */
11351 printf(" Built-in FTP client\n");
11352 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11353 #endif /* NEWFTP */
11355 printf(" Built-in HTTP client\n");
11356 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11357 #endif /* CKHTTP */
11358 #endif /* NETCONN */
11361 printf(" Hardware flow control\n");
11362 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11363 #endif /* CK_RTSCTS */
11366 #ifdef XYZ_INTERNAL
11367 printf(" Built-in XYZMODEM protocols\n");
11369 printf(" External XYZMODEM protocol support\n");
11370 #endif /* XYZ_INTERNAL */
11371 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11372 #endif /* CK_XYZ */
11375 printf(" Latin-1 (West European) character-set translation\n");
11376 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11378 printf(" Latin-2 (East European) character-set translation\n");
11379 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11380 #endif /* LATIN2 */
11382 printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
11383 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11384 #endif /* CYRILLIC */
11386 printf(" Greek character-set translation\n");
11387 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11390 printf(" Hebrew character-set translation\n");
11391 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11392 #endif /* HEBREW */
11394 printf(" Japanese character-set translation\n");
11395 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11398 printf(" Unicode character-set translation\n");
11399 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11400 #endif /* UNICODE */
11403 printf(" Unicode support for ISO-2022 Terminal Emulation\n");
11405 printf(" Unicode translation for Terminal Character-Sets\n");
11406 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11407 #endif /* CKOUNI */
11408 #endif /* NOCSETS */
11411 printf(" Pseudoterminal control\n");
11412 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11413 #endif /* NETPTY */
11416 printf(" REDIRECT command\n");
11417 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11418 #endif /* CK_REDIR */
11421 printf(" RESEND command\n");
11422 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11423 #endif /* CK_RESEND */
11427 printf(" Fullscreen file transfer display\n");
11428 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11429 #endif /* CK_CURSES */
11430 #endif /* NOXFER */
11433 printf(" Control-character unprefixing\n");
11434 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11435 #endif /* CK_SPEED */
11438 printf(" Streaming\n");
11439 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11440 #endif /* STREAMING */
11443 printf(" Autodownload\n");
11444 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11445 #endif /* CK_AUTODL */
11448 printf(" Mouse support\n");
11449 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11450 #endif /* OS2MOUSE */
11453 printf(" REXX script language interface\n");
11454 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11455 #endif /* CK_REXX */
11459 printf(" Internet Kermit Service with user login support\n");
11460 #else /* CK_LOGIN */
11461 printf(" Internet Kermit Service without user login support\n");
11462 #endif /* CK_LOGIN */
11463 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11467 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11468 printf("Major optional features not included:\n");
11469 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11472 printf(" No file-transfer protocols\n");
11473 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11478 printf(" No fullscreen file transfer display\n");
11479 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11482 #endif /* CK_CURSES */
11485 printf(" No server mode\n");
11486 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11488 #endif /* NOSERVER */
11491 printf(" No control-character unprefixing\n");
11492 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11494 #endif /* CK_SPEED */
11497 printf(" No streaming\n");
11498 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11500 #endif /* STREAMING */
11503 printf(" No autodownload\n");
11504 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11506 #endif /* CK_AUTODL */
11509 printf(" No built-in XYZMODEM protocols\n");
11510 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11512 #endif /* CK_XYZ */
11515 printf(" No transaction log\n");
11516 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11518 #endif /* NOTLOG */
11519 #endif /* NOXFER */
11522 printf(" No debugging\n");
11523 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11525 #endif /* NODEBUG */
11528 printf(" No built-in help\n");
11529 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11531 #endif /* NOHELP */
11534 printf(" No making connections\n");
11535 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11539 printf(" No network support\n");
11540 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11542 #else /* NETCONN */
11544 printf(" No Telnet Kermit Option\n");
11545 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11547 #endif /* IKS_OPTION */
11548 #endif /* NETCONN */
11551 printf(" No Secure Shell (SSH)\n");
11552 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11554 #ifndef CK_AUTHENTICATION
11555 printf(" No Kerberos(TM) authentication\n");
11556 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11557 printf(" No SRP(TM) (Secure Remote Password) protocol\n");
11558 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11559 printf(" No Secure Sockets Layer (SSL) protocol\n");
11560 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11561 printf(" No Transport Layer Security (TLS) protocol\n");
11562 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11563 printf(" No encryption\n");
11564 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11566 #else /* CK_AUTHENTICATION */
11567 #ifndef CK_KERBEROS
11568 printf(" No Kerberos(TM) authentication\n");
11569 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11571 #else /* CK_KERBEROS */
11573 printf(" No Kerberos(TM) IV authentication\n");
11574 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11578 printf(" No Kerberos(TM) V authentication\n");
11579 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11582 #endif /* CK_KERBEROS */
11584 printf(" No SRP(TM) (Secure Remote Password) authentication\n");
11585 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11587 #endif /* CK_SRP */
11589 printf(" No Secure Sockets Layer (SSL) protocol\n");
11590 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11591 printf(" No Transport Layer Security (TLS) protocol\n");
11592 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11594 #endif /* CK_SSL */
11595 #ifndef CK_ENCRYPTION
11596 printf(" No Telnet Encryption Option\n");
11597 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11599 #else /* CK_ENCRYPTION */
11602 printf(" No Telnet DES encryption\n");
11603 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11605 #endif /* CK_DES */
11607 printf(" No Telnet CAST encryption\n");
11608 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11610 #endif /* CK_CAST */
11613 #ifndef ALLOW_KRB_3DES_ENCRYPT
11614 printf(" No Kerberos 3DES/AES Telnet Encryption\n");
11615 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11616 #endif /* ALLOW_KRB_3DES_ENCRYPT */
11618 #endif /* CK_KERBEROS */
11620 #endif /* CK_ENCRYPTION */
11621 #endif /* CK_AUTHENTICATION */
11622 #ifndef CK_FORWARD_X
11623 printf(" No X Windows forwarding\n");
11624 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11625 #endif /* CK_FORWARD_X */
11627 printf(" No Telnet Remote Com Port Control Option\n");
11628 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11629 #endif /* TN_COMPORT */
11631 printf(" No SOCKS\n");
11632 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11633 #endif /* CK_SOCKS */
11635 printf(" No built-in FTP client\n");
11636 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11637 #endif /* NEWFTP */
11639 printf(" No built-in HTTP client\n");
11640 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11641 #endif /* NOHTTP */
11644 printf(" No DIAL command\n");
11645 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11649 printf(" Support for most modem types excluded\n");
11650 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11652 #endif /* MINIDIAL */
11653 #endif /* NODIAL */
11654 #endif /* NOLOCAL */
11658 printf(" No hardware flow control\n");
11659 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11662 #endif /* CK_RTSCTS */
11665 printf(" No TRANSMIT command\n");
11666 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11668 #endif /* NOXMIT */
11671 printf(" No SCRIPT command\n");
11672 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11674 #endif /* NOSCRIPT */
11677 printf(" No script programming features\n");
11678 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11683 printf(" No character-set translation\n");
11684 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11689 printf(" No Latin-2 character-set translation\n");
11690 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11692 #endif /* LATIN2 */
11695 printf(" No Greek character-set translation\n");
11696 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11698 #endif /* NOGREEK */
11701 printf(" No Hebrew character-set translation\n");
11702 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11704 #endif /* NOHEBREW */
11707 printf(" No Unicode character-set translation\n");
11708 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11710 #endif /* NOUNICODE */
11713 printf(" No Cyrillic character-set translation\n");
11714 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11716 #endif /* NOCYRIL */
11719 printf(" No Kanji character-set translation\n");
11720 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11723 #endif /* NOCSETS */
11726 printf(" No command-line arguments\n");
11727 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11729 #endif /* NOCMDL */
11732 printf(" No escape to system\n");
11733 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11735 #endif /* NOPUSH */
11739 printf(" No UNIX job control\n");
11740 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11746 printf(" No SET KEY command\n");
11747 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11749 #endif /* NOSETKEY */
11752 printf(" No REDIRECT or PIPE command\n");
11753 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11755 #endif /* CK_REDIR */
11759 printf(" No pseudoterminal control\n");
11760 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11762 #endif /* NETPTY */
11766 printf(" No RESEND command\n");
11767 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11769 #endif /* CK_RESEND */
11774 printf(" No Mouse support\n");
11775 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11777 #endif /* __32BIT__ */
11779 #endif /* OS2MOUSE */
11784 printf(" No REXX script language interface\n");
11785 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11787 #endif /* CK_REXX */
11792 printf(" No Internet Kermit Service\n");
11793 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11799 if (++lines > cmd_rows - 3)
11800 { if (!askmore()) return(1); else lines = 0; }
11803 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11806 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11807 printf("Host info:\n");
11808 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11809 printf(" Machine: %s\n",unm_mch[0] ? unm_mch : "(unknown)");
11810 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11811 printf(" Model: %s\n",unm_mod[0] ? unm_mod : "(unknown)");
11812 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11813 printf(" OS: %s\n",unm_nam[0] ? unm_nam : "(unknown)");
11814 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11815 printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
11816 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11817 printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
11818 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11820 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11821 #endif /* CK_UTSNAME */
11824 Print compile-time (-D) options, as well as C preprocessor
11825 predefined symbols that might affect us...
11829 char * s; /* Makefile target */
11832 if (!*s) s = "(unknown)";
11834 if (++lines > cmd_rows - 3) {
11835 if (!askmore()) return(1); else lines = 0;
11837 printf("Target: %s\n", s);
11838 if (++lines > cmd_rows - 3) {
11839 if (!askmore()) return(1); else lines = 0;
11842 #endif /* KTARGET */
11846 printf("GCC version: %s\n", __VERSION__);
11848 printf("Compiler version: %s\n", __VERSION__);
11849 #endif /* __GNUC__ */
11850 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11851 #endif /* __VERSION__ */
11853 #ifdef __DATE__ /* GNU and other ANSI */
11855 printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
11857 printf("Compiled %s, options:\n", __DATE__);
11858 #endif /* __TIME__ */
11859 #else /* !__DATE__ */
11860 printf("Compiler options:\n");
11861 #endif /* __DATE__ */
11862 if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
11864 for (i = 0; i < noptlist; i++) /* Print sorted option list */
11865 if (!prtopt(&lines,optlist[i]))
11868 if (!prtopt(&lines,"")) return(0); /* Start a new section */
11870 /* Sizes of data types */
11875 byteorder ? "little" : "big",
11879 if (!prtopt(&lines,line)) return(0);
11880 if (!prtopt(&lines,"")) return(0); /* Start a new section */
11881 sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
11882 if (!prtopt(&lines,line)) return(0);
11883 sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
11884 if (!prtopt(&lines,line)) return(0);
11885 sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
11886 if (!prtopt(&lines,line)) return(0);
11887 sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
11888 if (!prtopt(&lines,line)) return(0);
11889 sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
11890 if (!prtopt(&lines,line)) return(0);
11892 sprintf(line,"LONG_MAX=%d",LONG_MAX); /* SAFE */
11893 #endif /* LONG_MAX */
11895 sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
11896 if (!prtopt(&lines,line)) return(0);
11897 sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
11898 if (!prtopt(&lines,line)) return(0);
11900 if (!prtopt(&lines,"")) return(0); /* Start a new section */
11901 if (!prtopt(&lines,"floating-point:")) return(0);
11902 sprintf(line,"precision=%d",fp_digits); /* SAFE */
11903 if (!prtopt(&lines,line)) return(0);
11904 sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
11905 if (!prtopt(&lines,line)) return(0);
11906 #endif /* FNFLOAT */
11907 #endif /* CKFLOAT */
11912 #endif /* NOSHOW */