home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku208.zip / ckuus5.c < prev    next >
C/C++ Source or Header  |  2003-03-26  |  387KB  |  11,808 lines

  1. #include "ckcsym.h"
  2.  
  3. int xcmdsrc = 0;
  4.  
  5. #ifdef NOICP
  6. int cmdsrc() { return(0); }
  7. #endif /* NOICP */
  8.  
  9. /*  C K U U S 5 --  "User Interface" for C-Kermit, part 5  */
  10.  
  11. /*
  12.   Author: Frank da Cruz <fdc@columbia.edu>,
  13.   Columbia University Academic Information Systems, New York City.
  14.  
  15.   Copyright (C) 1985, 2003,
  16.     Trustees of Columbia University in the City of New York.
  17.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  18.     copyright text in the ckcmai.c module for disclaimer and permissions.
  19. */
  20.  
  21. /* Includes */
  22.  
  23. #include "ckcdeb.h"
  24. #include "ckcasc.h"
  25. #include "ckcker.h"
  26. #include "ckuusr.h"
  27.  
  28. #ifdef DCMDBUF
  29. char *line;                             /* Character buffer for anything */
  30. char *tmpbuf;
  31. #else
  32. char line[LINBUFSIZ+1];
  33. char tmpbuf[TMPBUFSIZ+1];               /* Temporary buffer */
  34. #endif /* DCMDBUF */
  35.  
  36. #ifndef NOICP
  37.  
  38. #include "ckcnet.h"
  39. #ifndef NOCSETS
  40. #include "ckcxla.h"
  41. #endif /* NOCSETS */
  42. #ifdef MAC
  43. #include "ckmasm.h"
  44. #endif /* MAC */
  45. #ifdef CK_SSL
  46. #include "ck_ssl.h"
  47. #endif /* CK_SSL */
  48.  
  49. #ifdef OS2
  50. #include "ckoetc.h"
  51. #ifndef NT
  52. #define INCL_NOPM
  53. #define INCL_VIO /* Needed for ckocon.h */
  54. #include <os2.h>
  55. #undef COMMENT
  56. #else /* NT */
  57. #include <windows.h>
  58. #define TAPI_CURRENT_VERSION 0x00010004
  59. #include <tapi.h>
  60. #include <mcx.h>
  61. #include "ckntap.h"
  62. #define APIRET ULONG
  63. extern int DialerHandle;
  64. extern int StartedFromDialer;
  65. #endif /* NT */
  66. #include "ckocon.h"
  67. #include "ckokey.h"
  68. #ifdef KUI
  69. #include "ikui.h"
  70. #endif /* KUI */
  71. #ifdef putchar
  72. #undef putchar
  73. #endif /* putchar */
  74. #define putchar(x) conoc(x)
  75. extern int cursor_save ;
  76. extern bool cursorena[] ;
  77. #endif /* OS2 */
  78.  
  79. /* For formatted screens, "more?" prompting, etc. */
  80.  
  81. #ifdef FT18
  82. #define isxdigit(c) isdigit(c)
  83. #endif /* FT18 */
  84.  
  85. #ifdef STRATUS                          /* Stratus Computer, Inc.  VOS */
  86. #ifdef putchar
  87. #undef putchar
  88. #endif /* putchar */
  89. #define putchar(x) conoc(x)
  90. #ifdef getchar
  91. #undef getchar
  92. #endif /* getchar */
  93. #define getchar(x) coninc(0)
  94. #endif /* STRATUS */
  95.  
  96. /* External variables */
  97.  
  98. extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
  99.   binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  100.   inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  101.   zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  102.   debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
  103.   rcdactive, keepallchars;
  104.  
  105. #ifdef LOCUS
  106. extern int locus, autolocus;
  107. #endif /* LOCUS */
  108.  
  109. #ifndef NOMSEND
  110. extern int addlist;
  111. #endif /* NOMSEND */
  112.  
  113. #ifdef CK_SPEED
  114. extern int prefixing;
  115. #endif /* CK_SPEED */
  116.  
  117. extern int g_matchdot;
  118.  
  119. #ifdef RECURSIVE
  120. extern int recursive;
  121. #endif /* RECURSIVE */
  122. extern int xfiletype;
  123.  
  124. #ifdef IKSDCONF
  125. extern char * iksdconf;
  126. extern int iksdcf;
  127. #endif /* IKSDCONF */
  128.  
  129. #ifdef CK_RECALL
  130. extern int on_recall;
  131. #endif /* CK_RECALL */
  132.  
  133. extern int ngetpath, exitonclose;
  134. extern char * getpath[];
  135. extern CHAR * epktmsg;
  136.  
  137. extern char * snd_move;
  138. extern char * snd_rename;
  139. extern char * rcv_move;
  140. extern char * rcv_rename;
  141. extern char * g_snd_move;
  142. extern char * g_snd_rename;
  143. extern char * g_rcv_move;
  144. extern char * g_rcv_rename;
  145.  
  146. extern char * nm[];
  147.  
  148. #ifdef CK_UTSNAME
  149. extern char unm_mch[];
  150. extern char unm_mod[];
  151. extern char unm_nam[];
  152. extern char unm_rel[];
  153. extern char unm_ver[];
  154. #endif /* CK_UTSNAME */
  155.  
  156. #ifndef NOPUSH
  157. #ifndef NOFRILLS
  158. extern char editor[];
  159. extern char editfile[];
  160. extern char editopts[];
  161. #ifdef BROWSER
  162. extern char browser[];
  163. extern char browsopts[];
  164. extern char browsurl[];
  165. #endif /* BROWSER */
  166. #endif /*  NOFRILLS */
  167. #endif /* NOPUSH */
  168.  
  169. #ifndef NOSERVER
  170. extern char * x_user, * x_passwd, * x_acct;
  171. #endif /* NOSERVER */
  172.  
  173. #ifdef CKLOGDIAL
  174. extern int dialog;
  175. extern char diafil[];
  176. #endif /* CKLOGDIAL */
  177.  
  178. #ifdef CKROOT
  179. extern int ckrooterr;
  180. #endif /* CKROOT */
  181.  
  182. #ifndef NOSPL
  183. extern int cfilef, xxdot;
  184. extern char cmdfil[];
  185.  
  186. struct localvar * localhead[CMDSTKL];
  187. struct localvar * localtail = NULL;
  188. struct localvar * localnext = NULL;
  189.  
  190. _PROTOTYP( VOID shosexp, (void) );
  191. _PROTOTYP( static VOID shoinput, (void) );
  192. _PROTOTYP( static char gettok,   (void) );
  193. _PROTOTYP( static VOID factor,   (void) );
  194. _PROTOTYP( static VOID term,     (void) );
  195. _PROTOTYP( static VOID termp,    (void) );
  196. _PROTOTYP( static VOID exprp,    (void) );
  197. _PROTOTYP( static VOID expr,     (void) );
  198. _PROTOTYP( static VOID simple,   (void) );
  199. _PROTOTYP( static VOID simpler,  (void) );
  200. _PROTOTYP( static VOID simplest, (void) );
  201. _PROTOTYP( static long xparse,   (void) );
  202. #endif /* NOSPL */
  203. #ifndef NOSHOW
  204. _PROTOTYP( int sho_iks, (void) );
  205. #endif /* NOSHOW */
  206.  
  207. #ifdef MAC
  208. char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
  209. char * ikprompt = "IKSD>";
  210. #else  /* Not MAC */
  211. #ifdef NOSPL
  212. #ifdef OS2
  213. char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
  214. char * ikprompt = "IKSD> ";
  215. #else
  216. char * ckprompt = "C-Kermit>";
  217. char * ikprompt = "IKSD>";
  218. #endif /* NT */
  219. #else  /* NOSPL */
  220. #ifdef OS2
  221. /* Default prompt for OS/2 and Win32 */
  222. #ifdef NT
  223. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
  224. char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
  225. #else  /* NT */
  226. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  227. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  228. #endif /* NT */
  229. #else  /* OS2 */
  230. #ifdef VMS
  231. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  232. char * ikprompt = "\\v(dir) IKSD>";
  233. #else
  234. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  235. char * ikprompt = "(\\v(dir)) IKSD>";
  236. #endif /* VMS */
  237. #endif /* NT */
  238. #endif /* NOSPL */
  239. #endif /* MAC */
  240.  
  241. #ifndef CCHMAXPATH
  242. #define CCHMAXPATH 257
  243. #endif /* CCHMAXPATH */
  244. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  245.  
  246. #ifdef TNCODE
  247. extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
  248. #endif /* TNCODE */
  249.  
  250. #ifndef NOKVERBS
  251. extern struct keytab kverbs[];          /* Table of \Kverbs */
  252. extern int nkverbs;                     /* Number of \Kverbs */
  253. #endif /* NOKVERBS */
  254.  
  255. #ifndef NOPUSH
  256. extern int nopush;
  257. #endif /* NOPUSH */
  258.  
  259. #ifdef CK_RECALL
  260. extern int cm_recall;
  261. #endif /* CK_RECALL */
  262.  
  263. extern char *ccntab[];
  264.  
  265. /* Printer stuff */
  266.  
  267. extern char *printername;
  268. extern int printpipe;
  269. #ifdef BPRINT
  270. extern int printbidi, pportparity, pportflow;
  271. extern long pportspeed;
  272. #endif /* BPRINT */
  273.  
  274. #ifdef OS2
  275. _PROTOTYP (int os2getcp, (void) );
  276. _PROTOTYP (int os2getcplist, (int *, int) );
  277. #ifdef OS2MOUSE
  278. extern int tt_mouse;
  279. #endif /* OS2MOUSE */
  280. extern int tt_update, tt_updmode, updmode, tt_utf8;
  281. #ifndef IKSDONLY
  282. extern int tt_status[];
  283. #endif /* IKSDONLY */
  284. #ifdef PCFONTS
  285. extern struct keytab term_font[];
  286. #else
  287. #ifdef KUI
  288. extern struct keytab * term_font;
  289. #endif /* KUI */
  290. #endif /* PCFONTS */
  291. extern int ntermfont, tt_font, tt_font_size;
  292. extern unsigned char colornormal, colorunderline, colorstatus,
  293.     colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  294.     colorreverse, colorcmd, coloritalic;
  295. extern int priority;
  296. extern struct keytab prtytab[];
  297. extern int nprty;
  298. char * cmdmac = NULL;
  299. #endif /* OS2 */
  300.  
  301. #ifdef VMS
  302. _PROTOTYP (int zkermini, (char *, int, char *) );
  303. #endif /* VMS */
  304.  
  305. extern long vernum;
  306. extern int inecho, insilence, inbufsize, nvars, inintr;
  307. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  308.  *cknetv, *clcmds;
  309. #ifdef OS2
  310. extern char *ckyv;
  311. #endif /* OS2 */
  312. #ifdef CK_AUTHENTICATION
  313. extern char * ckathv;
  314. #endif /* CK_AUTHENTICATION */
  315. #ifdef CK_SSL
  316. extern char * cksslv;
  317. #endif /* CK_SSL */
  318. #ifdef CK_ENCRYPTION
  319. #ifndef CRYPT_DLL
  320. extern char * ckcrpv;
  321. #endif /* CRYPT_DLL */
  322. #endif /* CK_ENCRYPTION */
  323.  
  324. #ifdef TNCODE
  325. extern char *cktelv;
  326. #endif /* TNCODE */
  327. #ifndef NOFTP
  328. #ifndef SYSFTP
  329. extern char * ckftpv;
  330. #endif /* SYSFTP */
  331. #endif /* NOFTP */
  332.  
  333. extern int srvidl;
  334.  
  335. #ifdef OS2
  336. extern char *ckonetv;
  337. extern int interm;
  338. #ifdef CK_NETBIOS
  339. extern char *ckonbiv;
  340. #endif /* CK_NETBIOS */
  341. #ifdef OS2MOUSE
  342. extern char *ckomouv;
  343. #endif /* OS2MOUSE */
  344. #endif /* OS2 */
  345.  
  346. #ifndef NOLOCAL
  347. extern char *connv;
  348. #endif /* NOLOCAL */
  349. #ifndef NODIAL
  350. extern char *dialv;
  351. #endif /* NODIAL */
  352. #ifndef NOSCRIPT
  353. extern char *loginv;
  354. extern int secho;
  355. #endif /* NOSCRIPT */
  356.  
  357. #ifndef NODIAL
  358. extern int nmdm, dirline;
  359. extern struct keytab mdmtab[];
  360. #endif /* NODIAL */
  361.  
  362. extern int network, nettype, ttnproto;
  363.  
  364. #ifdef OS2
  365. #ifndef NOTERM
  366. /* SET TERMINAL items... */
  367. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  368. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  369. extern char answerback[];
  370. extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
  371. extern int max_tt;
  372. #endif /* NOTERM */
  373. #endif /* OS2 */
  374.  
  375. _PROTOTYP( VOID shotrm, (void) );
  376. _PROTOTYP( int shofea, (void) );
  377.  
  378. #ifdef OS2
  379. extern int tt_rows[], tt_cols[];
  380. #else /* OS2 */
  381. extern int tt_rows, tt_cols;
  382. #endif /* OS2 */
  383. extern int cmd_rows, cmd_cols;
  384.  
  385. #ifdef CK_TMPDIR
  386. extern int f_tmpdir;                    /* Directory changed temporarily */
  387. extern char savdir[];                   /* Temporary directory */
  388. #endif /* CK_TMPDIR */
  389.  
  390. #ifndef NOLOCAL
  391. extern int tt_crd, tt_escape;
  392. #endif /* NOLOCAL */
  393.  
  394. #ifndef NOCSETS
  395. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  396. extern struct keytab fcstab[];
  397. extern struct csinfo fcsinfo[];
  398. #ifndef MAC
  399. extern struct keytab ttcstab[];
  400. #endif /* MAC */
  401. #endif /* NOCSETS */
  402.  
  403. extern long speed;
  404.  
  405. #ifndef NOXMIT
  406. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  407. extern char xmitbuf[];
  408. #endif /* NOXMIT */
  409.  
  410. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  411.  
  412. #ifdef DCMDBUF
  413. extern char *cmdbuf, *atmbuf;           /* Command buffers */
  414. #ifndef NOSPL
  415. extern char *savbuf;                    /* Command buffers */
  416. #endif /* NOSPL */
  417. #else
  418. extern char cmdbuf[], atmbuf[];         /* Command buffers */
  419. #ifndef NOSPL
  420. extern char savbuf[];                   /* Command buffers */
  421. #endif /* NOSPL */
  422. #endif /* DCMDBUF */
  423.  
  424. extern char toktab[], ttname[], psave[];
  425. extern CHAR sstate, feol;
  426. extern int cmflgs, techo, repars, ncmd;
  427. extern struct keytab cmdtab[];
  428.  
  429. #ifndef NOSETKEY
  430. KEY *keymap;
  431. #ifndef OS2
  432. #define mapkey(x) keymap[x]
  433. #endif /* OS2 */
  434. MACRO *macrotab;
  435. _PROTOTYP( VOID shostrdef, (CHAR *) );
  436. #endif /* NOSETKEY */
  437.  
  438. extern int cmdlvl;
  439.  
  440. #ifndef NOSPL
  441. extern struct mtab *mactab;
  442. extern struct keytab mackey[];
  443. extern struct keytab vartab[], fnctab[], iftab[];
  444. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  445. #endif /* NOSPL */
  446.  
  447. FILE *tfile[MAXTAKE];                   /* TAKE file stack */
  448. char *tfnam[MAXTAKE];
  449. int tfline[MAXTAKE];
  450.  
  451. int topcmd = -1;                        /* cmdtab index of current command */
  452. int havetoken = 0;
  453. extern int dblquo;                      /* Doublequoting enabled */
  454.  
  455. #ifdef DCMDBUF                          /* Initialization filespec */
  456. char *kermrc = NULL;
  457. #else
  458. char kermrcb[KERMRCL];
  459. char *kermrc = kermrcb;
  460. #endif /* DCMDBUF */
  461.  
  462. int noherald = 0;
  463. int cm_retry = 1;                       /* Command retry enabled */
  464. xx_strp xxstring = zzstring;
  465.  
  466. #ifndef NOXFER
  467. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  468.   keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  469.   srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  470.   fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  471.  
  472. #ifdef CK_AUTODL
  473. extern int inautodl, cmdadl;
  474. #endif /* CK_AUTODL */
  475.  
  476. #ifndef NOSERVER
  477. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  478.   en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  479.   en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  480. #endif /* NOSERVER */
  481.  
  482. extern int atcapr,
  483.   atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  484.   attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  485.  
  486. #ifdef STRATUS
  487. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  488. #endif /* STRATUS */
  489.  
  490. #ifdef CK_PERMS
  491. extern int atlpri, atlpro, atgpri, atgpro;
  492. #endif /* CK_PERMS */
  493.  
  494. #ifdef CK_LOGIN
  495. extern char * anonfile;                 /* Anonymous login init file */
  496. extern char * anonroot;                 /* Anonymous file-system root */
  497. extern char * userfile;                 /* Forbidden user file */
  498. extern int isguest;                     /* Flag for anonymous user */
  499. #endif /* CK_LOGIN */
  500. #endif /* NOXFER */
  501.  
  502. #ifdef DCMDBUF
  503. int *xquiet = NULL;
  504. #else
  505. int xquiet[CMDSTKL];
  506. #endif /* DCMDBUF */
  507.  
  508. char * prstring[CMDSTKL];
  509.  
  510. #ifndef NOSPL
  511.  
  512. extern long ck_alarm;
  513. extern char alrm_date[], alrm_time[];
  514.  
  515. /* Local declarations */
  516.  
  517. static int nulcmd = 0;                  /* Flag for next cmd to be ignored */
  518.  
  519. /* Definitions for predefined macros */
  520.  
  521. /* First, the single-line macros, installed with addmac()... */
  522.  
  523. /* IBM-LINEMODE macro */
  524. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  525.  
  526. /* FATAL macro */
  527. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  528.  
  529. #ifdef CK_SPEED
  530. #ifdef IRIX65
  531. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  532. #else
  533. #ifdef IRIX
  534. /* Because of bug in telnet server */
  535. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  536.  set pref cautious";
  537. #else
  538. #ifdef pdp11
  539. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  540. #else
  541. #ifdef BIGBUFOK
  542. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  543. #else
  544. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  545. #endif /* BIGBUFOK */
  546. #endif /* IRIX */
  547. #endif /* IRIX65 */
  548. #endif /* pdp11 */
  549. #ifdef pdp11
  550. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  551. #else
  552. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  553. #endif /* pdp11 */
  554. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  555. set reliable off, set clearchannel off";
  556. #else
  557. #ifdef BIGBUFOK
  558. #ifdef IRIX65
  559. char *m_fast = "set win 30, set rec pack 4000";
  560. #else
  561. #ifdef IRIX
  562. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  563. #else
  564. char *m_fast = "set win 30, set rec pack 4000";
  565. #endif /* IRIX */
  566. #endif /* IRIX65 */
  567. #else /* Not BIGBUFOK */
  568. char *m_fast = "set win 4, set rec pack 2200";
  569. #endif /* BIGBUFOK */
  570. char *m_cautious = "set win 4, set rec pack 1000";
  571. char *m_robust = "set win 1, set rec pack 90, set reliable off";
  572. #endif /* CK_SPEED */
  573.  
  574. #ifdef VMS
  575. char *m_purge = "run purge \\%*";
  576. #endif /* VMS */
  577.  
  578. #ifdef OS2
  579. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  580. #endif /* OS2 */
  581.  
  582. /* Now the multiline macros, defined with addmmac()... */
  583.  
  584. /* FOR macro for \%i-style loop variables (see dofor()...) */
  585.  
  586. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  587. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  588. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  589. "def break goto _..bot, def continue goto _..inc,",
  590. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  591. ""};
  592.  
  593. /* This is the FOR macro when the loop variable is itself a macro */
  594.  
  595. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  596. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  597. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  598. "def break goto _..bot, def continue goto _..inc,",
  599. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  600. ""};
  601.  
  602. /* WHILE macro */
  603. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  604. ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
  605. "_def break goto _..bot, _def continue goto _..inc,",
  606. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  607. ""};
  608.  
  609. /* SWITCH macro */
  610. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  611. "_forward \"\\%1\",\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  612. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  613. ""};
  614.  
  615. /* XIF macro */
  616. char *xif_def[] = {
  617. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  618. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  619. ""};
  620.  
  621. /*
  622.   Variables declared here for use by other ckuus*.c modules.
  623.   Space is allocated here to save room in ckuusr.c.
  624. */
  625. #ifdef DCMDBUF
  626. struct cmdptr *cmdstk;
  627. int
  628.   *ifcmd  = NULL,
  629.   *count  = NULL,
  630.   *iftest = NULL,
  631.   *intime = NULL,
  632.   *inpcas = NULL,
  633.   *takerr = NULL,
  634.   *merror = NULL;
  635. #else
  636. struct cmdptr cmdstk[CMDSTKL];
  637. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  638.   inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  639. #endif /* DCMDBUF */
  640.  
  641. /* Macro stack */
  642.  
  643. #ifdef COMMENT
  644. char *topline = NULL;                   /* Program invocation arg line */
  645. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  646. #endif /* COMMENT */
  647.  
  648. char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
  649. int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
  650. char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
  651. int macargc[MACLEVEL];                  /* Argc of each level */
  652. char *macp[MACLEVEL];                   /* Current position in each macro */
  653. char *macx[MACLEVEL];                   /* Beginning of each macro def */
  654. char *mrval[MACLEVEL];                  /* RETURN value at each level */
  655. int lastcmd[MACLEVEL];                  /* Last command at each level */
  656. int topargc = 0;                        /* Argc at top level */
  657. char **topxarg = NULL;                  /* Argv at top level */
  658. char *toparg[MAXARGLIST+2];
  659.  
  660. /* Global Variables */
  661.  
  662. char *g_var[GVARS+1];                   /* Global \%a..z pointers */
  663. extern char varnam[];                   /* \%x variable name buffer */
  664.  
  665. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  666. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  667.  
  668. char **a_ptr[32];                       /* Array pointers, for arrays a-z */
  669. int a_dim[32];                          /* Dimensions for each array */
  670. int a_link[32];                         /* Link (index of linked-to-array) */
  671.  
  672. char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
  673. int aa_dim[CMDSTKL][32];                /* Dimensions for each array */
  674.  
  675. /* INPUT command buffers and variables */
  676.  
  677. char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
  678. extern char * inpbp;                    /* Global/static pointer to it  */
  679. char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
  680. int  incount = 0;                       /* INPUT character count */
  681. extern int instatus;                    /* INPUT status */
  682. static char * i_text[] = {              /* INPUT status text */
  683.     "success", "timeout", "interrupted", "internal error", "i/o error"
  684. };
  685.  
  686. char lblbuf[LBLSIZ];                    /* Buffer for labels */
  687.  
  688. #else  /* NOSPL */
  689.  
  690. int takerr[MAXTAKE];
  691. #endif /* NOSPL */
  692.  
  693. static char *prevdir = NULL;
  694.  
  695. int pacing = 0;                         /* OUTPUT pacing */
  696.  
  697. char *tp;                               /* Temporary buffer pointer */
  698.  
  699. int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */
  700.  
  701. #ifdef CK_APC                           /* Application Program Command (APC) */
  702. int apcactive = APC_INACTIVE;
  703. int apcstatus = APC_OFF;                /* OFF by default everywhere */
  704. #ifdef DCMDBUF
  705. char *apcbuf;
  706. #else
  707. char apcbuf[APCBUFLEN];
  708. #endif /* DCMDBUF */
  709. #endif /* CK_APC */
  710.  
  711. extern char pktfil[],
  712. #ifdef DEBUG
  713.   debfil[],
  714. #endif /* DEBUG */
  715. #ifdef TLOG
  716.   trafil[],
  717. #endif /* TLOG */
  718.   sesfil[];
  719.  
  720. #ifndef NOFRILLS
  721. extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
  722. extern char optbuf[];
  723. #endif /* NOFRILLS */
  724.  
  725. extern int noinit;            /* Flat to skip init file */
  726.  
  727. #ifndef NOSPL
  728. static struct keytab kcdtab[] = {    /* Symbolic directory names */
  729. #ifdef NT
  730.     { "appdata",  VN_APPDATA,   0 },
  731.     { "common",   VN_COMMON,    0 },
  732.     { "desktop",  VN_DESKTOP,   0 },
  733. #endif /* NT */
  734.     { "download", VN_DLDIR,     0 },
  735. #ifdef OS2ORUNIX
  736.     { "exedir",   VN_EXEDIR,    0 },
  737. #endif /* OS2ORUNIX */
  738.     { "home",     VN_HOME,      0 },
  739.     { "inidir",   VN_INI,       0 },
  740. #ifdef UNIX
  741.     { "lockdir",  VN_LCKDIR,    0 },
  742. #endif /* UNIX */
  743. #ifdef NT
  744.     { "personal", VN_PERSONAL,  0 },
  745. #endif /* NT */
  746.     { "startup",  VN_STAR,      0 },
  747.     { "textdir",  VN_TXTDIR,    0 },
  748.     { "tmpdir",   VN_TEMP,      0 }
  749. };
  750. static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
  751. #endif /* NOSPL */
  752.  
  753. #ifndef NOSPL
  754. _PROTOTYP( VOID freelocal, (int) );
  755. _PROTOTYP( static long expon, (long, long) );
  756. _PROTOTYP( static long gcd, (long, long) );
  757. _PROTOTYP( static long fact, (long) );
  758.  
  759. int                     /* Initialize macro data structures. */
  760. macini() {              /* Allocate mactab and preset the first element. */
  761.     int i;
  762.     if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  763.       return(-1);
  764.     mactab[0].kwd = NULL;
  765.     mactab[0].mval = NULL;
  766.     mactab[0].flgs = 0;
  767.     for (i = 0; i < MACLEVEL; i++)
  768.       localhead[i] = NULL;
  769.     return(0);
  770. }
  771. #endif /* NOSPL */
  772.  
  773. /*  C M D S R C  --  Returns current command source  */
  774.  
  775. /*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  776.  
  777. /*
  778.   As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  779.   xcmdsrc can be checked instead to save the overhead of a function call.
  780. */
  781. int
  782. cmdsrc() {
  783. #ifdef COMMENT
  784.     return(xcmdsrc);
  785. #else
  786. #ifndef NOSPL
  787.     if (cmdlvl == 0)
  788.       return(0);
  789.     else if (cmdstk[cmdlvl].src == CMD_MD)
  790.       return(2);
  791.     else if (cmdstk[cmdlvl].src == CMD_TF)
  792.       return(1);
  793.     else
  794.       return(-1);
  795. #else
  796.     if (tlevel < 0)
  797.       return(0);
  798.     else
  799.       return(1);
  800. #endif /* NOSPL */
  801. #endif /* COMMENT */
  802. }
  803.  
  804. /*  C M D I N I  --  Initialize the interactive command parser  */
  805.  
  806. static int cmdinited = 0;               /* Command parser initialized */
  807. extern int cmdint;                      /* Interrupts are allowed */
  808. #ifdef CK_AUTODL
  809. int cmdadl = 1;                         /* Autodownload */
  810. #else
  811. int cmdadl = 0;
  812. #endif /* CK_AUTODL */
  813.  
  814. char * k_info_dir = NULL;               /* Where to find text files */
  815. #ifdef UNIX
  816. static char * txtdir[] = {
  817.     "/usr/local/doc/",                  /* Linux, SunOS, ... */
  818.     "/usr/share/lib/",                  /* HP-UX 10.xx... */
  819.     "/usr/share/doc/",                  /* Other possibilities... */
  820.     "/usr/local/lib/",                  /* NOTE: Each of these is tried */
  821.     "/usr/local/share/",                /* as is, and also with a kermit */
  822.     "/usr/local/share/doc/",            /* subdirectory. */
  823.     "/usr/local/share/lib/",
  824.     "/opt/kermit/",                     /* Solaris */
  825.     "/opt/kermit/doc/",
  826.     "/opt/",
  827.     "/usr/doc/",
  828.     "/doc/",
  829.     ""
  830. };
  831. #endif /* UNIX */
  832.  
  833. /*
  834.   lookup() cache to speed up script execution.
  835.  
  836.   This is a static cache.  Items are stored in decreasing frequency of
  837.   reference based on statistics from a range of scripts.  This gives
  838.   better performance than a dynamic cache, which would require a lot more
  839.   code and also would require system-dependent elements including system
  840.   calls (e.g. to get subsecond times for entry aging).
  841. */
  842. #ifdef USE_LUCACHE                      /* Set in ckuusr.h */
  843. #define LUCACHE 32                      /* Change this to reduce cache size */
  844. int lusize = 0;
  845. char * lucmd[LUCACHE];
  846. int luval[LUCACHE];
  847. int luidx[LUCACHE];
  848. struct keytab * lutab[LUCACHE];
  849. #endif /* USE_LUCACHE */
  850.  
  851. static VOID
  852. luinit() {                              /* Initialize lookup() cache */
  853.     int x, y;
  854.  
  855. #ifdef USE_LUCACHE
  856.     x = lookup(cmdtab,"if",ncmd,&y);
  857.     lucmd[lusize] = "if";
  858.     luval[lusize] = x;
  859.     luidx[lusize] = y;
  860.     lutab[lusize] = cmdtab;
  861.     if (++lusize > LUCACHE) return;
  862.  
  863.     x = lookup(iftab,"not",nif,&y);
  864.     lucmd[lusize] = "not";
  865.     luval[lusize] = x;
  866.     luidx[lusize] = y;
  867.     lutab[lusize] = iftab;
  868.     if (++lusize > LUCACHE) return;
  869.  
  870.     x = lookup(vartab,"cmdlevel",nvars,&y);
  871.     lucmd[lusize] = "cmdlevel";
  872.     luval[lusize] = x;
  873.     luidx[lusize] = y;
  874.     lutab[lusize] = vartab;
  875.     if (++lusize > LUCACHE) return;
  876.  
  877.     x = lookup(cmdtab,"goto",ncmd,&y);
  878.     lucmd[lusize] = "goto";
  879.     luval[lusize] = x;
  880.     luidx[lusize] = y;
  881.     lutab[lusize] = cmdtab;
  882.     if (++lusize > LUCACHE) return;
  883.  
  884.     x = lookup(iftab,">",nif,&y);
  885.     lucmd[lusize] = ">";
  886.     luval[lusize] = x;
  887.     luidx[lusize] = y;
  888.     lutab[lusize] = iftab;
  889.     if (++lusize > LUCACHE) return;
  890.  
  891.     x = lookup(cmdtab,"incr",ncmd,&y);
  892.     lucmd[lusize] = "incr";
  893.     luval[lusize] = x;
  894.     luidx[lusize] = y;
  895.     lutab[lusize] = cmdtab;
  896.     if (++lusize > LUCACHE) return;
  897.  
  898.     x = lookup(cmdtab,"def",ncmd,&y);
  899.     lucmd[lusize] = "def";
  900.     luval[lusize] = x;
  901.     luidx[lusize] = y;
  902.     lutab[lusize] = cmdtab;
  903.     if (++lusize > LUCACHE) return;
  904.  
  905.     x = lookup(cmdtab,"_assign",ncmd,&y);
  906.     lucmd[lusize] = "_assign";
  907.     luval[lusize] = x;
  908.     luidx[lusize] = y;
  909.     lutab[lusize] = cmdtab;
  910.     if (++lusize > LUCACHE) return;
  911.  
  912.     x = lookup(cmdtab,"echo",ncmd,&y);
  913.     lucmd[lusize] = "echo";
  914.     luval[lusize] = x;
  915.     luidx[lusize] = y;
  916.     lutab[lusize] = cmdtab;
  917.     if (++lusize > LUCACHE) return;
  918.  
  919.     x = lookup(fnctab,"eval",nfuncs,&y);
  920.     lucmd[lusize] = "eval";
  921.     luval[lusize] = x;
  922.     luidx[lusize] = y;
  923.     lutab[lusize] = fnctab;
  924.     if (++lusize > LUCACHE) return;
  925.  
  926.     x = lookup(fnctab,"lit",nfuncs,&y);
  927.     lucmd[lusize] = "lit";
  928.     luval[lusize] = x;
  929.     luidx[lusize] = y;
  930.     lutab[lusize] = fnctab;
  931.     if (++lusize > LUCACHE) return;
  932.  
  933.     x = lookup(cmdtab,"do",ncmd,&y);
  934.     lucmd[lusize] = "do";
  935.     luval[lusize] = x;
  936.     luidx[lusize] = y;
  937.     lutab[lusize] = cmdtab;
  938.     if (++lusize > LUCACHE) return;
  939.  
  940.     x = lookup(cmdtab,"_getargs",ncmd,&y);
  941.     lucmd[lusize] = "_getargs";
  942.     luval[lusize] = x;
  943.     luidx[lusize] = y;
  944.     lutab[lusize] = cmdtab;
  945.     if (++lusize > LUCACHE) return;
  946.  
  947.     x = lookup(iftab,"<",nif,&y);
  948.     lucmd[lusize] = "<";
  949.     luval[lusize] = x;
  950.     luidx[lusize] = y;
  951.     lutab[lusize] = iftab;
  952.     if (++lusize > LUCACHE) return;
  953.  
  954.     x = lookup(cmdtab,"_putargs",ncmd,&y);
  955.     lucmd[lusize] = "_putargs";
  956.     luval[lusize] = x;
  957.     luidx[lusize] = y;
  958.     lutab[lusize] = cmdtab;
  959.     if (++lusize > LUCACHE) return;
  960.  
  961.     x = lookup(cmdtab,"asg",ncmd,&y);
  962.     lucmd[lusize] = "asg";
  963.     luval[lusize] = x;
  964.     luidx[lusize] = y;
  965.     lutab[lusize] = cmdtab;
  966.     if (++lusize > LUCACHE) return;
  967.  
  968.     x = lookup(cmdtab,"else",ncmd,&y);
  969.     lucmd[lusize] = "else";
  970.     luval[lusize] = x;
  971.     luidx[lusize] = y;
  972.     lutab[lusize] = cmdtab;
  973. #endif /* USE_LUCACHE */
  974. }
  975.  
  976. VOID
  977. cmdini() {
  978.     int i = 0, x = 0, y = 0, z = 0, skip = 0;
  979.     char * p;
  980. #ifdef TTSPDLIST
  981.     long * ss = NULL;
  982.     extern int nspd;
  983.     extern struct keytab * spdtab;
  984. #endif /* TTSPDLIST */
  985.  
  986. #ifndef NOSPL
  987. /*
  988.   On stack to allow recursion!
  989. */
  990.     char vnambuf[VNAML];                /* Buffer for variable names */
  991. #endif /* NOSPL */
  992.  
  993.     if (cmdinited)                      /* Already initialized */
  994.       return;                           /* Don't do it again */
  995.  
  996.     for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
  997.       prstring[i] = NULL;               /* command level */
  998.  
  999. #ifndef NOCSETS
  1000.     p = getenv("K_CHARSET");            /* Set default file character set */
  1001.     if (p) {                            /* from environment */
  1002.         x = lookup(fcstab,p,nfilc,&y);
  1003.         if (x > -1)
  1004.           fcharset = x;
  1005.     }
  1006. #endif /* NOCSETS */
  1007.  
  1008.     p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
  1009.     if (p && *p && strlen(p) <= CKMAXPATH)
  1010.       makestr(&k_info_dir,p);
  1011.     if (!k_info_dir) {
  1012.         p = getenv("K_INFO_DIR");
  1013.         if (p && *p && strlen(p) <= CKMAXPATH)
  1014.           makestr(&k_info_dir,p);
  1015.     }
  1016. #ifdef UNIX
  1017.     if (k_info_dir) {                   /* Look for Kermit docs directory */
  1018.         if (zchki(k_info_dir) == -2) {
  1019.             char xbuf[CKMAXPATH+32], *s = "";
  1020.             if (ckrchar(k_info_dir) != '/')
  1021.               s = "/";
  1022.             ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  1023.             if (zchki(xbuf) < 0)
  1024.               makestr(&k_info_dir,NULL);
  1025.         }
  1026.     }
  1027.     if (!k_info_dir) {
  1028.         char xbuf[CKMAXPATH+32];
  1029.         int i;
  1030.         for (i = 0; *(txtdir[i]); i++) {
  1031.             ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  1032.             if (zchki(xbuf) > 0) {
  1033.                 makestr(&k_info_dir,txtdir[i]);
  1034.                 debug(F110,"k_info_dir 1",k_info_dir,0);
  1035.                 break;
  1036.             }
  1037.             ckmakmsg(xbuf,CKMAXPATH+32,
  1038.                      txtdir[i],"kermit/","ckubwr.txt",NULL);
  1039.             if (zchki(xbuf) > 0) {
  1040.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  1041.                 makestr(&k_info_dir,xbuf);
  1042.                 debug(F110,"k_info_dir 2",k_info_dir,0);
  1043.                 break;
  1044.             }
  1045.         }
  1046.         if (k_info_dir) {               /* Make sure it ends with "/" */
  1047.             if (ckrchar(k_info_dir) != '/') {
  1048.                 char xbuf[CKMAXPATH+32];
  1049.                 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1050.                 makestr(&k_info_dir,xbuf);
  1051.             }
  1052.         }
  1053.     }
  1054. #else
  1055. #ifdef OS2
  1056.     {
  1057.         char xdir[CKMAXPATH+8], *s = "";
  1058.         extern char startupdir[];
  1059.         xdir[0] = NUL;
  1060.         if (ckrchar(startupdir) != '/')
  1061.           s = "/";
  1062.         if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1063.           ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1064.         makestr(&k_info_dir,xdir);
  1065.     }
  1066. #endif /* OS2 */
  1067. #endif /* UNIX */
  1068.  
  1069. #ifdef TTSPDLIST
  1070.     if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1071.         int j, k, m = 0, n;             /* Create sorted keyword table */
  1072.         char buf[16];
  1073.         char * p;
  1074.         if ((spdtab =
  1075.              (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1076.             for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1077.                 if (ss[i] < 1L) break;     /* Shouldn't happen */
  1078.                 buf[0] = NUL;              /* Make string */
  1079.                 sprintf(buf,"%ld",ss[i]);  /* SAFE */
  1080.                 if (ss[i] == 8880L)
  1081.                   ckstrncpy(buf,"75/1200",sizeof(buf));
  1082.                 if (ss[i] == 134L)
  1083.                   ckstrncat(buf,".5",16);
  1084.                 n = strlen(buf);
  1085.                 if ((n > 0) && (p = (char *)malloc(n+1))) {
  1086.                     if (m > 0) {        /* Have at least one in list */
  1087.                         for (j = 0;     /* Find slot */
  1088.                              j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1089.                              j++
  1090.                              )
  1091.                           ;
  1092.                         if (j < m) {    /* Must insert */
  1093.                             for (k = m-1; k >= j; k--) { /* Move others down */
  1094.                                 spdtab[k+1].kwd = spdtab[k].kwd;
  1095.                                 spdtab[k+1].flgs = spdtab[k].flgs;
  1096.                                 spdtab[k+1].kwval = spdtab[k].kwval;
  1097.                             }
  1098.                         }
  1099.                     } else              /* First one */
  1100.                       j = 0;
  1101.                     ckstrncpy(p,buf,n+1); /* Add new speed */
  1102.                     spdtab[j].kwd = p;
  1103.                     spdtab[j].flgs = 0;
  1104.                     spdtab[j].kwval = (int) ss[i] / 10;
  1105.                     m++;                /* Count this one */
  1106.                 }
  1107.             }
  1108.         }
  1109.         nspd = m;
  1110.     }
  1111. #endif /* TTSPDLIST */
  1112.  
  1113. #ifndef NOSPL
  1114.     /* Allocate INPUT command buffer */
  1115.     if (!inpbuf) {
  1116.         if (!(inpbuf = (char *) malloc(INPBUFSIZ+1)))
  1117.           fatal("cmdini: no memory for INPUT buffer");
  1118.     }
  1119.     for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
  1120.       inpbuf[x] = NUL;
  1121.     inpbp = inpbuf;                     /* Initialize pointer */
  1122.     inbufsize = INPBUFSIZ;              /* and size. */
  1123. #endif /* NOSPL */
  1124.  
  1125. #ifdef DCMDBUF
  1126.     if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1127.  
  1128. #ifndef NOSPL
  1129.     /* Allocate command stack allowing command parser to call itself */
  1130.  
  1131.     if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1132.       fatal("cmdini: no memory for cmdstk");
  1133.     if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1134.       fatal("cmdini: no memory for ifcmd");
  1135.     if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1136.       fatal("cmdini: no memory for count");
  1137.     if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1138.       fatal("cmdini: no memory for iftest");
  1139.     if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1140.       fatal("cmdini: no memory for intime");
  1141.     if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1142.       fatal("cmdini: no memory for inpcas");
  1143.     if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1144.       fatal("cmdini: no memory for takerr");
  1145.     if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1146.       fatal("cmdini: no memory for merror");
  1147.     if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1148.       fatal("cmdini: no memory for xquiet");
  1149.     if (!kermrc)
  1150.       if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1151.         fatal("cmdini: no memory for kermrc");
  1152. #ifdef CK_APC
  1153. /* Application Program Command buffer */
  1154.     if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1155.         fatal("cmdini: no memory for apcbuf");
  1156. #endif /* CK_APC */
  1157. #endif /* NOSPL */
  1158.  
  1159. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1160.  
  1161.     if (!(line = malloc(LINBUFSIZ + 1)))
  1162.         fatal("cmdini: no memory for line");
  1163.     if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1164.         fatal("cmdini: no memory for tmpbuf");
  1165. #endif /* DCMDBUF */
  1166.  
  1167. #ifndef NOSPL
  1168. #ifdef CK_MINPUT
  1169.     {                                   /* Initialize MINPUT pointers */
  1170.         int i;
  1171.         extern char *ms[];
  1172.         for (i = 0; i < MINPMAX; i++)
  1173.           ms[i] = NULL;
  1174.     }
  1175. #endif /* CK_MINPUT */
  1176.  
  1177.     if (macini() < 0)                   /* Allocate macro buffers */
  1178.       fatal("Can't allocate macro buffers!");
  1179.  
  1180.     ifcmd[0] = 0;                       /* Command-level related variables. */
  1181.     iftest[0] = 0;                      /* Initialize variables at top level */
  1182.     count[0] = 0;                       /* of stack... */
  1183.     intime[0] = 0;
  1184.     inpcas[0] = 0;
  1185.     takerr[0] = 0;
  1186.     merror[0] = 0;
  1187.     xquiet[0] = quiet;
  1188. #endif /* NOSPL */
  1189.  
  1190. #ifndef NOSPL
  1191.     cmdlvl = 0;                         /* Initialize the command stack */
  1192.     xcmdsrc = CMD_KB;
  1193.     cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
  1194.     cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
  1195.     cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
  1196. #endif /* NOSPL */
  1197.  
  1198.     tlevel = -1;                        /* Take file level = keyboard */
  1199.     for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
  1200.       tfnam[i] = NULL;
  1201.  
  1202.     cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
  1203.                                         /* Can't set IKSD prompt here since */
  1204.                                         /* we do not yet know if we are IKSD */
  1205. #ifndef NOSPL
  1206.  
  1207.     initmac();                          /* Initialize macro table */
  1208.  
  1209. /* Predefine built-in one-line macros */
  1210.  
  1211.     addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
  1212.     addmac("fatal",m_fat);              /* FATAL macro */
  1213.     y = addmac("fast",m_fast);          /* FAST macro */
  1214.     addmac("cautious",m_cautious);      /* CAUTIOUS macro */
  1215.     addmac("robust",m_robust);          /* ROBUST macro */
  1216. #ifdef OS2
  1217.     addmac("manual",m_manual);          /* MANUAL macro */
  1218. #endif /* OS2 */
  1219. #ifdef VMS
  1220.     addmac("purge",m_purge);            /* PURGE macro */
  1221. #endif /* VMS */
  1222.  
  1223. /*
  1224.   Predefine built-in multiline macros; these are top-level commands
  1225.   that are implemented internally as macros.  NOTE: When adding a new
  1226.   one of these, remember to update the END and RETURN commands to
  1227.   account for it, or else END and RETURN from within it won't work right.
  1228. */
  1229.     x = addmmac("_forx",for_def);       /* FOR macro */
  1230.     if (x > -1) mactab[x].flgs = CM_INV;
  1231.     x = addmmac("_forz",foz_def);       /* Other FOR macro */
  1232.     if (x > -1) mactab[x].flgs = CM_INV;
  1233.     x = addmmac("_xif",xif_def);        /* XIF macro */
  1234.     if (x > -1) mactab[x].flgs = CM_INV;
  1235.     x = addmmac("_while",whil_def);     /* WHILE macro */
  1236.     if (x > -1) mactab[x].flgs = CM_INV;
  1237.     x = addmmac("_switx",sw_def);       /* SWITCH macro */
  1238.     if (x > -1) mactab[x].flgs = CM_INV;
  1239.  
  1240. /* Fill in command-line argument vector */
  1241.  
  1242.     sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
  1243.     if (inserver) {                     /* But hidden in IKSD */
  1244.         y = -1;
  1245.         xargs = 0;
  1246.     } else
  1247.       y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */
  1248.  
  1249.     tmpbuf[0] = NUL;
  1250.     if (y > -1) {
  1251.         int j = -1;
  1252.         int yy = 0;
  1253.         dclarray((char)x,z);            /* Declare the array */
  1254. #ifndef NOTAKEARGS
  1255.         /* Macro argument vector */
  1256.         sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
  1257.         yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
  1258.         if (yy > -1)                    /* Name is OK */
  1259.           dclarray((char)x,z);          /* Declare the array */
  1260. #endif /* NOTAKEARGS */
  1261.         skip = 0;
  1262.         for (i = 0; i < xargs; i++) {   /* Fill the arrays */
  1263.             sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1264.             addmac(vnambuf,xargv[i]);
  1265.             if (cfilef && i == 0)
  1266.               continue;
  1267. #ifdef KERBANG
  1268.             if (skip) {
  1269.                 j = 0;
  1270.                 skip = 0;
  1271.                 continue;
  1272.             }
  1273. #endif /* KERBANG */
  1274.             if (j < 0 &&                /* Assign items after "=" or "--"*/
  1275.                 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1276.                 ) {
  1277.                 j = 0;                  /* to \%1..\%9 */
  1278. #ifdef KERBANG
  1279.             } else if (j < 0 &&
  1280.                        (!strcmp(xargv[i],"+") ||
  1281.                         !strncmp(xargv[i],"+ ",2) ||
  1282.                         !strncmp(xargv[i],"+\t",2))
  1283.                         ) {
  1284.                 skip = 1;
  1285.                 continue;
  1286. #endif /* KERBANG */
  1287.             } else if (j > -1) {
  1288.                 j++;
  1289.                 if (j <= 9) {
  1290.                     vnambuf[0] = '\\';
  1291.                     vnambuf[1] = '%';
  1292.                     vnambuf[2] = (char)(j+'0');
  1293.                     vnambuf[3] = NUL;
  1294.                     addmac(vnambuf,xargv[i]);
  1295.                 }
  1296.                 if (yy > -1) {
  1297.                     char c, * p;
  1298.                     int flag = 0;
  1299.                     p = xargv[i];
  1300.                     makestr(&(toparg[j]),p);
  1301.                     while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1302.                     if (flag)
  1303.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1304.                     ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1305.                     if (flag)
  1306.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1307.                     ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1308.                 }
  1309.             }
  1310.         }
  1311.         if (cfilef) {
  1312.             addmac("\\%0",cmdfil);
  1313.             if (yy > -1)
  1314.               makestr(&(toparg[0]),cmdfil);
  1315.         } else {
  1316.             addmac("\\%0",xargv[0]);
  1317.             if (yy > -1)
  1318.               makestr(&(toparg[0]),xargv[0]);
  1319.         }
  1320.         if (yy > -1) {
  1321.             topargc = (j < 0) ? 1 : j + 1;
  1322.             topxarg = toparg;
  1323. #ifdef COMMENT
  1324.             /* This needs work */
  1325.             if (!cfilef)
  1326.               makestr(&topline,tmpbuf);
  1327. #endif /* COMMENT */
  1328.         } else {
  1329.             topargc = 0;
  1330.             topxarg = NULL;
  1331.         }
  1332.         a_dim[0] = topargc - 1;
  1333.         a_ptr[0] = topxarg;
  1334.     debug(F111,"a_dim[0]","A",a_dim[0]);
  1335.     }
  1336.     *vnambuf = NUL;
  1337. #endif /* NOSPL */
  1338.  
  1339.     luinit();                           /* Initialize lookup() cache */
  1340.  
  1341. /* Get our home directory now.  This needed in lots of places. */
  1342.  
  1343.     cmdinited = 1;
  1344. }
  1345.  
  1346. #ifdef NT
  1347. _PROTOTYP(char * GetAppData,(int));
  1348. #endif /* NT */
  1349.  
  1350. VOID
  1351. doinit() {
  1352. #ifdef CKROOT
  1353. extern int ckrooterr;
  1354. #endif /* CKROOT */
  1355.     int x = 0, ok = 0;
  1356. #ifdef OS2
  1357.     char * ptr = 0;
  1358. #endif /* OS2 */
  1359.  
  1360.     if (!cmdinited)
  1361.       cmdini();
  1362.  
  1363. #ifdef MAC
  1364.     return;                             /* Mac Kermit has no init file */
  1365.  
  1366. #else /* !MAC */
  1367.  
  1368. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1369.  
  1370.     if (noinit) {
  1371.         kermrc[0] = '\0';
  1372.         inidir[0] = '\0';
  1373. /*
  1374.   But returning from here results in inidir[] never being set to anything.
  1375.   Instead it should be set to wherever the init file *would* have been
  1376.   executed from.  So this bit of code should be removed, and then we should
  1377.   sprinkle "if (noinit)" tests throughout the following code until we have
  1378.   set inidir[], and then return without actually taking the init file.
  1379. */
  1380.         return;
  1381.     }
  1382.  
  1383. #ifdef OS2
  1384. /*
  1385.   The -y init file must be fully specified or in the current directory.
  1386.   KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  1387.   own executable file path is taken and the .EXE suffix is replaced by .INI
  1388.   and this is tried as the initialization file.
  1389. */
  1390. #ifdef CK_LOGIN
  1391.     debug(F101,"doinit inserver","",inserver);
  1392.     debug(F101,"doinit isguest","",isguest);
  1393.     debug(F110,"doinit anonfile",anonfile,0);
  1394.  
  1395.     if (isguest && anonfile) {
  1396.       ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1397.     } else
  1398. #endif /* CK_LOGIN */
  1399.       if (rcflag) {
  1400.           ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1401. #ifdef CK_LOGIN
  1402.       } else if (inserver) {
  1403.           char * appdata = NULL;
  1404. #ifdef NT
  1405.           appdata = GetAppData(1);
  1406.           if ( appdata ) {
  1407.               ckmakmsg(line,LINBUFSIZ+1,appdata,
  1408.                         "Kermit 95/k95.ini",NULL,NULL);
  1409.               if ( zchki(line) < 0 )
  1410.                   line[0] = '\0';
  1411.           }
  1412.           if (line[0] == 0) {
  1413.               appdata = GetAppData(0);
  1414.               if ( appdata ) {
  1415.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1416.                             "Kermit 95/k95.ini",NULL,NULL);
  1417.                   if ( zchki(line) < 0 )
  1418.                       line[0] = '\0';
  1419.               }
  1420.           }
  1421. #endif /* NT */
  1422.           if (line[0] == 0) {
  1423.               appdata = zhome();
  1424.               if ( appdata ) {
  1425.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1426. #ifdef NT
  1427.                           "k95.ini",
  1428. #else /* NT */
  1429.                           "k2.ini",
  1430. #endif /* NT */
  1431.                            NULL,NULL);
  1432.                   if ( zchki(line) < 0 )
  1433.                       line[0] = '\0';
  1434.               }
  1435.           }
  1436.           debug(F110,"doinit inserver inifile",line,0);
  1437. #endif /* CK_LOGIN */
  1438.     } else {
  1439.         char * env = 0;
  1440. #ifdef NT
  1441.         env = getenv("K95.KSC");
  1442. #else
  1443.         env = getenv("K2.KSC");
  1444. #endif /* NT */
  1445.         if (!env) {
  1446. #ifdef NT
  1447.             env = getenv("K95.INI");
  1448. #else
  1449.             env = getenv("K2.INI");
  1450. #endif /* NT */
  1451.         }
  1452.         if (!env)
  1453.           env = getenv("CKERMIT.INI");
  1454.         if (!env)
  1455.           env = getenv("CKERMIT_INI");
  1456.         line[0] = '\0';
  1457.  
  1458.         debug(F110,"doinit env",env,0);
  1459.         if (env)
  1460.           ckstrncpy(line,env,LINBUFSIZ+1);
  1461.  
  1462. #ifdef NT
  1463.         if (line[0] == 0) {
  1464.             env = GetAppData(1);
  1465.             if ( env ) {
  1466.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1467.                 if ( zchki(line) < 0 )
  1468.                     line[0] = '\0';
  1469.             }
  1470.         }
  1471.         if (line[0] == 0) {
  1472.             env = GetAppData(0);
  1473.             if ( env ) {
  1474.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1475.                 if ( zchki(line) < 0 )
  1476.                     line[0] = '\0';
  1477.             }
  1478.         }
  1479. #endif /* NT */
  1480.  
  1481.         if (line[0] == 0) {
  1482.             env = zhome();
  1483.             if ( env ) {
  1484.                 ckmakmsg(line,LINBUFSIZ+1,env,
  1485. #ifdef NT
  1486.                           "k95.ini",
  1487. #else /* NT */
  1488.                           "k2.ini",
  1489. #endif /* NT */
  1490.                           NULL,NULL);
  1491.                 if ( zchki(line) < 0 )
  1492.                     line[0] = '\0';
  1493.             }
  1494.         }
  1495.  
  1496.         if (line[0] == 0)
  1497.           _searchenv(kermrc,"INIT",line);
  1498.         if (line[0] == 0)
  1499.           _searchenv(kermrc,"DPATH",line);
  1500.         if (line[0] == 0)
  1501.           _searchenv(kermrc,"PATH",line);
  1502.         if (line[0] == 0) {
  1503.             char *pgmptr = GetLoadPath();
  1504.             if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1505.                 lp = strrchr(pgmptr, '\\');
  1506.                 if (lp) {
  1507.                     strncpy(line, pgmptr, lp - pgmptr);
  1508. #ifdef NT
  1509.                     strcpy(line + (lp - pgmptr), "/k95.ini");
  1510. #else /* NT */
  1511.                     strcpy(line + (lp - pgmptr), "/k2.ini");
  1512. #endif /* NT */
  1513.                 } else {
  1514.                     lp = strrchr(pgmptr, '.');
  1515.                     if (lp) {
  1516.                         strncpy(line, pgmptr, lp - pgmptr);
  1517.                         strcpy(line + (lp - pgmptr), ".ini");
  1518.                     }
  1519.                 }
  1520.             }
  1521.         }
  1522.     }
  1523.  
  1524. #ifdef CKROOT
  1525.     if (!zinroot(line)) {
  1526.         debug(F110,"doinit setroot violation",line,0);
  1527.         return;
  1528.     }
  1529. #endif /* CKROOT */
  1530.  
  1531.     debug(F110,"doinit fopen()",line,0);
  1532.     if ((tfile[0] = fopen(line,"r")) != NULL) {
  1533.         ok = 1;
  1534.         tlevel = 0;
  1535.         tfline[tlevel] = 0;
  1536.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1537.           strcpy(tfnam[tlevel],line);   /* safe */
  1538. #ifndef NOSPL
  1539.         cmdlvl++;
  1540.         xcmdsrc = CMD_TF;
  1541.         cmdstk[cmdlvl].src = CMD_TF;
  1542.         cmdstk[cmdlvl].lvl = tlevel;
  1543.         cmdstk[cmdlvl].ccflgs = 0;
  1544.         ifcmd[cmdlvl] = 0;
  1545.         iftest[cmdlvl] = 0;
  1546.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1547.         intime[cmdlvl] = intime[cmdlvl-1];
  1548.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1549.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1550.         merror[cmdlvl] = merror[cmdlvl-1];
  1551.         xquiet[cmdlvl] = quiet;
  1552. #endif /* NOSPL */
  1553.         debug(F110,"doinit init file",line,0);
  1554.     } else {
  1555.         debug(F100,"doinit no init file","",0);
  1556.     }
  1557.     ckstrncpy(kermrc,line,KERMRCL);
  1558.     for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
  1559.        if (*ptr == '\\')
  1560.          *ptr = '/';
  1561. #else /* not OS2 */
  1562.     lp = line;
  1563.     lp[0] = '\0';
  1564.     debug(F101,"doinit rcflag","",rcflag);
  1565. #ifdef GEMDOS
  1566.     zkermini(line, rcflag, kermrc);
  1567. #else
  1568. #ifdef VMS
  1569.     {
  1570.     int x;
  1571.     x = zkermini(line,LINBUFSIZ,kermrc);
  1572.     debug(F111,"CUSTOM zkermini",line,x);
  1573.     if (x == 0)
  1574.       line[0] = NUL;
  1575.     }
  1576. #else /* not VMS */
  1577. #ifdef CK_LOGIN
  1578.     debug(F101,"doinit isguest","",isguest);
  1579.     if (isguest)
  1580.       ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1581.     else
  1582. #endif /* CK_LOGIN */
  1583.       if (rcflag) {                     /* If init file name from cmd line */
  1584.           ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1585.       } else {                          /* otherwise... */
  1586. #ifdef CK_INI_A                         /* If we've a system-wide init file */
  1587.           /* And it takes precedence over the user's... */
  1588.           ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1589.           if (zchki(lp) < 0) {          /* (if it exists...) */
  1590. #endif /* CK_INI_A */
  1591.               char * homdir;
  1592.               char * env = 0;
  1593.               line[0] = NUL;
  1594.  
  1595.               /* Add support for environment variable */
  1596.               env = getenv("CKERMIT.INI");
  1597.               if (!env)
  1598.                 env = getenv("CKERMIT_INI");
  1599.               if (env)
  1600.                 ckstrncpy(lp,env,KERMRCL);
  1601.  
  1602.               if (lp[0] == 0) {
  1603.                   homdir = zhome();
  1604.                   if (homdir) {         /* Home directory for init file. */
  1605.                       ckstrncpy(lp,homdir,KERMRCL);
  1606. #ifdef STRATUS
  1607.                       ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1608. #else
  1609.                       if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1610. #endif /* STRATUS */
  1611.                   }
  1612.                   ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1613.               }
  1614. #ifdef CK_INI_A
  1615.           }
  1616. #endif /* CK_INI_A */
  1617. #ifdef CK_INI_B                         /* System-wide init defined? */
  1618.           /* But user's ini file takes precedence */
  1619.           if (zchki(lp) < 0)            /* If user doesn't have her own, */
  1620.             ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1621. #endif /* CK_INI_B */
  1622.       }
  1623. #endif /* VMS */
  1624. #endif /* GEMDOS */
  1625.  
  1626. #ifdef AMIGA
  1627.     reqoff();                           /* Disable requestors */
  1628. #endif /* AMIGA */
  1629.  
  1630. #ifdef USE_CUSTOM
  1631.     /* If no init file was found, execute the customization file */
  1632.     debug(F110,"CUSTOM 1",line,0);
  1633.     if (!line[0] || zchki(line) < 0) {
  1634.     int x;
  1635. #ifdef OS2
  1636.     x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1637.     debug(F111,"CUSTOM 2",line,x);
  1638.     if (zchki(line) < 0) {
  1639.         x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1640.         debug(F111,"CUSTOM 3",line,x);
  1641.     }
  1642. #else  /* OS2 */
  1643.     x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1644. #ifndef VMS
  1645.     /* VMS zhome() returns "SYS$LOGIN:" */
  1646.     if (line[x-1] != DIRSEP) {
  1647.         line[x++] = DIRSEP;
  1648.         line[x] = NUL;
  1649.     }
  1650. #endif /* VMS */
  1651.     x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1652.     debug(F111,"CUSTOM 4",line,x);
  1653. #endif /* OS2 */
  1654.     }
  1655.     debug(F110,"CUSTOM 5",line,0);
  1656. #endif /* USE_CUSTOM */
  1657.  
  1658. #ifdef CKROOT
  1659.     if (!zinroot(line)) {
  1660.         debug(F110,"doinit setroot violation",line,0);
  1661.         return;
  1662.     }
  1663. #endif /* CKROOT */
  1664.  
  1665.     debug(F110,"doinit ini file is",line,0);
  1666.     if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1667.         ok = 1;
  1668.         tlevel = 0;
  1669.         tfline[tlevel] = 0;
  1670.         if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1671.           strcpy(tfnam[tlevel],line);   /* safe */
  1672.  
  1673.         ckstrncpy(kermrc,line,KERMRCL);
  1674.  
  1675. #ifndef NOSPL
  1676.         cmdlvl++;
  1677.         ifcmd[cmdlvl] = 0;
  1678.         iftest[cmdlvl] = 0;
  1679.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1680.         intime[cmdlvl] = intime[cmdlvl-1];
  1681.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1682.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1683.         merror[cmdlvl] = merror[cmdlvl-1];
  1684.         xquiet[cmdlvl] = quiet;
  1685.         debug(F101,"doinit open ok","",cmdlvl);
  1686.         xcmdsrc = CMD_TF;
  1687.         cmdstk[cmdlvl].src = CMD_TF;
  1688.         cmdstk[cmdlvl].lvl = tlevel;
  1689.         cmdstk[cmdlvl].ccflgs = 0;
  1690. #endif /* NOSPL */
  1691.     } else if (rcflag) {
  1692.         /* Print an error message only if a specific file was asked for. */
  1693.         printf("?%s - %s\n", ck_errstr(), line);
  1694.     }
  1695.  
  1696. #ifdef datageneral
  1697. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1698.     if (/* homdir && */ (tlevel < 0)) {
  1699.         ckstrncpy(lp,kermrc,LINBUFSIZ);
  1700.         if ((tfile[0] = fopen(line,"r")) != NULL) {
  1701.             ok = 1;
  1702.             tlevel = 0;
  1703.             tfline[tlevel] = 0;
  1704.             if (tfnam[tlevel] = malloc(strlen(line)+1))
  1705.               strcpy(tfnam[tlevel],line); /* safe */
  1706. #ifndef NOSPL
  1707.             cmdlvl++;
  1708.             xcmdsrc = CMD_TF;
  1709.             cmdstk[cmdlvl].src = CMD_TF;
  1710.             cmdstk[cmdlvl].lvl = tlevel;
  1711.             cmdstk[cmdlvl].ccflgs = 0;
  1712.             ifcmd[cmdlvl] = 0;
  1713.             iftest[cmdlvl] = 0;
  1714.             count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1715.             intime[cmdlvl] = intime[cmdlvl-1];
  1716.             inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1717.             takerr[cmdlvl] = takerr[cmdlvl-1];
  1718.             merror[cmdlvl] = merror[cmdlvl-1];
  1719.             xquiet[cmdlvl] = quiet;
  1720. #endif /* NOSPL */
  1721.         }
  1722.     }
  1723. #endif /* datageneral */
  1724.  
  1725. #ifdef AMIGA                            /* Amiga... */
  1726.     reqpop();                           /* Restore requestors */
  1727. #endif /* AMIGA */
  1728. #endif /* OS2 */
  1729. #endif /* MAC */
  1730.  
  1731.     /* Assign value to inidir */
  1732.  
  1733.     if (!ok) {
  1734.         inidir[0] = NUL;
  1735.     } else {
  1736.         ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1737.         x = strlen(inidir);
  1738.         if (x > 0) {
  1739.             int i;
  1740.             for (i = x - 1; i > 0; i-- ) {
  1741.                 if (ISDIRSEP(inidir[i])) {
  1742.                     inidir[i+1] = NUL;
  1743.                     break;
  1744.                 }
  1745.             }
  1746.         }
  1747. #ifdef NT
  1748.         GetShortPathName(inidir,inidir,CCHMAXPATH);
  1749. #endif /* NT */
  1750.     }
  1751. }
  1752.  
  1753. VOID
  1754. doiksdinit() {
  1755. #ifdef CK_SSL
  1756.     /* IKSD doesn't request client certs */
  1757.     ssl_verify_flag = SSL_VERIFY_NONE;
  1758. #endif /* CK_SSL */
  1759.  
  1760.     if (!cmdinited)
  1761.       cmdini();
  1762.  
  1763. #ifdef IKSDCONF
  1764. #ifdef OS2
  1765.     line[0] = '\0';
  1766.     _searchenv(iksdconf,"INIT",line);
  1767.     if (line[0] == 0)
  1768.       _searchenv(iksdconf,"DPATH",line);
  1769.     if (line[0] == 0)
  1770.       _searchenv(iksdconf,"PATH",line);
  1771.     if (line[0] == 0) {
  1772.         char *pgmptr = GetLoadPath();
  1773.         if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1774.             lp = strrchr(pgmptr, '\\');
  1775.             if (lp) {
  1776.                 strncpy(line, pgmptr, lp - pgmptr);
  1777.                 strcpy(line + (lp - pgmptr), "\\");
  1778.                 strcpy(line + (lp - pgmptr + 1), iksdconf);
  1779.             } else {
  1780.                 lp = strrchr(pgmptr, '.');
  1781.                 if (lp) {
  1782.                     strncpy(line, pgmptr, lp - pgmptr);
  1783.                     strcpy(line + (lp - pgmptr), ".ksc");
  1784.                 }
  1785.             }
  1786.         }
  1787.     }
  1788.     debug(F110,"doiksdinit() line",line,0);
  1789.     tfile[0] = fopen(line,"r");
  1790. #else /* OS2 */
  1791.     tfile[0] = fopen(iksdconf,"r");
  1792. #endif /* OS2 */
  1793.     if (tfile[0] != NULL) {
  1794.         tlevel = 0;
  1795.         tfline[tlevel] = 0;
  1796. #ifdef OS2
  1797.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1798.           strcpy(tfnam[tlevel],line);
  1799. #else /* OS2 */
  1800.         if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1801.           strcpy(tfnam[tlevel],iksdconf);
  1802. #endif /* OS2 */
  1803. #ifndef NOSPL
  1804.         cmdlvl++;
  1805.         xcmdsrc = CMD_TF;
  1806.         cmdstk[cmdlvl].src = CMD_TF;
  1807.         cmdstk[cmdlvl].lvl = tlevel;
  1808.         cmdstk[cmdlvl].ccflgs = 0;
  1809.         ifcmd[cmdlvl]  = 0;
  1810.         iftest[cmdlvl] = 0;
  1811.         count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
  1812.         intime[cmdlvl] = intime[cmdlvl-1];
  1813.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1814.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1815.         merror[cmdlvl] = merror[cmdlvl-1];
  1816.         xquiet[cmdlvl] = quiet;
  1817. #endif /* NOSPL */
  1818.         debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1819.     } else {
  1820.         debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1821.     }
  1822. #endif /* IKSDCONF */
  1823. }
  1824.  
  1825. #ifndef NOSPL
  1826. /*
  1827.   G E T N C M
  1828.  
  1829.   Get next command from current macro definition.  Command is copied
  1830.   into string pointed to by argument s, max length n.   Returns:
  1831.    0 if a string was copied;
  1832.   -1 if there was no string to copy.
  1833. */
  1834. int
  1835. getncm(s,n) char *s; int n; {
  1836.     int y,                              /* Character counter */
  1837.     quote = 0,
  1838.     kp = 0,                             /* Brace up-down counter */
  1839.     pp = 0,                             /* Parenthesis up-down counter */
  1840. #ifndef NODQMACRO
  1841.     dq = 0;                             /* Doublequote counter */
  1842. #endif /* NODQMACRO */
  1843.     char *s2;                           /* Copy of destination pointer */
  1844.  
  1845.     s2 = s;                             /* Initialize string pointers */
  1846.     *s = NUL;                           /* and destination buffer */
  1847.  
  1848.     /* debug(F010,"getncm entry",macp[maclvl],0); */
  1849.  
  1850.     for (y = 0;                         /* Loop for n bytes max */
  1851.          macp[maclvl] && *macp[maclvl] && y < n;
  1852.          y++, s++, macp[maclvl]++) {
  1853.  
  1854.         *s = *macp[maclvl];             /* Get next char from macro def */
  1855.  
  1856. #ifndef COMMENT
  1857. /*
  1858.   This is to allow quoting of parentheses, commas, etc, in function
  1859.   arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  1860.   COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  1861.   everything again.)  <-- The preceding warning should be obsolete since the
  1862.   statements below have been fixed, but in case of fire, remove the "n" from
  1863.   the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the
  1864.   opening brace in \{nnn} from being treated as a quoted brace.
  1865. */
  1866.         if (!quote && *s == CMDQ) {
  1867.             quote = 1;
  1868.             continue;
  1869.         }
  1870.         if (quote) {
  1871.         int notquote = 0;
  1872.             quote = 0;
  1873.         if (*s == '{') {        /* Check for \{nnn} (8.0.203) */
  1874.         char c, * p;
  1875.         p = macp[maclvl] + 1;
  1876.         while ((c = *p++)) {
  1877.             if (isdigit(c))
  1878.               continue;
  1879.             else if (c == '}') {
  1880.             notquote++;
  1881.             break;
  1882.             } else {
  1883.             break;
  1884.             }
  1885.         }
  1886.         }
  1887.         if (notquote == 0)
  1888.           continue;
  1889.         }
  1890. #endif /* COMMENT */
  1891.  
  1892. /*
  1893.   Allow braces around macro definition to prevent commas from being turned to
  1894.   end-of-lines and also treat any commas within parens as text so that
  1895.   multiple-argument functions won't cause the command to break prematurely.
  1896.   19 Oct 2001: Similar treatment was added for doublequotes, so
  1897.  
  1898.      define foo { echo "one, two, three" }
  1899.  
  1900.   would work as expected.  This doesn't seem to have broken anything but
  1901.   if something comes up later, rebuild with NODQMACRO defined.
  1902. */
  1903.         if (*s == '{') kp++;            /* Count braces */
  1904.         if (*s == '}' && kp > 0) kp--;
  1905.         if (*s == '(') pp++;            /* Count parentheses. */
  1906.         if (*s == ')' && pp > 0) pp--;
  1907. #ifndef NODQMACRO
  1908. #ifdef COMMENT
  1909.     /* Too many false positives */
  1910.     if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1911. #else
  1912.     if (dblquo && (*s == '"')) {    /* Have doublequote */
  1913.         if (dq == 1) {
  1914.         /* Close quote only if at end or followed by space */
  1915.         if (*(s+1) == SP || !*(s+1))
  1916.           dq = 0;
  1917.         } else if (dq == 0) {
  1918.         /* Open quote only if at beginning or preceded by space */
  1919.         if (s > macp[maclvl]) {
  1920.             if (*(s-1) == SP)
  1921.               dq = 1;
  1922.         } else if (s == macp[maclvl]) {
  1923.               dq = 1;
  1924.         }
  1925.         }
  1926.     }
  1927. #endif /* COMMENT */
  1928. #endif /* NODQMACRO */
  1929.         if (*s == ',' && pp <= 0 && kp <= 0
  1930. #ifndef NODQMACRO
  1931.             && dq == 0
  1932. #endif /* NODQMACRO */
  1933.             ) {
  1934.             macp[maclvl]++;             /* Comma not in {} or () */
  1935.             /* debug(F110,"next cmd",s,0); */
  1936.             kp = pp = 0;                /* so we have the next command */
  1937.             break;
  1938.         }
  1939.     }                                   /* Reached end. */
  1940. #ifdef COMMENT
  1941.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1942.     *s = NUL;
  1943. #endif /* COMMENT */
  1944.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1945.         /* debug(F100,"getncm eom","",0); */
  1946.         popclvl();                      /* pop command level. */
  1947.         return(-1);
  1948.     } else {                            /* otherwise, tack CR onto end */
  1949.         *s++ = CR;
  1950.         *s = '\0';
  1951.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  1952.           printf("%s\n",s2);
  1953.     }
  1954.     return(0);
  1955. }
  1956.  
  1957. /*  D O M A C  --  Define and then execute a macro */
  1958.  
  1959. int
  1960. domac(name, def, flags) char *name, *def; int flags; {
  1961.     int x, m;
  1962. #ifndef NOLOCAL
  1963. #ifdef OS2
  1964.     extern int term_io;
  1965.     int term_io_sav = term_io;
  1966.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  1967. #endif /* OS2 */
  1968. #endif /* NOLOCAL */
  1969.     m = maclvl;                         /* Current macro stack level */
  1970.     x = addmac(name, def);              /* Define a new macro */
  1971.     if (x > -1) {                       /* If successful, */
  1972.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  1973.         while (maclvl > m) {            /* Keep going till done with it, */
  1974.             debug(F101,"domac loop maclvl 1","",maclvl);
  1975.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  1976.             debug(F101,"domac loop maclvl 2","",maclvl);
  1977.             if (sstate) proto();        /* including protocol commands. */
  1978.         }
  1979.         debug(F101,"domac loop exit maclvl","",maclvl);
  1980.     }
  1981. #ifndef NOLOCAL
  1982. #ifdef OS2
  1983.     term_io = term_io_sav;
  1984. #endif /* OS2 */
  1985. #endif /* NOLOCAL */
  1986.     return(success);
  1987. }
  1988. #endif /* NOSPL */
  1989.  
  1990. /*
  1991.   G E T N C T
  1992.  
  1993.   Get next command from TAKE (command) file.
  1994.  
  1995.   Call with:
  1996.    s     Pointer to buffer to read into
  1997.    n     Length of buffer
  1998.    f     File descriptor of file to read from
  1999.    flag  0 == keep line terminator on and allow continuation
  2000.          1 == discard line terminator and don't allow continuation
  2001.  
  2002.   Call with flag == 0 to read a command from a TAKE file;
  2003.   Call with flag != 0 to read a line from a dialing or network directory.
  2004.  
  2005.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  2006.   If flag == 0, continued lines are combined into one line.  A continued line
  2007.   is one that ends in hypen, or any line in a "block", which starts with "{"
  2008.   at the end of a line and ends with a matching "}" at the beginning of a
  2009.   subsequent line; blocks may be nested.
  2010.  
  2011.   Returns:
  2012.    0 if a string was copied,
  2013.   -1 on EOF,
  2014.   -2 on malloc failure
  2015.   -3 if line is not properly terminated
  2016.   -4 if (possibly continued) line is too long.
  2017. */
  2018. static int lpxlen = 0;
  2019.  
  2020. int
  2021. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  2022.     int i = 0, len = 0, buflen = 0;
  2023.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  2024.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  2025.     char * prev = NULL;
  2026.     int bc = 0;                         /* Block counter */
  2027.  
  2028.     s2 = s;                             /* Remember original pointer */
  2029.     prev = s2;
  2030.     buflen = n;                         /* Remember original buffer length */
  2031.  
  2032.     if (n < 0)
  2033.       return(-2);
  2034.  
  2035.     /* Allocate a line buffer only if we don't have one that's big enough */
  2036.  
  2037.     debug(F111,"getnct",ckitoa(lpxlen),n);
  2038.  
  2039.     if (lpx && (n > lpxlen)) {          /* Have one already */
  2040.         debug(F101,"getnct new buffer","",lpxlen);
  2041.         free(lpx);                      /* But it's not big enough */
  2042.         lpx = NULL;                     /* Free current one */
  2043.         lpxlen = 0;
  2044.     }
  2045.     if (!lpx) {                         /* Get new one */
  2046.         if (!(lpx = (char *) malloc(n))) {
  2047.             debug(F101,"getnct malloc failure","",0);
  2048.             printf("?Memory allocation failure [getnct]\n");
  2049.             return(-2);
  2050.         }
  2051.         lpxlen = n;
  2052.     }
  2053.     lp2 = lpx;
  2054. #ifdef KLUDGE
  2055.     /* NOTE: No longer used as of 14 Aug 2000 */
  2056.     lp2++;
  2057. #endif /* KLUDGE */
  2058.  
  2059.     while (1) {                         /* Loop to read lines from file */
  2060.         debug(F101,"getnct while (1)","",n);
  2061.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  2062.             debug(F110,"getnct EOF",s2,0); /* EOF */
  2063.             free(lpx);                  /* Free temporary storage */
  2064.             lpx = NULL;
  2065.             *s = NUL;                   /* Make destination be empty */
  2066.             return(-1);                 /* Return failure code */
  2067.         }
  2068. #ifndef NODIAL
  2069.         if (flag)                       /* Count this line */
  2070.           dirline++;
  2071.         else
  2072. #endif /* NODIAL */
  2073.           tfline[tlevel]++;
  2074.         len = strlen(lp2) - 1;          /* Position of line terminator */
  2075.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  2076.             lp2[++len] = '\n';          /* that is not a newline */
  2077.             lp2[len] = NUL;
  2078.         }
  2079.         debug(F010,"getnct",lp2,0);
  2080.         if (len < 0)
  2081.           len = 0;
  2082.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2083.           printf("%3d. %s",             /* echo it this line. */
  2084. #ifndef NODIAL
  2085.                  flag ? dirline :
  2086. #endif /* NODIAL */
  2087.                  tfline[tlevel],
  2088.                  lp2
  2089.                  );
  2090.         lp3 = lp2;                      /* Working pointer */
  2091.         i = len;                        /* Get first nonwhitespace character */
  2092.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2093.             i--;
  2094.             lp3++;
  2095.         }
  2096.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2097.           continue;
  2098.  
  2099.         /* Isolate, remove, and check terminator */
  2100.  
  2101.         c = lp2[len];                   /* Value of line terminator */
  2102.         /* debug(F101,"getnct terminator","",c); */
  2103.         if (c < LF || c > CR) {         /* It's not a terminator */
  2104.             /* debug(F111,"getnct bad line",lp2,c); */
  2105.             if (feof(f) && len > 0 && len < n) {
  2106.                 /* Kludge Alert... */
  2107.                 if (!quiet)
  2108.                   printf("WARNING: Last line of %s lacks terminator\n",
  2109.                          s2 == cmdbuf ? "command file" : "directory file");
  2110.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2111.             } else {                    /* Something's wrong, fail. */
  2112.                 free(lpx);
  2113.                 lpx = NULL;
  2114.                 return(-3);
  2115.             }
  2116.         }
  2117.         /* Trim trailing whitespace */
  2118.  
  2119.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2120.           ;
  2121.         /* debug(F101,"getnct i","",i); */
  2122.         lp2[i+1] = NUL;                 /* Terminate the string */
  2123.         /* debug(F110,"getnct lp2",lp2,0); */
  2124.         lp = lp2;                       /* Make a working pointer */
  2125.  
  2126.         /* Remove trailing or full-line comment */
  2127.  
  2128.         while ((cc = *lp)) {
  2129.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2130.                 if (lp == lp2) {        /* First char on line */
  2131.                     *lp = NUL;
  2132.                     break;
  2133.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2134.                     lp--;
  2135.                     *lp = NUL;  /* Or preceded by whitespace */
  2136.                     break;
  2137.                 }
  2138.             }
  2139.             lp++;
  2140.         }
  2141.         if (lp > lp2)
  2142.           lp--;                         /* Back up over the NUL */
  2143.  
  2144.         /* Now trim any space that preceded the comment */
  2145.  
  2146.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2147.             *lp = NUL;
  2148.             if (lp <= lp2)
  2149.               break;
  2150.             lp--;
  2151.         }
  2152.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2153.  
  2154.         len = strlen(lp2);              /* Length after trimming */
  2155.  
  2156.         if (n - len < 2) {              /* Check remaining space */
  2157.             debug(F111,"getnct command too long",s2,buflen);
  2158.             printf("?Line too long, maximum length: %d.\n",buflen);
  2159.             free(lpx);
  2160.             return(-4);
  2161.         }
  2162.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2163.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2164.  
  2165. #ifdef COMMENT
  2166.         /* Line containing only whitespace and ,- */
  2167.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2168.           continue;
  2169. #endif /* COMMENT */
  2170.  
  2171. #ifdef KLUDGE
  2172. /*
  2173.   If it is a command and it begins with a token (like ! or .) that is not
  2174.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2175.   confused.
  2176. */
  2177.         if (s == s2 && !flag) {
  2178.             char *p = toktab;
  2179.             while (*p) {
  2180.                 if (*p == *lp3 && *(p+1) != SP) {
  2181.                     debug(F110,"getnct token",p,0);
  2182.                     *lp3-- = SP;
  2183.                     *lp3 = *p;
  2184.                     if (lp3 < lp2) {
  2185.                         lp2--;
  2186.                         len++;
  2187.                     }
  2188.                     break;
  2189.                 } else
  2190.                   p++;
  2191.             }
  2192.         }
  2193. #endif /* KLUDGE */
  2194.         lp = lp2;
  2195.  
  2196.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2197.           n--;                          /* accounting for length */
  2198.         s--;                            /* Back up over the NUL */
  2199.  
  2200.         /* Check whether this line is continued */
  2201.  
  2202.         if (flag)                       /* No line continuation when flag=1 */
  2203.           break;                        /* So break out of read-lines loop */
  2204.  
  2205. #ifdef COMMENT
  2206.         debug(F000,"getnct first char","",*lp3);
  2207.         debug(F000,"getnct last char","",ccl);
  2208.         debug(F000,"getnct next-to-last char","",ccx);
  2209. #endif /* COMMENT */
  2210.  
  2211.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2212.             bc--;                               /* Decrement block counter */
  2213.         }
  2214.  
  2215.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2216. #ifdef COMMENT
  2217.             /* Not supported as of C-Kermit 6.0 */
  2218.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2219. #endif /* COMMENT */
  2220.             ccl != '-'  &&              /* or line ends with dash */
  2221.             ccl != '{')                 /* or line ends with opening brace */
  2222.           break;                        /* None of those, we're done. */
  2223.  
  2224.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2225.           if (ccx == CMDQ)              /* But it's quoted */
  2226.             break;                      /* so ignore it */
  2227.  
  2228.         if (ccl == '{') {               /* Last char on line is '{'? */
  2229.             bc++;                       /* Count the block opener. */
  2230.         } else if (ccl == '-') {        /* Explicit continue? */
  2231.             char c, * ss;
  2232.             int state = 0, nn;
  2233.             s--;                        /* Yes, back up over terminators */
  2234.             n++;                        /* and over continuation character */
  2235.             nn = n;                     /* Save current count */
  2236.             ss = s;                     /* and pointer */
  2237.             s--;                        /* Back up over dash */
  2238.             n++;
  2239.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2240.                 n++;
  2241.                 c = *s--;
  2242.                 if (c <= SP)
  2243.                   continue;
  2244.                 if (c != ',' && c != '{')
  2245.                   break;
  2246.                 switch (state) {
  2247.                   case 0:               /* Looking for comma */
  2248.                     if (c == ',')
  2249.                       state = 1;
  2250.                     break;
  2251.                   case 1:               /* Looking for left brace */
  2252.                     if (c == '{') {
  2253.                         state = 2;
  2254.                         s += 2;
  2255.                         *s = NUL;
  2256.                         bc++;
  2257.                     }
  2258.                     break;
  2259.                 }
  2260.             }
  2261.             if (state != 2) { s = ss; n = nn; }
  2262.             *s = NUL;
  2263.         } else {                        /* None of those but (bc > 0) */
  2264.             lastcomma = s;
  2265.             *s++ = ',';                 /* and insert a comma */
  2266.             n--;
  2267.         }
  2268. #ifdef COMMENT
  2269.         debug(F101,"getnct bc","",bc);
  2270.         debug(F100,"getnct continued","",0);
  2271. #endif /* COMMENT */
  2272.  
  2273.         *s = NUL;
  2274.         prev = s;
  2275.  
  2276.     } /* read-lines while loop */
  2277.  
  2278.     if (lastcomma)
  2279.       *lastcomma = SP;
  2280.     if (!flag)                          /* Tack line terminator back on */
  2281.       *s++ = c;
  2282.     *s++ = NUL;                         /* Terminate the string */
  2283.     untab(s2);                          /* Done, convert tabs to spaces */
  2284. #ifdef DEBUG
  2285.     if (!flag) {
  2286.         debug(F010,"CMD(F)",s2,0);
  2287.     }
  2288. #endif /* DEBUG */
  2289.     free(lpx);                          /* Free temporary storage */
  2290.     return(0);                          /* Return success */
  2291. }
  2292.  
  2293. VOID
  2294. shostack() {                            /* Dump the command stack */
  2295.     int i;
  2296.     char *p;
  2297. #ifndef NOSPL
  2298.     for (i = cmdlvl; i > 0; i--) {
  2299.         if (cmdstk[i].src == CMD_TF) {
  2300.             p = tfnam[cmdstk[i].lvl];
  2301.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2302.               p = tmpbuf;
  2303.             printf(" %2d. File  : %s (line %d)\n",
  2304.                    i,
  2305.                    p,
  2306.                    tfline[cmdstk[i].lvl]
  2307.                    );
  2308.         } else if (cmdstk[i].src == CMD_MD) {
  2309.             char * m;
  2310.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2311.             if (i > 0) {                 /* Special handling for 2-level */
  2312.                 char *s;                 /* built-in macros... */
  2313.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2314.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2315.                     if (!strcmp(s,"_forx"))
  2316.                       m = "FOR";
  2317.                     else if (!strcmp(s,"_xif"))
  2318.                       m = "XIF";
  2319.                     else if (!strcmp(s,"_while"))
  2320.                       m = "WHILE";
  2321.                     else if (!strcmp(s,"_switx"))
  2322.                       m = "SWITCH";
  2323.                 }
  2324.             }
  2325.             printf(" %2d. Macro : %s\n",i,m);
  2326.         } else if (cmdstk[i].src == CMD_KB) {
  2327.             printf(" %2d. Prompt:\n",i);
  2328.         } else {
  2329.             printf(" %2d. ERROR : Command source unknown\n",i);
  2330.         }
  2331.     }
  2332. #else
  2333.     for (i = tlevel; i > -1; i--) {
  2334.         p = tfnam[i];
  2335.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2336.           p = tmpbuf;
  2337.         printf(" %2d. File  : %s (line %d)\n",
  2338.                i,
  2339.                p,
  2340.                tfline[i]
  2341.                );
  2342.     }
  2343. #endif /* NOSPL */
  2344.     if (i == 0)
  2345.       printf(" %2d. Prompt: (top level)\n",0);
  2346. }
  2347.  
  2348.  
  2349. /*  P A R S E R  --  Top-level interactive command parser.  */
  2350.  
  2351. /*
  2352.   Call with:
  2353.     m = 0 for normal behavior: keep parsing and executing commands
  2354.           until an action command is parsed, then return with a
  2355.           Kermit start-state as the value of this function.
  2356.     m = 1 to parse only one command, can also be used to call parser()
  2357.           recursively.
  2358.     m = 2 to read but do not execute one command.
  2359.   In all cases, parser() returns:
  2360.     0     if no Kermit protocol action required
  2361.     > 0   with a Kermit protocol start-state.
  2362.     < 0   upon error.
  2363. */
  2364. int
  2365. parser(m) int m; {
  2366.     int tfcode, xx, yy, zz;             /* Workers */
  2367.     int is_tn = 0;
  2368.     int cdlost = 0;
  2369.  
  2370. #ifndef NOSPL
  2371.     int inlevel;                        /* Level we were called at */
  2372.     extern int askflag;
  2373. #endif /* NOSPL */
  2374.     char *cbp;                          /* Command buffer pointer */
  2375. #ifdef MAC
  2376.     extern char *lfiles;                /* Fake extern cast */
  2377. #endif /* MAC */
  2378.     extern int interrupted;
  2379. #ifndef NOXFER
  2380.     extern int sndcmd, getcmd, fatalio, clearrq;
  2381. #endif /* NOXFER */
  2382.  
  2383.     debok = 1;                          /* Undisable debugging */
  2384.  
  2385. #ifdef AMIGA
  2386.     reqres();                           /* Restore AmigaDOS requestors */
  2387. #endif /* AMIGA */
  2388.  
  2389. #ifdef OS2
  2390.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2391.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2392.         cursor_save = -1;
  2393.     }
  2394. #endif /* OS2 */
  2395.  
  2396. #ifdef IKSDB
  2397.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2398. #endif /* IKSDB */
  2399.  
  2400.     is_tn = (local && network && IS_TELNET()) ||
  2401.       (!local && sstelnet);
  2402.  
  2403.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2404.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2405.  
  2406. #ifdef CK_TMPDIR
  2407. /* If we were cd'd temporarily to another device or directory ... */
  2408.     if (f_tmpdir) {
  2409.         int x;
  2410.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2411.         f_tmpdir = 0;                   /* and remember we did it. */
  2412.         debug(F111,"parser tmpdir restoring",savdir,x);
  2413.     }
  2414. #endif /* CK_TMPDIR */
  2415.  
  2416. #ifndef NOSPL
  2417.     inlevel = cmdlvl;           /* Current macro level */
  2418. #ifdef DEBUG
  2419.     if (deblog) {
  2420.         debug(F101,"&parser entry maclvl","",maclvl);
  2421.         debug(F101,"&parser entry inlevel","",inlevel);
  2422.         debug(F101,"&parser entry tlevel","",tlevel);
  2423.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2424.         debug(F101,"&parser entry m","",m);
  2425.     }
  2426. #endif /* DEBUG */
  2427. #endif /* NOSPL */
  2428.  
  2429. #ifndef NOXFER
  2430.     ftreset();                          /* Reset global file settings */
  2431. #endif /* NOXFER */
  2432. /*
  2433.   sstate becomes nonzero when a command has been parsed that requires some
  2434.   action from the protocol module.  Any non-protocol actions, such as local
  2435.   directory listing or terminal emulation, are invoked directly from below.
  2436. */
  2437.     sstate = 0;                         /* Start with no start state. */
  2438.  
  2439. #ifndef NOXFER
  2440. #ifndef NOSPL
  2441.     query = 0;                          /* QUERY not active */
  2442. #endif /* NOSPL */
  2443. #ifndef NOHINTS
  2444.     if (!success) {
  2445.         if (local && !network && carrier != CAR_OFF) {
  2446.             int x;                      /* Serial connection */
  2447.             x = ttgmdm();               /* with carrier checking */
  2448.             if (x > -1) {
  2449.                 if (!(x & BM_DCD)) {
  2450.                     cdlost = 1;
  2451.                     fatalio = 1;
  2452.                 }
  2453.             }
  2454.         }
  2455.     }
  2456. #ifdef DEBUG
  2457.     if (deblog) {
  2458.         debug(F101,"parser top what","",what);
  2459.         debug(F101,"parser top interrupted","",interrupted);
  2460.         debug(F101,"parser top cdlost","",cdlost);
  2461.         debug(F101,"parser top sndcmd","",sndcmd);
  2462.         debug(F101,"parser top getcmd","",getcmd);
  2463.     }
  2464. #endif /* DEBUG */
  2465.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2466.         printf("?Connection broken (carrier signal lost)\n");
  2467.     }
  2468.     if (sndcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2469.         int x = 0, n = 0;
  2470.         printf("\n*************************\n");
  2471.         printf("SEND-class command failed.\n");
  2472.         printf(" Packets sent: %d\n", spackets);
  2473.         printf(" Retransmissions: %d\n",retrans);
  2474.         printf(" Timeouts: %d\n", timeouts);
  2475.         printf(" Damaged packets: %d\n", crunched);
  2476.         if (epktrcvd) {
  2477.             printf(" Transfer canceled by receiver.\n");
  2478.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2479.             n++;
  2480.         } else {
  2481.             if (epktmsg) if (*epktmsg) {
  2482.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2483.                 n++;
  2484.             }
  2485.         }
  2486.         if (local && !network && carrier != CAR_OFF) {
  2487.             int xx;                     /* Serial connection */
  2488.             xx = ttgmdm();              /* with carrier checking */
  2489.             if (xx > -1) {
  2490.                 if (!(xx & BM_DCD))
  2491.                   cdlost = 1;
  2492.             }
  2493.         }
  2494.  
  2495. #ifdef UNIX
  2496.         if (errno != 0)
  2497. #endif /* UNIX */
  2498.           {
  2499.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2500.               n++;
  2501.           }
  2502.         printf(
  2503.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2504.                (n > 1) ? "s do" : " does"
  2505.                );
  2506. #ifndef NOLOCAL
  2507.         if (local) {
  2508.             if (rpackets == 0) {
  2509.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2510.             } else {
  2511.                 printf(
  2512.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2513.                 if (!network && mdmtyp > 0)
  2514.                   if ((3 * crunched) > spackets)
  2515.                     printf(
  2516.                 " . Try placing a new call to get a cleaner connection.\n");
  2517.             }
  2518.         } else if (rpackets > 0) {
  2519.             if (flow == FLO_NONE)
  2520.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2521.             else
  2522.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2523.         }
  2524.         x++;
  2525. #endif /* NOLOCAL */
  2526.  
  2527.         if ((3 * timeouts) > spackets)
  2528.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2529.         if ((3 * retrans) > spackets)
  2530.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2531.  
  2532. #ifdef CK_SPEED
  2533.         if (prefixing != PX_ALL && rpackets > 2) {
  2534.             printf(" . Try it again with SET PREFIXING ALL.\n");
  2535.             x++;
  2536.         }
  2537. #endif /* CK_SPEED */
  2538. #ifdef STREAMING
  2539.         if (streamed) {
  2540.             printf(" . Try it again with SET STREAMING OFF.\n");
  2541.             x++;
  2542.         } else if (reliable) {
  2543.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2544.             x++;
  2545.         }
  2546. #endif /* STREAMING */
  2547.  
  2548. #ifdef CK_SPEED
  2549.         if (clearrq > 0 && prefixing == PX_NON) {
  2550.             printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");
  2551.             x++;
  2552.         }
  2553. #endif /* CK_SPEED */
  2554.         if (!parity) {
  2555.             printf(" . Try it again with SET PARITY SPACE.\n");
  2556.             x++;
  2557.         }
  2558.         printf(" . %sive a ROBUST command and try again.\n",
  2559.                (x > 0) ? "As a last resort, g" : "G"
  2560.                );
  2561.         printf("Also:\n");
  2562.         printf(" . Be sure the source file has read permission.\n");
  2563.         printf(" . Be sure the target directory has write permission.\n");
  2564.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2565.         printf("*************************\n\n");
  2566.     }
  2567.     debug(F101,"topcmd","",topcmd);
  2568.     if (getcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2569.         int x = 0;
  2570.         extern int urpsiz, wslotr;
  2571.         printf("\n*************************\n");
  2572.         printf("RECEIVE- or GET-class command failed.\n");
  2573.         printf(" Packets received: %d\n", rpackets);
  2574.         printf(" Damaged packets: %d\n", crunched);
  2575.         printf(" Timeouts: %d\n", timeouts);
  2576.         if (rpackets > 0)
  2577.           printf(" Packet length: %d\n", urpsiz);
  2578.         if (epktrcvd) {
  2579.             printf(" Transfer canceled by sender.\n");
  2580.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2581.         }
  2582. #ifdef UNIX
  2583.         if (errno != 0)
  2584. #endif /* UNIX */
  2585.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2586.         printf(
  2587.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2588.                epktrcvd ? "s do" : " does"
  2589.                );
  2590. #ifndef NOLOCAL
  2591.         if (local) {
  2592.             if (topcmd == XXGET)
  2593.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2594.             if (rpackets == 0) {
  2595.                 if (topcmd != XXGET)
  2596.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2597.             } else {
  2598.                 printf(
  2599.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2600.             }
  2601.         } else if (topcmd == XXGET)
  2602.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2603.         if (rpackets > 0 && urpsiz > 90)
  2604.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2605.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2606.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2607.         if (!local && rpackets > 0) {
  2608.             if (flow == FLO_NONE)
  2609.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2610.             else
  2611.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2612.         }
  2613.         x++;
  2614. #endif /* NOLOCAL */
  2615. #ifdef STREAMING
  2616.         if (streamed) {
  2617.             printf(" . Try it again with SET STREAMING OFF.\n");
  2618.             x++;
  2619.         } else if (reliable && local) {
  2620.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2621.             x++;
  2622.         } else
  2623. #endif /* STREAMING */
  2624.         if (!parity) {
  2625.             printf(" . Try it again with SET PARITY SPACE.\n");
  2626.             x++;
  2627.         }
  2628.         printf((x > 0) ?
  2629.                " . As a last resort, give a ROBUST command and try again.\n" :
  2630.                " . Give a ROBUST command and try again.\n"
  2631.                );
  2632.         printf("Also:\n");
  2633.         printf(" . Be sure the target directory has write permission.\n");
  2634.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2635.                topcmd == XXGET ? "server" : "sender"
  2636.                );
  2637.         printf(" . Try giving a ROBUST command to the %s.\n",
  2638.                topcmd == XXGET ? "server" : "sender"
  2639.                );
  2640.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2641.         printf("*************************\n\n");
  2642.     }
  2643. #endif /* NOHINTS */
  2644.     getcmd = 0;
  2645.     sndcmd = 0;
  2646.     interrupted = 0;
  2647. #endif /* NOXFER */
  2648.  
  2649.     while (sstate == 0) {               /* Parse cmds until action requested */
  2650.         debug(F100,"parse top","",0);
  2651.     what = W_COMMAND;        /* Now we're parsing commands. */
  2652.     rcdactive = 0;            /* REMOTE CD not active */
  2653.     keepallchars = 0;        /* MINPUT not active */
  2654.  
  2655. #ifdef OS2
  2656.         if (apcactive == APC_INACTIVE)
  2657.           WaitCommandModeSem(-1);
  2658. #endif /* OS2 */
  2659. #ifdef IKS_OPTION
  2660.         if ((local &&
  2661.              !xcmdsrc &&
  2662.              is_tn &&
  2663.              TELOPT_ME(TELOPT_KERMIT) &&
  2664.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2665.             (!local &&
  2666.              !cmdadl &&
  2667.              TELOPT_ME(TELOPT_KERMIT) &&
  2668.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2669.             ) {
  2670.             tn_siks(KERMIT_STOP);
  2671.         }
  2672. #endif /* IKS_OPTION */
  2673.  
  2674. #ifndef NOXFER
  2675.         if (autopath) {
  2676.             fnrpath = PATH_AUTO;
  2677.             autopath = 0;
  2678.         }
  2679.         remfile = 0;                    /* Clear these in case REMOTE */
  2680.         remappd = 0;                    /* command was interrupted... */
  2681.         rempipe = 0;
  2682.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2683.         makestr(&rcv_move,g_rcv_move);
  2684.         makestr(&snd_rename,g_snd_rename);
  2685.         makestr(&rcv_rename,g_rcv_rename);
  2686. #endif /* NOXFER */
  2687.         xaskmore = saveask;             /* Restore global more-prompting */
  2688.         diractive = 0;
  2689.         cdactive = 0;
  2690.  
  2691. #ifndef NOSPL
  2692.         askflag = 0;
  2693. #endif /* NOSPL */
  2694.  
  2695.     /* Take requested action if there was an error in the previous command */
  2696.  
  2697.         setint();
  2698.         debug(F101,"parser tlevel","",tlevel);
  2699.         debug(F101,"parser cmd_rows","",cmd_rows);
  2700.  
  2701. #ifndef NOLOCAL
  2702.         debug(F101,"parser wasclosed","",wasclosed);
  2703.         if (wasclosed) {                /* If connection was just closed */
  2704. #ifndef NOSPL
  2705.             int k;
  2706.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2707.             if (k >= 0) {               /* If found, */
  2708.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2709.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2710.             }
  2711. #endif /* NOSPL */
  2712.             whyclosed = WC_REMO;
  2713.             wasclosed = 0;
  2714.         }
  2715. #endif /* NOLOCAL */
  2716.  
  2717. #ifndef NOSPL
  2718.         xxdot = 0;                      /* Clear this... */
  2719.  
  2720.         debug(F101,"parser success","",success);
  2721.         if (success == 0) {
  2722.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2723.                 printf("Command file terminated by error.\n");
  2724.                 popclvl();
  2725.                 if (cmdlvl == 0) return(0);
  2726.             }
  2727.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2728.                 printf("Command error: macro terminated.\n");
  2729.                 popclvl();
  2730.                 if (m && (cmdlvl < inlevel))
  2731.                   return((int) sstate);
  2732.             }
  2733.         }
  2734.         nulcmd = (m == 2);
  2735.         debug(F101,"parser nulcmd","",nulcmd);
  2736. #else
  2737.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2738.             printf("Command file terminated by error.\n");
  2739.             popclvl();
  2740.             cmini(ckxech);              /* Clear the cmd buffer. */
  2741.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2742.               return(0);                /* End of init file or whatever. */
  2743.         }
  2744. #endif /* NOSPL */
  2745.  
  2746. #ifdef MAC
  2747.         /* Check for TAKE initiated by menu. */
  2748.         if ((tlevel == -1) && lfiles)
  2749.             startlfile();
  2750. #endif /* MAC */
  2751.  
  2752.         /* If in TAKE file, check for EOF */
  2753. #ifndef NOSPL
  2754. #ifdef MAC
  2755.         if
  2756. #else
  2757.         while
  2758. #endif /* MAC */
  2759.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2760.                && (tlevel > -1)
  2761.                && feof(tfile[tlevel])) {
  2762.             popclvl();                  /* pop command level */
  2763.             cmini(ckxech);              /* and clear the cmd buffer. */
  2764.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2765.                 return(0);              /* End of init file or whatever. */
  2766.             }
  2767.         }
  2768. #ifdef MAC
  2769.         miniparser(1);
  2770.         if (sstate == 'a') {            /* if cmd-. cancel */
  2771.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2772.             sstate = '\0';
  2773.             dostop();
  2774.             return(0);                  /* End of init file or whatever. */
  2775.         }
  2776. #endif /*  MAC */
  2777.  
  2778. #else /* NOSPL */
  2779.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2780.             popclvl();                  /* Pop up one level. */
  2781.             cmini(ckxech);              /* and clear the cmd buffer. */
  2782.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2783.               return(0);                /* End of init file or whatever. */
  2784.         }
  2785. #endif /* NOSPL */
  2786.  
  2787.  
  2788. #ifndef NOSPL
  2789.         debug(F101,"parser cmdlvl","",cmdlvl);
  2790.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2791.  
  2792.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2793.             debug(F100,"parser macro","",0);
  2794.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2795.             debug(F101,"parser maclvl","",maclvl);
  2796.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2797.             *cbp = NUL;
  2798.             if (*savbuf) {              /* In case then-part of 'if' command */
  2799.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2800.                 *savbuf = '\0';
  2801.             } else {                    /* Else get next cmd from macro def */
  2802.                 if (getncm(cbp,CMDBL) < 0) {
  2803. #ifdef DEBUG
  2804.                     if (deblog) {
  2805.                         debug(F101,"parser end of macro m","",m);
  2806.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2807.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2808.                     }
  2809. #endif /* DEBUG */
  2810.                     if (m && (cmdlvl < inlevel))
  2811.                       return((int) sstate);
  2812.                     else /* if (!m) */ continue;
  2813.                 }
  2814.             }
  2815.             debug(F010,"CMD(M)",cmdbuf,0);
  2816.  
  2817.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2818. #else
  2819.           if (tlevel > -1)
  2820. #endif /* NOSPL */
  2821.           {
  2822. #ifndef NOSPL
  2823.             debug(F111,"parser savbuf",savbuf,tlevel);
  2824.             if (*savbuf) {              /* In case THEN-part of IF command */
  2825.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2826.                 *savbuf = '\0';
  2827.             } else
  2828. #endif /* NOSPL */
  2829.  
  2830.               /* Get next line from TAKE file */
  2831.  
  2832.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2833.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2834.                   if (tfcode < -1) {    /* Error */
  2835.                       printf("?Error in TAKE command file: %s\n",
  2836.                              (tfcode == -2) ? "Memory allocation failure" :
  2837.                              "Line too long or contains NUL characters"
  2838.                              );
  2839.                       dostop();
  2840.                   }
  2841.                   continue;             /* -1 means EOF */
  2842.               }
  2843.  
  2844.         /* If interactive, get next command from user. */
  2845.  
  2846.         } else {                        /* User types it in. */
  2847.             if (pflag) prompt(xxstring);
  2848.             cmini(ckxech);
  2849.         }
  2850.  
  2851.     /* Now we know where next command is coming from. Parse and execute it. */
  2852.  
  2853.         repars = 1;                     /* 1 = command needs parsing */
  2854. #ifndef NOXFER
  2855.         displa = 0;                     /* Assume no file transfer display */
  2856. #endif /* NOXFER */
  2857.  
  2858.         while (repars) {                /* Parse this cmd until entered. */
  2859.  
  2860.             debug(F101,"parser top of while loop","",0);
  2861.  
  2862. #ifdef RECURSIVE
  2863.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2864.             recursive = 0;              /* This is never sticky */
  2865. #endif /* RECURSIVE */
  2866.             xfiletype = -1;             /* Reset this between each command */
  2867. #ifndef NOMSEND
  2868.             addlist = 0;
  2869. #endif /* NOMSEND */
  2870. #ifdef CK_RECALL
  2871.             on_recall = 1;
  2872. #endif /* CK_RECALL */
  2873.             /* This might have been changed by a switch */
  2874.             if (g_matchdot > -1) {
  2875.                 matchdot = g_matchdot;
  2876.                 g_matchdot = -1;
  2877.             }
  2878.             cmres();                    /* Reset buffer pointers. */
  2879.  
  2880. #ifdef OS2
  2881. #ifdef COMMENT
  2882.             /* we check to see if a macro is waiting to be executed */
  2883.             /* if so, we call domac on it */
  2884.             if (cmdmac) {
  2885.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2886.                 free(cmdmac);
  2887.                 cmdmac = NULL;
  2888.             }
  2889. #endif /* COMMENT */
  2890. #endif /* OS2 */
  2891. #ifndef NOXFER
  2892.             bye_active = 0;
  2893. #endif /* NOXFER */
  2894.             havetoken = 0;
  2895.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2896.             debug(F101,"top-level cmkey2","",xx);
  2897.             if (xx == -5) {
  2898.                 yy = chktok(toktab);
  2899.                 debug(F101,"top-level cmkey token","",yy);
  2900. #ifndef COMMENT
  2901.                 /* Either way makes absolutely no difference */
  2902.                 debug(F110,"NO UNGWORD",atmbuf,0);
  2903.                 /* ungword(); */
  2904. #else
  2905.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  2906.                 ungword();
  2907. #endif /* COMMENT */
  2908.                 switch (yy) {
  2909.                   case '#': xx = XXCOM; break; /* Comment */
  2910.                   case ';': xx = XXCOM; break; /* Comment */
  2911. #ifndef NOSPL
  2912.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  2913.                   case ':': xx = XXLBL; break; /* GOTO label */
  2914. #endif /* NOSPL */
  2915.  
  2916. #ifndef NOPUSH
  2917. #ifdef CK_REDIR
  2918.                   case '<':
  2919. #endif /* CK_REDIR */
  2920.                   case '@':
  2921.                   case '!':
  2922.                     if (nopush) {
  2923.                         char *s; int x;
  2924.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  2925.                           return(x);
  2926.                         success = 0;
  2927.                         xx = XXCOM;
  2928.                     } else {
  2929.                         switch(yy) {
  2930. #ifdef CK_REDIR
  2931.                           case '<': xx = XXFUN; break; /* REDIRECT */
  2932. #endif /* CK_REDIR */
  2933.                           case '@':
  2934.                           case '!': xx = XXSHE; break; /* Shell escape */
  2935.                         }
  2936.                     }
  2937.                     break;
  2938. #endif /* NOPUSH */
  2939. #ifdef CK_RECALL
  2940.                   case '^': xx = XXREDO;  break;
  2941. #endif /* CK_RECALL */
  2942. #ifndef NOSPL
  2943.                   case '{': xx = XXMACRO; break;
  2944.                   case '(': xx = XXSEXP;  break;
  2945. #endif /* NOSPL */
  2946.  
  2947.                   default:
  2948.                     if (!quiet) {
  2949.                         printf("\n?Invalid - \"%s\"\n",cmdbuf);
  2950. #ifdef COMMENT
  2951. #ifndef NOSPL
  2952.                         if (maclvl > -1 && xcmdsrc == 2)
  2953.                           printf("Macro: %s; ",
  2954.                                  m_arg[maclvl][0] ?
  2955.                                  m_arg[maclvl][0] : "");
  2956. #endif /* NOSPL */
  2957.                         if (tlevel > -1) {
  2958.                             printf("Command file: %s, line %d\n",
  2959.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  2960.                                    tfline[tlevel]
  2961.                                    );
  2962.                         }
  2963. #else
  2964.                         if (xcmdsrc > 0) {
  2965.                             printf("Command stack:\n");
  2966.                             shostack();
  2967.                         }
  2968. #endif /* COMMENT */
  2969.  
  2970.                     }
  2971.                     xx = -2;
  2972.                 }
  2973.                 havetoken = 1;
  2974.                 debug(F101,"HAVE TOKEN","",xx);
  2975.             }
  2976.             if (xx > -1) {
  2977.                 topcmd = xx;            /* Top-level command index */
  2978. #ifndef NOSPL
  2979.                 if (maclvl > -1)
  2980.                   lastcmd[maclvl] = xx;
  2981. #endif /* NOSPL */
  2982.                 debug(F101,"topcmd","",topcmd);
  2983.                 debug(F101,"cmflgs","",cmflgs);
  2984.             }
  2985.  
  2986. #ifndef NOSPL
  2987.             /* Special handling for IF..ELSE */
  2988.  
  2989.             debug(F101,"cmdlvl","",cmdlvl);
  2990.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  2991.  
  2992.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  2993.               ifcmd[cmdlvl]++;
  2994.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  2995.               ifcmd[cmdlvl] = 0;
  2996.  
  2997.             /* Execute the command and take action based on return code. */
  2998.  
  2999.             if (nulcmd) {               /* Ignoring this command? */
  3000.                 xx = XXCOM;             /* Make this command a comment. */
  3001.             }
  3002.             fnsuccess = 1;              /* For catching \function() errors */
  3003. #endif /* NOSPL */
  3004.  
  3005.             debug(F101,"calling docmd()","",xx);
  3006.             zz = docmd(xx);             /* Parse rest of command & execute. */
  3007.  
  3008. #ifndef NOSPL
  3009.             if (fnerror && !fnsuccess)
  3010.               success = 0;
  3011. #endif /* NOSPL */
  3012.             debug(F101,"docmd returns","",zz);
  3013.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  3014.             /* debug(F011,"atmbuf",atmbuf,30); */
  3015. #ifdef MAC
  3016.             if (tlevel > -1) {
  3017.                 if (sstate == 'a') {    /* if cmd-. cancel */
  3018.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  3019.                     sstate = '\0';
  3020.                     dostop();
  3021.                     return(0);          /* End of init file or whatever. */
  3022.                 }
  3023.             }
  3024. #endif /* MAC */
  3025.             switch (zz) {
  3026.               case -4:                  /* EOF (e.g. on redirected stdin) */
  3027.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  3028.               case -1:                  /* Reparse needed */
  3029.                 repars = 1;             /* Just set reparse flag and... */
  3030.                 continue;
  3031. #ifdef OS2
  3032.               case -7:                  /* They typed a disk letter */
  3033.                 if (!zchdir((char *)cmdbuf)) {
  3034.                     perror((char *)cmdbuf);
  3035.                     success = 0;
  3036.                 } else success = 1;
  3037.                 repars = 0;
  3038.                 continue;
  3039.  
  3040. #endif /* OS2 */
  3041.               case -6:                  /* Invalid command given w/no args */
  3042.               case -2:                  /* Invalid command given w/args */
  3043. #ifdef COMMENT
  3044. #ifndef NOSPL
  3045.                     /* This is going to be really ugly... */
  3046.                     yy = mlook(mactab,atmbuf,nmac); /* Look in macro table */
  3047.                     if (yy > -1) {                  /* If it's there */
  3048.                         if (zz == -2) {             /* insert "do" */
  3049.                             char *mp;
  3050.                             mp = malloc((int)strlen(cmdbuf) + 5);
  3051.                             if (!mp) {
  3052.                                 printf("?malloc error 1\n");
  3053.                                 return(-2);
  3054.                             }
  3055.                             sprintf(mp,"do %s ",cmdbuf); /* SAFE (checked) */
  3056.                             ckstrncpy(cmdbuf,mp,CMDBL);
  3057.                             free(mp);
  3058.                             mp = NULL;
  3059.                         } else {
  3060.                             if (((int)strlen(atmbuf) + 5) < CMDBL)
  3061.                               sprintf(cmdbuf,"do %s %c",atmbuf, CR); /* SAFE */
  3062.                             else
  3063.                               ckstrncpy(cmdbuf,"echo ?Too long\r",CMDBL);
  3064.                         }
  3065.                         if (ifcmd[cmdlvl] == 2) /* This one doesn't count! */
  3066.                           ifcmd[cmdlvl]--;
  3067.                         debug(F111,"stuff cmdbuf",cmdbuf,zz);
  3068.                         repars = 1;     /* Go for reparse */
  3069.                         continue;
  3070.                     } else {
  3071.                         char *p;
  3072.                         int n;
  3073.                         p = cmdbuf;
  3074.                         lp = line;
  3075.                         n = LINBUFSIZ;
  3076.                         if (cmflgs == 0) printf("\n");
  3077.                         if (zzstring(p,&lp,&n) > -1)
  3078.                           printf("?Invalid: %s\n",line);
  3079.                         else
  3080.                           printf("?Invalid: %s\n",cmdbuf);
  3081.                     } /* (fall thru...) */
  3082. #else
  3083.                     printf("?Invalid: %s\n",cmdbuf);
  3084. #endif /* NOSPL */
  3085. #else /* Not COMMENT */
  3086.                     printf("?Invalid: %s\n",cmdbuf);
  3087. #endif /* COMMENT */
  3088.  
  3089.                 case -9:                /* Bad, error message already done */
  3090.                     success = 0;
  3091.                     debug(F110,"top-level cmkey failed",cmdbuf,0);
  3092.                     /* If in background w/ commands coming stdin, terminate */
  3093.                     if (pflag == 0 && tlevel < 0)
  3094.                       fatal("Kermit command error in background execution");
  3095. /*
  3096.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3097.   reprompt the user with as much of the command as didn't fail.
  3098. */
  3099. #ifdef CK_RECALL
  3100.                     if (cm_retry && !xcmdsrc) { /* If at top level */
  3101.                         int len;
  3102.                         char *p, *s;
  3103.                         len = strlen(cmdbuf); /* Length of command buffer */
  3104.                         p = malloc(len + 1);  /* Allocate space for copy */
  3105.                         if (p) {              /* If we got the space copy */
  3106.                             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3107.                             /* Chop off final field, the one that failed. */
  3108.                             s = p + len - 1;          /* Point to end */
  3109.                             while (*s == SP && s > p) /* Trim blanks */
  3110.                               s--;
  3111.                             while (*s != SP && s > p) /* Trim last field */
  3112.                               s--;
  3113.                             if (s > p)        /* Keep the space */
  3114.                               s++;            /* after last good field */
  3115.                             if (s >= p)       /* Cut off remainder */
  3116.                               *s = NUL;
  3117.                             cmini(ckxech);    /* Reinitialize the parser */
  3118.                             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3119.                             free(p);          /* Free temporary storage */
  3120.                             p = NULL;
  3121.                             prompt(xxstring); /* Reprint the prompt */
  3122.                             printf("%s",cmdbuf); /* Reprint partial command */
  3123.                             repars = 1;          /* Force reparse */
  3124.                             continue;
  3125.                         }
  3126.                     } else
  3127. #endif /* CK_RECALL */
  3128.                       if (!quiet) {
  3129. #ifdef COMMENT
  3130. #ifndef NOSPL
  3131.                           if (maclvl > -1)
  3132.                             printf("Macro: %s; ",
  3133.                                    m_arg[maclvl][0] ?
  3134.                                    m_arg[maclvl][0] : "");
  3135. #endif /* NOSPL */
  3136.                           if (tlevel > -1)
  3137.                             printf("Command file: %s, line %d\n",
  3138.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  3139.                                    tfline[tlevel]
  3140.                                    );
  3141. #else
  3142.                           if (xcmdsrc > 0) {
  3143.                               printf("Command stack:\n");
  3144.                               shostack();
  3145.                           }
  3146. #endif /* COMMENT */
  3147.                       }
  3148.                       cmini(ckxech);    /* (fall thru) */
  3149.  
  3150.                 case -3:                /* Empty command OK at top level */
  3151.                     repars = 0;         /* Don't need to reparse. */
  3152.                     continue;           /* Go back and get another command. */
  3153.  
  3154.                 default:                /* Command was successful. */
  3155. #ifndef NOSPL
  3156.                     debug(F101,"parser preparing to continue","",maclvl);
  3157. #endif /* NOSPL */
  3158.                     debug(F101,"parser success","",success);
  3159.                     repars = 0;         /* Don't need to reparse. */
  3160.                     continue;           /* Go back and get another command. */
  3161.                 }
  3162.         }
  3163. #ifndef NOSPL
  3164.         debug(F101,"parser breaks out of while loop","",maclvl);
  3165.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3166. #endif /* NOSPL */
  3167.     }
  3168.  
  3169. /* Got an action command, return start state. */
  3170.  
  3171.     return((int) sstate);
  3172. }
  3173.  
  3174. #ifndef NOSPL
  3175. /*
  3176.   OUTPUT command.
  3177.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3178. */
  3179. #define OBSIZE 80                       /* Size of local character buffer */
  3180.  
  3181. static int obn;                         /* Buffer offset (high water mark) */
  3182. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3183. static char *obp;                       /* Pointer to output buffer. */
  3184. _PROTOTYP( static int oboc, (char) );
  3185. _PROTOTYP( static int xxout, (char *, int) );
  3186.  
  3187. static int
  3188. #ifdef CK_ANSIC
  3189. xxout(char *obuf, int obsize)
  3190. #else
  3191. xxout(obuf, obsize) char *obuf; int obsize;
  3192. #endif /* CK_ANSIC */
  3193. /* xxout */ {                           /* OUTPUT command's output function */
  3194.     int i, rc;
  3195.  
  3196.     debug(F101,"xxout obsize","",obsize);
  3197.     debug(F101,"xxout pacing","",pacing);
  3198.     debug(F111,"xxout string",obuf,strlen(obuf));
  3199.  
  3200.     rc = 0;                             /* Initial return code. */
  3201.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3202.       goto xxout_x;                     /* Return successfully */
  3203.  
  3204.     rc = -1;                              /* Now assume failure */
  3205.     if (pacing == 0) {                    /* Is pacing enabled? */
  3206.         if ((local ?                      /* No, write entire string at once */
  3207.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3208.              conxo(obsize, obuf))         /* or to console */
  3209.             != obsize)
  3210.           goto xxout_x;
  3211.     } else {
  3212.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3213.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3214.               goto xxout_x;
  3215.             msleep(pacing);
  3216.         }
  3217.     }
  3218.     if (duplex) {
  3219. #ifdef OS2
  3220.         if (inecho && local) {
  3221. #ifndef NOLOCAL
  3222.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3223.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3224.             }
  3225. #endif /* NOLOCAL */
  3226.             conxo(obsize,obuf);
  3227.         } else if (seslog) {            /* or log session here */
  3228.             logstr((char *) obuf, obsize);
  3229.         }
  3230. #else /* OS2 */
  3231.         if (seslog) {
  3232.             logstr((char *) obuf, obsize);
  3233.         }
  3234.         if (inecho && local) {
  3235.             conxo(obsize,obuf);
  3236.         }
  3237. #endif /* OS2 */
  3238.     }
  3239.     rc = 0;                             /* Success */
  3240.   xxout_x:
  3241.     obn = 0;                            /* Reset count */
  3242.     obp = obuf;                         /* and pointers */
  3243.     return(rc);                         /* return our return code */
  3244. }
  3245.  
  3246. #ifdef COMMENT
  3247. /*
  3248.   Macros for OUTPUT command execution, to make it go faster.
  3249. */
  3250. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3251. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3252.  
  3253. #else /* The macros cause some compilers to generate bad code. */
  3254.  
  3255. static int
  3256. #ifdef CK_ANSIC
  3257. oboc(char c)
  3258. #else
  3259. oboc(c) char c;
  3260. #endif /* CK_ANSIC */
  3261. /* oboc */ {                            /* OUTPUT command's output function */
  3262.  
  3263.     *obp++ = c;                         /* Deposit character */
  3264.     *obp = NUL;                         /* Flush buffer if it's now full */
  3265.  
  3266.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3267. }
  3268. #endif /* COMMENT */
  3269.  
  3270. /*  Routines for handling local variables -- also see popclvl().  */
  3271.  
  3272. VOID
  3273. freelocal(m) int m; {                   /* Free local variables */
  3274.     struct localvar * v, * tv;          /* at macro level m... */
  3275.     debug(F101,"freelocal level","",m);
  3276.     if (m < 0) return;
  3277.     v = localhead[m];                   /* List head for level m */
  3278.     while (v) {
  3279.         if (v->lv_name)                 /* Variable name */
  3280.           free(v->lv_name);
  3281.         if (v->lv_value)                /* Value */
  3282.           free(v->lv_value);
  3283.         tv = v;                         /* Save pointer to this node */
  3284.         v = v->lv_next;                 /* Get next one */
  3285.         if (tv)                         /* Free this one */
  3286.           free((char *)tv);
  3287.     }
  3288.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3289. }
  3290.  
  3291. #define MAXLOCALVAR 64
  3292.  
  3293. /* Return a pointer to the definition of a user-defined variable */
  3294.  
  3295. static char *
  3296. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3297.     char * p;
  3298.     char c;
  3299.     *isarray = 0;
  3300.     if (!s) return(NULL);
  3301.     if (!*s) return(NULL);
  3302.     p = s;
  3303.     if (*s == CMDQ) {
  3304.         p++;
  3305.         if (!*p)
  3306.           return(NULL);
  3307.         if ((c = *p) == '%') {          /* Scalar variable. */
  3308.             c = *++p;                   /* Get ID character. */
  3309.             p = "";                     /* Assume definition is empty */
  3310.             if (!c)
  3311.               return(NULL);
  3312.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3313.                 if (maclvl < 0)         /* Digit variables are global */
  3314.                   return(g_var[c]);     /* if no macro is active */
  3315.                 else                    /* otherwise */
  3316.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3317.             } else if (isalpha(c)) {
  3318.                 if (isupper(c)) c -= ('a'-'A');
  3319.                 return(g_var[c]);           /* Letter for global variable */
  3320.             } else
  3321.               return(NULL);
  3322.         } else if (c == '&') {          /* Array reference. */
  3323.             int x, vbi, d;
  3324.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3325.             if (x > -1 || d == -17) {
  3326.                 *isarray = 1;
  3327.                 *x1 = vbi;
  3328.                 *x2 = (d == -17) ? 0 : d;
  3329.             }
  3330.             if (x < 0)
  3331.               return(NULL);
  3332.             if (chkarray(vbi,d) > 0) {  /* Array is declared? */
  3333.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3334.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3335.                     char **ap;
  3336.                     ap = a_ptr[vbi];
  3337.                     return((ap) ? ap[d] : NULL);
  3338.                 }
  3339.             }
  3340.         }
  3341.         return(NULL);
  3342.     } else {
  3343.         int k;
  3344.         k = mxlook(mactab,s,nmac);
  3345.         return((k > -1) ? mactab[k].mval : NULL);
  3346.     }
  3347. }
  3348.  
  3349.  
  3350. int
  3351. addlocal(p) char * p; {
  3352.     int x, z, isarray = 0;
  3353.     char * s;
  3354.     struct localvar * v, *prev = (struct localvar *)NULL;
  3355.     extern int tra_asg; int tra_tmp;
  3356.  
  3357.     tra_tmp = tra_asg;
  3358.  
  3359.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3360.     if (isarray) {                      /* Arrays are handled specially */
  3361.         pusharray(x,z);
  3362.         return(0);
  3363.     }
  3364.     if (!s) s = "";
  3365.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3366.         while (v) {                     /* Find end of list */
  3367.             prev = v;
  3368.             v = v->lv_next;
  3369.         }
  3370.     }
  3371.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3372.     if (!v) {
  3373.         printf("?Failure to allocate storage for local variables");
  3374.         return(-9);
  3375.     }
  3376.     if (!localhead[cmdlvl])             /* If first, set list head */
  3377.       localhead[cmdlvl] = v;
  3378.     else                                /* Otherwise link previous to this */
  3379.       prev->lv_next = v;
  3380.     prev = v;                           /* And make this previous */
  3381.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3382.  
  3383.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3384.       return(-1);
  3385.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3386.  
  3387.     if (*s) {
  3388.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3389.           return(-1);
  3390.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3391.     } else
  3392.       v->lv_value = NULL;
  3393.  
  3394.     tra_asg = 0;
  3395.     delmac(p,1);                        /* Delete the original macro */
  3396.     tra_asg = tra_tmp;
  3397.     return(0);
  3398. }
  3399.  
  3400. int
  3401. dolocal() {                             /* Do the LOCAL command */
  3402.     int i, x;
  3403.     char * s;
  3404.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3405.  
  3406.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3407.       return(x);
  3408.  
  3409.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3410.  
  3411.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3412.  
  3413.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3414.         if (addlocal(list[i]) < 0)
  3415.           goto localbad;
  3416.     }
  3417.     return(success = 1);
  3418.  
  3419.   localbad:
  3420.     printf("?Failure to allocate storage for local variables");
  3421.     freelocal(cmdlvl);
  3422.     return(-9);
  3423. }
  3424.  
  3425. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3426.  
  3427. #ifndef NOKVERBS
  3428. #define K_BUFLEN 30
  3429. #define SEND_BUFLEN 255
  3430. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3431.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3432. #endif /* NOKVERBS */
  3433.  
  3434. int outesc = 1;                         /* Process special OUTPUT escapes */
  3435.  
  3436. int
  3437. dooutput(s, cx) char *s; int cx; {
  3438.  
  3439.     int x, xx, y, quote;                /* Workers */
  3440.     int is_tn = 0;
  3441.  
  3442.     is_tn = (local && network && IS_TELNET()) ||
  3443.       (!local && sstelnet);
  3444.  
  3445.     debug(F111,"dooutput s",s,(int)strlen(s));
  3446.  
  3447.     if (local) {                        /* Condition external line */
  3448. #ifdef NOLOCAL
  3449.         goto outerr;
  3450. #else
  3451.         if (ttchk() < 0) {
  3452.             printf("?Connection %s %s is not open.\n",
  3453.                    network ? "to" : "on",
  3454.                    ttname
  3455.                    );
  3456.             return(0);
  3457.         }
  3458.         if (ttvt(speed,flow) < 0) {
  3459.             printf("?OUTPUT initialization error\n");
  3460.             return(0);
  3461.         }
  3462. #endif /* NOLOCAL */
  3463.     }
  3464.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3465.         x = strlen(s);                  /* Just send the string literally */
  3466.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3467.         return(success = (xx == x) ? 1 : 0);
  3468.     }
  3469.     quote = 0;                          /* Initialize backslash (\) quote */
  3470.     obn = 0;                            /* Reset count */
  3471.     obp = obuf;                         /* and pointers */
  3472.  
  3473.   outagain:
  3474.     while ((x = *s++)) {                /* Loop through the string */
  3475.         y = 0;                          /* Error code, 0 = no error. */
  3476.         debug(F000,"dooutput","",x);
  3477.         if (quote) {                    /* This character is quoted */
  3478. #ifndef NOKVERBS
  3479.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3480.                extern struct keytab kverbs[];
  3481.                extern int nkverbs;
  3482.                extern char * keydefptr;
  3483.                extern int keymac;
  3484.                extern int keymacx;
  3485.                int x, y, brace = 0;
  3486.                int pause;
  3487.                char * p, * b;
  3488.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3489.                char osendbuf[SEND_BUFLEN +1];
  3490.                int  sendndx = 0;
  3491.  
  3492.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3493.                  goto outerr;
  3494.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3495.                {                        /* Have K verb? */
  3496.                    if (!*s) {
  3497.                        break;
  3498.                    }
  3499. /*
  3500.   We assume that the verb name is {braced}, or it extends to the end of the
  3501.   string, s, or it ends with a space, control character, or backslash.
  3502. */
  3503.                    p = kbuf;            /* Copy verb name into local buffer */
  3504.                    x = 0;
  3505.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3506.                        if (brace && *s == '}') {
  3507.                            break;
  3508.                        }
  3509.                        *p++ = *s++;
  3510.                    }
  3511.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3512.                      s--;               /*  back up so we get another look. */
  3513.                    brace = 0;
  3514.                    *p = NUL;            /* Terminate. */
  3515.                    p = kbuf;            /* Point back to beginning */
  3516.                    debug(F110,"dooutput kverb",p,0);
  3517.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3518.                    debug(F101,"dooutput lookup",0,y);
  3519.                    if (y > -1) {
  3520.                        if (sendndx) {
  3521.                            dooutput(osendbuf,cx);
  3522.                            sendndx = 0;
  3523.                        }
  3524.                        dokverb(VCMD,y);
  3525. #ifndef NOSPL
  3526.                    } else {             /* Is it a macro? */
  3527.                        y = mxlook(mactab,p,nmac);
  3528.                        if (y > -1) {
  3529.                            cmpush();
  3530.                            keymac = 1;  /* Flag for key macro active */
  3531.                            keymacx = y; /* Key macro index */
  3532.                            keydefptr = s; /* Where to resume next time */
  3533.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3534.                            parser(1);
  3535.                            cmpop();
  3536.                        }
  3537. #endif /* NOSPL */
  3538.                    }
  3539.                }
  3540.                quote = 0;
  3541.                continue;
  3542.            } else
  3543. #endif /* NOKVERBS */
  3544.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3545.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3546.                    goto outerr;
  3547.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3548.                  if (local)
  3549.                    ttoc(NUL);
  3550.                  else
  3551.                    conoc(NUL);
  3552.                  quote = 0;
  3553.                  continue;
  3554.  
  3555.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3556.  
  3557.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3558.                   goto outerr;
  3559.                 debug(F100,"OUTPUT BREAK","",0);
  3560. #ifndef NOLOCAL
  3561.                 ttsndb();               /* Send BREAK signal */
  3562. #else
  3563.                  if (local)
  3564.                    ttoc(NUL);
  3565.                  else
  3566.                    conoc(NUL);
  3567. #endif /* NOLOCAL */
  3568.                 quote = 0;              /* Turn off quote flag */
  3569.                 continue;               /* and not the b or B */
  3570. #ifdef CK_LBRK
  3571.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3572.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3573.                    goto outerr;
  3574.                  debug(F100,"OUTPUT Long BREAK","",0);
  3575. #ifndef NOLOCAL
  3576.                  ttsndlb();             /* Send Long BREAK signal */
  3577. #else
  3578.                  if (local)
  3579.                    ttoc(NUL);
  3580.                  else
  3581.                    conoc(NUL);
  3582. #endif /* NOLOCAL */
  3583.                  quote = 0;             /* Turn off quote flag */
  3584.                  continue;              /* and not the l or L */
  3585. #endif /* CK_LBRK */
  3586.  
  3587.              } else if (x == CMDQ) {    /* Backslash itself */
  3588.                  debug(F100,"OUTPUT CMDQ","",0);
  3589.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3590.                  if (xx < 0)
  3591.                    goto outerr;
  3592.                  quote = 0;
  3593.                  continue;
  3594.  
  3595.              } else {                   /* if \ not followed by special esc */
  3596.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3597.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3598.                  if (xx < 0)
  3599.                    goto outerr;
  3600.                  quote = 0;             /* Turn off quote flag */
  3601.              }
  3602.         } else if (x == CMDQ) {         /* This is the quote character */
  3603.             quote = 1;                  /* Go back and get next character */
  3604.             continue;                   /* which is quoted */
  3605.         }
  3606.         xx = oboc(dopar((char)x));      /* Output this character */
  3607.         debug(F111,"dooutput",obuf,obn);
  3608.         if (xx < 0)
  3609.           goto outerr;
  3610. #ifdef COMMENT
  3611.         if (seslog && duplex) {         /* Log the character if log is on */
  3612.             logchar((char)x);
  3613.         }
  3614. #endif /* COMMENT */
  3615.         if (x == '\015') {              /* String contains carriage return */
  3616.             int stuff = -1, stuff2 = -1;
  3617.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3618.                 stuff = LF;             /* Stuff LF */
  3619.             }
  3620. #ifdef TNCODE
  3621.             /* TELNET NEWLINE ON/OFF/RAW */
  3622.             if (is_tn) {
  3623.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3624.                         tn_b_nlm :
  3625.                         tn_nlm
  3626.                         ) {
  3627.                   case TNL_CR:
  3628.                     break;
  3629.                   case TNL_CRNUL:
  3630.                     stuff2 = stuff;
  3631.                     stuff  = NUL;
  3632.                     break;
  3633.                   case TNL_CRLF:
  3634.                     stuff2 = stuff;
  3635.                     stuff = LF;
  3636.                     break;
  3637.                 }
  3638.             }
  3639. #endif /* TNCODE */
  3640.             if (stuff > -1) {           /* Stuffing another character... */
  3641.                 xx = oboc(dopar((CHAR)stuff));
  3642.                 if (xx < 0)
  3643.                   goto outerr;
  3644. #ifdef COMMENT
  3645.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3646.                     logchar((char)stuff);
  3647.                 }
  3648. #endif /* COMMENT */
  3649.             }
  3650.             if (stuff2 > -1) {          /* Stuffing another character... */
  3651.                 xx = oboc(dopar((CHAR)stuff2));
  3652.                 if (xx < 0)
  3653.                   goto outerr;
  3654. #ifdef COMMENT
  3655.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3656.                     logchar((char)stuff2);
  3657.                 }
  3658. #endif /* COMMENT */
  3659.             }
  3660.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3661.               goto outerr;
  3662.         }
  3663.     }
  3664.     if (cx == XXLNOUT) {
  3665.         s = "\015";
  3666.         cx = 0;
  3667.         goto outagain;
  3668.     }
  3669.     if (quote == 1)                     /* String ended with backslash */
  3670.       xx = oboc(dopar(CMDQ));
  3671.  
  3672.     if (obn > 0)                        /* OUTPUT done */
  3673.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3674.         goto outerr;
  3675.     return(1);
  3676.  
  3677. outerr:                                 /* OUTPUT command error handler */
  3678.     if (msgflg) printf("?OUTPUT execution error\n");
  3679.     return(0);
  3680.  
  3681. /* Remove "local" OUTPUT macro defininitions */
  3682.  
  3683. #ifdef COMMENT
  3684. /* No more macros ... */
  3685. #undef oboc
  3686. #undef obfls
  3687. #endif /* COMMENT */
  3688. }
  3689. #endif /* NOSPL */
  3690.  
  3691. /* Display version herald and initial prompt */
  3692.  
  3693. VOID
  3694. herald() {
  3695.     int x = 0, i;
  3696.     extern int srvcdmsg;
  3697.     extern char * cdmsgfile[];
  3698. #ifndef NOCMDL
  3699.     extern char * bannerfile;
  3700.     debug(F110,"herald bannerfile",bannerfile,0);
  3701.     if (bannerfile) {
  3702.         concb((char)escape);
  3703.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3704.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3705.             if (srvcdmsg) {
  3706.                 for (i = 0; i < 8; i++) {
  3707.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3708.                     if (zchki(cdmsgfile[i]) > -1) {
  3709.                         printf("\n");
  3710.                         dotype(cdmsgfile[i],
  3711.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3712.                         break;
  3713.                     }
  3714.                 }
  3715.             }
  3716.             return;
  3717.         }
  3718.     }
  3719. #endif /* NOCMDL */
  3720.  
  3721. #ifdef COMMENT
  3722.     /* The following generates bad code in SCO compilers. */
  3723.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3724.     /* statement when all conditions are false, x has a value of -32. */
  3725.     if (noherald || bgset > 0 || (bgset != 0 && backgrd != 0)) x = 1;
  3726. #else
  3727.     x = 0;
  3728.     if (noherald)
  3729.       x = 1;
  3730.     else if (bgset > 0)
  3731.       x = 1;
  3732.     else if (bgset < 0 && backgrd > 0)
  3733.       x = 1;
  3734. #endif /* COMMENT */
  3735.  
  3736.     if (x == 0) {
  3737. #ifdef datageneral
  3738.         printf("%s, for%s\n",versio,ckxsys);
  3739. #else
  3740. #ifdef OSK
  3741.         printf("%s, for%s\n",versio,ckxsys);
  3742. #else
  3743.         printf("%s, for%s\n\r",versio,ckxsys);
  3744. #endif /* OSK */
  3745. #endif /* datageneral */
  3746.         printf(" Copyright (C) 1985, 2003,\n");
  3747.         printf("  Trustees of Columbia University in the City of New York.\n");
  3748.  
  3749. #ifdef OS2
  3750.        shoreg();
  3751. #endif /* OS2 */
  3752.  
  3753.         if (!quiet && !backgrd) {
  3754. #ifdef COMMENT
  3755. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3756.             char * s;
  3757.             extern int xfermode;
  3758. #ifdef VMS
  3759.             s = "AUTOMATIC";
  3760. #else
  3761.             if (xfermode == XMODE_A) {
  3762.                 s = "AUTOMATIC";
  3763.             } else {
  3764.                 s = gfmode(binary,1);
  3765.             }
  3766.             if (!s) s = "";
  3767. #endif /* VMS */
  3768.             if (*s)
  3769.               printf("Default file-transfer mode is %s\n", s);
  3770. #endif /* COMMENT */
  3771.  
  3772.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3773.             if (srvcdmsg) {
  3774.                 for (i = 0; i < 8; i++) {
  3775.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3776.                     if (zchki(cdmsgfile[i]) > -1) {
  3777.                         printf("\n");
  3778.                         dotype(cdmsgfile[i],
  3779.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3780.                         break;
  3781.                     }
  3782.                 }
  3783.             }
  3784.             printf("Type ? or HELP for help.\n");
  3785.         }
  3786.     }
  3787. }
  3788.  
  3789. /*  G F M O D E  --  Get File (transfer) Mode  */
  3790.  
  3791. char *
  3792. gfmode(binary,upcase) int binary, upcase; {
  3793.     char * s;
  3794.     switch (binary) {
  3795.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3796. #ifdef VMS
  3797.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3798.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3799.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3800.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3801. #else
  3802. #ifdef MAC
  3803.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3804.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3805. #else
  3806.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3807. #ifdef CK_LABELED
  3808.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3809. #endif /* CK_LABELED */
  3810. #endif /* MAC */
  3811. #endif /* VMS */
  3812.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3813.       default: s = "";
  3814.     }
  3815.     return(s);
  3816. }
  3817.  
  3818. #ifndef NOSPL
  3819. static int
  3820. isaa(s) char * s; {                     /* Is associative array */
  3821.     char c;
  3822.     int x;
  3823.     if (!s) s = "";
  3824.     if (!*s) return(0);
  3825.     s++;
  3826.     while ((c = *s++)) {
  3827.         if (c == '<') {
  3828.             x = strlen(s);
  3829.             return ((*(s+x-1) == '>') ? 1 : 0);
  3830.         }
  3831.     }
  3832.     return(0);
  3833. }
  3834.  
  3835. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3836.  
  3837. /*
  3838.   Call this way:  v = mlook(table,word,n);
  3839.  
  3840.     table - a 'struct mtab' table.
  3841.     word  - the target string to look up in the table.
  3842.     n     - the number of elements in the table.
  3843.  
  3844.   The keyword table must be arranged in ascending alphabetical order, and
  3845.   all letters must be lowercase.
  3846.  
  3847.   Returns the table index, 0 or greater, if the name was found, or:
  3848.  
  3849.    -3 if nothing to look up (target was null),
  3850.    -2 if ambiguous,
  3851.    -1 if not found.
  3852.  
  3853.   A match is successful if the target matches a keyword exactly, or if
  3854.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3855.   target matches two or more keywords from the table.
  3856. */
  3857. int
  3858. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3859.     register int i;
  3860.     int v, w, cmdlen = 0;
  3861.     char c = 0, c1, * s;
  3862.     if (!cmd) cmd = "";
  3863.  
  3864.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3865.     debug(F111,"MLOOK",cmd,cmdlen);
  3866.  
  3867.     c1 = *cmd;
  3868.     if (isupper(c1))
  3869.       c1 = tolower(c1);
  3870.     if (cmdlen < 1)
  3871.       return(-3);
  3872.  
  3873. /* Not null, look it up */
  3874.  
  3875.     if (n < 12) {                       /* Not worth it for small tables */
  3876.         i = 0;
  3877.     } else {                            /* Binary search for where to start */
  3878.         int lo = 0;
  3879.         int hi = n;
  3880.         int count = 0;
  3881.         while (lo+2 < hi && ++count < 12) {
  3882.             i = lo + ((hi - lo) / 2);
  3883.             c = *(table[i].kwd);
  3884.             if (isupper(c)) c = tolower(c);
  3885.             if (c < c1) {
  3886.                 lo = i;
  3887.             } else {
  3888.                 hi = i;
  3889.             }
  3890.         }
  3891.         i = (c < c1) ? lo+1 : lo;
  3892.     }
  3893.     for ( ; i < n-1; i++) {
  3894.         s = table[i].kwd;
  3895.         if (!s) s = "";
  3896.         if (!*s) continue;              /* Empty table entry */
  3897.         c = *s;
  3898.         if (isupper(c)) c = tolower(c);
  3899.         if (c1 != c) continue;          /* First char doesn't match */
  3900.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  3901.           return(i);
  3902.         v = !ckstrcmp(s,cmd,cmdlen,0);
  3903.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3904.         if (v && w)                     /* Have abbreviated match? */
  3905.           return(i);
  3906.         if (v)                          /* Ambiguous? */
  3907.           return(-2);
  3908.         if (w > 0)                      /* Past our alphabetic area? */
  3909.           return(-1);
  3910.     }
  3911.  
  3912. /* Last (or only) element */
  3913.  
  3914.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3915.       return(n-1);
  3916.  
  3917.     return(-1);
  3918. }
  3919.  
  3920. /* mxlook is like mlook, but an exact full-length match is required */
  3921.  
  3922. int
  3923. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3924.     register int i;
  3925.     int w, cmdlen = 0, one = 0;
  3926.     register char c = 0, c1, * s;
  3927.  
  3928.     if (!cmd) cmd = "";                 /* Check args */
  3929.  
  3930.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3931.     debug(F111,"MXLOOK",cmd,cmdlen);
  3932.  
  3933.     c1 = *cmd;                          /* First char of string to look up */
  3934.     if (isupper(c1))
  3935.       c1 = tolower(c1);
  3936.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  3937.       one = 1;
  3938.  
  3939.     if (cmdlen < 1)                     /* Nothing to look up */
  3940.       return(-3);
  3941.  
  3942.     if (n < 12) {                       /* Not worth it for small tables */
  3943.         i = 0;
  3944.     } else {                            /* Binary search for where to start */
  3945.         int lo = 0;
  3946.         int hi = n;
  3947.         int count = 0;
  3948.         while (lo+2 < hi && ++count < 12) {
  3949.             i = lo + ((hi - lo) / 2);
  3950.             c = *(table[i].kwd);
  3951.             if (isupper(c)) c = tolower(c);
  3952.             if (c < c1) {
  3953.                 lo = i;
  3954.             } else {
  3955.                 hi = i;
  3956.             }
  3957.         }
  3958.         i = (c < c1) ? lo+1 : lo;
  3959.     }
  3960.     for ( ; i < n; i++) {               /* Look thru table */
  3961.         s = table[i].kwd;               /* This entry */
  3962.         if (!s) s = "";
  3963.         if (!*s) continue;              /* Empty table entry */
  3964.         c = *s;
  3965.         if (isupper(c)) c = tolower(c);
  3966.         if (c1 != c) continue;          /* First char doesn't match */
  3967.         if (one) {                      /* Name is one char long */
  3968.             if (!*(s+1))
  3969.               return(i);                /* So is table entry */
  3970.         }
  3971. #ifdef COMMENT
  3972.         if (((int)strlen(s) == cmdlen) &&
  3973.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  3974. #else
  3975.         w = ckstrcmp(s,cmd,-1,0);
  3976.         if (!w) return(i);
  3977.         if (w > 0) return(-1);
  3978. #endif /* COMMENT */
  3979.     }
  3980.     return(-1);
  3981. }
  3982.  
  3983. /* mxxlook is like mxlook, but case-sensitive */
  3984.  
  3985. int
  3986. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3987.     int i, cmdlen;
  3988.     if (!cmd) cmd = "";
  3989.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  3990.     /* debug(F111,"mxxlook target",cmd,n); */
  3991.     for (i = 0; i < n; i++) {
  3992.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  3993.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  3994.           return(i);
  3995.     }
  3996.     return(-1);
  3997. }
  3998.  
  3999. static int
  4000. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  4001.     if (val)
  4002.       printf(">>> %s: \"%s\"\n", nam, val);
  4003.     else
  4004.       printf(">>> %s: (undef)\n", nam);
  4005.     return(0);
  4006. }
  4007.  
  4008. #ifdef USE_VARLEN                       /* Not used */
  4009.  
  4010. /*  V A R L E N  --  Get length of variable's value.
  4011.  
  4012.   Given a variable name, return the length of its definition or 0 if the
  4013.   variable is not defined.  If it is defined, set argument s to point to its
  4014.   definition.  Otherwise set s to NULL.
  4015. */
  4016. int
  4017. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  4018.     int x, z;
  4019.     char *p = NULL, c;
  4020.  
  4021.     *s = NULL;
  4022.     if (!nam) return(0);                /* Watch out for null pointer */
  4023.     if (*nam == CMDQ) {
  4024.         nam++;
  4025.         if (*nam == '%') {              /* If it's a variable name */
  4026.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  4027.             p = (char *)0;              /* Initialize value pointer */
  4028.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4029.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  4030.             } else {                    /* It's a global variable */
  4031.                 if (c < 33 || c > GVARS) return(0);
  4032.                 p = g_var[c];           /* Get pointer from global-var table */
  4033.             }
  4034.         } else if (*nam == '&') {               /* An array reference? */
  4035.             char **q;
  4036.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4037.               return(-1);               /* return -1. */
  4038.             x -= ARRAYBASE;             /* Convert name to number. */
  4039.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4040.               return(0);                /* return -2. */
  4041.             if (z > a_dim[x])           /* If subscript out of range, */
  4042.               return(0);                /* return -3. */
  4043.             p = q[z];
  4044.         }
  4045.     } else {                            /* Macro */
  4046.         z = isaa(nam);
  4047.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  4048.         if (x < 0)
  4049.           return(0);
  4050.         p = mactab[x].mval;
  4051.     }
  4052.     if (p)
  4053.       *s = p;
  4054.     else
  4055.       p = "";
  4056.     return((int)strlen(p));
  4057. }
  4058. #endif /* USE_VARLEN */
  4059.  
  4060. /*
  4061.   This routine is for the benefit of those compilers that can't handle
  4062.   long string constants or continued lines within them.  Long predefined
  4063.   macros like FOR, WHILE, and XIF have their contents broken up into
  4064.   arrays of string pointers.  This routine concatenates them back into a
  4065.   single string again, and then calls the real addmac() routine to enter
  4066.   the definition into the macro table.
  4067. */
  4068. int
  4069. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  4070.     int i, x, y; char *p;
  4071.     x = 0;                              /* Length counter */
  4072.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  4073.         debug(F111,"addmmac line",s[i],y);
  4074.         x += y;
  4075.     }
  4076.     debug(F101,"addmmac lines","",i);
  4077.     debug(F101,"addmmac loop exit","",y);
  4078.     debug(F111,"addmmac length",nam,x);
  4079.     if (x < 0) return(-1);
  4080.  
  4081.     p = malloc(x+1);                    /* Allocate space for all of it. */
  4082.     if (!p) {
  4083.         printf("?addmmac malloc error: %s\n",nam);
  4084.         debug(F110,"addmmac malloc error",nam,0);
  4085.         return(-1);
  4086.     }
  4087.     *p = '\0';                          /* Start off with null string. */
  4088.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4089.       ckstrncat(p,s[i],x+1);
  4090.     y = (int)strlen(p);                 /* Final precaution. */
  4091.     debug(F111,"addmmac constructed string",p,y);
  4092.     if (y == x) {
  4093.         y = addmac(nam,p);              /* Add result to the macro table. */
  4094.     } else {
  4095.         debug(F100,"addmmac length mismatch","",0);
  4096.         printf("\n!addmmac internal error!\n");
  4097.         y = -1;
  4098.     }
  4099.     free(p);                            /* Free the temporary copy. */
  4100.     return(y);
  4101. }
  4102.  
  4103. /* Here is the real addmac routine. */
  4104.  
  4105. /* Returns -1 on failure, macro table index >= 0 on success. */
  4106.  
  4107. int mtchanged = 0;
  4108.  
  4109. int
  4110. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4111.     int i, x, y, z, namlen, deflen, flag = 0;
  4112.     int replacing = 0, deleting = 0;
  4113.     char * p = NULL, c, *s;
  4114.     extern int tra_asg; int tra_tmp;
  4115.  
  4116.     if (!nam) return(-1);
  4117.     if (!*nam) return(-1);
  4118.  
  4119. #ifdef IKSD
  4120.     if (inserver &&
  4121. #ifdef IKSDCONF
  4122.         iksdcf
  4123. #else /* IKSDCONF */
  4124.         1
  4125. #endif /* IKSDCONF */
  4126.         ) {
  4127.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4128.             !ckstrcmp("on_logout",nam,-1,0))
  4129.           return(-1);
  4130.     }
  4131. #endif /* IKSD */
  4132.  
  4133.     namlen = 0;
  4134.     p = nam;
  4135.     while (*p++) namlen++;              /* (instead of strlen) */
  4136.  
  4137.     tra_tmp = tra_asg;                  /* trace... */
  4138.     debug(F111,"addmac nam",nam,namlen);
  4139.     if (!def) {                         /* Watch out for null pointer */
  4140.         deflen = 0;
  4141.         debug(F111,"addmac def","(null pointer)",deflen);
  4142.     } else {
  4143.         deflen = 0;
  4144.         p = def;
  4145.         while (*p++) deflen++;          /* (instead of strlen) */
  4146.         debug(F010,"addmac def",def,0);
  4147.     }
  4148. #ifdef USE_VARLEN                       /* NOT USED */
  4149.     /* This does not boost performance much because varlen() does a lot */
  4150.     x = varlen(nam,&s);
  4151.     if (x > 0 && x >= deflen) {
  4152.         strcpy(s,def);                  /* NOT USED */
  4153.         flag = 1;
  4154.         p = s;
  4155.     }
  4156. #endif /* USE_VARLEN */
  4157.  
  4158.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4159.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4160.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4161.         if (!flag) {
  4162.             tra_asg = 0;
  4163.             delmac(nam,0);              /* Delete any old value. */
  4164.             tra_asg = tra_tmp;
  4165.         }
  4166.         if (deflen < 1) {               /* Null definition */
  4167.             p = NULL;                   /* Better not malloc or strcpy! */
  4168.         } else if (!flag) {             /* A substantial definition */
  4169.             p = malloc(deflen + 1);     /* Allocate space for it */
  4170.             if (!p) {
  4171.                 printf("?addmac malloc error 2\n");
  4172.                 return(-1);
  4173.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4174.         }
  4175.  
  4176.         /* Now p points to the definition, or is a null pointer */
  4177.  
  4178.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4179.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4180.                 g_var[c] = p;           /* No, it's top level one */
  4181.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4182.             } else {                    /* Yes, it's a macro argument */
  4183.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4184.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4185.             }
  4186.         } else {                        /* It's a \%a-z variable */
  4187.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4188.             if (isupper(c)) c = (char) tolower(c);
  4189.             g_var[c] = p;               /* Put pointer in global-var table */
  4190.         }
  4191.         if (tra_asg) traceval(nam,p);
  4192.         return(0);
  4193.     } else if (*nam == '&') {           /* An array reference? */
  4194.         char **q = NULL;
  4195.         int rc = 0;
  4196.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4197.           return(-1);                   /* return -1. */
  4198.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4199.           rc = -2;                      /* subscript out of range, ret -2 */
  4200.         if (!flag) {
  4201.             tra_asg = 0;
  4202.             delmac(nam,0);              /* Delete any old value. */
  4203.             tra_asg = tra_tmp;
  4204.         }
  4205.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4206.         if (x > 'z' - ARRAYBASE + 1)
  4207.           rc = -1;
  4208.         if (rc != -1) {
  4209.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4210.               return(-3);               /* return -3. */
  4211.         }
  4212.         if (rc < 0)
  4213.           return(rc);
  4214.         if (!flag) {
  4215.             if (deflen > 0) {
  4216.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4217.                     printf("addmac macro error 7: %s\n",nam);
  4218.                     return(-4);         /* for new def, return -4 on fail. */
  4219.                 }
  4220.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4221.             } else p = NULL;
  4222.         }
  4223.         q[z] = p;                       /* Store pointer to it. */
  4224.         if (x == 0) {                   /* Arg vector array */
  4225.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4226.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4227.                     makestr(&(toparg[z]),p);
  4228.                 } else {
  4229.                     makestr(&(m_arg[maclvl][z]),p);
  4230.                 }
  4231.             }
  4232.         }
  4233.         if (tra_asg) traceval(nam,p);
  4234.         return(0);                      /* Done. */
  4235.     }
  4236.  
  4237. /* Not a macro argument or a variable, so it's a macro definition */
  4238.  
  4239. #ifdef USE_VARLEN
  4240.     if (flag) {
  4241.         if (tra_asg) traceval(nam,p);
  4242.         return(0);
  4243.     }
  4244. #endif /* USE_VARLEN */
  4245.     x = isaa(nam) ?                     /* If it's an associative array */
  4246.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4247.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4248.     if (x > -1) {                       /* If found... */
  4249.         if (deflen > 0)                 /* and a new definition was given */
  4250.           replacing = 1;                /* we're replacing */
  4251.         else                            /* otherwise */
  4252.           deleting = 1;                 /* we're deleting */
  4253.     }
  4254.     if (deleting) {                     /* Deleting... */
  4255.         if (delmac(nam,0) < 0)
  4256.           return(-1);
  4257.         mtchanged++;
  4258.         if (tra_asg) traceval(nam,p);
  4259.         return(0);
  4260.     } else if (deflen < 1)              /* New macro with no definition */
  4261.       return(0);                        /* Nothing to do. */
  4262.  
  4263.     if (replacing) {                    /* Replacing an existing macro */
  4264.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4265.             free(mactab[x].mval);       /* free it. */
  4266.             mactab[x].mval = NULL;
  4267.         }
  4268.         mtchanged++;
  4269.         y = x;                          /* Replacement index. */
  4270.  
  4271.     } else {                            /* Adding a new macro... */
  4272.         char c1, c2;                    /* Use fast lookup to find the */
  4273.         c1 = *nam;                      /* alphabetical slot. */
  4274.         if (isupper(c1)) c1 = (char) tolower(c1);
  4275.  
  4276.         if (nmac < 5) {                 /* Not worth it for small tables */
  4277.             y = 0;
  4278.         } else {                        /* First binary search to find */
  4279.             int lo = 0;                 /* where to start */
  4280.             int hi = nmac;
  4281.             int count = 0;
  4282.             char c = 0;
  4283.             while (lo+2 < hi && ++count < 12) {
  4284.                 y = lo + ((hi - lo) / 2);
  4285.                 c = *(mactab[y].kwd);
  4286.                 if (isupper(c)) c = (char) tolower(c);
  4287.                 if (c < c1) {
  4288.                     lo = y;
  4289.                 } else {
  4290.                     hi = y;
  4291.                 }
  4292.             }
  4293.             y = (c < c1) ? lo+1 : lo;
  4294.         }
  4295.         /* Now search linearly from starting location */
  4296.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4297.             c2 = *(mactab[y].kwd);
  4298.             if (isupper(c2)) c2 = (char) tolower(c2);
  4299.             if (c1 > c2)
  4300.               continue;
  4301.             if (c1 < c2)
  4302.               break;
  4303.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4304.               break;
  4305.         }
  4306.         if (y == MAC_MAX) {             /* Macro table is full. */
  4307.             debug(F101,"addmac table overflow","",y);
  4308.             printf("?Macro table overflow\n");
  4309.             return(-1);
  4310.         }
  4311.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4312.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4313.                 mactab[i].kwd = mactab[i-1].kwd;
  4314.                 mactab[i].mval = mactab[i-1].mval;
  4315.                 mactab[i].flgs = mactab[i-1].flgs;
  4316.             }
  4317.         }
  4318.         mtchanged++;
  4319.         p = malloc(namlen + 1);         /* Allocate space for name */
  4320.         if (!p) {
  4321.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4322.             return(-1);
  4323.         }
  4324.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4325.         mactab[y].kwd = p;              /* Add pointer to table */
  4326.     }
  4327.     if (deflen > 0) {                   /* If we have a definition */
  4328.         p = malloc(deflen + 1);         /* Get space */
  4329.         if (p == NULL) {
  4330.             printf("?Space exhausted - \"%s\"\n", nam);
  4331.             if (mactab[y].kwd) {
  4332.                 free(mactab[y].kwd);
  4333.                 mactab[y].kwd = NULL;
  4334.             }
  4335.             return(-1);
  4336.         } else {
  4337.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4338.         }
  4339.     } else {                            /* definition is empty */
  4340.         p = NULL;
  4341.     }
  4342.     mactab[y].mval = p;                 /* Macro points to definition */
  4343.     mactab[y].flgs = 0;                 /* No flags */
  4344.     if (!replacing)                     /* If new macro */
  4345.       nmac++;                           /* count it */
  4346.     if (tra_asg) traceval(nam,p);
  4347.     return(y);
  4348. }
  4349.  
  4350. int
  4351. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4352.     int i;
  4353.     extern int tra_asg;
  4354.     if (x < 0) return(x);
  4355.     if (tra_asg)
  4356.       traceval(mactab[x].kwd,NULL);
  4357.  
  4358.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4359.         free(mactab[x].kwd);
  4360.         mactab[x].kwd = NULL;
  4361.     }
  4362.     if (mactab[x].mval) {               /* and for the definition */
  4363.         free(mactab[x].mval);
  4364.         mactab[x].mval = NULL;
  4365.     }
  4366.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4367.         mactab[i].kwd = mactab[i+1].kwd;
  4368.         mactab[i].mval = mactab[i+1].mval;
  4369.         mactab[i].flgs = mactab[i+1].flgs;
  4370.     }
  4371.     nmac--;                             /* One less macro */
  4372.  
  4373.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4374.     mactab[nmac].mval = NULL;
  4375.     mactab[nmac].flgs = 0;
  4376.     mtchanged++;
  4377.     return(0);
  4378. }
  4379.  
  4380. int
  4381. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4382.     int x, z;
  4383.     char *p, c;
  4384.     extern int tra_asg;
  4385.  
  4386.     if (!nam) return(0);                /* Watch out for null pointer */
  4387.     debug(F110,"delmac nam",nam,0);
  4388. #ifdef IKSD
  4389.     if ( inserver &&
  4390. #ifdef IKSDCONF
  4391.         iksdcf
  4392. #else /* IKSDCONF */
  4393.         1
  4394. #endif /* IKSDCONF */
  4395.         ) {
  4396.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4397.             !ckstrcmp("on_logout",nam,-1,0))
  4398.           return(-1);
  4399.     }
  4400. #endif /* IKSD */
  4401.  
  4402.     if (*nam == CMDQ) nam++;
  4403.     if (*nam == '%') {                  /* If it's a variable name */
  4404.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4405.         p = (char *)0;                  /* Initialize value pointer */
  4406.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4407.             p = toparg[c - '0'];
  4408.             if (p) if (p != g_var[c]) {
  4409.                 free(p);
  4410.                 toparg[c - '0'] = NULL;
  4411.             }
  4412.             p = g_var[c];
  4413.             g_var[c] = NULL;            /* Zero the table entry */
  4414.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4415.             p = m_xarg[maclvl][c - '0'];
  4416.             if (p) if (p != g_var[c]) {
  4417.                 free(p);
  4418.                 m_xarg[maclvl][c - '0'] = NULL;
  4419.             }
  4420.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4421.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4422.         } else {                        /* It's a global variable */
  4423.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4424.             p = g_var[c];               /* Get pointer from global-var table */
  4425.             g_var[c] = NULL;            /* Zero the table entry */
  4426.         }
  4427.         if (p) {
  4428.             debug(F010,"delmac def",p,0);
  4429.             free(p);                    /* Free the storage */
  4430.             p = NULL;
  4431.         } else debug(F110,"delmac def","(null pointer)",0);
  4432.         if (tra_asg) traceval(nam,NULL);
  4433.         return(0);
  4434.     }
  4435.     if (*nam == '&') {                  /* An array reference? */
  4436.         char **q;
  4437.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4438.           return(-1);                   /* return -1. */
  4439.         x -= ARRAYBASE;                 /* Convert name to number. */
  4440.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4441.           return(-2);                   /* return -2. */
  4442.         if (z > a_dim[x])               /* If subscript out of range, */
  4443.           return(-3);                   /* return -3. */
  4444.         if (q[z]) {                     /* If there is an old value, */
  4445.             debug(F010,"delmac def",q[z],0);
  4446.             if (x != 0)                 /* Macro arg vector is just a copy */
  4447.               free(q[z]);               /* Others are real so free them */
  4448.             q[z] = NULL;
  4449.             if (x == 0) {               /* Arg vector array */
  4450.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4451.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4452.                         makestr(&(toparg[z]),NULL);
  4453.                     } else {
  4454.                         makestr(&(m_arg[maclvl][z]),NULL);
  4455.                     }
  4456.                 }
  4457.             }
  4458.             if (tra_asg) traceval(nam,NULL);
  4459.         } else debug(F010,"delmac def","(null pointer)",0);
  4460.     }
  4461.  
  4462.    /* Not a variable or an array, so it must be a macro. */
  4463.  
  4464.     z = isaa(nam);
  4465.     debug(F111,"delmac isaa",nam,z);
  4466.     debug(F111,"delmac exact",nam,exact);
  4467.     x = z ? mxxlook(mactab,nam,nmac) :
  4468.       exact ? mxlook(mactab,nam,nmac) :
  4469.         mlook(mactab,nam,nmac);
  4470.     if (x < 0) {
  4471.         debug(F111,"delmac mlook",nam,x);
  4472.         return(x);
  4473.     }
  4474.     return(xdelmac(x));
  4475. }
  4476.  
  4477. VOID
  4478. initmac() {                             /* Init macro & variable tables */
  4479.     int i, j, x;
  4480.  
  4481.     nmac = 0;                           /* No macros */
  4482.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4483.         mactab[i].kwd = NULL;
  4484.         mactab[i].mval = NULL;
  4485.         mactab[i].flgs = 0;
  4486.     }
  4487.     mtchanged++;
  4488.     x = (MAXARGLIST + 1) * sizeof(char **);
  4489.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4490.         m_xarg[i] = (char **) malloc(x);
  4491.         mrval[i] = NULL;                /* Macro return value */
  4492.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4493.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4494.             if (j < 10)                 /* For the \%0..\%9 variables */
  4495.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4496.             if (m_xarg[i])              /* For \&_[] - all args. */
  4497.               m_xarg[i][j] = NULL;
  4498.         }
  4499.     }
  4500.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4501.         g_var[i] = NULL;
  4502.     }
  4503.     /* And the table of arrays */
  4504.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4505.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4506.         a_dim[i] = 0;                   /* and a dimension of zero */
  4507.         a_link[i] = -1;
  4508.         for (j = 0; j < CMDSTKL; j++) {
  4509.             aa_ptr[j][i] = (char **) NULL;
  4510.             aa_dim[j][i] = 0;
  4511.         }
  4512.     }
  4513. }
  4514.  
  4515. int
  4516. popclvl() {                             /* Pop command level, return cmdlvl */
  4517.     extern int tra_cmd;
  4518.     struct localvar * v;
  4519.     int i, topcmd;
  4520.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4521.     if (cmdlvl > 0) {
  4522.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4523.             while (v) {                 /* Yes */
  4524.                 if (v->lv_value)        /* Copy old ones back */
  4525.                   addmac(v->lv_name,v->lv_value);
  4526.                 else
  4527.                   delmac(v->lv_name,1);
  4528.                 v = v->lv_next;
  4529.             }
  4530.             freelocal(cmdlvl);          /* Free local storage */
  4531.         }
  4532.         /* Automatic arrays do not use the localhead list */
  4533.  
  4534.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4535.             if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
  4536.                 dclarray((char)(i+ARRAYBASE),0); /* Destroy global one */
  4537.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4538.                 a_dim[i] = aa_dim[cmdlvl][i];
  4539.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4540.                 aa_dim[cmdlvl][i] = 0;
  4541.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4542.                 dclarray((char)(i+ARRAYBASE),0); /* (see pusharray()) */
  4543.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4544.                 aa_dim[cmdlvl][i] = 0;
  4545.             }
  4546.             /* Otherwise do nothing - it is a local array that was declared */
  4547.             /* at a level above this one so leave it alone. */
  4548.         }
  4549.     }
  4550.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4551.         cmdlvl = 0;                     /* just make sure all the */
  4552.         tlevel = -1;                    /* stack pointers are set right */
  4553.         maclvl = -1;                    /* and return */
  4554.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4555.         debug(F101,"popclvl tlevel","",tlevel);
  4556.         if (tlevel > -1) {              /* Yes, */
  4557.             fclose(tfile[tlevel]);      /* close it */
  4558.  
  4559.             if (tra_cmd)
  4560.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4561.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4562.             if (tfnam[tlevel]) {        /* free storage for name */
  4563.                 free(tfnam[tlevel]);
  4564.                 tfnam[tlevel] = NULL;
  4565.             }
  4566.             tlevel--;                   /* and pop take level */
  4567.             cmdlvl--;                   /* and command level */
  4568.             quiet = xquiet[cmdlvl];
  4569.         } else
  4570.           tlevel = -1;
  4571.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4572.         topcmd = lastcmd[maclvl];
  4573.         debug(F101,"popclvl maclvl","",maclvl);
  4574.         if (maclvl > -1) {              /* Yes, */
  4575. #ifdef COMMENT
  4576.             int i;
  4577.             char **q;
  4578. #endif /* COMMENT */
  4579.             macp[maclvl] = "";          /* set macro pointer to null string */
  4580.             *cmdbuf = '\0';             /* clear the command buffer */
  4581.  
  4582.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4583.                 (m_arg[maclvl-1][0]) &&
  4584.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4585.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4586.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4587.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4588.                 mrval[maclvl+1]) {
  4589.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4590.             }
  4591.             if (maclvl+1 < MACLEVEL) {
  4592.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4593.                     free(mrval[maclvl+1]);
  4594.                     mrval[maclvl+1] = NULL;
  4595.                 }
  4596.             }
  4597.             if (tra_cmd)
  4598.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4599.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4600.  
  4601.             maclvl--;                   /* Pop macro level */
  4602.             cmdlvl--;                   /* and command level */
  4603.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4604.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4605.  
  4606.             quiet = xquiet[cmdlvl];
  4607.             if (maclvl > -1) {
  4608.                 a_ptr[0] = m_xarg[maclvl];
  4609.                 a_dim[0] = n_xarg[maclvl] - 1;
  4610.         debug(F111,"a_dim[0]","B",a_dim[0]);
  4611.             } else {
  4612.                 a_ptr[0] = topxarg;
  4613.                 a_dim[0] = topargc - 1;
  4614.         debug(F111,"a_dim[0]","C",a_dim[0]);
  4615.             }
  4616.         } else {
  4617.             maclvl = -1;
  4618.         }
  4619. #ifndef NOSEXP
  4620.         debug(F101,"popclvl topcmd","",topcmd);
  4621.         if (topcmd == XXSEXP) {
  4622.             extern char * sexpval;
  4623.             makestr(&(mrval[maclvl+1]),sexpval);
  4624.         }
  4625. #endif /* NOSEXP */
  4626.     } else {
  4627.         cmdlvl--;
  4628.     }
  4629.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4630.     if (prstring[cmdlvl]) {
  4631.         cmsetp(prstring[cmdlvl]);
  4632.         makestr(&(prstring[cmdlvl]),NULL);
  4633.     }
  4634. #ifndef MAC
  4635.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4636.         setint();
  4637.         concb((char)escape);            /* Go into cbreak mode */
  4638.     }
  4639. #endif /* MAC */
  4640.     xcmdsrc = cmdstk[cmdlvl].src;
  4641.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4642.     debug(F101,"popclvl tlevel","",tlevel);
  4643.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4644. }
  4645. #else /* No script programming language */
  4646. int popclvl() {                         /* Just close current take file. */
  4647.     if (tlevel > -1) {                  /* if any... */
  4648.         if (tfnam[tlevel]) {
  4649.             free(tfnam[tlevel]);
  4650.             tfnam[tlevel] = NULL;
  4651.         }
  4652.         fclose(tfile[tlevel--]);
  4653.     }
  4654.     if (tlevel == -1) {                 /* And if back at top level */
  4655.         setint();
  4656.         concb((char)escape);            /* and go back into cbreak mode. */
  4657.     }
  4658.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4659.     return(tlevel + 1);
  4660. }
  4661. #endif /* NOSPL */
  4662.  
  4663.  
  4664. #ifndef NOSPL
  4665. static int
  4666. iseom(m) char * m; {                    /* Test if at end of macro def */
  4667.     if (!m)
  4668.       m = "";
  4669.     debug(F111,"iseom",m,maclvl);
  4670.     while (*m) {
  4671.         /* Anything but Space and Comma means more macro is left */
  4672.         if ((*m > SP) && (*m != ',')) {
  4673.             debug(F111,"iseom return",m,0);
  4674.             return(0);
  4675.         }
  4676.         m++;
  4677.     }
  4678.     debug(F111,"iseom return",m,1);
  4679.     return(1);                          /* Nothing left */
  4680. }
  4681. #endif /* NOSPL */
  4682.  
  4683. /* Pop all command levels that can be popped */
  4684.  
  4685. int
  4686. prepop() {
  4687.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4688.         while (
  4689. #ifndef NOSPL
  4690.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4691. #endif /* NOSPL */
  4692.             (tlevel > -1) &&
  4693.             feof(tfile[tlevel]))        /* And at end of file... */
  4694. #ifndef NOSPL
  4695.                /* Or command source is macro... */
  4696.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4697.                 (maclvl > -1) &&
  4698.                 iseom(macp[maclvl])))  /* and at end of macro, then... */
  4699. #endif /* NOSPL */
  4700.         {
  4701.               popclvl();                /* pop command level. */
  4702.         }
  4703.     }
  4704.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4705. }
  4706.  
  4707. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4708.  
  4709. int
  4710. dostop() {
  4711.     extern int cmddep;
  4712.     while (popclvl()) ;         /* Pop all macros & take files */
  4713. #ifndef NOSPL
  4714.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4715.       while (cmpop() > -1) ;
  4716. #endif /* NOSPL */
  4717.     cmini(ckxech);              /* Clear the command buffer. */
  4718.     return(0);
  4719. }
  4720.  
  4721. /* Close the given log */
  4722.  
  4723. int
  4724. doclslog(x) int x; {
  4725.     int y;
  4726.     switch (x) {
  4727. #ifdef DEBUG
  4728.       case LOGD:
  4729.         if (deblog <= 0) {
  4730.             printf("?Debugging log wasn't open\n");
  4731.             return(0);
  4732.         }
  4733.         debug(F100,"Debug Log Closed","",0L);
  4734.         *debfil = '\0';
  4735.         deblog = 0;
  4736.         return(zclose(ZDFILE));
  4737. #endif /* DEBUG */
  4738.  
  4739. #ifndef NOXFER
  4740.       case LOGP:
  4741.         if (pktlog <= 0) {
  4742.             printf("?Packet log wasn't open\n");
  4743.             return(0);
  4744.         }
  4745.         *pktfil = '\0';
  4746.         pktlog = 0;
  4747.         return(zclose(ZPFILE));
  4748. #endif /* NOXFER */
  4749.  
  4750. #ifndef NOLOCAL
  4751.       case LOGS:
  4752.         if (seslog <= 0) {
  4753.             printf("?Session log wasn't open\n");
  4754.             return(0);
  4755.         }
  4756.         *sesfil = '\0';
  4757.         setseslog(0);
  4758.         return(zclose(ZSFILE));
  4759. #endif /* NOLOCAL */
  4760.  
  4761. #ifdef TLOG
  4762.       case LOGT: {
  4763. #ifdef IKSD
  4764.           extern int iklogopen, xferlog;
  4765. #endif /* IKSD */
  4766.           if (tralog <= 0
  4767. #ifdef IKSD
  4768.               && !iklogopen
  4769. #endif /* IKSD */
  4770.               ) {
  4771.               if (msgflg)
  4772.                 printf("?Transaction log wasn't open\n");
  4773.               return(0);
  4774.           }
  4775. #ifdef IKSD
  4776.           if (iklogopen && !inserver) {
  4777.               close(xferlog);
  4778.               iklogopen = 0;
  4779.           }
  4780. #endif /* IKSD */
  4781.           if (tralog) {
  4782.               tlog(F100,"Transaction Log Closed","",0L);
  4783.               zclose(ZTFILE);
  4784.           }
  4785.           *trafil = '\0';
  4786.           tralog = 0;
  4787.           return(1);
  4788.       }
  4789. #endif /* TLOG */
  4790.  
  4791. #ifdef CKLOGDIAL
  4792.       case LOGM:
  4793.         if (dialog <= 0) {
  4794.             if (msgflg) printf("?Connection log wasn't open\n");
  4795.             return(0);
  4796.         }
  4797.         *diafil = '\0';
  4798.         dialog = 0;
  4799.         return(zclose(ZDIFIL));
  4800. #endif /* CKLOGDIAL */
  4801.  
  4802. #ifndef NOSPL
  4803.       case LOGW:                        /* WRITE file */
  4804.       case LOGR:                        /* READ file */
  4805.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4806.         if (chkfn(y) < 1)               /* If no file to close */
  4807.           return(1);                    /* succeed silently. */
  4808.         return(zclose(y));              /* Otherwise, close the file. */
  4809. #endif /* NOSPL */
  4810.  
  4811.       default:
  4812.         printf("\n?Unexpected log designator - %d\n", x);
  4813.         return(0);
  4814.     }
  4815. }
  4816.  
  4817. static int slc = 0;                     /* Screen line count */
  4818.  
  4819. char *
  4820. showstring(s) char * s; {
  4821.     return(s ? s : "(null)");
  4822. }
  4823.  
  4824. char *
  4825. showoff(x) int x; {
  4826.     return(x ? "on" : "off");
  4827. }
  4828.  
  4829. char *
  4830. showooa(x) int x; {
  4831.     switch (x) {
  4832.       case SET_OFF:  return("off");
  4833.       case SET_ON:   return("on");
  4834.       case SET_AUTO: return("automatic");
  4835.       default:       return("(unknown)");
  4836.     }
  4837. }
  4838.  
  4839. #ifdef GEMDOS
  4840. isxdigit(c) int c; {
  4841.     return(isdigit(c) ||
  4842.            (c >= 'a' && c <= 'f') ||
  4843.            (c >= 'A' && c <= 'F'));
  4844. }
  4845. #endif /* GEMDOS */
  4846.  
  4847. #ifndef NOSETKEY
  4848. #ifdef OS2
  4849. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4850.     "all",    1, 0,
  4851.     "one",    0, 0
  4852. };
  4853. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4854.  
  4855. #define SHKEYDEF TT_MAX+5
  4856. struct keytab shokeymtab[] = {
  4857.     "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
  4858.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4859.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4860.     "annarbor",  TT_AAA,     0,         /* AnnArbor */
  4861.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4862.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4863.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4864.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4865.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4866.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4867.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4868.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4869.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4870.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4871.     "default",   SHKEYDEF,   0,
  4872.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4873.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4874.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4875.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4876.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4877.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4878.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4879.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4880.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4881.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4882.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4883.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4884.     "linux",     TT_LINUX,   0,         /* Linux */
  4885.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4886.     "qnx",       TT_QNX,     0,         /* QNX */
  4887.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4888.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4889.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4890.     "sun",       TT_SUN,     0,         /* Sun Console */
  4891. #ifdef OS2PM
  4892. #ifdef COMMENT
  4893.     "tek4014", TT_TEK40, 0,
  4894. #endif /* COMMENT */
  4895. #endif /* OS2PM */
  4896.     "tty",     TT_NONE,  0,
  4897.     "tvi910+", TT_TVI910, 0,
  4898.     "tvi925",  TT_TVI925, 0,
  4899.     "tvi950",  TT_TVI950, 0,
  4900.     "vc404",   TT_VC4404, 0,
  4901.     "vc4404",  TT_VC4404, CM_INV,
  4902.     "vip7809", TT_VIP7809, 0,
  4903.     "vt100",   TT_VT100, 0,
  4904.     "vt102",   TT_VT102, 0,
  4905.     "vt220",   TT_VT220, 0,
  4906.     "vt220pc", TT_VT220PC, 0,
  4907.     "vt320",   TT_VT320, 0,
  4908.     "vt320pc", TT_VT320PC, 0,
  4909.     "vt52",    TT_VT52,  0,
  4910.     "wp",      TT_KBM_WP, 0,
  4911.     "wy160",   TT_WY160,  0,
  4912.     "wy30",    TT_WY30,  0,
  4913.     "wy370",   TT_WY370, 0,
  4914.     "wy50",    TT_WY50,  0,
  4915.     "wy60",    TT_WY60,  0,
  4916.     "wyse30",  TT_WY30,  CM_INV,
  4917.     "wyse370", TT_WY370, CM_INV,
  4918.     "wyse50",  TT_WY50,  CM_INV,
  4919.     "wyse60",  TT_WY60,  CM_INV
  4920. };
  4921. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4922. #endif /* OS2 */
  4923.  
  4924. VOID
  4925. #ifdef OS2
  4926. shokeycode(c,m) int c, m;
  4927. #else
  4928. shokeycode(c) int c;
  4929. #endif
  4930. /* shokeycode */ {
  4931.     KEY ch;
  4932.     CHAR *s;
  4933. #ifdef OS2
  4934.     int i;
  4935.     con_event km;
  4936. #else /* OS2 */
  4937.     int km;
  4938. #endif /* OS2 */
  4939.  
  4940. #ifdef OS2
  4941.     extern int mskkeys;
  4942.     char * mstr = "";
  4943.  
  4944.     if (c >= KMSIZE) {
  4945.         bleep(BP_FAIL);
  4946.         return;
  4947.     }
  4948. #else /* OS2 */
  4949.     printf(" Key code \\%d => ", c);
  4950. #endif /* OS2 */
  4951.  
  4952. #ifndef OS2
  4953.     km = mapkey(c);
  4954.  
  4955. #ifndef NOKVERBS
  4956.     if (IS_KVERB(km)) {                 /* \Kverb? */
  4957.         int i, kv;
  4958.         kv = km & ~(F_KVERB);
  4959.         printf("Verb: ");
  4960.         for (i = 0; i < nkverbs; i++)
  4961.           if (kverbs[i].kwval == kv) {
  4962.               printf("\\K%s",kverbs[i].kwd);
  4963.               break;
  4964.           }
  4965.         printf("\n");
  4966.     } else
  4967. #endif /* NOKVERBS */
  4968.       if (IS_CSI(km)) {
  4969.           int xkm = km & 0xFF;
  4970.           if (xkm <= 32 || xkm >= 127)
  4971.             printf("String: \\{27}[\\{%d}\n",xkm);
  4972.           else
  4973.             printf("String: \\{27}[%c\n",xkm);
  4974.       } else if (IS_ESC(km)) {
  4975.           int xkm = km & 0xFF;
  4976.           if (xkm <= 32 || xkm >= 127)
  4977.             printf("String: \\{27}\\{%d}\n",xkm);
  4978.           else
  4979.             printf("String: \\{27}%c\n",xkm);
  4980.       } else if (macrotab[c]) {         /* See if there's a macro */
  4981.           printf("String: ");           /* If so, display its definition */
  4982.           s = macrotab[c];
  4983.           shostrdef(s);
  4984.           printf("\n");
  4985. #ifndef NOKVERBS
  4986.     } else if (km >= 0x100) {           /* This means "undefined" */
  4987.         printf("Undefined\n");
  4988. #endif /* NOKVERBS */
  4989.     } else {                            /* No macro, show single character */
  4990.         printf("Character: ");
  4991.         ch = km;
  4992.         if (ch < 32 || ch == 127
  4993. #ifdef OS2
  4994.             || ch > 255
  4995. #endif /* OS2 */
  4996. #ifndef NEXT
  4997. #ifndef AUX
  4998. #ifndef XENIX
  4999. #ifndef OS2
  5000.             || (ch > 127 && ch < 160)
  5001. #endif /* OS2 */
  5002. #endif /* XENIX */
  5003. #endif /* AUX */
  5004. #endif /* NEXT */
  5005.             )
  5006. /*
  5007.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5008.   %u is supposed to be totally portable.
  5009. */
  5010.           printf("\\%u",(unsigned int) ch);
  5011.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5012.         if (ch == (KEY) c)
  5013.           printf(" (self, no translation)\n");
  5014.         else
  5015.           printf("\n");
  5016.     }
  5017. #else /* OS2 */
  5018.     if (m < 0) {
  5019.         km = mapkey(c);
  5020.         mstr = "default";
  5021.     } else {
  5022.         km = maptermkey(c,m);
  5023.         for (i = 0; i < nshokeym; i++) {
  5024.             if (m == shokeymtab[i].kwval) {
  5025.                 mstr = shokeymtab[i].kwd;
  5026.                 break;
  5027.             }
  5028.         }
  5029.     }
  5030.     s = keyname(c);
  5031.     debug(F111,"shokeycode mstr",mstr,m);
  5032.     debug(F111,"shokeycode keyname",s,c);
  5033.     printf(" %sKey code \\%d %s (%s) => ",
  5034.             mskkeys ? "mskermit " : "",
  5035.             mskkeys ? cktomsk(c) : c,
  5036.             s == NULL ? "" : s, mstr);
  5037.  
  5038.     switch (km.type) {
  5039. #ifndef NOKVERBS
  5040.       case kverb: {
  5041.           int i, kv;
  5042.           kv = km.kverb.id & ~(F_KVERB);
  5043.           printf("Verb: ");
  5044.           for (i = 0; i < nkverbs; i++) {
  5045.               if (kverbs[i].kwval == kv) {
  5046.                   printf("\\K%s",kverbs[i].kwd);
  5047.                   break;
  5048.               }
  5049.           }
  5050.           printf("\n");
  5051.           break;
  5052.       }
  5053. #endif /* NOKVERBS */
  5054.       case csi: {
  5055.           int xkm = km.csi.key & 0xFF;
  5056.           if (xkm <= 32 || xkm >= 127)
  5057.             printf("String: \\{27}[\\{%d}\n",xkm);
  5058.           else
  5059.             printf("String: \\{27}[%c\n",xkm);
  5060.           break;
  5061.       }
  5062.       case esc: {
  5063.           int xkm = km.esc.key & 0xFF;
  5064.           if (xkm <= 32 || xkm >= 127)
  5065.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  5066.           else
  5067.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  5068.           break;
  5069.       }
  5070.       case macro: {
  5071.           printf("String: ");           /* Macro, display its definition */
  5072.           shostrdef(km.macro.string);
  5073.           printf("\n");
  5074.           break;
  5075.       }
  5076.       case literal: {
  5077.           printf("Literal string: ");   /* Literal, display its definition */
  5078.           shostrdef(km.literal.string);
  5079.           printf("\n");
  5080.           break;
  5081.       }
  5082.       case error: {
  5083.           if (c >= 0x100) {
  5084.               printf("Undefined\n");
  5085.           } else {
  5086.               printf("Character: ");
  5087.               ch = c;
  5088.               if (ch < 32 || ch == 127 || ch > 255
  5089. #ifndef NEXT
  5090. #ifndef AUX
  5091. #ifndef XENIX
  5092. #ifndef OS2
  5093.                    || (ch > 127 && ch < 160)
  5094. #endif /* OS2 */
  5095. #endif /* XENIX */
  5096. #endif /* AUX */
  5097. #endif /* NEXT */
  5098.                    )
  5099. /*
  5100.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5101.   %u is supposed to be totally portable.
  5102. */
  5103.                   printf("\\%u",(unsigned int) ch);
  5104.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5105.               printf(" (self, no translation)\n");
  5106.           }
  5107.           break;
  5108.       }
  5109.       case key: {
  5110.           printf("Character: ");
  5111.           ch = km.key.scancode;
  5112.           if (ch < 32 || ch == 127 || ch > 255
  5113. #ifndef NEXT
  5114. #ifndef AUX
  5115. #ifndef XENIX
  5116. #ifndef OS2
  5117.               || (ch > 127 && ch < 160)
  5118. #else
  5119.                || (ch > 127)
  5120. #endif /* OS2 */
  5121. #endif /* XENIX */
  5122. #endif /* AUX */
  5123. #endif /* NEXT */
  5124.               )
  5125. /*
  5126.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5127.   %u is supposed to be totally portable.
  5128. */
  5129.             printf("\\%u",(unsigned int) ch);
  5130.           else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5131.           if (ch == (KEY) c)
  5132.             printf(" (self, no translation)\n");
  5133.           else
  5134.             printf("\n");
  5135.           break;
  5136.       }
  5137.     }
  5138. #endif /* OS2 */
  5139. }
  5140. #endif /* NOSETKEY */
  5141.  
  5142. VOID
  5143. shostrdef(s) CHAR * s; {
  5144.     CHAR ch;
  5145.     if (!s) s = (CHAR *)"";
  5146.     while ((ch = *s++)) {
  5147.         if (ch < 32 || ch == 127 || ch == 255
  5148. /*
  5149.   Systems whose native character sets have graphic characters in C1...
  5150. */
  5151. #ifndef NEXT                            /* NeXT */
  5152. #ifndef AUX                             /* Macintosh */
  5153. #ifndef XENIX                           /* IBM PC */
  5154. #ifdef OS2
  5155. /*
  5156.   It doesn't matter whether the local host can display 8-bit characters;
  5157.   they are not portable among character-sets and fonts.  Who knows what
  5158.   would be displayed...
  5159. */
  5160.             || (ch > 127)
  5161. #else /* OS2 */
  5162.             || (ch > 127 && ch < 160)
  5163. #endif /* OS2 */
  5164. #endif /* XENIX */
  5165. #endif /* AUX */
  5166. #endif /* NEXT */
  5167.             )
  5168.           printf("\\{%d}",ch);          /* Display control characters */
  5169.         else putchar((char) ch);        /* in backslash notation */
  5170.     }
  5171. }
  5172.  
  5173. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5174.  
  5175. #ifndef NOSHOW
  5176. VOID
  5177. shover() {
  5178. #ifdef OS2
  5179.     extern char ckxsystem[];
  5180. #endif /* OS2 */
  5181.     extern char *ck_patch, * cklibv;
  5182.     printf("\nVersions:\n %s\n",versio);
  5183.     printf(" Numeric: %ld\n",vernum);
  5184. #ifdef OS2
  5185.     printf(" Operating System: %s\n", ckxsystem);
  5186. #else /* OS2 */
  5187.     printf(" Built for: %s\n", ckxsys);
  5188. #ifdef CK_UTSNAME
  5189.     if (unm_nam[0])
  5190.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5191. #endif /* CK_UTSNAME */
  5192.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5193. #endif /* OS2 */
  5194.     if (xxdiff(ckxv,ckxsys))
  5195.       printf(" %s for%s\n",ckxv,ckxsys);
  5196.     else
  5197.       printf(" %s\n",ckxv);
  5198.     if (xxdiff(ckzv,ckzsys))
  5199.       printf(" %s for%s\n",ckzv,ckzsys);
  5200.     else
  5201.       printf(" %s\n",ckzv);
  5202.     printf(" %s\n",cklibv);
  5203.     printf(" %s\n",protv);
  5204.     printf(" %s\n",fnsv);
  5205.     printf(" %s\n %s\n",cmdv,userv);
  5206. #ifndef NOCSETS
  5207.     printf(" %s\n",xlav);
  5208. #endif /* NOCSETS */
  5209. #ifndef MAC
  5210. #ifndef NOLOCAL
  5211.     printf(" %s\n",connv);
  5212. #ifdef OS2
  5213.     printf(" %s\n",ckyv);
  5214. #endif /* OS2 */
  5215. #endif /* NOLOCAL */
  5216. #endif /* MAC */
  5217. #ifndef NODIAL
  5218.     printf(" %s\n",dialv);
  5219. #endif /* NODIAL */
  5220. #ifndef NOSCRIPT
  5221.     printf(" %s\n",loginv);
  5222. #endif /* NOSCRIPT */
  5223. #ifdef NETCONN
  5224.     printf(" %s\n",cknetv);
  5225. #ifdef OS2
  5226.     printf(" %s\n",ckonetv);
  5227. #ifdef CK_NETBIOS
  5228.     printf(" %s\n",ckonbiv);
  5229. #endif /* CK_NETBIOS */
  5230. #endif /* OS2 */
  5231. #endif /* NETCONN */
  5232. #ifdef TNCODE
  5233.     printf(" %s\n",cktelv);
  5234. #endif /* TNCODE */
  5235. #ifdef OS2
  5236. #ifdef OS2MOUSE
  5237.     printf(" %s\n",ckomouv);
  5238. #endif /* OS2MOUSE */
  5239. #endif /* OS2 */
  5240. #ifdef NEWFTP
  5241.     printf(" %s\n",ckftpv);
  5242. #endif /* NEWFTP */
  5243. #ifdef CK_AUTHENTICATION
  5244.     printf(" %s\n",ckathv);
  5245. #endif /* CK_AUTHENTICATION */
  5246. #ifdef CK_ENCRYPTION
  5247. #ifdef CRYPT_DLL
  5248.     printf(" %s\n",ck_crypt_dll_version());
  5249. #else /* CRYPT_DLL */
  5250.     printf(" %s\n",ckcrpv);
  5251. #endif /* CRYPT_DLL */
  5252. #endif /* CK_ENCRYPTION */
  5253. #ifdef CK_SSL
  5254.     printf(" %s\n",cksslv);
  5255. #endif /* CK_SSL */
  5256.     printf("\n");
  5257. }
  5258.  
  5259. #ifdef CK_LABELED
  5260. VOID
  5261. sholbl() {
  5262. #ifdef VMS
  5263.     printf("VMS Labeled File Features:\n");
  5264.     printf(" acl %s (ACL info %s)\n",
  5265.            showoff(lf_opts & LBL_ACL),
  5266.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5267.     printf(" backup-date %s (backup date/time %s)\n",
  5268.            showoff(lf_opts & LBL_BCK),
  5269.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5270.     printf(" name %s (original filename %s)\n",
  5271.            showoff(lf_opts & LBL_NAM),
  5272.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5273.     printf(" owner %s (original file owner id %s)\n",
  5274.            showoff(lf_opts & LBL_OWN),
  5275.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5276.     printf(" path %s (original file's disk:[directory] %s)\n",
  5277.            showoff(lf_opts & LBL_PTH),
  5278.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5279. #else
  5280. #ifdef OS2
  5281.     printf("OS/2 Labeled File features (attributes):\n");
  5282.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5283.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5284.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5285.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5286.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5287. #endif /* OS2 */
  5288. #endif /* VMS */
  5289. }
  5290. #endif /* CK_LABELED */
  5291.  
  5292. VOID
  5293. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5294. #ifndef NOCSETS
  5295. #ifdef OS2
  5296. #ifndef NOTERM
  5297.     extern struct _vtG G[4], *GL, *GR;
  5298.     extern int decnrcm, sni_chcode;
  5299.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5300.     extern prncs;
  5301.  
  5302.     printf(" Terminal character-sets:\n");
  5303.     if (IS97801(tt_type_mode)) {
  5304.         if (cmask == 0377)
  5305.           printf("     Mode: 8-bit Mode\n");
  5306.         else
  5307.           printf("     Mode: 7-bit Mode\n");
  5308.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5309.     } else if (ISVT100(tt_type_mode)) {
  5310.         if (decnrcm)
  5311.           printf("     Mode: 7-bit National Mode\n");
  5312.         else
  5313.           printf("     Mode: 8-bit Multinational Mode\n");
  5314.     }
  5315.     if ( isunicode() )
  5316.         printf("    Local: Unicode display / %s input\n",
  5317.                 csl == TX_TRANSP ? "transparent" :
  5318.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5319.     else
  5320.         printf("    Local: %s\n",
  5321.                 csl == TX_TRANSP ? "transparent" :
  5322.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5323.  
  5324.     if ( tt_utf8 ) {
  5325.         printf("   Remote: UTF-8\n");
  5326.     } else {
  5327.         printf("   Remote: %sG0: %s (%s)\n",
  5328.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5329.            txrinfo[G[0].designation]->keywd,
  5330.            G[0].designation == TX_TRANSP ? "" :
  5331.            G[0].size == cs94 ? "94 chars" :
  5332.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5333.         printf("           %sG1: %s (%s)\n",
  5334.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5335.            txrinfo[G[1].designation]->keywd,
  5336.            G[1].designation == TX_TRANSP ? "" :
  5337.            G[1].size == cs94 ? "94 chars" :
  5338.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5339.         printf("           %sG2: %s (%s)\n",
  5340.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5341.            txrinfo[G[2].designation]->keywd,
  5342.            G[2].designation == TX_TRANSP ? "" :
  5343.            G[2].size == cs94 ? "94 chars" :
  5344.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5345.         printf("           %sG3: %s (%s)\n",
  5346.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5347.            txrinfo[G[3].designation]->keywd,
  5348.            G[3].designation == TX_TRANSP ? "" :
  5349.            G[3].size == cs94 ? "94 chars" :
  5350.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5351.     }
  5352.     printf("\n");
  5353.     printf(" Keyboard character-sets:\n");
  5354.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5355.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5356.     printf("\n");
  5357.     printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5358. #endif /* NOTERM */
  5359. #else /* OS2 */
  5360. #ifndef MAC
  5361.     char *s;
  5362.  
  5363.     debug(F101,"TERM LOCAL CSET","",csl);
  5364.     debug(F101,"TERM REMOTE CSET","",csr);
  5365.     printf(" Terminal character-set: ");
  5366.     if (tcs_transp) {                   /* No translation */
  5367.         printf("transparent\n");
  5368.     } else {                            /* Translation */
  5369.         printf("%s (remote) %s (local)\n",
  5370.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5371.         if (csr != csl) {
  5372.             switch(gettcs(csr,csl)) {
  5373.               case TC_USASCII:  s = "ascii";        break;
  5374.               case TC_1LATIN:   s = "latin1-iso";   break;
  5375.               case TC_2LATIN:   s = "latin2-iso";   break;
  5376.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5377.               case TC_JEUC:     s = "japanese-euc"; break;
  5378.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5379.               case TC_GREEK:    s = "greek-iso";    break;
  5380.               case TC_9LATIN:   s = "latin9-iso";   break;
  5381.               default:          s = "transparent";  break;
  5382.             }
  5383.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5384.                 strcmp(s,fcsinfo[csr].keyword))
  5385.               printf("                         (via %s)\n",s);
  5386.         }
  5387.     }
  5388. #endif /* MAC */
  5389. #endif /* OS2 */
  5390. #endif /* NOCSETS */
  5391. }
  5392.  
  5393. #ifndef NOLOCAL
  5394. #ifdef OS2
  5395. extern char htab[];
  5396. VOID
  5397. shotabs() {
  5398.     int i,j,k,n;
  5399.  
  5400.     printf("Tab Stops:\n\n");
  5401.     for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5402.         do {
  5403.             printf("%c",htab[++i]=='T'?'T':'-');
  5404.         } while (i % k && i < MAXTERMCOL);
  5405.         printf("\n");
  5406.         for ( ; j <= i; j++) {
  5407.             switch ( j%10 ) {
  5408.           case 1:
  5409.                 printf("%c",j == 1 ? '1' : '.');
  5410.                 break;
  5411.           case 2:
  5412.           case 3:
  5413.           case 4:
  5414.           case 5:
  5415.           case 6:
  5416.           case 7:
  5417.                 printf("%c",'.');
  5418.                 break;
  5419.           case 8:
  5420.                 n = (j+2)/100;
  5421.                 if (n)
  5422.           printf("%d",n);
  5423.                 else 
  5424.           printf("%c",'.');
  5425.                 break;
  5426.           case 9:
  5427.                 n = (j+1)%100/10;
  5428.                 if (n)
  5429.           printf("%d",n);
  5430.                 else if (j>90)
  5431.           printf("0");
  5432.                 else 
  5433.           printf("%c",'.');
  5434.                 break;
  5435.           case 0:
  5436.                 printf("0");
  5437.                 break;
  5438.             }
  5439.         }
  5440.         printf("\n");
  5441.     }
  5442. #ifdef COMMENT
  5443.     for (i = 1; i <= 70; i++)
  5444.       printf("%c",htab[i]=='T'?'T':'-');
  5445.     printf("\n1.......10........20........30........40........50........60\
  5446. ........70\n\n");
  5447.     for (; i <= 140; i++)
  5448.       printf("%c",htab[i]=='T'?'T':'-');
  5449.     printf("\n........80........90.......100.......110.......120.......130\
  5450. .......140\n\n");
  5451.     for (; i <= 210; i++)
  5452.       printf("%c",htab[i]=='T'?'T':'-');
  5453.     printf("\n.......150.......160.......170.......180.......190.......200\
  5454. .......210\n\n");
  5455.     for (; i <= 255; i++)
  5456.       printf("%c",htab[i]=='T'?'T':'-');
  5457.     printf("\n.......220.......230.......240.......250..255\n");
  5458. #endif
  5459.  
  5460. }
  5461. #endif /* OS2 */
  5462. #endif /* NOLOCAL */
  5463.  
  5464. #ifdef OS2MOUSE
  5465. VOID
  5466. shomou() {
  5467.     int button, event, id, i;
  5468.     char * name = "";
  5469.  
  5470.     printf("Mouse settings:\n");
  5471.     printf("   Button Count:   %d\n",mousebuttoncount());
  5472.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5473.  
  5474.     for (button = 0; button < MMBUTTONMAX; button++)
  5475.       for (event = 0; event < MMEVENTSIZE; event++)
  5476.         if (mousemap[button][event].type != error)
  5477.           switch (mousemap[button][event].type) {
  5478.             case key:
  5479.               printf("   %s = Character: %c \\%d\n",
  5480.                      mousename(button,event),
  5481.                      mousemap[button][event].key.scancode,
  5482.                      mousemap[button][event].key.scancode );
  5483.               break;
  5484.             case kverb:
  5485.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5486.               if (id != K_IGNORE) {
  5487.                   for (i = 0; i< nkverbs; i++)
  5488.                     if (id == kverbs[i].kwval) {
  5489.                         name = kverbs[i].kwd;
  5490.                         break;
  5491.                     }
  5492.                   printf("   %s = Kverb: \\K%s\n",
  5493.                          mousename(button,event),
  5494.                          name
  5495.                          );
  5496.               }
  5497.               break;
  5498.             case macro:
  5499.               printf("   %s = Macro: ",
  5500.                      mousename(button,event) );
  5501.               shostrdef(mousemap[button][event].macro.string);
  5502.               printf("\n");
  5503.               break;
  5504.           }
  5505. }
  5506. #endif /* OS2MOUSE */
  5507.  
  5508. #ifndef NOLOCAL
  5509. VOID
  5510. shotrm() {
  5511.     char *s;
  5512.     extern char * getiact();
  5513.     extern int tt_print, adl_err;
  5514. #ifndef NOTRIGGER
  5515.     extern char * tt_trigger[];
  5516. #endif /* NOTRIGGER */
  5517. #ifdef CKTIDLE
  5518.     extern char * tt_idlesnd_str;
  5519.     extern int tt_idlesnd_tmo;
  5520.     extern int tt_idlelimit, tt_idleact;
  5521. #endif /* CKTIDLE */
  5522. #ifdef OS2
  5523.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5524.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5525.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5526.     int lines = 0;
  5527. #ifdef KUI
  5528.     extern CKFLOAT tt_linespacing[];
  5529. #endif /* KUI */
  5530. #ifdef PCFONTS
  5531.     int i;
  5532.     char *font;
  5533.  
  5534.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5535.         if (!os2LoadPCFonts()) {
  5536.             for (i = 0; i < ntermfont; i++) {
  5537.                 if (tt_font == term_font[i].kwval) {
  5538.                     font = term_font[i].kwd;
  5539.                     break;
  5540.                 }
  5541.             }
  5542.         } else {
  5543.             font = "(DLL not available)";
  5544.         }
  5545.     } else {
  5546.         font =     "(full screen only)";
  5547.     }
  5548. #endif /* PCFONTS */
  5549. #ifdef KUI
  5550.     char font[64] = "(unknown)";
  5551.     if ( ntermfont > 0 ) {
  5552.         int i;
  5553.         for (i = 0; i < ntermfont; i++) {
  5554.             if (tt_font == term_font[i].kwval) {
  5555.                 ckstrncpy(font,term_font[i].kwd,59);
  5556.                 ckstrncat(font," ",64);
  5557.                 ckstrncat(font,ckitoa(tt_font_size/2),64);
  5558.                 if ( tt_font_size % 2 )
  5559.                     ckstrncat(font,".5",64);
  5560.                 break;
  5561.             }
  5562.         }
  5563.     }
  5564. #endif /* KUI */
  5565.  
  5566.     printf("Terminal parameters:\n");
  5567.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5568.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5569.            "Bytesize: Command",
  5570.            (cmdmsk == 0377) ? 8 : 7,
  5571.            " bits","Terminal",
  5572.            (cmask == 0377) ? 8 : 7," bits");
  5573.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5574.     printf(" %19s: %-13s","Type",
  5575.            (tt_type >= 0 && tt_type <= max_tt) ?
  5576.            tt_info[tt_type].x_name :
  5577.            "unknown" );
  5578.     if (tt_type >= 0 && tt_type <= max_tt)
  5579.       if (strlen(tt_info[tt_type].x_id))
  5580.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5581.     printf("\n");
  5582.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5583.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5584.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5585.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5586.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5587.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5588.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5589.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5590.            (tt_cursor == 2) ? "full" :
  5591.            (tt_cursor == 1) ? "half" : "underline",
  5592. #ifdef CK_AUTODL
  5593.            "autodownload",autodl ?
  5594.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5595. #else /* CK_AUTODL */
  5596.            "", ""
  5597. #endif /* CK_AUTODL */
  5598.            );
  5599.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5600.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5601.            tt_arrow ? "application" : "cursor",
  5602.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5603.            );
  5604.  
  5605.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5606.  
  5607.     /* Just to make sure we are using current info */
  5608.     updanswerbk();
  5609.  
  5610.     /*
  5611.        This line doesn't end with '\n' because the answerback string
  5612.        is terminated with a newline
  5613.     */
  5614.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5615.            showoff(tt_answer),"response",answerback);
  5616.     switch (tt_bell) {
  5617.       case XYB_NONE:
  5618.         s = "none";
  5619.         break;
  5620.       case XYB_VIS:
  5621.         s= "visible";
  5622.         break;
  5623.       case XYB_AUD | XYB_BEEP:
  5624.         s="beep";
  5625.         break;
  5626.       case XYB_AUD | XYB_SYS:
  5627.         s="system sounds";
  5628.         break;
  5629.       default:
  5630.         s="(unknown)";
  5631.     }
  5632.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5633.            "Wrap",showoff(tt_wrap));
  5634.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5635.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5636.            "Autoscroll",showoff(autoscroll));
  5637.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5638.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5639.            "ESC[0m color",colorreset?"default-color":"current-color");
  5640.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5641.     printf(" %19s: %-13s  %13s: %-15s\n",
  5642.             "Erase color",user_erasemode?"default-color":"current-color",
  5643.            "Screen mode",decscnm?"reverse":"normal");
  5644.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5645.  
  5646.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5647.            "Output-pacing",tt_pacing);
  5648.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5649.  
  5650.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5651.            "Idle-action", getiact());
  5652.  
  5653.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5654.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5655.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5656.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5657. #ifndef NOTRIGGER
  5658.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5659.            tt_trigger[0],"Output pacing",tt_pacing );
  5660.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5661. #endif /* NOTRIGGER */
  5662.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5663.            showoff(marginbell),"at column", marginbellcol);
  5664.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5665.     switch (tt_modechg) {
  5666.       case TVC_DIS: s = "disabled"; break;
  5667.       case TVC_ENA: s = "enabled";  break;
  5668.       case TVC_W95: s = "win95-restricted"; break;
  5669.       default: s = "(unknown)";
  5670.     }
  5671.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5672.            showoff(dgunix),"Video change", s);
  5673.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5674.  
  5675. #ifdef CK_APC
  5676.     if (apcstatus == APC_ON) s = "on";
  5677.     else if (apcstatus == APC_OFF) s = "off";
  5678.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5679.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5680.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5681.     printf(" %19s: %-13s  %13s: %-15s\n",
  5682.            "APC", s,
  5683. #ifdef PCFONTS
  5684.            "Font (VGA)",font
  5685. #else /* PCFONTS */
  5686. #ifdef KUI
  5687.            "Font",font
  5688. #else
  5689.            "Font","(not supported)"
  5690. #endif /* KUI */
  5691. #endif /* PCFONTS */
  5692.  
  5693.            );
  5694. #endif /* CK_APC */
  5695.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5696.  
  5697. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5698.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5699.       ttgwsiz();                        /* Try to get latest size */
  5700. #endif /* CK_TTGWSIZ */
  5701.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5702.            "Width",tt_cols[VTERM]);
  5703.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5704. #ifdef KUI
  5705.     printf(" %19s: %-13f  %13s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5706.            "Display Height",VscrnGetDisplayHeight(VTERM));
  5707.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5708. #endif /* KUI */
  5709.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5710.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5711.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5712.  
  5713.     if (updmode == tt_updmode)
  5714.       if (updmode == TTU_FAST)
  5715.         s = "fast (fast)";
  5716.       else
  5717.         s = "smooth (smooth)";
  5718.     else
  5719.       if (updmode == TTU_FAST)
  5720.         s = "fast (smooth)";
  5721.       else
  5722.         s = "smooth (fast)";
  5723.  
  5724.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5725.            "interval",tt_update);
  5726.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5727.     printf(" %19s: %-13s  %13s: %-15s\n",
  5728.            "Screen-optimization",showoff(tt_diff_upd),
  5729.            "Status line",showoff(tt_status[VTERM]));
  5730.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5731.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5732.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5733.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5734.  
  5735.     /* Display colors (should become SHOW COLORS) */
  5736.     {
  5737.         USHORT row, col;
  5738.         char * colors[16] = {
  5739.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5740.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5741.         };
  5742.         printf("\n");
  5743.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5744.  
  5745.         printf(" Color:");
  5746. #ifndef ONETERMUPD
  5747.         GetCurPos(&row, &col);
  5748.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5749.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5750.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5751.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5752.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5753.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5754.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5755.         WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5756. #endif /* ONETERMUPD */
  5757.         row = VscrnGetCurPos(VCMD)->y+1;
  5758.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5759.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5760.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5761.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5762.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5763.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5764.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5765.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5766.         printf("\n");
  5767.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5768.  
  5769.         /* Foreground color names */
  5770.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5771.                 "",
  5772.                 colors[colordebug&0x0F],
  5773.                 colors[colorhelp&0x0F],
  5774.                 colors[colorreverse&0x0F],
  5775.                 colors[colorselect&0x0F],
  5776.                 colors[colorstatus&0x0F],
  5777.                 colors[colornormal&0x0F],
  5778.                 colors[colorunderline&0x0F]);
  5779.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5780.  
  5781.         /* Background color names */
  5782.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5783.                 colors[colorborder],
  5784.                 colors[colordebug>>4],
  5785.                 colors[colorhelp>>4],
  5786.                 colors[colorreverse>>4],
  5787.                 colors[colorselect>>4],
  5788.                 colors[colorstatus>>4],
  5789.                 colors[colornormal>>4],
  5790.                 colors[colorunderline>>4] );
  5791.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5792.         printf("\n");
  5793.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5794.         printf(" Color:");
  5795. #ifndef ONETERMUPD
  5796.         GetCurPos(&row, &col);
  5797.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5798.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5799.         WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
  5800. #endif /* ONETERMUPD */
  5801.         row = VscrnGetCurPos(VCMD)->y+1;
  5802.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5803.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5804.         VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
  5805.         printf("\n");
  5806.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5807.  
  5808.         /* Foreground color names */
  5809.         printf("%6s: %-8s%-8s%-8s\n","fore",
  5810.                 colors[colorgraphic&0x0F],
  5811.                 colors[colorcmd&0x0F],
  5812.                 colors[coloritalic&0x0F]);
  5813.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5814.  
  5815.         /* Background color names */
  5816.         printf("%6s: %-8s%-8s%-8s\n","back",
  5817.                 colors[colorgraphic>>4],
  5818.                 colors[colorcmd>>4],
  5819.                 colors[coloritalic>>4]);
  5820.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5821.     }
  5822.     printf("\n");
  5823.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5824.     {
  5825.         extern int trueblink, truereverse, trueunderline, trueitalic;
  5826.         printf(
  5827.     " Attribute:  blink: %-3s  reverse: %-3s  underline: %-3s italic: %-3s\n",
  5828.                 trueblink?"on":"off", truereverse?"on":"off",
  5829.                 trueunderline?"on":"off", trueitalic?"on":"off");
  5830.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5831.     }
  5832.     {
  5833.         extern vtattrib WPattrib;
  5834.         printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5835.                 WPattrib.blinking?"blink ":"",
  5836.                 WPattrib.italic?"italic ":"",
  5837.                 WPattrib.reversed?"reverse ":"",
  5838.                 WPattrib.underlined?"underline ":"",
  5839.                 WPattrib.bold?"bold ":"",
  5840.                 WPattrib.dim?"dim ":"",
  5841.                 WPattrib.invisible?"invisible ":"");
  5842.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5843.     }
  5844.  
  5845.     printf("\n");
  5846.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5847.     (VOID) shoesc(escape);
  5848.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5849.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5850.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5851.  
  5852. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5853.  
  5854.     printf("\n");
  5855.     printf("Terminal parameters:\n");
  5856.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5857.            "Bytesize: Command",
  5858.            (cmdmsk == 0377) ? 8 : 7,
  5859.            " bits","Terminal",
  5860.            (cmask == 0377) ? 8 : 7," bits");
  5861.     s = getenv("TERM");
  5862. #ifdef XPRINT
  5863.     printf(" %19s: %-13s  %13s: %-15s\n",
  5864.            "Type",
  5865.            s ? s : "(unknown)",
  5866.            "Print",
  5867.            showoff(tt_print)
  5868.            );
  5869. #else
  5870.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5871. #endif /* XPRINT */
  5872.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5873.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5874.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5875.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5876.  
  5877. #ifdef CK_APC
  5878.     if (apcstatus == APC_ON) s = "on";
  5879.     else if (apcstatus == APC_OFF) s = "off";
  5880.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5881.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5882.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5883.     printf(" %19s: %-13s  %13s: %-15s\n",
  5884.            "APC", s,
  5885. #ifdef CK_AUTODL
  5886.            "Autodownload", autodl ?
  5887.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5888. #else
  5889.            "",""
  5890. #endif /* CK_AUTODL */
  5891.            );
  5892. #endif /* CK_APC */
  5893.  
  5894. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5895.     ttgwsiz();                          /* Try to get latest size */
  5896.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5897. #endif /* CK_TTGWSIZ */
  5898.  
  5899.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5900.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5901.  
  5902. #ifdef CKTIDLE
  5903.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5904.            "Idle-action", getiact());
  5905. #endif /* CKTIDLE */
  5906.  
  5907. #ifndef NOTRIGGER
  5908.     printf(" %19s: %-13s\n","Trigger",
  5909.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  5910. #endif /* NOTRIGGER */
  5911. #ifdef UNIX
  5912. #ifndef NOJC
  5913.     printf(" %19s: %-13s\n\n","Suspend", showoff(xsuspend));
  5914. #endif /* NOJC */
  5915. #endif /* UNIX */
  5916.  
  5917.     printf("\n");
  5918.     (VOID) shoesc(escape);
  5919. #ifndef NOCSETS
  5920.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  5921. #endif /* NOCSETS */
  5922.  
  5923. #endif /* OS2 */
  5924. }
  5925.  
  5926. VOID
  5927. shmdmlin() {                            /* Briefly show modem & line */
  5928. #ifndef NODIAL
  5929. #ifndef MINIDIAL
  5930. #ifdef OLDTBCODE
  5931.     extern int tbmodel;
  5932.     _PROTOTYP( char * gtbmodel, (void) );
  5933. #endif /* OLDTBCODE */
  5934. #endif /* MINIDIAL */
  5935. #endif /* NODIAL */
  5936.     if (local)
  5937. #ifdef OS2
  5938.       printf(" Port: %s, Modem type: ",ttname);
  5939. #else
  5940.       printf(" Line: %s, Modem type: ",ttname);
  5941. #endif /* OS2 */
  5942.     else
  5943.       printf(
  5944. #ifdef OS2
  5945. " Communication device not yet selected with SET PORT\n Modem type: "
  5946. #else
  5947. " Communication device not yet selected with SET LINE\n Modem type: "
  5948. #endif /* OS2 */
  5949.              );
  5950. #ifndef NODIAL
  5951.     printf("%s",gmdmtyp());
  5952. #ifndef MINIDIAL
  5953. #ifdef OLDTBCODE
  5954.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  5955. #endif /* OLDTBCODE */
  5956. #endif /* MINIDIAL */
  5957. #else
  5958.     printf("(disabled)");
  5959. #endif /* NODIAL */
  5960. }
  5961.  
  5962. #ifdef CK_TAPI
  5963. void
  5964. shotapi(int option) {
  5965.     int rc=0,k ;
  5966.     char *s=NULL;
  5967.     LPDEVCFG        lpDevCfg = NULL;
  5968.     LPCOMMCONFIG    lpCommConfig = NULL;
  5969.     LPMODEMSETTINGS lpModemSettings = NULL;
  5970.     DCB *           lpDCB = NULL;
  5971.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  5972.     extern int ntapiloc;
  5973.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  5974.     extern int ntapiline;
  5975.     extern int tttapi;                  /* TAPI in use */
  5976.     extern int tapipass;                /* TAPI Passthrough mode */
  5977.     extern int tapiconv;                /* TAPI Conversion mode */
  5978.     extern int tapilights;
  5979.     extern int tapipreterm;
  5980.     extern int tapipostterm;
  5981.     extern int tapimanual;
  5982.     extern int tapiinactivity;
  5983.     extern int tapibong;
  5984.     extern int tapiusecfg;
  5985.     extern char tapiloc[];
  5986.     extern int tapilocid;
  5987.     extern int TAPIAvail;
  5988.  
  5989.     if (!TAPIAvail) {
  5990.         printf("TAPI Support not enabled\r\n");
  5991.         return;
  5992.     }
  5993.     switch (option) {
  5994.       case 0:
  5995.         printf("TAPI Settings:\n");
  5996.         printf("  Line:                      %s\n",
  5997.                tttapi ? ttname : "(none in use)");
  5998.  
  5999.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  6000.         if (tapilocid == -1)
  6001.           tapilocid = cktapiGetCurrentLocationID();
  6002.  
  6003.         /* Find the current tapiloc entry */
  6004.         /* and use it as the default. */
  6005.         for (k = 0; k < ntapiloc; k++) {
  6006.             if (tapiloctab[k].kwval == tapilocid)
  6007.               break;
  6008.         }
  6009.         if (k >= 0 && k < ntapiloc)
  6010.           s = tapiloctab[k].kwd;
  6011.         else
  6012.           s = "(unknown)";
  6013.         printf("  Location:                  %s\n",s);
  6014.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  6015.         printf("  Phone-number-conversions:  %s\n",
  6016.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  6017.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  6018.                 tapipass?"(n/a)":"");
  6019.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  6020.                 tapipass?"(n/a)":"");
  6021.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  6022.                 tapipass?"(n/a)":"");
  6023.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  6024.                 tapipass?"(n/a)":"");
  6025.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  6026.                 tapipass?"(n/a)":"");
  6027.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  6028.                 tapipass?"(n/a)":"");
  6029.         printf("  Use-windows-configuration: %s %s\n",
  6030.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  6031.         printf("\n");
  6032.  
  6033. #ifdef BETATEST
  6034.         if (tapipass) {
  6035. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  6036. printf("may open the device but may not place calls nor answer calls.\n");
  6037. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  6038. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  6039. printf("definition associated with the active TAPI LINE device.\n\n");
  6040.  
  6041.         } else {
  6042.  
  6043. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  6044. printf("may open the device, place and answer calls.  Dialing is performed\n");
  6045. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  6046.         }
  6047.  
  6048.         if (tapiconv == CK_ON ||
  6049.             tapiconv == CK_AUTO && !tapipass) {
  6050. printf(
  6051. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  6052. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  6053. printf("dialog.\n\n");
  6054.  
  6055.         } else {
  6056.  
  6057. printf(
  6058. "Phone numbers are converted from canonical to dialable form by K-95\n");
  6059. printf(
  6060. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  6061. printf(
  6062. "Dialing Properties are imported automaticly upon startup and whenever\n");
  6063. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  6064. printf("is changed.\n\n");
  6065.         }
  6066. #endif /* BETATEST */
  6067.  
  6068.         if (tapipass) {
  6069.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  6070.             if (tapiconv == CK_ON)
  6071.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6072.         } else {
  6073.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  6074.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6075.         }
  6076.         break;
  6077.       case 1:
  6078.         cktapiDisplayTapiLocationInfo();
  6079.         break;
  6080.       case 2:
  6081.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  6082.                                      &lpCommConfig,&lpDCB);
  6083.         if (rc) {
  6084.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  6085.                                          lpCommConfig,lpDCB);
  6086.         } else {
  6087.             printf("?Unable to retrieve Modem Settings\n");
  6088.         }
  6089.         break;
  6090.       case 3: {
  6091.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  6092.           if (hModem)
  6093.             DisplayCommProperties(hModem);
  6094.           else
  6095.             printf("?Unable to retrieve a valid Modem Handle\n");
  6096.           CloseHandle(hModem);
  6097.           break;
  6098.       }
  6099.     }
  6100.     printf("\n");
  6101. }
  6102. #endif /* CK_TAPI */
  6103. #endif /* NOLOCAL */
  6104.  
  6105. #ifdef PATTERNS
  6106. static VOID
  6107. shopat() {
  6108.     extern char * binpatterns[], * txtpatterns[];
  6109.     extern int patterns, filepeek;
  6110.     char **p, *s;
  6111.     int i, j, k, n, flag, width;
  6112. #ifdef CK_TTGWSIZ
  6113.     ttgwsiz();                          /* Try to get latest size */
  6114. #ifdef OS2
  6115.     width = tt_cols[VCMD];
  6116. #else /* OS2 */
  6117.     width = tt_cols;
  6118. #endif /* OS2 */
  6119.     if (width < 1)
  6120. #endif /* CK_TTGWSIZ */
  6121.       width = 80;
  6122.     printf("\n");
  6123.     printf(" Set file type:            %s\n",gfmode(binary,1));
  6124.     printf(" Set file patterns:        %s", showooa(patterns));
  6125. #ifdef CK_LABELED
  6126.     if (binary == XYFT_L)
  6127.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  6128.     else
  6129. #endif /* CK_LABELED */
  6130. #ifdef VMS
  6131.     if (binary == XYFT_I)
  6132.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  6133.     else
  6134. #endif /* VMS */
  6135.     if (filepeek)
  6136.       printf(" (but SET FILE SCAN ON overrides)\n");
  6137.     else
  6138.       printf("\n");
  6139.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  6140.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  6141.         printf("\n");
  6142.         if (k == 0) {                   /* binary... */
  6143.             printf(" File binary-patterns: ");
  6144.             p = binpatterns;
  6145.         } else {                        /* text... */
  6146.             printf(" File text-patterns:   ");
  6147.             p = txtpatterns;
  6148.         }
  6149.         if (!p[0]) {
  6150.             printf("(none)\n");
  6151.         } else {
  6152.             printf("\n ");
  6153.             n = 2;
  6154.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  6155.                 if (!p[i])              /* Done */
  6156.                   break;
  6157.                 s = p[i];               /* Look for embedded space */
  6158.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  6159.                   if (*s == SP)
  6160.                     flag = 3;
  6161.                 n += j + flag;          /* Length of this line */
  6162.                 if (n >= width - 1) {
  6163.                     printf("\n ");
  6164.                     n = j+2;
  6165.                 }
  6166.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6167.             }
  6168.             if (n > 2)
  6169.               printf("\n");
  6170.         }
  6171.     }
  6172.     printf("\n");
  6173. }
  6174. #endif /* PATTERNS */
  6175.  
  6176. #ifndef NOSPL
  6177. static VOID
  6178. shooutput() {
  6179.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6180.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6181. }
  6182.  
  6183. static VOID
  6184. shoinput() {
  6185. #ifdef CK_AUTODL
  6186.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6187. #endif /* CK_AUTODL */
  6188.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6189.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6190.            "observe" : "ignore");
  6191.     printf(" Input buffer-length:    %d\n", inbufsize);
  6192.     printf(" Input echo:             %s\n", showoff(inecho));
  6193.     printf(" Input silence:          %d (seconds)\n", insilence);
  6194. #ifdef OS2
  6195.     printf(" Input terminal:         %s\n", showoff(interm));
  6196. #endif /* OS2 */
  6197.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6198.            "quit" : "proceed");
  6199.     if (instatus < 0)
  6200.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6201.     else
  6202.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6203. }
  6204. #endif /* NOSPL */
  6205.  
  6206. #ifndef NOSPL
  6207. int
  6208. showarray() {
  6209. #ifdef COMMENT
  6210.     char * p, * q, ** ap;
  6211.     int i;
  6212. #endif /* COMMENT */
  6213.     char *s; int x = 0, y;
  6214.     int range[2];
  6215.  
  6216.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6217.       if (y != -3)
  6218.         return(y);
  6219.     ckstrncpy(line,s,LINBUFSIZ);
  6220.     s = line;
  6221.     if ((y = cmcfm()) < 0)
  6222.       return(y);
  6223.     if (*s) {
  6224.         char ** ap;
  6225.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6226.             printf("?Bad array: %s\n",s);
  6227.             return(-9);
  6228.         }
  6229.         ap = a_ptr[x];
  6230.         if (!ap) {
  6231.             printf("Array not declared: %s\n", s);
  6232.             return(success = 1);
  6233.         } else {
  6234.             int i, n, max;
  6235.             max = (range[1] > 0) ?
  6236.               range[1] :
  6237.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6238.             if (range[0] < 0)
  6239.               range[0] = 0;
  6240.             if (max > a_dim[x])
  6241.               max = a_dim[x];
  6242.             n = 1;
  6243.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6244.             if (a_link[x] > -1)
  6245.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6246.             printf("\n");
  6247.             for (i = range[0]; i <= max; i++) {
  6248.                 if (ap[i]) {
  6249.                     printf("%3d. %s\n",i,ap[i]);
  6250.                     if (xaskmore) {
  6251.                         if (cmd_cols > 0) {
  6252.                             x = strlen(ap[i]) + 5;
  6253.                             y = (x % cmd_cols) ? 1 : 0;
  6254.                             n += (x / cmd_cols) + y;
  6255.                         } else {
  6256.                             n++;
  6257.                         }
  6258.                         if (n > (cmd_rows - 3)) {
  6259.                             if (!askmore())
  6260.                               break;
  6261.                             else
  6262.                               n = 0;
  6263.                         }
  6264.                     }
  6265.                 }
  6266.             }
  6267.         }
  6268.         return(1);
  6269.     }
  6270.  
  6271.     /* All arrays - just show name and dimension */
  6272.  
  6273.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6274.         if (a_ptr[y]) {
  6275.             if (x == 0) printf("Declared arrays:\n");
  6276.             x = 1;
  6277.             printf(" \\&%c[%d]",
  6278.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6279.             if (a_link[y] > -1)
  6280.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6281.             printf("\n");
  6282.         }
  6283.         if (!x) printf(" No arrays declared\n");
  6284.     }
  6285.     return(1);
  6286. }
  6287. #endif /* NOSPL */
  6288.  
  6289. int
  6290. doshow(x) int x; {
  6291.     int y, z, i; long zz;
  6292.     extern int optlines;
  6293.     char *s;
  6294. #ifdef OS2
  6295.     extern int os2gks;
  6296.     extern int tt_kb_mode;
  6297. #endif /* OS2 */
  6298.     extern int srvcdmsg;
  6299.     extern char * cdmsgstr, * ckcdpath;
  6300.  
  6301. #ifndef NOSETKEY
  6302.     if (x == SHKEY) {                   /* SHOW KEY */
  6303.         int c;
  6304. #ifdef OS2
  6305.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6306.                         "one",xxstring)) < 0) return(x);
  6307.         switch (tt_kb_mode) {
  6308.           case KBM_EM:
  6309.             s = "emacs";
  6310.             break;
  6311.           case KBM_HE:
  6312.             s = "hebrew";
  6313.             break;
  6314.           case KBM_RU:
  6315.             s = "russian";
  6316.             break;
  6317.           case KBM_EN:
  6318.           default:
  6319.             s = "default";
  6320.             break;
  6321.         }
  6322.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6323.                         s,xxstring)) < 0) return(z);
  6324.         if (z == SHKEYDEF)
  6325.           z = -1;
  6326. #endif /* OS2 */
  6327.         if ((y = cmcfm()) < 0) return(y);
  6328. #ifdef IKSD
  6329.         if (inserver) {
  6330.             printf("Sorry, command disabled.\r\n");
  6331.             return(success = 0);
  6332.         }
  6333. #endif /* IKSD */
  6334.  
  6335. #ifdef MAC
  6336.         printf("Not implemented\n");
  6337.         return(0);
  6338. #else /* Not MAC */
  6339. #ifdef OS2
  6340.         if (x) {
  6341.             con_event evt;
  6342.             for (c = 0; c < KMSIZE; c++) {
  6343.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6344.                 if (evt.type != error) {
  6345.                     shokeycode(c,z);
  6346.                 }
  6347.             }
  6348.         } else {
  6349. #endif /* OS2 */
  6350.             printf(" Press key: ");
  6351. #ifdef UNIX
  6352. #ifdef NOSETBUF
  6353.             fflush(stdout);
  6354. #endif /* NOSETBUF */
  6355. #endif /* UNIX */
  6356.             conbin((char)escape);       /* Put terminal in binary mode */
  6357. #ifdef OS2
  6358.             os2gks = 0;                 /* Raw scancode processing */
  6359. #endif /* OS2 */
  6360.             c = congks(0);              /* Get character or scan code */
  6361. #ifdef OS2
  6362.             os2gks = 1;                 /* Cooked scancode processing */
  6363. #endif /* OS2 */
  6364.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6365.             if (c < 0) {                /* Check for error */
  6366.                 printf("?Error reading key\n");
  6367.                 return(0);
  6368.             }
  6369. #ifndef OS2
  6370. /*
  6371.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6372. */
  6373.             c &= cmdmsk;                /* Apply command mask */
  6374. #endif /* OS2 */
  6375.             printf("\n");
  6376. #ifdef OS2
  6377.             shokeycode(c,z);
  6378. #else /* OS2 */
  6379.             shokeycode(c);
  6380. #endif /* OS2 */
  6381. #ifdef OS2
  6382.         }
  6383. #endif /* OS2 */
  6384.         return(1);
  6385. #endif /* MAC */
  6386.     }
  6387. #ifndef NOKVERBS
  6388.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6389.         if ((y = cmcfm()) < 0) return(y);
  6390. #ifdef IKSD
  6391.         if (inserver) {
  6392.             printf("Sorry, command disabled.\r\n");
  6393.             return(success = 0);
  6394.         }
  6395. #endif /* IKSD */
  6396.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6397.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6398.         printf("\n");
  6399.         return(1);
  6400.     }
  6401. #ifdef OS2
  6402.     if (x == SHUDK) {                   /* SHOW UDKs */
  6403.         extern void showudk(void);
  6404.         if ((y = cmcfm()) < 0) return(y);
  6405. #ifdef IKSD
  6406.         if (inserver) {
  6407.             printf("Sorry, command disabled.\r\n");
  6408.             return(success = 0);
  6409.         }
  6410. #endif /* IKSD */
  6411.         showudk();
  6412.         return(1);
  6413.     }
  6414. #endif /* OS2 */
  6415. #endif /* NOKVERBS */
  6416. #endif /* NOSETKEY */
  6417.  
  6418. #ifndef NOSPL
  6419.     if (x == SHMAC) {                   /* SHOW MACRO */
  6420.         struct FDB kw, fl, cm;
  6421.         int i, k, n = 0, left, flag, confirmed = 0;
  6422.         char * p, *q[64];
  6423.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6424.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6425.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6426.             mackey[i].flgs = mactab[i].flgs;
  6427.         }
  6428.         p = line;
  6429.         left = LINBUFSIZ;
  6430.         while (!confirmed && n < 64) {
  6431.             cmfdbi(&kw,                 /* First FDB - macro table */
  6432.                    _CMKEY,              /* fcode */
  6433.                    "Macro name",        /* hlpmsg */
  6434.                    "",                  /* default */
  6435.                    "",                  /* addtl string data */
  6436.                    nmac,                /* addtl numeric data 1: tbl size */
  6437.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6438.                    xxstring,            /* Processing function */
  6439.                    mackey,              /* Keyword table */
  6440.                    &fl                  /* Pointer to next FDB */
  6441.                    );
  6442.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6443.                    _CMFLD,              /* fcode */
  6444.                    "",                  /* hlpmsg */
  6445.                    "",                  /* default */
  6446.                    "",                  /* addtl string data */
  6447.                    0,                   /* addtl numeric data 1 */
  6448.                    0,                   /* addtl numeric data 2 */
  6449.                    xxstring,
  6450.                    NULL,
  6451.                    &cm
  6452.                    );
  6453.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6454.                    _CMCFM,              /* fcode */
  6455.                    "",                  /* hlpmsg */
  6456.                    "",                  /* default */
  6457.                    "",                  /* addtl string data */
  6458.                    0,                   /* addtl numeric data 1 */
  6459.                    0,                   /* addtl numeric data 2 */
  6460.                    NULL,
  6461.                    NULL,
  6462.                    NULL
  6463.                    );
  6464.             x = cmfdb(&kw);             /* Parse something */
  6465.             if (x < 0)
  6466.               return(x);
  6467.             s = atmbuf;                 /* What the user typed */
  6468.             switch (cmresult.fcode) {
  6469.               case _CMKEY:              /* If it was a keyword */
  6470.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6471.                 if (y > -1)
  6472.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6473.               case _CMFLD:
  6474.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6475.                 left -= k;
  6476.                 if (left <= 0) {
  6477.                     *p = NUL;
  6478.                     break;
  6479.                 }
  6480.                 q[n++] = p;             /* Point to this item */
  6481.                 p += k;                 /* Move buffer pointer past it */
  6482.                 break;
  6483.               case _CMCFM:              /* End of command */
  6484.                 confirmed++;
  6485.               default:
  6486.                 break;
  6487.             }
  6488.         }
  6489.         if (n == 0) {
  6490.             printf("Macros:\n");
  6491.             slc = 1;
  6492.             for (y = 0; y < nmac; y++)
  6493.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6494.             return(1);
  6495.         }
  6496.         slc = 0;
  6497.         for (i = 0; i < n; i++) {
  6498.             flag = 0;
  6499.             s = q[i];
  6500.             if (!s) s = "";
  6501.             if (!*s) continue;
  6502.             if (iswild(s)) {            /* Pattern match */
  6503.                 for (k = 0, x = 0; x < nmac; x++) {
  6504.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6505.                         shomac(mactab[x].kwd,mactab[x].mval);
  6506.                         k++;
  6507.                     }
  6508.                 }
  6509.                 if (!k)
  6510.                   x = -1;
  6511.                 else
  6512.                   continue;
  6513.             } else {                    /* Exact match */
  6514.                 x = mxlook(mactab,s,nmac);
  6515.                 flag = 1;
  6516.             }
  6517.             if (flag && x == -1)
  6518.               x = mlook(mactab,s,nmac);
  6519.             switch (x) {
  6520.               case -3:                  /* Nothing to look up */
  6521.               case -1:                  /* Not found */
  6522.                 printf("%s - (not defined)\n",s);
  6523.                 break;
  6524.               case -2:                  /* Ambiguous, matches more than one */
  6525.                 printf("%s - ambiguous\n",s);
  6526.                 break;
  6527.               default:                  /* Matches one exactly */
  6528.                 shomac(mactab[x].kwd,mactab[x].mval);
  6529.                 break;
  6530.             }
  6531.         }
  6532.         return(1);
  6533.     }
  6534. #endif /* NOSPL */
  6535.  
  6536. /*
  6537.   Other SHOW commands only have two fields.  Get command confirmation here,
  6538.   then handle with big switch() statement.
  6539. */
  6540. #ifndef NOSPL
  6541.     if (x != SHBUI && x != SHARR)
  6542. #endif /* NOSPL */
  6543.       if ((y = cmcfm()) < 0)
  6544.         return(y);
  6545.  
  6546. #ifdef COMMENT
  6547.     /* This restriction is too general. */
  6548. #ifdef IKSD
  6549.     if (inserver &&
  6550. #ifdef CK_LOGIN
  6551.         isguest
  6552. #else
  6553.         0
  6554. #endif /* CK_LOGIN */
  6555.         ) {
  6556.         printf("Sorry, command disabled.\r\n");
  6557.         return(success = 0);
  6558.     }
  6559. #endif /* IKSD */
  6560. #endif /* COMMENT */
  6561.  
  6562.     switch (x) {
  6563.  
  6564. #ifdef ANYX25
  6565. #ifndef IBMX25
  6566.       case SHPAD:
  6567.         shopad(0);
  6568.         break;
  6569. #endif /* IBMX25 */
  6570. #endif /* ANYX25 */
  6571.  
  6572.       case SHNET:
  6573. #ifdef NOLOCAL
  6574.         printf(" No network support in this version of C-Kermit.\n");
  6575. #else
  6576. #ifndef NETCONN
  6577.         printf(" No network support in this version of C-Kermit.\n");
  6578. #else
  6579.         shonet();
  6580. #endif /* NETCONN */
  6581. #endif /* NOLOCAL */
  6582.         break;
  6583.  
  6584.       case SHPAR:
  6585.         shopar();
  6586.         break;
  6587.  
  6588. #ifndef NOXFER
  6589.       case SHATT:
  6590.         shoatt();
  6591.         break;
  6592. #endif /* NOXFER */
  6593.  
  6594. #ifndef NOSPL
  6595.       case SHCOU:
  6596.         printf(" %d\n",count[cmdlvl]);
  6597.         break;
  6598. #endif /* NOSPL */
  6599.  
  6600. #ifndef NOSERVER
  6601.       case SHSER:                       /* Show Server */
  6602.         i = 0;
  6603. #ifndef NOFRILLS
  6604.         printf("Function:          Status:\n");
  6605.         i++;
  6606.         printf(" GET                %s\n",nm[en_get]);
  6607.         i++;
  6608.         printf(" SEND               %s\n",nm[en_sen]);
  6609.         i++;
  6610.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6611.         i++;
  6612.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6613.         i++;
  6614. #ifndef NOSPL
  6615.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6616.         i++;
  6617. #endif /* NOSPL */
  6618.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6619.         i++;
  6620. #ifdef ZCOPY
  6621.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6622.         i++;
  6623. #endif /* ZCOPY */
  6624.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6625.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6626.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6627.         i += 3;
  6628. #ifndef NOSPL
  6629.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6630.         i++;
  6631. #endif /* NOSPL */
  6632.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6633.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6634.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6635.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6636.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6637.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6638.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6639.         printf(" BYE                %s\n",nm[en_bye]);
  6640.         printf(" FINISH             %s\n",nm[en_fin]);
  6641.         printf(" EXIT               %s\n",nm[en_xit]);
  6642.         printf(" ENABLE             %s\n",nm[en_ena]);
  6643.         i += 11;
  6644. #endif /* NOFRILLS */
  6645.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6646.         printf("Server timeout:      %d\n",srvtim);
  6647.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6648.         printf("Server idle-timeout: %d\n",srvidl);
  6649.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6650.         printf("Server keepalive     %s\n", showoff(srvping));
  6651.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6652.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6653.         if (srvcdmsg && cdmsgstr)
  6654.           printf("Server cd-message    %s\n", cdmsgstr);
  6655.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6656.         printf("Server display:      %s\n", showoff(srvdis));
  6657.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6658.         printf("Server login:        ");
  6659.         if (!x_user) {
  6660.             printf("(none)\n");
  6661.         } else {
  6662.             printf("\"%s\", \"%s\", \"%s\"\n",
  6663.                    x_user,
  6664.                    x_passwd ? x_passwd : "",
  6665.                    x_acct ? x_acct : ""
  6666.                    );
  6667.         }
  6668.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6669.         printf("Server get-path: ");
  6670.         if (ngetpath == 0) {
  6671.             printf("    (none)\n");
  6672.         } else {
  6673.             printf("\n");
  6674.             i += 3;
  6675.             for (x = 0; x < ngetpath; x++) {
  6676.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6677.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6678.                     if (!askmore())
  6679.                       break;
  6680.                     else
  6681.                       i = 0;
  6682.                 }
  6683.             }
  6684.         }
  6685.         break;
  6686. #endif /* NOSERVER */
  6687.  
  6688.       case SHSTA:                       /* Status of last command */
  6689.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6690.         return(0);                      /* Don't change it */
  6691.  
  6692.       case SHSTK: {                     /* Stack for MAC debugging */
  6693. #ifdef MAC
  6694.           long sp;
  6695.           sp = -1;
  6696.           loadA0 ((char *)&sp);         /* set destination address */
  6697.           SPtoaA0();                    /* move SP to destination */
  6698.           printf("Stack at 0x%x\n", sp);
  6699.           show_queue();                 /* more debugging */
  6700.           break;
  6701. #else
  6702.           shostack();
  6703. #endif /* MAC */
  6704.           break;
  6705.       }
  6706.  
  6707.  
  6708. #ifndef NOLOCAL
  6709. #ifdef OS2
  6710.       case SHTAB:                       /* SHOW TABS */
  6711. #ifdef IKSD
  6712.         if (inserver) {
  6713.             printf("Sorry, command disabled.\r\n");
  6714.             return(success = 0);
  6715.         }
  6716. #endif /* IKSD */
  6717.         shotabs();
  6718.         break;
  6719. #endif /* OS2 */
  6720.  
  6721.       case SHTER:                       /* SHOW TERMINAL */
  6722. #ifdef IKSD
  6723.         if (inserver) {
  6724.             printf("Sorry, command disabled.\r\n");
  6725.             return(success = 0);
  6726.         }
  6727. #endif /* IKSD */
  6728.         shotrm();
  6729.         break;
  6730.  
  6731. #ifdef OS2
  6732.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6733.         shovscrn();
  6734.         break;
  6735. #endif /* OS2 */
  6736. #endif /* NOLOCAL */
  6737.  
  6738. #ifdef OS2MOUSE
  6739.       case SHMOU:                       /* SHOW MOUSE */
  6740. #ifdef IKSD
  6741.         if (inserver) {
  6742.             printf("Sorry, command disabled.\r\n");
  6743.             return(success = 0);
  6744.         }
  6745. #endif /* IKSD */
  6746.         shomou();
  6747.         break;
  6748. #endif /* OS2MOUSE */
  6749.  
  6750. #ifndef NOFRILLS
  6751.       case SHVER:
  6752.         shover();
  6753.         break;
  6754. #endif /* NOFRILLS */
  6755.  
  6756. #ifndef NOSPL
  6757.       case SHBUI:                       /* Built-in variables */
  6758.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6759.           return(y);
  6760.         ckstrncpy(line,s,LINBUFSIZ);
  6761.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6762.  
  6763.       case SHFUN:                       /* or built-in functions */
  6764. #ifdef CK_TTGWSIZ
  6765. #ifdef OS2
  6766.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6767.           ttgwsiz();
  6768. #else /* OS2 */
  6769.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6770.             if (tt_rows > 0 && tt_cols > 0) {
  6771.                 cmd_rows = tt_rows;
  6772.                 cmd_cols = tt_cols;
  6773.             }
  6774.         }
  6775. #endif /* OS2 */
  6776. #endif /* CK_TTGWSIZ */
  6777.  
  6778.         if (x == SHFUN) {               /* Functions */
  6779.             printf("\nThe following functions are available:\n\n");
  6780.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6781.             printf("\n");
  6782. #ifndef NOHELP
  6783.             printf(
  6784. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6785.                    );
  6786. #endif /* NOHELP */
  6787.             break;
  6788.         } else {                        /* Variables */
  6789.         int j, flag = 0, havearg = 0;
  6790.         struct stringarray * q = NULL;
  6791.         char ** pp;
  6792.         if (line[0]) {        /* Have something to search for */
  6793.         havearg = 1;        /* Maybe a list of things */
  6794.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6795.         if (!q) break;
  6796.         pp = q->a_head;
  6797.         }
  6798.         i = 0;
  6799.         for (y = 0; y < nvars; y++) {
  6800.         if ((vartab[y].flgs & CM_INV))
  6801.           continue;
  6802.         if (havearg) {        /* If I have something to match */
  6803.             char * s2;
  6804.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6805.             s2 = pp[j] ? pp[j] : "";
  6806. #ifdef COMMENT
  6807. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6808.             len = strlen(s2);
  6809.             if (len > 0) {
  6810.                 if (s2[len-1] != '$') {/* To allow anchors */
  6811.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6812.                 s2 = line;
  6813.                 }
  6814.             }
  6815. #endif /* COMMENT */
  6816.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6817.                 flag = 1;    /* Matches */
  6818.                 break;
  6819.             }
  6820.             }
  6821.             if (!flag)        /* Doesn't match */
  6822.               continue;
  6823.         }
  6824.         s = nvlook(vartab[y].kwd);
  6825.         printf(" \\v(%s) = ",vartab[y].kwd);
  6826.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6827.             while (*s)        /* Show control chars symbolically */
  6828.               printf("\\{%d}",*s++);
  6829.             printf("\n");
  6830.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6831.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6832. #ifdef OS2
  6833.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6834. #endif /* OS2 */
  6835.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6836.                 vartab[y].kwval <= VN_M_ZZZ)
  6837.                ) {
  6838.             int r = 12;        /* This one can wrap around */
  6839.             char buf[10];
  6840.             while (*s) {
  6841.             if (isprint(*s)) {
  6842.                 buf[0] = *s;
  6843.                 buf[1] = NUL;
  6844.                 r++;
  6845.             } else {
  6846.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6847.                 r += (int) strlen(buf);
  6848.             }
  6849.             if (r >= cmd_cols - 1) {
  6850.                 printf("\n");
  6851.                 r = 0;
  6852.                 i++;
  6853.             }
  6854.             printf("%s",buf);
  6855.             s++;
  6856.             }
  6857.             printf("\n");
  6858.         } else
  6859.           printf("%s\n",s);
  6860.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6861.             if ((y >= nvars - 1) || !askmore())
  6862.               break;
  6863.             else
  6864.               i = 0;
  6865.         }
  6866.         }
  6867.         }
  6868.         break;
  6869.  
  6870.       case SHVAR:                       /* Global variables */
  6871.         x = 0;                          /* Variable count */
  6872.         slc = 1;                        /* Screen line count for "more?" */
  6873.         for (y = 33; y < GVARS; y++)
  6874.           if (g_var[y]) {
  6875.               if (x++ == 0) printf("Global variables:\n");
  6876.               sprintf(line," \\%%%c",y); /* SAFE */
  6877.               if (shomac(line,g_var[y]) < 0) break;
  6878.           }
  6879.         if (!x) printf(" No variables defined\n");
  6880.         break;
  6881.  
  6882.       case SHARG: {                     /* Args */
  6883.           char * s1, * s2;
  6884.           if (maclvl > -1) {
  6885.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6886.                      maclvl,
  6887.                      macargc[maclvl]
  6888.                      );
  6889.               for (y = 0; y < macargc[maclvl]; y++) {
  6890.                   s1 = m_arg[maclvl][y];
  6891.                   if (!s1) s1 = "(NULL)";
  6892.                   s2 = m_xarg[maclvl][y];
  6893.                   if (!s2) s2 = "(NULL)";
  6894.                   if (y < 10)
  6895.                     printf(" \\%%%d = %s\n",y,s1);
  6896.                   else
  6897.                     printf(" \\&_[%d] = %s\n",y,s2);
  6898.               }
  6899.           } else {
  6900.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  6901.               for (y = 0; y < topargc; y++) {
  6902.                   s1 = g_var[y + '0'];
  6903.                   if (!s1) s1 = "(NULL)";
  6904.                   s2 = toparg[y];
  6905.                   if (!s2) s2 = "(NULL)";
  6906.                   if (y < 10 && g_var[y])
  6907.                     printf(" \\%%%d = %s\n",y,s1);
  6908.                   if (toparg[y])
  6909.                     printf(" \\&_[%d] = %s\n",y,s2);
  6910.               }
  6911.           }
  6912.         }
  6913.         break;
  6914.  
  6915.       case SHARR:                       /* Arrays */
  6916.         return(showarray());
  6917. #endif /* NOSPL */
  6918.  
  6919. #ifndef NOXFER
  6920.       case SHPRO:                       /* Protocol parameters */
  6921.         shoparp();
  6922.         printf("\n");
  6923.         break;
  6924. #endif /* NOXFER */
  6925.  
  6926. #ifndef NOLOCAL
  6927.       case SHCOM:                       /* Communication parameters */
  6928.         printf("\n");
  6929.         shoparc();
  6930. #ifdef OS2
  6931.         {
  6932.             int i;
  6933.             char *s = "(unknown)";
  6934.             for (i = 0; i < nprty; i++)
  6935.               if (prtytab[i].kwval == priority) {
  6936.                   s = prtytab[i].kwd;
  6937.                   break;
  6938.               }
  6939.             printf(" Priority: %s\n", s );
  6940.         }
  6941. #endif /* OS2 */
  6942.  
  6943.         printf("\n");
  6944. #ifdef NETCONN
  6945.         if (!network
  6946. #ifdef IKSD
  6947.              && !inserver
  6948. #endif /* IKSD */
  6949.              ) {
  6950. #endif /* NETCONN */
  6951.             shomdm();
  6952.             printf("\n");
  6953. #ifdef NETCONN
  6954.         }
  6955. #endif /* NETCONN */
  6956.  
  6957. #ifndef NODIAL
  6958. #ifdef IKSD
  6959.         if ( !inserver )
  6960. #endif /* IKSD */
  6961.         {
  6962.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  6963.             printf("Type SHOW MODEM to see modem-related items.\n");
  6964. #ifdef CK_TAPI
  6965.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  6966. #endif /* CK_TAPI */
  6967.             printf("\n");
  6968.         }
  6969. #endif /* NODIAL */
  6970.         break;
  6971. #endif /* NOLOCAL */
  6972.  
  6973.       case SHFIL:                       /* File parameters */
  6974.         shofil();
  6975.         /* printf("\n"); */             /* (out o' space) */
  6976.         break;
  6977.  
  6978. #ifndef NOCSETS
  6979.       case SHLNG:                       /* Languages */
  6980.         shoparl();
  6981.         break;
  6982. #endif /* NOCSETS */
  6983.  
  6984. #ifndef NOSPL
  6985.       case SHSCR:                       /* Scripts */
  6986.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  6987.         printf(" Take  echo:             %s\n", showoff(techo));
  6988.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  6989.         printf(" Macro echo:             %s\n", showoff(mecho));
  6990.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  6991.         printf(" Quiet:                  %s\n", showoff(quiet));
  6992.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  6993.         printf(" Function error:         %s\n", showoff(fnerror));
  6994. #ifdef CKLEARN
  6995.         {
  6996.             extern char * learnfile;
  6997.             extern int learning;
  6998.             if (learnfile) {
  6999.                 printf(" LEARN file:             %s (%s)\n",
  7000.                        learnfile,
  7001.                        learning ? "ON" : "OFF"
  7002.                        );
  7003.             } else
  7004.               printf(" LEARN file:             (none)\n");
  7005.         }
  7006. #endif /* CKLEARN */
  7007.         shoinput();
  7008.         shooutput();
  7009. #ifndef NOSCRIPT
  7010.         printf(" Script echo:            %s\n", showoff(secho));
  7011. #endif /* NOSCRIPT */
  7012.         printf(" Command buffer length:  %d\n", CMDBL);
  7013.         printf(" Atom buffer length:     %d\n", ATMBL);
  7014.         break;
  7015. #endif /* NOSPL */
  7016.  
  7017. #ifndef NOXMIT
  7018.       case SHXMI:
  7019.         printf("\n");
  7020.         printf(" File type:                       %s\n",
  7021.                binary ? "binary" : "text");
  7022. #ifndef NOCSETS
  7023.         printf(" File character-set:              %s\n",
  7024.                fcsinfo[fcharset].keyword);
  7025. #ifdef OS2
  7026.         if ( isunicode() ) {
  7027.         printf(" Terminal Character (remote):     %s\n",
  7028.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7029.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7030.         printf(" Terminal Character (local):      %s\n",
  7031.               tcsl == TX_TRANSP ? "transparent" :
  7032.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7033.         } else {
  7034.         printf(" Terminal Character (remote):     %s\n",
  7035.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7036.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7037.         printf(" Terminal Character (local):      %s\n",
  7038.               tcsl == TX_TRANSP ? "transparent" :
  7039.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7040.         }
  7041. #else /* OS2 */
  7042.         printf(" Terminal character-set (remote): %s\n",
  7043.                fcsinfo[tcsr].keyword);
  7044.         printf(" Terminal character-set (local):  %s\n",
  7045.                fcsinfo[tcsl].keyword);
  7046. #endif /* OS2 */
  7047. #endif /* NOCSETS */
  7048.         printf(" Terminal bytesize:               %d\n",
  7049.                (cmask == 0xff) ? 8 : 7);
  7050.         printf(" Terminal echo:                   %s\n",
  7051.                duplex ? "local" : "remote");
  7052.         printf(" Transmit EOF:                    ");
  7053.         if (*xmitbuf == NUL) {
  7054.             printf("(none)\n");
  7055.         } else {
  7056.             char *p;
  7057.             p = xmitbuf;
  7058.             while (*p) {
  7059.                 if (*p < SP)
  7060.                   printf("^%c",ctl(*p));
  7061.                 else
  7062.                   printf("%c",*p);
  7063.                 p++;
  7064.             }
  7065.             printf("\n");
  7066.         }
  7067.         if (xmitf)
  7068.           printf(" Transmit Fill:                   %d\n", xmitf);
  7069.         else
  7070.           printf(" Transmit Fill:                   (none)\n");
  7071.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  7072.         if (xmitp)
  7073.           printf(" Transmit Prompt:                 %d (%s)\n",
  7074.                  xmitp,
  7075.                  chartostr(xmitp)
  7076.                  );
  7077.         else
  7078.           printf(" Transmit Prompt:                 (none)\n");
  7079.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  7080.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  7081.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  7082.                xmitw,
  7083.                (xmitw == 1) ? "" : "s"
  7084.                );
  7085.         printf(" Transmit Timeout:                %d (second%s)\n",
  7086.                xmitt,
  7087.                (xmitt == 1) ? "" : "s"
  7088.                );
  7089.         printf("\n");
  7090.         break;
  7091. #endif /* NOXMIT */
  7092.  
  7093. #ifndef NODIAL
  7094.       case SHMOD:                       /* SHOW MODEM */
  7095. #ifdef IKSD
  7096.         if (inserver) {
  7097.             printf("Sorry, command disabled.\r\n");
  7098.             return(success = 0);
  7099.         }
  7100. #endif /* IKSD */
  7101.         shomodem();                     /* Show SET MODEM items */
  7102.         break;
  7103. #endif /* NODIAL */
  7104.  
  7105. #ifndef MAC
  7106.       case SHDFLT:
  7107.         printf("%s\n",zgtdir());
  7108.         break;
  7109. #endif /* MAC */
  7110.  
  7111. #ifndef NOLOCAL
  7112.       case SHESC:
  7113. #ifdef IKSD
  7114.         if (inserver) {
  7115.             printf("Sorry, command disabled.\r\n");
  7116.             return(success = 0);
  7117.         }
  7118. #endif /* IKSD */
  7119.         return(shoesc(escape));
  7120.  
  7121. #ifndef NODIAL
  7122.       case SHDIA:                       /* SHOW DIAL */
  7123. #ifdef IKSD
  7124.         if (inserver) {
  7125.             printf("Sorry, command disabled.\r\n");
  7126.             return(success = 0);
  7127.         }
  7128. #endif /* IKSD */
  7129.         shmdmlin();
  7130.         printf(", speed: ");
  7131.         if ((zz = ttgspd()) < 0) {
  7132.             printf("unknown");
  7133.         } else {
  7134.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  7135.         }
  7136.         if (carrier == CAR_OFF) s = "off";
  7137.         else if (carrier == CAR_ON) s = "on";
  7138.         else if (carrier == CAR_AUT) s = "auto";
  7139.         else s = "unknown";
  7140.         printf(", carrier: %s", s);
  7141.         if (carrier == CAR_ON) {
  7142.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  7143.             else printf(", timeout: none");
  7144.         }
  7145.         printf("\n");
  7146.         doshodial();
  7147.         if (local
  7148. #ifdef NETCONN
  7149.             && !network
  7150. #endif /* NETCONN */
  7151.             ) {
  7152.             printf("Type SHOW MODEM to see modem settings.\n");
  7153. #ifdef CK_TAPI
  7154.             printf("Type SHOW TAPI to see TAPI-related items\n");
  7155. #endif /* CK_TAPI */
  7156.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  7157.         }
  7158.         break;
  7159. #endif /* NODIAL */
  7160. #endif /* NOLOCAL */
  7161.  
  7162. #ifndef NOXFER
  7163. #ifdef CK_LABELED
  7164.       case SHLBL:                       /* Labeled file info */
  7165.         sholbl();
  7166.         break;
  7167. #endif /* CK_LABELED */
  7168. #endif /* NOXFER */
  7169.  
  7170.       case SHCSE:                       /* Character sets */
  7171. #ifdef NOCSETS
  7172.         printf(
  7173. " Character set translation is not supported in this version of C-Kermit\n");
  7174. #else
  7175.         shocharset();
  7176. #ifndef NOXFER
  7177.         printf("\n Unknown-Char-Set: %s\n",
  7178.                unkcs ? "Keep" : "Discard");
  7179. #endif /* NOXFER */
  7180. #ifdef OS2
  7181.         printf("\n");
  7182. #endif /* OS2 */
  7183.         shotcs(tcsl,tcsr);
  7184.         printf("\n");
  7185. #ifdef OS2
  7186.         /* PC Code Page information */
  7187.         {
  7188.             char cpbuf[128];
  7189.             int cplist[16], cps;
  7190.             int activecp;
  7191.             cps = os2getcplist(cplist, sizeof(cplist));
  7192.  
  7193.             sprintf(cpbuf,              /* SAFE */
  7194.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7195.                      cps > 1 ? cplist[1] : 0,
  7196.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7197.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7198.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7199.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7200.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7201.                      cps > 12 ? cplist[12] : 0
  7202.                      );
  7203.             printf(" Code Pages:\n");
  7204.             activecp = os2getcp();
  7205.             if ( activecp ) {
  7206.               printf("     Active: %d\n",activecp);
  7207.               if (!isWin95())
  7208.                 printf("  Available: %s\n",cpbuf);
  7209.             } else
  7210.               printf("     Active: n/a\n");
  7211.             printf("\n");
  7212.         }
  7213. #endif /* OS2 */
  7214. #endif /* NOCSETS */
  7215.         break;
  7216.  
  7217.       case SHFEA:                       /* Features */
  7218.         shofea();
  7219.         break;
  7220.  
  7221. #ifdef CK_SPEED
  7222.       case SHCTL:                       /* Control-Prefix table */
  7223.         shoctl();
  7224.         break;
  7225. #endif /* CK_SPEED */
  7226.  
  7227.       case SHEXI: {
  7228.           extern int exithangup;
  7229.           printf("\n Exit warning %s\n", xitwarn ?
  7230.                  (xitwarn == 1 ? "on" : "always") : "off");
  7231.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7232.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7233.           printf(" Current exit status: %d\n\n", xitsta);
  7234.           break;
  7235.       }
  7236.       case SHPRT: {
  7237. #ifdef PRINTSWI
  7238.           extern int printtimo, printertype, noprinter;
  7239.           extern char * printterm, * printsep;
  7240. #ifdef BPRINT
  7241.           extern int printbidi;
  7242. #endif /* BPRINT */
  7243. #endif /* PRINTSWI */
  7244.  
  7245. #ifdef IKSD
  7246.         if (inserver &&
  7247. #ifdef CK_LOGIN
  7248.             isguest
  7249. #else /* CK_LOGIN */
  7250.             0
  7251. #endif /* CK_LOGIN */
  7252.              ) {
  7253.             printf("Sorry, command disabled.\r\n");
  7254.             return(success = 0);
  7255.         }
  7256. #endif /* IKSD */
  7257. #ifdef PRINTSWI
  7258.           if (noprinter) {
  7259.               printf("Printer: (none)\n\n");
  7260.               break;
  7261.           }
  7262. #endif /* PRINTSWI */
  7263.  
  7264.           printf("Printer: %s%s\n",
  7265.  
  7266.                  printpipe ? "| " : "",
  7267.                  printername ? printername :
  7268. #ifdef OS2
  7269.                  "PRN"
  7270. #else
  7271.                  "(default)"
  7272. #endif /* OS2 */
  7273.                  );
  7274. #ifdef PRINTSWI
  7275. #ifdef BPRINT
  7276.           if (printbidi) {
  7277.               printf(" /BIDIRECTIONAL\n");
  7278.               if (pportspeed > 0)
  7279.                 printf(" /SPEED:%ld\n",pportspeed);
  7280.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7281.               printf(" /FLOW:%s\n",
  7282.                      pportflow == FLO_NONE ? "NONE" :
  7283.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7284.                      );
  7285.           } else
  7286.             printf(" /OUTPUT-ONLY\n");
  7287. #endif /* BPRINT */
  7288.           switch (printertype) {
  7289.             case PRT_NON: printf(" /NONE\n"); break;
  7290.             case PRT_FIL: printf(" /FILE\n"); break;
  7291.             case PRT_PIP: printf(" /PIPE\n"); break;
  7292.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7293.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7294.           }
  7295.           printf(" /TIMEOUT:%d\n",printtimo);
  7296.           if (printterm) {
  7297.               printf(" /END-OF-JOB-STRING:");
  7298.               shostrdef(printterm);
  7299.               printf("\n");
  7300.           } else
  7301.             printf(" /END-OF-JOB-STRING:(none)\n");
  7302.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7303. #endif /* PRINTSWI */
  7304.           printf("\n");
  7305.           break;
  7306.       }
  7307.  
  7308.       case SHCMD: {
  7309. #ifdef DOUBLEQUOTING
  7310.           extern int dblquo;
  7311. #endif /* DOUBLEQUOTING */
  7312. #ifdef CK_AUTODL
  7313.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7314. #else
  7315.           printf(" Command autodownload: (not available)\n");
  7316. #endif /* CK_AUTODL */
  7317.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7318. #ifdef CK_RECALL
  7319.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7320. #else
  7321.           printf(" Command recall-buffer not available in this version\n");
  7322. #endif /* CK_RECALL */
  7323. #ifdef CK_RECALL
  7324.           printf(" Command retry: %s\n",showoff(cm_retry));
  7325. #else
  7326.           printf(" Command retry not available in this version\n");
  7327. #endif /* CK_RECALL */
  7328.           printf(" Command interruption: %s\n", showoff(cmdint));
  7329.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7330. #ifdef DOUBLEQUOTING
  7331.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7332. #endif /* DOUBLEQUOTING */
  7333.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7334.           printf(" Command height: %d\n", cmd_rows);
  7335.           printf(" Command width:  %d\n", cmd_cols);
  7336. #ifndef IKSDONLY
  7337. #ifdef OS2
  7338.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7339. #endif /* OS2 */
  7340. #endif /* IKSDONLY */
  7341. #ifdef LOCUS
  7342.           printf(" Locus:          %s",
  7343.                  autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7344.          (locus ? "local" : "remote"));
  7345.           if (autolocus)
  7346.             printf(" (%s)", locus ? "local" : "remote");
  7347.           printf("\n");
  7348. #endif /* LOCUS */
  7349.           printf(" Hints:          %s\n", showoff(hints));
  7350.           printf(" Quiet:          %s\n", showoff(quiet));
  7351.           printf(" Maximum command length: %d\n", CMDBL);
  7352. #ifndef NOSPL
  7353.           {
  7354.               char * s;
  7355.               int k;
  7356.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7357.               printf(" Macros defined: %d\n", nmac);
  7358.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7359.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7360.               s = "(not defined)";
  7361.               k = mlook(mactab,"on_unknown_command",nmac);
  7362.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7363.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7364.           }
  7365. #endif /* NOSPL */
  7366. #ifdef UNIX
  7367. #ifndef NOJC
  7368.           printf(" Suspend: %s\n", showoff(xsuspend));
  7369. #endif /* NOJC */
  7370. #endif /* UNIX */
  7371.           printf(" Access to external commands and programs%s allowed\n",
  7372. #ifndef NOPUSH
  7373.                  !nopush ? "" :
  7374. #endif /* NOPUSH */
  7375.                   " not");
  7376.           break;
  7377.       }
  7378.  
  7379. #ifndef NOSPL
  7380.       case SHALRM:
  7381.         if (ck_alarm)
  7382.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7383.         else
  7384.           printf("(no alarm set)\n");
  7385.         break;
  7386. #endif /* NOSPL */
  7387.  
  7388. #ifndef NOMSEND
  7389.       case SHSFL: {
  7390.           extern struct filelist * filehead;
  7391.           if (!filehead) {
  7392.               printf("send-list is empty\n");
  7393.           } else {
  7394.               struct filelist * flp;
  7395.               char * s;
  7396.               flp = filehead;
  7397.               while (flp) {
  7398.                   s = flp->fl_alias;
  7399.                   if (!s) s = "(none)";
  7400.                   printf("%s, mode: %s, alias: %s\n",
  7401.                          flp->fl_name,
  7402.                          gfmode(flp->fl_mode,0),
  7403.                          s
  7404.                          );
  7405.                   flp = flp->fl_next;
  7406.               }
  7407.           }
  7408.       }
  7409.       break;
  7410. #endif /* NOMSEND */
  7411.  
  7412. #ifdef CKXXCHAR
  7413.       case SHDBL:
  7414.         shodbl();
  7415.         break;
  7416. #endif /* CKXXCHAR */
  7417.  
  7418. #ifndef NOPUSH
  7419. #ifndef NOFRILLS
  7420.       case SHEDIT:
  7421.         if (!editor[0]) {
  7422.             s = getenv("EDITOR");
  7423.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7424.         }
  7425.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7426.         if (editor[0]) {
  7427.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7428.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7429.         }
  7430.         printf("\n");
  7431.         break;
  7432.  
  7433. #ifdef BROWSER
  7434.       case SHBROWSE:
  7435.         if (!browser[0]) {
  7436.             s = getenv("BROWSER");
  7437.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7438.         }
  7439.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7440.         if (browser[0]) {
  7441.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7442.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7443.         }
  7444.         printf("\n");
  7445.         break;
  7446. #endif /* BROWSER */
  7447. #endif /*  NOFRILLS */
  7448. #endif /* NOPUSH */
  7449.  
  7450. #ifndef NOLOCAL
  7451. #ifdef CK_TAPI
  7452.       case SHTAPI:                      /* TAPI options */
  7453. #ifdef IKSD
  7454.         if (inserver) {
  7455.             printf("Sorry, command disabled.\r\n");
  7456.             return(success = 0);
  7457.         }
  7458. #endif /* IKSD */
  7459.         shotapi(0);
  7460.         break;
  7461.       case SHTAPI_L:                    /* TAPI Locations */
  7462. #ifdef IKSD
  7463.         if (inserver) {
  7464.             printf("Sorry, command disabled.\r\n");
  7465.             return(success = 0);
  7466.         }
  7467. #endif /* IKSD */
  7468.         shotapi(1);
  7469.         break;
  7470.       case SHTAPI_M:                    /* TAPI Modem */
  7471. #ifdef IKSD
  7472.         if (inserver) {
  7473.             printf("Sorry, command disabled.\r\n");
  7474.             return(success = 0);
  7475.         }
  7476. #endif /* IKSD */
  7477.         shotapi(2);
  7478.         break;
  7479.       case SHTAPI_C:                    /* TAPI Comm */
  7480. #ifdef IKSD
  7481.         if (inserver) {
  7482.             printf("Sorry, command disabled.\r\n");
  7483.             return(success = 0);
  7484.         }
  7485. #endif /* IKSD */
  7486.         shotapi(3);
  7487.         break;
  7488. #endif /* CK_TAPI */
  7489.  
  7490.       case SHTCP:                       /* SHOTCP */
  7491.         printf("\n");
  7492.         shotcp(0);
  7493.         printf("\n");
  7494.         break;
  7495.  
  7496. #ifdef TNCODE
  7497.       case SHTEL:                       /* TELNET */
  7498.         printf("\n");
  7499.         shotel(0);
  7500.         printf("\n");
  7501.         break;
  7502.  
  7503.       case SHTOPT:                      /* TELNET OPTIONS */
  7504.         printf("\n");
  7505.         shotopt(0);
  7506.         printf("\n");
  7507.         break;
  7508. #endif /* TNCODE */
  7509.  
  7510. #ifdef CK_TRIGGER
  7511.       case SHTRIG: {
  7512.           extern char * tt_trigger[], * triggerval;
  7513.           int i;
  7514.           if (!tt_trigger[0]) {
  7515.               printf(" Triggers: (none)\n");
  7516.           } else {
  7517.               printf(" Triggers:\n");
  7518.               for (i = 0; i < TRIGGERS; i++) {
  7519.                   if (!tt_trigger[i])
  7520.                     break;
  7521.                   printf("  \"%s\"\n",tt_trigger[i]);
  7522.               }
  7523.               printf(" Most recent trigger encountered: ");
  7524.               if (triggerval)
  7525.                 printf("\"%s\"\n",triggerval);
  7526.               else
  7527.                 printf("(none)\n");
  7528.           }
  7529.           break;
  7530.       }
  7531. #endif /* CK_TRIGGER */
  7532. #endif /* NOLOCAL */
  7533.  
  7534. #ifndef NOSPL
  7535.       case SHINP:
  7536.         shoinput();
  7537.         break;
  7538. #endif /* NOSPL */
  7539.  
  7540.       case SHLOG: {
  7541. #ifndef MAC
  7542. #ifdef IKSD
  7543.           if (inserver &&
  7544. #ifdef CK_LOGIN
  7545.               isguest
  7546. #else /* CK_LOGIN */
  7547.               0
  7548. #endif /* CK_LOGIN */
  7549.              ) {
  7550.             printf("Sorry, command disabled.\r\n");
  7551.             return(success = 0);
  7552.         }
  7553. #endif /* IKSD */
  7554. #ifdef DEBUG
  7555.           printf("\n Debug log:       %s\n", deblog ? debfil : "(none)");
  7556. #endif /* DEBUG */
  7557. #ifndef NOXFER
  7558.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7559. #endif /* NOXFER */
  7560. #ifndef NOLOCAL
  7561.           printf(" Session log:     %s\n",   seslog ? sesfil : "(none)");
  7562. #endif /* NOLOCAL */
  7563. #ifdef TLOG
  7564.           printf(" Transaction log: %s (%s)\n",
  7565.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7566.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7567.                  );
  7568. #endif /* TLOG */
  7569. #ifdef CKLOGDIAL
  7570.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7571. #endif /* CKLOGDIAL */
  7572.           printf("\n");
  7573. #endif /* MAC */
  7574.           break;
  7575.       }
  7576.  
  7577. #ifndef NOSPL
  7578.       case SHOUTP:                      /* OUTPUT */
  7579.         shooutput();
  7580.         break;
  7581. #endif /* NOSPL */
  7582.  
  7583. #ifdef PATTERNS
  7584.       case SHOPAT:                      /* PATTERNS */
  7585.         shopat();
  7586.         break;
  7587. #endif /* PATTERNS */
  7588.  
  7589. #ifdef STREAMING
  7590.       case SHOSTR: {                    /* STREAMING */
  7591.           extern int streamrq, clearrq, cleared;
  7592.           extern long tfcps;
  7593.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7594.           printf("\n Reliable:     %s\n",showooa(reliable));
  7595.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7596.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7597.           if ((!local && (streamrq == SET_ON)) ||
  7598.               (streamrq == SET_AUTO && reliable))
  7599.             printf(" Streaming will be done if requested.\n");
  7600.           else if ((streamrq == SET_OFF) ||
  7601.                    ((streamrq == SET_AUTO) && !reliable))
  7602.             printf(" Streaming will not be requested and will not be done.\n");
  7603.           else if ((streamrq == SET_ON) ||
  7604.                    ((streamrq == SET_AUTO) && reliable))
  7605.             printf(
  7606. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7607.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7608.                  streamed > 0 ? "" : "no ",
  7609.                  cleared ? ", clearchannel" : "",
  7610.                  tfcps
  7611.                  );
  7612.           printf("\n");
  7613.           break;
  7614.       }
  7615. #endif /* STREAMING */
  7616.  
  7617.       case SHOIKS:
  7618.         return(sho_iks());
  7619.         break;
  7620.  
  7621. #ifdef CK_AUTHENTICATION
  7622.       case SHOAUTH:
  7623.         return(sho_auth(0));
  7624. #endif /* CK_AUTHENTICATION */
  7625.  
  7626. #ifndef NOFTP
  7627.       case SHOFTP: {
  7628. #ifdef IKSD
  7629.         if (inserver) {
  7630.             printf("Sorry, command disabled.\r\n");
  7631.             return(success = 0);
  7632.         }
  7633. #endif /* IKSD */
  7634. #ifdef SYSFTP
  7635.         {
  7636.             extern char ftpapp[], ftpopts[];
  7637.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7638.             if (ftpapp[0])
  7639.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7640.         }
  7641. #else
  7642. #ifdef NEWFTP
  7643.         shoftp(0);
  7644. #else
  7645.         printf("(No FTP client included in this version of Kermit.)\n");
  7646. #endif /* NEWFTP */
  7647. #endif /* SYSFTP */
  7648.         break;
  7649.       }
  7650. #endif /* NOFTP */
  7651.  
  7652. #ifndef NOCMDL
  7653.       case SHXOPT: {
  7654. #ifdef IKSDB
  7655.           extern int dbenabled;
  7656.           extern char * dbfile, * dbdir;
  7657. #endif /* IKSDB */
  7658. #ifdef CKWTMP
  7659.           extern int ckxwtmp;
  7660.           extern char * wtmpfile;
  7661. #endif /* CKWTMP */
  7662. #ifdef CK_LOGIN
  7663.           extern int ckxanon, xferlog, logintimo;
  7664.           extern char * xferfile;
  7665. #ifdef UNIX
  7666.           extern int ckxpriv;
  7667. #endif /* UNIX */
  7668. #ifdef CK_PERMS
  7669.           extern int ckxperms;
  7670. #endif /* CK_PERMS */
  7671. #endif /* CK_LOGIN */
  7672.           extern char * bannerfile, * helpfile;
  7673.  
  7674. #ifdef IKSD
  7675.           if (inserver &&
  7676. #ifdef CK_LOGIN
  7677.               isguest
  7678. #else /* CK_LOGIN */
  7679.               0
  7680. #endif /* CK_LOGIN */
  7681.               ) {
  7682.               printf("Sorry, command disabled.\r\n");
  7683.               return(success = 0);
  7684.           }
  7685. #endif /* IKSD */
  7686.           printf("\n");
  7687.           if (!cmdint)
  7688.             printf(" --nointerrupts\n");
  7689.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7690.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7691.           printf(" --cdmessage:%d\n",srvcdmsg);
  7692.           printf(" --helpfile:%d\n",helpfile);
  7693.           if (inserver) {
  7694.               printf("\n");
  7695.               break;
  7696.           }
  7697. #ifdef CKSYSLOG
  7698. #ifdef SYSLOGLEVEL
  7699.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7700. #else
  7701.           printf(" --syslog:%d\n",ckxsyslog);
  7702. #endif /* SYSLOGLEVEL */
  7703. #endif /* CKSYSLOG */
  7704. #ifdef CKWTMP
  7705.           printf(" --wtmplog:%d\n",ckxwtmp);
  7706.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7707. #endif /* CKWTMP */
  7708. #ifdef IKSD
  7709. #ifdef CK_LOGIN
  7710.           printf(" --anonymous:%d\n",ckxanon);
  7711. #ifdef UNIX
  7712.           printf(" --privid:%d\n",ckxpriv);
  7713. #endif /* UNIX */
  7714. #ifdef CK_PERMS
  7715.           printf(" --permission:%04o\n",ckxperms);
  7716. #endif /* CK_PERMS */
  7717.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7718.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7719.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7720.           printf(" --xferlog=%d\n",xferlog);
  7721.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7722.           printf(" --timeout=%d\n",logintimo);
  7723. #endif /* CK_LOGIN */
  7724. #ifdef IKSDB
  7725.           printf(" --database=%d\n",dbenabled);
  7726.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7727.           if (dbdir)
  7728.             printf("   (db directory=[%s])\n",dbdir);
  7729. #endif /* IKSDB */
  7730. #ifdef IKSDCONF
  7731.           printf(" IKSD conf=%s\n",iksdconf);
  7732. #endif /* IKSDCONF */
  7733. #endif /* IKSD */
  7734.           printf("\n");
  7735.           break;
  7736.       }
  7737. #endif /* NOCMDL */
  7738.  
  7739.       case SHCD: {
  7740.       extern char * myhome;
  7741.       s = getenv("CDPATH");
  7742.       if (!s) s = "(none)";
  7743.       printf("\n current directory:  %s\n", zgtdir());
  7744.       printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7745.       printf(" cd home:            %s\n", homepath());
  7746.       printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7747.       printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7748.       printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7749.       printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7750.       break;
  7751.       }
  7752. #ifndef NOCSETS
  7753.       case SHASSOC:
  7754.         (VOID) showassoc();
  7755.         break;
  7756. #endif /* NOCSETS */
  7757.  
  7758. #ifdef CKLOGDIAL
  7759.       case SHCONNX:
  7760. #ifdef NEWFTP
  7761.         if (ftpisconnected()) {
  7762.             extern char cxlogbuf[];
  7763.             dologshow(W_FTP | 1);
  7764.             if (cxlogbuf[0])
  7765.               dologshow(1);
  7766.         } else {
  7767. #endif /* NEWFTP */
  7768.             dologshow(1);
  7769. #ifdef NEWFTP
  7770.         }
  7771. #endif /* NEWFTP */
  7772.         break;
  7773. #endif /* CKLOGDIAL */
  7774.  
  7775.       case SHOPTS:
  7776.         optlines = 0;
  7777. #ifndef NOFRILLS
  7778.         (VOID) showdelopts();
  7779. #endif /* NOFRILLS */
  7780. #ifdef DOMYDIR
  7781.         (VOID) showdiropts();
  7782. #endif /* DOMYDIR */
  7783. #ifdef CKPURGE
  7784.         (VOID) showpurgopts();
  7785. #endif /* CKPURGE */
  7786.         (VOID) showtypopts();
  7787.         break;
  7788.  
  7789. #ifndef NOLOCAL
  7790.       case SHOFLO:
  7791.         (VOID) shoflow();
  7792.         break;
  7793. #endif /* NOLOCAL */
  7794.  
  7795. #ifndef NOXFER
  7796.       case SHOXFER:
  7797.         (VOID) shoxfer();
  7798.         break;
  7799. #endif /* NOXFER */
  7800.  
  7801. #ifdef CK_RECALL
  7802.       case SHHISTORY:
  7803.         (VOID) cmhistory();
  7804.         break;
  7805. #endif /* CK_RECALL */
  7806.  
  7807. #ifndef NOSEXP
  7808. #ifndef NOSPL
  7809.       case SHSEXP:
  7810.         (VOID) shosexp();
  7811.         break;
  7812. #endif /* NOSPL */
  7813. #endif /* NOSEXP */
  7814.  
  7815. #ifdef ANYSSH
  7816.       case SHOSSH:
  7817.         (VOID) shossh();
  7818.         break;
  7819. #endif /* ANYSSH */
  7820.  
  7821. #ifdef KUI
  7822.       case SHOGUI:
  7823.         (VOID) shogui();
  7824.         break;
  7825. #endif /* KUI */
  7826.  
  7827.       default:
  7828.         printf("\nNothing to show...\n");
  7829.         return(-2);
  7830.     }
  7831.     return(success = 1);
  7832. }
  7833.  
  7834. #ifndef NOXFER
  7835. int
  7836. shoatt() {
  7837.     printf("Attributes: %s\n", showoff(atcapr));
  7838.     if (!atcapr) return(0);
  7839.     printf(" Blocksize: %s\n", showoff(atblki));
  7840.     printf(" Date: %s\n", showoff(atdati));
  7841.     printf(" Disposition: %s\n", showoff(atdisi));
  7842.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7843.     printf(" Length: %s\n", showoff(atleni));
  7844.     printf(" Type (text/binary): %s\n", showoff(attypi));
  7845.     printf(" System ID: %s\n", showoff(atsidi));
  7846.     printf(" System Info: %s\n", showoff(atsysi));
  7847. #ifdef CK_PERMS
  7848.     printf(" Permissions In:  %s\n", showoff(atlpri));
  7849.     printf(" Permissions Out: %s\n", showoff(atlpro));
  7850. #endif /* CK_PERMS */
  7851. #ifdef STRATUS
  7852.     printf(" Format: %s\n", showoff(atfrmi));
  7853.     printf(" Creator: %s\n", showoff(atcrei));
  7854.     printf(" Account: %s\n", showoff(atacti));
  7855. #endif /* STRATUS */
  7856.     return(0);
  7857. }
  7858. #endif /* NOXFER */
  7859.  
  7860. #ifndef NOSPL
  7861. int                                     /* SHOW MACROS */
  7862. shomac(s1, s2) char *s1, *s2; {
  7863.     int x, n, pp;
  7864.     pp = 0;                             /* Parenthesis counter */
  7865.  
  7866.     debug(F110,"shomac s1",s1,0);
  7867.     debug(F110,"shomac s2",s2,0);
  7868.  
  7869. #ifdef IKSD
  7870.     if ( inserver &&
  7871. #ifdef IKSDCONF
  7872.         iksdcf
  7873. #else /* IKSDCONF */
  7874.         1
  7875. #endif /* IKSDCONF */
  7876.         ) {
  7877.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  7878.             !ckstrcmp("on_logout",s1,-1,0))
  7879.           return(0);
  7880.     }
  7881. #endif /* IKSD */
  7882.  
  7883.     if (!s1)
  7884.       return(0);
  7885.     else
  7886.       printf("%s = ",s1);               /* Print blank line and macro name */
  7887.     n = (int)strlen(s1) + 4;            /* Width of current line */
  7888.     if (!s2) s2 = "(not defined)";
  7889.  
  7890.     while ((x = *s2++)) {               /* Loop thru definition */
  7891.         if (x == '(') pp++;             /* Treat commas within parens */
  7892.         if (x == ')') pp--;             /* as ordinary text */
  7893.         if (pp < 0) pp = 0;             /* Outside parens, */
  7894.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  7895.             putchar(',');
  7896.             putchar('-');
  7897.             x = '\n';
  7898.         }
  7899.         if (inserver && (x == '\n'))    /* Send CR before LF */
  7900.           putchar(CR);
  7901.         putchar((CHAR)x);               /* Output the character */
  7902.         if (x == '\n') {                /* If it was a newline */
  7903. #ifdef UNIX
  7904. #ifdef NOSETBUF
  7905.             fflush(stdout);
  7906. #endif /* NOSETBUF */
  7907. #endif /* UNIX */
  7908.             putchar(' ');               /* Indent the next line 1 space */
  7909.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  7910.             n = 2;                      /* restart the character counter */
  7911.             slc++;                      /* and increment the line counter. */
  7912.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  7913.             putchar('-');               /* output a dash */
  7914.             if (inserver)
  7915.               putchar(CR);              /* and a carriage return */
  7916.             putchar(NL);                /* and a newline */
  7917. #ifdef UNIX
  7918. #ifdef NOSETBUF
  7919.             fflush(stdout);
  7920. #endif /* NOSETBUF */
  7921. #endif /* UNIX */
  7922.             n = 1;                      /* and restart the char counter */
  7923.             slc++;                      /* and increment the line counter */
  7924.         }
  7925.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  7926.             if (!askmore()) return(-1); /* ask if they want more. */
  7927.             n = 1;                      /* They do, start a new line */
  7928.             slc = 0;                    /* and restart line counter */
  7929.         }
  7930.     }
  7931.     if (inserver)
  7932.       putchar(CR);
  7933.     putchar(NL);                        /* End of definition */
  7934.     if (++slc > (cmd_rows - 3)) {
  7935.         if (!askmore()) return(-1);
  7936.         slc = 0;
  7937.     }
  7938.     return(0);
  7939. }
  7940. #endif /* NOSPL */
  7941. #endif /* NOSHOW */
  7942.  
  7943. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  7944.  
  7945. #ifndef NOSPL
  7946. /* Evaluate an arithmetic expression. */
  7947. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  7948.  
  7949. static int xerror = 0;
  7950. int divbyzero = 0;
  7951. static char *cp;
  7952. static long tokval;
  7953. static char curtok;
  7954. static long expval;
  7955.  
  7956. #define LONGBITS (8*sizeof (long))
  7957. #define NUMBER 'N'
  7958. #define N_EOT 'E'
  7959.  
  7960. /*
  7961.  Replacement for strchr() and index(), neither of which seem to be universal.
  7962. */
  7963.  
  7964. static char *
  7965. #ifdef CK_ANSIC
  7966. windex(char * s, char c)
  7967. #else
  7968. windex(s,c) char *s, c;
  7969. #endif /* CK_ANSIC */
  7970. /* windex */ {
  7971.     while (*s != NUL && *s != c) s++;
  7972.     if (*s == c) return(s); else return(NULL);
  7973. }
  7974.  
  7975.  
  7976. /*
  7977.  g e t t o k
  7978.  
  7979.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  7980. */
  7981. static char
  7982. gettok() {
  7983.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  7984.  
  7985.     while (isspace(*cp))                /* Skip past leading spaces */
  7986.       cp++;
  7987.  
  7988.     debug(F110,"GETTOK",cp,0);
  7989.  
  7990.     switch (*cp) {
  7991.       case '$':                         /* ??? */
  7992.       case '+':                         /* Add */
  7993.       case '-':                         /* Subtract or Negate */
  7994.       case '@':                         /* Greatest Common Divisor */
  7995.       case '*':                         /* Multiply */
  7996.       case '/':                         /* Divide */
  7997.       case '%':                         /* Modulus */
  7998.       case '<':                         /* Left shift */
  7999.       case '>':                         /* Right shift */
  8000.       case '&':                         /* And */
  8001.       case '|':                         /* Or */
  8002.       case '#':                         /* Exclusive Or */
  8003.       case '~':                         /* Not */
  8004.       case '^':                         /* Exponent */
  8005.       case '!':                         /* Factorial */
  8006.       case '(':                         /* Parens for grouping */
  8007.       case ')': return(*cp++);          /* operator, just return it */
  8008.       case '\n':
  8009.       case '\0': return(N_EOT);         /* End of line, return that */
  8010.     }
  8011. #ifdef COMMENT
  8012. /* This is the original code, which allows only integer numbers. */
  8013.  
  8014.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  8015.         int radix = 10;                 /* Default radix */
  8016.         for (tp = tbuf; isxdigit(*cp); cp++)
  8017.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  8018.         *tp = '\0';                     /* End number */
  8019.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  8020.           case 'h':
  8021.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  8022.           case 'o':
  8023.           case 'q': radix = 8; cp++; break;
  8024.           case 't': radix = 2; cp++; break;
  8025.         }
  8026.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  8027.             int dig;
  8028.             dig = *tp - '0';            /* Convert number */
  8029.             if (dig > 10) dig -= 'a'-'0'-10;
  8030.             if (dig >= radix) {
  8031.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8032.                   printf("?Invalid digit '%c' in number\n",*tp);
  8033.                 xerror = 1;
  8034.                 return(NUMBER);
  8035.             }
  8036.             tokval = radix*tokval + dig;
  8037.         }
  8038.         return(NUMBER);
  8039.     }
  8040.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  8041.       printf("Invalid character '%c' in input\n",*cp);
  8042.     xerror = 1;
  8043.     cp++;
  8044.     return(gettok());
  8045. #else
  8046. /* This code allows non-numbers to be treated as macro names */
  8047.     {
  8048.         int i, x;
  8049.         char * s, * cp1;
  8050.         cp1 = cp;
  8051.         tp = tbuf;
  8052.         for (i = 0; i < 80; i++) {
  8053.             /* Look ahead to next break character */
  8054.             /* pretty much anything that is not in the switch() above. */
  8055.             if (isalpha(*cp) || isdigit(*cp) ||
  8056.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  8057.                 *cp == '[' || *cp == ']' ||
  8058.                 *cp == '{' || *cp == '}'
  8059.                 )
  8060.               tbuf[i] = *cp++;
  8061.             else
  8062.               break;
  8063.         }
  8064.         if (i >= 80) {
  8065.             printf("Too long - \"%s\"\n", cp1);
  8066.             xerror = 1;
  8067.             cp++;
  8068.             return(gettok());
  8069.         }
  8070.         if (xerror) return(NUMBER);
  8071.  
  8072.         tbuf[i] = NUL;
  8073.         s = tbuf;
  8074.         if (!isdigit(tbuf[0])) {
  8075.             char * s2 = NULL;
  8076.             x = mxlook(mactab,tbuf,nmac);
  8077.             debug(F111,"gettok mxlook",tbuf,x);
  8078.             if (x < 0) {
  8079.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8080.                   printf("Bad number - \"%s\"\n",tbuf);
  8081.                 xerror = 1;
  8082.                 cp++;
  8083.                 return(gettok());
  8084.             }
  8085.             s2 = mactab[x].mval;
  8086.             if (!s2) s2 = "";
  8087.             if (*s2) s = s2;
  8088.         }
  8089. #ifdef CKFLOAT
  8090.         x = isfloat(s,0);
  8091. #else
  8092.         x = chknum(s);
  8093. #endif /* CKFLOAT */
  8094.         if (x > 0) {
  8095.             tokval = atoi(s);
  8096.         } else {
  8097.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8098.               printf("Bad number - \"%s\"\n",tbuf);
  8099.             xerror = 1;
  8100.             cp++;
  8101.             return(gettok());
  8102.         }
  8103.         return(NUMBER);
  8104.     }
  8105. #endif /* COMMENT */
  8106. }
  8107.  
  8108. static long
  8109. #ifdef CK_ANSIC
  8110. expon(long x, long y)
  8111. #else
  8112. expon(x,y) long x,y;
  8113. #endif /* CK_ANSIC */
  8114. /* expon */ {
  8115.     long result = 1;
  8116.     int sign = 1;
  8117.     if (y < 0) return(0);
  8118.     if (x < 0) {
  8119.         x = -x;
  8120.         if (y & 1) sign = -1;
  8121.     }
  8122.     while (y != 0) {
  8123.         if (y & 1) result *= x;
  8124.         y >>= 1;
  8125.         if (y != 0) x *= x;
  8126.   }
  8127.   return(result * sign);
  8128. }
  8129.  
  8130. /*
  8131.  * factor ::= simple | simple ^ factor
  8132.  *
  8133.  */
  8134. static VOID
  8135. factor() {
  8136.     long oldval;
  8137.     simple();
  8138.     if (curtok == '^') {
  8139.         oldval = expval;
  8140.         curtok = gettok();
  8141.         factor();
  8142.         expval = expon(oldval,expval);
  8143.     }
  8144. }
  8145.  
  8146. /*
  8147.  * termp ::= NULL | {*,/,%,&} factor termp
  8148.  *
  8149.  */
  8150. static VOID
  8151. termp() {
  8152.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  8153.         long oldval;
  8154.         char op;
  8155.         op = curtok;
  8156.         curtok = gettok();              /* skip past operator */
  8157.         oldval = expval;
  8158.         factor();
  8159.         switch(op) {
  8160.           case '*': expval = oldval * expval; break;
  8161.           case '/':
  8162.           case '%':
  8163.             if (expval == 0) {
  8164.                 if (!x_ifnum)
  8165.                   printf("?Divide by zero\n");
  8166.                 xerror = 1;
  8167.                 divbyzero = 1;
  8168.                 expval = -1;
  8169.             } else
  8170.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  8171.             break;
  8172.           case '&':
  8173.             expval = oldval & expval; break;
  8174.         }
  8175.     }
  8176. }
  8177.  
  8178. static long
  8179. #ifdef CK_ANSIC
  8180. fact(long x)
  8181. #else
  8182. fact(x) long x;
  8183. #endif /* CK_ANSIC */
  8184. /* fact */ {                            /* factorial */
  8185.     long result = 1;
  8186.     while (x > 1)
  8187.       result *= x--;
  8188.     return(result);
  8189. }
  8190.  
  8191. /*
  8192.  * term ::= factor termp
  8193.  *
  8194.  */
  8195. static VOID
  8196. term() {
  8197.     factor();
  8198.     termp();
  8199. }
  8200.  
  8201. static long
  8202. #ifdef CK_ANSIC
  8203. gcd(long x, long y)
  8204. #else
  8205. gcd(x,y) long x,y;
  8206. #endif /* CK_ANSIC */
  8207. /* gcd */ {                             /* Greatest Common Divisor */
  8208.     int nshift = 0;
  8209.     if (x < 0) x = -x;
  8210.     if (y < 0) y = -y;                  /* validate arguments */
  8211.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8212.  
  8213.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8214.         nshift++;
  8215.         x >>= 1;
  8216.         y >>= 1;
  8217.     }
  8218.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8219.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8220.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8221.         if (x < y) {                    /* force x to be larger */
  8222.             long t;
  8223.             t = x;
  8224.             x = y;
  8225.             y = t;
  8226.         }
  8227.         x -= y;
  8228.     }
  8229.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8230.     else return((long) 1 << nshift);    /* else gcd is 1 */
  8231. }
  8232.  
  8233. /*
  8234.  * exprp ::= NULL | {+,-,|,...} term exprp
  8235.  *
  8236.  */
  8237. static VOID
  8238. exprp() {
  8239.     while (windex("+-|<>#@",curtok) != NULL) {
  8240.         long oldval;
  8241.         char op;
  8242.         op = curtok;
  8243.         curtok = gettok();              /* skip past operator */
  8244.         oldval = expval;
  8245.         term();
  8246.         switch(op) {
  8247.           case '+' : expval = oldval + expval; break;
  8248.           case '-' : expval = oldval - expval; break;
  8249.           case '|' : expval = oldval | expval; break;
  8250.           case '#' : expval = oldval ^ expval; break;
  8251.           case '@' : expval = gcd(oldval,expval); break;
  8252.           case '<' : expval = oldval << expval; break;
  8253.           case '>' : expval = oldval >> expval; break;
  8254.         }
  8255.     }
  8256. }
  8257.  
  8258. /*
  8259.  * expr ::= term exprp
  8260.  *
  8261.  */
  8262. static VOID
  8263. expr() {
  8264.     term();
  8265.     exprp();
  8266. }
  8267.  
  8268. static long
  8269. xparse() {
  8270.     curtok = gettok();
  8271.     expr();
  8272. #ifdef COMMENT
  8273.     if (curtok == '$') {
  8274.         curtok = gettok();
  8275.         if (curtok != NUMBER) {
  8276.             if (cmdlvl == 0 && !x_ifnum)
  8277.               printf("?Illegal radix\n");
  8278.             xerror = 1;
  8279.             return(0);
  8280.         }
  8281.         curtok = gettok();
  8282.     }
  8283. #endif /* COMMENT */
  8284.     if (curtok != N_EOT) {
  8285.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8286.           printf("?Extra characters after expression\n");
  8287.         xerror = 1;
  8288.     }
  8289.     return(expval);
  8290. }
  8291.  
  8292. char *                                  /* Silent front end for evala() */
  8293. evalx(s) char *s; {
  8294.     char * p;
  8295.     int t;
  8296.     t = x_ifnum;
  8297.     x_ifnum = 1;
  8298.     p = evala(s);
  8299.     x_ifnum = t;
  8300.     return(p);
  8301. }
  8302.  
  8303. char *
  8304. evala(s) char *s; {
  8305.     long v;                             /* Numeric value */
  8306.     if (!s) return("");
  8307.     xerror = 0;                         /* Start out with no error */
  8308.     divbyzero = 0;
  8309.     cp = s;                             /* Make the argument global */
  8310.     v = xparse();                       /* Parse the string */
  8311.     return(xerror ? "" : ckltoa(v));    /* Return empty string on error */
  8312. }
  8313.  
  8314. /*
  8315.  * simplest ::= NUMBER | ( expr )
  8316.  *
  8317.  */
  8318. static VOID
  8319. simplest() {
  8320.     char * p;
  8321.     p = cp;
  8322.     if (curtok == NUMBER)
  8323.       expval = tokval;
  8324.     else if (curtok == '(') {
  8325.         curtok = gettok();              /* skip over paren */
  8326.         expr();
  8327.         if (curtok != ')') {
  8328.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8329.               printf("?Missing right parenthesis\n");
  8330.             xerror = 1;
  8331.         }
  8332.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8333.  
  8334.     } else {
  8335.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8336.           printf("?Operator unexpected\n");
  8337.         xerror = 1;
  8338.     }
  8339.     curtok = gettok();
  8340. }
  8341.  
  8342. /*
  8343.  * simpler ::= simplest | simplest !
  8344.  *
  8345.  */
  8346. static VOID
  8347. simpler() {
  8348.     simplest();
  8349.     if (curtok == '!') {
  8350.         curtok = gettok();
  8351.         expval = fact(expval);
  8352.     }
  8353. }
  8354.  
  8355. /*
  8356.  * simple ::= {-,~,!} simpler | simpler
  8357.  *
  8358.  */
  8359.  
  8360. static VOID
  8361. simple() {
  8362.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8363.         int op = curtok;
  8364.         curtok = gettok();              /* skip over - sign */
  8365.         simpler();                      /* parse the factor again */
  8366.         if (op != '+')
  8367.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8368.     } else simpler();
  8369. }
  8370.  
  8371. /*  D C L A R R A Y  --  Declare an array  */
  8372. /*
  8373.   Call with:
  8374.    char a = single character designator for the array, e.g. "a".
  8375.    int  n = size of array.
  8376.   Returns:
  8377.    0 or greater on success, having created the requested array with
  8378.      with n+1 elements, 0..n.  If an array of the same name existed
  8379.      previously, it is destroyed.  The new array has all its elements
  8380.      initialized to NULL pointers.
  8381.   -1 on failure (because 'a' out of range or malloc failure).
  8382. */
  8383. int
  8384. #ifdef CK_ANSIC
  8385. dclarray(char a, int n)
  8386. #else
  8387. dclarray(a,n) char a; int n;
  8388. #endif /* CK_ANSIC */
  8389. /* dclarray */ {
  8390.     char c, **p; int i, n2, rc;
  8391.  
  8392.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8393.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8394.       return(-1);
  8395.     c = a;
  8396.     a -= ARRAYBASE;                     /* Convert name to number */
  8397.     rc = a;
  8398.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8399.         if (a_link[a] > -1) {           /* Is it a link? */
  8400.             if (n == 0) {               /* If we're just deleting it */
  8401.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8402.                 a_dim[a] = 0;
  8403.                 a_link[a] = -1;
  8404.                 return(0);
  8405.             }                           /* Not deleting */
  8406.             a = a_link[a];              /* Switch to linked-to array */
  8407.         }
  8408.         n2 = a_dim[a];                  /* Real array */
  8409.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8410.             if (p[i]) {
  8411.                 free(p[i]);
  8412.                 p[i] = NULL;
  8413.             }
  8414.         }
  8415.         free((char *)a_ptr[a]);         /* Then the element list */
  8416.         if (n == 0) {                   /* If undeclaring this array... */
  8417.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8418.                 if (i != a && a_link[i] == a) {     /* Find them */
  8419.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8420.                     a_dim[i] = 0;
  8421.                     a_link[i] = -1;
  8422.                 }
  8423.             }
  8424.         }
  8425.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8426.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8427.         a_link[a] = -1;                 /* Unset link word */
  8428.         if (n == 0)
  8429.           return(0);                    /* If dimension 0, just deallocate. */
  8430.     }
  8431.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8432.     if (p == NULL) return(-1);          /* Check */
  8433.     a_ptr[a] = p;                       /* Save pointer to member list */
  8434.     a_dim[a] = n;                       /* Save dimension */
  8435.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8436.       p[i] = NULL;
  8437.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8438.         if (i != a && a_link[i] == a) { /* Find and update them */
  8439.             a_ptr[i] = p;
  8440.             a_dim[i] = n;
  8441.         }
  8442.     }
  8443.     return(rc);
  8444. }
  8445.  
  8446. /*  X A R R A Y  -- Convert array name to array index  */
  8447.  
  8448. int
  8449. xarray(s) char * s; {
  8450.     char buf[8];
  8451.     int x;
  8452.     char c;
  8453.  
  8454.     if (!s) s = "";
  8455.     debug(F110,"xarray",s,0);
  8456.     if (!*s)
  8457.       return(-1);
  8458.     x = strlen(s);
  8459.  
  8460.     buf[0] = NUL;
  8461.     buf[1] = NUL;
  8462.     buf[2] = s[0];
  8463.     buf[3] = (x > 0) ? s[1] : NUL;
  8464.     buf[4] = (x > 1) ? s[2] : NUL;
  8465.     buf[5] = (x > 2) ? s[3] : NUL;
  8466.     buf[6] = NUL;
  8467.     s = buf+2;
  8468.     if (*s == '&') {
  8469.         buf[1] = CMDQ;
  8470.         s--;
  8471.     } else if (*s != CMDQ) {
  8472.         buf[0] = CMDQ;
  8473.         buf[1] = '&';
  8474.         s = buf;
  8475.     }
  8476.     c = *(s+2);
  8477.     if (isupper(c))
  8478.       c = tolower(c);
  8479.     if (c == '@')
  8480.       c = 96;
  8481.     x = (int)c - ARRAYBASE;
  8482.     if (*(s+3) == '[')
  8483.       *(s+3) = NUL;
  8484.     return((x < 0 || x > 'z' - ARRAYBASE || *(s+3)) ? -1 : x);
  8485. }
  8486.  
  8487. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8488.  
  8489. /*
  8490.   Call with s = array reference, plus two pointers to ints.
  8491.   Returns -1 on error, or array index, with the two ints set as follows:
  8492.    \&a[]     -1, -1
  8493.    \&a[3]     3, -1
  8494.    \&a[3:17]  3, 17
  8495.   The array need not be declared -- this routine is just for parsing.
  8496. */
  8497. int
  8498. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8499.     int i, x, y, range[2];
  8500.     char buf[256], * p, * q;
  8501.     char * tmp = NULL;
  8502.  
  8503.     *lo = -1;                           /* Default bounds */
  8504.     *hi = -1;
  8505.  
  8506.     if (!s) s = "";                     /* Defense de null args */
  8507.     if (!*s)
  8508.       return(-1);
  8509.  
  8510.     x = xarray(s);                      /* Check basic structure */
  8511.     debug(F111,"arraybounds xarray",s,x);
  8512.  
  8513.     if (x < 0)                          /* Not OK, fail. */
  8514.       return(-1);
  8515.     range[0] = -1;                      /* It's OK -- get contents */
  8516.     range[1] = -1;                      /* of subscript brackets */
  8517.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8518.     s = tmp;
  8519.     p = s;
  8520.     for (p = s, q = NULL; *p; p++) {    /* First find the brackets */
  8521.         if (*p == '[') {
  8522.             q = p+1;
  8523.         } else if (*p == ']')
  8524.           break;
  8525.     }
  8526.     if (q && *p == ']') {               /* If we have brackets... */
  8527.         int quitnow = 0;
  8528.         for (i = 0; i < 2 && !quitnow; i++) { /* Loop thru their contents */
  8529.             for (p = q; *p; p++) {
  8530.                 if ((i == 0 && *p == ':') || *p == ']') {
  8531.                     if (*p == ']')
  8532.                       quitnow = 1;
  8533.                     *p = NUL;
  8534.                     if (*q) {           /* We have something */
  8535.                         y = 255;        /* Expand variables, etc. */
  8536.                         s = buf;
  8537.                         zzstring(q,&s,&y);
  8538.                         s = evalx(buf); /* Evaluate it arithmetically */
  8539.                         if (s) if (*s)
  8540.                           ckstrncpy(buf,s,256);
  8541.                         if (!chknum(buf)) { /* Did we get a number? */
  8542.                             makestr(&tmp,NULL); /* No, fail. */
  8543.                             return(-1);
  8544.                         }
  8545.                         q = (i == 0) ? p+1 : NULL; /* Point to next if any */
  8546.                         range[i] = atoi(buf); /* Set this one */
  8547.                     }
  8548.                     break;
  8549.                 }
  8550.             }
  8551.         }
  8552.     }
  8553.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8554.     *lo = range[0];                     /* Return what we got */
  8555.     *hi = range[1];
  8556.     debug(F101,"arraybounds lo","",*lo);
  8557.     debug(F101,"arraybounds hi","",*hi);
  8558.     return(x);
  8559. }
  8560.  
  8561. /*  A R R A Y N A M  --  Parse an array name  */
  8562.  
  8563. /*
  8564.   Call with pointer to string that starts with the array reference.
  8565.   String may begin with either \& or just &.
  8566.   On success,
  8567.     Returns letter ID (always lowercase) in argument c,
  8568.       which can also be accent grave (` = 96; '@' is converted to grave);
  8569.     Dimension or subscript in argument n;
  8570.     IMPORTANT: These arguments must be provided by the caller as addresses
  8571.     of ints (not chars), for example:
  8572.       char *s; int x, y;
  8573.       arraynam(s,&x,&y);
  8574.   On failure, returns a negative number, with args n and c set to zero.
  8575. */
  8576. int
  8577. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8578.     int i, y, pp, len;
  8579.     char x;
  8580.     char *s, *p, *sx, *vnp;
  8581.     /* On stack to allow for recursive calls... */
  8582.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8583.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8584.     char sxbuf[16];                     /* Evaluated subscript */
  8585.  
  8586.     *c = *n = 0;                        /* Initialize return values */
  8587.     len = strlen(ss);
  8588.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8589.         if (ss[i] == '[') {
  8590.             pp++;
  8591.         } else if (ss[i] == ']') {
  8592.             if (--pp == 0)
  8593.               break;
  8594.         }
  8595.     }
  8596.     if (i > ARRAYREFLEN) {
  8597.         printf("?Array reference too long - %s\n",ss);
  8598.         return(-9);
  8599.     }
  8600.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8601.     vnp = vnbuf;
  8602.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8603.     if (*vnp != '&') {
  8604.         printf("?Not an array - %s\n",vnbuf);
  8605.         return(-9);
  8606.     }
  8607.     x = *(vnp + 1);                     /* Fold case of array name */
  8608.  
  8609.     /* We don't use isupper & tolower here on purpose because these */
  8610.     /* would produce undesired effects with accented letters. */
  8611.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8612.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8613.         if (msgflg) {
  8614.             printf("?Invalid format for array name - %s\n",vnbuf);
  8615.             return(-9);
  8616.         } else
  8617.           return(-2);
  8618.     }
  8619.     *c = x;                             /* Return the array name */
  8620.     s = vnp+3;                          /* Get dimension */
  8621.     p = ssbuf;
  8622.     pp = 1;                             /* Bracket counter */
  8623.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8624.         if (*s == '[') pp++;
  8625.         if (*s == ']' && --pp == 0) break;
  8626.         *p++ = *s++;
  8627.     }
  8628.     if (*s != ']') {
  8629.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8630.         return(-9);
  8631.     }
  8632.     p--;                                /* Trim whitespace from end */
  8633.     while (*p == SP || *p == HT)
  8634.       p--;
  8635.     p++;
  8636.     *p = NUL;                           /* Terminate subscript with null */
  8637.     p = ssbuf;                          /* Point to beginning of subscript */
  8638.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8639.       p++;
  8640.     sx = sxbuf;                         /* Where to put expanded subscript */
  8641.     y = 16;
  8642.     zzstring(p,&sx,&y);                 /* Convert variables, etc. */
  8643.     sx = sxbuf;
  8644.     while (*sx == SP) sx++;
  8645.     debug(F110,"arraynam sx","",sx);
  8646.     if (!*sx) {                         /* Empty brackets... */
  8647.         *n = -17;                       /* (Secret code :-) */
  8648.         return(-2);
  8649.     }
  8650.     p = evala(sx);                      /* Run it thru \fneval()... */
  8651.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8652.  
  8653.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8654.         if (msgflg) {
  8655.             printf("?Array dimension or subscript missing or not numeric\n");
  8656.             return(-9);
  8657.         } else
  8658.           return(-2);
  8659.     }
  8660.     if ((y = atoi(sxbuf)) < 0) {
  8661.         if (cmflgs == 0) printf("\n");
  8662.         if (msgflg) {
  8663.             printf("?Array dimension or subscript not positive or zero\n");
  8664.             return(-9);
  8665.         } else
  8666.           return(-2);
  8667.     }
  8668.     *n = y;                             /* Return the subscript or dimension */
  8669.     return(0);
  8670. }
  8671.  
  8672. int
  8673. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8674.     int x;                              /* and if subscript is in range */
  8675.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8676.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8677. #ifdef COMMENT
  8678.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8679.       return(0);
  8680. #endif /* COMMENT */
  8681.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8682.       return(-2);
  8683.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8684.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8685.     return(a_dim[x]);                   /* All ok, return dimension */
  8686. }
  8687.  
  8688. #ifdef COMMENT                          /* This isn't used. */
  8689. char *
  8690. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8691.     int x; char **p;                    /* (possibly NULL) */
  8692.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8693.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8694.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8695.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8696.       return(NULL);
  8697.     if (i > a_dim[x])                   /* Subscript out of range. */
  8698.       return(NULL);
  8699.     return(p[i]);                       /* All ok, return pointer to value. */
  8700. }
  8701. #endif /* COMMENT */
  8702.  
  8703. /*
  8704.   pusharray() is called when an array name is included in a LOCAL statement.
  8705.   It moves the pointers from the global definition to the stack, and removes
  8706.   the global definition.  Later, if the same array is declared in the local
  8707.   context, it occupies the global definition in the normal way.  But when
  8708.   popclvl() is called, it replaces the global definition with the one saved
  8709.   here.  The "secret code" is used to indicate to popclv() that it should
  8710.   remove the global array when popping through this level -- otherwise if a
  8711.   local array were declared that had no counterpart at any higher level, it
  8712.   would never be deleted.  This allows Algol-like inheritance to work both
  8713.   on the way down and on the way back up.
  8714. */
  8715. int
  8716. pusharray(x,z) int x, z; {
  8717.     int y;
  8718.     debug(F000,"pusharray x","",x);
  8719.     debug(F101,"pusharray z","",z);
  8720.     y = chkarray(x,z);
  8721.     debug(F101,"pusharray y","",y);
  8722.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8723.     if (x < 0 || x > 27)
  8724.       return(-1);
  8725.     if (y < 0) {
  8726.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8727.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8728.     } else {
  8729.         aa_ptr[cmdlvl][x] = a_ptr[x];
  8730.         aa_dim[cmdlvl][x] = y;
  8731.     }
  8732.     a_ptr[x] = (char **) NULL;
  8733.     a_dim[x] = 0;
  8734.     return(0);
  8735. }
  8736.  
  8737. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  8738. /*
  8739.  Call with:
  8740.    s  = pointer to candidate variable name or array reference.
  8741.    *c = address of integer in which to return variable ID.
  8742.    *i = address of integer in which to return array subscript.
  8743.  Returns:
  8744.    -2:  syntax error in variable name or array reference.
  8745.     1:  successful parse of a simple variable, with ID in c.
  8746.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  8747. */
  8748. int
  8749. parsevar(s,c,i) char *s; int *c, *i; {
  8750.     char *p;
  8751.     int x,y,z;
  8752.  
  8753.     p = s;
  8754.     if (*s == CMDQ) s++;                /* Point after backslash */
  8755.  
  8756.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  8757.         printf("?Not a variable name - %s\n",p);
  8758.         return(-9);
  8759.     }
  8760.     if ((int)strlen(s) < 2) {
  8761.         printf("?Incomplete variable name - %s\n",p);
  8762.         return(-9);
  8763.     }
  8764.     if (*s == '%' && *(s+2) != '\0') {
  8765.         printf("?Only one character after '%%' in variable name, please\n");
  8766.         return(-9);
  8767.     }
  8768.     if (*s == '&' && *(s+2) != '[') {
  8769.         printf("?Array subscript expected - %s\n",p);
  8770.         return(-9);
  8771.     }
  8772.     if (*s == '%') {                    /* Simple variable. */
  8773.         y = *(s+1);                     /* Get variable ID letter/char */
  8774.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  8775.         *c = y;                         /* Set the return values. */
  8776.         *i = -1;                        /* No array subscript. */
  8777.         return(1);                      /* Return 1 = simple variable */
  8778.     }
  8779.     if (*s == '&') {                    /* Array reference. */
  8780.         y = arraynam(s,&x,&z);          /* Go parse it. */
  8781.         debug(F101,"parsevar arraynam","",y);
  8782.         if ((y) < 0) {
  8783.             if (y == -2)
  8784.               return(pusharray(x,z));
  8785.             if (y != -9)
  8786.               printf("?Invalid array reference - %s\n",p);
  8787.             return(-9);
  8788.         }
  8789.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  8790.             printf("?Array not declared or subscript out of range\n");
  8791.             return(-9);
  8792.         }
  8793.         *c = x;                         /* Return array letter */
  8794.         *i = z;                         /* and subscript. */
  8795.         return(2);
  8796.     }
  8797.     return(-2);                         /* None of the above. */
  8798. }
  8799.  
  8800.  
  8801. #define VALN 32
  8802.  
  8803. /* Get the numeric value of a variable */
  8804. /*
  8805.   Call with pointer to variable name, pointer to int for return value.
  8806.   Returns:
  8807.     0 on success with second arg containing the value.
  8808.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  8809. */
  8810. int
  8811. varval(s,v) char *s; int *v; {
  8812.     char valbuf[VALN+1];                /* s is pointer to variable name */
  8813.     char name[256];
  8814.     char *p;
  8815.     int y;
  8816.  
  8817.     if (*s != CMDQ) {                   /* Handle macro names too */
  8818.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  8819.         s = name;
  8820.     }
  8821.     p = valbuf;                         /* Expand variable into valbuf. */
  8822.     y = VALN;
  8823.     if (zzstring(s,&p,&y) < 0) return(-1);
  8824.     p = valbuf;                         /* Make sure value is numeric  */
  8825.     if (!*p) {                          /* Be nice -- let an undefined */
  8826.         valbuf[0] = '0';                /* variable be treated as 0.   */
  8827.         valbuf[1] = NUL;
  8828.     }
  8829.     if (chknum(p)) {                    /* Convert numeric string to int */
  8830.         *v = atoi(p);                   /* OK */
  8831.     } else {                            /* Not OK */
  8832.         p = evala(p);                   /* Maybe it's an expression */
  8833.         if (!chknum(p))                 /* Did it evaluate? */
  8834.           return(-1);                   /* No, failure. */
  8835.         else                            /* Yes, */
  8836.           *v = atoi(p);                 /* success */
  8837.     }
  8838.     return(0);
  8839. }
  8840.  
  8841. /* Increment or decrement a variable */
  8842. /* Returns -1 on failure, 0 on success */
  8843.  
  8844. int
  8845. incvar(s,x,z) char *s; int x; int z; {  /* Increment a numeric variable */
  8846.     int n;                              /* s is pointer to variable name */
  8847.                                         /* x is amount to increment by */
  8848.                                         /* z != 0 means add */
  8849.                                         /* z = 0 means subtract */
  8850.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  8851.       return(-1);
  8852.     if (z)                              /* Increment it by the given amount */
  8853.       n += x;
  8854.     else                                /* or decrement as requested. */
  8855.       n -= x;
  8856.     addmac(s,ckitoa(n));                /* Replace old variable */
  8857.     return(0);
  8858. }
  8859.  
  8860. /* D O D O  --  Do a macro */
  8861.  
  8862. /*
  8863.   Call with x = macro table index, s = pointer to arguments.
  8864.   Returns 0 on failure, 1 on success.
  8865. */
  8866.  
  8867. int
  8868. dodo(x,s,flags) int x; char *s; int flags; {
  8869.     int y;
  8870.     extern int tra_asg, tra_cmd; int tra_tmp;
  8871. #ifndef NOLOCAL
  8872. #ifdef OS2
  8873.     extern int term_io;
  8874.     int term_io_sav = term_io;
  8875. #endif /* OS2 */
  8876. #endif /* NOLOCAL */
  8877.  
  8878.     if (x < 0)                          /* It can happen! */
  8879.       return(-1);
  8880.  
  8881.     tra_tmp = tra_asg;
  8882.  
  8883.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  8884.         debug(F101,"dodo maclvl too deep","",maclvl);
  8885.         --maclvl;
  8886.         printf("Macros nested too deeply\n");
  8887.         return(0);
  8888.     }
  8889.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  8890.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  8891.  
  8892. #ifdef COMMENT
  8893.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  8894. #endif /* COMMENT */
  8895.  
  8896.     cmdlvl++;                           /* Entering a new command level */
  8897.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  8898.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  8899.         cmdlvl--;
  8900.         printf("?TAKE files and DO commands nested too deeply\n");
  8901.         return(0);
  8902.     }
  8903. #ifdef DEBUG
  8904.     if (deblog) {
  8905.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  8906.         debug(F010,"CMD ->",s,0);
  8907.     }
  8908. #endif /* DEBUG */
  8909.  
  8910. #ifdef VMS
  8911.     conres();                           /* So Ctrl-C, etc, will work. */
  8912. #endif /* VMS */
  8913. #ifndef NOLOCAL
  8914. #ifdef OS2
  8915.     term_io = 0;                        /* Disable terminal emulator I/O */
  8916. #endif /* OS2 */
  8917. #endif /* NOLOCAL */
  8918.     ifcmd[cmdlvl] = 0;
  8919.     iftest[cmdlvl] = 0;
  8920.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  8921.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  8922.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  8923.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  8924.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  8925.     xquiet[cmdlvl] = quiet;
  8926.     xcmdsrc = CMD_MD;
  8927.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  8928.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  8929.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  8930.  
  8931.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  8932.  
  8933.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  8934.         free(mrval[maclvl]);
  8935.         mrval[maclvl] = NULL;
  8936.     }
  8937.  
  8938.     /* Clear old %0..%9 arguments */
  8939.  
  8940.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  8941.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  8942.     varnam[0] = '%';
  8943.     varnam[2] = '\0';
  8944.     tra_asg = 0;
  8945.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  8946.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  8947.             varnam[1] = (char) (y + '0'); /* we have to... */
  8948.             delmac(varnam,0);
  8949.         }
  8950.     }
  8951.     tra_asg = tra_tmp;
  8952.  
  8953. /* Assign the new args one word per arg, allowing braces to group words */
  8954.  
  8955.     xwords(s,MAXARGLIST,NULL,0);
  8956.  
  8957. #ifndef NOLOCAL
  8958. #ifdef OS2
  8959.     term_io = term_io_sav;
  8960. #endif /* OS2 */
  8961. #endif /* NOLOCAL */
  8962.     if (tra_cmd)
  8963.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  8964.     return(1);
  8965. }
  8966.  
  8967. /* Insert "literal" quote around each comma-separated command to prevent */
  8968. /* its premature expansion.  Only do this if object command is surrounded */
  8969. /* by braces. */
  8970.  
  8971. static char* flit = "\\flit(";
  8972.  
  8973. int
  8974. litcmd(src,dest,n) char **src, **dest; int n; {
  8975.     int bc = 0, pp = 0;
  8976.     char c, *s, *lp, *ss;
  8977.  
  8978.     s = *src;
  8979.     lp = *dest;
  8980.  
  8981.     debug(F010,"litcmd",s,0);
  8982.  
  8983.     while (*s == SP) s++;               /* Strip extra leading spaces */
  8984.  
  8985.     if (*s == '{') {                    /* Starts with brace */
  8986.         pp = 0;                         /* Paren counter */
  8987.         bc = 1;                         /* Count leading brace */
  8988.         *lp++ = *s++;                   /* Copy it */
  8989.         if (--n < 1) return(-1);        /* Check space */
  8990.         while (*s == SP) s++;           /* Strip interior leading spaces */
  8991.         ss = flit;                      /* Point to "\flit(" */
  8992.         while ((*lp++ = *ss++))         /* Copy it */
  8993.           if (--n < 1)                  /* and check space */
  8994.             return(-1);
  8995.         lp--;                           /* Back up over null */
  8996.  
  8997.         while (*s) {                    /* Go thru rest of text */
  8998.             c = *s;
  8999.             if (c == '{') bc++;         /* Count brackets */
  9000.             if (c == '(') pp++;         /* and parens */
  9001.             if (c == ')') {             /* Right parenthesis. */
  9002.                 pp--;                   /* Count it. */
  9003.                 if (pp < 0) {           /* An unbalanced right paren... */
  9004. #ifdef COMMENT
  9005. /*
  9006.   The problem here is that "\{" appears to be a quoted brace and therefore
  9007.   isn't counted; then the "}" matches an earlier opening brace, causing
  9008.   (e.g.) truncation of macros by getncm().
  9009. */
  9010.                     if (n < 5)          /* Out of space in dest buffer? */
  9011.                       return(-1);       /* If so, give up. */
  9012.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9013.                     *lp++ = '}';        /* premature termination of */
  9014.                     *lp++ = '4';        /* \flit(...) */
  9015.                     *lp++ = '1';
  9016.                     *lp++ = '}';
  9017.                     n -= 5;
  9018. #else
  9019. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  9020.                     if (n < 4)          /* Out of space in dest buffer? */
  9021.                       return(-1);       /* If so, give up. */
  9022.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9023.                     *lp++ = '0';        /* premature termination of */
  9024.                     *lp++ = '4';        /* \flit(...) */
  9025.                     *lp++ = '1';
  9026.                     n -= 4;
  9027. #endif /* COMMENT */
  9028.                     pp++;               /* Uncount it. */
  9029.                     s++;
  9030.                     continue;
  9031.                 }
  9032.             }
  9033.             if (c == '}') {             /* Closing brace. */
  9034.                 if (--bc == 0) {        /* Final one? */
  9035.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  9036.                     if (--n < 1) return(-1);
  9037.                     *lp++ = c;
  9038.                     if (--n < 1) return(-1);
  9039.                     s++;
  9040.                     break;
  9041.                 }
  9042.             }
  9043.             *lp++ = c;                  /* General case */
  9044.             if (--n < 1) return(-1);
  9045.             s++;
  9046.         }
  9047.         *lp = NUL;
  9048.     } else {                            /* No brackets around, */
  9049.         while ((*lp++ = *s++))          /* just copy. */
  9050.           if (--n < 1)
  9051.             return(-1);
  9052.         lp--;
  9053.     }
  9054.     *src = s;                           /* Return updated source */
  9055.     *dest = lp;                         /* and destination pointers */
  9056.     if (bc)                             /* Fail if braces unbalanced */
  9057.       return(-1);
  9058.     else                                /* Otherwise succeed. */
  9059.       return(0);
  9060. }
  9061. #endif /* NOSPL */
  9062.  
  9063. /* Functions moved here from ckuusr.c to even out the module sizes... */
  9064.  
  9065. /*
  9066.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  9067.   Pointers to each word go into the array list[].
  9068.   max is the maximum number of words (pointers).
  9069.   If list is NULL, then they are added to the macro table.
  9070.   flag = 0 means the last field is to be one word, like all the other fields,
  9071.          so anything after it is discarded.
  9072.   flag = 1 means the last field extends to the end of the string, even if
  9073.          there are lots of words left, so the last field contains the
  9074.          remainder of the string.
  9075. */
  9076. VOID
  9077. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  9078.     char *p;
  9079.     int b, i, k, q, y, z;
  9080. #ifndef NOSPL
  9081.     int macro;
  9082.     macro = (list == NULL);
  9083.     debug(F010,"xwords",s,0);
  9084. #endif /* NOSPL */
  9085.  
  9086. #ifdef XWORDSDEBUG
  9087.     printf("XWORDS string=%s\n",s);
  9088.     printf("XWORDS max=%d\n",max);
  9089. #endif /* XWORDSDEBUG */
  9090.     p = s;                              /* Pointer to beginning of string */
  9091.     q = 0;                              /* Flag for doublequote removal */
  9092.     b = 0;                              /* Flag for outer brace removal */
  9093.     k = 0;                              /* Flag for in-word */
  9094.     y = 0;                              /* Brace nesting level */
  9095.     z = 0;                              /* "Word" counter, 0 thru max */
  9096.  
  9097.     if (list)
  9098.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  9099.         list[i] = NULL;
  9100.  
  9101.     if (flag) max--;
  9102.  
  9103.     while (1) {                         /* Go thru word list */
  9104.         if (!s || (*s == '\0')) {       /* No more characters? */
  9105.             if (k != 0) {               /* Was I in a word? */
  9106.                 if (z == max) break;    /* Yes, only go up to max. */
  9107.                 z++;                    /* Count this word. */
  9108. #ifdef XWORDSDEBUG
  9109.                 printf("1 z++ = %d\n", z);
  9110. #endif /* XWORDSDEBUG */
  9111. #ifndef NOSPL
  9112.                 if (macro) {            /* Doing macro args */
  9113.                     if (z < 10) {
  9114.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  9115.                         addmac(varnam,p);
  9116.                     }
  9117.                     if (z <= max) {
  9118. #ifdef COMMENT
  9119.                         if (maclvl < 0)
  9120.                           addmac(varnam,p);
  9121.                         else
  9122. #endif /* COMMENT */
  9123.                           makestr(&(m_xarg[maclvl][z]),p);
  9124.                     }
  9125.                 } else {                /* Not doing macro args */
  9126. #endif /* NOSPL */
  9127.                     list[z] = p;        /* Assign pointer. */
  9128. #ifdef XWORDSDEBUG
  9129.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  9130. #endif /* XWORDSDEBUG */
  9131. #ifndef NOSPL
  9132.                 }
  9133. #endif /* NOSPL */
  9134.                 break;                  /* And get out. */
  9135.             } else break;               /* Was not in a word */
  9136.         }
  9137.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  9138.             s++;
  9139.             continue;
  9140.         } else if (q == 0 && *s == '{') { /* An opening brace */
  9141.             if (k == 0 && y == 0) {     /* If leading brace */
  9142.                 p = s+1;                /* point past it */
  9143.                 b = 1;                  /* and flag that we did this */
  9144.             }
  9145.             k = 1;                      /* Flag that we're in a word */
  9146.             y++;                        /* Count the brace. */
  9147.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  9148.             y--;                        /* Count it. */
  9149.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  9150.                 char c;
  9151.                 c = *(s+1);
  9152.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9153.                     *s = SP;            /* change it to a space */
  9154.                     b = 0;              /* and we're not in braces any more */
  9155.                 }
  9156.             }
  9157. #ifdef DOUBLEQUOTING
  9158.         /* Opening doublequote */
  9159.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9160.             y++;
  9161.             p = s+1;                    /* point past it */
  9162.             q = 1;                      /* and flag that we did this */
  9163.             k = 1;                      /* Flag that we're in a word */
  9164.         /* Closing double quote */
  9165.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9166.             char c;
  9167.             c = *(s+1);
  9168.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9169.                 y--;
  9170.                 *s = SP;                /* change it to a space */
  9171.                 q = 0;                  /* and we're not in quotes any more */
  9172.             }
  9173. #endif /* DOUBLEQUOTING */
  9174.  
  9175.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9176.             if (k == 0) {               /* If we weren't in a word before, */
  9177.                 p = s;                  /* Mark the beginning */
  9178.                 if (flag && z == max) { /* Want last word to be remainder? */
  9179.                     z++;
  9180. #ifdef XWORDSDEBUG
  9181.                     printf("1 z++ = %d\n", z);
  9182. #endif /* XWORDSDEBUG */
  9183.                     list[z] = p;        /* Yes, point to it */
  9184. #ifdef XWORDSDEBUG
  9185.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9186. #endif /* XWORDSDEBUG */
  9187.                     break;              /* and quit */
  9188.                 }
  9189.                 k = 1;                  /* Set in-word flag */
  9190.             }
  9191.         }
  9192.         /* If we're not inside a braced quantity, and we are in a word, and */
  9193.         /* we have hit whitespace, then we have a word. */
  9194.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9195.             if (!flag || z < max)       /* if we don't want to keep rest */
  9196.               *s = '\0';                /* terminate the arg with null */
  9197.             k = 0;                      /* say we're not in a word any more */
  9198.             y = 0;                      /* start braces off clean again */
  9199.             if (z == max) break;        /* Only go up to max. */
  9200.             z++;                        /* count this arg */
  9201. #ifdef XWORDSDEBUG
  9202.             printf("1 z++ = %d\n", z);
  9203. #endif /* XWORDSDEBUG */
  9204.  
  9205. #ifndef NOSPL
  9206.             if (macro) {
  9207.                 if (z < 10) {
  9208.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9209.                     addmac(varnam,p);   /* add it to the macro table */
  9210.                 }
  9211.                 if (z <= max) {
  9212. #ifdef COMMENT
  9213.                     if (maclvl < 0)
  9214.                       addmac(varnam,p);
  9215.                     else
  9216. #endif /* COMMENT */
  9217.                       makestr(&(m_xarg[maclvl][z]),p);
  9218.                 }
  9219.             } else {
  9220. #endif /* NOSPL */
  9221.                 list[z] = p;
  9222. #ifdef XWORDSDEBUG
  9223.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9224. #endif /* XWORDSDEBUG */
  9225. #ifndef NOSPL
  9226.             }
  9227. #endif /* NOSPL */
  9228.             p = s+1;
  9229.         }
  9230.         s++;                            /* Point past this character */
  9231.     }
  9232.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9233.         z++;
  9234. #ifndef NOSPL
  9235.         if (macro) {
  9236.             if (z < 10) {
  9237.                 varnam[1] = z + '0';    /* compute its name */
  9238.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9239.             }
  9240.             if (z <= max) {
  9241. #ifdef COMMENT
  9242.                 if (maclvl < 0)
  9243.                   addmac(varnam,p);
  9244.                 else
  9245. #endif /* COMMENT */
  9246.                   makestr(&(m_xarg[maclvl][z]),p);
  9247.             }
  9248.         } else {
  9249. #endif /* NOSPL */
  9250.             list[z] = p;
  9251. #ifdef XWORDSDEBUG
  9252.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9253. #endif /* XWORDSDEBUG */
  9254. #ifndef NOSPL
  9255.         }
  9256. #endif /* NOSPL */
  9257.     }
  9258. #ifndef NOSPL
  9259.     if (macro) {                        /* Macro */
  9260.         if (maclvl < 0) {
  9261.             a_dim[0] = z;               /* Array dimension is one less */
  9262.             topargc = z + 1;            /* than \v(argc) */
  9263.         debug(F111,"a_dim[0]","D",a_dim[0]);
  9264.         } else {
  9265.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9266.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9267.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9268.             a_dim[0] = z;               /* And give it this dimension */
  9269.         debug(F111,"a_dim[0]","E",a_dim[0]);
  9270.         }
  9271.     }
  9272. #endif /* NOSPL */
  9273.     return;
  9274. }
  9275.  
  9276. #ifndef NOSPL
  9277.  
  9278. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9279.  
  9280. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9281.  
  9282. int
  9283. doshift(n) int n; {                     /* n = shift count */
  9284.     int i, top, level;
  9285.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9286.     char * sx = tmpbuf;
  9287.     int nx = TMPBUFSIZ;
  9288.  
  9289.     debug(F101,"SHIFT count","",n);
  9290.     debug(F101,"SHIFT topargc","",topargc);
  9291.  
  9292.     if (n < 1)                          /* Stay in range */
  9293.       return(n == 0 ? 1 : 0);
  9294.  
  9295.     level = maclvl;
  9296.     top = (level < 0) ? topargc : macargc[level];
  9297.  
  9298.     if (n >= top)
  9299.       n = top - 1;
  9300.  
  9301. #ifdef DEBUG
  9302.     if (deblog) {
  9303.         debug(F101,"SHIFT count 2","",n);
  9304.         debug(F101,"SHIFT level","",level);
  9305.         if (level > -1)
  9306.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9307.     }
  9308. #endif /* DEBUG */
  9309.  
  9310.     buf[0] = '\\';                      /* Initialize name template */
  9311.     buf[1] = '%';
  9312.     buf[2] = NUL;
  9313.     buf[3] = NUL;
  9314.  
  9315.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9316.         if (level < 0) {
  9317.             makestr(&(toparg[i]),NULL);
  9318.         } else {
  9319.             makestr(&(m_xarg[level][i]),NULL);
  9320.         }
  9321.         if (i < 10) {                   /* Is this necessary? */
  9322.             buf[2] = (char)(i+'0');
  9323.             delmac(buf,0);
  9324.         }
  9325.     }
  9326.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9327.         if (level < 0) {
  9328. #ifdef COMMENT
  9329.             toparg[i] = toparg[i+n];    /* Full vector */
  9330. #else
  9331.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9332. #endif /* COMMENT */
  9333.             if (i < 10)                 /* Scalars... */
  9334.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9335.         } else {
  9336. #ifdef COMMENT
  9337.             m_xarg[level][i] = m_xarg[level][i+n];
  9338. #else
  9339.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9340. #endif /* COMMENT */
  9341.             if (i < 10) {
  9342.                 buf[2] = (char)(i+'0');
  9343.                 debug(F010,"SHIFT buf",buf,0);
  9344.                 addmac(buf,m_xarg[level][i+n]);
  9345.             }
  9346.         }
  9347.     }
  9348.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9349.         if (level < 0) {
  9350. #ifdef COMMENT
  9351.             toparg[i] = NULL;
  9352. #else
  9353.             makestr(&(toparg[i]),NULL);
  9354. #endif /* COMMENt */
  9355.             if (i < 10)
  9356.               makestr(&(g_var[i+'0']),NULL);
  9357.         } else {
  9358. #ifdef COMMENT
  9359.             m_xarg[level][i] = NULL;
  9360. #else
  9361.             makestr(&(m_xarg[level][i]),NULL);
  9362. #endif /* COMMENt */
  9363.             if (i < 10) {
  9364.                 buf[2] = (char)(i+'0');
  9365.                 delmac(buf,0);
  9366.             }
  9367.         }
  9368.     }
  9369.     if (level > -1) {                   /* Macro args */
  9370.         macargc[level] -= n;            /* Adjust count */
  9371.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9372.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9373.     debug(F111,"a_dim[0]","F",a_dim[0]);
  9374.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9375. #ifdef COMMENT
  9376.         makestr(&(m_line[level]),tmpbuf);
  9377. #endif /* COMMENT */
  9378.     } else {                            /* Ditto for top level */
  9379.         topargc -= n;
  9380.         a_dim[0] = topargc - 1;
  9381.     debug(F111,"a_dim[0]","G",a_dim[0]);
  9382.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9383. #ifdef COMMENT
  9384.         makestr(&topline,tmpbuf);
  9385. #endif /* COMMENT */
  9386.     }
  9387.     return(1);
  9388. }
  9389. #endif /* NOSPL */
  9390.  
  9391. int
  9392. docd(cx) int cx; {                      /* Do the CD command */
  9393.     int x;
  9394.     extern int server, srvcdmsg, cdactive;
  9395.     extern char * cdmsgfile[], * ckcdpath;
  9396.     char *s, *p;
  9397. #ifdef MAC
  9398.     char temp[34];
  9399. #endif /* MAC */
  9400. #ifdef IKSDCONF
  9401. extern int iksdcf;
  9402. #endif /* IKSDCONF */
  9403.  
  9404. #ifndef NOFRILLS
  9405.     if (cx == XXBACK) {
  9406.         if ((x = cmcfm()) < 0)
  9407.         cwdf = 1;
  9408.         if (prevdir) {
  9409.             s = zgtdir();
  9410.             if (!zchdir(prevdir)) {
  9411.                 cwdf = 0;
  9412.                 perror(s);
  9413.             } else {
  9414.                 makestr(&prevdir,s);
  9415.             }
  9416.         }
  9417.         return(cwdf);
  9418.     }
  9419. #endif /* NOFRILLS */
  9420.  
  9421.     if (cx == XXCDUP) {
  9422. #ifdef VMS
  9423.         s = "[-]";
  9424. #else
  9425. #ifdef datageneral
  9426.         s = "^";
  9427. #else
  9428.         s = "..";
  9429. #endif /* datageneral */
  9430. #endif /* VMS */
  9431.         ckstrncpy(line,s,LINBUFSIZ);
  9432.         goto gocd;
  9433.     }
  9434. #ifndef NOSPL
  9435.     if (cx == XXKCD) {            /* Symbolic (Kermit) CD */
  9436.     char * p;
  9437.     int n, k;
  9438.     x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9439.     if (x < 0)
  9440.       return(x);
  9441.     x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9442.     if (x < 0) {
  9443.         printf("?Lookup error\n");    /* shouldn't happen */
  9444.         return(-9);
  9445.     }
  9446.         if ((x = cmcfm()) < 0)
  9447.       return(x);
  9448.     if (k == VN_HOME) {        /* HOME: allow SET HOME to override */
  9449.         ckstrncpy(line,homepath(),LINBUFSIZ);
  9450.     } else {            /* Other symbolic name */
  9451.         /* Convert to variable syntax */
  9452.         ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9453.         p = line;            /* Expand the variable */
  9454.         n = LINBUFSIZ;
  9455.         zzstring(tmpbuf,&p,&n);
  9456.         if (!line[0]) {        /* Fail if variable not defined */
  9457.         printf("?%s - not defined\n",tmpbuf);
  9458.         return(success = 0);
  9459.         }
  9460.     }
  9461.     s = line;            /* All OK, go try to CD... */
  9462.     goto gocd;
  9463.     }
  9464. #endif /* NOSPL */
  9465.  
  9466.     cdactive = 1;
  9467. #ifdef GEMDOS
  9468.     if ((x = cmdir("Name of local directory, or carriage return",
  9469.                    homepath(),
  9470.                    &s,
  9471.                    NULL
  9472.                    )
  9473.          ) < 0 )
  9474.       return(x);
  9475. #else
  9476. #ifdef OS2
  9477.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9478.        or press the Enter key for the default",
  9479.                     homepath(),
  9480.                     &s,
  9481.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9482.                     xxstring
  9483.                     )
  9484.          ) < 0 )
  9485.       return(x);
  9486. #else
  9487. #ifdef MAC
  9488.     x = ckstrncpy(temp,homepath(),32);
  9489.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9490.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9491.  or press the Return key for the desktop on the boot disk",
  9492.                    temp,&s, xxstring)) < 0 )
  9493.       return(x);
  9494. #else
  9495.     if ((x = cmdirp("Carriage return for home directory,\n\
  9496. or name of directory on this computer",
  9497. #ifdef VMS
  9498.                     "SYS$LOGIN",        /* With no colon */
  9499. #else
  9500.                     homepath(),        /* In VMS this is "SYS$LOGIN:" */
  9501. #endif /* VMS */
  9502.                     &s,
  9503.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9504.                     xxstring
  9505.                     )) < 0)
  9506.       return(x);
  9507. #endif /* MAC */
  9508. #endif /* OS2 */
  9509. #endif /* GEMDOS */
  9510.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9511.     s = line;
  9512. #ifdef VMS
  9513.     if (ckmatch("*.DIR;1$",s,0,0))
  9514.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9515.         s = tmpbuf;
  9516. #endif /* VMS */
  9517.     debug(F110,"docd",s,0);
  9518. #ifndef MAC
  9519.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9520.       return(x);
  9521. #endif /* MAC */
  9522.  
  9523.   gocd:
  9524.  
  9525. #ifdef datageneral
  9526.     x = strlen(line);                   /* homdir ends in colon, */
  9527.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9528.       line[x-1] = NUL;
  9529. #endif /* datageneral */
  9530.  
  9531. #ifdef MAC
  9532.     cwdf = 1;
  9533.     if (!zchdir(s)) {
  9534.         cwdf = 0;
  9535.         if (*s != ':') {                /* If it failed, */
  9536.             char *p;                    /* supply leading colon */
  9537.             int len = (int)strlen(s) + 2;
  9538.             p = malloc(len);            /* and try again... */
  9539.             if (p) {
  9540.                 strcpy(p,":");          /* safe */
  9541.                 strcat(p,s);            /* safe */
  9542.                 if (zchdir(p))
  9543.                   cwdf = 1;
  9544.                 free(p);
  9545.                 p = NULL;
  9546.             }
  9547.         }
  9548.     }
  9549.     if (!cwdf)
  9550.       perror(s);
  9551. #else
  9552.     p = zgtdir();
  9553.     if (!zchdir(s)) {
  9554.         cwdf = 0;
  9555. #ifdef CKROOT
  9556.         if (ckrooterr)
  9557.           printf("?Off limits: \"%s\"\n",s);
  9558.         else
  9559. #endif /* CKROOT */
  9560.           perror(s);
  9561.     } else cwdf = 1;
  9562. #endif /* MAC */
  9563.  
  9564.     x = 0;
  9565.     if (cwdf) {
  9566.         makestr(&prevdir,p);
  9567.         debug(F111,"docd","srvcdmsg",srvcdmsg);
  9568.         if (srvcdmsg
  9569. #ifdef IKSDCONF
  9570.             && !(inserver && !iksdcf)
  9571. #endif /* IKSDCONF */
  9572.             ) {
  9573.             int i;
  9574.             for (i = 0; i < 8; i++) {
  9575.                 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9576.                 if (zchki(cdmsgfile[i]) > -1) {
  9577.                     x = 1;
  9578.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9579.                     break;
  9580.                 }
  9581.             }
  9582.         }
  9583.     }
  9584. /* xdocd: */
  9585.     if (!x && srvcdmsg && !server
  9586. #ifdef IKSDCONF
  9587.         && !(inserver && !iksdcf)
  9588. #endif /* IKSDCONF */
  9589.         && !quiet && !xcmdsrc)
  9590.       printf("%s\n", zgtdir());
  9591.  
  9592.     return(cwdf);
  9593. }
  9594.  
  9595. static int on_ctrlc = 0;
  9596.  
  9597. VOID
  9598. fixcmd() {                      /* Fix command parser after interruption */
  9599. #ifndef NOSPL
  9600. #ifndef NOONCTRLC
  9601.     if (nmac) {                         /* Any macros defined? */
  9602.         int k;                          /* Yes */
  9603.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9604.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9605.         if (k >= 0) {                   /* If found, */
  9606.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9607.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9608.                   parser(1);            /* execute it, */
  9609.             }
  9610.             delmac(s,1);                /* and undefine it. */
  9611.         }
  9612.     }
  9613.     on_ctrlc = 0;
  9614. #endif /* NOONCTRLC */
  9615. #endif /* NOSPL */
  9616.     dostop();                   /* Back to top level (also calls conint()). */
  9617.     bgchk();                    /* Check background status */
  9618.     if (*psave) {               /* If old prompt saved, */
  9619.         cmsetp(psave);          /* restore it. */
  9620.         *psave = NUL;
  9621.     }
  9622.     success = 0;                /* Tell parser last command failed */
  9623. }
  9624.  
  9625. #ifndef NOSHOW                          /* SHOW FEATURES */
  9626. /*
  9627.   Note, presently optlist[] index overflow is not checked.
  9628.   There is plenty of room (less than 360 entries for 1000 slots).
  9629.   When space starts to get tight, check for noptlist >= NOPTLIST
  9630.   every time noptlist is incremented.
  9631. */
  9632. #define NOPTLIST 1024
  9633. static int noptlist = 0;
  9634. static char * optlist[NOPTLIST+1];
  9635. static int hpos = 0;
  9636.  
  9637. int
  9638. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9639.     int y, i;                           /* Does word wrap. */
  9640.     if (!s) s = "";
  9641.     i = *lines;
  9642.     if (!*s) {                          /* Empty argument */
  9643.         if (hpos > 0) {                 /* means to end this line. */
  9644.             printf("\n");               /* Not needed if already at */
  9645.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9646.                 if (!askmore())
  9647.                   return(0);
  9648.                 else
  9649.                   i = 0;
  9650.             }
  9651.         }
  9652.         printf("\n");                   /* And then make a blank line */
  9653.         if (++i > (cmd_rows - 3)) {
  9654.             if (!askmore())
  9655.               return(0);
  9656.             else
  9657.               i = 0;
  9658.         }
  9659.         hpos = 0;
  9660.         *lines = i;
  9661.         return(1);
  9662.     }
  9663.     y = (int)strlen(s) + 1;
  9664.     hpos += y;
  9665.     debug(F101,"prtopt hpos","",hpos);
  9666.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9667.  
  9668.     if (
  9669. #ifdef OS2
  9670.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9671. #else /* OS2 */
  9672.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9673. #endif /* OS2 */
  9674.         ) {
  9675.         printf("\n");
  9676.         if (++i > (cmd_rows - 3)) {
  9677.             if (!askmore())
  9678.               return(0);
  9679.             else
  9680.               i = 0;
  9681.         }
  9682.         printf(" %s",s);
  9683.         hpos = y;
  9684.     } else
  9685.       printf(" %s",s);
  9686.     *lines = i;
  9687.     return(1);
  9688. }
  9689.  
  9690. static VOID
  9691. initoptlist() {
  9692.     int i;
  9693.     if (noptlist > 0)
  9694.       return;
  9695.     for (i = 0; i < NOPTLIST; i++)
  9696.       optlist[i] = NULL;
  9697.  
  9698. #ifdef MAC
  9699. #ifdef MPW
  9700.     makestr(&(optlist[noptlist++]),"MPW");
  9701. #endif /* MPW */
  9702. #endif /* MAC */
  9703.  
  9704. #ifdef MAC
  9705. #ifdef THINK_C
  9706.     makestr(&(optlist[noptlist++]),"THINK_C");
  9707. #endif /* THINK_C */
  9708. #endif /* MAC */
  9709.  
  9710. #ifdef __386__
  9711.     makestr(&(optlist[noptlist++]),"__386__");
  9712. #endif /* __386__ */
  9713.  
  9714. /* Memory models... */
  9715.  
  9716. #ifdef __FLAT__
  9717.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9718. #endif /* __FLAT__ */
  9719. #ifdef __SMALL__
  9720.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9721. #endif /* __SMALL__ */
  9722. #ifdef __MEDIUM__
  9723.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9724. #endif /* __MEDIUM__ */
  9725. #ifdef __COMPACT__
  9726.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9727. #endif /* __COMPACT__ */
  9728. #ifdef __LARGE__
  9729.     makestr(&(optlist[noptlist++]),"__LARGE__");
  9730. #endif /* __LARGE__ */
  9731.  
  9732. #ifdef DEBUG
  9733. #ifdef IFDEBUG
  9734.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  9735. #else
  9736.     makestr(&(optlist[noptlist++]),"DEBUG");
  9737. #endif /* IFDEBUG */
  9738. #endif /* DEBUG */
  9739. #ifdef TLOG
  9740.     makestr(&(optlist[noptlist++]),"TLOG");
  9741. #endif /* TLOG */
  9742. #ifdef BIGBUFOK
  9743.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9744. #endif /* BIGBUFOK */
  9745. #ifdef INPBUFSIZ
  9746.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9747.     makestr(&(optlist[noptlist++]),line);
  9748. #endif /* INPBUFSIZE */
  9749. #ifdef INBUFSIZE
  9750.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9751.     makestr(&(optlist[noptlist++]),line);
  9752. #endif /* INBUFSIZE */
  9753. #ifdef OBUFSIZE
  9754.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9755.     makestr(&(optlist[noptlist++]),line);
  9756. #endif /* OBUFSIZE */
  9757. #ifdef FD_SETSIZE
  9758.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9759.     makestr(&(optlist[noptlist++]),line);
  9760. #endif /* FD_SETSIZE */
  9761. #ifdef XFRCAN
  9762.     makestr(&(optlist[noptlist++]),"XFRCAN");
  9763. #endif /* XFRCAN */
  9764. #ifdef XPRINT
  9765.     makestr(&(optlist[noptlist++]),"XPRINT");
  9766. #endif /* XPRINT */
  9767. #ifdef PIPESEND
  9768.     makestr(&(optlist[noptlist++]),"PIPESEND");
  9769. #endif /* PIPESEND */
  9770. #ifdef CK_SPEED
  9771.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  9772. #endif /* CK_SPEED */
  9773. #ifdef CK_FAST
  9774.     makestr(&(optlist[noptlist++]),"CK_FAST");
  9775. #endif /* CK_FAST */
  9776. #ifdef CK_APC
  9777.     makestr(&(optlist[noptlist++]),"CK_APC");
  9778. #endif /* CK_APC */
  9779. #ifdef CK_AUTODL
  9780.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  9781. #endif /* CK_AUTODL */
  9782. #ifdef CK_MKDIR
  9783.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  9784. #endif /* CK_MKDIR */
  9785. #ifdef NOMKDIR
  9786.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  9787. #endif /* NOMKDIR */
  9788. #ifdef CK_LABELED
  9789.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  9790. #endif /* CK_LABELED */
  9791. #ifdef NODIAL
  9792.     makestr(&(optlist[noptlist++]),"NODIAL");
  9793. #endif /* NODIAL */
  9794. #ifdef MINIDIAL
  9795.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  9796. #endif /* MINIDIAL */
  9797. #ifdef WHATAMI
  9798.     makestr(&(optlist[noptlist++]),"WHATAMI");
  9799. #endif /* WHATAMI */
  9800. #ifdef DYNAMIC
  9801.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  9802. #endif /* IFDEBUG */
  9803. #ifndef NOSPL
  9804.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  9805.     makestr(&(optlist[noptlist++]),line);
  9806. #endif /* NOSPL */
  9807.  
  9808. #ifdef MAXPATHLEN
  9809.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  9810.     makestr(&(optlist[noptlist++]),line);
  9811. #endif /* MAXPATHLEN */
  9812.  
  9813. #ifdef DEVNAMLEN
  9814.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  9815.     makestr(&(optlist[noptlist++]),line);
  9816. #endif /* DEVNAMLEN */
  9817.  
  9818. #ifdef NO_PARAM_H
  9819.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  9820. #endif /* NO_PARAM_H */
  9821.  
  9822. #ifdef INCL_PARAM_H
  9823.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  9824. #endif /* INCL_PARAM_H */
  9825.  
  9826.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  9827.     makestr(&(optlist[noptlist++]),line);
  9828.  
  9829.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  9830.     makestr(&(optlist[noptlist++]),line);
  9831.  
  9832.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  9833.     makestr(&(optlist[noptlist++]),line);
  9834.  
  9835. #ifdef OPEN_MAX
  9836.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  9837.     makestr(&(optlist[noptlist++]),line);
  9838. #endif /* OPEN_MAX */
  9839.  
  9840. #ifdef _POSIX_OPEN_MAX
  9841.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  9842.     makestr(&(optlist[noptlist++]),line);
  9843. #endif /* _POSIX_OPEN_MAX */
  9844.  
  9845. #ifdef CKCHANNELIO
  9846.     {
  9847.         extern int z_maxchan;
  9848. #ifdef UNIX
  9849.         extern int ckmaxfiles;
  9850.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  9851.         makestr(&(optlist[noptlist++]),line);
  9852. #endif /* UNIX */
  9853.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  9854.         makestr(&(optlist[noptlist++]),line);
  9855.     }
  9856. #endif /* CKCHANNELIO */
  9857.  
  9858. #ifdef FOPEN_MAX
  9859.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  9860.     makestr(&(optlist[noptlist++]),line);
  9861. #endif /* FOPEN_MAX */
  9862.  
  9863. #ifdef MAXGETPATH
  9864.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  9865.     makestr(&(optlist[noptlist++]),line);
  9866. #endif /* MAXGETPATH */
  9867.  
  9868. #ifdef CMDBL
  9869.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  9870.     makestr(&(optlist[noptlist++]),line);
  9871. #endif /* CMDBL */
  9872.  
  9873. #ifdef VNAML
  9874.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  9875.     makestr(&(optlist[noptlist++]),line);
  9876. #endif /* VNAML */
  9877.  
  9878. #ifdef ARRAYREFLEN
  9879.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  9880.     makestr(&(optlist[noptlist++]),line);
  9881. #endif /* ARRAYREFLEN */
  9882.  
  9883. #ifdef UIDBUFLEN
  9884.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  9885.     makestr(&(optlist[noptlist++]),line);
  9886. #endif /* UIDBUFLEN */
  9887.  
  9888. #ifdef FORDEPTH
  9889.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  9890.     makestr(&(optlist[noptlist++]),line);
  9891. #endif /* FORDEPTH */
  9892.  
  9893. #ifdef MAXTAKE
  9894.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  9895.     makestr(&(optlist[noptlist++]),line);
  9896. #endif /* MAXTAKE */
  9897.  
  9898. #ifdef MACLEVEL
  9899.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  9900.     makestr(&(optlist[noptlist++]),line);
  9901. #endif /* MACLEVEL */
  9902.  
  9903. #ifdef MAC_MAX
  9904.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  9905.     makestr(&(optlist[noptlist++]),line);
  9906. #endif /* MAC_MAX */
  9907.  
  9908. #ifdef MINPUTMAX
  9909.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  9910.     makestr(&(optlist[noptlist++]),line);
  9911. #endif /* MINPUTMAX */
  9912.  
  9913. #ifdef MAXWLD
  9914.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  9915.     makestr(&(optlist[noptlist++]),line);
  9916. #else
  9917. #ifdef OS2
  9918.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  9919. #endif /* OS2 */
  9920. #endif /* MAXWLD */
  9921.  
  9922. #ifdef MSENDMAX
  9923.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  9924.     makestr(&(optlist[noptlist++]),line);
  9925. #endif /* MSENDMAX */
  9926.  
  9927. #ifdef MAXDDIR
  9928.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  9929.     makestr(&(optlist[noptlist++]),line);
  9930. #endif /* MAXDDIR */
  9931.  
  9932. #ifdef MAXDNUMS
  9933.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  9934.     makestr(&(optlist[noptlist++]),line);
  9935. #endif /* MAXDNUMS */
  9936.  
  9937. #ifdef UNIX
  9938.     makestr(&(optlist[noptlist++]),"UNIX");
  9939. #endif /* UNIX */
  9940. #ifdef VMS
  9941.     makestr(&(optlist[noptlist++]),"VMS");
  9942. #ifdef __VMS_VER
  9943.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  9944.     makestr(&(optlist[noptlist++]),line);
  9945. #endif /* __VMS_VER */
  9946. #ifdef VMSV70
  9947.     makestr(&(optlist[noptlist++]),"VMSV70");
  9948. #endif /* VMSV70 */
  9949. #endif /* VMS */
  9950. #ifdef OLD_VMS
  9951.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  9952. #endif /* OLD_VMS */
  9953. #ifdef vms
  9954.     makestr(&(optlist[noptlist++]),"vms");
  9955. #endif /* vms */
  9956. #ifdef VMSV60
  9957.     makestr(&(optlist[noptlist++]),"VMSV60");
  9958. #endif /* VMSV60 */
  9959. #ifdef VMSV70
  9960.     makestr(&(optlist[noptlist++]),"VMSV70");
  9961. #endif /* VMSV70 */
  9962. #ifdef VMSSHARE
  9963.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  9964. #endif /* VMSSHARE */
  9965. #ifdef NOVMSSHARE
  9966.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  9967. #endif /* NOVMSSHARE */
  9968. #ifdef datageneral
  9969.     makestr(&(optlist[noptlist++]),"datageneral");
  9970. #endif /* datageneral */
  9971. #ifdef apollo
  9972.     makestr(&(optlist[noptlist++]),"apollo");
  9973. #endif /* apollo */
  9974. #ifdef aegis
  9975.     makestr(&(optlist[noptlist++]),"aegis");
  9976. #endif /* aegis */
  9977. #ifdef A986
  9978.     makestr(&(optlist[noptlist++]),"A986");
  9979. #endif /* A986 */
  9980. #ifdef AMIGA
  9981.     makestr(&(optlist[noptlist++]),"AMIGA");
  9982. #endif /* AMIGA */
  9983. #ifdef CONVEX9
  9984.     makestr(&(optlist[noptlist++]),"CONVEX9");
  9985. #endif /* CONVEX9 */
  9986. #ifdef CONVEX10
  9987.     makestr(&(optlist[noptlist++]),"CONVEX10");
  9988. #endif /* CONVEX9 */
  9989. #ifdef MAC
  9990.     makestr(&(optlist[noptlist++]),"MAC");
  9991. #endif /* MAC */
  9992. #ifdef AUX
  9993.     makestr(&(optlist[noptlist++]),"AUX");
  9994. #endif /* AUX */
  9995. #ifdef OS2
  9996.     makestr(&(optlist[noptlist++]),"OS2");
  9997. #ifdef NT
  9998.     makestr(&(optlist[noptlist++]),"NT");
  9999. #endif /* NT */
  10000. #endif /* OS2 */
  10001. #ifdef OSK
  10002.     makestr(&(optlist[noptlist++]),"OS9");
  10003. #endif /* OSK */
  10004. #ifdef MSDOS
  10005.     makestr(&(optlist[noptlist++]),"MSDOS");
  10006. #endif /* MSDOS */
  10007. #ifdef DIRENT
  10008.     makestr(&(optlist[noptlist++]),"DIRENT");
  10009. #endif /* DIRENT */
  10010. #ifdef SDIRENT
  10011.     makestr(&(optlist[noptlist++]),"SDIRENT");
  10012. #endif /* SDIRENT */
  10013. #ifdef NDIR
  10014.     makestr(&(optlist[noptlist++]),"NDIR");
  10015. #endif /* NDIR */
  10016. #ifdef XNDIR
  10017.     makestr(&(optlist[noptlist++]),"XNDIR");
  10018. #endif /* XNDIR */
  10019. #ifdef SAVEDUID
  10020.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  10021. #endif /* SAVEDUID */
  10022. #ifdef RENAME
  10023.     makestr(&(optlist[noptlist++]),"RENAME");
  10024. #endif /* RENAME */
  10025. #ifdef CK_TMPDIR
  10026.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  10027. #endif /* CK_TMPDIR */
  10028. #ifdef NOCCTRAP
  10029.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  10030. #endif /* NOCCTRAP */
  10031. #ifdef NOCOTFMC
  10032.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  10033. #endif /* NOCOTFMC */
  10034. #ifdef NOFRILLS
  10035.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  10036. #endif /* NOFRILLS */
  10037. #ifdef PARSENSE
  10038.     makestr(&(optlist[noptlist++]),"PARSENSE");
  10039. #endif /* PARSENSE */
  10040. #ifdef TIMEH
  10041.     makestr(&(optlist[noptlist++]),"TIMEH");
  10042. #endif /* TIMEH */
  10043. #ifdef NOTIMEH
  10044.     makestr(&(optlist[noptlist++]),"TIMEH");
  10045. #endif /* NOTIMEH */
  10046.  
  10047. #ifdef SYSTIMEH
  10048.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10049. #endif /* SYSTIMEH */
  10050. #ifdef NOSYSTIMEH
  10051.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10052. #endif /* NOSYSTIMEH */
  10053.  
  10054. #ifdef SYSTIMEBH
  10055.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10056. #endif /* SYSTIMEBH */
  10057. #ifdef NOSYSTIMEBH
  10058.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10059. #endif /* NOSYSTIMEBH */
  10060. #ifdef UTIMEH
  10061.     makestr(&(optlist[noptlist++]),"UTIMEH");
  10062. #endif /* UTIMEH */
  10063. #ifdef SYSUTIMEH
  10064.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  10065. #endif /* SYSUTIMEH */
  10066.  
  10067. #ifdef CK_NEED_SIG
  10068.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  10069. #endif /* CK_NEED_SIG */
  10070. #ifdef CK_TTYFD
  10071.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  10072. #endif /* CK_TTYFD */
  10073. #ifdef NETCONN
  10074.     makestr(&(optlist[noptlist++]),"NETCONN");
  10075. #endif /* NETCONN */
  10076. #ifdef TCPSOCKET
  10077.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  10078. #ifdef NOTCPOPTS
  10079.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  10080. #endif /* NOTCPOPTS */
  10081. #ifdef CK_DNS_SRV
  10082.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  10083. #endif /* CK_DNS_SRV */
  10084. #ifdef NO_DNS_SRV
  10085.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  10086. #endif /* NO_DNS_SRV */
  10087. #ifdef CKGHNLHOST
  10088.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  10089. #endif /* CKGHNLHOST */
  10090. #ifdef NOLISTEN
  10091.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  10092. #endif /* NOLISTEN */
  10093. #ifdef SOL_SOCKET
  10094.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  10095. #endif /* SOL_SOCKET */
  10096. #ifdef SO_OOBINLINE
  10097.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  10098. #endif /* SO_OOBINLNE */
  10099. #ifdef SO_DONTROUTE
  10100.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  10101. #endif /* SO_DONTROUTE */
  10102. #ifdef SO_KEEPALIVE
  10103.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  10104. #endif /* SO_KEEPALIVE */
  10105. #ifdef SO_LINGER
  10106.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  10107. #endif /* SO_LINGER */
  10108. #ifdef TCP_NODELAY
  10109.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  10110. #endif /* TCP_NODELAY */
  10111. #ifdef SO_SNDBUF
  10112.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  10113. #endif /* SO_SNDBUF */
  10114. #ifdef SO_RCVBUF
  10115.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  10116. #endif /* SO_RCVBUF */
  10117. #ifdef h_addr
  10118.     makestr(&(optlist[noptlist++]),"h_addr");
  10119. #endif /* h_addr */
  10120. #ifdef HADDRLIST
  10121.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  10122. #endif /* HADDRLIST */
  10123. #ifdef CK_SOCKS
  10124.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  10125. #ifdef CK_SOCKS5
  10126.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  10127. #endif /* CK_SOCKS5 */
  10128. #ifdef CK_SOCKS_NS
  10129.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  10130. #endif /* CK_SOCKS_NS */
  10131. #endif /* CK_SOCKS */
  10132. #ifdef RLOGCODE
  10133.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  10134. #endif /* RLOGCODE */
  10135. #ifdef NETCMD
  10136.     makestr(&(optlist[noptlist++]),"NETCMD");
  10137. #endif /* NETCMD */
  10138. #ifdef NONETCMD
  10139.     makestr(&(optlist[noptlist++]),"NONETCMD");
  10140. #endif /* NONETCMD */
  10141. #ifdef NETPTY
  10142.     makestr(&(optlist[noptlist++]),"NETPTY");
  10143. #endif /* NETPTY */
  10144. #ifdef CK_ENVIRONMENT
  10145.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  10146. #endif /* CK_ENVIRONMENT */
  10147. #endif /* TCPSOCKET */
  10148. #ifdef TNCODE
  10149.     makestr(&(optlist[noptlist++]),"TNCODE");
  10150. #endif /* TNCODE */
  10151. #ifdef CK_FORWARD_X
  10152.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  10153. #endif /* CK_FORWARD_X */
  10154. #ifdef TN_COMPORT
  10155.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  10156. #endif /* TN_COMPORT */
  10157. #ifdef MULTINET
  10158.     makestr(&(optlist[noptlist++]),"MULTINET");
  10159. #endif /* MULTINET */
  10160. #ifdef DEC_TCPIP
  10161.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  10162. #endif /* DEC_TCPIP */
  10163. #ifdef TCPWARE
  10164.     makestr(&(optlist[noptlist++]),"TCPWARE");
  10165. #endif /* TCPWARE */
  10166. #ifdef UCX50
  10167.     makestr(&(optlist[noptlist++]),"UCX50");
  10168. #endif /* UCX50 */
  10169. #ifdef CMU_TCPIP
  10170.     makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  10171. #endif /* CMU_TCPIP */
  10172. #ifdef TTLEBUF
  10173.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  10174. #endif /* TTLEBUF */
  10175. #ifdef NETLEBUF
  10176.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  10177. #endif /* NETLEBUF */
  10178. #ifdef IKS_OPTION
  10179.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10180. #endif /* IKS_OPTION */
  10181. #ifdef IKSDB
  10182.     makestr(&(optlist[noptlist++]),"IKSDB");
  10183. #endif /* IKSDB */
  10184. #ifdef IKSDCONF
  10185.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  10186. #endif /* IKSDCONF */
  10187. #ifdef CK_LOGIN
  10188.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10189. #endif /* CK_LOGIN */
  10190. #ifdef CK_PAM
  10191.     makestr(&(optlist[noptlist++]),"CK_PAM");
  10192. #endif /* CK_PAM */
  10193. #ifdef CK_SHADOW
  10194.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10195. #endif /* CK_SHADOW */
  10196. #ifdef CONGSPD
  10197.     makestr(&(optlist[noptlist++]),"CONGSPD");
  10198. #endif /* CONGSPD */
  10199. #ifdef SUNX25
  10200.     makestr(&(optlist[noptlist++]),"SUNX25");
  10201. #endif /* SUNX25 */
  10202. #ifdef IBMX25
  10203.     makestr(&(optlist[noptlist++]),"IBMX25");
  10204. #endif /* IBMX25 */
  10205. #ifdef HPX25
  10206.     makestr(&(optlist[noptlist++]),"HPX25");
  10207. #endif /* HPX25 */
  10208. #ifdef DECNET
  10209.     makestr(&(optlist[noptlist++]),"DECNET");
  10210. #endif /* DECNET */
  10211. #ifdef SUPERLAT
  10212.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  10213. #endif /* SUPERLAT */
  10214. #ifdef NPIPE
  10215.     makestr(&(optlist[noptlist++]),"NPIPE");
  10216. #endif /* NPIPE */
  10217. #ifdef CK_NETBIOS
  10218.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10219. #endif /* CK_NETBIOS */
  10220. #ifdef ATT7300
  10221.     makestr(&(optlist[noptlist++]),"ATT7300");
  10222. #endif /* ATT7300 */
  10223. #ifdef ATT6300
  10224.     makestr(&(optlist[noptlist++]),"ATT6300");
  10225. #endif /* ATT6300 */
  10226. #ifdef HDBUUCP
  10227.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10228. #endif /* HDBUUCP */
  10229. #ifdef USETTYLOCK
  10230.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10231. #endif /* USETTYLOCK */
  10232. #ifdef NOUUCP
  10233.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10234. #endif /* NOUUCP */
  10235. #ifdef LONGFN
  10236.     makestr(&(optlist[noptlist++]),"LONGFN");
  10237. #endif /* LONGFN */
  10238. #ifdef RDCHK
  10239.     makestr(&(optlist[noptlist++]),"RDCHK");
  10240. #endif /* RDCHK */
  10241. #ifdef SELECT
  10242.     makestr(&(optlist[noptlist++]),"SELECT");
  10243. #endif /* SELECT */
  10244. #ifdef USLEEP
  10245.     makestr(&(optlist[noptlist++]),"USLEEP");
  10246. #endif /* USLEEP */
  10247. #ifdef NAP
  10248.     makestr(&(optlist[noptlist++]),"NAP");
  10249. #endif /* NAP */
  10250. #ifdef NAPHACK
  10251.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10252. #endif /* NAPHACK */
  10253. #ifdef CK_POLL
  10254.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10255. #endif /* CK_POLL */
  10256. #ifdef NOIEXTEN
  10257.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10258. #endif /* NOIEXTEN */
  10259. #ifdef EXCELAN
  10260.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10261. #endif /* EXCELAN */
  10262. #ifdef INTERLAN
  10263.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10264. #endif /* INTERLAN */
  10265. #ifdef NOFILEH
  10266.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10267. #endif /* NOFILEH */
  10268. #ifdef NOSYSIOCTLH
  10269.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10270. #endif /* NOSYSIOCTLH */
  10271. #ifdef DCLPOPEN
  10272.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10273. #endif /* DCLPOPEN */
  10274. #ifdef NOSETBUF
  10275.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10276. #endif /* NOSETBUF */
  10277. #ifdef NOXFER
  10278.     makestr(&(optlist[noptlist++]),"NOXFER");
  10279. #endif /* NOXFER */
  10280. #ifdef NOCURSES
  10281.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10282. #endif /* NOCURSES */
  10283. #ifdef NOSERVER
  10284.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10285. #endif /* NOSERVER */
  10286. #ifdef NOPATTERNS
  10287.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10288. #else
  10289. #ifdef PATTERNS
  10290.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10291. #endif /* PATTERNS */
  10292. #endif /* NOPATTERNS */
  10293. #ifdef NOCKEXEC
  10294.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10295. #else
  10296. #ifdef CKEXEC
  10297.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10298. #endif /* CKEXEC */
  10299. #endif /* NOCKEXEC */
  10300. #ifdef NOAUTODL
  10301.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10302. #endif /* NOAUTODL */
  10303. #ifdef NOMSEND
  10304.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10305. #endif /* NOMSEND */
  10306. #ifdef NOFDZERO
  10307.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10308. #endif /* NOFDZERO */
  10309. #ifdef NOPOPEN
  10310.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10311. #endif /* NOPOPEN */
  10312. #ifdef NOPARTIAL
  10313.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10314. #endif /* NOPARTIAL */
  10315. #ifdef NOKVERBS
  10316.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10317. #endif /* NOKVERBS */
  10318. #ifdef NOSETREU
  10319.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10320. #endif /* NOSETREU */
  10321. #ifdef LCKDIR
  10322.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10323. #endif /* LCKDIR */
  10324. #ifdef ACUCNTRL
  10325.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10326. #endif /* ACUCNTRL */
  10327. #ifdef BSD4
  10328.     makestr(&(optlist[noptlist++]),"BSD4");
  10329. #endif /* BSD4 */
  10330. #ifdef BSD44
  10331.     makestr(&(optlist[noptlist++]),"BSD44");
  10332. #endif /* BSD44 */
  10333. #ifdef BSD41
  10334.     makestr(&(optlist[noptlist++]),"BSD41");
  10335. #endif /* BSD41 */
  10336. #ifdef BSD43
  10337.     makestr(&(optlist[noptlist++]),"BSD43");
  10338. #endif /* BSD43 */
  10339. #ifdef BSD29
  10340.     makestr(&(optlist[noptlist++]),"BSD29");
  10341. #endif /* BSD29 */
  10342. #ifdef BSDI
  10343.     makestr(&(optlist[noptlist++]),"BSDI");
  10344. #endif /* BSDI */
  10345. #ifdef __bsdi__
  10346.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10347. #endif /* __bsdi__ */
  10348. #ifdef __NetBSD__
  10349.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10350. #endif /* __NetBSD__ */
  10351. #ifdef __OpenBSD__
  10352.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10353. #endif /* __OpenBSD__ */
  10354. #ifdef __FreeBSD__
  10355.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10356. #endif /* __FreeBSD__ */
  10357. #ifdef __linux__
  10358.     makestr(&(optlist[noptlist++]),"__linux__");
  10359. #endif /* __linux__ */
  10360. #ifdef LINUX_HI_SPD
  10361.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10362. #endif /* LINUX_HI_SPD */
  10363. #ifdef LYNXOS
  10364.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10365. #endif /* LYNXOS */
  10366. #ifdef V7
  10367.     makestr(&(optlist[noptlist++]),"V7");
  10368. #endif /* V7 */
  10369. #ifdef AIX370
  10370.     makestr(&(optlist[noptlist++]),"AIX370");
  10371. #endif /* AIX370 */
  10372. #ifdef RTAIX
  10373.     makestr(&(optlist[noptlist++]),"RTAIX");
  10374. #endif /* RTAIX */
  10375. #ifdef HPUX
  10376.     makestr(&(optlist[noptlist++]),"HPUX");
  10377. #endif /* HPUX */
  10378. #ifdef HPUXPRE65
  10379.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10380. #endif /* HPUXPRE65 */
  10381. #ifdef DGUX
  10382.     makestr(&(optlist[noptlist++]),"DGUX");
  10383. #endif /* DGUX */
  10384. #ifdef DGUX430
  10385.     makestr(&(optlist[noptlist++]),"DGUX430");
  10386. #endif /* DGUX430 */
  10387. #ifdef DGUX540
  10388.     makestr(&(optlist[noptlist++]),"DGUX540");
  10389. #endif /* DGUX540 */
  10390. #ifdef DGUX543
  10391.     makestr(&(optlist[noptlist++]),"DGUX543");
  10392. #endif /* DGUX543 */
  10393. #ifdef DGUX54410
  10394.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10395. #endif /* DGUX54410 */
  10396. #ifdef DGUX54411
  10397.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10398. #endif /* DGUX54411 */
  10399. #ifdef sony_news
  10400.     makestr(&(optlist[noptlist++]),"sony_news");
  10401. #endif /* sony_news */
  10402. #ifdef CIE
  10403.     makestr(&(optlist[noptlist++]),"CIE");
  10404. #endif /* CIE */
  10405. #ifdef XENIX
  10406.     makestr(&(optlist[noptlist++]),"XENIX");
  10407. #endif /* XENIX */
  10408. #ifdef SCO_XENIX
  10409.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10410. #endif /* SCO_XENIX */
  10411. #ifdef ISIII
  10412.     makestr(&(optlist[noptlist++]),"ISIII");
  10413. #endif /* ISIII */
  10414. #ifdef I386IX
  10415.     makestr(&(optlist[noptlist++]),"I386IX");
  10416. #endif /* I386IX */
  10417. #ifdef RTU
  10418.     makestr(&(optlist[noptlist++]),"RTU");
  10419. #endif /* RTU */
  10420. #ifdef PROVX1
  10421.     makestr(&(optlist[noptlist++]),"PROVX1");
  10422. #endif /* PROVX1 */
  10423. #ifdef PYRAMID
  10424.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10425. #endif /* PYRAMID */
  10426. #ifdef TOWER1
  10427.     makestr(&(optlist[noptlist++]),"TOWER1");
  10428. #endif /* TOWER1 */
  10429. #ifdef UTEK
  10430.     makestr(&(optlist[noptlist++]),"UTEK");
  10431. #endif /* UTEK */
  10432. #ifdef ZILOG
  10433.     makestr(&(optlist[noptlist++]),"ZILOG");
  10434. #endif /* ZILOG */
  10435. #ifdef TRS16
  10436.     makestr(&(optlist[noptlist++]),"TRS16");
  10437. #endif /* TRS16 */
  10438. #ifdef MINIX
  10439.     makestr(&(optlist[noptlist++]),"MINIX");
  10440. #endif /* MINIX */
  10441. #ifdef C70
  10442.     makestr(&(optlist[noptlist++]),"C70");
  10443. #endif /* C70 */
  10444. #ifdef AIXPS2
  10445.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10446. #endif /* AIXPS2 */
  10447. #ifdef AIXRS
  10448.     makestr(&(optlist[noptlist++]),"AIXRS");
  10449. #endif /* AIXRS */
  10450. #ifdef UTSV
  10451.     makestr(&(optlist[noptlist++]),"UTSV");
  10452. #endif /* UTSV */
  10453. #ifdef ATTSV
  10454.     makestr(&(optlist[noptlist++]),"ATTSV");
  10455. #endif /* ATTSV */
  10456. #ifdef SVR3
  10457.     makestr(&(optlist[noptlist++]),"SVR3");
  10458. #endif /* SVR3 */
  10459. #ifdef SVR4
  10460.     makestr(&(optlist[noptlist++]),"SVR4");
  10461. #endif /* SVR4 */
  10462. #ifdef DELL_SVR4
  10463.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10464. #endif /* DELL_SVR4 */
  10465. #ifdef ICL_SVR4
  10466.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10467. #endif /* ICL_SVR4 */
  10468. #ifdef OSF
  10469.     makestr(&(optlist[noptlist++]),"OSF");
  10470. #endif /* OSF */
  10471. #ifdef OSF1
  10472.     makestr(&(optlist[noptlist++]),"OSF1");
  10473. #endif /* OSF1 */
  10474. #ifdef __OSF
  10475.     makestr(&(optlist[noptlist++]),"__OSF");
  10476. #endif /* __OSF */
  10477. #ifdef __OSF__
  10478.     makestr(&(optlist[noptlist++]),"__OSF__");
  10479. #endif /* __OSF__ */
  10480. #ifdef __osf__
  10481.     makestr(&(optlist[noptlist++]),"__osf__");
  10482. #endif /* __osf__ */
  10483. #ifdef __OSF1
  10484.     makestr(&(optlist[noptlist++]),"__OSF1");
  10485. #endif /* __OSF1 */
  10486. #ifdef __OSF1__
  10487.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10488. #endif /* __OSF1__ */
  10489. #ifdef PTX
  10490.     makestr(&(optlist[noptlist++]),"PTX");
  10491. #endif /* PTX */
  10492. #ifdef POSIX
  10493.     makestr(&(optlist[noptlist++]),"POSIX");
  10494. #endif /* POSIX */
  10495. #ifdef BSD44ORPOSIX
  10496.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10497. #endif /* BSD44ORPOSIX */
  10498. #ifdef SVORPOSIX
  10499.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10500. #endif /* SVORPOSIX */
  10501. #ifdef SVR4ORPOSIX
  10502.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10503. #endif /* SVR4ORPOSIX */
  10504. #ifdef OS2ORVMS
  10505.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10506. #endif /* OS2ORVMS */
  10507. #ifdef OS2ORUNIX
  10508.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10509. #endif /* OS2ORUNIX */
  10510. #ifdef VMSORUNIX
  10511.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10512. #endif /* VMSORUNIX */
  10513. #ifdef _POSIX_SOURCE
  10514.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10515. #endif /* _POSIX_SOURCE */
  10516. #ifdef _XOPEN_SOURCE
  10517.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10518. #endif
  10519. #ifdef _ALL_SOURCE
  10520.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10521. #endif
  10522. #ifdef _SVID3
  10523.     makestr(&(optlist[noptlist++]),"_SVID3");
  10524. #endif /* _SVID3 */
  10525. #ifdef Plan9
  10526.     makestr(&(optlist[noptlist++]),"Plan9");
  10527. #endif /* Plan9 */
  10528. #ifdef SOLARIS
  10529.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10530. #ifdef SOLARIS24
  10531.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10532. #endif /* SOLARIS24 */
  10533. #ifdef SOLARIS25
  10534.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10535. #endif /* SOLARIS25 */
  10536. #ifdef SOLARIS26
  10537.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10538. #endif /* SOLARIS26 */
  10539. #ifdef SOLARIS7
  10540.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10541. #endif /* SOLARIS7 */
  10542. #ifdef SOLARIS8
  10543.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10544. #endif /* SOLARIS8 */
  10545. #endif /* SOLARIS */
  10546.  
  10547. #ifdef SUNOS4
  10548.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10549. #endif /* SUNOS4 */
  10550. #ifdef SUN4S5
  10551.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10552. #endif /* SUN4S5 */
  10553. #ifdef IRIX
  10554.     makestr(&(optlist[noptlist++]),"IRIX");
  10555. #endif /* IRIX */
  10556. #ifdef ENCORE
  10557.     makestr(&(optlist[noptlist++]),"ENCORE");
  10558. #endif /* ENCORE */
  10559. #ifdef ultrix
  10560.     makestr(&(optlist[noptlist++]),"ultrix");
  10561. #endif
  10562. #ifdef sxaE50
  10563.     makestr(&(optlist[noptlist++]),"sxaE50");
  10564. #endif
  10565. #ifdef mips
  10566.     makestr(&(optlist[noptlist++]),"mips");
  10567. #endif
  10568. #ifdef MIPS
  10569.     makestr(&(optlist[noptlist++]),"MIPS");
  10570. #endif
  10571. #ifdef vax
  10572.     makestr(&(optlist[noptlist++]),"vax");
  10573. #endif
  10574. #ifdef VAX
  10575.     makestr(&(optlist[noptlist++]),"VAX");
  10576. #endif
  10577. #ifdef alpha
  10578.     makestr(&(optlist[noptlist++]),"alpha");
  10579. #endif
  10580. #ifdef ALPHA
  10581.     makestr(&(optlist[noptlist++]),"ALPHA");
  10582. #endif
  10583. #ifdef __ALPHA
  10584.     makestr(&(optlist[noptlist++]),"__ALPHA");
  10585. #endif
  10586. #ifdef __alpha
  10587.     makestr(&(optlist[noptlist++]),"__alpha");
  10588. #endif
  10589. #ifdef __AXP
  10590.     makestr(&(optlist[noptlist++]),"__AXP");
  10591. #endif
  10592. #ifdef AXP
  10593.     makestr(&(optlist[noptlist++]),"AXP");
  10594. #endif
  10595. #ifdef axp
  10596.     makestr(&(optlist[noptlist++]),"axp");
  10597. #endif
  10598. #ifdef __ALPHA__
  10599.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  10600. #endif
  10601. #ifdef __alpha__
  10602.     makestr(&(optlist[noptlist++]),"__alpha__");
  10603. #endif
  10604. #ifdef sun
  10605.     makestr(&(optlist[noptlist++]),"sun");
  10606. #endif
  10607. #ifdef sun3
  10608.     makestr(&(optlist[noptlist++]),"sun3");
  10609. #endif
  10610. #ifdef sun386
  10611.     makestr(&(optlist[noptlist++]),"sun386");
  10612. #endif
  10613. #ifdef _SUN
  10614.     makestr(&(optlist[noptlist++]),"_SUN");
  10615. #endif
  10616. #ifdef sun4
  10617.     makestr(&(optlist[noptlist++]),"sun4");
  10618. #endif
  10619. #ifdef sparc
  10620.     makestr(&(optlist[noptlist++]),"sparc");
  10621. #endif
  10622. #ifdef _CRAY
  10623.     makestr(&(optlist[noptlist++]),"_CRAY");
  10624. #endif /* _CRAY */
  10625. #ifdef NEXT33
  10626.     makestr(&(optlist[noptlist++]),"NEXT33");
  10627. #endif
  10628. #ifdef NEXT
  10629.     makestr(&(optlist[noptlist++]),"NEXT");
  10630. #endif
  10631. #ifdef NeXT
  10632.     makestr(&(optlist[noptlist++]),"NeXT");
  10633. #endif
  10634. #ifdef MACH
  10635.     makestr(&(optlist[noptlist++]),"MACH");
  10636. #endif
  10637. #ifdef sgi
  10638.     makestr(&(optlist[noptlist++]),"sgi");
  10639. #endif
  10640. #ifdef M_SYS5
  10641.     makestr(&(optlist[noptlist++]),"M_SYS5");
  10642. #endif
  10643. #ifdef __SYSTEM_FIVE
  10644.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  10645. #endif
  10646. #ifdef sysV
  10647.     makestr(&(optlist[noptlist++]),"sysV");
  10648. #endif
  10649. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  10650.     makestr(&(optlist[noptlist++]),"M_XENIX");
  10651. #endif
  10652. #ifdef M_UNIX                           /* SCO UNIX */
  10653.     makestr(&(optlist[noptlist++]),"M_UNIX");
  10654. #endif
  10655. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  10656.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  10657. #endif
  10658. #ifdef CK_SCOV5
  10659.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  10660. #endif
  10661. #ifdef SCO_OSR504
  10662.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  10663. #endif
  10664. #ifdef M_IA64
  10665.     makestr(&(optlist[noptlist++]),"M_IA64");
  10666. #endif
  10667. #ifdef _M_IA64
  10668.     makestr(&(optlist[noptlist++]),"_M_IA64");
  10669. #endif
  10670. #ifdef ia64
  10671.     makestr(&(optlist[noptlist++]),"ia64");
  10672. #endif
  10673. #ifdef _ia64
  10674.     makestr(&(optlist[noptlist++]),"_ia64");
  10675. #endif
  10676. #ifdef _ia64_
  10677.     makestr(&(optlist[noptlist++]),"_ia64_");
  10678. #endif
  10679. #ifdef M_I686
  10680.     makestr(&(optlist[noptlist++]),"M_I686");
  10681. #endif
  10682. #ifdef _M_I686
  10683.     makestr(&(optlist[noptlist++]),"_M_I686");
  10684. #endif
  10685. #ifdef i686
  10686.     makestr(&(optlist[noptlist++]),"i686");
  10687. #endif
  10688. #ifdef M_I586
  10689.     makestr(&(optlist[noptlist++]),"M_I586");
  10690. #endif
  10691. #ifdef _M_I586
  10692.     makestr(&(optlist[noptlist++]),"_M_I586");
  10693. #endif
  10694. #ifdef i586
  10695.     makestr(&(optlist[noptlist++]),"i586");
  10696. #endif
  10697. #ifdef M_I486
  10698.     makestr(&(optlist[noptlist++]),"M_I486");
  10699. #endif
  10700. #ifdef _M_I486
  10701.     makestr(&(optlist[noptlist++]),"_M_I486");
  10702. #endif
  10703. #ifdef i486
  10704.     makestr(&(optlist[noptlist++]),"i486");
  10705. #endif
  10706. #ifdef M_I386
  10707.     makestr(&(optlist[noptlist++]),"M_I386");
  10708. #endif
  10709. #ifdef _M_I386
  10710.     makestr(&(optlist[noptlist++]),"_M_I386");
  10711. #endif
  10712. #ifdef i386
  10713.     makestr(&(optlist[noptlist++]),"i386");
  10714. #endif
  10715. #ifdef i286
  10716.     makestr(&(optlist[noptlist++]),"i286");
  10717. #endif
  10718. #ifdef M_I286
  10719.     makestr(&(optlist[noptlist++]),"M_I286");
  10720. #endif
  10721. #ifdef mc68000
  10722.     makestr(&(optlist[noptlist++]),"mc68000");
  10723. #endif
  10724. #ifdef mc68010
  10725.     makestr(&(optlist[noptlist++]),"mc68010");
  10726. #endif
  10727. #ifdef mc68020
  10728.     makestr(&(optlist[noptlist++]),"mc68020");
  10729. #endif
  10730. #ifdef mc68030
  10731.     makestr(&(optlist[noptlist++]),"mc68030");
  10732. #endif
  10733. #ifdef mc68040
  10734.     makestr(&(optlist[noptlist++]),"mc68040");
  10735. #endif
  10736. #ifdef M_68000
  10737.     makestr(&(optlist[noptlist++]),"M_68000");
  10738. #endif
  10739. #ifdef M_68010
  10740.     makestr(&(optlist[noptlist++]),"M_68010");
  10741. #endif
  10742. #ifdef M_68020
  10743.     makestr(&(optlist[noptlist++]),"M_68020");
  10744. #endif
  10745. #ifdef M_68030
  10746.     makestr(&(optlist[noptlist++]),"M_68030");
  10747. #endif
  10748. #ifdef M_68040
  10749.     makestr(&(optlist[noptlist++]),"M_68040");
  10750. #endif
  10751. #ifdef m68k
  10752.     makestr(&(optlist[noptlist++]),"m68k");
  10753. #endif
  10754. #ifdef m88k
  10755.     makestr(&(optlist[noptlist++]),"m88k");
  10756. #endif
  10757. #ifdef pdp11
  10758.     makestr(&(optlist[noptlist++]),"pdp11");
  10759. #endif
  10760. #ifdef iAPX
  10761.     makestr(&(optlist[noptlist++]),"iAPX");
  10762. #endif
  10763. #ifdef hpux
  10764.     makestr(&(optlist[noptlist++]),"hpux");
  10765. #endif
  10766. #ifdef __hpux
  10767.     makestr(&(optlist[noptlist++]),"__hpux");
  10768. #endif
  10769. #ifdef __hp9000s800
  10770.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  10771. #endif
  10772. #ifdef __hp9000s700
  10773.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  10774. #endif
  10775. #ifdef __hp9000s500
  10776.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  10777. #endif
  10778. #ifdef __hp9000s300
  10779.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  10780. #endif
  10781. #ifdef __hp9000s200
  10782.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  10783. #endif
  10784. #ifdef AIX
  10785.     makestr(&(optlist[noptlist++]),"AIX");
  10786. #endif
  10787. #ifdef _AIXFS
  10788.     makestr(&(optlist[noptlist++]),"_AIXFS");
  10789. #endif
  10790. #ifdef u370
  10791.     makestr(&(optlist[noptlist++]),"u370");
  10792. #endif
  10793. #ifdef u3b
  10794.     makestr(&(optlist[noptlist++]),"u3b");
  10795. #endif
  10796. #ifdef u3b2
  10797.     makestr(&(optlist[noptlist++]),"u3b2");
  10798. #endif
  10799. #ifdef multimax
  10800.     makestr(&(optlist[noptlist++]),"multimax");
  10801. #endif
  10802. #ifdef balance
  10803.     makestr(&(optlist[noptlist++]),"balance");
  10804. #endif
  10805. #ifdef ibmrt
  10806.     makestr(&(optlist[noptlist++]),"ibmrt");
  10807. #endif
  10808. #ifdef _IBMRT
  10809.     makestr(&(optlist[noptlist++]),"_IBMRT");
  10810. #endif
  10811. #ifdef ibmrs6000
  10812.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  10813. #endif
  10814. #ifdef _AIX
  10815.     makestr(&(optlist[noptlist++]),"_AIX");
  10816. #endif /* _AIX */
  10817. #ifdef _IBMR2
  10818.     makestr(&(optlist[noptlist++]),"_IBMR2");
  10819. #endif
  10820. #ifdef UNIXWARE
  10821.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  10822. #endif
  10823. #ifdef QNX
  10824.     makestr(&(optlist[noptlist++]),"QNX");
  10825. #ifdef __QNX__
  10826.     makestr(&(optlist[noptlist++]),"__QNX__");
  10827. #ifdef __16BIT__
  10828.     makestr(&(optlist[noptlist++]),"__16BIT__");
  10829. #endif
  10830. #ifdef CK_QNX16
  10831.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  10832. #endif
  10833. #ifdef __32BIT__
  10834.     makestr(&(optlist[noptlist++]),"__32BIT__");
  10835. #endif
  10836. #ifdef CK_QNX32
  10837.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  10838. #endif
  10839. #endif /* __QNX__ */
  10840. #endif /* QNX */
  10841.  
  10842. #ifdef QNX6
  10843.     makestr(&(optlist[noptlist++]),"QNX6");
  10844. #endif /* QNX6 */
  10845.  
  10846. #ifdef NEUTRINO
  10847.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  10848. #endif /* NEUTRINO */
  10849.  
  10850. #ifdef __STRICT_BSD__
  10851.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  10852. #endif
  10853. #ifdef __STRICT_ANSI__
  10854.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  10855. #endif
  10856. #ifdef _ANSI_C_SOURCE
  10857.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  10858. #endif
  10859. #ifdef __STDC__
  10860.     makestr(&(optlist[noptlist++]),"__STDC__");
  10861. #endif
  10862. #ifdef __DECC
  10863.     makestr(&(optlist[noptlist++]),"__DECC");
  10864. #ifdef __DECC_VER
  10865.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  10866.     makestr(&(optlist[noptlist++]),line);
  10867. #endif /* __DECC_VER */
  10868. #endif /* __DECC */
  10869. #ifdef __CRTL_VER
  10870.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  10871.     makestr(&(optlist[noptlist++]),line);
  10872. #endif /* __CRTL_VER */
  10873. #ifdef __GNUC__                         /* gcc in ansi mode */
  10874.     makestr(&(optlist[noptlist++]),"__GNUC__");
  10875. #endif
  10876. #ifdef GNUC                             /* gcc in traditional mode */
  10877.     makestr(&(optlist[noptlist++]),"GNUC");
  10878. #endif
  10879. #ifdef __EGCS__                         /* egcs in ansi mode */
  10880.     makestr(&(optlist[noptlist++]),"__EGCS__");
  10881. #endif
  10882. #ifdef __egcs__                         /* egcs in ansi mode */
  10883.     makestr(&(optlist[noptlist++]),"__egcs__");
  10884. #endif
  10885. #ifdef __WATCOMC__
  10886.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  10887. #endif
  10888. #ifdef CK_ANSIC
  10889.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  10890. #endif
  10891. #ifdef CK_ANSILIBS
  10892.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  10893. #endif
  10894. #ifdef CKCONINTB4CB
  10895.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  10896. #endif /* CKCONINTB4CB */
  10897. #ifdef NOTERMCAP
  10898.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  10899. #endif /* NOTERMCAP */
  10900. #ifdef __GLIBC__
  10901.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  10902. #endif
  10903. #ifdef _SC_JOB_CONTROL
  10904.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  10905. #endif
  10906. #ifdef _POSIX_JOB_CONTROL
  10907.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  10908. #endif
  10909. #ifdef SIG_I
  10910.     makestr(&(optlist[noptlist++]),"SIG_I");
  10911. #endif /* SIG_I */
  10912. #ifdef SIG_V
  10913.     makestr(&(optlist[noptlist++]),"SIG_V");
  10914. #endif /* SIG_V */
  10915. #ifdef CK_POSIX_SIG
  10916.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  10917. #endif
  10918. #ifdef SVR3JC
  10919.     makestr(&(optlist[noptlist++]),"SVR3JC");
  10920. #endif
  10921. #ifdef _386BSD
  10922.     makestr(&(optlist[noptlist++]),"_386BSD");
  10923. #endif
  10924. #ifdef _BSD
  10925.     makestr(&(optlist[noptlist++]),"_BSD");
  10926. #endif
  10927. #ifdef USE_MEMCPY
  10928.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  10929. #endif /* USE_MEMCPY */
  10930. #ifdef USE_LSTAT
  10931.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  10932. #endif /* USE_LSTAT */
  10933. #ifdef TERMIOX
  10934.     makestr(&(optlist[noptlist++]),"TERMIOX");
  10935. #endif /* TERMIOX */
  10936. #ifdef STERMIOX
  10937.     makestr(&(optlist[noptlist++]),"STERMIOX");
  10938. #endif /* STERMIOX */
  10939. #ifdef CK_CURSES
  10940.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  10941. #endif /* CK_CURSES */
  10942. #ifdef CK_NEWTERM
  10943.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  10944. #endif /* CK_NEWTERM */
  10945. #ifdef CK_WREFRESH
  10946.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  10947. #endif /* CK_WREFRESH */
  10948. #ifdef CK_PCT_BAR
  10949.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  10950. #endif /* CK_PCT_BAR */
  10951. #ifdef CK_DTRCD
  10952.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  10953. #endif /* CK_DTRCD */
  10954. #ifdef CK_DTRCTS
  10955.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  10956. #endif /* CK_DTRCTS */
  10957. #ifdef CK_RTSCTS
  10958.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  10959. #endif /* CK_RTSCTS */
  10960. #ifdef POSIX_CRTSCTS
  10961.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  10962. #endif /* POSIX_CRTSCTS */
  10963. #ifdef FIXCRTSCTS
  10964.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  10965. #endif /* FIXCRTSCTS */
  10966. #ifdef HWPARITY
  10967.     makestr(&(optlist[noptlist++]),"HWPARITY");
  10968. #endif /* HWPARITY */
  10969. #ifdef CK_SYSINI
  10970. #ifdef CK_INI_A
  10971.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  10972.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10973.     makestr(&(optlist[noptlist++]),line);
  10974. #else
  10975. #ifdef CK_INI_B
  10976.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  10977.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10978.     makestr(&(optlist[noptlist++]),line);
  10979. #else
  10980.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  10981. #endif /* CK_INI_B */
  10982. #endif /* CK_INI_A */
  10983. #endif /* CK_DSYSINI */
  10984. #ifdef CK_DSYSINI
  10985.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  10986. #endif /* CK_DSYSINI */
  10987. #ifdef CK_TTGWSIZ
  10988.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  10989. #endif /* CK_TTGWSIZ */
  10990. #ifdef CK_NAWS
  10991.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  10992. #endif /* CK_NAWS */
  10993. #ifdef MDMHUP
  10994.     makestr(&(optlist[noptlist++]),"MDMHUP");
  10995. #endif /* MDMHUP */
  10996. #ifdef HUP_CLOSE_POSIX
  10997.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  10998. #endif /* HUP_CLOSE_POSIX */
  10999. #ifdef NO_HUP_CLOSE_POSIX
  11000.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  11001. #endif /* NO_HUP_CLOSE_POSIX */
  11002. #ifdef DCMDBUF
  11003.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  11004. #endif /* DCMDBUF */
  11005. #ifdef CK_RECALL
  11006.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  11007. #endif /* CK_RECALL */
  11008. #ifdef BROWSER
  11009.     makestr(&(optlist[noptlist++]),"BROWSER");
  11010. #endif /* BROWSER */
  11011. #ifdef CLSOPN
  11012.     makestr(&(optlist[noptlist++]),"CLSOPN");
  11013. #endif /* CLSOPN */
  11014. #ifdef STRATUS
  11015.     makestr(&(optlist[noptlist++]),"STRATUS");
  11016. #endif /* STRATUS */
  11017. #ifdef __VOS__
  11018.     makestr(&(optlist[noptlist++]),"__VOS__");
  11019. #endif /* __VOS__ */
  11020. #ifdef STRATUSX25
  11021.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  11022. #endif /* STRATUSX25 */
  11023. #ifdef OS2MOUSE
  11024.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  11025. #endif /* OS2MOUSE */
  11026. #ifdef CK_REXX
  11027.     makestr(&(optlist[noptlist++]),"CK_REXX");
  11028. #endif /* CK_REXX */
  11029. #ifdef CK_TIMERS
  11030.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  11031. #endif /* CK_TIMERS */
  11032. #ifdef TTSPDLIST
  11033.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  11034. #endif /* TTSPDLIST */
  11035. #ifdef CK_PERMS
  11036.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  11037. #endif /* CK_PERMS */
  11038. #ifdef CKTUNING
  11039.     makestr(&(optlist[noptlist++]),"CKTUNING");
  11040. #endif /* CKTUNING */
  11041. #ifdef NEWFTP
  11042.     makestr(&(optlist[noptlist++]),"NEWFTP");
  11043. #endif /* NEWFTP */
  11044. #ifdef SYSFTP
  11045.     makestr(&(optlist[noptlist++]),"SYSFTP");
  11046. #endif /* SYSFTP */
  11047. #ifdef NOFTP
  11048.     makestr(&(optlist[noptlist++]),"NOFTP");
  11049. #endif /* NOFTP */
  11050. #ifdef CKHTTP
  11051.     makestr(&(optlist[noptlist++]),"CKHTTP");
  11052. #endif /* CKHTTP */
  11053. #ifdef NOHTTP
  11054.     makestr(&(optlist[noptlist++]),"NOHTTP");
  11055. #endif /* NOHTTP */
  11056. #ifdef CKROOT
  11057.     makestr(&(optlist[noptlist++]),"CKROOT");
  11058. #endif /* CKROOT */
  11059. #ifdef CKREALPATH
  11060.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  11061. #endif /* CKREALPATH */
  11062. #ifdef STREAMING
  11063.     makestr(&(optlist[noptlist++]),"STREAMING");
  11064. #endif /* STREAMING */
  11065. #ifdef UNPREFIXZERO
  11066.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11067. #endif /* UNPREFIXZERO */
  11068. #ifdef CKREGEX
  11069.     makestr(&(optlist[noptlist++]),"CKREGEX");
  11070. #endif /* CKREGEX */
  11071. #ifdef ZXREWIND
  11072.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  11073. #endif /* ZXREWIND */
  11074. #ifdef CKSYSLOG
  11075.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11076. #endif /* CKSYSLOG */
  11077. #ifdef SYSLOGLEVEL
  11078.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11079.     makestr(&(optlist[noptlist++]),line);
  11080. #endif /* SYSLOGLEVEL */
  11081. #ifdef NOSEXP
  11082.     makestr(&(optlist[noptlist++]),"NOSEXP");
  11083. #endif /* NOSEXP */
  11084. #ifdef CKLEARN
  11085.     makestr(&(optlist[noptlist++]),"CKLEARN");
  11086. #else
  11087. #ifdef NOLOEARN
  11088.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  11089. #endif /* NOLOEARN */
  11090. #endif /* CKLEARN */
  11091. #ifdef NOFLOAT
  11092.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  11093. #else
  11094. #ifdef FNFLOAT
  11095.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  11096. #endif /* FNFLOAT */
  11097. #ifdef CKFLOAT
  11098. #ifdef GFTIMER
  11099.     makestr(&(optlist[noptlist++]),"GFTIMER");
  11100. #endif /* GFTIMER */
  11101. #ifdef CKFLOAT_S
  11102.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11103.     makestr(&(optlist[noptlist++]),line);
  11104. #else
  11105.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  11106. #endif /* CKFLOAT_S */
  11107. #endif /* CKFLOAT */
  11108. #endif /* NOFLOAT */
  11109.  
  11110. #ifdef SSH
  11111.     makestr(&(optlist[noptlist++]),"SSH");
  11112. #endif /* SSH */
  11113. #ifdef NETDLL
  11114.     makestr(&(optlist[noptlist++]),"NETDLL");
  11115. #endif /* NETDLL */
  11116. #ifdef NETFILE
  11117.     makestr(&(optlist[noptlist++]),"NETFILE");
  11118. #endif /* NETFILE */
  11119. #ifdef CK_TAPI
  11120.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  11121. #endif /* CK_TAPI */
  11122. #ifdef CK_SSL
  11123.     makestr(&(optlist[noptlist++]),"CK_SSL");
  11124. #endif /* CK_SSL */
  11125.  
  11126.     debug(F101,"initoptlist noptlist","",noptlist);
  11127.     sh_sort(optlist,NULL,noptlist,0,0,0);
  11128. }
  11129.  
  11130. int
  11131. shofea() {
  11132.     int i;
  11133.     int flag = 0;
  11134.     int lines = 1;
  11135. #ifdef FNFLOAT
  11136.     extern int fp_digits, fp_rounding;
  11137. #endif /* FNFLOAT */
  11138.     extern int byteorder;
  11139.     printf("%s\n",versio);
  11140.     if (inserver)
  11141.       return(1);
  11142.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11143.     initoptlist();
  11144.     debug(F101,"shofea noptlist","",noptlist);
  11145. #ifdef OS2
  11146. #ifdef NT
  11147. #ifdef _M_ALPHA
  11148.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11149. #else /* _M_ALPHA */
  11150. #ifdef _M_PPC
  11151.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11152. #else /* _M_PPC */
  11153. #ifdef _M_MRX000
  11154.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11155. #else /* _M_MRX000 */
  11156. #ifdef _M_IX86
  11157.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11158. #else /* _M_IX86 */
  11159.     UNKNOWN WINDOWS PLATFORM
  11160. #endif /* _M_IX86 */
  11161. #endif /* _M_MRX000 */
  11162. #endif /* _M_PPC */
  11163. #endif /* _M_ALPHA */
  11164. #else /* NT */
  11165. #ifdef M_I286
  11166.     printf("IBM OS/2 16-bit.\n");
  11167. #else
  11168.     printf("IBM OS/2 32-bit.\n");
  11169. #endif /* M_I286 */
  11170. #endif /* NT */
  11171.     lines++;
  11172. #endif /* OS2 */
  11173.     printf("\n");
  11174.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11175.     printf("Major optional features included:\n");
  11176.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11177.  
  11178. #ifdef NETCONN
  11179.     printf(" Network support (type SHOW NET for further info)\n");
  11180.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11181. #ifdef IKS_OPTION
  11182.     printf(" Telnet Kermit Option\n");
  11183.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11184. #endif /* IKS_OPTION */
  11185. #ifdef CK_AUTHENTICATION
  11186.     printf(" Telnet Authentication Option\n");
  11187.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11188. #ifdef CK_KERBEROS
  11189. #ifdef KRB4
  11190. #ifdef KRB5
  11191.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11192.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11193. #else /* KRB5 */
  11194.     printf(" Kerberos(TM) IV authentication\n");
  11195.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11196. #endif /* KRB5 */
  11197. #else /* KRB4 */
  11198. #ifdef KRB5
  11199.     printf(" Kerberos(TM) V authentication\n");
  11200.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11201. #endif /* KRB5 */
  11202. #endif /* KRB4 */
  11203. #endif /* CK_KERBEROS */
  11204. #ifdef CK_SRP
  11205.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11206.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11207. #endif /* CK_SRP */
  11208. #ifdef CK_SSL
  11209.     printf(" Secure Sockets Layer (SSL)\n");
  11210.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11211.     printf(" Transport Layer Security (TLS)\n");
  11212.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11213. #endif /* CK_SSL */
  11214. #ifdef SSHBUILTIN
  11215.     printf(" Secure Shell (SSH) [internal]\n");
  11216.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11217. #endif /* SSHBUILTIN */
  11218. #ifdef SSHCMD
  11219.     printf(" Secure Shell (SSH) [external]\n");
  11220.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11221. #endif /* SSHCMD */
  11222. #ifdef CK_ENCRYPTION
  11223.     printf(" Telnet Encryption Option\n");
  11224.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11225. #ifdef CK_DES
  11226.     printf(" DES Encryption\n");
  11227.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11228. #endif /* CK_DES */
  11229. #ifdef CK_CAST
  11230.     printf(" CAST Encryption\n");
  11231.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11232. #endif /* CK_CAST */
  11233. #endif /* CK_ENCRYPTION */
  11234. #endif /* CK_AUTHENTICATION */
  11235. #ifdef CK_FORWARD_X
  11236.     printf(" X Windows forwarding\n");
  11237.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11238. #endif /* CK_FORWARD_X */
  11239. #ifdef TN_COMPORT
  11240.     printf(" Telnet Remote Com Port Control Option\n");
  11241.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11242. #endif /* TN_COMPORT */
  11243. #ifdef CK_SOCKS
  11244. #ifdef CK_SOCKS5
  11245.     printf(" SOCKS 5\n");
  11246.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11247. #else /* CK_SOCKS5 */
  11248.     printf(" SOCKS 4\n");
  11249.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11250. #endif /* CK_SOCKS5 */
  11251. #endif /* CK_SOCKS */
  11252. #ifdef NEWFTP
  11253.     printf(" Built-in FTP client\n");
  11254.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11255. #endif /* NEWFTP */
  11256. #ifdef CKHTTP
  11257.     printf(" Built-in HTTP client\n");
  11258.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11259. #endif /* CKHTTP */
  11260. #endif /* NETCONN */
  11261.  
  11262. #ifdef CK_RTSCTS
  11263.     printf(" Hardware flow control\n");
  11264.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11265. #endif /* CK_RTSCTS */
  11266.  
  11267. #ifdef CK_XYZ
  11268. #ifdef XYZ_INTERNAL
  11269.     printf(" Built-in XYZMODEM protocols\n");
  11270. #else
  11271.     printf(" External XYZMODEM protocol support\n");
  11272. #endif /* XYZ_INTERNAL */
  11273.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11274. #endif /* CK_XYZ */
  11275.  
  11276. #ifndef NOCSETS
  11277.     printf(" Latin-1 (West European) character-set translation\n");
  11278.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11279. #ifdef LATIN2
  11280.     printf(" Latin-2 (East European) character-set translation\n");
  11281.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11282. #endif /* LATIN2 */
  11283. #ifdef CYRILLIC
  11284.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11285.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11286. #endif /* CYRILLIC */
  11287. #ifdef GREEK
  11288.     printf(" Greek character-set translation\n");
  11289.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11290. #endif /* GREEK */
  11291. #ifdef HEBREW
  11292.     printf(" Hebrew character-set translation\n");
  11293.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11294. #endif /* HEBREW */
  11295. #ifdef KANJI
  11296.     printf(" Japanese character-set translation\n");
  11297.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11298. #endif /* KANJI */
  11299. #ifdef UNICODE
  11300.     printf(" Unicode character-set translation\n");
  11301.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11302. #endif /* UNICODE */
  11303. #ifdef CKOUNI
  11304.     if (isunicode())
  11305.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11306.     else
  11307.       printf(" Unicode translation for Terminal Character-Sets\n");
  11308.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11309. #endif /* CKOUNI */
  11310. #endif /* NOCSETS */
  11311.  
  11312. #ifdef NETPTY
  11313.     printf(" Pseudoterminal control\n");
  11314.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11315. #endif /* NETPTY */
  11316.  
  11317. #ifdef CK_REDIR
  11318.     printf(" REDIRECT command\n");
  11319.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11320. #endif /* CK_REDIR */
  11321.  
  11322. #ifdef CK_RESEND
  11323.     printf(" RESEND command\n");
  11324.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11325. #endif /* CK_RESEND */
  11326.  
  11327. #ifndef NOXFER
  11328. #ifdef CK_CURSES
  11329.     printf(" Fullscreen file transfer display\n");
  11330.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11331. #endif /* CK_CURSES */
  11332. #endif /* NOXFER */
  11333.  
  11334. #ifdef CK_SPEED
  11335.     printf(" Control-character unprefixing\n");
  11336.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11337. #endif /* CK_SPEED */
  11338.  
  11339. #ifdef STREAMING
  11340.     printf(" Streaming\n");
  11341.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11342. #endif /* STREAMING */
  11343.  
  11344. #ifdef CK_AUTODL
  11345.     printf(" Autodownload\n");
  11346.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11347. #endif /* CK_AUTODL */
  11348.  
  11349. #ifdef OS2MOUSE
  11350.     printf(" Mouse support\n");
  11351.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11352. #endif /* OS2MOUSE */
  11353.  
  11354. #ifdef CK_REXX
  11355.     printf(" REXX script language interface\n");
  11356.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11357. #endif /* CK_REXX */
  11358.  
  11359. #ifdef IKSD
  11360. #ifdef CK_LOGIN
  11361.     printf(" Internet Kermit Service with user login support\n");
  11362. #else /* CK_LOGIN */
  11363.     printf(" Internet Kermit Service without user login support\n");
  11364. #endif /* CK_LOGIN */
  11365.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11366. #endif /* IKSD */
  11367.  
  11368.     printf("\n");
  11369.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11370.     printf("Major optional features not included:\n");
  11371.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11372.  
  11373. #ifdef NOXFER
  11374.     printf(" No file-transfer protocols\n");
  11375.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11376.     flag = 1;
  11377. #else
  11378. #ifndef CK_CURSES
  11379. #ifndef MAC
  11380.     printf(" No fullscreen file transfer display\n");
  11381.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11382.     flag = 1;
  11383. #endif /* MAC */
  11384. #endif /* CK_CURSES */
  11385.  
  11386. #ifdef NOSERVER
  11387.     printf(" No server mode\n");
  11388.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11389.     flag = 1;
  11390. #endif /* NOSERVER */
  11391.  
  11392. #ifndef CK_SPEED
  11393.     printf(" No control-character unprefixing\n");
  11394.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11395.     flag = 1;
  11396. #endif /* CK_SPEED */
  11397.  
  11398. #ifndef STREAMING
  11399.     printf(" No streaming\n");
  11400.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11401.     flag = 1;
  11402. #endif /* STREAMING */
  11403.  
  11404. #ifndef CK_AUTODL
  11405.     printf(" No autodownload\n");
  11406.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11407.     flag = 1;
  11408. #endif /* CK_AUTODL */
  11409.  
  11410. #ifndef CK_XYZ
  11411.     printf(" No built-in XYZMODEM protocols\n");
  11412.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11413.     flag = 1;
  11414. #endif /* CK_XYZ */
  11415.  
  11416. #ifdef NOTLOG
  11417.     printf(" No transaction log\n");
  11418.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11419.     flag = 1;
  11420. #endif /* NOTLOG */
  11421. #endif /* NOXFER */
  11422.  
  11423. #ifdef NODEBUG
  11424.     printf(" No debugging\n");
  11425.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11426.     flag = 1;
  11427. #endif /* NODEBUG */
  11428.  
  11429. #ifdef NOHELP
  11430.     printf(" No built-in help\n");
  11431.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11432.     flag = 1;
  11433. #endif /* NOHELP */
  11434.  
  11435. #ifdef NOLOCAL
  11436.     printf(" No making connections\n");
  11437.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11438.     flag = 1;
  11439. #else
  11440. #ifndef NETCONN
  11441.     printf(" No network support\n");
  11442.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11443.     flag = 1;
  11444. #else /* NETCONN */
  11445. #ifndef IKS_OPTION
  11446.     printf(" No Telnet Kermit Option\n");
  11447.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11448.     flag = 1;
  11449. #endif /* IKS_OPTION */
  11450. #endif /* NETCONN */
  11451.  
  11452. #ifdef NOSSH
  11453.     printf(" No Secure Shell (SSH)\n");
  11454.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11455. #endif /* NOSSH */
  11456. #ifndef CK_AUTHENTICATION
  11457.     printf(" No Kerberos(TM) authentication\n");
  11458.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11459.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11460.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11461.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11462.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11463.     printf(" No Transport Layer Security (TLS) protocol\n");
  11464.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11465.     printf(" No encryption\n");
  11466.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11467.     flag = 1;
  11468. #else /* CK_AUTHENTICATION */
  11469. #ifndef CK_KERBEROS
  11470.     printf(" No Kerberos(TM) authentication\n");
  11471.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11472.     flag = 1;
  11473. #else /* CK_KERBEROS */
  11474. #ifndef KRB4
  11475.     printf(" No Kerberos(TM) IV authentication\n");
  11476.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11477.     flag = 1;
  11478. #endif /* KRB4 */
  11479. #ifndef KRB5
  11480.     printf(" No Kerberos(TM) V authentication\n");
  11481.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11482.     flag = 1;
  11483. #endif /* KRB5 */
  11484. #endif /* CK_KERBEROS */
  11485. #ifndef CK_SRP
  11486.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11487.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11488.     flag = 1;
  11489. #endif /* CK_SRP */
  11490. #ifndef CK_SSL
  11491.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11492.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11493.     printf(" No Transport Layer Security (TLS) protocol\n");
  11494.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11495.     flag = 1;
  11496. #endif /* CK_SSL */
  11497. #ifndef CK_ENCRYPTION
  11498.     printf(" No encryption\n");
  11499.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11500.     flag = 1;
  11501. #else /* CK_ENCRYPTION */
  11502. #ifndef OS2
  11503. #ifndef CK_DES
  11504.     printf(" No DES encryption\n");
  11505.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11506.     flag = 1;
  11507. #endif /* CK_DES */
  11508. #ifndef CK_CAST
  11509.     printf(" No CAST encryption\n");
  11510.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11511.     flag = 1;
  11512. #endif /* CK_CAST */
  11513. #endif /* OS2 */
  11514. #endif /* CK_ENCRYPTION */
  11515. #endif /* CK_AUTHENTICATION */
  11516. #ifndef CK_FORWARD_X
  11517.     printf(" No X Windows forwarding\n");
  11518.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11519. #endif /* CK_FORWARD_X */
  11520. #ifndef TN_COMPORT
  11521.     printf(" No Telnet Remote Com Port Control Option\n");
  11522.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11523. #endif /* TN_COMPORT */
  11524. #ifndef CK_SOCKS
  11525.     printf(" No SOCKS\n");
  11526.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11527. #endif /* CK_SOCKS */
  11528. #ifndef NEWFTP
  11529.     printf(" No built-in FTP client\n");
  11530.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11531. #endif /* NEWFTP */
  11532. #ifdef NOHTTP
  11533.     printf(" No built-in HTTP client\n");
  11534.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11535. #endif /* NOHTTP */
  11536.  
  11537. #ifdef NODIAL
  11538.     printf(" No DIAL command\n");
  11539.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11540.     flag = 1;
  11541. #else
  11542. #ifdef MINIDIAL
  11543.     printf(" Support for most modem types excluded\n");
  11544.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11545.     flag = 1;
  11546. #endif /* MINIDIAL */
  11547. #endif /* NODIAL */
  11548. #endif /* NOLOCAL */
  11549.  
  11550. #ifndef CK_RTSCTS
  11551. #ifndef MAC
  11552.     printf(" No hardware flow control\n");
  11553.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11554.     flag = 1;
  11555. #endif /* MAC */
  11556. #endif /* CK_RTSCTS */
  11557.  
  11558. #ifdef NOXMIT
  11559.     printf(" No TRANSMIT command\n");
  11560.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11561.     flag = 1;
  11562. #endif /* NOXMIT */
  11563.  
  11564. #ifdef NOSCRIPT
  11565.     printf(" No SCRIPT command\n");
  11566.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11567.     flag = 1;
  11568. #endif /* NOSCRIPT */
  11569.  
  11570. #ifdef NOSPL
  11571.     printf(" No script programming features\n");
  11572.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11573.     flag = 1;
  11574. #endif /* NOSPL */
  11575.  
  11576. #ifdef NOCSETS
  11577.     printf(" No character-set translation\n");
  11578.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11579.     flag = 1;
  11580. #else
  11581.  
  11582. #ifndef LATIN2
  11583.     printf(" No Latin-2 character-set translation\n");
  11584.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11585.     flag = 1;
  11586. #endif /* LATIN2 */
  11587.  
  11588. #ifdef NOGREEK
  11589.     printf(" No Greek character-set translation\n");
  11590.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11591.     flag = 1;
  11592. #endif /* NOGREEK */
  11593.  
  11594. #ifdef NOHEBREW
  11595.     printf(" No Hebrew character-set translation\n");
  11596.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11597.     flag = 1;
  11598. #endif /* NOHEBREW */
  11599.  
  11600. #ifdef NOUNICODE
  11601.     printf(" No Unicode character-set translation\n");
  11602.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11603.     flag = 1;
  11604. #endif /* NOUNICODE */
  11605.  
  11606. #ifdef NOCYRIL
  11607.     printf(" No Cyrillic character-set translation\n");
  11608.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11609.     flag = 1;
  11610. #endif /* NOCYRIL */
  11611.  
  11612. #ifndef KANJI
  11613.     printf(" No Kanji character-set translation\n");
  11614.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11615.     flag = 1;
  11616. #endif /* KANJI */
  11617. #endif /* NOCSETS */
  11618.  
  11619. #ifdef NOCMDL
  11620.     printf(" No command-line arguments\n");
  11621.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11622.     flag = 1;
  11623. #endif /* NOCMDL */
  11624.  
  11625. #ifdef NOPUSH
  11626.     printf(" No escape to system\n");
  11627.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11628.     flag = 1;
  11629. #endif /* NOPUSH */
  11630.  
  11631. #ifdef NOJC
  11632. #ifdef UNIX
  11633.     printf(" No UNIX job control\n");
  11634.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11635.     flag = 1;
  11636. #endif /* UNIX */
  11637. #endif /* NOJC */
  11638.  
  11639. #ifdef NOSETKEY
  11640.     printf(" No SET KEY command\n");
  11641.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11642.     flag = 1;
  11643. #endif /* NOSETKEY */
  11644.  
  11645. #ifndef CK_REDIR
  11646.     printf(" No REDIRECT or PIPE command\n");
  11647.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11648.     flag = 1;
  11649. #endif /* CK_REDIR */
  11650.  
  11651. #ifdef UNIX
  11652. #ifndef NETPTY
  11653.     printf(" No pseudoterminal control\n");
  11654.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11655.     flag = 1;
  11656. #endif /* NETPTY */
  11657. #endif /* UNIX */
  11658.  
  11659. #ifndef CK_RESEND
  11660.     printf(" No RESEND command\n");
  11661.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11662.     flag = 1;
  11663. #endif /* CK_RESEND */
  11664.  
  11665. #ifdef OS2
  11666. #ifdef __32BIT__
  11667. #ifndef OS2MOUSE
  11668.     printf(" No Mouse support\n");
  11669.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11670.     flag = 1;
  11671. #endif /* __32BIT__ */
  11672. #endif /* OS2 */
  11673. #endif /* OS2MOUSE */
  11674.  
  11675. #ifdef OS2
  11676. #ifndef NT
  11677. #ifndef CK_REXX
  11678.     printf(" No REXX script language interface\n");
  11679.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11680.     flag = 1;
  11681. #endif /* CK_REXX */
  11682. #endif /* NT */
  11683. #endif /* OS2 */
  11684.  
  11685. #ifndef IKSD
  11686.     printf(" No Internet Kermit Service\n");
  11687.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11688.     flag = 1;
  11689. #endif /* IKSD */
  11690.  
  11691.     if (flag == 0) {
  11692.         printf(" None\n");
  11693.         if (++lines > cmd_rows - 3)
  11694.           { if (!askmore()) return(1); else lines = 0; }
  11695.     }
  11696.     printf("\n");
  11697.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11698.  
  11699. #ifdef CK_UTSNAME
  11700.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11701.     printf("Host info:\n");
  11702.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11703.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  11704.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11705.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  11706.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11707.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  11708.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11709.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  11710.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11711.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  11712.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11713.     printf("\n");
  11714.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11715. #endif /* CK_UTSNAME */
  11716.  
  11717. /*
  11718.   Print compile-time (-D) options, as well as C preprocessor
  11719.   predefined symbols that might affect us...
  11720. */
  11721. #ifdef KTARGET
  11722.     {
  11723.         char * s;                       /* Makefile target */
  11724.         s = KTARGET;
  11725.         if (!s) s = "";
  11726.         if (!*s) s = "(unknown)";
  11727.         printf("\n");
  11728.         if (++lines > cmd_rows - 3) {
  11729.             if (!askmore()) return(1); else lines = 0;
  11730.         }
  11731.         printf("Target: %s\n", s);
  11732.         if (++lines > cmd_rows - 3) {
  11733.             if (!askmore()) return(1); else lines = 0;
  11734.         }
  11735.     }
  11736. #endif /* KTARGET */
  11737.  
  11738. #ifdef __VERSION__
  11739. #ifdef __GNUC__
  11740.     printf("GCC version: %s\n", __VERSION__);
  11741. #else
  11742.     printf("Compiler version: %s\n", __VERSION__);
  11743. #endif /* __GNUC__ */
  11744.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11745. #endif /* __VERSION__ */
  11746.  
  11747. #ifdef __DATE__                         /* GNU and other ANSI */
  11748. #ifdef __TIME__
  11749.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  11750. #else
  11751.     printf("Compiled %s, options:\n", __DATE__);
  11752. #endif /* __TIME__ */
  11753. #else /* !__DATE__ */
  11754.     printf("Compiler options:\n");
  11755. #endif /* __DATE__ */
  11756.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11757.  
  11758.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  11759.       if (!prtopt(&lines,optlist[i]))
  11760.         return(0);
  11761.  
  11762.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11763.  
  11764. /* Sizes of data types */
  11765.  
  11766.     ckmakmsg(line,
  11767.              LINBUFSIZ,
  11768.              "byte order: ",
  11769.              byteorder ? "little" : "big",
  11770.              " endian",
  11771.              NULL
  11772.              );
  11773.     if (!prtopt(&lines,line)) return(0);
  11774.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11775.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  11776.     if (!prtopt(&lines,line)) return(0);
  11777.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  11778.     if (!prtopt(&lines,line)) return(0);
  11779.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  11780.     if (!prtopt(&lines,line)) return(0);
  11781.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  11782.     if (!prtopt(&lines,line)) return(0);
  11783.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  11784.     if (!prtopt(&lines,line)) return(0);
  11785. #ifdef LONG_MAX
  11786.     sprintf(line,"LONG_MAX=%d",LONG_MAX); /* SAFE */
  11787. #endif /* LONG_MAX */
  11788. #ifdef CKFLOAT
  11789.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  11790.     if (!prtopt(&lines,line)) return(0);
  11791.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  11792.     if (!prtopt(&lines,line)) return(0);
  11793. #ifdef FNFLOAT
  11794.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11795.     if (!prtopt(&lines,"floating-point:")) return(0);
  11796.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  11797.     if (!prtopt(&lines,line)) return(0);
  11798.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  11799.     if (!prtopt(&lines,line)) return(0);
  11800. #endif /* FNFLOAT */
  11801. #endif /* CKFLOAT */
  11802.  
  11803.     prtopt(&lines,"");
  11804.     return(0);
  11805. }
  11806. #endif /* NOSHOW */
  11807. #endif /* NOICP */
  11808.