home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ck208 / cku208.tar.gz / cku208.tar / ckuus5.c < prev    next >
C/C++ Source or Header  |  2003-01-16  |  374KB  |  11,788 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, suspend,
  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;
  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.         if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1909. #endif /* NODQMACRO */
  1910.         if (*s == ',' && pp <= 0 && kp <= 0
  1911. #ifndef NODQMACRO
  1912.             && dq == 0
  1913. #endif /* NODQMACRO */
  1914.             ) {
  1915.             macp[maclvl]++;             /* Comma not in {} or () */
  1916.             /* debug(F110,"next cmd",s,0); */
  1917.             kp = pp = 0;                /* so we have the next command */
  1918.             break;
  1919.         }
  1920.     }                                   /* Reached end. */
  1921. #ifdef COMMENT
  1922.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1923.     *s = NUL;
  1924. #endif /* COMMENT */
  1925.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1926.         /* debug(F100,"getncm eom","",0); */
  1927.         popclvl();                      /* pop command level. */
  1928.         return(-1);
  1929.     } else {                            /* otherwise, tack CR onto end */
  1930.         *s++ = CR;
  1931.         *s = '\0';
  1932.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  1933.           printf("%s\n",s2);
  1934.     }
  1935.     return(0);
  1936. }
  1937.  
  1938. /*  D O M A C  --  Define and then execute a macro */
  1939.  
  1940. int
  1941. domac(name, def, flags) char *name, *def; int flags; {
  1942.     int x, m;
  1943. #ifndef NOLOCAL
  1944. #ifdef OS2
  1945.     extern int term_io;
  1946.     int term_io_sav = term_io;
  1947.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  1948. #endif /* OS2 */
  1949. #endif /* NOLOCAL */
  1950.     m = maclvl;                         /* Current macro stack level */
  1951.     x = addmac(name, def);              /* Define a new macro */
  1952.     if (x > -1) {                       /* If successful, */
  1953.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  1954.         while (maclvl > m) {            /* Keep going till done with it, */
  1955.             debug(F101,"domac loop maclvl 1","",maclvl);
  1956.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  1957.             debug(F101,"domac loop maclvl 2","",maclvl);
  1958.             if (sstate) proto();        /* including protocol commands. */
  1959.         }
  1960.         debug(F101,"domac loop exit maclvl","",maclvl);
  1961.     }
  1962. #ifndef NOLOCAL
  1963. #ifdef OS2
  1964.     term_io = term_io_sav;
  1965. #endif /* OS2 */
  1966. #endif /* NOLOCAL */
  1967.     return(success);
  1968. }
  1969. #endif /* NOSPL */
  1970.  
  1971. /*
  1972.   G E T N C T
  1973.  
  1974.   Get next command from TAKE (command) file.
  1975.  
  1976.   Call with:
  1977.    s     Pointer to buffer to read into
  1978.    n     Length of buffer
  1979.    f     File descriptor of file to read from
  1980.    flag  0 == keep line terminator on and allow continuation
  1981.          1 == discard line terminator and don't allow continuation
  1982.  
  1983.   Call with flag == 0 to read a command from a TAKE file;
  1984.   Call with flag != 0 to read a line from a dialing or network directory.
  1985.  
  1986.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  1987.   If flag == 0, continued lines are combined into one line.  A continued line
  1988.   is one that ends in hypen, or any line in a "block", which starts with "{"
  1989.   at the end of a line and ends with a matching "}" at the beginning of a
  1990.   subsequent line; blocks may be nested.
  1991.  
  1992.   Returns:
  1993.    0 if a string was copied,
  1994.   -1 on EOF,
  1995.   -2 on malloc failure
  1996.   -3 if line is not properly terminated
  1997.   -4 if (possibly continued) line is too long.
  1998. */
  1999. static int lpxlen = 0;
  2000.  
  2001. int
  2002. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  2003.     int i = 0, len = 0, buflen = 0;
  2004.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  2005.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  2006.     char * prev = NULL;
  2007.     int bc = 0;                         /* Block counter */
  2008.  
  2009.     s2 = s;                             /* Remember original pointer */
  2010.     prev = s2;
  2011.     buflen = n;                         /* Remember original buffer length */
  2012.  
  2013.     if (n < 0)
  2014.       return(-2);
  2015.  
  2016.     /* Allocate a line buffer only if we don't have one that's big enough */
  2017.  
  2018.     debug(F111,"getnct",ckitoa(lpxlen),n);
  2019.  
  2020.     if (lpx && (n > lpxlen)) {          /* Have one already */
  2021.         debug(F101,"getnct new buffer","",lpxlen);
  2022.         free(lpx);                      /* But it's not big enough */
  2023.         lpx = NULL;                     /* Free current one */
  2024.         lpxlen = 0;
  2025.     }
  2026.     if (!lpx) {                         /* Get new one */
  2027.         if (!(lpx = (char *) malloc(n))) {
  2028.             debug(F101,"getnct malloc failure","",0);
  2029.             printf("?Memory allocation failure [getnct]\n");
  2030.             return(-2);
  2031.         }
  2032.         lpxlen = n;
  2033.     }
  2034.     lp2 = lpx;
  2035. #ifdef KLUDGE
  2036.     /* NOTE: No longer used as of 14 Aug 2000 */
  2037.     lp2++;
  2038. #endif /* KLUDGE */
  2039.  
  2040.     while (1) {                         /* Loop to read lines from file */
  2041.         debug(F101,"getnct while (1)","",n);
  2042.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  2043.             debug(F110,"getnct EOF",s2,0); /* EOF */
  2044.             free(lpx);                  /* Free temporary storage */
  2045.             lpx = NULL;
  2046.             *s = NUL;                   /* Make destination be empty */
  2047.             return(-1);                 /* Return failure code */
  2048.         }
  2049. #ifndef NODIAL
  2050.         if (flag)                       /* Count this line */
  2051.           dirline++;
  2052.         else
  2053. #endif /* NODIAL */
  2054.           tfline[tlevel]++;
  2055.         len = strlen(lp2) - 1;          /* Position of line terminator */
  2056.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  2057.             lp2[++len] = '\n';          /* that is not a newline */
  2058.             lp2[len] = NUL;
  2059.         }
  2060.         debug(F010,"getnct",lp2,0);
  2061.         if (len < 0)
  2062.           len = 0;
  2063.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2064.           printf("%3d. %s",             /* echo it this line. */
  2065. #ifndef NODIAL
  2066.                  flag ? dirline :
  2067. #endif /* NODIAL */
  2068.                  tfline[tlevel],
  2069.                  lp2
  2070.                  );
  2071.         lp3 = lp2;                      /* Working pointer */
  2072.         i = len;                        /* Get first nonwhitespace character */
  2073.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2074.             i--;
  2075.             lp3++;
  2076.         }
  2077.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2078.           continue;
  2079.  
  2080.         /* Isolate, remove, and check terminator */
  2081.  
  2082.         c = lp2[len];                   /* Value of line terminator */
  2083.         /* debug(F101,"getnct terminator","",c); */
  2084.         if (c < LF || c > CR) {         /* It's not a terminator */
  2085.             /* debug(F111,"getnct bad line",lp2,c); */
  2086.             if (feof(f) && len > 0 && len < n) {
  2087.                 /* Kludge Alert... */
  2088.                 if (!quiet)
  2089.                   printf("WARNING: Last line of %s lacks terminator\n",
  2090.                          s2 == cmdbuf ? "command file" : "directory file");
  2091.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2092.             } else {                    /* Something's wrong, fail. */
  2093.                 free(lpx);
  2094.                 lpx = NULL;
  2095.                 return(-3);
  2096.             }
  2097.         }
  2098.         /* Trim trailing whitespace */
  2099.  
  2100.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2101.           ;
  2102.         /* debug(F101,"getnct i","",i); */
  2103.         lp2[i+1] = NUL;                 /* Terminate the string */
  2104.         /* debug(F110,"getnct lp2",lp2,0); */
  2105.         lp = lp2;                       /* Make a working pointer */
  2106.  
  2107.         /* Remove trailing or full-line comment */
  2108.  
  2109.         while ((cc = *lp)) {
  2110.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2111.                 if (lp == lp2) {        /* First char on line */
  2112.                     *lp = NUL;
  2113.                     break;
  2114.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2115.                     lp--;
  2116.                     *lp = NUL;  /* Or preceded by whitespace */
  2117.                     break;
  2118.                 }
  2119.             }
  2120.             lp++;
  2121.         }
  2122.         if (lp > lp2)
  2123.           lp--;                         /* Back up over the NUL */
  2124.  
  2125.         /* Now trim any space that preceded the comment */
  2126.  
  2127.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2128.             *lp = NUL;
  2129.             if (lp <= lp2)
  2130.               break;
  2131.             lp--;
  2132.         }
  2133.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2134.  
  2135.         len = strlen(lp2);              /* Length after trimming */
  2136.  
  2137.         if (n - len < 2) {              /* Check remaining space */
  2138.             debug(F111,"getnct command too long",s2,buflen);
  2139.             printf("?Line too long, maximum length: %d.\n",buflen);
  2140.             free(lpx);
  2141.             return(-4);
  2142.         }
  2143.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2144.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2145.  
  2146. #ifdef COMMENT
  2147.         /* Line containing only whitespace and ,- */
  2148.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2149.           continue;
  2150. #endif /* COMMENT */
  2151.  
  2152. #ifdef KLUDGE
  2153. /*
  2154.   If it is a command and it begins with a token (like ! or .) that is not
  2155.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2156.   confused.
  2157. */
  2158.         if (s == s2 && !flag) {
  2159.             char *p = toktab;
  2160.             while (*p) {
  2161.                 if (*p == *lp3 && *(p+1) != SP) {
  2162.                     debug(F110,"getnct token",p,0);
  2163.                     *lp3-- = SP;
  2164.                     *lp3 = *p;
  2165.                     if (lp3 < lp2) {
  2166.                         lp2--;
  2167.                         len++;
  2168.                     }
  2169.                     break;
  2170.                 } else
  2171.                   p++;
  2172.             }
  2173.         }
  2174. #endif /* KLUDGE */
  2175.         lp = lp2;
  2176.  
  2177.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2178.           n--;                          /* accounting for length */
  2179.         s--;                            /* Back up over the NUL */
  2180.  
  2181.         /* Check whether this line is continued */
  2182.  
  2183.         if (flag)                       /* No line continuation when flag=1 */
  2184.           break;                        /* So break out of read-lines loop */
  2185.  
  2186. #ifdef COMMENT
  2187.         debug(F000,"getnct first char","",*lp3);
  2188.         debug(F000,"getnct last char","",ccl);
  2189.         debug(F000,"getnct next-to-last char","",ccx);
  2190. #endif /* COMMENT */
  2191.  
  2192.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2193.             bc--;                               /* Decrement block counter */
  2194.         }
  2195.  
  2196.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2197. #ifdef COMMENT
  2198.             /* Not supported as of C-Kermit 6.0 */
  2199.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2200. #endif /* COMMENT */
  2201.             ccl != '-'  &&              /* or line ends with dash */
  2202.             ccl != '{')                 /* or line ends with opening brace */
  2203.           break;                        /* None of those, we're done. */
  2204.  
  2205.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2206.           if (ccx == CMDQ)              /* But it's quoted */
  2207.             break;                      /* so ignore it */
  2208.  
  2209.         if (ccl == '{') {               /* Last char on line is '{'? */
  2210.             bc++;                       /* Count the block opener. */
  2211.         } else if (ccl == '-') {        /* Explicit continue? */
  2212.             char c, * ss;
  2213.             int state = 0, nn;
  2214.             s--;                        /* Yes, back up over terminators */
  2215.             n++;                        /* and over continuation character */
  2216.             nn = n;                     /* Save current count */
  2217.             ss = s;                     /* and pointer */
  2218.             s--;                        /* Back up over dash */
  2219.             n++;
  2220.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2221.                 n++;
  2222.                 c = *s--;
  2223.                 if (c <= SP)
  2224.                   continue;
  2225.                 if (c != ',' && c != '{')
  2226.                   break;
  2227.                 switch (state) {
  2228.                   case 0:               /* Looking for comma */
  2229.                     if (c == ',')
  2230.                       state = 1;
  2231.                     break;
  2232.                   case 1:               /* Looking for left brace */
  2233.                     if (c == '{') {
  2234.                         state = 2;
  2235.                         s += 2;
  2236.                         *s = NUL;
  2237.                         bc++;
  2238.                     }
  2239.                     break;
  2240.                 }
  2241.             }
  2242.             if (state != 2) { s = ss; n = nn; }
  2243.             *s = NUL;
  2244.         } else {                        /* None of those but (bc > 0) */
  2245.             lastcomma = s;
  2246.             *s++ = ',';                 /* and insert a comma */
  2247.             n--;
  2248.         }
  2249. #ifdef COMMENT
  2250.         debug(F101,"getnct bc","",bc);
  2251.         debug(F100,"getnct continued","",0);
  2252. #endif /* COMMENT */
  2253.  
  2254.         *s = NUL;
  2255.         prev = s;
  2256.  
  2257.     } /* read-lines while loop */
  2258.  
  2259.     if (lastcomma)
  2260.       *lastcomma = SP;
  2261.     if (!flag)                          /* Tack line terminator back on */
  2262.       *s++ = c;
  2263.     *s++ = NUL;                         /* Terminate the string */
  2264.     untab(s2);                          /* Done, convert tabs to spaces */
  2265. #ifdef DEBUG
  2266.     if (!flag) {
  2267.         debug(F010,"CMD(F)",s2,0);
  2268.     }
  2269. #endif /* DEBUG */
  2270.     free(lpx);                          /* Free temporary storage */
  2271.     return(0);                          /* Return success */
  2272. }
  2273.  
  2274. VOID
  2275. shostack() {                            /* Dump the command stack */
  2276.     int i;
  2277.     char *p;
  2278. #ifndef NOSPL
  2279.     for (i = cmdlvl; i > 0; i--) {
  2280.         if (cmdstk[i].src == CMD_TF) {
  2281.             p = tfnam[cmdstk[i].lvl];
  2282.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2283.               p = tmpbuf;
  2284.             printf(" %2d. File  : %s (line %d)\n",
  2285.                    i,
  2286.                    p,
  2287.                    tfline[cmdstk[i].lvl]
  2288.                    );
  2289.         } else if (cmdstk[i].src == CMD_MD) {
  2290.             char * m;
  2291.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2292.             if (i > 0) {                 /* Special handling for 2-level */
  2293.                 char *s;                 /* built-in macros... */
  2294.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2295.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2296.                     if (!strcmp(s,"_forx"))
  2297.                       m = "FOR";
  2298.                     else if (!strcmp(s,"_xif"))
  2299.                       m = "XIF";
  2300.                     else if (!strcmp(s,"_while"))
  2301.                       m = "WHILE";
  2302.                     else if (!strcmp(s,"_switx"))
  2303.                       m = "SWITCH";
  2304.                 }
  2305.             }
  2306.             printf(" %2d. Macro : %s\n",i,m);
  2307.         } else if (cmdstk[i].src == CMD_KB) {
  2308.             printf(" %2d. Prompt:\n",i);
  2309.         } else {
  2310.             printf(" %2d. ERROR : Command source unknown\n",i);
  2311.         }
  2312.     }
  2313. #else
  2314.     for (i = tlevel; i > -1; i--) {
  2315.         p = tfnam[i];
  2316.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2317.           p = tmpbuf;
  2318.         printf(" %2d. File  : %s (line %d)\n",
  2319.                i,
  2320.                p,
  2321.                tfline[i]
  2322.                );
  2323.     }
  2324. #endif /* NOSPL */
  2325.     if (i == 0)
  2326.       printf(" %2d. Prompt: (top level)\n",0);
  2327. }
  2328.  
  2329.  
  2330. /*  P A R S E R  --  Top-level interactive command parser.  */
  2331.  
  2332. /*
  2333.   Call with:
  2334.     m = 0 for normal behavior: keep parsing and executing commands
  2335.           until an action command is parsed, then return with a
  2336.           Kermit start-state as the value of this function.
  2337.     m = 1 to parse only one command, can also be used to call parser()
  2338.           recursively.
  2339.     m = 2 to read but do not execute one command.
  2340.   In all cases, parser() returns:
  2341.     0     if no Kermit protocol action required
  2342.     > 0   with a Kermit protocol start-state.
  2343.     < 0   upon error.
  2344. */
  2345. int
  2346. parser(m) int m; {
  2347.     int tfcode, xx, yy, zz;             /* Workers */
  2348.     int is_tn = 0;
  2349.     int cdlost = 0;
  2350.  
  2351. #ifndef NOSPL
  2352.     int inlevel;                        /* Level we were called at */
  2353.     extern int askflag;
  2354. #endif /* NOSPL */
  2355.     char *cbp;                          /* Command buffer pointer */
  2356. #ifdef MAC
  2357.     extern char *lfiles;                /* Fake extern cast */
  2358. #endif /* MAC */
  2359.     extern int interrupted;
  2360. #ifndef NOXFER
  2361.     extern int sndcmd, getcmd, fatalio, clearrq;
  2362. #endif /* NOXFER */
  2363.  
  2364.     debok = 1;                          /* Undisable debugging */
  2365.  
  2366. #ifdef AMIGA
  2367.     reqres();                           /* Restore AmigaDOS requestors */
  2368. #endif /* AMIGA */
  2369.  
  2370. #ifdef OS2
  2371.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2372.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2373.         cursor_save = -1;
  2374.     }
  2375. #endif /* OS2 */
  2376.  
  2377. #ifdef IKSDB
  2378.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2379. #endif /* IKSDB */
  2380.  
  2381.     is_tn = (local && network && IS_TELNET()) ||
  2382.       (!local && sstelnet);
  2383.  
  2384.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2385.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2386.  
  2387. #ifdef CK_TMPDIR
  2388. /* If we were cd'd temporarily to another device or directory ... */
  2389.     if (f_tmpdir) {
  2390.         int x;
  2391.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2392.         f_tmpdir = 0;                   /* and remember we did it. */
  2393.         debug(F111,"parser tmpdir restoring",savdir,x);
  2394.     }
  2395. #endif /* CK_TMPDIR */
  2396.  
  2397. #ifndef NOSPL
  2398.     inlevel = cmdlvl;           /* Current macro level */
  2399. #ifdef DEBUG
  2400.     if (deblog) {
  2401.         debug(F101,"&parser entry maclvl","",maclvl);
  2402.         debug(F101,"&parser entry inlevel","",inlevel);
  2403.         debug(F101,"&parser entry tlevel","",tlevel);
  2404.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2405.         debug(F101,"&parser entry m","",m);
  2406.     }
  2407. #endif /* DEBUG */
  2408. #endif /* NOSPL */
  2409.  
  2410. #ifndef NOXFER
  2411.     ftreset();                          /* Reset global file settings */
  2412. #endif /* NOXFER */
  2413. /*
  2414.   sstate becomes nonzero when a command has been parsed that requires some
  2415.   action from the protocol module.  Any non-protocol actions, such as local
  2416.   directory listing or terminal emulation, are invoked directly from below.
  2417. */
  2418.     sstate = 0;                         /* Start with no start state. */
  2419.  
  2420. #ifndef NOXFER
  2421. #ifndef NOSPL
  2422.     query = 0;                          /* QUERY not active */
  2423. #endif /* NOSPL */
  2424. #ifndef NOHINTS
  2425.     if (!success) {
  2426.         if (local && !network && carrier != CAR_OFF) {
  2427.             int x;                      /* Serial connection */
  2428.             x = ttgmdm();               /* with carrier checking */
  2429.             if (x > -1) {
  2430.                 if (!(x & BM_DCD)) {
  2431.                     cdlost = 1;
  2432.                     fatalio = 1;
  2433.                 }
  2434.             }
  2435.         }
  2436.     }
  2437. #ifdef DEBUG
  2438.     if (deblog) {
  2439.         debug(F101,"parser top what","",what);
  2440.         debug(F101,"parser top interrupted","",interrupted);
  2441.         debug(F101,"parser top cdlost","",cdlost);
  2442.         debug(F101,"parser top sndcmd","",sndcmd);
  2443.         debug(F101,"parser top getcmd","",getcmd);
  2444.     }
  2445. #endif /* DEBUG */
  2446.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2447.         printf("?Connection broken (carrier signal lost)\n");
  2448.     }
  2449.     if (sndcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2450.         int x = 0, n = 0;
  2451.         printf("\n*************************\n");
  2452.         printf("SEND-class command failed.\n");
  2453.         printf(" Packets sent: %d\n", spackets);
  2454.         printf(" Retransmissions: %d\n",retrans);
  2455.         printf(" Timeouts: %d\n", timeouts);
  2456.         printf(" Damaged packets: %d\n", crunched);
  2457.         if (epktrcvd) {
  2458.             printf(" Transfer canceled by receiver.\n");
  2459.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2460.             n++;
  2461.         } else {
  2462.             if (epktmsg) if (*epktmsg) {
  2463.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2464.                 n++;
  2465.             }
  2466.         }
  2467.         if (local && !network && carrier != CAR_OFF) {
  2468.             int xx;                     /* Serial connection */
  2469.             xx = ttgmdm();              /* with carrier checking */
  2470.             if (xx > -1) {
  2471.                 if (!(xx & BM_DCD))
  2472.                   cdlost = 1;
  2473.             }
  2474.         }
  2475.  
  2476. #ifdef UNIX
  2477.         if (errno != 0)
  2478. #endif /* UNIX */
  2479.           {
  2480.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2481.               n++;
  2482.           }
  2483.         printf(
  2484.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2485.                (n > 1) ? "s do" : " does"
  2486.                );
  2487. #ifndef NOLOCAL
  2488.         if (local) {
  2489.             if (rpackets == 0) {
  2490.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2491.             } else {
  2492.                 printf(
  2493.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2494.                 if (!network && mdmtyp > 0)
  2495.                   if ((3 * crunched) > spackets)
  2496.                     printf(
  2497.                 " . Try placing a new call to get a cleaner connection.\n");
  2498.             }
  2499.         } else if (rpackets > 0) {
  2500.             if (flow == FLO_NONE)
  2501.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2502.             else
  2503.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2504.         }
  2505.         x++;
  2506. #endif /* NOLOCAL */
  2507.  
  2508.         if ((3 * timeouts) > spackets)
  2509.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2510.         if ((3 * retrans) > spackets)
  2511.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2512.  
  2513. #ifdef CK_SPEED
  2514.         if (prefixing != PX_ALL && rpackets > 2) {
  2515.             printf(" . Try it again with SET PREFIXING ALL.\n");
  2516.             x++;
  2517.         }
  2518. #endif /* CK_SPEED */
  2519. #ifdef STREAMING
  2520.         if (streamed) {
  2521.             printf(" . Try it again with SET STREAMING OFF.\n");
  2522.             x++;
  2523.         } else if (reliable) {
  2524.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2525.             x++;
  2526.         }
  2527. #endif /* STREAMING */
  2528.  
  2529. #ifdef CK_SPEED
  2530.         if (clearrq > 0 && prefixing == PX_NON) {
  2531.             printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");
  2532.             x++;
  2533.         }
  2534. #endif /* CK_SPEED */
  2535.         if (!parity) {
  2536.             printf(" . Try it again with SET PARITY SPACE.\n");
  2537.             x++;
  2538.         }
  2539.         printf(" . %sive a ROBUST command and try again.\n",
  2540.                (x > 0) ? "As a last resort, g" : "G"
  2541.                );
  2542.         printf("Also:\n");
  2543.         printf(" . Be sure the source file has read permission.\n");
  2544.         printf(" . Be sure the target directory has write permission.\n");
  2545.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2546.         printf("*************************\n\n");
  2547.     }
  2548.     debug(F101,"topcmd","",topcmd);
  2549.     if (getcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2550.         int x = 0;
  2551.         extern int urpsiz, wslotr;
  2552.         printf("\n*************************\n");
  2553.         printf("RECEIVE- or GET-class command failed.\n");
  2554.         printf(" Packets received: %d\n", rpackets);
  2555.         printf(" Damaged packets: %d\n", crunched);
  2556.         printf(" Timeouts: %d\n", timeouts);
  2557.         if (rpackets > 0)
  2558.           printf(" Packet length: %d\n", urpsiz);
  2559.         if (epktrcvd) {
  2560.             printf(" Transfer canceled by sender.\n");
  2561.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2562.         }
  2563. #ifdef UNIX
  2564.         if (errno != 0)
  2565. #endif /* UNIX */
  2566.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2567.         printf(
  2568.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2569.                epktrcvd ? "s do" : " does"
  2570.                );
  2571. #ifndef NOLOCAL
  2572.         if (local) {
  2573.             if (topcmd == XXGET)
  2574.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2575.             if (rpackets == 0) {
  2576.                 if (topcmd != XXGET)
  2577.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2578.             } else {
  2579.                 printf(
  2580.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2581.             }
  2582.         } else if (topcmd == XXGET)
  2583.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2584.         if (rpackets > 0 && urpsiz > 90)
  2585.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2586.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2587.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2588.         if (!local && rpackets > 0) {
  2589.             if (flow == FLO_NONE)
  2590.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2591.             else
  2592.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2593.         }
  2594.         x++;
  2595. #endif /* NOLOCAL */
  2596. #ifdef STREAMING
  2597.         if (streamed) {
  2598.             printf(" . Try it again with SET STREAMING OFF.\n");
  2599.             x++;
  2600.         } else if (reliable && local) {
  2601.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2602.             x++;
  2603.         } else
  2604. #endif /* STREAMING */
  2605.         if (!parity) {
  2606.             printf(" . Try it again with SET PARITY SPACE.\n");
  2607.             x++;
  2608.         }
  2609.         printf((x > 0) ?
  2610.                " . As a last resort, give a ROBUST command and try again.\n" :
  2611.                " . Give a ROBUST command and try again.\n"
  2612.                );
  2613.         printf("Also:\n");
  2614.         printf(" . Be sure the target directory has write permission.\n");
  2615.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2616.                topcmd == XXGET ? "server" : "sender"
  2617.                );
  2618.         printf(" . Try giving a ROBUST command to the %s.\n",
  2619.                topcmd == XXGET ? "server" : "sender"
  2620.                );
  2621.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2622.         printf("*************************\n\n");
  2623.     }
  2624. #endif /* NOHINTS */
  2625.     getcmd = 0;
  2626.     sndcmd = 0;
  2627.     interrupted = 0;
  2628. #endif /* NOXFER */
  2629.  
  2630.     while (sstate == 0) {               /* Parse cmds until action requested */
  2631.         debug(F100,"parse top","",0);
  2632.     what = W_COMMAND;        /* Now we're parsing commands. */
  2633.     rcdactive = 0;            /* REMOTE CD not active */
  2634.  
  2635. #ifdef OS2
  2636.         if (apcactive == APC_INACTIVE)
  2637.           WaitCommandModeSem(-1);
  2638. #endif /* OS2 */
  2639. #ifdef IKS_OPTION
  2640.         if ((local &&
  2641.              !xcmdsrc &&
  2642.              is_tn &&
  2643.              TELOPT_ME(TELOPT_KERMIT) &&
  2644.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2645.             (!local &&
  2646.              !cmdadl &&
  2647.              TELOPT_ME(TELOPT_KERMIT) &&
  2648.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2649.             ) {
  2650.             tn_siks(KERMIT_STOP);
  2651.         }
  2652. #endif /* IKS_OPTION */
  2653.  
  2654. #ifndef NOXFER
  2655.         if (autopath) {
  2656.             fnrpath = PATH_AUTO;
  2657.             autopath = 0;
  2658.         }
  2659.         remfile = 0;                    /* Clear these in case REMOTE */
  2660.         remappd = 0;                    /* command was interrupted... */
  2661.         rempipe = 0;
  2662.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2663.         makestr(&rcv_move,g_rcv_move);
  2664.         makestr(&snd_rename,g_snd_rename);
  2665.         makestr(&rcv_rename,g_rcv_rename);
  2666. #endif /* NOXFER */
  2667.         xaskmore = saveask;             /* Restore global more-prompting */
  2668.         diractive = 0;
  2669.         cdactive = 0;
  2670.  
  2671. #ifndef NOSPL
  2672.         askflag = 0;
  2673. #endif /* NOSPL */
  2674.  
  2675.     /* Take requested action if there was an error in the previous command */
  2676.  
  2677.         setint();
  2678.         debug(F101,"parser tlevel","",tlevel);
  2679.         debug(F101,"parser cmd_rows","",cmd_rows);
  2680.  
  2681. #ifndef NOLOCAL
  2682.         debug(F101,"parser wasclosed","",wasclosed);
  2683.         if (wasclosed) {                /* If connection was just closed */
  2684. #ifndef NOSPL
  2685.             int k;
  2686.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2687.             if (k >= 0) {               /* If found, */
  2688.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2689.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2690.             }
  2691. #endif /* NOSPL */
  2692.             whyclosed = WC_REMO;
  2693.             wasclosed = 0;
  2694.         }
  2695. #endif /* NOLOCAL */
  2696.  
  2697. #ifndef NOSPL
  2698.         xxdot = 0;                      /* Clear this... */
  2699.  
  2700.         debug(F101,"parser success","",success);
  2701.         if (success == 0) {
  2702.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2703.                 printf("Command file terminated by error.\n");
  2704.                 popclvl();
  2705.                 if (cmdlvl == 0) return(0);
  2706.             }
  2707.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2708.                 printf("Command error: macro terminated.\n");
  2709.                 popclvl();
  2710.                 if (m && (cmdlvl < inlevel))
  2711.                   return((int) sstate);
  2712.             }
  2713.         }
  2714.         nulcmd = (m == 2);
  2715.         debug(F101,"parser nulcmd","",nulcmd);
  2716. #else
  2717.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2718.             printf("Command file terminated by error.\n");
  2719.             popclvl();
  2720.             cmini(ckxech);              /* Clear the cmd buffer. */
  2721.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2722.               return(0);                /* End of init file or whatever. */
  2723.         }
  2724. #endif /* NOSPL */
  2725.  
  2726. #ifdef MAC
  2727.         /* Check for TAKE initiated by menu. */
  2728.         if ((tlevel == -1) && lfiles)
  2729.             startlfile();
  2730. #endif /* MAC */
  2731.  
  2732.         /* If in TAKE file, check for EOF */
  2733. #ifndef NOSPL
  2734. #ifdef MAC
  2735.         if
  2736. #else
  2737.         while
  2738. #endif /* MAC */
  2739.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2740.                && (tlevel > -1)
  2741.                && feof(tfile[tlevel])) {
  2742.             popclvl();                  /* pop command level */
  2743.             cmini(ckxech);              /* and clear the cmd buffer. */
  2744.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2745.                 return(0);              /* End of init file or whatever. */
  2746.             }
  2747.         }
  2748. #ifdef MAC
  2749.         miniparser(1);
  2750.         if (sstate == 'a') {            /* if cmd-. cancel */
  2751.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2752.             sstate = '\0';
  2753.             dostop();
  2754.             return(0);                  /* End of init file or whatever. */
  2755.         }
  2756. #endif /*  MAC */
  2757.  
  2758. #else /* NOSPL */
  2759.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2760.             popclvl();                  /* Pop up one level. */
  2761.             cmini(ckxech);              /* and clear the cmd buffer. */
  2762.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2763.               return(0);                /* End of init file or whatever. */
  2764.         }
  2765. #endif /* NOSPL */
  2766.  
  2767.  
  2768. #ifndef NOSPL
  2769.         debug(F101,"parser cmdlvl","",cmdlvl);
  2770.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2771.  
  2772.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2773.             debug(F100,"parser macro","",0);
  2774.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2775.             debug(F101,"parser maclvl","",maclvl);
  2776.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2777.             *cbp = NUL;
  2778.             if (*savbuf) {              /* In case then-part of 'if' command */
  2779.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2780.                 *savbuf = '\0';
  2781.             } else {                    /* Else get next cmd from macro def */
  2782.                 if (getncm(cbp,CMDBL) < 0) {
  2783. #ifdef DEBUG
  2784.                     if (deblog) {
  2785.                         debug(F101,"parser end of macro m","",m);
  2786.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2787.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2788.                     }
  2789. #endif /* DEBUG */
  2790.                     if (m && (cmdlvl < inlevel))
  2791.                       return((int) sstate);
  2792.                     else /* if (!m) */ continue;
  2793.                 }
  2794.             }
  2795.             debug(F010,"CMD(M)",cmdbuf,0);
  2796.  
  2797.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2798. #else
  2799.           if (tlevel > -1)
  2800. #endif /* NOSPL */
  2801.           {
  2802. #ifndef NOSPL
  2803.             debug(F111,"parser savbuf",savbuf,tlevel);
  2804.             if (*savbuf) {              /* In case THEN-part of IF command */
  2805.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2806.                 *savbuf = '\0';
  2807.             } else
  2808. #endif /* NOSPL */
  2809.  
  2810.               /* Get next line from TAKE file */
  2811.  
  2812.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2813.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2814.                   if (tfcode < -1) {    /* Error */
  2815.                       printf("?Error in TAKE command file: %s\n",
  2816.                              (tfcode == -2) ? "Memory allocation failure" :
  2817.                              "Line too long or contains NUL characters"
  2818.                              );
  2819.                       dostop();
  2820.                   }
  2821.                   continue;             /* -1 means EOF */
  2822.               }
  2823.  
  2824.         /* If interactive, get next command from user. */
  2825.  
  2826.         } else {                        /* User types it in. */
  2827.             if (pflag) prompt(xxstring);
  2828.             cmini(ckxech);
  2829.         }
  2830.  
  2831.     /* Now we know where next command is coming from. Parse and execute it. */
  2832.  
  2833.         repars = 1;                     /* 1 = command needs parsing */
  2834. #ifndef NOXFER
  2835.         displa = 0;                     /* Assume no file transfer display */
  2836. #endif /* NOXFER */
  2837.  
  2838.         while (repars) {                /* Parse this cmd until entered. */
  2839.  
  2840.             debug(F101,"parser top of while loop","",0);
  2841.  
  2842. #ifdef RECURSIVE
  2843.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2844.             recursive = 0;              /* This is never sticky */
  2845. #endif /* RECURSIVE */
  2846.             xfiletype = -1;             /* Reset this between each command */
  2847. #ifndef NOMSEND
  2848.             addlist = 0;
  2849. #endif /* NOMSEND */
  2850. #ifdef CK_RECALL
  2851.             on_recall = 1;
  2852. #endif /* CK_RECALL */
  2853.             /* This might have been changed by a switch */
  2854.             if (g_matchdot > -1) {
  2855.                 matchdot = g_matchdot;
  2856.                 g_matchdot = -1;
  2857.             }
  2858.             cmres();                    /* Reset buffer pointers. */
  2859.  
  2860. #ifdef OS2
  2861. #ifdef COMMENT
  2862.             /* we check to see if a macro is waiting to be executed */
  2863.             /* if so, we call domac on it */
  2864.             if (cmdmac) {
  2865.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2866.                 free(cmdmac);
  2867.                 cmdmac = NULL;
  2868.             }
  2869. #endif /* COMMENT */
  2870. #endif /* OS2 */
  2871. #ifndef NOXFER
  2872.             bye_active = 0;
  2873. #endif /* NOXFER */
  2874.             havetoken = 0;
  2875.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2876.             debug(F101,"top-level cmkey2","",xx);
  2877.             if (xx == -5) {
  2878.                 yy = chktok(toktab);
  2879.                 debug(F101,"top-level cmkey token","",yy);
  2880. #ifndef COMMENT
  2881.                 /* Either way makes absolutely no difference */
  2882.                 debug(F110,"NO UNGWORD",atmbuf,0);
  2883.                 /* ungword(); */
  2884. #else
  2885.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  2886.                 ungword();
  2887. #endif /* COMMENT */
  2888.                 switch (yy) {
  2889.                   case '#': xx = XXCOM; break; /* Comment */
  2890.                   case ';': xx = XXCOM; break; /* Comment */
  2891. #ifndef NOSPL
  2892.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  2893.                   case ':': xx = XXLBL; break; /* GOTO label */
  2894. #endif /* NOSPL */
  2895.  
  2896. #ifndef NOPUSH
  2897. #ifdef CK_REDIR
  2898.                   case '<':
  2899. #endif /* CK_REDIR */
  2900.                   case '@':
  2901.                   case '!':
  2902.                     if (nopush) {
  2903.                         char *s; int x;
  2904.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  2905.                           return(x);
  2906.                         success = 0;
  2907.                         xx = XXCOM;
  2908.                     } else {
  2909.                         switch(yy) {
  2910. #ifdef CK_REDIR
  2911.                           case '<': xx = XXFUN; break; /* REDIRECT */
  2912. #endif /* CK_REDIR */
  2913.                           case '@':
  2914.                           case '!': xx = XXSHE; break; /* Shell escape */
  2915.                         }
  2916.                     }
  2917.                     break;
  2918. #endif /* NOPUSH */
  2919. #ifdef CK_RECALL
  2920.                   case '^': xx = XXREDO;  break;
  2921. #endif /* CK_RECALL */
  2922. #ifndef NOSPL
  2923.                   case '{': xx = XXMACRO; break;
  2924.                   case '(': xx = XXSEXP;  break;
  2925. #endif /* NOSPL */
  2926.  
  2927.                   default:
  2928.                     if (!quiet) {
  2929.                         printf("\n?Invalid - \"%s\"\n",cmdbuf);
  2930. #ifdef COMMENT
  2931. #ifndef NOSPL
  2932.                         if (maclvl > -1 && xcmdsrc == 2)
  2933.                           printf("Macro: %s; ",
  2934.                                  m_arg[maclvl][0] ?
  2935.                                  m_arg[maclvl][0] : "");
  2936. #endif /* NOSPL */
  2937.                         if (tlevel > -1) {
  2938.                             printf("Command file: %s, line %d\n",
  2939.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  2940.                                    tfline[tlevel]
  2941.                                    );
  2942.                         }
  2943. #else
  2944.                         if (xcmdsrc > 0) {
  2945.                             printf("Command stack:\n");
  2946.                             shostack();
  2947.                         }
  2948. #endif /* COMMENT */
  2949.  
  2950.                     }
  2951.                     xx = -2;
  2952.                 }
  2953.                 havetoken = 1;
  2954.                 debug(F101,"HAVE TOKEN","",xx);
  2955.             }
  2956.             if (xx > -1) {
  2957.                 topcmd = xx;            /* Top-level command index */
  2958. #ifndef NOSPL
  2959.                 if (maclvl > -1)
  2960.                   lastcmd[maclvl] = xx;
  2961. #endif /* NOSPL */
  2962.                 debug(F101,"topcmd","",topcmd);
  2963.                 debug(F101,"cmflgs","",cmflgs);
  2964.             }
  2965.  
  2966. #ifndef NOSPL
  2967.             /* Special handling for IF..ELSE */
  2968.  
  2969.             debug(F101,"cmdlvl","",cmdlvl);
  2970.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  2971.  
  2972.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  2973.               ifcmd[cmdlvl]++;
  2974.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  2975.               ifcmd[cmdlvl] = 0;
  2976.  
  2977.             /* Execute the command and take action based on return code. */
  2978.  
  2979.             if (nulcmd) {               /* Ignoring this command? */
  2980.                 xx = XXCOM;             /* Make this command a comment. */
  2981.             }
  2982.             fnsuccess = 1;              /* For catching \function() errors */
  2983. #endif /* NOSPL */
  2984.  
  2985.             debug(F101,"calling docmd()","",xx);
  2986.             zz = docmd(xx);             /* Parse rest of command & execute. */
  2987.  
  2988. #ifndef NOSPL
  2989.             if (fnerror && !fnsuccess)
  2990.               success = 0;
  2991. #endif /* NOSPL */
  2992.             debug(F101,"docmd returns","",zz);
  2993.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  2994.             /* debug(F011,"atmbuf",atmbuf,30); */
  2995. #ifdef MAC
  2996.             if (tlevel > -1) {
  2997.                 if (sstate == 'a') {    /* if cmd-. cancel */
  2998.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  2999.                     sstate = '\0';
  3000.                     dostop();
  3001.                     return(0);          /* End of init file or whatever. */
  3002.                 }
  3003.             }
  3004. #endif /* MAC */
  3005.             switch (zz) {
  3006.               case -4:                  /* EOF (e.g. on redirected stdin) */
  3007.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  3008.               case -1:                  /* Reparse needed */
  3009.                 repars = 1;             /* Just set reparse flag and... */
  3010.                 continue;
  3011. #ifdef OS2
  3012.               case -7:                  /* They typed a disk letter */
  3013.                 if (!zchdir((char *)cmdbuf)) {
  3014.                     perror((char *)cmdbuf);
  3015.                     success = 0;
  3016.                 } else success = 1;
  3017.                 repars = 0;
  3018.                 continue;
  3019.  
  3020. #endif /* OS2 */
  3021.               case -6:                  /* Invalid command given w/no args */
  3022.               case -2:                  /* Invalid command given w/args */
  3023. #ifdef COMMENT
  3024. #ifndef NOSPL
  3025.                     /* This is going to be really ugly... */
  3026.                     yy = mlook(mactab,atmbuf,nmac); /* Look in macro table */
  3027.                     if (yy > -1) {                  /* If it's there */
  3028.                         if (zz == -2) {             /* insert "do" */
  3029.                             char *mp;
  3030.                             mp = malloc((int)strlen(cmdbuf) + 5);
  3031.                             if (!mp) {
  3032.                                 printf("?malloc error 1\n");
  3033.                                 return(-2);
  3034.                             }
  3035.                             sprintf(mp,"do %s ",cmdbuf); /* SAFE (checked) */
  3036.                             ckstrncpy(cmdbuf,mp,CMDBL);
  3037.                             free(mp);
  3038.                             mp = NULL;
  3039.                         } else {
  3040.                             if (((int)strlen(atmbuf) + 5) < CMDBL)
  3041.                               sprintf(cmdbuf,"do %s %c",atmbuf, CR); /* SAFE */
  3042.                             else
  3043.                               ckstrncpy(cmdbuf,"echo ?Too long\r",CMDBL);
  3044.                         }
  3045.                         if (ifcmd[cmdlvl] == 2) /* This one doesn't count! */
  3046.                           ifcmd[cmdlvl]--;
  3047.                         debug(F111,"stuff cmdbuf",cmdbuf,zz);
  3048.                         repars = 1;     /* Go for reparse */
  3049.                         continue;
  3050.                     } else {
  3051.                         char *p;
  3052.                         int n;
  3053.                         p = cmdbuf;
  3054.                         lp = line;
  3055.                         n = LINBUFSIZ;
  3056.                         if (cmflgs == 0) printf("\n");
  3057.                         if (zzstring(p,&lp,&n) > -1)
  3058.                           printf("?Invalid: %s\n",line);
  3059.                         else
  3060.                           printf("?Invalid: %s\n",cmdbuf);
  3061.                     } /* (fall thru...) */
  3062. #else
  3063.                     printf("?Invalid: %s\n",cmdbuf);
  3064. #endif /* NOSPL */
  3065. #else /* Not COMMENT */
  3066.                     printf("?Invalid: %s\n",cmdbuf);
  3067. #endif /* COMMENT */
  3068.  
  3069.                 case -9:                /* Bad, error message already done */
  3070.                     success = 0;
  3071.                     debug(F110,"top-level cmkey failed",cmdbuf,0);
  3072.                     /* If in background w/ commands coming stdin, terminate */
  3073.                     if (pflag == 0 && tlevel < 0)
  3074.                       fatal("Kermit command error in background execution");
  3075. /*
  3076.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3077.   reprompt the user with as much of the command as didn't fail.
  3078. */
  3079. #ifdef CK_RECALL
  3080.                     if (cm_retry && !xcmdsrc) { /* If at top level */
  3081.                         int len;
  3082.                         char *p, *s;
  3083.                         len = strlen(cmdbuf); /* Length of command buffer */
  3084.                         p = malloc(len + 1);  /* Allocate space for copy */
  3085.                         if (p) {              /* If we got the space copy */
  3086.                             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3087.                             /* Chop off final field, the one that failed. */
  3088.                             s = p + len - 1;          /* Point to end */
  3089.                             while (*s == SP && s > p) /* Trim blanks */
  3090.                               s--;
  3091.                             while (*s != SP && s > p) /* Trim last field */
  3092.                               s--;
  3093.                             if (s > p)        /* Keep the space */
  3094.                               s++;            /* after last good field */
  3095.                             if (s >= p)       /* Cut off remainder */
  3096.                               *s = NUL;
  3097.                             cmini(ckxech);    /* Reinitialize the parser */
  3098.                             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3099.                             free(p);          /* Free temporary storage */
  3100.                             p = NULL;
  3101.                             prompt(xxstring); /* Reprint the prompt */
  3102.                             printf("%s",cmdbuf); /* Reprint partial command */
  3103.                             repars = 1;          /* Force reparse */
  3104.                             continue;
  3105.                         }
  3106.                     } else
  3107. #endif /* CK_RECALL */
  3108.                       if (!quiet) {
  3109. #ifdef COMMENT
  3110. #ifndef NOSPL
  3111.                           if (maclvl > -1)
  3112.                             printf("Macro: %s; ",
  3113.                                    m_arg[maclvl][0] ?
  3114.                                    m_arg[maclvl][0] : "");
  3115. #endif /* NOSPL */
  3116.                           if (tlevel > -1)
  3117.                             printf("Command file: %s, line %d\n",
  3118.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  3119.                                    tfline[tlevel]
  3120.                                    );
  3121. #else
  3122.                           if (xcmdsrc > 0) {
  3123.                               printf("Command stack:\n");
  3124.                               shostack();
  3125.                           }
  3126. #endif /* COMMENT */
  3127.                       }
  3128.                       cmini(ckxech);    /* (fall thru) */
  3129.  
  3130.                 case -3:                /* Empty command OK at top level */
  3131.                     repars = 0;         /* Don't need to reparse. */
  3132.                     continue;           /* Go back and get another command. */
  3133.  
  3134.                 default:                /* Command was successful. */
  3135. #ifndef NOSPL
  3136.                     debug(F101,"parser preparing to continue","",maclvl);
  3137. #endif /* NOSPL */
  3138.                     debug(F101,"parser success","",success);
  3139.                     repars = 0;         /* Don't need to reparse. */
  3140.                     continue;           /* Go back and get another command. */
  3141.                 }
  3142.         }
  3143. #ifndef NOSPL
  3144.         debug(F101,"parser breaks out of while loop","",maclvl);
  3145.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3146. #endif /* NOSPL */
  3147.     }
  3148.  
  3149. /* Got an action command, return start state. */
  3150.  
  3151.     return((int) sstate);
  3152. }
  3153.  
  3154. #ifndef NOSPL
  3155. /*
  3156.   OUTPUT command.
  3157.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3158. */
  3159. #define OBSIZE 80                       /* Size of local character buffer */
  3160.  
  3161. static int obn;                         /* Buffer offset (high water mark) */
  3162. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3163. static char *obp;                       /* Pointer to output buffer. */
  3164. _PROTOTYP( static int oboc, (char) );
  3165. _PROTOTYP( static int xxout, (char *, int) );
  3166.  
  3167. static int
  3168. #ifdef CK_ANSIC
  3169. xxout(char *obuf, int obsize)
  3170. #else
  3171. xxout(obuf, obsize) char *obuf; int obsize;
  3172. #endif /* CK_ANSIC */
  3173. /* xxout */ {                           /* OUTPUT command's output function */
  3174.     int i, rc;
  3175.  
  3176.     debug(F101,"xxout obsize","",obsize);
  3177.     debug(F101,"xxout pacing","",pacing);
  3178.     debug(F111,"xxout string",obuf,strlen(obuf));
  3179.  
  3180.     rc = 0;                             /* Initial return code. */
  3181.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3182.       goto xxout_x;                     /* Return successfully */
  3183.  
  3184.     rc = -1;                              /* Now assume failure */
  3185.     if (pacing == 0) {                    /* Is pacing enabled? */
  3186.         if ((local ?                      /* No, write entire string at once */
  3187.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3188.              conxo(obsize, obuf))         /* or to console */
  3189.             != obsize)
  3190.           goto xxout_x;
  3191.     } else {
  3192.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3193.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3194.               goto xxout_x;
  3195.             msleep(pacing);
  3196.         }
  3197.     }
  3198.     if (duplex) {
  3199. #ifdef OS2
  3200.         if (inecho && local) {
  3201. #ifndef NOLOCAL
  3202.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3203.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3204.             }
  3205. #endif /* NOLOCAL */
  3206.             conxo(obsize,obuf);
  3207.         } else if (seslog) {            /* or log session here */
  3208.             logstr((char *) obuf, obsize);
  3209.         }
  3210. #else /* OS2 */
  3211.         if (seslog) {
  3212.             logstr((char *) obuf, obsize);
  3213.         }
  3214.         if (inecho && local) {
  3215.             conxo(obsize,obuf);
  3216.         }
  3217. #endif /* OS2 */
  3218.     }
  3219.     rc = 0;                             /* Success */
  3220.   xxout_x:
  3221.     obn = 0;                            /* Reset count */
  3222.     obp = obuf;                         /* and pointers */
  3223.     return(rc);                         /* return our return code */
  3224. }
  3225.  
  3226. #ifdef COMMENT
  3227. /*
  3228.   Macros for OUTPUT command execution, to make it go faster.
  3229. */
  3230. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3231. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3232.  
  3233. #else /* The macros cause some compilers to generate bad code. */
  3234.  
  3235. static int
  3236. #ifdef CK_ANSIC
  3237. oboc(char c)
  3238. #else
  3239. oboc(c) char c;
  3240. #endif /* CK_ANSIC */
  3241. /* oboc */ {                            /* OUTPUT command's output function */
  3242.  
  3243.     *obp++ = c;                         /* Deposit character */
  3244.     *obp = NUL;                         /* Flush buffer if it's now full */
  3245.  
  3246.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3247. }
  3248. #endif /* COMMENT */
  3249.  
  3250. /*  Routines for handling local variables -- also see popclvl().  */
  3251.  
  3252. VOID
  3253. freelocal(m) int m; {                   /* Free local variables */
  3254.     struct localvar * v, * tv;          /* at macro level m... */
  3255.     debug(F101,"freelocal level","",m);
  3256.     if (m < 0) return;
  3257.     v = localhead[m];                   /* List head for level m */
  3258.     while (v) {
  3259.         if (v->lv_name)                 /* Variable name */
  3260.           free(v->lv_name);
  3261.         if (v->lv_value)                /* Value */
  3262.           free(v->lv_value);
  3263.         tv = v;                         /* Save pointer to this node */
  3264.         v = v->lv_next;                 /* Get next one */
  3265.         if (tv)                         /* Free this one */
  3266.           free((char *)tv);
  3267.     }
  3268.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3269. }
  3270.  
  3271. #define MAXLOCALVAR 64
  3272.  
  3273. /* Return a pointer to the definition of a user-defined variable */
  3274.  
  3275. static char *
  3276. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3277.     char * p;
  3278.     char c;
  3279.     *isarray = 0;
  3280.     if (!s) return(NULL);
  3281.     if (!*s) return(NULL);
  3282.     p = s;
  3283.     if (*s == CMDQ) {
  3284.         p++;
  3285.         if (!*p)
  3286.           return(NULL);
  3287.         if ((c = *p) == '%') {          /* Scalar variable. */
  3288.             c = *++p;                   /* Get ID character. */
  3289.             p = "";                     /* Assume definition is empty */
  3290.             if (!c)
  3291.               return(NULL);
  3292.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3293.                 if (maclvl < 0)         /* Digit variables are global */
  3294.                   return(g_var[c]);     /* if no macro is active */
  3295.                 else                    /* otherwise */
  3296.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3297.             } else if (isalpha(c)) {
  3298.                 if (isupper(c)) c -= ('a'-'A');
  3299.                 return(g_var[c]);           /* Letter for global variable */
  3300.             } else
  3301.               return(NULL);
  3302.         } else if (c == '&') {          /* Array reference. */
  3303.             int x, vbi, d;
  3304.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3305.             if (x > -1 || d == -17) {
  3306.                 *isarray = 1;
  3307.                 *x1 = vbi;
  3308.                 *x2 = (d == -17) ? 0 : d;
  3309.             }
  3310.             if (x < 0)
  3311.               return(NULL);
  3312.             if (chkarray(vbi,d) > 0) {  /* Array is declared? */
  3313.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3314.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3315.                     char **ap;
  3316.                     ap = a_ptr[vbi];
  3317.                     return((ap) ? ap[d] : NULL);
  3318.                 }
  3319.             }
  3320.         }
  3321.         return(NULL);
  3322.     } else {
  3323.         int k;
  3324.         k = mxlook(mactab,s,nmac);
  3325.         return((k > -1) ? mactab[k].mval : NULL);
  3326.     }
  3327. }
  3328.  
  3329.  
  3330. int
  3331. addlocal(p) char * p; {
  3332.     int x, z, isarray = 0;
  3333.     char * s;
  3334.     struct localvar * v, *prev = (struct localvar *)NULL;
  3335.     extern int tra_asg; int tra_tmp;
  3336.  
  3337.     tra_tmp = tra_asg;
  3338.  
  3339.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3340.     if (isarray) {                      /* Arrays are handled specially */
  3341.         pusharray(x,z);
  3342.         return(0);
  3343.     }
  3344.     if (!s) s = "";
  3345.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3346.         while (v) {                     /* Find end of list */
  3347.             prev = v;
  3348.             v = v->lv_next;
  3349.         }
  3350.     }
  3351.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3352.     if (!v) {
  3353.         printf("?Failure to allocate storage for local variables");
  3354.         return(-9);
  3355.     }
  3356.     if (!localhead[cmdlvl])             /* If first, set list head */
  3357.       localhead[cmdlvl] = v;
  3358.     else                                /* Otherwise link previous to this */
  3359.       prev->lv_next = v;
  3360.     prev = v;                           /* And make this previous */
  3361.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3362.  
  3363.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3364.       return(-1);
  3365.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3366.  
  3367.     if (*s) {
  3368.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3369.           return(-1);
  3370.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3371.     } else
  3372.       v->lv_value = NULL;
  3373.  
  3374.     tra_asg = 0;
  3375.     delmac(p,1);                        /* Delete the original macro */
  3376.     tra_asg = tra_tmp;
  3377.     return(0);
  3378. }
  3379.  
  3380. int
  3381. dolocal() {                             /* Do the LOCAL command */
  3382.     int i, x;
  3383.     char * s;
  3384.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3385.  
  3386.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3387.       return(x);
  3388.  
  3389.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3390.  
  3391.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3392.  
  3393.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3394.         if (addlocal(list[i]) < 0)
  3395.           goto localbad;
  3396.     }
  3397.     return(success = 1);
  3398.  
  3399.   localbad:
  3400.     printf("?Failure to allocate storage for local variables");
  3401.     freelocal(cmdlvl);
  3402.     return(-9);
  3403. }
  3404.  
  3405. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3406.  
  3407. #ifndef NOKVERBS
  3408. #define K_BUFLEN 30
  3409. #define SEND_BUFLEN 255
  3410. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3411.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3412. #endif /* NOKVERBS */
  3413.  
  3414. int outesc = 1;                         /* Process special OUTPUT escapes */
  3415.  
  3416. int
  3417. dooutput(s, cx) char *s; int cx; {
  3418.  
  3419.     int x, xx, y, quote;                /* Workers */
  3420.     int is_tn = 0;
  3421.  
  3422.     is_tn = (local && network && IS_TELNET()) ||
  3423.       (!local && sstelnet);
  3424.  
  3425.     debug(F111,"dooutput s",s,(int)strlen(s));
  3426.  
  3427.     if (local) {                        /* Condition external line */
  3428. #ifdef NOLOCAL
  3429.         goto outerr;
  3430. #else
  3431.         if (ttchk() < 0) {
  3432.             printf("?Connection %s %s is not open.\n",
  3433.                    network ? "to" : "on",
  3434.                    ttname
  3435.                    );
  3436.             return(0);
  3437.         }
  3438.         if (ttvt(speed,flow) < 0) {
  3439.             printf("?OUTPUT initialization error\n");
  3440.             return(0);
  3441.         }
  3442. #endif /* NOLOCAL */
  3443.     }
  3444.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3445.         x = strlen(s);                  /* Just send the string literally */
  3446.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3447.         return(success = (xx == x) ? 1 : 0);
  3448.     }
  3449.     quote = 0;                          /* Initialize backslash (\) quote */
  3450.     obn = 0;                            /* Reset count */
  3451.     obp = obuf;                         /* and pointers */
  3452.  
  3453.   outagain:
  3454.     while ((x = *s++)) {                /* Loop through the string */
  3455.         y = 0;                          /* Error code, 0 = no error. */
  3456.         debug(F000,"dooutput","",x);
  3457.         if (quote) {                    /* This character is quoted */
  3458. #ifndef NOKVERBS
  3459.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3460.                extern struct keytab kverbs[];
  3461.                extern int nkverbs;
  3462.                extern char * keydefptr;
  3463.                extern int keymac;
  3464.                extern int keymacx;
  3465.                int x, y, brace = 0;
  3466.                int pause;
  3467.                char * p, * b;
  3468.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3469.                char osendbuf[SEND_BUFLEN +1];
  3470.                int  sendndx = 0;
  3471.  
  3472.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3473.                  goto outerr;
  3474.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3475.                {                        /* Have K verb? */
  3476.                    if (!*s) {
  3477.                        break;
  3478.                    }
  3479. /*
  3480.   We assume that the verb name is {braced}, or it extends to the end of the
  3481.   string, s, or it ends with a space, control character, or backslash.
  3482. */
  3483.                    p = kbuf;            /* Copy verb name into local buffer */
  3484.                    x = 0;
  3485.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3486.                        if (brace && *s == '}') {
  3487.                            break;
  3488.                        }
  3489.                        *p++ = *s++;
  3490.                    }
  3491.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3492.                      s--;               /*  back up so we get another look. */
  3493.                    brace = 0;
  3494.                    *p = NUL;            /* Terminate. */
  3495.                    p = kbuf;            /* Point back to beginning */
  3496.                    debug(F110,"dooutput kverb",p,0);
  3497.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3498.                    debug(F101,"dooutput lookup",0,y);
  3499.                    if (y > -1) {
  3500.                        if (sendndx) {
  3501.                            dooutput(osendbuf,cx);
  3502.                            sendndx = 0;
  3503.                        }
  3504.                        dokverb(VCMD,y);
  3505. #ifndef NOSPL
  3506.                    } else {             /* Is it a macro? */
  3507.                        y = mxlook(mactab,p,nmac);
  3508.                        if (y > -1) {
  3509.                            cmpush();
  3510.                            keymac = 1;  /* Flag for key macro active */
  3511.                            keymacx = y; /* Key macro index */
  3512.                            keydefptr = s; /* Where to resume next time */
  3513.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3514.                            parser(1);
  3515.                            cmpop();
  3516.                        }
  3517. #endif /* NOSPL */
  3518.                    }
  3519.                }
  3520.                quote = 0;
  3521.                continue;
  3522.            } else
  3523. #endif /* NOKVERBS */
  3524.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3525.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3526.                    goto outerr;
  3527.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3528.                  if (local)
  3529.                    ttoc(NUL);
  3530.                  else
  3531.                    conoc(NUL);
  3532.                  quote = 0;
  3533.                  continue;
  3534.  
  3535.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3536.  
  3537.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3538.                   goto outerr;
  3539.                 debug(F100,"OUTPUT BREAK","",0);
  3540. #ifndef NOLOCAL
  3541.                 ttsndb();               /* Send BREAK signal */
  3542. #else
  3543.                  if (local)
  3544.                    ttoc(NUL);
  3545.                  else
  3546.                    conoc(NUL);
  3547. #endif /* NOLOCAL */
  3548.                 quote = 0;              /* Turn off quote flag */
  3549.                 continue;               /* and not the b or B */
  3550. #ifdef CK_LBRK
  3551.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3552.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3553.                    goto outerr;
  3554.                  debug(F100,"OUTPUT Long BREAK","",0);
  3555. #ifndef NOLOCAL
  3556.                  ttsndlb();             /* Send Long BREAK signal */
  3557. #else
  3558.                  if (local)
  3559.                    ttoc(NUL);
  3560.                  else
  3561.                    conoc(NUL);
  3562. #endif /* NOLOCAL */
  3563.                  quote = 0;             /* Turn off quote flag */
  3564.                  continue;              /* and not the l or L */
  3565. #endif /* CK_LBRK */
  3566.  
  3567.              } else if (x == CMDQ) {    /* Backslash itself */
  3568.                  debug(F100,"OUTPUT CMDQ","",0);
  3569.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3570.                  if (xx < 0)
  3571.                    goto outerr;
  3572.                  quote = 0;
  3573.                  continue;
  3574.  
  3575.              } else {                   /* if \ not followed by special esc */
  3576.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3577.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3578.                  if (xx < 0)
  3579.                    goto outerr;
  3580.                  quote = 0;             /* Turn off quote flag */
  3581.              }
  3582.         } else if (x == CMDQ) {         /* This is the quote character */
  3583.             quote = 1;                  /* Go back and get next character */
  3584.             continue;                   /* which is quoted */
  3585.         }
  3586.         xx = oboc(dopar((char)x));      /* Output this character */
  3587.         debug(F111,"dooutput",obuf,obn);
  3588.         if (xx < 0)
  3589.           goto outerr;
  3590. #ifdef COMMENT
  3591.         if (seslog && duplex) {         /* Log the character if log is on */
  3592.             logchar((char)x);
  3593.         }
  3594. #endif /* COMMENT */
  3595.         if (x == '\015') {              /* String contains carriage return */
  3596.             int stuff = -1, stuff2 = -1;
  3597.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3598.                 stuff = LF;             /* Stuff LF */
  3599.             }
  3600. #ifdef TNCODE
  3601.             /* TELNET NEWLINE ON/OFF/RAW */
  3602.             if (is_tn) {
  3603.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3604.                         tn_b_nlm :
  3605.                         tn_nlm
  3606.                         ) {
  3607.                   case TNL_CR:
  3608.                     break;
  3609.                   case TNL_CRNUL:
  3610.                     stuff2 = stuff;
  3611.                     stuff  = NUL;
  3612.                     break;
  3613.                   case TNL_CRLF:
  3614.                     stuff2 = stuff;
  3615.                     stuff = LF;
  3616.                     break;
  3617.                 }
  3618.             }
  3619. #endif /* TNCODE */
  3620.             if (stuff > -1) {           /* Stuffing another character... */
  3621.                 xx = oboc(dopar((CHAR)stuff));
  3622.                 if (xx < 0)
  3623.                   goto outerr;
  3624. #ifdef COMMENT
  3625.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3626.                     logchar((char)stuff);
  3627.                 }
  3628. #endif /* COMMENT */
  3629.             }
  3630.             if (stuff2 > -1) {          /* Stuffing another character... */
  3631.                 xx = oboc(dopar((CHAR)stuff2));
  3632.                 if (xx < 0)
  3633.                   goto outerr;
  3634. #ifdef COMMENT
  3635.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3636.                     logchar((char)stuff2);
  3637.                 }
  3638. #endif /* COMMENT */
  3639.             }
  3640.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3641.               goto outerr;
  3642.         }
  3643.     }
  3644.     if (cx == XXLNOUT) {
  3645.         s = "\015";
  3646.         cx = 0;
  3647.         goto outagain;
  3648.     }
  3649.     if (quote == 1)                     /* String ended with backslash */
  3650.       xx = oboc(dopar(CMDQ));
  3651.  
  3652.     if (obn > 0)                        /* OUTPUT done */
  3653.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3654.         goto outerr;
  3655.     return(1);
  3656.  
  3657. outerr:                                 /* OUTPUT command error handler */
  3658.     if (msgflg) printf("?OUTPUT execution error\n");
  3659.     return(0);
  3660.  
  3661. /* Remove "local" OUTPUT macro defininitions */
  3662.  
  3663. #ifdef COMMENT
  3664. /* No more macros ... */
  3665. #undef oboc
  3666. #undef obfls
  3667. #endif /* COMMENT */
  3668. }
  3669. #endif /* NOSPL */
  3670.  
  3671. /* Display version herald and initial prompt */
  3672.  
  3673. VOID
  3674. herald() {
  3675.     int x = 0, i;
  3676.     extern int srvcdmsg;
  3677.     extern char * cdmsgfile[];
  3678. #ifndef NOCMDL
  3679.     extern char * bannerfile;
  3680.     debug(F110,"herald bannerfile",bannerfile,0);
  3681.     if (bannerfile) {
  3682.         concb((char)escape);
  3683.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3684.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3685.             if (srvcdmsg) {
  3686.                 for (i = 0; i < 8; i++) {
  3687.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3688.                     if (zchki(cdmsgfile[i]) > -1) {
  3689.                         printf("\n");
  3690.                         dotype(cdmsgfile[i],
  3691.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3692.                         break;
  3693.                     }
  3694.                 }
  3695.             }
  3696.             return;
  3697.         }
  3698.     }
  3699. #endif /* NOCMDL */
  3700.  
  3701. #ifdef COMMENT
  3702.     /* The following generates bad code in SCO compilers. */
  3703.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3704.     /* statement when all conditions are false, x has a value of -32. */
  3705.     if (noherald || bgset > 0 || (bgset != 0 && backgrd != 0)) x = 1;
  3706. #else
  3707.     x = 0;
  3708.     if (noherald)
  3709.       x = 1;
  3710.     else if (bgset > 0)
  3711.       x = 1;
  3712.     else if (bgset < 0 && backgrd > 0)
  3713.       x = 1;
  3714. #endif /* COMMENT */
  3715.  
  3716.     if (x == 0) {
  3717. #ifdef datageneral
  3718.         printf("%s, for%s\n",versio,ckxsys);
  3719. #else
  3720. #ifdef OSK
  3721.         printf("%s, for%s\n",versio,ckxsys);
  3722. #else
  3723.         printf("%s, for%s\n\r",versio,ckxsys);
  3724. #endif /* OSK */
  3725. #endif /* datageneral */
  3726.         printf(" Copyright (C) 1985, 2003,\n");
  3727.         printf("  Trustees of Columbia University in the City of New York.\n");
  3728.  
  3729. #ifdef OS2
  3730.        shoreg();
  3731. #endif /* OS2 */
  3732.  
  3733.         if (!quiet && !backgrd) {
  3734. #ifdef COMMENT
  3735. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3736.             char * s;
  3737.             extern int xfermode;
  3738. #ifdef VMS
  3739.             s = "AUTOMATIC";
  3740. #else
  3741.             if (xfermode == XMODE_A) {
  3742.                 s = "AUTOMATIC";
  3743.             } else {
  3744.                 s = gfmode(binary,1);
  3745.             }
  3746.             if (!s) s = "";
  3747. #endif /* VMS */
  3748.             if (*s)
  3749.               printf("Default file-transfer mode is %s\n", s);
  3750. #endif /* COMMENT */
  3751.  
  3752.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3753.             if (srvcdmsg) {
  3754.                 for (i = 0; i < 8; i++) {
  3755.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3756.                     if (zchki(cdmsgfile[i]) > -1) {
  3757.                         printf("\n");
  3758.                         dotype(cdmsgfile[i],
  3759.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3760.                         break;
  3761.                     }
  3762.                 }
  3763.             }
  3764.             printf("Type ? or HELP for help.\n");
  3765.         }
  3766.     }
  3767. }
  3768.  
  3769. /*  G F M O D E  --  Get File (transfer) Mode  */
  3770.  
  3771. char *
  3772. gfmode(binary,upcase) int binary, upcase; {
  3773.     char * s;
  3774.     switch (binary) {
  3775.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3776. #ifdef VMS
  3777.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3778.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3779.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3780.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3781. #else
  3782. #ifdef MAC
  3783.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3784.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3785. #else
  3786.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3787. #ifdef CK_LABELED
  3788.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3789. #endif /* CK_LABELED */
  3790. #endif /* MAC */
  3791. #endif /* VMS */
  3792.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3793.       default: s = "";
  3794.     }
  3795.     return(s);
  3796. }
  3797.  
  3798. #ifndef NOSPL
  3799. static int
  3800. isaa(s) char * s; {                     /* Is associative array */
  3801.     char c;
  3802.     int x;
  3803.     if (!s) s = "";
  3804.     if (!*s) return(0);
  3805.     s++;
  3806.     while ((c = *s++)) {
  3807.         if (c == '<') {
  3808.             x = strlen(s);
  3809.             return ((*(s+x-1) == '>') ? 1 : 0);
  3810.         }
  3811.     }
  3812.     return(0);
  3813. }
  3814.  
  3815. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3816.  
  3817. /*
  3818.   Call this way:  v = mlook(table,word,n);
  3819.  
  3820.     table - a 'struct mtab' table.
  3821.     word  - the target string to look up in the table.
  3822.     n     - the number of elements in the table.
  3823.  
  3824.   The keyword table must be arranged in ascending alphabetical order, and
  3825.   all letters must be lowercase.
  3826.  
  3827.   Returns the table index, 0 or greater, if the name was found, or:
  3828.  
  3829.    -3 if nothing to look up (target was null),
  3830.    -2 if ambiguous,
  3831.    -1 if not found.
  3832.  
  3833.   A match is successful if the target matches a keyword exactly, or if
  3834.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3835.   target matches two or more keywords from the table.
  3836. */
  3837. int
  3838. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3839.     register int i;
  3840.     int v, w, cmdlen = 0;
  3841.     char c = 0, c1, * s;
  3842.     if (!cmd) cmd = "";
  3843.  
  3844.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3845.     debug(F111,"MLOOK",cmd,cmdlen);
  3846.  
  3847.     c1 = *cmd;
  3848.     if (isupper(c1))
  3849.       c1 = tolower(c1);
  3850.     if (cmdlen < 1)
  3851.       return(-3);
  3852.  
  3853. /* Not null, look it up */
  3854.  
  3855.     if (n < 12) {                       /* Not worth it for small tables */
  3856.         i = 0;
  3857.     } else {                            /* Binary search for where to start */
  3858.         int lo = 0;
  3859.         int hi = n;
  3860.         int count = 0;
  3861.         while (lo+2 < hi && ++count < 12) {
  3862.             i = lo + ((hi - lo) / 2);
  3863.             c = *(table[i].kwd);
  3864.             if (isupper(c)) c = tolower(c);
  3865.             if (c < c1) {
  3866.                 lo = i;
  3867.             } else {
  3868.                 hi = i;
  3869.             }
  3870.         }
  3871.         i = (c < c1) ? lo+1 : lo;
  3872.     }
  3873.     for ( ; i < n-1; i++) {
  3874.         s = table[i].kwd;
  3875.         if (!s) s = "";
  3876.         if (!*s) continue;              /* Empty table entry */
  3877.         c = *s;
  3878.         if (isupper(c)) c = tolower(c);
  3879.         if (c1 != c) continue;          /* First char doesn't match */
  3880.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  3881.           return(i);
  3882.         v = !ckstrcmp(s,cmd,cmdlen,0);
  3883.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3884.         if (v && w)                     /* Have abbreviated match? */
  3885.           return(i);
  3886.         if (v)                          /* Ambiguous? */
  3887.           return(-2);
  3888.         if (w > 0)                      /* Past our alphabetic area? */
  3889.           return(-1);
  3890.     }
  3891.  
  3892. /* Last (or only) element */
  3893.  
  3894.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3895.       return(n-1);
  3896.  
  3897.     return(-1);
  3898. }
  3899.  
  3900. /* mxlook is like mlook, but an exact full-length match is required */
  3901.  
  3902. int
  3903. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3904.     register int i;
  3905.     int w, cmdlen = 0, one = 0;
  3906.     register char c = 0, c1, * s;
  3907.  
  3908.     if (!cmd) cmd = "";                 /* Check args */
  3909.  
  3910.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3911.     debug(F111,"MXLOOK",cmd,cmdlen);
  3912.  
  3913.     c1 = *cmd;                          /* First char of string to look up */
  3914.     if (isupper(c1))
  3915.       c1 = tolower(c1);
  3916.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  3917.       one = 1;
  3918.  
  3919.     if (cmdlen < 1)                     /* Nothing to look up */
  3920.       return(-3);
  3921.  
  3922.     if (n < 12) {                       /* Not worth it for small tables */
  3923.         i = 0;
  3924.     } else {                            /* Binary search for where to start */
  3925.         int lo = 0;
  3926.         int hi = n;
  3927.         int count = 0;
  3928.         while (lo+2 < hi && ++count < 12) {
  3929.             i = lo + ((hi - lo) / 2);
  3930.             c = *(table[i].kwd);
  3931.             if (isupper(c)) c = tolower(c);
  3932.             if (c < c1) {
  3933.                 lo = i;
  3934.             } else {
  3935.                 hi = i;
  3936.             }
  3937.         }
  3938.         i = (c < c1) ? lo+1 : lo;
  3939.     }
  3940.     for ( ; i < n; i++) {               /* Look thru table */
  3941.         s = table[i].kwd;               /* This entry */
  3942.         if (!s) s = "";
  3943.         if (!*s) continue;              /* Empty table entry */
  3944.         c = *s;
  3945.         if (isupper(c)) c = tolower(c);
  3946.         if (c1 != c) continue;          /* First char doesn't match */
  3947.         if (one) {                      /* Name is one char long */
  3948.             if (!*(s+1))
  3949.               return(i);                /* So is table entry */
  3950.         }
  3951. #ifdef COMMENT
  3952.         if (((int)strlen(s) == cmdlen) &&
  3953.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  3954. #else
  3955.         w = ckstrcmp(s,cmd,-1,0);
  3956.         if (!w) return(i);
  3957.         if (w > 0) return(-1);
  3958. #endif /* COMMENT */
  3959.     }
  3960.     return(-1);
  3961. }
  3962.  
  3963. /* mxxlook is like mxlook, but case-sensitive */
  3964.  
  3965. int
  3966. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3967.     int i, cmdlen;
  3968.     if (!cmd) cmd = "";
  3969.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  3970.     /* debug(F111,"mxxlook target",cmd,n); */
  3971.     for (i = 0; i < n; i++) {
  3972.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  3973.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  3974.           return(i);
  3975.     }
  3976.     return(-1);
  3977. }
  3978.  
  3979. static int
  3980. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  3981.     if (val)
  3982.       printf(">>> %s: \"%s\"\n", nam, val);
  3983.     else
  3984.       printf(">>> %s: (undef)\n", nam);
  3985.     return(0);
  3986. }
  3987.  
  3988. #ifdef USE_VARLEN                       /* Not used */
  3989.  
  3990. /*  V A R L E N  --  Get length of variable's value.
  3991.  
  3992.   Given a variable name, return the length of its definition or 0 if the
  3993.   variable is not defined.  If it is defined, set argument s to point to its
  3994.   definition.  Otherwise set s to NULL.
  3995. */
  3996. int
  3997. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  3998.     int x, z;
  3999.     char *p = NULL, c;
  4000.  
  4001.     *s = NULL;
  4002.     if (!nam) return(0);                /* Watch out for null pointer */
  4003.     if (*nam == CMDQ) {
  4004.         nam++;
  4005.         if (*nam == '%') {              /* If it's a variable name */
  4006.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  4007.             p = (char *)0;              /* Initialize value pointer */
  4008.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4009.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  4010.             } else {                    /* It's a global variable */
  4011.                 if (c < 33 || c > GVARS) return(0);
  4012.                 p = g_var[c];           /* Get pointer from global-var table */
  4013.             }
  4014.         } else if (*nam == '&') {               /* An array reference? */
  4015.             char **q;
  4016.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4017.               return(-1);               /* return -1. */
  4018.             x -= ARRAYBASE;             /* Convert name to number. */
  4019.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4020.               return(0);                /* return -2. */
  4021.             if (z > a_dim[x])           /* If subscript out of range, */
  4022.               return(0);                /* return -3. */
  4023.             p = q[z];
  4024.         }
  4025.     } else {                            /* Macro */
  4026.         z = isaa(nam);
  4027.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  4028.         if (x < 0)
  4029.           return(0);
  4030.         p = mactab[x].mval;
  4031.     }
  4032.     if (p)
  4033.       *s = p;
  4034.     else
  4035.       p = "";
  4036.     return((int)strlen(p));
  4037. }
  4038. #endif /* USE_VARLEN */
  4039.  
  4040. /*
  4041.   This routine is for the benefit of those compilers that can't handle
  4042.   long string constants or continued lines within them.  Long predefined
  4043.   macros like FOR, WHILE, and XIF have their contents broken up into
  4044.   arrays of string pointers.  This routine concatenates them back into a
  4045.   single string again, and then calls the real addmac() routine to enter
  4046.   the definition into the macro table.
  4047. */
  4048. int
  4049. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  4050.     int i, x, y; char *p;
  4051.     x = 0;                              /* Length counter */
  4052.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  4053.         debug(F111,"addmmac line",s[i],y);
  4054.         x += y;
  4055.     }
  4056.     debug(F101,"addmmac lines","",i);
  4057.     debug(F101,"addmmac loop exit","",y);
  4058.     debug(F111,"addmmac length",nam,x);
  4059.     if (x < 0) return(-1);
  4060.  
  4061.     p = malloc(x+1);                    /* Allocate space for all of it. */
  4062.     if (!p) {
  4063.         printf("?addmmac malloc error: %s\n",nam);
  4064.         debug(F110,"addmmac malloc error",nam,0);
  4065.         return(-1);
  4066.     }
  4067.     *p = '\0';                          /* Start off with null string. */
  4068.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4069.       ckstrncat(p,s[i],x+1);
  4070.     y = (int)strlen(p);                 /* Final precaution. */
  4071.     debug(F111,"addmmac constructed string",p,y);
  4072.     if (y == x) {
  4073.         y = addmac(nam,p);              /* Add result to the macro table. */
  4074.     } else {
  4075.         debug(F100,"addmmac length mismatch","",0);
  4076.         printf("\n!addmmac internal error!\n");
  4077.         y = -1;
  4078.     }
  4079.     free(p);                            /* Free the temporary copy. */
  4080.     return(y);
  4081. }
  4082.  
  4083. /* Here is the real addmac routine. */
  4084.  
  4085. /* Returns -1 on failure, macro table index >= 0 on success. */
  4086.  
  4087. int mtchanged = 0;
  4088.  
  4089. int
  4090. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4091.     int i, x, y, z, namlen, deflen, flag = 0;
  4092.     int replacing = 0, deleting = 0;
  4093.     char * p = NULL, c, *s;
  4094.     extern int tra_asg; int tra_tmp;
  4095.  
  4096.     if (!nam) return(-1);
  4097.     if (!*nam) return(-1);
  4098.  
  4099. #ifdef IKSD
  4100.     if (inserver &&
  4101. #ifdef IKSDCONF
  4102.         iksdcf
  4103. #else /* IKSDCONF */
  4104.         1
  4105. #endif /* IKSDCONF */
  4106.         ) {
  4107.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4108.             !ckstrcmp("on_logout",nam,-1,0))
  4109.           return(-1);
  4110.     }
  4111. #endif /* IKSD */
  4112.  
  4113.     namlen = 0;
  4114.     p = nam;
  4115.     while (*p++) namlen++;              /* (instead of strlen) */
  4116.  
  4117.     tra_tmp = tra_asg;                  /* trace... */
  4118.     debug(F111,"addmac nam",nam,namlen);
  4119.     if (!def) {                         /* Watch out for null pointer */
  4120.         deflen = 0;
  4121.         debug(F111,"addmac def","(null pointer)",deflen);
  4122.     } else {
  4123.         deflen = 0;
  4124.         p = def;
  4125.         while (*p++) deflen++;          /* (instead of strlen) */
  4126.         debug(F010,"addmac def",def,0);
  4127.     }
  4128. #ifdef USE_VARLEN                       /* NOT USED */
  4129.     /* This does not boost performance much because varlen() does a lot */
  4130.     x = varlen(nam,&s);
  4131.     if (x > 0 && x >= deflen) {
  4132.         strcpy(s,def);                  /* NOT USED */
  4133.         flag = 1;
  4134.         p = s;
  4135.     }
  4136. #endif /* USE_VARLEN */
  4137.  
  4138.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4139.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4140.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4141.         if (!flag) {
  4142.             tra_asg = 0;
  4143.             delmac(nam,0);              /* Delete any old value. */
  4144.             tra_asg = tra_tmp;
  4145.         }
  4146.         if (deflen < 1) {               /* Null definition */
  4147.             p = NULL;                   /* Better not malloc or strcpy! */
  4148.         } else if (!flag) {             /* A substantial definition */
  4149.             p = malloc(deflen + 1);     /* Allocate space for it */
  4150.             if (!p) {
  4151.                 printf("?addmac malloc error 2\n");
  4152.                 return(-1);
  4153.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4154.         }
  4155.  
  4156.         /* Now p points to the definition, or is a null pointer */
  4157.  
  4158.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4159.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4160.                 g_var[c] = p;           /* No, it's top level one */
  4161.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4162.             } else {                    /* Yes, it's a macro argument */
  4163.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4164.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4165.             }
  4166.         } else {                        /* It's a \%a-z variable */
  4167.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4168.             if (isupper(c)) c = (char) tolower(c);
  4169.             g_var[c] = p;               /* Put pointer in global-var table */
  4170.         }
  4171.         if (tra_asg) traceval(nam,p);
  4172.         return(0);
  4173.     } else if (*nam == '&') {           /* An array reference? */
  4174.         char **q = NULL;
  4175.         int rc = 0;
  4176.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4177.           return(-1);                   /* return -1. */
  4178.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4179.           rc = -2;                      /* subscript out of range, ret -2 */
  4180.         if (!flag) {
  4181.             tra_asg = 0;
  4182.             delmac(nam,0);              /* Delete any old value. */
  4183.             tra_asg = tra_tmp;
  4184.         }
  4185.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4186.         if (x > 'z' - ARRAYBASE + 1)
  4187.           rc = -1;
  4188.         if (rc != -1) {
  4189.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4190.               return(-3);               /* return -3. */
  4191.         }
  4192.         if (rc < 0)
  4193.           return(rc);
  4194.         if (!flag) {
  4195.             if (deflen > 0) {
  4196.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4197.                     printf("addmac macro error 7: %s\n",nam);
  4198.                     return(-4);         /* for new def, return -4 on fail. */
  4199.                 }
  4200.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4201.             } else p = NULL;
  4202.         }
  4203.         q[z] = p;                       /* Store pointer to it. */
  4204.         if (x == 0) {                   /* Arg vector array */
  4205.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4206.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4207.                     makestr(&(toparg[z]),p);
  4208.                 } else {
  4209.                     makestr(&(m_arg[maclvl][z]),p);
  4210.                 }
  4211.             }
  4212.         }
  4213.         if (tra_asg) traceval(nam,p);
  4214.         return(0);                      /* Done. */
  4215.     }
  4216.  
  4217. /* Not a macro argument or a variable, so it's a macro definition */
  4218.  
  4219. #ifdef USE_VARLEN
  4220.     if (flag) {
  4221.         if (tra_asg) traceval(nam,p);
  4222.         return(0);
  4223.     }
  4224. #endif /* USE_VARLEN */
  4225.     x = isaa(nam) ?                     /* If it's an associative array */
  4226.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4227.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4228.     if (x > -1) {                       /* If found... */
  4229.         if (deflen > 0)                 /* and a new definition was given */
  4230.           replacing = 1;                /* we're replacing */
  4231.         else                            /* otherwise */
  4232.           deleting = 1;                 /* we're deleting */
  4233.     }
  4234.     if (deleting) {                     /* Deleting... */
  4235.         if (delmac(nam,0) < 0)
  4236.           return(-1);
  4237.         mtchanged++;
  4238.         if (tra_asg) traceval(nam,p);
  4239.         return(0);
  4240.     } else if (deflen < 1)              /* New macro with no definition */
  4241.       return(0);                        /* Nothing to do. */
  4242.  
  4243.     if (replacing) {                    /* Replacing an existing macro */
  4244.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4245.             free(mactab[x].mval);       /* free it. */
  4246.             mactab[x].mval = NULL;
  4247.         }
  4248.         mtchanged++;
  4249.         y = x;                          /* Replacement index. */
  4250.  
  4251.     } else {                            /* Adding a new macro... */
  4252.         char c1, c2;                    /* Use fast lookup to find the */
  4253.         c1 = *nam;                      /* alphabetical slot. */
  4254.         if (isupper(c1)) c1 = (char) tolower(c1);
  4255.  
  4256.         if (nmac < 5) {                 /* Not worth it for small tables */
  4257.             y = 0;
  4258.         } else {                        /* First binary search to find */
  4259.             int lo = 0;                 /* where to start */
  4260.             int hi = nmac;
  4261.             int count = 0;
  4262.             char c = 0;
  4263.             while (lo+2 < hi && ++count < 12) {
  4264.                 y = lo + ((hi - lo) / 2);
  4265.                 c = *(mactab[y].kwd);
  4266.                 if (isupper(c)) c = (char) tolower(c);
  4267.                 if (c < c1) {
  4268.                     lo = y;
  4269.                 } else {
  4270.                     hi = y;
  4271.                 }
  4272.             }
  4273.             y = (c < c1) ? lo+1 : lo;
  4274.         }
  4275.         /* Now search linearly from starting location */
  4276.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4277.             c2 = *(mactab[y].kwd);
  4278.             if (isupper(c2)) c2 = (char) tolower(c2);
  4279.             if (c1 > c2)
  4280.               continue;
  4281.             if (c1 < c2)
  4282.               break;
  4283.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4284.               break;
  4285.         }
  4286.         if (y == MAC_MAX) {             /* Macro table is full. */
  4287.             debug(F101,"addmac table overflow","",y);
  4288.             printf("?Macro table overflow\n");
  4289.             return(-1);
  4290.         }
  4291.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4292.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4293.                 mactab[i].kwd = mactab[i-1].kwd;
  4294.                 mactab[i].mval = mactab[i-1].mval;
  4295.                 mactab[i].flgs = mactab[i-1].flgs;
  4296.             }
  4297.         }
  4298.         mtchanged++;
  4299.         p = malloc(namlen + 1);         /* Allocate space for name */
  4300.         if (!p) {
  4301.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4302.             return(-1);
  4303.         }
  4304.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4305.         mactab[y].kwd = p;              /* Add pointer to table */
  4306.     }
  4307.     if (deflen > 0) {                   /* If we have a definition */
  4308.         p = malloc(deflen + 1);         /* Get space */
  4309.         if (p == NULL) {
  4310.             printf("?Space exhausted - \"%s\"\n", nam);
  4311.             if (mactab[y].kwd) {
  4312.                 free(mactab[y].kwd);
  4313.                 mactab[y].kwd = NULL;
  4314.             }
  4315.             return(-1);
  4316.         } else {
  4317.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4318.         }
  4319.     } else {                            /* definition is empty */
  4320.         p = NULL;
  4321.     }
  4322.     mactab[y].mval = p;                 /* Macro points to definition */
  4323.     mactab[y].flgs = 0;                 /* No flags */
  4324.     if (!replacing)                     /* If new macro */
  4325.       nmac++;                           /* count it */
  4326.     if (tra_asg) traceval(nam,p);
  4327.     return(y);
  4328. }
  4329.  
  4330. int
  4331. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4332.     int i;
  4333.     extern int tra_asg;
  4334.     if (x < 0) return(x);
  4335.     if (tra_asg)
  4336.       traceval(mactab[x].kwd,NULL);
  4337.  
  4338.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4339.         free(mactab[x].kwd);
  4340.         mactab[x].kwd = NULL;
  4341.     }
  4342.     if (mactab[x].mval) {               /* and for the definition */
  4343.         free(mactab[x].mval);
  4344.         mactab[x].mval = NULL;
  4345.     }
  4346.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4347.         mactab[i].kwd = mactab[i+1].kwd;
  4348.         mactab[i].mval = mactab[i+1].mval;
  4349.         mactab[i].flgs = mactab[i+1].flgs;
  4350.     }
  4351.     nmac--;                             /* One less macro */
  4352.  
  4353.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4354.     mactab[nmac].mval = NULL;
  4355.     mactab[nmac].flgs = 0;
  4356.     mtchanged++;
  4357.     return(0);
  4358. }
  4359.  
  4360. int
  4361. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4362.     int x, z;
  4363.     char *p, c;
  4364.     extern int tra_asg;
  4365.  
  4366.     if (!nam) return(0);                /* Watch out for null pointer */
  4367.     debug(F110,"delmac nam",nam,0);
  4368. #ifdef IKSD
  4369.     if ( inserver &&
  4370. #ifdef IKSDCONF
  4371.         iksdcf
  4372. #else /* IKSDCONF */
  4373.         1
  4374. #endif /* IKSDCONF */
  4375.         ) {
  4376.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4377.             !ckstrcmp("on_logout",nam,-1,0))
  4378.           return(-1);
  4379.     }
  4380. #endif /* IKSD */
  4381.  
  4382.     if (*nam == CMDQ) nam++;
  4383.     if (*nam == '%') {                  /* If it's a variable name */
  4384.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4385.         p = (char *)0;                  /* Initialize value pointer */
  4386.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4387.             p = toparg[c - '0'];
  4388.             if (p) if (p != g_var[c]) {
  4389.                 free(p);
  4390.                 toparg[c - '0'] = NULL;
  4391.             }
  4392.             p = g_var[c];
  4393.             g_var[c] = NULL;            /* Zero the table entry */
  4394.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4395.             p = m_xarg[maclvl][c - '0'];
  4396.             if (p) if (p != g_var[c]) {
  4397.                 free(p);
  4398.                 m_xarg[maclvl][c - '0'] = NULL;
  4399.             }
  4400.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4401.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4402.         } else {                        /* It's a global variable */
  4403.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4404.             p = g_var[c];               /* Get pointer from global-var table */
  4405.             g_var[c] = NULL;            /* Zero the table entry */
  4406.         }
  4407.         if (p) {
  4408.             debug(F010,"delmac def",p,0);
  4409.             free(p);                    /* Free the storage */
  4410.             p = NULL;
  4411.         } else debug(F110,"delmac def","(null pointer)",0);
  4412.         if (tra_asg) traceval(nam,NULL);
  4413.         return(0);
  4414.     }
  4415.     if (*nam == '&') {                  /* An array reference? */
  4416.         char **q;
  4417.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4418.           return(-1);                   /* return -1. */
  4419.         x -= ARRAYBASE;                 /* Convert name to number. */
  4420.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4421.           return(-2);                   /* return -2. */
  4422.         if (z > a_dim[x])               /* If subscript out of range, */
  4423.           return(-3);                   /* return -3. */
  4424.         if (q[z]) {                     /* If there is an old value, */
  4425.             debug(F010,"delmac def",q[z],0);
  4426.             if (x != 0)                 /* Macro arg vector is just a copy */
  4427.               free(q[z]);               /* Others are real so free them */
  4428.             q[z] = NULL;
  4429.             if (x == 0) {               /* Arg vector array */
  4430.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4431.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4432.                         makestr(&(toparg[z]),NULL);
  4433.                     } else {
  4434.                         makestr(&(m_arg[maclvl][z]),NULL);
  4435.                     }
  4436.                 }
  4437.             }
  4438.             if (tra_asg) traceval(nam,NULL);
  4439.         } else debug(F010,"delmac def","(null pointer)",0);
  4440.     }
  4441.  
  4442.    /* Not a variable or an array, so it must be a macro. */
  4443.  
  4444.     z = isaa(nam);
  4445.     debug(F111,"delmac isaa",nam,z);
  4446.     debug(F111,"delmac exact",nam,exact);
  4447.     x = z ? mxxlook(mactab,nam,nmac) :
  4448.       exact ? mxlook(mactab,nam,nmac) :
  4449.         mlook(mactab,nam,nmac);
  4450.     if (x < 0) {
  4451.         debug(F111,"delmac mlook",nam,x);
  4452.         return(x);
  4453.     }
  4454.     return(xdelmac(x));
  4455. }
  4456.  
  4457. VOID
  4458. initmac() {                             /* Init macro & variable tables */
  4459.     int i, j, x;
  4460.  
  4461.     nmac = 0;                           /* No macros */
  4462.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4463.         mactab[i].kwd = NULL;
  4464.         mactab[i].mval = NULL;
  4465.         mactab[i].flgs = 0;
  4466.     }
  4467.     mtchanged++;
  4468.     x = (MAXARGLIST + 1) * sizeof(char **);
  4469.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4470.         m_xarg[i] = (char **) malloc(x);
  4471.         mrval[i] = NULL;                /* Macro return value */
  4472.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4473.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4474.             if (j < 10)                 /* For the \%0..\%9 variables */
  4475.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4476.             if (m_xarg[i])              /* For \&_[] - all args. */
  4477.               m_xarg[i][j] = NULL;
  4478.         }
  4479.     }
  4480.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4481.         g_var[i] = NULL;
  4482.     }
  4483.     /* And the table of arrays */
  4484.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4485.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4486.         a_dim[i] = 0;                   /* and a dimension of zero */
  4487.         a_link[i] = -1;
  4488.         for (j = 0; j < CMDSTKL; j++) {
  4489.             aa_ptr[j][i] = (char **) NULL;
  4490.             aa_dim[j][i] = 0;
  4491.         }
  4492.     }
  4493. }
  4494.  
  4495. int
  4496. popclvl() {                             /* Pop command level, return cmdlvl */
  4497.     extern int tra_cmd;
  4498.     struct localvar * v;
  4499.     int i, topcmd;
  4500.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4501.     if (cmdlvl > 0) {
  4502.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4503.             while (v) {                 /* Yes */
  4504.                 if (v->lv_value)        /* Copy old ones back */
  4505.                   addmac(v->lv_name,v->lv_value);
  4506.                 else
  4507.                   delmac(v->lv_name,1);
  4508.                 v = v->lv_next;
  4509.             }
  4510.             freelocal(cmdlvl);          /* Free local storage */
  4511.         }
  4512.         /* Automatic arrays do not use the localhead list */
  4513.  
  4514.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4515.             if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
  4516.                 dclarray((char)(i+ARRAYBASE),0); /* Destroy global one */
  4517.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4518.                 a_dim[i] = aa_dim[cmdlvl][i];
  4519.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4520.                 aa_dim[cmdlvl][i] = 0;
  4521.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4522.                 dclarray((char)(i+ARRAYBASE),0); /* (see pusharray()) */
  4523.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4524.                 aa_dim[cmdlvl][i] = 0;
  4525.             }
  4526.             /* Otherwise do nothing - it is a local array that was declared */
  4527.             /* at a level above this one so leave it alone. */
  4528.         }
  4529.     }
  4530.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4531.         cmdlvl = 0;                     /* just make sure all the */
  4532.         tlevel = -1;                    /* stack pointers are set right */
  4533.         maclvl = -1;                    /* and return */
  4534.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4535.         debug(F101,"popclvl tlevel","",tlevel);
  4536.         if (tlevel > -1) {              /* Yes, */
  4537.             fclose(tfile[tlevel]);      /* close it */
  4538.  
  4539.             if (tra_cmd)
  4540.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4541.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4542.             if (tfnam[tlevel]) {        /* free storage for name */
  4543.                 free(tfnam[tlevel]);
  4544.                 tfnam[tlevel] = NULL;
  4545.             }
  4546.             tlevel--;                   /* and pop take level */
  4547.             cmdlvl--;                   /* and command level */
  4548.             quiet = xquiet[cmdlvl];
  4549.         } else
  4550.           tlevel = -1;
  4551.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4552.         topcmd = lastcmd[maclvl];
  4553.         debug(F101,"popclvl maclvl","",maclvl);
  4554.         if (maclvl > -1) {              /* Yes, */
  4555. #ifdef COMMENT
  4556.             int i;
  4557.             char **q;
  4558. #endif /* COMMENT */
  4559.             macp[maclvl] = "";          /* set macro pointer to null string */
  4560.             *cmdbuf = '\0';             /* clear the command buffer */
  4561.  
  4562.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4563.                 (m_arg[maclvl-1][0]) &&
  4564.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4565.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4566.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4567.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4568.                 mrval[maclvl+1]) {
  4569.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4570.             }
  4571.             if (maclvl+1 < MACLEVEL) {
  4572.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4573.                     free(mrval[maclvl+1]);
  4574.                     mrval[maclvl+1] = NULL;
  4575.                 }
  4576.             }
  4577.             if (tra_cmd)
  4578.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4579.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4580.  
  4581.             maclvl--;                   /* Pop macro level */
  4582.             cmdlvl--;                   /* and command level */
  4583.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4584.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4585.  
  4586.             quiet = xquiet[cmdlvl];
  4587.             if (maclvl > -1) {
  4588.                 a_ptr[0] = m_xarg[maclvl];
  4589.                 a_dim[0] = n_xarg[maclvl] - 1;
  4590.         debug(F111,"a_dim[0]","B",a_dim[0]);
  4591.             } else {
  4592.                 a_ptr[0] = topxarg;
  4593.                 a_dim[0] = topargc - 1;
  4594.         debug(F111,"a_dim[0]","C",a_dim[0]);
  4595.             }
  4596.         } else {
  4597.             maclvl = -1;
  4598.         }
  4599. #ifndef NOSEXP
  4600.         debug(F101,"popclvl topcmd","",topcmd);
  4601.         if (topcmd == XXSEXP) {
  4602.             extern char * sexpval;
  4603.             makestr(&(mrval[maclvl+1]),sexpval);
  4604.         }
  4605. #endif /* NOSEXP */
  4606.     } else {
  4607.         cmdlvl--;
  4608.     }
  4609.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4610.     if (prstring[cmdlvl]) {
  4611.         cmsetp(prstring[cmdlvl]);
  4612.         makestr(&(prstring[cmdlvl]),NULL);
  4613.     }
  4614. #ifndef MAC
  4615.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4616.         setint();
  4617.         concb((char)escape);            /* Go into cbreak mode */
  4618.     }
  4619. #endif /* MAC */
  4620.     xcmdsrc = cmdstk[cmdlvl].src;
  4621.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4622.     debug(F101,"popclvl tlevel","",tlevel);
  4623.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4624. }
  4625. #else /* No script programming language */
  4626. int popclvl() {                         /* Just close current take file. */
  4627.     if (tlevel > -1) {                  /* if any... */
  4628.         if (tfnam[tlevel]) {
  4629.             free(tfnam[tlevel]);
  4630.             tfnam[tlevel] = NULL;
  4631.         }
  4632.         fclose(tfile[tlevel--]);
  4633.     }
  4634.     if (tlevel == -1) {                 /* And if back at top level */
  4635.         setint();
  4636.         concb((char)escape);            /* and go back into cbreak mode. */
  4637.     }
  4638.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4639.     return(tlevel + 1);
  4640. }
  4641. #endif /* NOSPL */
  4642.  
  4643.  
  4644. #ifndef NOSPL
  4645. static int
  4646. iseom(m) char * m; {                    /* Test if at end of macro def */
  4647.     if (!m)
  4648.       m = "";
  4649.     debug(F111,"iseom",m,maclvl);
  4650.     while (*m) {
  4651.         /* Anything but Space and Comma means more macro is left */
  4652.         if ((*m > SP) && (*m != ',')) {
  4653.             debug(F111,"iseom return",m,0);
  4654.             return(0);
  4655.         }
  4656.         m++;
  4657.     }
  4658.     debug(F111,"iseom return",m,1);
  4659.     return(1);                          /* Nothing left */
  4660. }
  4661. #endif /* NOSPL */
  4662.  
  4663. /* Pop all command levels that can be popped */
  4664.  
  4665. int
  4666. prepop() {
  4667.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4668.         while (
  4669. #ifndef NOSPL
  4670.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4671. #endif /* NOSPL */
  4672.             (tlevel > -1) &&
  4673.             feof(tfile[tlevel]))        /* And at end of file... */
  4674. #ifndef NOSPL
  4675.                /* Or command source is macro... */
  4676.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4677.                 (maclvl > -1) &&
  4678.                 iseom(macp[maclvl])))  /* and at end of macro, then... */
  4679. #endif /* NOSPL */
  4680.         {
  4681.               popclvl();                /* pop command level. */
  4682.         }
  4683.     }
  4684.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4685. }
  4686.  
  4687. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4688.  
  4689. int
  4690. dostop() {
  4691.     extern int cmddep;
  4692.     while (popclvl()) ;         /* Pop all macros & take files */
  4693. #ifndef NOSPL
  4694.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4695.       while (cmpop() > -1) ;
  4696. #endif /* NOSPL */
  4697.     cmini(ckxech);              /* Clear the command buffer. */
  4698.     return(0);
  4699. }
  4700.  
  4701. /* Close the given log */
  4702.  
  4703. int
  4704. doclslog(x) int x; {
  4705.     int y;
  4706.     switch (x) {
  4707. #ifdef DEBUG
  4708.       case LOGD:
  4709.         if (deblog <= 0) {
  4710.             printf("?Debugging log wasn't open\n");
  4711.             return(0);
  4712.         }
  4713.         debug(F100,"Debug Log Closed","",0L);
  4714.         *debfil = '\0';
  4715.         deblog = 0;
  4716.         return(zclose(ZDFILE));
  4717. #endif /* DEBUG */
  4718.  
  4719. #ifndef NOXFER
  4720.       case LOGP:
  4721.         if (pktlog <= 0) {
  4722.             printf("?Packet log wasn't open\n");
  4723.             return(0);
  4724.         }
  4725.         *pktfil = '\0';
  4726.         pktlog = 0;
  4727.         return(zclose(ZPFILE));
  4728. #endif /* NOXFER */
  4729.  
  4730. #ifndef NOLOCAL
  4731.       case LOGS:
  4732.         if (seslog <= 0) {
  4733.             printf("?Session log wasn't open\n");
  4734.             return(0);
  4735.         }
  4736.         *sesfil = '\0';
  4737.         setseslog(0);
  4738.         return(zclose(ZSFILE));
  4739. #endif /* NOLOCAL */
  4740.  
  4741. #ifdef TLOG
  4742.       case LOGT: {
  4743. #ifdef IKSD
  4744.           extern int iklogopen, xferlog;
  4745. #endif /* IKSD */
  4746.           if (tralog <= 0
  4747. #ifdef IKSD
  4748.               && !iklogopen
  4749. #endif /* IKSD */
  4750.               ) {
  4751.               if (msgflg)
  4752.                 printf("?Transaction log wasn't open\n");
  4753.               return(0);
  4754.           }
  4755. #ifdef IKSD
  4756.           if (iklogopen && !inserver) {
  4757.               close(xferlog);
  4758.               iklogopen = 0;
  4759.           }
  4760. #endif /* IKSD */
  4761.           if (tralog) {
  4762.               tlog(F100,"Transaction Log Closed","",0L);
  4763.               zclose(ZTFILE);
  4764.           }
  4765.           *trafil = '\0';
  4766.           tralog = 0;
  4767.           return(1);
  4768.       }
  4769. #endif /* TLOG */
  4770.  
  4771. #ifdef CKLOGDIAL
  4772.       case LOGM:
  4773.         if (dialog <= 0) {
  4774.             if (msgflg) printf("?Connection log wasn't open\n");
  4775.             return(0);
  4776.         }
  4777.         *diafil = '\0';
  4778.         dialog = 0;
  4779.         return(zclose(ZDIFIL));
  4780. #endif /* CKLOGDIAL */
  4781.  
  4782. #ifndef NOSPL
  4783.       case LOGW:                        /* WRITE file */
  4784.       case LOGR:                        /* READ file */
  4785.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4786.         if (chkfn(y) < 1)               /* If no file to close */
  4787.           return(1);                    /* succeed silently. */
  4788.         return(zclose(y));              /* Otherwise, close the file. */
  4789. #endif /* NOSPL */
  4790.  
  4791.       default:
  4792.         printf("\n?Unexpected log designator - %d\n", x);
  4793.         return(0);
  4794.     }
  4795. }
  4796.  
  4797. static int slc = 0;                     /* Screen line count */
  4798.  
  4799. char *
  4800. showstring(s) char * s; {
  4801.     return(s ? s : "(null)");
  4802. }
  4803.  
  4804. char *
  4805. showoff(x) int x; {
  4806.     return(x ? "on" : "off");
  4807. }
  4808.  
  4809. char *
  4810. showooa(x) int x; {
  4811.     switch (x) {
  4812.       case SET_OFF:  return("off");
  4813.       case SET_ON:   return("on");
  4814.       case SET_AUTO: return("automatic");
  4815.       default:       return("(unknown)");
  4816.     }
  4817. }
  4818.  
  4819. #ifdef GEMDOS
  4820. isxdigit(c) int c; {
  4821.     return(isdigit(c) ||
  4822.            (c >= 'a' && c <= 'f') ||
  4823.            (c >= 'A' && c <= 'F'));
  4824. }
  4825. #endif /* GEMDOS */
  4826.  
  4827. #ifndef NOSETKEY
  4828. #ifdef OS2
  4829. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4830.     "all",    1, 0,
  4831.     "one",    0, 0
  4832. };
  4833. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4834.  
  4835. #define SHKEYDEF TT_MAX+5
  4836. struct keytab shokeymtab[] = {
  4837.     "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
  4838.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4839.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4840.     "annarbor",  TT_AAA,     0,         /* AnnArbor */
  4841.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4842.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4843.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4844.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4845.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4846.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4847.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4848.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4849.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4850.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4851.     "default",   SHKEYDEF,   0,
  4852.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4853.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4854.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4855.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4856.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4857.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4858.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4859.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4860.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4861.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4862.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4863.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4864.     "linux",     TT_LINUX,   0,         /* Linux */
  4865.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4866.     "qnx",       TT_QNX,     0,         /* QNX */
  4867.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4868.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4869.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4870.     "sun",       TT_SUN,     0,         /* Sun Console */
  4871. #ifdef OS2PM
  4872. #ifdef COMMENT
  4873.     "tek4014", TT_TEK40, 0,
  4874. #endif /* COMMENT */
  4875. #endif /* OS2PM */
  4876.     "tty",     TT_NONE,  0,
  4877.     "tvi910+", TT_TVI910, 0,
  4878.     "tvi925",  TT_TVI925, 0,
  4879.     "tvi950",  TT_TVI950, 0,
  4880.     "vc404",   TT_VC4404, 0,
  4881.     "vc4404",  TT_VC4404, CM_INV,
  4882.     "vip7809", TT_VIP7809, 0,
  4883.     "vt100",   TT_VT100, 0,
  4884.     "vt102",   TT_VT102, 0,
  4885.     "vt220",   TT_VT220, 0,
  4886.     "vt220pc", TT_VT220PC, 0,
  4887.     "vt320",   TT_VT320, 0,
  4888.     "vt320pc", TT_VT320PC, 0,
  4889.     "vt52",    TT_VT52,  0,
  4890.     "wp",      TT_KBM_WP, 0,
  4891.     "wy160",   TT_WY160,  0,
  4892.     "wy30",    TT_WY30,  0,
  4893.     "wy370",   TT_WY370, 0,
  4894.     "wy50",    TT_WY50,  0,
  4895.     "wy60",    TT_WY60,  0,
  4896.     "wyse30",  TT_WY30,  CM_INV,
  4897.     "wyse370", TT_WY370, CM_INV,
  4898.     "wyse50",  TT_WY50,  CM_INV,
  4899.     "wyse60",  TT_WY60,  CM_INV
  4900. };
  4901. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4902. #endif /* OS2 */
  4903.  
  4904. VOID
  4905. #ifdef OS2
  4906. shokeycode(c,m) int c, m;
  4907. #else
  4908. shokeycode(c) int c;
  4909. #endif
  4910. /* shokeycode */ {
  4911.     KEY ch;
  4912.     CHAR *s;
  4913. #ifdef OS2
  4914.     int i;
  4915.     con_event km;
  4916. #else /* OS2 */
  4917.     int km;
  4918. #endif /* OS2 */
  4919.  
  4920. #ifdef OS2
  4921.     extern int mskkeys;
  4922.     char * mstr = "";
  4923.  
  4924.     if (c >= KMSIZE) {
  4925.         bleep(BP_FAIL);
  4926.         return;
  4927.     }
  4928. #else /* OS2 */
  4929.     printf(" Key code \\%d => ", c);
  4930. #endif /* OS2 */
  4931.  
  4932. #ifndef OS2
  4933.     km = mapkey(c);
  4934.  
  4935. #ifndef NOKVERBS
  4936.     if (IS_KVERB(km)) {                 /* \Kverb? */
  4937.         int i, kv;
  4938.         kv = km & ~(F_KVERB);
  4939.         printf("Verb: ");
  4940.         for (i = 0; i < nkverbs; i++)
  4941.           if (kverbs[i].kwval == kv) {
  4942.               printf("\\K%s",kverbs[i].kwd);
  4943.               break;
  4944.           }
  4945.         printf("\n");
  4946.     } else
  4947. #endif /* NOKVERBS */
  4948.       if (IS_CSI(km)) {
  4949.           int xkm = km & 0xFF;
  4950.           if (xkm <= 32 || xkm >= 127)
  4951.             printf("String: \\{27}[\\{%d}\n",xkm);
  4952.           else
  4953.             printf("String: \\{27}[%c\n",xkm);
  4954.       } else if (IS_ESC(km)) {
  4955.           int xkm = km & 0xFF;
  4956.           if (xkm <= 32 || xkm >= 127)
  4957.             printf("String: \\{27}\\{%d}\n",xkm);
  4958.           else
  4959.             printf("String: \\{27}%c\n",xkm);
  4960.       } else if (macrotab[c]) {         /* See if there's a macro */
  4961.           printf("String: ");           /* If so, display its definition */
  4962.           s = macrotab[c];
  4963.           shostrdef(s);
  4964.           printf("\n");
  4965. #ifndef NOKVERBS
  4966.     } else if (km >= 0x100) {           /* This means "undefined" */
  4967.         printf("Undefined\n");
  4968. #endif /* NOKVERBS */
  4969.     } else {                            /* No macro, show single character */
  4970.         printf("Character: ");
  4971.         ch = km;
  4972.         if (ch < 32 || ch == 127
  4973. #ifdef OS2
  4974.             || ch > 255
  4975. #endif /* OS2 */
  4976. #ifndef NEXT
  4977. #ifndef AUX
  4978. #ifndef XENIX
  4979. #ifndef OS2
  4980.             || (ch > 127 && ch < 160)
  4981. #endif /* OS2 */
  4982. #endif /* XENIX */
  4983. #endif /* AUX */
  4984. #endif /* NEXT */
  4985.             )
  4986. /*
  4987.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  4988.   %u is supposed to be totally portable.
  4989. */
  4990.           printf("\\%u",(unsigned int) ch);
  4991.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  4992.         if (ch == (KEY) c)
  4993.           printf(" (self, no translation)\n");
  4994.         else
  4995.           printf("\n");
  4996.     }
  4997. #else /* OS2 */
  4998.     if (m < 0) {
  4999.         km = mapkey(c);
  5000.         mstr = "default";
  5001.     } else {
  5002.         km = maptermkey(c,m);
  5003.         for (i = 0; i < nshokeym; i++) {
  5004.             if (m == shokeymtab[i].kwval) {
  5005.                 mstr = shokeymtab[i].kwd;
  5006.                 break;
  5007.             }
  5008.         }
  5009.     }
  5010.     s = keyname(c);
  5011.     debug(F111,"shokeycode mstr",mstr,m);
  5012.     debug(F111,"shokeycode keyname",s,c);
  5013.     printf(" %sKey code \\%d %s (%s) => ",
  5014.             mskkeys ? "mskermit " : "",
  5015.             mskkeys ? cktomsk(c) : c,
  5016.             s == NULL ? "" : s, mstr);
  5017.  
  5018.     switch (km.type) {
  5019. #ifndef NOKVERBS
  5020.       case kverb: {
  5021.           int i, kv;
  5022.           kv = km.kverb.id & ~(F_KVERB);
  5023.           printf("Verb: ");
  5024.           for (i = 0; i < nkverbs; i++) {
  5025.               if (kverbs[i].kwval == kv) {
  5026.                   printf("\\K%s",kverbs[i].kwd);
  5027.                   break;
  5028.               }
  5029.           }
  5030.           printf("\n");
  5031.           break;
  5032.       }
  5033. #endif /* NOKVERBS */
  5034.       case csi: {
  5035.           int xkm = km.csi.key & 0xFF;
  5036.           if (xkm <= 32 || xkm >= 127)
  5037.             printf("String: \\{27}[\\{%d}\n",xkm);
  5038.           else
  5039.             printf("String: \\{27}[%c\n",xkm);
  5040.           break;
  5041.       }
  5042.       case esc: {
  5043.           int xkm = km.esc.key & 0xFF;
  5044.           if (xkm <= 32 || xkm >= 127)
  5045.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  5046.           else
  5047.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  5048.           break;
  5049.       }
  5050.       case macro: {
  5051.           printf("String: ");           /* Macro, display its definition */
  5052.           shostrdef(km.macro.string);
  5053.           printf("\n");
  5054.           break;
  5055.       }
  5056.       case literal: {
  5057.           printf("Literal string: ");   /* Literal, display its definition */
  5058.           shostrdef(km.literal.string);
  5059.           printf("\n");
  5060.           break;
  5061.       }
  5062.       case error: {
  5063.           if (c >= 0x100) {
  5064.               printf("Undefined\n");
  5065.           } else {
  5066.               printf("Character: ");
  5067.               ch = c;
  5068.               if (ch < 32 || ch == 127 || ch > 255
  5069. #ifndef NEXT
  5070. #ifndef AUX
  5071. #ifndef XENIX
  5072. #ifndef OS2
  5073.                    || (ch > 127 && ch < 160)
  5074. #endif /* OS2 */
  5075. #endif /* XENIX */
  5076. #endif /* AUX */
  5077. #endif /* NEXT */
  5078.                    )
  5079. /*
  5080.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5081.   %u is supposed to be totally portable.
  5082. */
  5083.                   printf("\\%u",(unsigned int) ch);
  5084.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5085.               printf(" (self, no translation)\n");
  5086.           }
  5087.           break;
  5088.       }
  5089.       case key: {
  5090.           printf("Character: ");
  5091.           ch = km.key.scancode;
  5092.           if (ch < 32 || ch == 127 || ch > 255
  5093. #ifndef NEXT
  5094. #ifndef AUX
  5095. #ifndef XENIX
  5096. #ifndef OS2
  5097.               || (ch > 127 && ch < 160)
  5098. #else
  5099.                || (ch > 127)
  5100. #endif /* OS2 */
  5101. #endif /* XENIX */
  5102. #endif /* AUX */
  5103. #endif /* NEXT */
  5104.               )
  5105. /*
  5106.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5107.   %u is supposed to be totally portable.
  5108. */
  5109.             printf("\\%u",(unsigned int) ch);
  5110.           else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5111.           if (ch == (KEY) c)
  5112.             printf(" (self, no translation)\n");
  5113.           else
  5114.             printf("\n");
  5115.           break;
  5116.       }
  5117.     }
  5118. #endif /* OS2 */
  5119. }
  5120. #endif /* NOSETKEY */
  5121.  
  5122. VOID
  5123. shostrdef(s) CHAR * s; {
  5124.     CHAR ch;
  5125.     if (!s) s = (CHAR *)"";
  5126.     while ((ch = *s++)) {
  5127.         if (ch < 32 || ch == 127 || ch == 255
  5128. /*
  5129.   Systems whose native character sets have graphic characters in C1...
  5130. */
  5131. #ifndef NEXT                            /* NeXT */
  5132. #ifndef AUX                             /* Macintosh */
  5133. #ifndef XENIX                           /* IBM PC */
  5134. #ifdef OS2
  5135. /*
  5136.   It doesn't matter whether the local host can display 8-bit characters;
  5137.   they are not portable among character-sets and fonts.  Who knows what
  5138.   would be displayed...
  5139. */
  5140.             || (ch > 127)
  5141. #else /* OS2 */
  5142.             || (ch > 127 && ch < 160)
  5143. #endif /* OS2 */
  5144. #endif /* XENIX */
  5145. #endif /* AUX */
  5146. #endif /* NEXT */
  5147.             )
  5148.           printf("\\{%d}",ch);          /* Display control characters */
  5149.         else putchar((char) ch);        /* in backslash notation */
  5150.     }
  5151. }
  5152.  
  5153. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5154.  
  5155. #ifndef NOSHOW
  5156. VOID
  5157. shover() {
  5158. #ifdef OS2
  5159.     extern char ckxsystem[];
  5160. #endif /* OS2 */
  5161.     extern char *ck_patch, * cklibv;
  5162.     printf("\nVersions:\n %s\n",versio);
  5163.     printf(" Numeric: %ld\n",vernum);
  5164. #ifdef OS2
  5165.     printf(" Operating System: %s\n", ckxsystem);
  5166. #else /* OS2 */
  5167.     printf(" Built for: %s\n", ckxsys);
  5168. #ifdef CK_UTSNAME
  5169.     if (unm_nam[0])
  5170.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5171. #endif /* CK_UTSNAME */
  5172.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5173. #endif /* OS2 */
  5174.     if (xxdiff(ckxv,ckxsys))
  5175.       printf(" %s for%s\n",ckxv,ckxsys);
  5176.     else
  5177.       printf(" %s\n",ckxv);
  5178.     if (xxdiff(ckzv,ckzsys))
  5179.       printf(" %s for%s\n",ckzv,ckzsys);
  5180.     else
  5181.       printf(" %s\n",ckzv);
  5182.     printf(" %s\n",cklibv);
  5183.     printf(" %s\n",protv);
  5184.     printf(" %s\n",fnsv);
  5185.     printf(" %s\n %s\n",cmdv,userv);
  5186. #ifndef NOCSETS
  5187.     printf(" %s\n",xlav);
  5188. #endif /* NOCSETS */
  5189. #ifndef MAC
  5190. #ifndef NOLOCAL
  5191.     printf(" %s\n",connv);
  5192. #ifdef OS2
  5193.     printf(" %s\n",ckyv);
  5194. #endif /* OS2 */
  5195. #endif /* NOLOCAL */
  5196. #endif /* MAC */
  5197. #ifndef NODIAL
  5198.     printf(" %s\n",dialv);
  5199. #endif /* NODIAL */
  5200. #ifndef NOSCRIPT
  5201.     printf(" %s\n",loginv);
  5202. #endif /* NOSCRIPT */
  5203. #ifdef NETCONN
  5204.     printf(" %s\n",cknetv);
  5205. #ifdef OS2
  5206.     printf(" %s\n",ckonetv);
  5207. #ifdef CK_NETBIOS
  5208.     printf(" %s\n",ckonbiv);
  5209. #endif /* CK_NETBIOS */
  5210. #endif /* OS2 */
  5211. #endif /* NETCONN */
  5212. #ifdef TNCODE
  5213.     printf(" %s\n",cktelv);
  5214. #endif /* TNCODE */
  5215. #ifdef OS2
  5216. #ifdef OS2MOUSE
  5217.     printf(" %s\n",ckomouv);
  5218. #endif /* OS2MOUSE */
  5219. #endif /* OS2 */
  5220. #ifdef NEWFTP
  5221.     printf(" %s\n",ckftpv);
  5222. #endif /* NEWFTP */
  5223. #ifdef CK_AUTHENTICATION
  5224.     printf(" %s\n",ckathv);
  5225. #endif /* CK_AUTHENTICATION */
  5226. #ifdef CK_ENCRYPTION
  5227. #ifdef CRYPT_DLL
  5228.     printf(" %s\n",ck_crypt_dll_version());
  5229. #else /* CRYPT_DLL */
  5230.     printf(" %s\n",ckcrpv);
  5231. #endif /* CRYPT_DLL */
  5232. #endif /* CK_ENCRYPTION */
  5233. #ifdef CK_SSL
  5234.     printf(" %s\n",cksslv);
  5235. #endif /* CK_SSL */
  5236.     printf("\n");
  5237. }
  5238.  
  5239. #ifdef CK_LABELED
  5240. VOID
  5241. sholbl() {
  5242. #ifdef VMS
  5243.     printf("VMS Labeled File Features:\n");
  5244.     printf(" acl %s (ACL info %s)\n",
  5245.            showoff(lf_opts & LBL_ACL),
  5246.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5247.     printf(" backup-date %s (backup date/time %s)\n",
  5248.            showoff(lf_opts & LBL_BCK),
  5249.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5250.     printf(" name %s (original filename %s)\n",
  5251.            showoff(lf_opts & LBL_NAM),
  5252.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5253.     printf(" owner %s (original file owner id %s)\n",
  5254.            showoff(lf_opts & LBL_OWN),
  5255.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5256.     printf(" path %s (original file's disk:[directory] %s)\n",
  5257.            showoff(lf_opts & LBL_PTH),
  5258.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5259. #else
  5260. #ifdef OS2
  5261.     printf("OS/2 Labeled File features (attributes):\n");
  5262.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5263.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5264.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5265.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5266.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5267. #endif /* OS2 */
  5268. #endif /* VMS */
  5269. }
  5270. #endif /* CK_LABELED */
  5271.  
  5272. VOID
  5273. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5274. #ifndef NOCSETS
  5275. #ifdef OS2
  5276. #ifndef NOTERM
  5277.     extern struct _vtG G[4], *GL, *GR;
  5278.     extern int decnrcm, sni_chcode;
  5279.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5280.     extern prncs;
  5281.  
  5282.     printf(" Terminal character-sets:\n");
  5283.     if (IS97801(tt_type_mode)) {
  5284.         if (cmask == 0377)
  5285.           printf("     Mode: 8-bit Mode\n");
  5286.         else
  5287.           printf("     Mode: 7-bit Mode\n");
  5288.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5289.     } else if (ISVT100(tt_type_mode)) {
  5290.         if (decnrcm)
  5291.           printf("     Mode: 7-bit National Mode\n");
  5292.         else
  5293.           printf("     Mode: 8-bit Multinational Mode\n");
  5294.     }
  5295.     if ( isunicode() )
  5296.         printf("    Local: Unicode display / %s input\n",
  5297.                 csl == TX_TRANSP ? "transparent" :
  5298.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5299.     else
  5300.         printf("    Local: %s\n",
  5301.                 csl == TX_TRANSP ? "transparent" :
  5302.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5303.  
  5304.     if ( tt_utf8 ) {
  5305.         printf("   Remote: UTF-8\n");
  5306.     } else {
  5307.         printf("   Remote: %sG0: %s (%s)\n",
  5308.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5309.            txrinfo[G[0].designation]->keywd,
  5310.            G[0].designation == TX_TRANSP ? "" :
  5311.            G[0].size == cs94 ? "94 chars" :
  5312.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5313.         printf("           %sG1: %s (%s)\n",
  5314.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5315.            txrinfo[G[1].designation]->keywd,
  5316.            G[1].designation == TX_TRANSP ? "" :
  5317.            G[1].size == cs94 ? "94 chars" :
  5318.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5319.         printf("           %sG2: %s (%s)\n",
  5320.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5321.            txrinfo[G[2].designation]->keywd,
  5322.            G[2].designation == TX_TRANSP ? "" :
  5323.            G[2].size == cs94 ? "94 chars" :
  5324.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5325.         printf("           %sG3: %s (%s)\n",
  5326.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5327.            txrinfo[G[3].designation]->keywd,
  5328.            G[3].designation == TX_TRANSP ? "" :
  5329.            G[3].size == cs94 ? "94 chars" :
  5330.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5331.     }
  5332.     printf("\n");
  5333.     printf(" Keyboard character-sets:\n");
  5334.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5335.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5336.     printf("\n");
  5337.     printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5338. #endif /* NOTERM */
  5339. #else /* OS2 */
  5340. #ifndef MAC
  5341.     char *s;
  5342.  
  5343.     debug(F101,"TERM LOCAL CSET","",csl);
  5344.     debug(F101,"TERM REMOTE CSET","",csr);
  5345.     printf(" Terminal character-set: ");
  5346.     if (tcs_transp) {                   /* No translation */
  5347.         printf("transparent\n");
  5348.     } else {                            /* Translation */
  5349.         printf("%s (remote) %s (local)\n",
  5350.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5351.         if (csr != csl) {
  5352.             switch(gettcs(csr,csl)) {
  5353.               case TC_USASCII:  s = "ascii";        break;
  5354.               case TC_1LATIN:   s = "latin1-iso";   break;
  5355.               case TC_2LATIN:   s = "latin2-iso";   break;
  5356.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5357.               case TC_JEUC:     s = "japanese-euc"; break;
  5358.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5359.               case TC_GREEK:    s = "greek-iso";    break;
  5360.               case TC_9LATIN:   s = "latin9-iso";   break;
  5361.               default:          s = "transparent";  break;
  5362.             }
  5363.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5364.                 strcmp(s,fcsinfo[csr].keyword))
  5365.               printf("                         (via %s)\n",s);
  5366.         }
  5367.     }
  5368. #endif /* MAC */
  5369. #endif /* OS2 */
  5370. #endif /* NOCSETS */
  5371. }
  5372.  
  5373. #ifndef NOLOCAL
  5374. #ifdef OS2
  5375. extern char htab[];
  5376. VOID
  5377. shotabs() {
  5378.     int i,j,k,n;
  5379.  
  5380.     printf("Tab Stops:\n\n");
  5381.     for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5382.         do {
  5383.             printf("%c",htab[++i]=='T'?'T':'-');
  5384.         } while (i % k && i < MAXTERMCOL);
  5385.         printf("\n");
  5386.         for ( ; j <= i; j++) {
  5387.             switch ( j%10 ) {
  5388.           case 1:
  5389.                 printf("%c",j == 1 ? '1' : '.');
  5390.                 break;
  5391.           case 2:
  5392.           case 3:
  5393.           case 4:
  5394.           case 5:
  5395.           case 6:
  5396.           case 7:
  5397.                 printf("%c",'.');
  5398.                 break;
  5399.           case 8:
  5400.                 n = (j+2)/100;
  5401.                 if (n)
  5402.           printf("%d",n);
  5403.                 else 
  5404.           printf("%c",'.');
  5405.                 break;
  5406.           case 9:
  5407.                 n = (j+1)%100/10;
  5408.                 if (n)
  5409.           printf("%d",n);
  5410.                 else if (j>90)
  5411.           printf("0");
  5412.                 else 
  5413.           printf("%c",'.');
  5414.                 break;
  5415.           case 0:
  5416.                 printf("0");
  5417.                 break;
  5418.             }
  5419.         }
  5420.         printf("\n");
  5421.     }
  5422. #ifdef COMMENT
  5423.     for (i = 1; i <= 70; i++)
  5424.       printf("%c",htab[i]=='T'?'T':'-');
  5425.     printf("\n1.......10........20........30........40........50........60\
  5426. ........70\n\n");
  5427.     for (; i <= 140; i++)
  5428.       printf("%c",htab[i]=='T'?'T':'-');
  5429.     printf("\n........80........90.......100.......110.......120.......130\
  5430. .......140\n\n");
  5431.     for (; i <= 210; i++)
  5432.       printf("%c",htab[i]=='T'?'T':'-');
  5433.     printf("\n.......150.......160.......170.......180.......190.......200\
  5434. .......210\n\n");
  5435.     for (; i <= 255; i++)
  5436.       printf("%c",htab[i]=='T'?'T':'-');
  5437.     printf("\n.......220.......230.......240.......250..255\n");
  5438. #endif
  5439.  
  5440. }
  5441. #endif /* OS2 */
  5442. #endif /* NOLOCAL */
  5443.  
  5444. #ifdef OS2MOUSE
  5445. VOID
  5446. shomou() {
  5447.     int button, event, id, i;
  5448.     char * name = "";
  5449.  
  5450.     printf("Mouse settings:\n");
  5451.     printf("   Button Count:   %d\n",mousebuttoncount());
  5452.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5453.  
  5454.     for (button = 0; button < MMBUTTONMAX; button++)
  5455.       for (event = 0; event < MMEVENTSIZE; event++)
  5456.         if (mousemap[button][event].type != error)
  5457.           switch (mousemap[button][event].type) {
  5458.             case key:
  5459.               printf("   %s = Character: %c \\%d\n",
  5460.                      mousename(button,event),
  5461.                      mousemap[button][event].key.scancode,
  5462.                      mousemap[button][event].key.scancode );
  5463.               break;
  5464.             case kverb:
  5465.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5466.               if (id != K_IGNORE) {
  5467.                   for (i = 0; i< nkverbs; i++)
  5468.                     if (id == kverbs[i].kwval) {
  5469.                         name = kverbs[i].kwd;
  5470.                         break;
  5471.                     }
  5472.                   printf("   %s = Kverb: \\K%s\n",
  5473.                          mousename(button,event),
  5474.                          name
  5475.                          );
  5476.               }
  5477.               break;
  5478.             case macro:
  5479.               printf("   %s = Macro: ",
  5480.                      mousename(button,event) );
  5481.               shostrdef(mousemap[button][event].macro.string);
  5482.               printf("\n");
  5483.               break;
  5484.           }
  5485. }
  5486. #endif /* OS2MOUSE */
  5487.  
  5488. #ifndef NOLOCAL
  5489. VOID
  5490. shotrm() {
  5491.     char *s;
  5492.     extern char * getiact();
  5493.     extern int tt_print, adl_err;
  5494. #ifndef NOTRIGGER
  5495.     extern char * tt_trigger[];
  5496. #endif /* NOTRIGGER */
  5497. #ifdef CKTIDLE
  5498.     extern char * tt_idlesnd_str;
  5499.     extern int tt_idlesnd_tmo;
  5500.     extern int tt_idlelimit, tt_idleact;
  5501. #endif /* CKTIDLE */
  5502. #ifdef OS2
  5503.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5504.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5505.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5506.     int lines = 0;
  5507. #ifdef KUI
  5508.     extern CKFLOAT tt_linespacing[];
  5509. #endif /* KUI */
  5510. #ifdef PCFONTS
  5511.     int i;
  5512.     char *font;
  5513.  
  5514.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5515.         if (!os2LoadPCFonts()) {
  5516.             for (i = 0; i < ntermfont; i++) {
  5517.                 if (tt_font == term_font[i].kwval) {
  5518.                     font = term_font[i].kwd;
  5519.                     break;
  5520.                 }
  5521.             }
  5522.         } else {
  5523.             font = "(DLL not available)";
  5524.         }
  5525.     } else {
  5526.         font =     "(full screen only)";
  5527.     }
  5528. #endif /* PCFONTS */
  5529. #ifdef KUI
  5530.     char font[64] = "(unknown)";
  5531.     if ( ntermfont > 0 ) {
  5532.         int i;
  5533.         for (i = 0; i < ntermfont; i++) {
  5534.             if (tt_font == term_font[i].kwval) {
  5535.                 ckstrncpy(font,term_font[i].kwd,59);
  5536.                 ckstrncat(font," ",64);
  5537.                 ckstrncat(font,ckitoa(tt_font_size/2),64);
  5538.                 if ( tt_font_size % 2 )
  5539.                     ckstrncat(font,".5",64);
  5540.                 break;
  5541.             }
  5542.         }
  5543.     }
  5544. #endif /* KUI */
  5545.  
  5546.     printf("Terminal parameters:\n");
  5547.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5548.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5549.            "Bytesize: Command",
  5550.            (cmdmsk == 0377) ? 8 : 7,
  5551.            " bits","Terminal",
  5552.            (cmask == 0377) ? 8 : 7," bits");
  5553.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5554.     printf(" %19s: %-13s","Type",
  5555.            (tt_type >= 0 && tt_type <= max_tt) ?
  5556.            tt_info[tt_type].x_name :
  5557.            "unknown" );
  5558.     if (tt_type >= 0 && tt_type <= max_tt)
  5559.       if (strlen(tt_info[tt_type].x_id))
  5560.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5561.     printf("\n");
  5562.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5563.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5564.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5565.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5566.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5567.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5568.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5569.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5570.            (tt_cursor == 2) ? "full" :
  5571.            (tt_cursor == 1) ? "half" : "underline",
  5572. #ifdef CK_AUTODL
  5573.            "autodownload",autodl ?
  5574.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5575. #else /* CK_AUTODL */
  5576.            "", ""
  5577. #endif /* CK_AUTODL */
  5578.            );
  5579.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5580.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5581.            tt_arrow ? "application" : "cursor",
  5582.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5583.            );
  5584.  
  5585.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5586.  
  5587.     /* Just to make sure we are using current info */
  5588.     updanswerbk();
  5589.  
  5590.     /*
  5591.        This line doesn't end with '\n' because the answerback string
  5592.        is terminated with a newline
  5593.     */
  5594.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5595.            showoff(tt_answer),"response",answerback);
  5596.     switch (tt_bell) {
  5597.       case XYB_NONE:
  5598.         s = "none";
  5599.         break;
  5600.       case XYB_VIS:
  5601.         s= "visible";
  5602.         break;
  5603.       case XYB_AUD | XYB_BEEP:
  5604.         s="beep";
  5605.         break;
  5606.       case XYB_AUD | XYB_SYS:
  5607.         s="system sounds";
  5608.         break;
  5609.       default:
  5610.         s="(unknown)";
  5611.     }
  5612.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5613.            "Wrap",showoff(tt_wrap));
  5614.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5615.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5616.            "Autoscroll",showoff(autoscroll));
  5617.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5618.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5619.            "ESC[0m color",colorreset?"default-color":"current-color");
  5620.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5621.     printf(" %19s: %-13s  %13s: %-15s\n",
  5622.             "Erase color",user_erasemode?"default-color":"current-color",
  5623.            "Screen mode",decscnm?"reverse":"normal");
  5624.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5625.  
  5626.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5627.            "Output-pacing",tt_pacing);
  5628.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5629.  
  5630.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5631.            "Idle-action", getiact());
  5632.  
  5633.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5634.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5635.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5636.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5637. #ifndef NOTRIGGER
  5638.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5639.            tt_trigger[0],"Output pacing",tt_pacing );
  5640.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5641. #endif /* NOTRIGGER */
  5642.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5643.            showoff(marginbell),"at column", marginbellcol);
  5644.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5645.     switch (tt_modechg) {
  5646.       case TVC_DIS: s = "disabled"; break;
  5647.       case TVC_ENA: s = "enabled";  break;
  5648.       case TVC_W95: s = "win95-restricted"; break;
  5649.       default: s = "(unknown)";
  5650.     }
  5651.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5652.            showoff(dgunix),"Video change", s);
  5653.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5654.  
  5655. #ifdef CK_APC
  5656.     if (apcstatus == APC_ON) s = "on";
  5657.     else if (apcstatus == APC_OFF) s = "off";
  5658.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5659.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5660.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5661.     printf(" %19s: %-13s  %13s: %-15s\n",
  5662.            "APC", s,
  5663. #ifdef PCFONTS
  5664.            "Font (VGA)",font
  5665. #else /* PCFONTS */
  5666. #ifdef KUI
  5667.            "Font",font
  5668. #else
  5669.            "Font","(not supported)"
  5670. #endif /* KUI */
  5671. #endif /* PCFONTS */
  5672.  
  5673.            );
  5674. #endif /* CK_APC */
  5675.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5676.  
  5677. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5678.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5679.       ttgwsiz();                        /* Try to get latest size */
  5680. #endif /* CK_TTGWSIZ */
  5681.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5682.            "Width",tt_cols[VTERM]);
  5683.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5684. #ifdef KUI
  5685.     printf(" %19s: %-13f  %13s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5686.            "Display Height",VscrnGetDisplayHeight(VTERM));
  5687.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5688. #endif /* KUI */
  5689.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5690.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5691.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5692.  
  5693.     if (updmode == tt_updmode)
  5694.       if (updmode == TTU_FAST)
  5695.         s = "fast (fast)";
  5696.       else
  5697.         s = "smooth (smooth)";
  5698.     else
  5699.       if (updmode == TTU_FAST)
  5700.         s = "fast (smooth)";
  5701.       else
  5702.         s = "smooth (fast)";
  5703.  
  5704.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5705.            "interval",tt_update);
  5706.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5707.     printf(" %19s: %-13s  %13s: %-15s\n",
  5708.            "Screen-optimization",showoff(tt_diff_upd),
  5709.            "Status line",showoff(tt_status[VTERM]));
  5710.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5711.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5712.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5713.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5714.  
  5715.     /* Display colors (should become SHOW COLORS) */
  5716.     {
  5717.         USHORT row, col;
  5718.         char * colors[16] = {
  5719.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5720.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5721.         };
  5722.         printf("\n");
  5723.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5724.  
  5725.         printf(" Color:");
  5726. #ifndef ONETERMUPD
  5727.         GetCurPos(&row, &col);
  5728.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5729.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5730.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5731.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5732.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5733.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5734.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5735.         WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5736. #endif /* ONETERMUPD */
  5737.         row = VscrnGetCurPos(VCMD)->y+1;
  5738.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5739.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5740.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5741.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5742.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5743.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5744.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5745.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5746.         printf("\n");
  5747.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5748.  
  5749.         /* Foreground color names */
  5750.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5751.                 "",
  5752.                 colors[colordebug&0x0F],
  5753.                 colors[colorhelp&0x0F],
  5754.                 colors[colorreverse&0x0F],
  5755.                 colors[colorselect&0x0F],
  5756.                 colors[colorstatus&0x0F],
  5757.                 colors[colornormal&0x0F],
  5758.                 colors[colorunderline&0x0F]);
  5759.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5760.  
  5761.         /* Background color names */
  5762.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5763.                 colors[colorborder],
  5764.                 colors[colordebug>>4],
  5765.                 colors[colorhelp>>4],
  5766.                 colors[colorreverse>>4],
  5767.                 colors[colorselect>>4],
  5768.                 colors[colorstatus>>4],
  5769.                 colors[colornormal>>4],
  5770.                 colors[colorunderline>>4] );
  5771.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5772.         printf("\n");
  5773.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5774.         printf(" Color:");
  5775. #ifndef ONETERMUPD
  5776.         GetCurPos(&row, &col);
  5777.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5778.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5779.         WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
  5780. #endif /* ONETERMUPD */
  5781.         row = VscrnGetCurPos(VCMD)->y+1;
  5782.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5783.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5784.         VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
  5785.         printf("\n");
  5786.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5787.  
  5788.         /* Foreground color names */
  5789.         printf("%6s: %-8s%-8s%-8s\n","fore",
  5790.                 colors[colorgraphic&0x0F],
  5791.                 colors[colorcmd&0x0F],
  5792.                 colors[coloritalic&0x0F]);
  5793.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5794.  
  5795.         /* Background color names */
  5796.         printf("%6s: %-8s%-8s%-8s\n","back",
  5797.                 colors[colorgraphic>>4],
  5798.                 colors[colorcmd>>4],
  5799.                 colors[coloritalic>>4]);
  5800.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5801.     }
  5802.     printf("\n");
  5803.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5804.     {
  5805.         extern int trueblink, truereverse, trueunderline, trueitalic;
  5806.         printf(
  5807.     " Attribute:  blink: %-3s  reverse: %-3s  underline: %-3s italic: %-3s\n",
  5808.                 trueblink?"on":"off", truereverse?"on":"off",
  5809.                 trueunderline?"on":"off", trueitalic?"on":"off");
  5810.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5811.     }
  5812.     {
  5813.         extern vtattrib WPattrib;
  5814.         printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5815.                 WPattrib.blinking?"blink ":"",
  5816.                 WPattrib.italic?"italic ":"",
  5817.                 WPattrib.reversed?"reverse ":"",
  5818.                 WPattrib.underlined?"underline ":"",
  5819.                 WPattrib.bold?"bold ":"",
  5820.                 WPattrib.dim?"dim ":"",
  5821.                 WPattrib.invisible?"invisible ":"");
  5822.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5823.     }
  5824.  
  5825.     printf("\n");
  5826.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5827.     (VOID) shoesc(escape);
  5828.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5829.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5830.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5831.  
  5832. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5833.  
  5834.     printf("\n");
  5835.     printf("Terminal parameters:\n");
  5836.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5837.            "Bytesize: Command",
  5838.            (cmdmsk == 0377) ? 8 : 7,
  5839.            " bits","Terminal",
  5840.            (cmask == 0377) ? 8 : 7," bits");
  5841.     s = getenv("TERM");
  5842. #ifdef XPRINT
  5843.     printf(" %19s: %-13s  %13s: %-15s\n",
  5844.            "Type",
  5845.            s ? s : "(unknown)",
  5846.            "Print",
  5847.            showoff(tt_print)
  5848.            );
  5849. #else
  5850.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5851. #endif /* XPRINT */
  5852.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5853.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5854.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5855.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5856.  
  5857. #ifdef CK_APC
  5858.     if (apcstatus == APC_ON) s = "on";
  5859.     else if (apcstatus == APC_OFF) s = "off";
  5860.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5861.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5862.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5863.     printf(" %19s: %-13s  %13s: %-15s\n",
  5864.            "APC", s,
  5865. #ifdef CK_AUTODL
  5866.            "Autodownload", autodl ?
  5867.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5868. #else
  5869.            "",""
  5870. #endif /* CK_AUTODL */
  5871.            );
  5872. #endif /* CK_APC */
  5873.  
  5874. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5875.     ttgwsiz();                          /* Try to get latest size */
  5876.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5877. #endif /* CK_TTGWSIZ */
  5878.  
  5879.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5880.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5881.  
  5882. #ifdef CKTIDLE
  5883.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5884.            "Idle-action", getiact());
  5885. #endif /* CKTIDLE */
  5886.  
  5887. #ifndef NOTRIGGER
  5888.     printf(" %19s: %-13s\n","Trigger",
  5889.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  5890. #endif /* NOTRIGGER */
  5891. #ifdef UNIX
  5892. #ifndef NOJC
  5893.     printf(" %19s: %-13s\n\n","Suspend", showoff(suspend));
  5894. #endif /* NOJC */
  5895. #endif /* UNIX */
  5896.  
  5897.     printf("\n");
  5898.     (VOID) shoesc(escape);
  5899. #ifndef NOCSETS
  5900.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  5901. #endif /* NOCSETS */
  5902.  
  5903. #endif /* OS2 */
  5904. }
  5905.  
  5906. VOID
  5907. shmdmlin() {                            /* Briefly show modem & line */
  5908. #ifndef NODIAL
  5909. #ifndef MINIDIAL
  5910. #ifdef OLDTBCODE
  5911.     extern int tbmodel;
  5912.     _PROTOTYP( char * gtbmodel, (void) );
  5913. #endif /* OLDTBCODE */
  5914. #endif /* MINIDIAL */
  5915. #endif /* NODIAL */
  5916.     if (local)
  5917. #ifdef OS2
  5918.       printf(" Port: %s, Modem type: ",ttname);
  5919. #else
  5920.       printf(" Line: %s, Modem type: ",ttname);
  5921. #endif /* OS2 */
  5922.     else
  5923.       printf(
  5924. #ifdef OS2
  5925. " Communication device not yet selected with SET PORT\n Modem type: "
  5926. #else
  5927. " Communication device not yet selected with SET LINE\n Modem type: "
  5928. #endif /* OS2 */
  5929.              );
  5930. #ifndef NODIAL
  5931.     printf("%s",gmdmtyp());
  5932. #ifndef MINIDIAL
  5933. #ifdef OLDTBCODE
  5934.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  5935. #endif /* OLDTBCODE */
  5936. #endif /* MINIDIAL */
  5937. #else
  5938.     printf("(disabled)");
  5939. #endif /* NODIAL */
  5940. }
  5941.  
  5942. #ifdef CK_TAPI
  5943. void
  5944. shotapi(int option) {
  5945.     int rc=0,k ;
  5946.     char *s=NULL;
  5947.     LPDEVCFG        lpDevCfg = NULL;
  5948.     LPCOMMCONFIG    lpCommConfig = NULL;
  5949.     LPMODEMSETTINGS lpModemSettings = NULL;
  5950.     DCB *           lpDCB = NULL;
  5951.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  5952.     extern int ntapiloc;
  5953.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  5954.     extern int ntapiline;
  5955.     extern int tttapi;                  /* TAPI in use */
  5956.     extern int tapipass;                /* TAPI Passthrough mode */
  5957.     extern int tapiconv;                /* TAPI Conversion mode */
  5958.     extern int tapilights;
  5959.     extern int tapipreterm;
  5960.     extern int tapipostterm;
  5961.     extern int tapimanual;
  5962.     extern int tapiinactivity;
  5963.     extern int tapibong;
  5964.     extern int tapiusecfg;
  5965.     extern char tapiloc[];
  5966.     extern int tapilocid;
  5967.     extern int TAPIAvail;
  5968.  
  5969.     if (!TAPIAvail) {
  5970.         printf("TAPI Support not enabled\r\n");
  5971.         return;
  5972.     }
  5973.     switch (option) {
  5974.       case 0:
  5975.         printf("TAPI Settings:\n");
  5976.         printf("  Line:                      %s\n",
  5977.                tttapi ? ttname : "(none in use)");
  5978.  
  5979.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  5980.         if (tapilocid == -1)
  5981.           tapilocid = cktapiGetCurrentLocationID();
  5982.  
  5983.         /* Find the current tapiloc entry */
  5984.         /* and use it as the default. */
  5985.         for (k = 0; k < ntapiloc; k++) {
  5986.             if (tapiloctab[k].kwval == tapilocid)
  5987.               break;
  5988.         }
  5989.         if (k >= 0 && k < ntapiloc)
  5990.           s = tapiloctab[k].kwd;
  5991.         else
  5992.           s = "(unknown)";
  5993.         printf("  Location:                  %s\n",s);
  5994.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  5995.         printf("  Phone-number-conversions:  %s\n",
  5996.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  5997.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  5998.                 tapipass?"(n/a)":"");
  5999.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  6000.                 tapipass?"(n/a)":"");
  6001.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  6002.                 tapipass?"(n/a)":"");
  6003.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  6004.                 tapipass?"(n/a)":"");
  6005.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  6006.                 tapipass?"(n/a)":"");
  6007.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  6008.                 tapipass?"(n/a)":"");
  6009.         printf("  Use-windows-configuration: %s %s\n",
  6010.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  6011.         printf("\n");
  6012.  
  6013. #ifdef BETATEST
  6014.         if (tapipass) {
  6015. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  6016. printf("may open the device but may not place calls nor answer calls.\n");
  6017. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  6018. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  6019. printf("definition associated with the active TAPI LINE device.\n\n");
  6020.  
  6021.         } else {
  6022.  
  6023. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  6024. printf("may open the device, place and answer calls.  Dialing is performed\n");
  6025. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  6026.         }
  6027.  
  6028.         if (tapiconv == CK_ON ||
  6029.             tapiconv == CK_AUTO && !tapipass) {
  6030. printf(
  6031. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  6032. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  6033. printf("dialog.\n\n");
  6034.  
  6035.         } else {
  6036.  
  6037. printf(
  6038. "Phone numbers are converted from canonical to dialable form by K-95\n");
  6039. printf(
  6040. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  6041. printf(
  6042. "Dialing Properties are imported automaticly upon startup and whenever\n");
  6043. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  6044. printf("is changed.\n\n");
  6045.         }
  6046. #endif /* BETATEST */
  6047.  
  6048.         if (tapipass) {
  6049.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  6050.             if (tapiconv == CK_ON)
  6051.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6052.         } else {
  6053.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  6054.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6055.         }
  6056.         break;
  6057.       case 1:
  6058.         cktapiDisplayTapiLocationInfo();
  6059.         break;
  6060.       case 2:
  6061.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  6062.                                      &lpCommConfig,&lpDCB);
  6063.         if (rc) {
  6064.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  6065.                                          lpCommConfig,lpDCB);
  6066.         } else {
  6067.             printf("?Unable to retrieve Modem Settings\n");
  6068.         }
  6069.         break;
  6070.       case 3: {
  6071.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  6072.           if (hModem)
  6073.             DisplayCommProperties(hModem);
  6074.           else
  6075.             printf("?Unable to retrieve a valid Modem Handle\n");
  6076.           CloseHandle(hModem);
  6077.           break;
  6078.       }
  6079.     }
  6080.     printf("\n");
  6081. }
  6082. #endif /* CK_TAPI */
  6083. #endif /* NOLOCAL */
  6084.  
  6085. #ifdef PATTERNS
  6086. static VOID
  6087. shopat() {
  6088.     extern char * binpatterns[], * txtpatterns[];
  6089.     extern int patterns, filepeek;
  6090.     char **p, *s;
  6091.     int i, j, k, n, flag, width;
  6092. #ifdef CK_TTGWSIZ
  6093.     ttgwsiz();                          /* Try to get latest size */
  6094. #ifdef OS2
  6095.     width = tt_cols[VCMD];
  6096. #else /* OS2 */
  6097.     width = tt_cols;
  6098. #endif /* OS2 */
  6099.     if (width < 1)
  6100. #endif /* CK_TTGWSIZ */
  6101.       width = 80;
  6102.     printf("\n");
  6103.     printf(" Set file type:            %s\n",gfmode(binary,1));
  6104.     printf(" Set file patterns:        %s", showooa(patterns));
  6105. #ifdef CK_LABELED
  6106.     if (binary == XYFT_L)
  6107.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  6108.     else
  6109. #endif /* CK_LABELED */
  6110. #ifdef VMS
  6111.     if (binary == XYFT_I)
  6112.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  6113.     else
  6114. #endif /* VMS */
  6115.     if (filepeek)
  6116.       printf(" (but SET FILE SCAN ON overrides)\n");
  6117.     else
  6118.       printf("\n");
  6119.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  6120.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  6121.         printf("\n");
  6122.         if (k == 0) {                   /* binary... */
  6123.             printf(" File binary-patterns: ");
  6124.             p = binpatterns;
  6125.         } else {                        /* text... */
  6126.             printf(" File text-patterns:   ");
  6127.             p = txtpatterns;
  6128.         }
  6129.         if (!p[0]) {
  6130.             printf("(none)\n");
  6131.         } else {
  6132.             printf("\n ");
  6133.             n = 2;
  6134.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  6135.                 if (!p[i])              /* Done */
  6136.                   break;
  6137.                 s = p[i];               /* Look for embedded space */
  6138.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  6139.                   if (*s == SP)
  6140.                     flag = 3;
  6141.                 n += j + flag;          /* Length of this line */
  6142.                 if (n >= width - 1) {
  6143.                     printf("\n ");
  6144.                     n = j+2;
  6145.                 }
  6146.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6147.             }
  6148.             if (n > 2)
  6149.               printf("\n");
  6150.         }
  6151.     }
  6152.     printf("\n");
  6153. }
  6154. #endif /* PATTERNS */
  6155.  
  6156. #ifndef NOSPL
  6157. static VOID
  6158. shooutput() {
  6159.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6160.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6161. }
  6162.  
  6163. static VOID
  6164. shoinput() {
  6165. #ifdef CK_AUTODL
  6166.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6167. #endif /* CK_AUTODL */
  6168.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6169.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6170.            "observe" : "ignore");
  6171.     printf(" Input buffer-length:    %d\n", inbufsize);
  6172.     printf(" Input echo:             %s\n", showoff(inecho));
  6173.     printf(" Input silence:          %d (seconds)\n", insilence);
  6174. #ifdef OS2
  6175.     printf(" Input terminal:         %s\n", showoff(interm));
  6176. #endif /* OS2 */
  6177.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6178.            "quit" : "proceed");
  6179.     if (instatus < 0)
  6180.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6181.     else
  6182.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6183. }
  6184. #endif /* NOSPL */
  6185.  
  6186. #ifndef NOSPL
  6187. int
  6188. showarray() {
  6189. #ifdef COMMENT
  6190.     char * p, * q, ** ap;
  6191.     int i;
  6192. #endif /* COMMENT */
  6193.     char *s; int x = 0, y;
  6194.     int range[2];
  6195.  
  6196.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6197.       if (y != -3)
  6198.         return(y);
  6199.     ckstrncpy(line,s,LINBUFSIZ);
  6200.     s = line;
  6201.     if ((y = cmcfm()) < 0)
  6202.       return(y);
  6203.     if (*s) {
  6204.         char ** ap;
  6205.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6206.             printf("?Bad array: %s\n",s);
  6207.             return(-9);
  6208.         }
  6209.         ap = a_ptr[x];
  6210.         if (!ap) {
  6211.             printf("Array not declared: %s\n", s);
  6212.             return(success = 1);
  6213.         } else {
  6214.             int i, n, max;
  6215.             max = (range[1] > 0) ?
  6216.               range[1] :
  6217.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6218.             if (range[0] < 0)
  6219.               range[0] = 0;
  6220.             if (max > a_dim[x])
  6221.               max = a_dim[x];
  6222.             n = 1;
  6223.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6224.             if (a_link[x] > -1)
  6225.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6226.             printf("\n");
  6227.             for (i = range[0]; i <= max; i++) {
  6228.                 if (ap[i]) {
  6229.                     printf("%3d. %s\n",i,ap[i]);
  6230.                     if (xaskmore) {
  6231.                         if (cmd_cols > 0) {
  6232.                             x = strlen(ap[i]) + 5;
  6233.                             y = (x % cmd_cols) ? 1 : 0;
  6234.                             n += (x / cmd_cols) + y;
  6235.                         } else {
  6236.                             n++;
  6237.                         }
  6238.                         if (n > (cmd_rows - 3)) {
  6239.                             if (!askmore())
  6240.                               break;
  6241.                             else
  6242.                               n = 0;
  6243.                         }
  6244.                     }
  6245.                 }
  6246.             }
  6247.         }
  6248.         return(1);
  6249.     }
  6250.  
  6251.     /* All arrays - just show name and dimension */
  6252.  
  6253.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6254.         if (a_ptr[y]) {
  6255.             if (x == 0) printf("Declared arrays:\n");
  6256.             x = 1;
  6257.             printf(" \\&%c[%d]",
  6258.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6259.             if (a_link[y] > -1)
  6260.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6261.             printf("\n");
  6262.         }
  6263.         if (!x) printf(" No arrays declared\n");
  6264.     }
  6265.     return(1);
  6266. }
  6267. #endif /* NOSPL */
  6268.  
  6269. int
  6270. doshow(x) int x; {
  6271.     int y, z, i; long zz;
  6272.     extern int optlines;
  6273.     char *s;
  6274. #ifdef OS2
  6275.     extern int os2gks;
  6276.     extern int tt_kb_mode;
  6277. #endif /* OS2 */
  6278.     extern int srvcdmsg;
  6279.     extern char * cdmsgstr, * ckcdpath;
  6280.  
  6281. #ifndef NOSETKEY
  6282.     if (x == SHKEY) {                   /* SHOW KEY */
  6283.         int c;
  6284. #ifdef OS2
  6285.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6286.                         "one",xxstring)) < 0) return(x);
  6287.         switch (tt_kb_mode) {
  6288.           case KBM_EM:
  6289.             s = "emacs";
  6290.             break;
  6291.           case KBM_HE:
  6292.             s = "hebrew";
  6293.             break;
  6294.           case KBM_RU:
  6295.             s = "russian";
  6296.             break;
  6297.           case KBM_EN:
  6298.           default:
  6299.             s = "default";
  6300.             break;
  6301.         }
  6302.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6303.                         s,xxstring)) < 0) return(z);
  6304.         if (z == SHKEYDEF)
  6305.           z = -1;
  6306. #endif /* OS2 */
  6307.         if ((y = cmcfm()) < 0) return(y);
  6308. #ifdef IKSD
  6309.         if (inserver) {
  6310.             printf("Sorry, command disabled.\r\n");
  6311.             return(success = 0);
  6312.         }
  6313. #endif /* IKSD */
  6314.  
  6315. #ifdef MAC
  6316.         printf("Not implemented\n");
  6317.         return(0);
  6318. #else /* Not MAC */
  6319. #ifdef OS2
  6320.         if (x) {
  6321.             con_event evt;
  6322.             for (c = 0; c < KMSIZE; c++) {
  6323.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6324.                 if (evt.type != error) {
  6325.                     shokeycode(c,z);
  6326.                 }
  6327.             }
  6328.         } else {
  6329. #endif /* OS2 */
  6330.             printf(" Press key: ");
  6331. #ifdef UNIX
  6332. #ifdef NOSETBUF
  6333.             fflush(stdout);
  6334. #endif /* NOSETBUF */
  6335. #endif /* UNIX */
  6336.             conbin((char)escape);       /* Put terminal in binary mode */
  6337. #ifdef OS2
  6338.             os2gks = 0;                 /* Raw scancode processing */
  6339. #endif /* OS2 */
  6340.             c = congks(0);              /* Get character or scan code */
  6341. #ifdef OS2
  6342.             os2gks = 1;                 /* Cooked scancode processing */
  6343. #endif /* OS2 */
  6344.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6345.             if (c < 0) {                /* Check for error */
  6346.                 printf("?Error reading key\n");
  6347.                 return(0);
  6348.             }
  6349. #ifndef OS2
  6350. /*
  6351.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6352. */
  6353.             c &= cmdmsk;                /* Apply command mask */
  6354. #endif /* OS2 */
  6355.             printf("\n");
  6356. #ifdef OS2
  6357.             shokeycode(c,z);
  6358. #else /* OS2 */
  6359.             shokeycode(c);
  6360. #endif /* OS2 */
  6361. #ifdef OS2
  6362.         }
  6363. #endif /* OS2 */
  6364.         return(1);
  6365. #endif /* MAC */
  6366.     }
  6367. #ifndef NOKVERBS
  6368.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6369.         if ((y = cmcfm()) < 0) return(y);
  6370. #ifdef IKSD
  6371.         if (inserver) {
  6372.             printf("Sorry, command disabled.\r\n");
  6373.             return(success = 0);
  6374.         }
  6375. #endif /* IKSD */
  6376.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6377.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6378.         printf("\n");
  6379.         return(1);
  6380.     }
  6381. #ifdef OS2
  6382.     if (x == SHUDK) {                   /* SHOW UDKs */
  6383.         extern void showudk(void);
  6384.         if ((y = cmcfm()) < 0) return(y);
  6385. #ifdef IKSD
  6386.         if (inserver) {
  6387.             printf("Sorry, command disabled.\r\n");
  6388.             return(success = 0);
  6389.         }
  6390. #endif /* IKSD */
  6391.         showudk();
  6392.         return(1);
  6393.     }
  6394. #endif /* OS2 */
  6395. #endif /* NOKVERBS */
  6396. #endif /* NOSETKEY */
  6397.  
  6398. #ifndef NOSPL
  6399.     if (x == SHMAC) {                   /* SHOW MACRO */
  6400.         struct FDB kw, fl, cm;
  6401.         int i, k, n = 0, left, flag, confirmed = 0;
  6402.         char * p, *q[64];
  6403.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6404.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6405.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6406.             mackey[i].flgs = mactab[i].flgs;
  6407.         }
  6408.         p = line;
  6409.         left = LINBUFSIZ;
  6410.         while (!confirmed && n < 64) {
  6411.             cmfdbi(&kw,                 /* First FDB - macro table */
  6412.                    _CMKEY,              /* fcode */
  6413.                    "Macro name",        /* hlpmsg */
  6414.                    "",                  /* default */
  6415.                    "",                  /* addtl string data */
  6416.                    nmac,                /* addtl numeric data 1: tbl size */
  6417.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6418.                    xxstring,            /* Processing function */
  6419.                    mackey,              /* Keyword table */
  6420.                    &fl                  /* Pointer to next FDB */
  6421.                    );
  6422.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6423.                    _CMFLD,              /* fcode */
  6424.                    "",                  /* hlpmsg */
  6425.                    "",                  /* default */
  6426.                    "",                  /* addtl string data */
  6427.                    0,                   /* addtl numeric data 1 */
  6428.                    0,                   /* addtl numeric data 2 */
  6429.                    xxstring,
  6430.                    NULL,
  6431.                    &cm
  6432.                    );
  6433.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6434.                    _CMCFM,              /* fcode */
  6435.                    "",                  /* hlpmsg */
  6436.                    "",                  /* default */
  6437.                    "",                  /* addtl string data */
  6438.                    0,                   /* addtl numeric data 1 */
  6439.                    0,                   /* addtl numeric data 2 */
  6440.                    NULL,
  6441.                    NULL,
  6442.                    NULL
  6443.                    );
  6444.             x = cmfdb(&kw);             /* Parse something */
  6445.             if (x < 0)
  6446.               return(x);
  6447.             s = atmbuf;                 /* What the user typed */
  6448.             switch (cmresult.fcode) {
  6449.               case _CMKEY:              /* If it was a keyword */
  6450.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6451.                 if (y > -1)
  6452.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6453.               case _CMFLD:
  6454.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6455.                 left -= k;
  6456.                 if (left <= 0) {
  6457.                     *p = NUL;
  6458.                     break;
  6459.                 }
  6460.                 q[n++] = p;             /* Point to this item */
  6461.                 p += k;                 /* Move buffer pointer past it */
  6462.                 break;
  6463.               case _CMCFM:              /* End of command */
  6464.                 confirmed++;
  6465.               default:
  6466.                 break;
  6467.             }
  6468.         }
  6469.         if (n == 0) {
  6470.             printf("Macros:\n");
  6471.             slc = 1;
  6472.             for (y = 0; y < nmac; y++)
  6473.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6474.             return(1);
  6475.         }
  6476.         slc = 0;
  6477.         for (i = 0; i < n; i++) {
  6478.             flag = 0;
  6479.             s = q[i];
  6480.             if (!s) s = "";
  6481.             if (!*s) continue;
  6482.             if (iswild(s)) {            /* Pattern match */
  6483.                 for (k = 0, x = 0; x < nmac; x++) {
  6484.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6485.                         shomac(mactab[x].kwd,mactab[x].mval);
  6486.                         k++;
  6487.                     }
  6488.                 }
  6489.                 if (!k)
  6490.                   x = -1;
  6491.                 else
  6492.                   continue;
  6493.             } else {                    /* Exact match */
  6494.                 x = mxlook(mactab,s,nmac);
  6495.                 flag = 1;
  6496.             }
  6497.             if (flag && x == -1)
  6498.               x = mlook(mactab,s,nmac);
  6499.             switch (x) {
  6500.               case -3:                  /* Nothing to look up */
  6501.               case -1:                  /* Not found */
  6502.                 printf("%s - (not defined)\n",s);
  6503.                 break;
  6504.               case -2:                  /* Ambiguous, matches more than one */
  6505.                 printf("%s - ambiguous\n",s);
  6506.                 break;
  6507.               default:                  /* Matches one exactly */
  6508.                 shomac(mactab[x].kwd,mactab[x].mval);
  6509.                 break;
  6510.             }
  6511.         }
  6512.         return(1);
  6513.     }
  6514. #endif /* NOSPL */
  6515.  
  6516. /*
  6517.   Other SHOW commands only have two fields.  Get command confirmation here,
  6518.   then handle with big switch() statement.
  6519. */
  6520. #ifndef NOSPL
  6521.     if (x != SHBUI && x != SHARR)
  6522. #endif /* NOSPL */
  6523.       if ((y = cmcfm()) < 0)
  6524.         return(y);
  6525.  
  6526. #ifdef COMMENT
  6527.     /* This restriction is too general. */
  6528. #ifdef IKSD
  6529.     if (inserver &&
  6530. #ifdef CK_LOGIN
  6531.         isguest
  6532. #else
  6533.         0
  6534. #endif /* CK_LOGIN */
  6535.         ) {
  6536.         printf("Sorry, command disabled.\r\n");
  6537.         return(success = 0);
  6538.     }
  6539. #endif /* IKSD */
  6540. #endif /* COMMENT */
  6541.  
  6542.     switch (x) {
  6543.  
  6544. #ifdef ANYX25
  6545. #ifndef IBMX25
  6546.       case SHPAD:
  6547.         shopad(0);
  6548.         break;
  6549. #endif /* IBMX25 */
  6550. #endif /* ANYX25 */
  6551.  
  6552.       case SHNET:
  6553. #ifdef NOLOCAL
  6554.         printf(" No network support in this version of C-Kermit.\n");
  6555. #else
  6556. #ifndef NETCONN
  6557.         printf(" No network support in this version of C-Kermit.\n");
  6558. #else
  6559.         shonet();
  6560. #endif /* NETCONN */
  6561. #endif /* NOLOCAL */
  6562.         break;
  6563.  
  6564.       case SHPAR:
  6565.         shopar();
  6566.         break;
  6567.  
  6568. #ifndef NOXFER
  6569.       case SHATT:
  6570.         shoatt();
  6571.         break;
  6572. #endif /* NOXFER */
  6573.  
  6574. #ifndef NOSPL
  6575.       case SHCOU:
  6576.         printf(" %d\n",count[cmdlvl]);
  6577.         break;
  6578. #endif /* NOSPL */
  6579.  
  6580. #ifndef NOSERVER
  6581.       case SHSER:                       /* Show Server */
  6582.         i = 0;
  6583. #ifndef NOFRILLS
  6584.         printf("Function:          Status:\n");
  6585.         i++;
  6586.         printf(" GET                %s\n",nm[en_get]);
  6587.         i++;
  6588.         printf(" SEND               %s\n",nm[en_sen]);
  6589.         i++;
  6590.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6591.         i++;
  6592.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6593.         i++;
  6594. #ifndef NOSPL
  6595.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6596.         i++;
  6597. #endif /* NOSPL */
  6598.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6599.         i++;
  6600. #ifdef ZCOPY
  6601.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6602.         i++;
  6603. #endif /* ZCOPY */
  6604.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6605.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6606.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6607.         i += 3;
  6608. #ifndef NOSPL
  6609.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6610.         i++;
  6611. #endif /* NOSPL */
  6612.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6613.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6614.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6615.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6616.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6617.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6618.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6619.         printf(" BYE                %s\n",nm[en_bye]);
  6620.         printf(" FINISH             %s\n",nm[en_fin]);
  6621.         printf(" EXIT               %s\n",nm[en_xit]);
  6622.         printf(" ENABLE             %s\n",nm[en_ena]);
  6623.         i += 11;
  6624. #endif /* NOFRILLS */
  6625.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6626.         printf("Server timeout:      %d\n",srvtim);
  6627.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6628.         printf("Server idle-timeout: %d\n",srvidl);
  6629.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6630.         printf("Server keepalive     %s\n", showoff(srvping));
  6631.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6632.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6633.         if (srvcdmsg && cdmsgstr)
  6634.           printf("Server cd-message    %s\n", cdmsgstr);
  6635.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6636.         printf("Server display:      %s\n", showoff(srvdis));
  6637.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6638.         printf("Server login:        ");
  6639.         if (!x_user) {
  6640.             printf("(none)\n");
  6641.         } else {
  6642.             printf("\"%s\", \"%s\", \"%s\"\n",
  6643.                    x_user,
  6644.                    x_passwd ? x_passwd : "",
  6645.                    x_acct ? x_acct : ""
  6646.                    );
  6647.         }
  6648.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6649.         printf("Server get-path: ");
  6650.         if (ngetpath == 0) {
  6651.             printf("    (none)\n");
  6652.         } else {
  6653.             printf("\n");
  6654.             i += 3;
  6655.             for (x = 0; x < ngetpath; x++) {
  6656.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6657.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6658.                     if (!askmore())
  6659.                       break;
  6660.                     else
  6661.                       i = 0;
  6662.                 }
  6663.             }
  6664.         }
  6665.         break;
  6666. #endif /* NOSERVER */
  6667.  
  6668.       case SHSTA:                       /* Status of last command */
  6669.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6670.         return(0);                      /* Don't change it */
  6671.  
  6672.       case SHSTK: {                     /* Stack for MAC debugging */
  6673. #ifdef MAC
  6674.           long sp;
  6675.           sp = -1;
  6676.           loadA0 ((char *)&sp);         /* set destination address */
  6677.           SPtoaA0();                    /* move SP to destination */
  6678.           printf("Stack at 0x%x\n", sp);
  6679.           show_queue();                 /* more debugging */
  6680.           break;
  6681. #else
  6682.           shostack();
  6683. #endif /* MAC */
  6684.           break;
  6685.       }
  6686.  
  6687.  
  6688. #ifndef NOLOCAL
  6689. #ifdef OS2
  6690.       case SHTAB:                       /* SHOW TABS */
  6691. #ifdef IKSD
  6692.         if (inserver) {
  6693.             printf("Sorry, command disabled.\r\n");
  6694.             return(success = 0);
  6695.         }
  6696. #endif /* IKSD */
  6697.         shotabs();
  6698.         break;
  6699. #endif /* OS2 */
  6700.  
  6701.       case SHTER:                       /* SHOW TERMINAL */
  6702. #ifdef IKSD
  6703.         if (inserver) {
  6704.             printf("Sorry, command disabled.\r\n");
  6705.             return(success = 0);
  6706.         }
  6707. #endif /* IKSD */
  6708.         shotrm();
  6709.         break;
  6710.  
  6711. #ifdef OS2
  6712.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6713.         shovscrn();
  6714.         break;
  6715. #endif /* OS2 */
  6716. #endif /* NOLOCAL */
  6717.  
  6718. #ifdef OS2MOUSE
  6719.       case SHMOU:                       /* SHOW MOUSE */
  6720. #ifdef IKSD
  6721.         if (inserver) {
  6722.             printf("Sorry, command disabled.\r\n");
  6723.             return(success = 0);
  6724.         }
  6725. #endif /* IKSD */
  6726.         shomou();
  6727.         break;
  6728. #endif /* OS2MOUSE */
  6729.  
  6730. #ifndef NOFRILLS
  6731.       case SHVER:
  6732.         shover();
  6733.         break;
  6734. #endif /* NOFRILLS */
  6735.  
  6736. #ifndef NOSPL
  6737.       case SHBUI:                       /* Built-in variables */
  6738.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6739.           return(y);
  6740.         ckstrncpy(line,s,LINBUFSIZ);
  6741.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6742.  
  6743.       case SHFUN:                       /* or built-in functions */
  6744. #ifdef CK_TTGWSIZ
  6745. #ifdef OS2
  6746.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6747.           ttgwsiz();
  6748. #else /* OS2 */
  6749.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6750.             if (tt_rows > 0 && tt_cols > 0) {
  6751.                 cmd_rows = tt_rows;
  6752.                 cmd_cols = tt_cols;
  6753.             }
  6754.         }
  6755. #endif /* OS2 */
  6756. #endif /* CK_TTGWSIZ */
  6757.  
  6758.         if (x == SHFUN) {               /* Functions */
  6759.             printf("\nThe following functions are available:\n\n");
  6760.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6761.             printf("\n");
  6762. #ifndef NOHELP
  6763.             printf(
  6764. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6765.                    );
  6766. #endif /* NOHELP */
  6767.             break;
  6768.         } else {                        /* Variables */
  6769.         int j, flag = 0, havearg = 0;
  6770.         struct stringarray * q = NULL;
  6771.         char ** pp;
  6772.         if (line[0]) {        /* Have something to search for */
  6773.         havearg = 1;        /* Maybe a list of things */
  6774.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6775.         if (!q) break;
  6776.         pp = q->a_head;
  6777.         }
  6778.         i = 0;
  6779.         for (y = 0; y < nvars; y++) {
  6780.         if ((vartab[y].flgs & CM_INV))
  6781.           continue;
  6782.         if (havearg) {        /* If I have something to match */
  6783.             char * s2;
  6784.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6785.             s2 = pp[j] ? pp[j] : "";
  6786. #ifdef COMMENT
  6787. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6788.             len = strlen(s2);
  6789.             if (len > 0) {
  6790.                 if (s2[len-1] != '$') {/* To allow anchors */
  6791.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6792.                 s2 = line;
  6793.                 }
  6794.             }
  6795. #endif /* COMMENT */
  6796.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6797.                 flag = 1;    /* Matches */
  6798.                 break;
  6799.             }
  6800.             }
  6801.             if (!flag)        /* Doesn't match */
  6802.               continue;
  6803.         }
  6804.         s = nvlook(vartab[y].kwd);
  6805.         printf(" \\v(%s) = ",vartab[y].kwd);
  6806.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6807.             while (*s)        /* Show control chars symbolically */
  6808.               printf("\\{%d}",*s++);
  6809.             printf("\n");
  6810.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6811.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6812. #ifdef OS2
  6813.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6814. #endif /* OS2 */
  6815.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6816.                 vartab[y].kwval <= VN_M_ZZZ)
  6817.                ) {
  6818.             int r = 12;        /* This one can wrap around */
  6819.             char buf[10];
  6820.             while (*s) {
  6821.             if (isprint(*s)) {
  6822.                 buf[0] = *s;
  6823.                 buf[1] = NUL;
  6824.                 r++;
  6825.             } else {
  6826.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6827.                 r += (int) strlen(buf);
  6828.             }
  6829.             if (r >= cmd_cols - 1) {
  6830.                 printf("\n");
  6831.                 r = 0;
  6832.                 i++;
  6833.             }
  6834.             printf("%s",buf);
  6835.             s++;
  6836.             }
  6837.             printf("\n");
  6838.         } else
  6839.           printf("%s\n",s);
  6840.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6841.             if ((y >= nvars - 1) || !askmore())
  6842.               break;
  6843.             else
  6844.               i = 0;
  6845.         }
  6846.         }
  6847.         }
  6848.         break;
  6849.  
  6850.       case SHVAR:                       /* Global variables */
  6851.         x = 0;                          /* Variable count */
  6852.         slc = 1;                        /* Screen line count for "more?" */
  6853.         for (y = 33; y < GVARS; y++)
  6854.           if (g_var[y]) {
  6855.               if (x++ == 0) printf("Global variables:\n");
  6856.               sprintf(line," \\%%%c",y); /* SAFE */
  6857.               if (shomac(line,g_var[y]) < 0) break;
  6858.           }
  6859.         if (!x) printf(" No variables defined\n");
  6860.         break;
  6861.  
  6862.       case SHARG: {                     /* Args */
  6863.           char * s1, * s2;
  6864.           if (maclvl > -1) {
  6865.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6866.                      maclvl,
  6867.                      macargc[maclvl]
  6868.                      );
  6869.               for (y = 0; y < macargc[maclvl]; y++) {
  6870.                   s1 = m_arg[maclvl][y];
  6871.                   if (!s1) s1 = "(NULL)";
  6872.                   s2 = m_xarg[maclvl][y];
  6873.                   if (!s2) s2 = "(NULL)";
  6874.                   if (y < 10)
  6875.                     printf(" \\%%%d = %s\n",y,s1);
  6876.                   else
  6877.                     printf(" \\&_[%d] = %s\n",y,s2);
  6878.               }
  6879.           } else {
  6880.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  6881.               for (y = 0; y < topargc; y++) {
  6882.                   s1 = g_var[y + '0'];
  6883.                   if (!s1) s1 = "(NULL)";
  6884.                   s2 = toparg[y];
  6885.                   if (!s2) s2 = "(NULL)";
  6886.                   if (y < 10 && g_var[y])
  6887.                     printf(" \\%%%d = %s\n",y,s1);
  6888.                   if (toparg[y])
  6889.                     printf(" \\&_[%d] = %s\n",y,s2);
  6890.               }
  6891.           }
  6892.         }
  6893.         break;
  6894.  
  6895.       case SHARR:                       /* Arrays */
  6896.         return(showarray());
  6897. #endif /* NOSPL */
  6898.  
  6899. #ifndef NOXFER
  6900.       case SHPRO:                       /* Protocol parameters */
  6901.         shoparp();
  6902.         printf("\n");
  6903.         break;
  6904. #endif /* NOXFER */
  6905.  
  6906. #ifndef NOLOCAL
  6907.       case SHCOM:                       /* Communication parameters */
  6908.         printf("\n");
  6909.         shoparc();
  6910. #ifdef OS2
  6911.         {
  6912.             int i;
  6913.             char *s = "(unknown)";
  6914.             for (i = 0; i < nprty; i++)
  6915.               if (prtytab[i].kwval == priority) {
  6916.                   s = prtytab[i].kwd;
  6917.                   break;
  6918.               }
  6919.             printf(" Priority: %s\n", s );
  6920.         }
  6921. #endif /* OS2 */
  6922.  
  6923.         printf("\n");
  6924. #ifdef NETCONN
  6925.         if (!network
  6926. #ifdef IKSD
  6927.              && !inserver
  6928. #endif /* IKSD */
  6929.              ) {
  6930. #endif /* NETCONN */
  6931.             shomdm();
  6932.             printf("\n");
  6933. #ifdef NETCONN
  6934.         }
  6935. #endif /* NETCONN */
  6936.  
  6937. #ifndef NODIAL
  6938. #ifdef IKSD
  6939.         if ( !inserver )
  6940. #endif /* IKSD */
  6941.         {
  6942.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  6943.             printf("Type SHOW MODEM to see modem-related items.\n");
  6944. #ifdef CK_TAPI
  6945.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  6946. #endif /* CK_TAPI */
  6947.             printf("\n");
  6948.         }
  6949. #endif /* NODIAL */
  6950.         break;
  6951. #endif /* NOLOCAL */
  6952.  
  6953.       case SHFIL:                       /* File parameters */
  6954.         shofil();
  6955.         /* printf("\n"); */             /* (out o' space) */
  6956.         break;
  6957.  
  6958. #ifndef NOCSETS
  6959.       case SHLNG:                       /* Languages */
  6960.         shoparl();
  6961.         break;
  6962. #endif /* NOCSETS */
  6963.  
  6964. #ifndef NOSPL
  6965.       case SHSCR:                       /* Scripts */
  6966.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  6967.         printf(" Take  echo:             %s\n", showoff(techo));
  6968.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  6969.         printf(" Macro echo:             %s\n", showoff(mecho));
  6970.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  6971.         printf(" Quiet:                  %s\n", showoff(quiet));
  6972.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  6973.         printf(" Function error:         %s\n", showoff(fnerror));
  6974. #ifdef CKLEARN
  6975.         {
  6976.             extern char * learnfile;
  6977.             extern int learning;
  6978.             if (learnfile) {
  6979.                 printf(" LEARN file:             %s (%s)\n",
  6980.                        learnfile,
  6981.                        learning ? "ON" : "OFF"
  6982.                        );
  6983.             } else
  6984.               printf(" LEARN file:             (none)\n");
  6985.         }
  6986. #endif /* CKLEARN */
  6987.         shoinput();
  6988.         shooutput();
  6989. #ifndef NOSCRIPT
  6990.         printf(" Script echo:            %s\n", showoff(secho));
  6991. #endif /* NOSCRIPT */
  6992.         printf(" Command buffer length:  %d\n", CMDBL);
  6993.         printf(" Atom buffer length:     %d\n", ATMBL);
  6994.         break;
  6995. #endif /* NOSPL */
  6996.  
  6997. #ifndef NOXMIT
  6998.       case SHXMI:
  6999.         printf("\n");
  7000.         printf(" File type:                       %s\n",
  7001.                binary ? "binary" : "text");
  7002. #ifndef NOCSETS
  7003.         printf(" File character-set:              %s\n",
  7004.                fcsinfo[fcharset].keyword);
  7005. #ifdef OS2
  7006.         if ( isunicode() ) {
  7007.         printf(" Terminal Character (remote):     %s\n",
  7008.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7009.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7010.         printf(" Terminal Character (local):      %s\n",
  7011.               tcsl == TX_TRANSP ? "transparent" :
  7012.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7013.         } else {
  7014.         printf(" Terminal Character (remote):     %s\n",
  7015.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7016.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7017.         printf(" Terminal Character (local):      %s\n",
  7018.               tcsl == TX_TRANSP ? "transparent" :
  7019.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7020.         }
  7021. #else /* OS2 */
  7022.         printf(" Terminal character-set (remote): %s\n",
  7023.                fcsinfo[tcsr].keyword);
  7024.         printf(" Terminal character-set (local):  %s\n",
  7025.                fcsinfo[tcsl].keyword);
  7026. #endif /* OS2 */
  7027. #endif /* NOCSETS */
  7028.         printf(" Terminal bytesize:               %d\n",
  7029.                (cmask == 0xff) ? 8 : 7);
  7030.         printf(" Terminal echo:                   %s\n",
  7031.                duplex ? "local" : "remote");
  7032.         printf(" Transmit EOF:                    ");
  7033.         if (*xmitbuf == NUL) {
  7034.             printf("(none)\n");
  7035.         } else {
  7036.             char *p;
  7037.             p = xmitbuf;
  7038.             while (*p) {
  7039.                 if (*p < SP)
  7040.                   printf("^%c",ctl(*p));
  7041.                 else
  7042.                   printf("%c",*p);
  7043.                 p++;
  7044.             }
  7045.             printf("\n");
  7046.         }
  7047.         if (xmitf)
  7048.           printf(" Transmit Fill:                   %d\n", xmitf);
  7049.         else
  7050.           printf(" Transmit Fill:                   (none)\n");
  7051.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  7052.         if (xmitp)
  7053.           printf(" Transmit Prompt:                 %d (%s)\n",
  7054.                  xmitp,
  7055.                  chartostr(xmitp)
  7056.                  );
  7057.         else
  7058.           printf(" Transmit Prompt:                 (none)\n");
  7059.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  7060.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  7061.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  7062.                xmitw,
  7063.                (xmitw == 1) ? "" : "s"
  7064.                );
  7065.         printf(" Transmit Timeout:                %d (second%s)\n",
  7066.                xmitt,
  7067.                (xmitt == 1) ? "" : "s"
  7068.                );
  7069.         printf("\n");
  7070.         break;
  7071. #endif /* NOXMIT */
  7072.  
  7073. #ifndef NODIAL
  7074.       case SHMOD:                       /* SHOW MODEM */
  7075. #ifdef IKSD
  7076.         if (inserver) {
  7077.             printf("Sorry, command disabled.\r\n");
  7078.             return(success = 0);
  7079.         }
  7080. #endif /* IKSD */
  7081.         shomodem();                     /* Show SET MODEM items */
  7082.         break;
  7083. #endif /* NODIAL */
  7084.  
  7085. #ifndef MAC
  7086.       case SHDFLT:
  7087.         printf("%s\n",zgtdir());
  7088.         break;
  7089. #endif /* MAC */
  7090.  
  7091. #ifndef NOLOCAL
  7092.       case SHESC:
  7093. #ifdef IKSD
  7094.         if (inserver) {
  7095.             printf("Sorry, command disabled.\r\n");
  7096.             return(success = 0);
  7097.         }
  7098. #endif /* IKSD */
  7099.         return(shoesc(escape));
  7100.  
  7101. #ifndef NODIAL
  7102.       case SHDIA:                       /* SHOW DIAL */
  7103. #ifdef IKSD
  7104.         if (inserver) {
  7105.             printf("Sorry, command disabled.\r\n");
  7106.             return(success = 0);
  7107.         }
  7108. #endif /* IKSD */
  7109.         shmdmlin();
  7110.         printf(", speed: ");
  7111.         if ((zz = ttgspd()) < 0) {
  7112.             printf("unknown");
  7113.         } else {
  7114.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  7115.         }
  7116.         if (carrier == CAR_OFF) s = "off";
  7117.         else if (carrier == CAR_ON) s = "on";
  7118.         else if (carrier == CAR_AUT) s = "auto";
  7119.         else s = "unknown";
  7120.         printf(", carrier: %s", s);
  7121.         if (carrier == CAR_ON) {
  7122.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  7123.             else printf(", timeout: none");
  7124.         }
  7125.         printf("\n");
  7126.         doshodial();
  7127.         if (local
  7128. #ifdef NETCONN
  7129.             && !network
  7130. #endif /* NETCONN */
  7131.             ) {
  7132.             printf("Type SHOW MODEM to see modem settings.\n");
  7133. #ifdef CK_TAPI
  7134.             printf("Type SHOW TAPI to see TAPI-related items\n");
  7135. #endif /* CK_TAPI */
  7136.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  7137.         }
  7138.         break;
  7139. #endif /* NODIAL */
  7140. #endif /* NOLOCAL */
  7141.  
  7142. #ifndef NOXFER
  7143. #ifdef CK_LABELED
  7144.       case SHLBL:                       /* Labeled file info */
  7145.         sholbl();
  7146.         break;
  7147. #endif /* CK_LABELED */
  7148. #endif /* NOXFER */
  7149.  
  7150.       case SHCSE:                       /* Character sets */
  7151. #ifdef NOCSETS
  7152.         printf(
  7153. " Character set translation is not supported in this version of C-Kermit\n");
  7154. #else
  7155.         shocharset();
  7156. #ifndef NOXFER
  7157.         printf("\n Unknown-Char-Set: %s\n",
  7158.                unkcs ? "Keep" : "Discard");
  7159. #endif /* NOXFER */
  7160. #ifdef OS2
  7161.         printf("\n");
  7162. #endif /* OS2 */
  7163.         shotcs(tcsl,tcsr);
  7164.         printf("\n");
  7165. #ifdef OS2
  7166.         /* PC Code Page information */
  7167.         {
  7168.             char cpbuf[128];
  7169.             int cplist[16], cps;
  7170.             int activecp;
  7171.             cps = os2getcplist(cplist, sizeof(cplist));
  7172.  
  7173.             sprintf(cpbuf,              /* SAFE */
  7174.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7175.                      cps > 1 ? cplist[1] : 0,
  7176.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7177.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7178.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7179.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7180.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7181.                      cps > 12 ? cplist[12] : 0
  7182.                      );
  7183.             printf(" Code Pages:\n");
  7184.             activecp = os2getcp();
  7185.             if ( activecp ) {
  7186.               printf("     Active: %d\n",activecp);
  7187.               if (!isWin95())
  7188.                 printf("  Available: %s\n",cpbuf);
  7189.             } else
  7190.               printf("     Active: n/a\n");
  7191.             printf("\n");
  7192.         }
  7193. #endif /* OS2 */
  7194. #endif /* NOCSETS */
  7195.         break;
  7196.  
  7197.       case SHFEA:                       /* Features */
  7198.         shofea();
  7199.         break;
  7200.  
  7201. #ifdef CK_SPEED
  7202.       case SHCTL:                       /* Control-Prefix table */
  7203.         shoctl();
  7204.         break;
  7205. #endif /* CK_SPEED */
  7206.  
  7207.       case SHEXI: {
  7208.           extern int exithangup;
  7209.           printf("\n Exit warning %s\n", xitwarn ?
  7210.                  (xitwarn == 1 ? "on" : "always") : "off");
  7211.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7212.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7213.           printf(" Current exit status: %d\n\n", xitsta);
  7214.           break;
  7215.       }
  7216.       case SHPRT: {
  7217. #ifdef PRINTSWI
  7218.           extern int printtimo, printertype, noprinter;
  7219.           extern char * printterm, * printsep;
  7220. #ifdef BPRINT
  7221.           extern int printbidi;
  7222. #endif /* BPRINT */
  7223. #endif /* PRINTSWI */
  7224.  
  7225. #ifdef IKSD
  7226.         if (inserver &&
  7227. #ifdef CK_LOGIN
  7228.             isguest
  7229. #else /* CK_LOGIN */
  7230.             0
  7231. #endif /* CK_LOGIN */
  7232.              ) {
  7233.             printf("Sorry, command disabled.\r\n");
  7234.             return(success = 0);
  7235.         }
  7236. #endif /* IKSD */
  7237. #ifdef PRINTSWI
  7238.           if (noprinter) {
  7239.               printf("Printer: (none)\n\n");
  7240.               break;
  7241.           }
  7242. #endif /* PRINTSWI */
  7243.  
  7244.           printf("Printer: %s%s\n",
  7245.  
  7246.                  printpipe ? "| " : "",
  7247.                  printername ? printername :
  7248. #ifdef OS2
  7249.                  "PRN"
  7250. #else
  7251.                  "(default)"
  7252. #endif /* OS2 */
  7253.                  );
  7254. #ifdef PRINTSWI
  7255. #ifdef BPRINT
  7256.           if (printbidi) {
  7257.               printf(" /BIDIRECTIONAL\n");
  7258.               if (pportspeed > 0)
  7259.                 printf(" /SPEED:%ld\n",pportspeed);
  7260.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7261.               printf(" /FLOW:%s\n",
  7262.                      pportflow == FLO_NONE ? "NONE" :
  7263.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7264.                      );
  7265.           } else
  7266.             printf(" /OUTPUT-ONLY\n");
  7267. #endif /* BPRINT */
  7268.           switch (printertype) {
  7269.             case PRT_NON: printf(" /NONE\n"); break;
  7270.             case PRT_FIL: printf(" /FILE\n"); break;
  7271.             case PRT_PIP: printf(" /PIPE\n"); break;
  7272.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7273.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7274.           }
  7275.           printf(" /TIMEOUT:%d\n",printtimo);
  7276.           if (printterm) {
  7277.               printf(" /END-OF-JOB-STRING:");
  7278.               shostrdef(printterm);
  7279.               printf("\n");
  7280.           } else
  7281.             printf(" /END-OF-JOB-STRING:(none)\n");
  7282.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7283. #endif /* PRINTSWI */
  7284.           printf("\n");
  7285.           break;
  7286.       }
  7287.  
  7288.       case SHCMD: {
  7289. #ifdef DOUBLEQUOTING
  7290.           extern int dblquo;
  7291. #endif /* DOUBLEQUOTING */
  7292. #ifdef CK_AUTODL
  7293.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7294. #else
  7295.           printf(" Command autodownload: (not available)\n");
  7296. #endif /* CK_AUTODL */
  7297.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7298. #ifdef CK_RECALL
  7299.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7300. #else
  7301.           printf(" Command recall-buffer not available in this version\n");
  7302. #endif /* CK_RECALL */
  7303. #ifdef CK_RECALL
  7304.           printf(" Command retry: %s\n",showoff(cm_retry));
  7305. #else
  7306.           printf(" Command retry not available in this version\n");
  7307. #endif /* CK_RECALL */
  7308.           printf(" Command interruption: %s\n", showoff(cmdint));
  7309.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7310. #ifdef DOUBLEQUOTING
  7311.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7312. #endif /* DOUBLEQUOTING */
  7313.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7314.           printf(" Command height: %d\n", cmd_rows);
  7315.           printf(" Command width:  %d\n", cmd_cols);
  7316. #ifndef IKSDONLY
  7317. #ifdef OS2
  7318.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7319. #endif /* OS2 */
  7320. #endif /* IKSDONLY */
  7321. #ifdef LOCUS
  7322.           printf(" Locus:          %s",
  7323.                  autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7324.          (locus ? "local" : "remote"));
  7325.           if (autolocus)
  7326.             printf(" (%s)", locus ? "local" : "remote");
  7327.           printf("\n");
  7328. #endif /* LOCUS */
  7329.           printf(" Hints:          %s\n", showoff(hints));
  7330.           printf(" Quiet:          %s\n", showoff(quiet));
  7331.           printf(" Maximum command length: %d\n", CMDBL);
  7332. #ifndef NOSPL
  7333.           {
  7334.               char * s;
  7335.               int k;
  7336.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7337.               printf(" Macros defined: %d\n", nmac);
  7338.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7339.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7340.               s = "(not defined)";
  7341.               k = mlook(mactab,"on_unknown_command",nmac);
  7342.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7343.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7344.           }
  7345. #endif /* NOSPL */
  7346. #ifdef UNIX
  7347. #ifndef NOJC
  7348.           printf(" Suspend: %s\n", showoff(suspend));
  7349. #endif /* NOJC */
  7350. #endif /* UNIX */
  7351.           printf(" Access to external commands and programs%s allowed\n",
  7352. #ifndef NOPUSH
  7353.                  !nopush ? "" :
  7354. #endif /* NOPUSH */
  7355.                   " not");
  7356.           break;
  7357.       }
  7358.  
  7359. #ifndef NOSPL
  7360.       case SHALRM:
  7361.         if (ck_alarm)
  7362.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7363.         else
  7364.           printf("(no alarm set)\n");
  7365.         break;
  7366. #endif /* NOSPL */
  7367.  
  7368. #ifndef NOMSEND
  7369.       case SHSFL: {
  7370.           extern struct filelist * filehead;
  7371.           if (!filehead) {
  7372.               printf("send-list is empty\n");
  7373.           } else {
  7374.               struct filelist * flp;
  7375.               char * s;
  7376.               flp = filehead;
  7377.               while (flp) {
  7378.                   s = flp->fl_alias;
  7379.                   if (!s) s = "(none)";
  7380.                   printf("%s, mode: %s, alias: %s\n",
  7381.                          flp->fl_name,
  7382.                          gfmode(flp->fl_mode,0),
  7383.                          s
  7384.                          );
  7385.                   flp = flp->fl_next;
  7386.               }
  7387.           }
  7388.       }
  7389.       break;
  7390. #endif /* NOMSEND */
  7391.  
  7392. #ifdef CKXXCHAR
  7393.       case SHDBL:
  7394.         shodbl();
  7395.         break;
  7396. #endif /* CKXXCHAR */
  7397.  
  7398. #ifndef NOPUSH
  7399. #ifndef NOFRILLS
  7400.       case SHEDIT:
  7401.         if (!editor[0]) {
  7402.             s = getenv("EDITOR");
  7403.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7404.         }
  7405.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7406.         if (editor[0]) {
  7407.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7408.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7409.         }
  7410.         printf("\n");
  7411.         break;
  7412.  
  7413. #ifdef BROWSER
  7414.       case SHBROWSE:
  7415.         if (!browser[0]) {
  7416.             s = getenv("BROWSER");
  7417.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7418.         }
  7419.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7420.         if (browser[0]) {
  7421.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7422.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7423.         }
  7424.         printf("\n");
  7425.         break;
  7426. #endif /* BROWSER */
  7427. #endif /*  NOFRILLS */
  7428. #endif /* NOPUSH */
  7429.  
  7430. #ifndef NOLOCAL
  7431. #ifdef CK_TAPI
  7432.       case SHTAPI:                      /* TAPI options */
  7433. #ifdef IKSD
  7434.         if (inserver) {
  7435.             printf("Sorry, command disabled.\r\n");
  7436.             return(success = 0);
  7437.         }
  7438. #endif /* IKSD */
  7439.         shotapi(0);
  7440.         break;
  7441.       case SHTAPI_L:                    /* TAPI Locations */
  7442. #ifdef IKSD
  7443.         if (inserver) {
  7444.             printf("Sorry, command disabled.\r\n");
  7445.             return(success = 0);
  7446.         }
  7447. #endif /* IKSD */
  7448.         shotapi(1);
  7449.         break;
  7450.       case SHTAPI_M:                    /* TAPI Modem */
  7451. #ifdef IKSD
  7452.         if (inserver) {
  7453.             printf("Sorry, command disabled.\r\n");
  7454.             return(success = 0);
  7455.         }
  7456. #endif /* IKSD */
  7457.         shotapi(2);
  7458.         break;
  7459.       case SHTAPI_C:                    /* TAPI Comm */
  7460. #ifdef IKSD
  7461.         if (inserver) {
  7462.             printf("Sorry, command disabled.\r\n");
  7463.             return(success = 0);
  7464.         }
  7465. #endif /* IKSD */
  7466.         shotapi(3);
  7467.         break;
  7468. #endif /* CK_TAPI */
  7469.  
  7470.       case SHTCP:                       /* SHOTCP */
  7471.         printf("\n");
  7472.         shotcp(0);
  7473.         printf("\n");
  7474.         break;
  7475.  
  7476. #ifdef TNCODE
  7477.       case SHTEL:                       /* TELNET */
  7478.         printf("\n");
  7479.         shotel(0);
  7480.         printf("\n");
  7481.         break;
  7482.  
  7483.       case SHTOPT:                      /* TELNET OPTIONS */
  7484.         printf("\n");
  7485.         shotopt(0);
  7486.         printf("\n");
  7487.         break;
  7488. #endif /* TNCODE */
  7489.  
  7490. #ifdef CK_TRIGGER
  7491.       case SHTRIG: {
  7492.           extern char * tt_trigger[], * triggerval;
  7493.           int i;
  7494.           if (!tt_trigger[0]) {
  7495.               printf(" Triggers: (none)\n");
  7496.           } else {
  7497.               printf(" Triggers:\n");
  7498.               for (i = 0; i < TRIGGERS; i++) {
  7499.                   if (!tt_trigger[i])
  7500.                     break;
  7501.                   printf("  \"%s\"\n",tt_trigger[i]);
  7502.               }
  7503.               printf(" Most recent trigger encountered: ");
  7504.               if (triggerval)
  7505.                 printf("\"%s\"\n",triggerval);
  7506.               else
  7507.                 printf("(none)\n");
  7508.           }
  7509.           break;
  7510.       }
  7511. #endif /* CK_TRIGGER */
  7512. #endif /* NOLOCAL */
  7513.  
  7514. #ifndef NOSPL
  7515.       case SHINP:
  7516.         shoinput();
  7517.         break;
  7518. #endif /* NOSPL */
  7519.  
  7520.       case SHLOG: {
  7521. #ifndef MAC
  7522. #ifdef IKSD
  7523.           if (inserver &&
  7524. #ifdef CK_LOGIN
  7525.               isguest
  7526. #else /* CK_LOGIN */
  7527.               0
  7528. #endif /* CK_LOGIN */
  7529.              ) {
  7530.             printf("Sorry, command disabled.\r\n");
  7531.             return(success = 0);
  7532.         }
  7533. #endif /* IKSD */
  7534. #ifdef DEBUG
  7535.           printf("\n Debug log:       %s\n", deblog ? debfil : "(none)");
  7536. #endif /* DEBUG */
  7537. #ifndef NOXFER
  7538.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7539. #endif /* NOXFER */
  7540. #ifndef NOLOCAL
  7541.           printf(" Session log:     %s\n",   seslog ? sesfil : "(none)");
  7542. #endif /* NOLOCAL */
  7543. #ifdef TLOG
  7544.           printf(" Transaction log: %s (%s)\n",
  7545.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7546.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7547.                  );
  7548. #endif /* TLOG */
  7549. #ifdef CKLOGDIAL
  7550.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7551. #endif /* CKLOGDIAL */
  7552.           printf("\n");
  7553. #endif /* MAC */
  7554.           break;
  7555.       }
  7556.  
  7557. #ifndef NOSPL
  7558.       case SHOUTP:                      /* OUTPUT */
  7559.         shooutput();
  7560.         break;
  7561. #endif /* NOSPL */
  7562.  
  7563. #ifdef PATTERNS
  7564.       case SHOPAT:                      /* PATTERNS */
  7565.         shopat();
  7566.         break;
  7567. #endif /* PATTERNS */
  7568.  
  7569. #ifdef STREAMING
  7570.       case SHOSTR: {                    /* STREAMING */
  7571.           extern int streamrq, clearrq, cleared;
  7572.           extern long tfcps;
  7573.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7574.           printf("\n Reliable:     %s\n",showooa(reliable));
  7575.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7576.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7577.           if ((!local && (streamrq == SET_ON)) ||
  7578.               (streamrq == SET_AUTO && reliable))
  7579.             printf(" Streaming will be done if requested.\n");
  7580.           else if ((streamrq == SET_OFF) ||
  7581.                    ((streamrq == SET_AUTO) && !reliable))
  7582.             printf(" Streaming will not be requested and will not be done.\n");
  7583.           else if ((streamrq == SET_ON) ||
  7584.                    ((streamrq == SET_AUTO) && reliable))
  7585.             printf(
  7586. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7587.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7588.                  streamed > 0 ? "" : "no ",
  7589.                  cleared ? ", clearchannel" : "",
  7590.                  tfcps
  7591.                  );
  7592.           printf("\n");
  7593.           break;
  7594.       }
  7595. #endif /* STREAMING */
  7596.  
  7597.       case SHOIKS:
  7598.         return(sho_iks());
  7599.         break;
  7600.  
  7601. #ifdef CK_AUTHENTICATION
  7602.       case SHOAUTH:
  7603.         return(sho_auth(0));
  7604. #endif /* CK_AUTHENTICATION */
  7605.  
  7606. #ifndef NOFTP
  7607.       case SHOFTP: {
  7608. #ifdef IKSD
  7609.         if (inserver) {
  7610.             printf("Sorry, command disabled.\r\n");
  7611.             return(success = 0);
  7612.         }
  7613. #endif /* IKSD */
  7614. #ifdef SYSFTP
  7615.         {
  7616.             extern char ftpapp[], ftpopts[];
  7617.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7618.             if (ftpapp[0])
  7619.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7620.         }
  7621. #else
  7622. #ifdef NEWFTP
  7623.         shoftp(0);
  7624. #else
  7625.         printf("(No FTP client included in this version of Kermit.)\n");
  7626. #endif /* NEWFTP */
  7627. #endif /* SYSFTP */
  7628.         break;
  7629.       }
  7630. #endif /* NOFTP */
  7631.  
  7632. #ifndef NOCMDL
  7633.       case SHXOPT: {
  7634. #ifdef IKSDB
  7635.           extern int dbenabled;
  7636.           extern char * dbfile, * dbdir;
  7637. #endif /* IKSDB */
  7638. #ifdef CKWTMP
  7639.           extern int ckxwtmp;
  7640.           extern char * wtmpfile;
  7641. #endif /* CKWTMP */
  7642. #ifdef CK_LOGIN
  7643.           extern int ckxanon, xferlog, logintimo;
  7644.           extern char * xferfile;
  7645. #ifdef UNIX
  7646.           extern int ckxpriv;
  7647. #endif /* UNIX */
  7648. #ifdef CK_PERMS
  7649.           extern int ckxperms;
  7650. #endif /* CK_PERMS */
  7651. #endif /* CK_LOGIN */
  7652.           extern char * bannerfile, * helpfile;
  7653.  
  7654. #ifdef IKSD
  7655.           if (inserver &&
  7656. #ifdef CK_LOGIN
  7657.               isguest
  7658. #else /* CK_LOGIN */
  7659.               0
  7660. #endif /* CK_LOGIN */
  7661.               ) {
  7662.               printf("Sorry, command disabled.\r\n");
  7663.               return(success = 0);
  7664.           }
  7665. #endif /* IKSD */
  7666.           printf("\n");
  7667.           if (!cmdint)
  7668.             printf(" --nointerrupts\n");
  7669.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7670.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7671.           printf(" --cdmessage:%d\n",srvcdmsg);
  7672.           printf(" --helpfile:%d\n",helpfile);
  7673.           if (inserver) {
  7674.               printf("\n");
  7675.               break;
  7676.           }
  7677. #ifdef CKSYSLOG
  7678. #ifdef SYSLOGLEVEL
  7679.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7680. #else
  7681.           printf(" --syslog:%d\n",ckxsyslog);
  7682. #endif /* SYSLOGLEVEL */
  7683. #endif /* CKSYSLOG */
  7684. #ifdef CKWTMP
  7685.           printf(" --wtmplog:%d\n",ckxwtmp);
  7686.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7687. #endif /* CKWTMP */
  7688. #ifdef IKSD
  7689. #ifdef CK_LOGIN
  7690.           printf(" --anonymous:%d\n",ckxanon);
  7691. #ifdef UNIX
  7692.           printf(" --privid:%d\n",ckxpriv);
  7693. #endif /* UNIX */
  7694. #ifdef CK_PERMS
  7695.           printf(" --permission:%04o\n",ckxperms);
  7696. #endif /* CK_PERMS */
  7697.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7698.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7699.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7700.           printf(" --xferlog=%d\n",xferlog);
  7701.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7702.           printf(" --timeout=%d\n",logintimo);
  7703. #endif /* CK_LOGIN */
  7704. #ifdef IKSDB
  7705.           printf(" --database=%d\n",dbenabled);
  7706.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7707.           if (dbdir)
  7708.             printf("   (db directory=[%s])\n",dbdir);
  7709. #endif /* IKSDB */
  7710. #ifdef IKSDCONF
  7711.           printf(" IKSD conf=%s\n",iksdconf);
  7712. #endif /* IKSDCONF */
  7713. #endif /* IKSD */
  7714.           printf("\n");
  7715.           break;
  7716.       }
  7717. #endif /* NOCMDL */
  7718.  
  7719.       case SHCD: {
  7720.       extern char * myhome;
  7721.       s = getenv("CDPATH");
  7722.       if (!s) s = "(none)";
  7723.       printf("\n current directory:  %s\n", zgtdir());
  7724.       printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7725.       printf(" cd home:            %s\n", homepath());
  7726.       printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7727.       printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7728.       printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7729.       printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7730.       break;
  7731.       }
  7732. #ifndef NOCSETS
  7733.       case SHASSOC:
  7734.         (VOID) showassoc();
  7735.         break;
  7736. #endif /* NOCSETS */
  7737.  
  7738. #ifdef CKLOGDIAL
  7739.       case SHCONNX:
  7740. #ifdef NEWFTP
  7741.         if (ftpisconnected()) {
  7742.             extern char cxlogbuf[];
  7743.             dologshow(W_FTP | 1);
  7744.             if (cxlogbuf[0])
  7745.               dologshow(1);
  7746.         } else {
  7747. #endif /* NEWFTP */
  7748.             dologshow(1);
  7749. #ifdef NEWFTP
  7750.         }
  7751. #endif /* NEWFTP */
  7752.         break;
  7753. #endif /* CKLOGDIAL */
  7754.  
  7755.       case SHOPTS:
  7756.         optlines = 0;
  7757. #ifndef NOFRILLS
  7758.         (VOID) showdelopts();
  7759. #endif /* NOFRILLS */
  7760. #ifdef DOMYDIR
  7761.         (VOID) showdiropts();
  7762. #endif /* DOMYDIR */
  7763. #ifdef CKPURGE
  7764.         (VOID) showpurgopts();
  7765. #endif /* CKPURGE */
  7766.         (VOID) showtypopts();
  7767.         break;
  7768.  
  7769. #ifndef NOLOCAL
  7770.       case SHOFLO:
  7771.         (VOID) shoflow();
  7772.         break;
  7773. #endif /* NOLOCAL */
  7774.  
  7775. #ifndef NOXFER
  7776.       case SHOXFER:
  7777.         (VOID) shoxfer();
  7778.         break;
  7779. #endif /* NOXFER */
  7780.  
  7781. #ifdef CK_RECALL
  7782.       case SHHISTORY:
  7783.         (VOID) cmhistory();
  7784.         break;
  7785. #endif /* CK_RECALL */
  7786.  
  7787. #ifndef NOSEXP
  7788. #ifndef NOSPL
  7789.       case SHSEXP:
  7790.         (VOID) shosexp();
  7791.         break;
  7792. #endif /* NOSPL */
  7793. #endif /* NOSEXP */
  7794.  
  7795. #ifdef ANYSSH
  7796.       case SHOSSH:
  7797.         (VOID) shossh();
  7798.         break;
  7799. #endif /* ANYSSH */
  7800.  
  7801. #ifdef KUI
  7802.       case SHOGUI:
  7803.         (VOID) shogui();
  7804.         break;
  7805. #endif /* KUI */
  7806.  
  7807.       default:
  7808.         printf("\nNothing to show...\n");
  7809.         return(-2);
  7810.     }
  7811.     return(success = 1);
  7812. }
  7813.  
  7814. #ifndef NOXFER
  7815. int
  7816. shoatt() {
  7817.     printf("Attributes: %s\n", showoff(atcapr));
  7818.     if (!atcapr) return(0);
  7819.     printf(" Blocksize: %s\n", showoff(atblki));
  7820.     printf(" Date: %s\n", showoff(atdati));
  7821.     printf(" Disposition: %s\n", showoff(atdisi));
  7822.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7823.     printf(" Length: %s\n", showoff(atleni));
  7824.     printf(" Type (text/binary): %s\n", showoff(attypi));
  7825.     printf(" System ID: %s\n", showoff(atsidi));
  7826.     printf(" System Info: %s\n", showoff(atsysi));
  7827. #ifdef CK_PERMS
  7828.     printf(" Permissions In:  %s\n", showoff(atlpri));
  7829.     printf(" Permissions Out: %s\n", showoff(atlpro));
  7830. #endif /* CK_PERMS */
  7831. #ifdef STRATUS
  7832.     printf(" Format: %s\n", showoff(atfrmi));
  7833.     printf(" Creator: %s\n", showoff(atcrei));
  7834.     printf(" Account: %s\n", showoff(atacti));
  7835. #endif /* STRATUS */
  7836.     return(0);
  7837. }
  7838. #endif /* NOXFER */
  7839.  
  7840. #ifndef NOSPL
  7841. int                                     /* SHOW MACROS */
  7842. shomac(s1, s2) char *s1, *s2; {
  7843.     int x, n, pp;
  7844.     pp = 0;                             /* Parenthesis counter */
  7845.  
  7846.     debug(F110,"shomac s1",s1,0);
  7847.     debug(F110,"shomac s2",s2,0);
  7848.  
  7849. #ifdef IKSD
  7850.     if ( inserver &&
  7851. #ifdef IKSDCONF
  7852.         iksdcf
  7853. #else /* IKSDCONF */
  7854.         1
  7855. #endif /* IKSDCONF */
  7856.         ) {
  7857.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  7858.             !ckstrcmp("on_logout",s1,-1,0))
  7859.           return(0);
  7860.     }
  7861. #endif /* IKSD */
  7862.  
  7863.     if (!s1)
  7864.       return(0);
  7865.     else
  7866.       printf("%s = ",s1);               /* Print blank line and macro name */
  7867.     n = (int)strlen(s1) + 4;            /* Width of current line */
  7868.     if (!s2) s2 = "(not defined)";
  7869.  
  7870.     while ((x = *s2++)) {               /* Loop thru definition */
  7871.         if (x == '(') pp++;             /* Treat commas within parens */
  7872.         if (x == ')') pp--;             /* as ordinary text */
  7873.         if (pp < 0) pp = 0;             /* Outside parens, */
  7874.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  7875.             putchar(',');
  7876.             putchar('-');
  7877.             x = '\n';
  7878.         }
  7879.         if (inserver && (x == '\n'))    /* Send CR before LF */
  7880.           putchar(CR);
  7881.         putchar((CHAR)x);               /* Output the character */
  7882.         if (x == '\n') {                /* If it was a newline */
  7883. #ifdef UNIX
  7884. #ifdef NOSETBUF
  7885.             fflush(stdout);
  7886. #endif /* NOSETBUF */
  7887. #endif /* UNIX */
  7888.             putchar(' ');               /* Indent the next line 1 space */
  7889.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  7890.             n = 2;                      /* restart the character counter */
  7891.             slc++;                      /* and increment the line counter. */
  7892.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  7893.             putchar('-');               /* output a dash */
  7894.             if (inserver)
  7895.               putchar(CR);              /* and a carriage return */
  7896.             putchar(NL);                /* and a newline */
  7897. #ifdef UNIX
  7898. #ifdef NOSETBUF
  7899.             fflush(stdout);
  7900. #endif /* NOSETBUF */
  7901. #endif /* UNIX */
  7902.             n = 1;                      /* and restart the char counter */
  7903.             slc++;                      /* and increment the line counter */
  7904.         }
  7905.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  7906.             if (!askmore()) return(-1); /* ask if they want more. */
  7907.             n = 1;                      /* They do, start a new line */
  7908.             slc = 0;                    /* and restart line counter */
  7909.         }
  7910.     }
  7911.     if (inserver)
  7912.       putchar(CR);
  7913.     putchar(NL);                        /* End of definition */
  7914.     if (++slc > (cmd_rows - 3)) {
  7915.         if (!askmore()) return(-1);
  7916.         slc = 0;
  7917.     }
  7918.     return(0);
  7919. }
  7920. #endif /* NOSPL */
  7921. #endif /* NOSHOW */
  7922.  
  7923. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  7924.  
  7925. #ifndef NOSPL
  7926. /* Evaluate an arithmetic expression. */
  7927. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  7928.  
  7929. static int xerror = 0;
  7930. int divbyzero = 0;
  7931. static char *cp;
  7932. static long tokval;
  7933. static char curtok;
  7934. static long expval;
  7935.  
  7936. #define LONGBITS (8*sizeof (long))
  7937. #define NUMBER 'N'
  7938. #define N_EOT 'E'
  7939.  
  7940. /*
  7941.  Replacement for strchr() and index(), neither of which seem to be universal.
  7942. */
  7943.  
  7944. static char *
  7945. #ifdef CK_ANSIC
  7946. windex(char * s, char c)
  7947. #else
  7948. windex(s,c) char *s, c;
  7949. #endif /* CK_ANSIC */
  7950. /* windex */ {
  7951.     while (*s != NUL && *s != c) s++;
  7952.     if (*s == c) return(s); else return(NULL);
  7953. }
  7954.  
  7955.  
  7956. /*
  7957.  g e t t o k
  7958.  
  7959.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  7960. */
  7961. static char
  7962. gettok() {
  7963.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  7964.  
  7965.     while (isspace(*cp))                /* Skip past leading spaces */
  7966.       cp++;
  7967.  
  7968.     debug(F110,"GETTOK",cp,0);
  7969.  
  7970.     switch (*cp) {
  7971.       case '$':                         /* ??? */
  7972.       case '+':                         /* Add */
  7973.       case '-':                         /* Subtract or Negate */
  7974.       case '@':                         /* Greatest Common Divisor */
  7975.       case '*':                         /* Multiply */
  7976.       case '/':                         /* Divide */
  7977.       case '%':                         /* Modulus */
  7978.       case '<':                         /* Left shift */
  7979.       case '>':                         /* Right shift */
  7980.       case '&':                         /* And */
  7981.       case '|':                         /* Or */
  7982.       case '#':                         /* Exclusive Or */
  7983.       case '~':                         /* Not */
  7984.       case '^':                         /* Exponent */
  7985.       case '!':                         /* Factorial */
  7986.       case '(':                         /* Parens for grouping */
  7987.       case ')': return(*cp++);          /* operator, just return it */
  7988.       case '\n':
  7989.       case '\0': return(N_EOT);         /* End of line, return that */
  7990.     }
  7991. #ifdef COMMENT
  7992. /* This is the original code, which allows only integer numbers. */
  7993.  
  7994.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  7995.         int radix = 10;                 /* Default radix */
  7996.         for (tp = tbuf; isxdigit(*cp); cp++)
  7997.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  7998.         *tp = '\0';                     /* End number */
  7999.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  8000.           case 'h':
  8001.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  8002.           case 'o':
  8003.           case 'q': radix = 8; cp++; break;
  8004.           case 't': radix = 2; cp++; break;
  8005.         }
  8006.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  8007.             int dig;
  8008.             dig = *tp - '0';            /* Convert number */
  8009.             if (dig > 10) dig -= 'a'-'0'-10;
  8010.             if (dig >= radix) {
  8011.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8012.                   printf("?Invalid digit '%c' in number\n",*tp);
  8013.                 xerror = 1;
  8014.                 return(NUMBER);
  8015.             }
  8016.             tokval = radix*tokval + dig;
  8017.         }
  8018.         return(NUMBER);
  8019.     }
  8020.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  8021.       printf("Invalid character '%c' in input\n",*cp);
  8022.     xerror = 1;
  8023.     cp++;
  8024.     return(gettok());
  8025. #else
  8026. /* This code allows non-numbers to be treated as macro names */
  8027.     {
  8028.         int i, x;
  8029.         char * s, * cp1;
  8030.         cp1 = cp;
  8031.         tp = tbuf;
  8032.         for (i = 0; i < 80; i++) {
  8033.             /* Look ahead to next break character */
  8034.             /* pretty much anything that is not in the switch() above. */
  8035.             if (isalpha(*cp) || isdigit(*cp) ||
  8036.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  8037.                 *cp == '[' || *cp == ']' ||
  8038.                 *cp == '{' || *cp == '}'
  8039.                 )
  8040.               tbuf[i] = *cp++;
  8041.             else
  8042.               break;
  8043.         }
  8044.         if (i >= 80) {
  8045.             printf("Too long - \"%s\"\n", cp1);
  8046.             xerror = 1;
  8047.             cp++;
  8048.             return(gettok());
  8049.         }
  8050.         if (xerror) return(NUMBER);
  8051.  
  8052.         tbuf[i] = NUL;
  8053.         s = tbuf;
  8054.         if (!isdigit(tbuf[0])) {
  8055.             char * s2 = NULL;
  8056.             x = mxlook(mactab,tbuf,nmac);
  8057.             debug(F111,"gettok mxlook",tbuf,x);
  8058.             if (x < 0) {
  8059.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8060.                   printf("Bad number - \"%s\"\n",tbuf);
  8061.                 xerror = 1;
  8062.                 cp++;
  8063.                 return(gettok());
  8064.             }
  8065.             s2 = mactab[x].mval;
  8066.             if (!s2) s2 = "";
  8067.             if (*s2) s = s2;
  8068.         }
  8069. #ifdef CKFLOAT
  8070.         x = isfloat(s,0);
  8071. #else
  8072.         x = chknum(s);
  8073. #endif /* CKFLOAT */
  8074.         if (x > 0) {
  8075.             tokval = atoi(s);
  8076.         } else {
  8077.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8078.               printf("Bad number - \"%s\"\n",tbuf);
  8079.             xerror = 1;
  8080.             cp++;
  8081.             return(gettok());
  8082.         }
  8083.         return(NUMBER);
  8084.     }
  8085. #endif /* COMMENT */
  8086. }
  8087.  
  8088. static long
  8089. #ifdef CK_ANSIC
  8090. expon(long x, long y)
  8091. #else
  8092. expon(x,y) long x,y;
  8093. #endif /* CK_ANSIC */
  8094. /* expon */ {
  8095.     long result = 1;
  8096.     int sign = 1;
  8097.     if (y < 0) return(0);
  8098.     if (x < 0) {
  8099.         x = -x;
  8100.         if (y & 1) sign = -1;
  8101.     }
  8102.     while (y != 0) {
  8103.         if (y & 1) result *= x;
  8104.         y >>= 1;
  8105.         if (y != 0) x *= x;
  8106.   }
  8107.   return(result * sign);
  8108. }
  8109.  
  8110. /*
  8111.  * factor ::= simple | simple ^ factor
  8112.  *
  8113.  */
  8114. static VOID
  8115. factor() {
  8116.     long oldval;
  8117.     simple();
  8118.     if (curtok == '^') {
  8119.         oldval = expval;
  8120.         curtok = gettok();
  8121.         factor();
  8122.         expval = expon(oldval,expval);
  8123.     }
  8124. }
  8125.  
  8126. /*
  8127.  * termp ::= NULL | {*,/,%,&} factor termp
  8128.  *
  8129.  */
  8130. static VOID
  8131. termp() {
  8132.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  8133.         long oldval;
  8134.         char op;
  8135.         op = curtok;
  8136.         curtok = gettok();              /* skip past operator */
  8137.         oldval = expval;
  8138.         factor();
  8139.         switch(op) {
  8140.           case '*': expval = oldval * expval; break;
  8141.           case '/':
  8142.           case '%':
  8143.             if (expval == 0) {
  8144.                 if (!x_ifnum)
  8145.                   printf("?Divide by zero\n");
  8146.                 xerror = 1;
  8147.                 divbyzero = 1;
  8148.                 expval = -1;
  8149.             } else
  8150.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  8151.             break;
  8152.           case '&':
  8153.             expval = oldval & expval; break;
  8154.         }
  8155.     }
  8156. }
  8157.  
  8158. static long
  8159. #ifdef CK_ANSIC
  8160. fact(long x)
  8161. #else
  8162. fact(x) long x;
  8163. #endif /* CK_ANSIC */
  8164. /* fact */ {                            /* factorial */
  8165.     long result = 1;
  8166.     while (x > 1)
  8167.       result *= x--;
  8168.     return(result);
  8169. }
  8170.  
  8171. /*
  8172.  * term ::= factor termp
  8173.  *
  8174.  */
  8175. static VOID
  8176. term() {
  8177.     factor();
  8178.     termp();
  8179. }
  8180.  
  8181. static long
  8182. #ifdef CK_ANSIC
  8183. gcd(long x, long y)
  8184. #else
  8185. gcd(x,y) long x,y;
  8186. #endif /* CK_ANSIC */
  8187. /* gcd */ {                             /* Greatest Common Divisor */
  8188.     int nshift = 0;
  8189.     if (x < 0) x = -x;
  8190.     if (y < 0) y = -y;                  /* validate arguments */
  8191.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8192.  
  8193.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8194.         nshift++;
  8195.         x >>= 1;
  8196.         y >>= 1;
  8197.     }
  8198.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8199.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8200.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8201.         if (x < y) {                    /* force x to be larger */
  8202.             long t;
  8203.             t = x;
  8204.             x = y;
  8205.             y = t;
  8206.         }
  8207.         x -= y;
  8208.     }
  8209.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8210.     else return((long) 1 << nshift);    /* else gcd is 1 */
  8211. }
  8212.  
  8213. /*
  8214.  * exprp ::= NULL | {+,-,|,...} term exprp
  8215.  *
  8216.  */
  8217. static VOID
  8218. exprp() {
  8219.     while (windex("+-|<>#@",curtok) != NULL) {
  8220.         long oldval;
  8221.         char op;
  8222.         op = curtok;
  8223.         curtok = gettok();              /* skip past operator */
  8224.         oldval = expval;
  8225.         term();
  8226.         switch(op) {
  8227.           case '+' : expval = oldval + expval; break;
  8228.           case '-' : expval = oldval - expval; break;
  8229.           case '|' : expval = oldval | expval; break;
  8230.           case '#' : expval = oldval ^ expval; break;
  8231.           case '@' : expval = gcd(oldval,expval); break;
  8232.           case '<' : expval = oldval << expval; break;
  8233.           case '>' : expval = oldval >> expval; break;
  8234.         }
  8235.     }
  8236. }
  8237.  
  8238. /*
  8239.  * expr ::= term exprp
  8240.  *
  8241.  */
  8242. static VOID
  8243. expr() {
  8244.     term();
  8245.     exprp();
  8246. }
  8247.  
  8248. static long
  8249. xparse() {
  8250.     curtok = gettok();
  8251.     expr();
  8252. #ifdef COMMENT
  8253.     if (curtok == '$') {
  8254.         curtok = gettok();
  8255.         if (curtok != NUMBER) {
  8256.             if (cmdlvl == 0 && !x_ifnum)
  8257.               printf("?Illegal radix\n");
  8258.             xerror = 1;
  8259.             return(0);
  8260.         }
  8261.         curtok = gettok();
  8262.     }
  8263. #endif /* COMMENT */
  8264.     if (curtok != N_EOT) {
  8265.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8266.           printf("?Extra characters after expression\n");
  8267.         xerror = 1;
  8268.     }
  8269.     return(expval);
  8270. }
  8271.  
  8272. char *                                  /* Silent front end for evala() */
  8273. evalx(s) char *s; {
  8274.     char * p;
  8275.     int t;
  8276.     t = x_ifnum;
  8277.     x_ifnum = 1;
  8278.     p = evala(s);
  8279.     x_ifnum = t;
  8280.     return(p);
  8281. }
  8282.  
  8283. char *
  8284. evala(s) char *s; {
  8285.     long v;                             /* Numeric value */
  8286.     if (!s) return("");
  8287.     xerror = 0;                         /* Start out with no error */
  8288.     divbyzero = 0;
  8289.     cp = s;                             /* Make the argument global */
  8290.     v = xparse();                       /* Parse the string */
  8291.     return(xerror ? "" : ckltoa(v));    /* Return empty string on error */
  8292. }
  8293.  
  8294. /*
  8295.  * simplest ::= NUMBER | ( expr )
  8296.  *
  8297.  */
  8298. static VOID
  8299. simplest() {
  8300.     char * p;
  8301.     p = cp;
  8302.     if (curtok == NUMBER)
  8303.       expval = tokval;
  8304.     else if (curtok == '(') {
  8305.         curtok = gettok();              /* skip over paren */
  8306.         expr();
  8307.         if (curtok != ')') {
  8308.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8309.               printf("?Missing right parenthesis\n");
  8310.             xerror = 1;
  8311.         }
  8312.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8313.  
  8314.     } else {
  8315.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8316.           printf("?Operator unexpected\n");
  8317.         xerror = 1;
  8318.     }
  8319.     curtok = gettok();
  8320. }
  8321.  
  8322. /*
  8323.  * simpler ::= simplest | simplest !
  8324.  *
  8325.  */
  8326. static VOID
  8327. simpler() {
  8328.     simplest();
  8329.     if (curtok == '!') {
  8330.         curtok = gettok();
  8331.         expval = fact(expval);
  8332.     }
  8333. }
  8334.  
  8335. /*
  8336.  * simple ::= {-,~,!} simpler | simpler
  8337.  *
  8338.  */
  8339.  
  8340. static VOID
  8341. simple() {
  8342.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8343.         int op = curtok;
  8344.         curtok = gettok();              /* skip over - sign */
  8345.         simpler();                      /* parse the factor again */
  8346.         if (op != '+')
  8347.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8348.     } else simpler();
  8349. }
  8350.  
  8351. /*  D C L A R R A Y  --  Declare an array  */
  8352. /*
  8353.   Call with:
  8354.    char a = single character designator for the array, e.g. "a".
  8355.    int  n = size of array.
  8356.   Returns:
  8357.    0 or greater on success, having created the requested array with
  8358.      with n+1 elements, 0..n.  If an array of the same name existed
  8359.      previously, it is destroyed.  The new array has all its elements
  8360.      initialized to NULL pointers.
  8361.   -1 on failure (because 'a' out of range or malloc failure).
  8362. */
  8363. int
  8364. #ifdef CK_ANSIC
  8365. dclarray(char a, int n)
  8366. #else
  8367. dclarray(a,n) char a; int n;
  8368. #endif /* CK_ANSIC */
  8369. /* dclarray */ {
  8370.     char c, **p; int i, n2, rc;
  8371.  
  8372.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8373.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8374.       return(-1);
  8375.     c = a;
  8376.     a -= ARRAYBASE;                     /* Convert name to number */
  8377.     rc = a;
  8378.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8379.         if (a_link[a] > -1) {           /* Is it a link? */
  8380.             if (n == 0) {               /* If we're just deleting it */
  8381.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8382.                 a_dim[a] = 0;
  8383.                 a_link[a] = -1;
  8384.                 return(0);
  8385.             }                           /* Not deleting */
  8386.             a = a_link[a];              /* Switch to linked-to array */
  8387.         }
  8388.         n2 = a_dim[a];                  /* Real array */
  8389.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8390.             if (p[i]) {
  8391.                 free(p[i]);
  8392.                 p[i] = NULL;
  8393.             }
  8394.         }
  8395.         free((char *)a_ptr[a]);         /* Then the element list */
  8396.         if (n == 0) {                   /* If undeclaring this array... */
  8397.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8398.                 if (i != a && a_link[i] == a) {     /* Find them */
  8399.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8400.                     a_dim[i] = 0;
  8401.                     a_link[i] = -1;
  8402.                 }
  8403.             }
  8404.         }
  8405.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8406.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8407.         a_link[a] = -1;                 /* Unset link word */
  8408.         if (n == 0)
  8409.           return(0);                    /* If dimension 0, just deallocate. */
  8410.     }
  8411.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8412.     if (p == NULL) return(-1);          /* Check */
  8413.     a_ptr[a] = p;                       /* Save pointer to member list */
  8414.     a_dim[a] = n;                       /* Save dimension */
  8415.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8416.       p[i] = NULL;
  8417.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8418.         if (i != a && a_link[i] == a) { /* Find and update them */
  8419.             a_ptr[i] = p;
  8420.             a_dim[i] = n;
  8421.         }
  8422.     }
  8423.     return(rc);
  8424. }
  8425.  
  8426. /*  X A R R A Y  -- Convert array name to array index  */
  8427.  
  8428. int
  8429. xarray(s) char * s; {
  8430.     char buf[8];
  8431.     int x;
  8432.     char c;
  8433.  
  8434.     if (!s) s = "";
  8435.     debug(F110,"xarray",s,0);
  8436.     if (!*s)
  8437.       return(-1);
  8438.     x = strlen(s);
  8439.  
  8440.     buf[0] = NUL;
  8441.     buf[1] = NUL;
  8442.     buf[2] = s[0];
  8443.     buf[3] = (x > 0) ? s[1] : NUL;
  8444.     buf[4] = (x > 1) ? s[2] : NUL;
  8445.     buf[5] = (x > 2) ? s[3] : NUL;
  8446.     buf[6] = NUL;
  8447.     s = buf+2;
  8448.     if (*s == '&') {
  8449.         buf[1] = CMDQ;
  8450.         s--;
  8451.     } else if (*s != CMDQ) {
  8452.         buf[0] = CMDQ;
  8453.         buf[1] = '&';
  8454.         s = buf;
  8455.     }
  8456.     c = *(s+2);
  8457.     if (isupper(c))
  8458.       c = tolower(c);
  8459.     if (c == '@')
  8460.       c = 96;
  8461.     x = (int)c - ARRAYBASE;
  8462.     if (*(s+3) == '[')
  8463.       *(s+3) = NUL;
  8464.     return((x < 0 || x > 'z' - ARRAYBASE || *(s+3)) ? -1 : x);
  8465. }
  8466.  
  8467. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8468.  
  8469. /*
  8470.   Call with s = array reference, plus two pointers to ints.
  8471.   Returns -1 on error, or array index, with the two ints set as follows:
  8472.    \&a[]     -1, -1
  8473.    \&a[3]     3, -1
  8474.    \&a[3:17]  3, 17
  8475.   The array need not be declared -- this routine is just for parsing.
  8476. */
  8477. int
  8478. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8479.     int i, x, y, range[2];
  8480.     char buf[256], * p, * q;
  8481.     char * tmp = NULL;
  8482.  
  8483.     *lo = -1;                           /* Default bounds */
  8484.     *hi = -1;
  8485.  
  8486.     if (!s) s = "";                     /* Defense de null args */
  8487.     if (!*s)
  8488.       return(-1);
  8489.  
  8490.     x = xarray(s);                      /* Check basic structure */
  8491.     debug(F111,"arraybounds xarray",s,x);
  8492.  
  8493.     if (x < 0)                          /* Not OK, fail. */
  8494.       return(-1);
  8495.     range[0] = -1;                      /* It's OK -- get contents */
  8496.     range[1] = -1;                      /* of subscript brackets */
  8497.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8498.     s = tmp;
  8499.     p = s;
  8500.     for (p = s, q = NULL; *p; p++) {    /* First find the brackets */
  8501.         if (*p == '[') {
  8502.             q = p+1;
  8503.         } else if (*p == ']')
  8504.           break;
  8505.     }
  8506.     if (q && *p == ']') {               /* If we have brackets... */
  8507.         int quitnow = 0;
  8508.         for (i = 0; i < 2 && !quitnow; i++) { /* Loop thru their contents */
  8509.             for (p = q; *p; p++) {
  8510.                 if ((i == 0 && *p == ':') || *p == ']') {
  8511.                     if (*p == ']')
  8512.                       quitnow = 1;
  8513.                     *p = NUL;
  8514.                     if (*q) {           /* We have something */
  8515.                         y = 255;        /* Expand variables, etc. */
  8516.                         s = buf;
  8517.                         zzstring(q,&s,&y);
  8518.                         s = evalx(buf); /* Evaluate it arithmetically */
  8519.                         if (s) if (*s)
  8520.                           ckstrncpy(buf,s,256);
  8521.                         if (!chknum(buf)) { /* Did we get a number? */
  8522.                             makestr(&tmp,NULL); /* No, fail. */
  8523.                             return(-1);
  8524.                         }
  8525.                         q = (i == 0) ? p+1 : NULL; /* Point to next if any */
  8526.                         range[i] = atoi(buf); /* Set this one */
  8527.                     }
  8528.                     break;
  8529.                 }
  8530.             }
  8531.         }
  8532.     }
  8533.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8534.     *lo = range[0];                     /* Return what we got */
  8535.     *hi = range[1];
  8536.     debug(F101,"arraybounds lo","",*lo);
  8537.     debug(F101,"arraybounds hi","",*hi);
  8538.     return(x);
  8539. }
  8540.  
  8541. /*  A R R A Y N A M  --  Parse an array name  */
  8542.  
  8543. /*
  8544.   Call with pointer to string that starts with the array reference.
  8545.   String may begin with either \& or just &.
  8546.   On success,
  8547.     Returns letter ID (always lowercase) in argument c,
  8548.       which can also be accent grave (` = 96; '@' is converted to grave);
  8549.     Dimension or subscript in argument n;
  8550.     IMPORTANT: These arguments must be provided by the caller as addresses
  8551.     of ints (not chars), for example:
  8552.       char *s; int x, y;
  8553.       arraynam(s,&x,&y);
  8554.   On failure, returns a negative number, with args n and c set to zero.
  8555. */
  8556. int
  8557. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8558.     int i, y, pp, len;
  8559.     char x;
  8560.     char *s, *p, *sx, *vnp;
  8561.     /* On stack to allow for recursive calls... */
  8562.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8563.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8564.     char sxbuf[16];                     /* Evaluated subscript */
  8565.  
  8566.     *c = *n = 0;                        /* Initialize return values */
  8567.     len = strlen(ss);
  8568.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8569.         if (ss[i] == '[') {
  8570.             pp++;
  8571.         } else if (ss[i] == ']') {
  8572.             if (--pp == 0)
  8573.               break;
  8574.         }
  8575.     }
  8576.     if (i > ARRAYREFLEN) {
  8577.         printf("?Array reference too long - %s\n",ss);
  8578.         return(-9);
  8579.     }
  8580.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8581.     vnp = vnbuf;
  8582.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8583.     if (*vnp != '&') {
  8584.         printf("?Not an array - %s\n",vnbuf);
  8585.         return(-9);
  8586.     }
  8587.     x = *(vnp + 1);                     /* Fold case of array name */
  8588.  
  8589.     /* We don't use isupper & tolower here on purpose because these */
  8590.     /* would produce undesired effects with accented letters. */
  8591.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8592.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8593.         if (msgflg) {
  8594.             printf("?Invalid format for array name - %s\n",vnbuf);
  8595.             return(-9);
  8596.         } else
  8597.           return(-2);
  8598.     }
  8599.     *c = x;                             /* Return the array name */
  8600.     s = vnp+3;                          /* Get dimension */
  8601.     p = ssbuf;
  8602.     pp = 1;                             /* Bracket counter */
  8603.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8604.         if (*s == '[') pp++;
  8605.         if (*s == ']' && --pp == 0) break;
  8606.         *p++ = *s++;
  8607.     }
  8608.     if (*s != ']') {
  8609.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8610.         return(-9);
  8611.     }
  8612.     p--;                                /* Trim whitespace from end */
  8613.     while (*p == SP || *p == HT)
  8614.       p--;
  8615.     p++;
  8616.     *p = NUL;                           /* Terminate subscript with null */
  8617.     p = ssbuf;                          /* Point to beginning of subscript */
  8618.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8619.       p++;
  8620.     sx = sxbuf;                         /* Where to put expanded subscript */
  8621.     y = 16;
  8622.     zzstring(p,&sx,&y);                 /* Convert variables, etc. */
  8623.     sx = sxbuf;
  8624.     while (*sx == SP) sx++;
  8625.     debug(F110,"arraynam sx","",sx);
  8626.     if (!*sx) {                         /* Empty brackets... */
  8627.         *n = -17;                       /* (Secret code :-) */
  8628.         return(-2);
  8629.     }
  8630.     p = evala(sx);                      /* Run it thru \fneval()... */
  8631.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8632.  
  8633.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8634.         if (msgflg) {
  8635.             printf("?Array dimension or subscript missing or not numeric\n");
  8636.             return(-9);
  8637.         } else
  8638.           return(-2);
  8639.     }
  8640.     if ((y = atoi(sxbuf)) < 0) {
  8641.         if (cmflgs == 0) printf("\n");
  8642.         if (msgflg) {
  8643.             printf("?Array dimension or subscript not positive or zero\n");
  8644.             return(-9);
  8645.         } else
  8646.           return(-2);
  8647.     }
  8648.     *n = y;                             /* Return the subscript or dimension */
  8649.     return(0);
  8650. }
  8651.  
  8652. int
  8653. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8654.     int x;                              /* and if subscript is in range */
  8655.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8656.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8657. #ifdef COMMENT
  8658.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8659.       return(0);
  8660. #endif /* COMMENT */
  8661.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8662.       return(-2);
  8663.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8664.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8665.     return(a_dim[x]);                   /* All ok, return dimension */
  8666. }
  8667.  
  8668. #ifdef COMMENT                          /* This isn't used. */
  8669. char *
  8670. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8671.     int x; char **p;                    /* (possibly NULL) */
  8672.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8673.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8674.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8675.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8676.       return(NULL);
  8677.     if (i > a_dim[x])                   /* Subscript out of range. */
  8678.       return(NULL);
  8679.     return(p[i]);                       /* All ok, return pointer to value. */
  8680. }
  8681. #endif /* COMMENT */
  8682.  
  8683. /*
  8684.   pusharray() is called when an array name is included in a LOCAL statement.
  8685.   It moves the pointers from the global definition to the stack, and removes
  8686.   the global definition.  Later, if the same array is declared in the local
  8687.   context, it occupies the global definition in the normal way.  But when
  8688.   popclvl() is called, it replaces the global definition with the one saved
  8689.   here.  The "secret code" is used to indicate to popclv() that it should
  8690.   remove the global array when popping through this level -- otherwise if a
  8691.   local array were declared that had no counterpart at any higher level, it
  8692.   would never be deleted.  This allows Algol-like inheritance to work both
  8693.   on the way down and on the way back up.
  8694. */
  8695. int
  8696. pusharray(x,z) int x, z; {
  8697.     int y;
  8698.     debug(F000,"pusharray x","",x);
  8699.     debug(F101,"pusharray z","",z);
  8700.     y = chkarray(x,z);
  8701.     debug(F101,"pusharray y","",y);
  8702.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8703.     if (x < 0 || x > 27)
  8704.       return(-1);
  8705.     if (y < 0) {
  8706.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8707.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8708.     } else {
  8709.         aa_ptr[cmdlvl][x] = a_ptr[x];
  8710.         aa_dim[cmdlvl][x] = y;
  8711.     }
  8712.     a_ptr[x] = (char **) NULL;
  8713.     a_dim[x] = 0;
  8714.     return(0);
  8715. }
  8716.  
  8717. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  8718. /*
  8719.  Call with:
  8720.    s  = pointer to candidate variable name or array reference.
  8721.    *c = address of integer in which to return variable ID.
  8722.    *i = address of integer in which to return array subscript.
  8723.  Returns:
  8724.    -2:  syntax error in variable name or array reference.
  8725.     1:  successful parse of a simple variable, with ID in c.
  8726.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  8727. */
  8728. int
  8729. parsevar(s,c,i) char *s; int *c, *i; {
  8730.     char *p;
  8731.     int x,y,z;
  8732.  
  8733.     p = s;
  8734.     if (*s == CMDQ) s++;                /* Point after backslash */
  8735.  
  8736.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  8737.         printf("?Not a variable name - %s\n",p);
  8738.         return(-9);
  8739.     }
  8740.     if ((int)strlen(s) < 2) {
  8741.         printf("?Incomplete variable name - %s\n",p);
  8742.         return(-9);
  8743.     }
  8744.     if (*s == '%' && *(s+2) != '\0') {
  8745.         printf("?Only one character after '%%' in variable name, please\n");
  8746.         return(-9);
  8747.     }
  8748.     if (*s == '&' && *(s+2) != '[') {
  8749.         printf("?Array subscript expected - %s\n",p);
  8750.         return(-9);
  8751.     }
  8752.     if (*s == '%') {                    /* Simple variable. */
  8753.         y = *(s+1);                     /* Get variable ID letter/char */
  8754.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  8755.         *c = y;                         /* Set the return values. */
  8756.         *i = -1;                        /* No array subscript. */
  8757.         return(1);                      /* Return 1 = simple variable */
  8758.     }
  8759.     if (*s == '&') {                    /* Array reference. */
  8760.         y = arraynam(s,&x,&z);          /* Go parse it. */
  8761.         debug(F101,"parsevar arraynam","",y);
  8762.         if ((y) < 0) {
  8763.             if (y == -2)
  8764.               return(pusharray(x,z));
  8765.             if (y != -9)
  8766.               printf("?Invalid array reference - %s\n",p);
  8767.             return(-9);
  8768.         }
  8769.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  8770.             printf("?Array not declared or subscript out of range\n");
  8771.             return(-9);
  8772.         }
  8773.         *c = x;                         /* Return array letter */
  8774.         *i = z;                         /* and subscript. */
  8775.         return(2);
  8776.     }
  8777.     return(-2);                         /* None of the above. */
  8778. }
  8779.  
  8780.  
  8781. #define VALN 32
  8782.  
  8783. /* Get the numeric value of a variable */
  8784. /*
  8785.   Call with pointer to variable name, pointer to int for return value.
  8786.   Returns:
  8787.     0 on success with second arg containing the value.
  8788.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  8789. */
  8790. int
  8791. varval(s,v) char *s; int *v; {
  8792.     char valbuf[VALN+1];                /* s is pointer to variable name */
  8793.     char name[256];
  8794.     char *p;
  8795.     int y;
  8796.  
  8797.     if (*s != CMDQ) {                   /* Handle macro names too */
  8798.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  8799.         s = name;
  8800.     }
  8801.     p = valbuf;                         /* Expand variable into valbuf. */
  8802.     y = VALN;
  8803.     if (zzstring(s,&p,&y) < 0) return(-1);
  8804.     p = valbuf;                         /* Make sure value is numeric  */
  8805.     if (!*p) {                          /* Be nice -- let an undefined */
  8806.         valbuf[0] = '0';                /* variable be treated as 0.   */
  8807.         valbuf[1] = NUL;
  8808.     }
  8809.     if (chknum(p)) {                    /* Convert numeric string to int */
  8810.         *v = atoi(p);                   /* OK */
  8811.     } else {                            /* Not OK */
  8812.         p = evala(p);                   /* Maybe it's an expression */
  8813.         if (!chknum(p))                 /* Did it evaluate? */
  8814.           return(-1);                   /* No, failure. */
  8815.         else                            /* Yes, */
  8816.           *v = atoi(p);                 /* success */
  8817.     }
  8818.     return(0);
  8819. }
  8820.  
  8821. /* Increment or decrement a variable */
  8822. /* Returns -1 on failure, 0 on success */
  8823.  
  8824. int
  8825. incvar(s,x,z) char *s; int x; int z; {  /* Increment a numeric variable */
  8826.     int n;                              /* s is pointer to variable name */
  8827.                                         /* x is amount to increment by */
  8828.                                         /* z != 0 means add */
  8829.                                         /* z = 0 means subtract */
  8830.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  8831.       return(-1);
  8832.     if (z)                              /* Increment it by the given amount */
  8833.       n += x;
  8834.     else                                /* or decrement as requested. */
  8835.       n -= x;
  8836.     addmac(s,ckitoa(n));                /* Replace old variable */
  8837.     return(0);
  8838. }
  8839.  
  8840. /* D O D O  --  Do a macro */
  8841.  
  8842. /*
  8843.   Call with x = macro table index, s = pointer to arguments.
  8844.   Returns 0 on failure, 1 on success.
  8845. */
  8846.  
  8847. int
  8848. dodo(x,s,flags) int x; char *s; int flags; {
  8849.     int y;
  8850.     extern int tra_asg, tra_cmd; int tra_tmp;
  8851. #ifndef NOLOCAL
  8852. #ifdef OS2
  8853.     extern int term_io;
  8854.     int term_io_sav = term_io;
  8855. #endif /* OS2 */
  8856. #endif /* NOLOCAL */
  8857.  
  8858.     if (x < 0)                          /* It can happen! */
  8859.       return(-1);
  8860.  
  8861.     tra_tmp = tra_asg;
  8862.  
  8863.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  8864.         debug(F101,"dodo maclvl too deep","",maclvl);
  8865.         --maclvl;
  8866.         printf("Macros nested too deeply\n");
  8867.         return(0);
  8868.     }
  8869.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  8870.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  8871.  
  8872. #ifdef COMMENT
  8873.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  8874. #endif /* COMMENT */
  8875.  
  8876.     cmdlvl++;                           /* Entering a new command level */
  8877.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  8878.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  8879.         cmdlvl--;
  8880.         printf("?TAKE files and DO commands nested too deeply\n");
  8881.         return(0);
  8882.     }
  8883. #ifdef DEBUG
  8884.     if (deblog) {
  8885.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  8886.         debug(F010,"CMD ->",s,0);
  8887.     }
  8888. #endif /* DEBUG */
  8889.  
  8890. #ifdef VMS
  8891.     conres();                           /* So Ctrl-C, etc, will work. */
  8892. #endif /* VMS */
  8893. #ifndef NOLOCAL
  8894. #ifdef OS2
  8895.     term_io = 0;                        /* Disable terminal emulator I/O */
  8896. #endif /* OS2 */
  8897. #endif /* NOLOCAL */
  8898.     ifcmd[cmdlvl] = 0;
  8899.     iftest[cmdlvl] = 0;
  8900.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  8901.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  8902.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  8903.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  8904.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  8905.     xquiet[cmdlvl] = quiet;
  8906.     xcmdsrc = CMD_MD;
  8907.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  8908.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  8909.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  8910.  
  8911.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  8912.  
  8913.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  8914.         free(mrval[maclvl]);
  8915.         mrval[maclvl] = NULL;
  8916.     }
  8917.  
  8918.     /* Clear old %0..%9 arguments */
  8919.  
  8920.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  8921.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  8922.     varnam[0] = '%';
  8923.     varnam[2] = '\0';
  8924.     tra_asg = 0;
  8925.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  8926.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  8927.             varnam[1] = (char) (y + '0'); /* we have to... */
  8928.             delmac(varnam,0);
  8929.         }
  8930.     }
  8931.     tra_asg = tra_tmp;
  8932.  
  8933. /* Assign the new args one word per arg, allowing braces to group words */
  8934.  
  8935.     xwords(s,MAXARGLIST,NULL,0);
  8936.  
  8937. #ifndef NOLOCAL
  8938. #ifdef OS2
  8939.     term_io = term_io_sav;
  8940. #endif /* OS2 */
  8941. #endif /* NOLOCAL */
  8942.     if (tra_cmd)
  8943.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  8944.     return(1);
  8945. }
  8946.  
  8947. /* Insert "literal" quote around each comma-separated command to prevent */
  8948. /* its premature expansion.  Only do this if object command is surrounded */
  8949. /* by braces. */
  8950.  
  8951. static char* flit = "\\flit(";
  8952.  
  8953. int
  8954. litcmd(src,dest,n) char **src, **dest; int n; {
  8955.     int bc = 0, pp = 0;
  8956.     char c, *s, *lp, *ss;
  8957.  
  8958.     s = *src;
  8959.     lp = *dest;
  8960.  
  8961.     debug(F010,"litcmd",s,0);
  8962.  
  8963.     while (*s == SP) s++;               /* Strip extra leading spaces */
  8964.  
  8965.     if (*s == '{') {                    /* Starts with brace */
  8966.         pp = 0;                         /* Paren counter */
  8967.         bc = 1;                         /* Count leading brace */
  8968.         *lp++ = *s++;                   /* Copy it */
  8969.         if (--n < 1) return(-1);        /* Check space */
  8970.         while (*s == SP) s++;           /* Strip interior leading spaces */
  8971.         ss = flit;                      /* Point to "\flit(" */
  8972.         while ((*lp++ = *ss++))         /* Copy it */
  8973.           if (--n < 1)                  /* and check space */
  8974.             return(-1);
  8975.         lp--;                           /* Back up over null */
  8976.  
  8977.         while (*s) {                    /* Go thru rest of text */
  8978.             c = *s;
  8979.             if (c == '{') bc++;         /* Count brackets */
  8980.             if (c == '(') pp++;         /* and parens */
  8981.             if (c == ')') {             /* Right parenthesis. */
  8982.                 pp--;                   /* Count it. */
  8983.                 if (pp < 0) {           /* An unbalanced right paren... */
  8984. #ifdef COMMENT
  8985. /*
  8986.   The problem here is that "\{" appears to be a quoted brace and therefore
  8987.   isn't counted; then the "}" matches an earlier opening brace, causing
  8988.   (e.g.) truncation of macros by getncm().
  8989. */
  8990.                     if (n < 5)          /* Out of space in dest buffer? */
  8991.                       return(-1);       /* If so, give up. */
  8992.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  8993.                     *lp++ = '}';        /* premature termination of */
  8994.                     *lp++ = '4';        /* \flit(...) */
  8995.                     *lp++ = '1';
  8996.                     *lp++ = '}';
  8997.                     n -= 5;
  8998. #else
  8999. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  9000.                     if (n < 4)          /* Out of space in dest buffer? */
  9001.                       return(-1);       /* If so, give up. */
  9002.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9003.                     *lp++ = '0';        /* premature termination of */
  9004.                     *lp++ = '4';        /* \flit(...) */
  9005.                     *lp++ = '1';
  9006.                     n -= 4;
  9007. #endif /* COMMENT */
  9008.                     pp++;               /* Uncount it. */
  9009.                     s++;
  9010.                     continue;
  9011.                 }
  9012.             }
  9013.             if (c == '}') {             /* Closing brace. */
  9014.                 if (--bc == 0) {        /* Final one? */
  9015.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  9016.                     if (--n < 1) return(-1);
  9017.                     *lp++ = c;
  9018.                     if (--n < 1) return(-1);
  9019.                     s++;
  9020.                     break;
  9021.                 }
  9022.             }
  9023.             *lp++ = c;                  /* General case */
  9024.             if (--n < 1) return(-1);
  9025.             s++;
  9026.         }
  9027.         *lp = NUL;
  9028.     } else {                            /* No brackets around, */
  9029.         while ((*lp++ = *s++))          /* just copy. */
  9030.           if (--n < 1)
  9031.             return(-1);
  9032.         lp--;
  9033.     }
  9034.     *src = s;                           /* Return updated source */
  9035.     *dest = lp;                         /* and destination pointers */
  9036.     if (bc)                             /* Fail if braces unbalanced */
  9037.       return(-1);
  9038.     else                                /* Otherwise succeed. */
  9039.       return(0);
  9040. }
  9041. #endif /* NOSPL */
  9042.  
  9043. /* Functions moved here from ckuusr.c to even out the module sizes... */
  9044.  
  9045. /*
  9046.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  9047.   Pointers to each word go into the array list[].
  9048.   max is the maximum number of words (pointers).
  9049.   If list is NULL, then they are added to the macro table.
  9050.   flag = 0 means the last field is to be one word, like all the other fields,
  9051.          so anything after it is discarded.
  9052.   flag = 1 means the last field extends to the end of the string, even if
  9053.          there are lots of words left, so the last field contains the
  9054.          remainder of the string.
  9055. */
  9056. VOID
  9057. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  9058.     char *p;
  9059.     int b, i, k, q, y, z;
  9060. #ifndef NOSPL
  9061.     int macro;
  9062.     macro = (list == NULL);
  9063.     debug(F010,"xwords",s,0);
  9064. #endif /* NOSPL */
  9065.  
  9066. #ifdef XWORDSDEBUG
  9067.     printf("XWORDS string=%s\n",s);
  9068.     printf("XWORDS max=%d\n",max);
  9069. #endif /* XWORDSDEBUG */
  9070.     p = s;                              /* Pointer to beginning of string */
  9071.     q = 0;                              /* Flag for doublequote removal */
  9072.     b = 0;                              /* Flag for outer brace removal */
  9073.     k = 0;                              /* Flag for in-word */
  9074.     y = 0;                              /* Brace nesting level */
  9075.     z = 0;                              /* "Word" counter, 0 thru max */
  9076.  
  9077.     if (list)
  9078.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  9079.         list[i] = NULL;
  9080.  
  9081.     if (flag) max--;
  9082.  
  9083.     while (1) {                         /* Go thru word list */
  9084.         if (!s || (*s == '\0')) {       /* No more characters? */
  9085.             if (k != 0) {               /* Was I in a word? */
  9086.                 if (z == max) break;    /* Yes, only go up to max. */
  9087.                 z++;                    /* Count this word. */
  9088. #ifdef XWORDSDEBUG
  9089.                 printf("1 z++ = %d\n", z);
  9090. #endif /* XWORDSDEBUG */
  9091. #ifndef NOSPL
  9092.                 if (macro) {            /* Doing macro args */
  9093.                     if (z < 10) {
  9094.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  9095.                         addmac(varnam,p);
  9096.                     }
  9097.                     if (z <= max) {
  9098. #ifdef COMMENT
  9099.                         if (maclvl < 0)
  9100.                           addmac(varnam,p);
  9101.                         else
  9102. #endif /* COMMENT */
  9103.                           makestr(&(m_xarg[maclvl][z]),p);
  9104.                     }
  9105.                 } else {                /* Not doing macro args */
  9106. #endif /* NOSPL */
  9107.                     list[z] = p;        /* Assign pointer. */
  9108. #ifdef XWORDSDEBUG
  9109.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  9110. #endif /* XWORDSDEBUG */
  9111. #ifndef NOSPL
  9112.                 }
  9113. #endif /* NOSPL */
  9114.                 break;                  /* And get out. */
  9115.             } else break;               /* Was not in a word */
  9116.         }
  9117.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  9118.             s++;
  9119.             continue;
  9120.         } else if (q == 0 && *s == '{') { /* An opening brace */
  9121.             if (k == 0 && y == 0) {     /* If leading brace */
  9122.                 p = s+1;                /* point past it */
  9123.                 b = 1;                  /* and flag that we did this */
  9124.             }
  9125.             k = 1;                      /* Flag that we're in a word */
  9126.             y++;                        /* Count the brace. */
  9127.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  9128.             y--;                        /* Count it. */
  9129.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  9130.                 char c;
  9131.                 c = *(s+1);
  9132.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9133.                     *s = SP;            /* change it to a space */
  9134.                     b = 0;              /* and we're not in braces any more */
  9135.                 }
  9136.             }
  9137. #ifdef DOUBLEQUOTING
  9138.         /* Opening doublequote */
  9139.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9140.             y++;
  9141.             p = s+1;                    /* point past it */
  9142.             q = 1;                      /* and flag that we did this */
  9143.             k = 1;                      /* Flag that we're in a word */
  9144.         /* Closing double quote */
  9145.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9146.             char c;
  9147.             c = *(s+1);
  9148.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9149.                 y--;
  9150.                 *s = SP;                /* change it to a space */
  9151.                 q = 0;                  /* and we're not in quotes any more */
  9152.             }
  9153. #endif /* DOUBLEQUOTING */
  9154.  
  9155.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9156.             if (k == 0) {               /* If we weren't in a word before, */
  9157.                 p = s;                  /* Mark the beginning */
  9158.                 if (flag && z == max) { /* Want last word to be remainder? */
  9159.                     z++;
  9160. #ifdef XWORDSDEBUG
  9161.                     printf("1 z++ = %d\n", z);
  9162. #endif /* XWORDSDEBUG */
  9163.                     list[z] = p;        /* Yes, point to it */
  9164. #ifdef XWORDSDEBUG
  9165.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9166. #endif /* XWORDSDEBUG */
  9167.                     break;              /* and quit */
  9168.                 }
  9169.                 k = 1;                  /* Set in-word flag */
  9170.             }
  9171.         }
  9172.         /* If we're not inside a braced quantity, and we are in a word, and */
  9173.         /* we have hit whitespace, then we have a word. */
  9174.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9175.             if (!flag || z < max)       /* if we don't want to keep rest */
  9176.               *s = '\0';                /* terminate the arg with null */
  9177.             k = 0;                      /* say we're not in a word any more */
  9178.             y = 0;                      /* start braces off clean again */
  9179.             if (z == max) break;        /* Only go up to max. */
  9180.             z++;                        /* count this arg */
  9181. #ifdef XWORDSDEBUG
  9182.             printf("1 z++ = %d\n", z);
  9183. #endif /* XWORDSDEBUG */
  9184.  
  9185. #ifndef NOSPL
  9186.             if (macro) {
  9187.                 if (z < 10) {
  9188.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9189.                     addmac(varnam,p);   /* add it to the macro table */
  9190.                 }
  9191.                 if (z <= max) {
  9192. #ifdef COMMENT
  9193.                     if (maclvl < 0)
  9194.                       addmac(varnam,p);
  9195.                     else
  9196. #endif /* COMMENT */
  9197.                       makestr(&(m_xarg[maclvl][z]),p);
  9198.                 }
  9199.             } else {
  9200. #endif /* NOSPL */
  9201.                 list[z] = p;
  9202. #ifdef XWORDSDEBUG
  9203.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9204. #endif /* XWORDSDEBUG */
  9205. #ifndef NOSPL
  9206.             }
  9207. #endif /* NOSPL */
  9208.             p = s+1;
  9209.         }
  9210.         s++;                            /* Point past this character */
  9211.     }
  9212.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9213.         z++;
  9214. #ifndef NOSPL
  9215.         if (macro) {
  9216.             if (z < 10) {
  9217.                 varnam[1] = z + '0';    /* compute its name */
  9218.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9219.             }
  9220.             if (z <= max) {
  9221. #ifdef COMMENT
  9222.                 if (maclvl < 0)
  9223.                   addmac(varnam,p);
  9224.                 else
  9225. #endif /* COMMENT */
  9226.                   makestr(&(m_xarg[maclvl][z]),p);
  9227.             }
  9228.         } else {
  9229. #endif /* NOSPL */
  9230.             list[z] = p;
  9231. #ifdef XWORDSDEBUG
  9232.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9233. #endif /* XWORDSDEBUG */
  9234. #ifndef NOSPL
  9235.         }
  9236. #endif /* NOSPL */
  9237.     }
  9238. #ifndef NOSPL
  9239.     if (macro) {                        /* Macro */
  9240.         if (maclvl < 0) {
  9241.             a_dim[0] = z;               /* Array dimension is one less */
  9242.             topargc = z + 1;            /* than \v(argc) */
  9243.         debug(F111,"a_dim[0]","D",a_dim[0]);
  9244.         } else {
  9245.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9246.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9247.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9248.             a_dim[0] = z;               /* And give it this dimension */
  9249.         debug(F111,"a_dim[0]","E",a_dim[0]);
  9250.         }
  9251.     }
  9252. #endif /* NOSPL */
  9253.     return;
  9254. }
  9255.  
  9256. #ifndef NOSPL
  9257.  
  9258. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9259.  
  9260. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9261.  
  9262. int
  9263. doshift(n) int n; {                     /* n = shift count */
  9264.     int i, top, level;
  9265.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9266.     char * sx = tmpbuf;
  9267.     int nx = TMPBUFSIZ;
  9268.  
  9269.     debug(F101,"SHIFT count","",n);
  9270.     debug(F101,"SHIFT topargc","",topargc);
  9271.  
  9272.     if (n < 1)                          /* Stay in range */
  9273.       return(n == 0 ? 1 : 0);
  9274.  
  9275.     level = maclvl;
  9276.     top = (level < 0) ? topargc : macargc[level];
  9277.  
  9278.     if (n >= top)
  9279.       n = top - 1;
  9280.  
  9281. #ifdef DEBUG
  9282.     if (deblog) {
  9283.         debug(F101,"SHIFT count 2","",n);
  9284.         debug(F101,"SHIFT level","",level);
  9285.         if (level > -1)
  9286.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9287.     }
  9288. #endif /* DEBUG */
  9289.  
  9290.     buf[0] = '\\';                      /* Initialize name template */
  9291.     buf[1] = '%';
  9292.     buf[2] = NUL;
  9293.     buf[3] = NUL;
  9294.  
  9295.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9296.         if (level < 0) {
  9297.             makestr(&(toparg[i]),NULL);
  9298.         } else {
  9299.             makestr(&(m_xarg[level][i]),NULL);
  9300.         }
  9301.         if (i < 10) {                   /* Is this necessary? */
  9302.             buf[2] = (char)(i+'0');
  9303.             delmac(buf,0);
  9304.         }
  9305.     }
  9306.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9307.         if (level < 0) {
  9308. #ifdef COMMENT
  9309.             toparg[i] = toparg[i+n];    /* Full vector */
  9310. #else
  9311.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9312. #endif /* COMMENT */
  9313.             if (i < 10)                 /* Scalars... */
  9314.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9315.         } else {
  9316. #ifdef COMMENT
  9317.             m_xarg[level][i] = m_xarg[level][i+n];
  9318. #else
  9319.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9320. #endif /* COMMENT */
  9321.             if (i < 10) {
  9322.                 buf[2] = (char)(i+'0');
  9323.                 debug(F010,"SHIFT buf",buf,0);
  9324.                 addmac(buf,m_xarg[level][i+n]);
  9325.             }
  9326.         }
  9327.     }
  9328.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9329.         if (level < 0) {
  9330. #ifdef COMMENT
  9331.             toparg[i] = NULL;
  9332. #else
  9333.             makestr(&(toparg[i]),NULL);
  9334. #endif /* COMMENt */
  9335.             if (i < 10)
  9336.               makestr(&(g_var[i+'0']),NULL);
  9337.         } else {
  9338. #ifdef COMMENT
  9339.             m_xarg[level][i] = NULL;
  9340. #else
  9341.             makestr(&(m_xarg[level][i]),NULL);
  9342. #endif /* COMMENt */
  9343.             if (i < 10) {
  9344.                 buf[2] = (char)(i+'0');
  9345.                 delmac(buf,0);
  9346.             }
  9347.         }
  9348.     }
  9349.     if (level > -1) {                   /* Macro args */
  9350.         macargc[level] -= n;            /* Adjust count */
  9351.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9352.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9353.     debug(F111,"a_dim[0]","F",a_dim[0]);
  9354.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9355. #ifdef COMMENT
  9356.         makestr(&(m_line[level]),tmpbuf);
  9357. #endif /* COMMENT */
  9358.     } else {                            /* Ditto for top level */
  9359.         topargc -= n;
  9360.         a_dim[0] = topargc - 1;
  9361.     debug(F111,"a_dim[0]","G",a_dim[0]);
  9362.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9363. #ifdef COMMENT
  9364.         makestr(&topline,tmpbuf);
  9365. #endif /* COMMENT */
  9366.     }
  9367.     return(1);
  9368. }
  9369. #endif /* NOSPL */
  9370.  
  9371. int
  9372. docd(cx) int cx; {                      /* Do the CD command */
  9373.     int x;
  9374.     extern int server, srvcdmsg, cdactive;
  9375.     extern char * cdmsgfile[], * ckcdpath;
  9376.     char *s, *p;
  9377. #ifdef MAC
  9378.     char temp[34];
  9379. #endif /* MAC */
  9380. #ifdef IKSDCONF
  9381. extern int iksdcf;
  9382. #endif /* IKSDCONF */
  9383.  
  9384. #ifndef NOFRILLS
  9385.     if (cx == XXBACK) {
  9386.         if ((x = cmcfm()) < 0)
  9387.         cwdf = 1;
  9388.         if (prevdir) {
  9389.             s = zgtdir();
  9390.             if (!zchdir(prevdir)) {
  9391.                 cwdf = 0;
  9392.                 perror(s);
  9393.             } else {
  9394.                 makestr(&prevdir,s);
  9395.             }
  9396.         }
  9397.         return(cwdf);
  9398.     }
  9399. #endif /* NOFRILLS */
  9400.  
  9401.     if (cx == XXCDUP) {
  9402. #ifdef VMS
  9403.         s = "[-]";
  9404. #else
  9405. #ifdef datageneral
  9406.         s = "^";
  9407. #else
  9408.         s = "..";
  9409. #endif /* datageneral */
  9410. #endif /* VMS */
  9411.         ckstrncpy(line,s,LINBUFSIZ);
  9412.         goto gocd;
  9413.     }
  9414. #ifndef NOSPL
  9415.     if (cx == XXKCD) {            /* Symbolic (Kermit) CD */
  9416.     char * p;
  9417.     int n, k;
  9418.     x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9419.     if (x < 0)
  9420.       return(x);
  9421.     x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9422.     if (x < 0) {
  9423.         printf("?Lookup error\n");    /* shouldn't happen */
  9424.         return(-9);
  9425.     }
  9426.         if ((x = cmcfm()) < 0)
  9427.       return(x);
  9428.     if (k == VN_HOME) {        /* HOME: allow SET HOME to override */
  9429.         ckstrncpy(line,homepath(),LINBUFSIZ);
  9430.     } else {            /* Other symbolic name */
  9431.         /* Convert to variable syntax */
  9432.         ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9433.         p = line;            /* Expand the variable */
  9434.         n = LINBUFSIZ;
  9435.         zzstring(tmpbuf,&p,&n);
  9436.         if (!line[0]) {        /* Fail if variable not defined */
  9437.         printf("?%s - not defined\n",tmpbuf);
  9438.         return(success = 0);
  9439.         }
  9440.     }
  9441.     s = line;            /* All OK, go try to CD... */
  9442.     goto gocd;
  9443.     }
  9444. #endif /* NOSPL */
  9445.  
  9446.     cdactive = 1;
  9447. #ifdef GEMDOS
  9448.     if ((x = cmdir("Name of local directory, or carriage return",
  9449.                    homepath(),
  9450.                    &s,
  9451.                    NULL
  9452.                    )
  9453.          ) < 0 )
  9454.       return(x);
  9455. #else
  9456. #ifdef OS2
  9457.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9458.        or press the Enter key for the default",
  9459.                     homepath(),
  9460.                     &s,
  9461.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9462.                     xxstring
  9463.                     )
  9464.          ) < 0 )
  9465.       return(x);
  9466. #else
  9467. #ifdef MAC
  9468.     x = ckstrncpy(temp,homepath(),32);
  9469.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9470.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9471.  or press the Return key for the desktop on the boot disk",
  9472.                    temp,&s, xxstring)) < 0 )
  9473.       return(x);
  9474. #else
  9475.     if ((x = cmdirp("Carriage return for home directory,\n\
  9476. or name of directory on this computer",
  9477. #ifdef VMS
  9478.                     "SYS$LOGIN",        /* With no colon */
  9479. #else
  9480.                     homepath(),        /* In VMS this is "SYS$LOGIN:" */
  9481. #endif /* VMS */
  9482.                     &s,
  9483.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9484.                     xxstring
  9485.                     )) < 0)
  9486.       return(x);
  9487. #endif /* MAC */
  9488. #endif /* OS2 */
  9489. #endif /* GEMDOS */
  9490.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9491.     s = line;
  9492. #ifdef VMS
  9493.     if (ckmatch("*.DIR;1$",s,0,0))
  9494.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9495.         s = tmpbuf;
  9496. #endif /* VMS */
  9497.     debug(F110,"docd",s,0);
  9498. #ifndef MAC
  9499.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9500.       return(x);
  9501. #endif /* MAC */
  9502.  
  9503.   gocd:
  9504.  
  9505. #ifdef datageneral
  9506.     x = strlen(line);                   /* homdir ends in colon, */
  9507.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9508.       line[x-1] = NUL;
  9509. #endif /* datageneral */
  9510.  
  9511. #ifdef MAC
  9512.     cwdf = 1;
  9513.     if (!zchdir(s)) {
  9514.         cwdf = 0;
  9515.         if (*s != ':') {                /* If it failed, */
  9516.             char *p;                    /* supply leading colon */
  9517.             int len = (int)strlen(s) + 2;
  9518.             p = malloc(len);            /* and try again... */
  9519.             if (p) {
  9520.                 strcpy(p,":");          /* safe */
  9521.                 strcat(p,s);            /* safe */
  9522.                 if (zchdir(p))
  9523.                   cwdf = 1;
  9524.                 free(p);
  9525.                 p = NULL;
  9526.             }
  9527.         }
  9528.     }
  9529.     if (!cwdf)
  9530.       perror(s);
  9531. #else
  9532.     p = zgtdir();
  9533.     if (!zchdir(s)) {
  9534.         cwdf = 0;
  9535. #ifdef CKROOT
  9536.         if (ckrooterr)
  9537.           printf("?Off limits: \"%s\"\n",s);
  9538.         else
  9539. #endif /* CKROOT */
  9540.           perror(s);
  9541.     } else cwdf = 1;
  9542. #endif /* MAC */
  9543.  
  9544.     x = 0;
  9545.     if (cwdf) {
  9546.         makestr(&prevdir,p);
  9547.         debug(F111,"docd","srvcdmsg",srvcdmsg);
  9548.         if (srvcdmsg
  9549. #ifdef IKSDCONF
  9550.             && !(inserver && !iksdcf)
  9551. #endif /* IKSDCONF */
  9552.             ) {
  9553.             int i;
  9554.             for (i = 0; i < 8; i++) {
  9555.                 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9556.                 if (zchki(cdmsgfile[i]) > -1) {
  9557.                     x = 1;
  9558.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9559.                     break;
  9560.                 }
  9561.             }
  9562.         }
  9563.     }
  9564. /* xdocd: */
  9565.     if (!x && srvcdmsg && !server
  9566. #ifdef IKSDCONF
  9567.         && !(inserver && !iksdcf)
  9568. #endif /* IKSDCONF */
  9569.         && !quiet && !xcmdsrc)
  9570.       printf("%s\n", zgtdir());
  9571.  
  9572.     return(cwdf);
  9573. }
  9574.  
  9575. static int on_ctrlc = 0;
  9576.  
  9577. VOID
  9578. fixcmd() {                      /* Fix command parser after interruption */
  9579. #ifndef NOSPL
  9580. #ifndef NOONCTRLC
  9581.     if (nmac) {                         /* Any macros defined? */
  9582.         int k;                          /* Yes */
  9583.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9584.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9585.         if (k >= 0) {                   /* If found, */
  9586.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9587.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9588.                   parser(1);            /* execute it, */
  9589.             }
  9590.             delmac(s,1);                /* and undefine it. */
  9591.         }
  9592.     }
  9593.     on_ctrlc = 0;
  9594. #endif /* NOONCTRLC */
  9595. #endif /* NOSPL */
  9596.     dostop();                   /* Back to top level (also calls conint()). */
  9597.     bgchk();                    /* Check background status */
  9598.     if (*psave) {               /* If old prompt saved, */
  9599.         cmsetp(psave);          /* restore it. */
  9600.         *psave = NUL;
  9601.     }
  9602.     success = 0;                /* Tell parser last command failed */
  9603. }
  9604.  
  9605. #ifndef NOSHOW                          /* SHOW FEATURES */
  9606. /*
  9607.   Note, presently optlist[] index overflow is not checked.
  9608.   There is plenty of room (less than 360 entries for 1000 slots).
  9609.   When space starts to get tight, check for noptlist >= NOPTLIST
  9610.   every time noptlist is incremented.
  9611. */
  9612. #define NOPTLIST 1024
  9613. static int noptlist = 0;
  9614. static char * optlist[NOPTLIST+1];
  9615. static int hpos = 0;
  9616.  
  9617. int
  9618. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9619.     int y, i;                           /* Does word wrap. */
  9620.     if (!s) s = "";
  9621.     i = *lines;
  9622.     if (!*s) {                          /* Empty argument */
  9623.         if (hpos > 0) {                 /* means to end this line. */
  9624.             printf("\n");               /* Not needed if already at */
  9625.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9626.                 if (!askmore())
  9627.                   return(0);
  9628.                 else
  9629.                   i = 0;
  9630.             }
  9631.         }
  9632.         printf("\n");                   /* And then make a blank line */
  9633.         if (++i > (cmd_rows - 3)) {
  9634.             if (!askmore())
  9635.               return(0);
  9636.             else
  9637.               i = 0;
  9638.         }
  9639.         hpos = 0;
  9640.         *lines = i;
  9641.         return(1);
  9642.     }
  9643.     y = (int)strlen(s) + 1;
  9644.     hpos += y;
  9645.     debug(F101,"prtopt hpos","",hpos);
  9646.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9647.  
  9648.     if (
  9649. #ifdef OS2
  9650.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9651. #else /* OS2 */
  9652.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9653. #endif /* OS2 */
  9654.         ) {
  9655.         printf("\n");
  9656.         if (++i > (cmd_rows - 3)) {
  9657.             if (!askmore())
  9658.               return(0);
  9659.             else
  9660.               i = 0;
  9661.         }
  9662.         printf(" %s",s);
  9663.         hpos = y;
  9664.     } else
  9665.       printf(" %s",s);
  9666.     *lines = i;
  9667.     return(1);
  9668. }
  9669.  
  9670. static VOID
  9671. initoptlist() {
  9672.     int i;
  9673.     if (noptlist > 0)
  9674.       return;
  9675.     for (i = 0; i < NOPTLIST; i++)
  9676.       optlist[i] = NULL;
  9677.  
  9678. #ifdef MAC
  9679. #ifdef MPW
  9680.     makestr(&(optlist[noptlist++]),"MPW");
  9681. #endif /* MPW */
  9682. #endif /* MAC */
  9683.  
  9684. #ifdef MAC
  9685. #ifdef THINK_C
  9686.     makestr(&(optlist[noptlist++]),"THINK_C");
  9687. #endif /* THINK_C */
  9688. #endif /* MAC */
  9689.  
  9690. #ifdef __386__
  9691.     makestr(&(optlist[noptlist++]),"__386__");
  9692. #endif /* __386__ */
  9693.  
  9694. /* Memory models... */
  9695.  
  9696. #ifdef __FLAT__
  9697.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9698. #endif /* __FLAT__ */
  9699. #ifdef __SMALL__
  9700.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9701. #endif /* __SMALL__ */
  9702. #ifdef __MEDIUM__
  9703.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9704. #endif /* __MEDIUM__ */
  9705. #ifdef __COMPACT__
  9706.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9707. #endif /* __COMPACT__ */
  9708. #ifdef __LARGE__
  9709.     makestr(&(optlist[noptlist++]),"__LARGE__");
  9710. #endif /* __LARGE__ */
  9711.  
  9712. #ifdef DEBUG
  9713. #ifdef IFDEBUG
  9714.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  9715. #else
  9716.     makestr(&(optlist[noptlist++]),"DEBUG");
  9717. #endif /* IFDEBUG */
  9718. #endif /* DEBUG */
  9719. #ifdef TLOG
  9720.     makestr(&(optlist[noptlist++]),"TLOG");
  9721. #endif /* TLOG */
  9722. #ifdef BIGBUFOK
  9723.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9724. #endif /* BIGBUFOK */
  9725. #ifdef INPBUFSIZ
  9726.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9727.     makestr(&(optlist[noptlist++]),line);
  9728. #endif /* INPBUFSIZE */
  9729. #ifdef INBUFSIZE
  9730.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9731.     makestr(&(optlist[noptlist++]),line);
  9732. #endif /* INBUFSIZE */
  9733. #ifdef OBUFSIZE
  9734.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9735.     makestr(&(optlist[noptlist++]),line);
  9736. #endif /* OBUFSIZE */
  9737. #ifdef FD_SETSIZE
  9738.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9739.     makestr(&(optlist[noptlist++]),line);
  9740. #endif /* FD_SETSIZE */
  9741. #ifdef XFRCAN
  9742.     makestr(&(optlist[noptlist++]),"XFRCAN");
  9743. #endif /* XFRCAN */
  9744. #ifdef XPRINT
  9745.     makestr(&(optlist[noptlist++]),"XPRINT");
  9746. #endif /* XPRINT */
  9747. #ifdef PIPESEND
  9748.     makestr(&(optlist[noptlist++]),"PIPESEND");
  9749. #endif /* PIPESEND */
  9750. #ifdef CK_SPEED
  9751.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  9752. #endif /* CK_SPEED */
  9753. #ifdef CK_FAST
  9754.     makestr(&(optlist[noptlist++]),"CK_FAST");
  9755. #endif /* CK_FAST */
  9756. #ifdef CK_APC
  9757.     makestr(&(optlist[noptlist++]),"CK_APC");
  9758. #endif /* CK_APC */
  9759. #ifdef CK_AUTODL
  9760.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  9761. #endif /* CK_AUTODL */
  9762. #ifdef CK_MKDIR
  9763.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  9764. #endif /* CK_MKDIR */
  9765. #ifdef NOMKDIR
  9766.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  9767. #endif /* NOMKDIR */
  9768. #ifdef CK_LABELED
  9769.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  9770. #endif /* CK_LABELED */
  9771. #ifdef NODIAL
  9772.     makestr(&(optlist[noptlist++]),"NODIAL");
  9773. #endif /* NODIAL */
  9774. #ifdef MINIDIAL
  9775.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  9776. #endif /* MINIDIAL */
  9777. #ifdef WHATAMI
  9778.     makestr(&(optlist[noptlist++]),"WHATAMI");
  9779. #endif /* WHATAMI */
  9780. #ifdef DYNAMIC
  9781.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  9782. #endif /* IFDEBUG */
  9783. #ifndef NOSPL
  9784.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  9785.     makestr(&(optlist[noptlist++]),line);
  9786. #endif /* NOSPL */
  9787.  
  9788. #ifdef MAXPATHLEN
  9789.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  9790.     makestr(&(optlist[noptlist++]),line);
  9791. #endif /* MAXPATHLEN */
  9792.  
  9793. #ifdef DEVNAMLEN
  9794.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  9795.     makestr(&(optlist[noptlist++]),line);
  9796. #endif /* DEVNAMLEN */
  9797.  
  9798. #ifdef NO_PARAM_H
  9799.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  9800. #endif /* NO_PARAM_H */
  9801.  
  9802. #ifdef INCL_PARAM_H
  9803.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  9804. #endif /* INCL_PARAM_H */
  9805.  
  9806.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  9807.     makestr(&(optlist[noptlist++]),line);
  9808.  
  9809.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  9810.     makestr(&(optlist[noptlist++]),line);
  9811.  
  9812.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  9813.     makestr(&(optlist[noptlist++]),line);
  9814.  
  9815. #ifdef OPEN_MAX
  9816.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  9817.     makestr(&(optlist[noptlist++]),line);
  9818. #endif /* OPEN_MAX */
  9819.  
  9820. #ifdef _POSIX_OPEN_MAX
  9821.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  9822.     makestr(&(optlist[noptlist++]),line);
  9823. #endif /* _POSIX_OPEN_MAX */
  9824.  
  9825. #ifdef CKCHANNELIO
  9826.     {
  9827.         extern int z_maxchan;
  9828. #ifdef UNIX
  9829.         extern int ckmaxfiles;
  9830.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  9831.         makestr(&(optlist[noptlist++]),line);
  9832. #endif /* UNIX */
  9833.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  9834.         makestr(&(optlist[noptlist++]),line);
  9835.     }
  9836. #endif /* CKCHANNELIO */
  9837.  
  9838. #ifdef FOPEN_MAX
  9839.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  9840.     makestr(&(optlist[noptlist++]),line);
  9841. #endif /* FOPEN_MAX */
  9842.  
  9843. #ifdef MAXGETPATH
  9844.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  9845.     makestr(&(optlist[noptlist++]),line);
  9846. #endif /* MAXGETPATH */
  9847.  
  9848. #ifdef CMDBL
  9849.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  9850.     makestr(&(optlist[noptlist++]),line);
  9851. #endif /* CMDBL */
  9852.  
  9853. #ifdef VNAML
  9854.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  9855.     makestr(&(optlist[noptlist++]),line);
  9856. #endif /* VNAML */
  9857.  
  9858. #ifdef ARRAYREFLEN
  9859.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  9860.     makestr(&(optlist[noptlist++]),line);
  9861. #endif /* ARRAYREFLEN */
  9862.  
  9863. #ifdef UIDBUFLEN
  9864.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  9865.     makestr(&(optlist[noptlist++]),line);
  9866. #endif /* UIDBUFLEN */
  9867.  
  9868. #ifdef FORDEPTH
  9869.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  9870.     makestr(&(optlist[noptlist++]),line);
  9871. #endif /* FORDEPTH */
  9872.  
  9873. #ifdef MAXTAKE
  9874.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  9875.     makestr(&(optlist[noptlist++]),line);
  9876. #endif /* MAXTAKE */
  9877.  
  9878. #ifdef MACLEVEL
  9879.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  9880.     makestr(&(optlist[noptlist++]),line);
  9881. #endif /* MACLEVEL */
  9882.  
  9883. #ifdef MAC_MAX
  9884.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  9885.     makestr(&(optlist[noptlist++]),line);
  9886. #endif /* MAC_MAX */
  9887.  
  9888. #ifdef MINPUTMAX
  9889.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  9890.     makestr(&(optlist[noptlist++]),line);
  9891. #endif /* MINPUTMAX */
  9892.  
  9893. #ifdef MAXWLD
  9894.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  9895.     makestr(&(optlist[noptlist++]),line);
  9896. #else
  9897. #ifdef OS2
  9898.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  9899. #endif /* OS2 */
  9900. #endif /* MAXWLD */
  9901.  
  9902. #ifdef MSENDMAX
  9903.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  9904.     makestr(&(optlist[noptlist++]),line);
  9905. #endif /* MSENDMAX */
  9906.  
  9907. #ifdef MAXDDIR
  9908.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  9909.     makestr(&(optlist[noptlist++]),line);
  9910. #endif /* MAXDDIR */
  9911.  
  9912. #ifdef MAXDNUMS
  9913.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  9914.     makestr(&(optlist[noptlist++]),line);
  9915. #endif /* MAXDNUMS */
  9916.  
  9917. #ifdef UNIX
  9918.     makestr(&(optlist[noptlist++]),"UNIX");
  9919. #endif /* UNIX */
  9920. #ifdef VMS
  9921.     makestr(&(optlist[noptlist++]),"VMS");
  9922. #ifdef __VMS_VER
  9923.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  9924.     makestr(&(optlist[noptlist++]),line);
  9925. #endif /* __VMS_VER */
  9926. #ifdef VMSV70
  9927.     makestr(&(optlist[noptlist++]),"VMSV70");
  9928. #endif /* VMSV70 */
  9929. #endif /* VMS */
  9930. #ifdef OLD_VMS
  9931.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  9932. #endif /* OLD_VMS */
  9933. #ifdef vms
  9934.     makestr(&(optlist[noptlist++]),"vms");
  9935. #endif /* vms */
  9936. #ifdef VMSV60
  9937.     makestr(&(optlist[noptlist++]),"VMSV60");
  9938. #endif /* VMSV60 */
  9939. #ifdef VMSV70
  9940.     makestr(&(optlist[noptlist++]),"VMSV70");
  9941. #endif /* VMSV70 */
  9942. #ifdef VMSSHARE
  9943.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  9944. #endif /* VMSSHARE */
  9945. #ifdef NOVMSSHARE
  9946.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  9947. #endif /* NOVMSSHARE */
  9948. #ifdef datageneral
  9949.     makestr(&(optlist[noptlist++]),"datageneral");
  9950. #endif /* datageneral */
  9951. #ifdef apollo
  9952.     makestr(&(optlist[noptlist++]),"apollo");
  9953. #endif /* apollo */
  9954. #ifdef aegis
  9955.     makestr(&(optlist[noptlist++]),"aegis");
  9956. #endif /* aegis */
  9957. #ifdef A986
  9958.     makestr(&(optlist[noptlist++]),"A986");
  9959. #endif /* A986 */
  9960. #ifdef AMIGA
  9961.     makestr(&(optlist[noptlist++]),"AMIGA");
  9962. #endif /* AMIGA */
  9963. #ifdef CONVEX9
  9964.     makestr(&(optlist[noptlist++]),"CONVEX9");
  9965. #endif /* CONVEX9 */
  9966. #ifdef CONVEX10
  9967.     makestr(&(optlist[noptlist++]),"CONVEX10");
  9968. #endif /* CONVEX9 */
  9969. #ifdef MAC
  9970.     makestr(&(optlist[noptlist++]),"MAC");
  9971. #endif /* MAC */
  9972. #ifdef AUX
  9973.     makestr(&(optlist[noptlist++]),"AUX");
  9974. #endif /* AUX */
  9975. #ifdef OS2
  9976.     makestr(&(optlist[noptlist++]),"OS2");
  9977. #ifdef NT
  9978.     makestr(&(optlist[noptlist++]),"NT");
  9979. #endif /* NT */
  9980. #endif /* OS2 */
  9981. #ifdef OSK
  9982.     makestr(&(optlist[noptlist++]),"OS9");
  9983. #endif /* OSK */
  9984. #ifdef MSDOS
  9985.     makestr(&(optlist[noptlist++]),"MSDOS");
  9986. #endif /* MSDOS */
  9987. #ifdef DIRENT
  9988.     makestr(&(optlist[noptlist++]),"DIRENT");
  9989. #endif /* DIRENT */
  9990. #ifdef SDIRENT
  9991.     makestr(&(optlist[noptlist++]),"SDIRENT");
  9992. #endif /* SDIRENT */
  9993. #ifdef NDIR
  9994.     makestr(&(optlist[noptlist++]),"NDIR");
  9995. #endif /* NDIR */
  9996. #ifdef XNDIR
  9997.     makestr(&(optlist[noptlist++]),"XNDIR");
  9998. #endif /* XNDIR */
  9999. #ifdef SAVEDUID
  10000.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  10001. #endif /* SAVEDUID */
  10002. #ifdef RENAME
  10003.     makestr(&(optlist[noptlist++]),"RENAME");
  10004. #endif /* RENAME */
  10005. #ifdef CK_TMPDIR
  10006.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  10007. #endif /* CK_TMPDIR */
  10008. #ifdef NOCCTRAP
  10009.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  10010. #endif /* NOCCTRAP */
  10011. #ifdef NOCOTFMC
  10012.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  10013. #endif /* NOCOTFMC */
  10014. #ifdef NOFRILLS
  10015.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  10016. #endif /* NOFRILLS */
  10017. #ifdef PARSENSE
  10018.     makestr(&(optlist[noptlist++]),"PARSENSE");
  10019. #endif /* PARSENSE */
  10020. #ifdef TIMEH
  10021.     makestr(&(optlist[noptlist++]),"TIMEH");
  10022. #endif /* TIMEH */
  10023. #ifdef NOTIMEH
  10024.     makestr(&(optlist[noptlist++]),"TIMEH");
  10025. #endif /* NOTIMEH */
  10026.  
  10027. #ifdef SYSTIMEH
  10028.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10029. #endif /* SYSTIMEH */
  10030. #ifdef NOSYSTIMEH
  10031.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10032. #endif /* NOSYSTIMEH */
  10033.  
  10034. #ifdef SYSTIMEBH
  10035.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10036. #endif /* SYSTIMEBH */
  10037. #ifdef NOSYSTIMEBH
  10038.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10039. #endif /* NOSYSTIMEBH */
  10040. #ifdef UTIMEH
  10041.     makestr(&(optlist[noptlist++]),"UTIMEH");
  10042. #endif /* UTIMEH */
  10043. #ifdef SYSUTIMEH
  10044.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  10045. #endif /* SYSUTIMEH */
  10046.  
  10047. #ifdef CK_NEED_SIG
  10048.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  10049. #endif /* CK_NEED_SIG */
  10050. #ifdef CK_TTYFD
  10051.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  10052. #endif /* CK_TTYFD */
  10053. #ifdef NETCONN
  10054.     makestr(&(optlist[noptlist++]),"NETCONN");
  10055. #endif /* NETCONN */
  10056. #ifdef TCPSOCKET
  10057.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  10058. #ifdef NOTCPOPTS
  10059.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  10060. #endif /* NOTCPOPTS */
  10061. #ifdef CK_DNS_SRV
  10062.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  10063. #endif /* CK_DNS_SRV */
  10064. #ifdef NO_DNS_SRV
  10065.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  10066. #endif /* NO_DNS_SRV */
  10067. #ifdef CKGHNLHOST
  10068.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  10069. #endif /* CKGHNLHOST */
  10070. #ifdef NOLISTEN
  10071.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  10072. #endif /* NOLISTEN */
  10073. #ifdef SOL_SOCKET
  10074.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  10075. #endif /* SOL_SOCKET */
  10076. #ifdef SO_OOBINLINE
  10077.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  10078. #endif /* SO_OOBINLNE */
  10079. #ifdef SO_DONTROUTE
  10080.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  10081. #endif /* SO_DONTROUTE */
  10082. #ifdef SO_KEEPALIVE
  10083.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  10084. #endif /* SO_KEEPALIVE */
  10085. #ifdef SO_LINGER
  10086.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  10087. #endif /* SO_LINGER */
  10088. #ifdef TCP_NODELAY
  10089.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  10090. #endif /* TCP_NODELAY */
  10091. #ifdef SO_SNDBUF
  10092.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  10093. #endif /* SO_SNDBUF */
  10094. #ifdef SO_RCVBUF
  10095.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  10096. #endif /* SO_RCVBUF */
  10097. #ifdef h_addr
  10098.     makestr(&(optlist[noptlist++]),"h_addr");
  10099. #endif /* h_addr */
  10100. #ifdef HADDRLIST
  10101.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  10102. #endif /* HADDRLIST */
  10103. #ifdef CK_SOCKS
  10104.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  10105. #ifdef CK_SOCKS5
  10106.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  10107. #endif /* CK_SOCKS5 */
  10108. #ifdef CK_SOCKS_NS
  10109.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  10110. #endif /* CK_SOCKS_NS */
  10111. #endif /* CK_SOCKS */
  10112. #ifdef RLOGCODE
  10113.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  10114. #endif /* RLOGCODE */
  10115. #ifdef NETCMD
  10116.     makestr(&(optlist[noptlist++]),"NETCMD");
  10117. #endif /* NETCMD */
  10118. #ifdef NONETCMD
  10119.     makestr(&(optlist[noptlist++]),"NONETCMD");
  10120. #endif /* NONETCMD */
  10121. #ifdef NETPTY
  10122.     makestr(&(optlist[noptlist++]),"NETPTY");
  10123. #endif /* NETPTY */
  10124. #ifdef CK_ENVIRONMENT
  10125.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  10126. #endif /* CK_ENVIRONMENT */
  10127. #endif /* TCPSOCKET */
  10128. #ifdef TNCODE
  10129.     makestr(&(optlist[noptlist++]),"TNCODE");
  10130. #endif /* TNCODE */
  10131. #ifdef CK_FORWARD_X
  10132.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  10133. #endif /* CK_FORWARD_X */
  10134. #ifdef TN_COMPORT
  10135.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  10136. #endif /* TN_COMPORT */
  10137. #ifdef MULTINET
  10138.     makestr(&(optlist[noptlist++]),"MULTINET");
  10139. #endif /* MULTINET */
  10140. #ifdef DEC_TCPIP
  10141.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  10142. #endif /* DEC_TCPIP */
  10143. #ifdef TCPWARE
  10144.     makestr(&(optlist[noptlist++]),"TCPWARE");
  10145. #endif /* TCPWARE */
  10146. #ifdef UCX50
  10147.     makestr(&(optlist[noptlist++]),"UCX50");
  10148. #endif /* UCX50 */
  10149. #ifdef CMU_TCPIP
  10150.     makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  10151. #endif /* CMU_TCPIP */
  10152. #ifdef TTLEBUF
  10153.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  10154. #endif /* TTLEBUF */
  10155. #ifdef NETLEBUF
  10156.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  10157. #endif /* NETLEBUF */
  10158. #ifdef IKS_OPTION
  10159.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10160. #endif /* IKS_OPTION */
  10161. #ifdef IKSDB
  10162.     makestr(&(optlist[noptlist++]),"IKSDB");
  10163. #endif /* IKSDB */
  10164. #ifdef IKSDCONF
  10165.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  10166. #endif /* IKSDCONF */
  10167. #ifdef CK_LOGIN
  10168.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10169. #endif /* CK_LOGIN */
  10170. #ifdef CK_PAM
  10171.     makestr(&(optlist[noptlist++]),"CK_PAM");
  10172. #endif /* CK_PAM */
  10173. #ifdef CK_SHADOW
  10174.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10175. #endif /* CK_SHADOW */
  10176. #ifdef CONGSPD
  10177.     makestr(&(optlist[noptlist++]),"CONGSPD");
  10178. #endif /* CONGSPD */
  10179. #ifdef SUNX25
  10180.     makestr(&(optlist[noptlist++]),"SUNX25");
  10181. #endif /* SUNX25 */
  10182. #ifdef IBMX25
  10183.     makestr(&(optlist[noptlist++]),"IBMX25");
  10184. #endif /* IBMX25 */
  10185. #ifdef HPX25
  10186.     makestr(&(optlist[noptlist++]),"HPX25");
  10187. #endif /* HPX25 */
  10188. #ifdef DECNET
  10189.     makestr(&(optlist[noptlist++]),"DECNET");
  10190. #endif /* DECNET */
  10191. #ifdef SUPERLAT
  10192.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  10193. #endif /* SUPERLAT */
  10194. #ifdef NPIPE
  10195.     makestr(&(optlist[noptlist++]),"NPIPE");
  10196. #endif /* NPIPE */
  10197. #ifdef CK_NETBIOS
  10198.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10199. #endif /* CK_NETBIOS */
  10200. #ifdef ATT7300
  10201.     makestr(&(optlist[noptlist++]),"ATT7300");
  10202. #endif /* ATT7300 */
  10203. #ifdef ATT6300
  10204.     makestr(&(optlist[noptlist++]),"ATT6300");
  10205. #endif /* ATT6300 */
  10206. #ifdef HDBUUCP
  10207.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10208. #endif /* HDBUUCP */
  10209. #ifdef USETTYLOCK
  10210.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10211. #endif /* USETTYLOCK */
  10212. #ifdef NOUUCP
  10213.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10214. #endif /* NOUUCP */
  10215. #ifdef LONGFN
  10216.     makestr(&(optlist[noptlist++]),"LONGFN");
  10217. #endif /* LONGFN */
  10218. #ifdef RDCHK
  10219.     makestr(&(optlist[noptlist++]),"RDCHK");
  10220. #endif /* RDCHK */
  10221. #ifdef SELECT
  10222.     makestr(&(optlist[noptlist++]),"SELECT");
  10223. #endif /* SELECT */
  10224. #ifdef USLEEP
  10225.     makestr(&(optlist[noptlist++]),"USLEEP");
  10226. #endif /* USLEEP */
  10227. #ifdef NAP
  10228.     makestr(&(optlist[noptlist++]),"NAP");
  10229. #endif /* NAP */
  10230. #ifdef NAPHACK
  10231.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10232. #endif /* NAPHACK */
  10233. #ifdef CK_POLL
  10234.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10235. #endif /* CK_POLL */
  10236. #ifdef NOIEXTEN
  10237.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10238. #endif /* NOIEXTEN */
  10239. #ifdef EXCELAN
  10240.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10241. #endif /* EXCELAN */
  10242. #ifdef INTERLAN
  10243.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10244. #endif /* INTERLAN */
  10245. #ifdef NOFILEH
  10246.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10247. #endif /* NOFILEH */
  10248. #ifdef NOSYSIOCTLH
  10249.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10250. #endif /* NOSYSIOCTLH */
  10251. #ifdef DCLPOPEN
  10252.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10253. #endif /* DCLPOPEN */
  10254. #ifdef NOSETBUF
  10255.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10256. #endif /* NOSETBUF */
  10257. #ifdef NOXFER
  10258.     makestr(&(optlist[noptlist++]),"NOXFER");
  10259. #endif /* NOXFER */
  10260. #ifdef NOCURSES
  10261.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10262. #endif /* NOCURSES */
  10263. #ifdef NOSERVER
  10264.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10265. #endif /* NOSERVER */
  10266. #ifdef NOPATTERNS
  10267.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10268. #else
  10269. #ifdef PATTERNS
  10270.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10271. #endif /* PATTERNS */
  10272. #endif /* NOPATTERNS */
  10273. #ifdef NOCKEXEC
  10274.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10275. #else
  10276. #ifdef CKEXEC
  10277.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10278. #endif /* CKEXEC */
  10279. #endif /* NOCKEXEC */
  10280. #ifdef NOAUTODL
  10281.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10282. #endif /* NOAUTODL */
  10283. #ifdef NOMSEND
  10284.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10285. #endif /* NOMSEND */
  10286. #ifdef NOFDZERO
  10287.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10288. #endif /* NOFDZERO */
  10289. #ifdef NOPOPEN
  10290.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10291. #endif /* NOPOPEN */
  10292. #ifdef NOPARTIAL
  10293.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10294. #endif /* NOPARTIAL */
  10295. #ifdef NOKVERBS
  10296.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10297. #endif /* NOKVERBS */
  10298. #ifdef NOSETREU
  10299.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10300. #endif /* NOSETREU */
  10301. #ifdef LCKDIR
  10302.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10303. #endif /* LCKDIR */
  10304. #ifdef ACUCNTRL
  10305.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10306. #endif /* ACUCNTRL */
  10307. #ifdef BSD4
  10308.     makestr(&(optlist[noptlist++]),"BSD4");
  10309. #endif /* BSD4 */
  10310. #ifdef BSD44
  10311.     makestr(&(optlist[noptlist++]),"BSD44");
  10312. #endif /* BSD44 */
  10313. #ifdef BSD41
  10314.     makestr(&(optlist[noptlist++]),"BSD41");
  10315. #endif /* BSD41 */
  10316. #ifdef BSD43
  10317.     makestr(&(optlist[noptlist++]),"BSD43");
  10318. #endif /* BSD43 */
  10319. #ifdef BSD29
  10320.     makestr(&(optlist[noptlist++]),"BSD29");
  10321. #endif /* BSD29 */
  10322. #ifdef BSDI
  10323.     makestr(&(optlist[noptlist++]),"BSDI");
  10324. #endif /* BSDI */
  10325. #ifdef __bsdi__
  10326.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10327. #endif /* __bsdi__ */
  10328. #ifdef __NetBSD__
  10329.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10330. #endif /* __NetBSD__ */
  10331. #ifdef __OpenBSD__
  10332.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10333. #endif /* __OpenBSD__ */
  10334. #ifdef __FreeBSD__
  10335.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10336. #endif /* __FreeBSD__ */
  10337. #ifdef __linux__
  10338.     makestr(&(optlist[noptlist++]),"__linux__");
  10339. #endif /* __linux__ */
  10340. #ifdef LINUX_HI_SPD
  10341.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10342. #endif /* LINUX_HI_SPD */
  10343. #ifdef LYNXOS
  10344.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10345. #endif /* LYNXOS */
  10346. #ifdef V7
  10347.     makestr(&(optlist[noptlist++]),"V7");
  10348. #endif /* V7 */
  10349. #ifdef AIX370
  10350.     makestr(&(optlist[noptlist++]),"AIX370");
  10351. #endif /* AIX370 */
  10352. #ifdef RTAIX
  10353.     makestr(&(optlist[noptlist++]),"RTAIX");
  10354. #endif /* RTAIX */
  10355. #ifdef HPUX
  10356.     makestr(&(optlist[noptlist++]),"HPUX");
  10357. #endif /* HPUX */
  10358. #ifdef HPUXPRE65
  10359.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10360. #endif /* HPUXPRE65 */
  10361. #ifdef DGUX
  10362.     makestr(&(optlist[noptlist++]),"DGUX");
  10363. #endif /* DGUX */
  10364. #ifdef DGUX430
  10365.     makestr(&(optlist[noptlist++]),"DGUX430");
  10366. #endif /* DGUX430 */
  10367. #ifdef DGUX540
  10368.     makestr(&(optlist[noptlist++]),"DGUX540");
  10369. #endif /* DGUX540 */
  10370. #ifdef DGUX543
  10371.     makestr(&(optlist[noptlist++]),"DGUX543");
  10372. #endif /* DGUX543 */
  10373. #ifdef DGUX54410
  10374.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10375. #endif /* DGUX54410 */
  10376. #ifdef DGUX54411
  10377.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10378. #endif /* DGUX54411 */
  10379. #ifdef sony_news
  10380.     makestr(&(optlist[noptlist++]),"sony_news");
  10381. #endif /* sony_news */
  10382. #ifdef CIE
  10383.     makestr(&(optlist[noptlist++]),"CIE");
  10384. #endif /* CIE */
  10385. #ifdef XENIX
  10386.     makestr(&(optlist[noptlist++]),"XENIX");
  10387. #endif /* XENIX */
  10388. #ifdef SCO_XENIX
  10389.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10390. #endif /* SCO_XENIX */
  10391. #ifdef ISIII
  10392.     makestr(&(optlist[noptlist++]),"ISIII");
  10393. #endif /* ISIII */
  10394. #ifdef I386IX
  10395.     makestr(&(optlist[noptlist++]),"I386IX");
  10396. #endif /* I386IX */
  10397. #ifdef RTU
  10398.     makestr(&(optlist[noptlist++]),"RTU");
  10399. #endif /* RTU */
  10400. #ifdef PROVX1
  10401.     makestr(&(optlist[noptlist++]),"PROVX1");
  10402. #endif /* PROVX1 */
  10403. #ifdef PYRAMID
  10404.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10405. #endif /* PYRAMID */
  10406. #ifdef TOWER1
  10407.     makestr(&(optlist[noptlist++]),"TOWER1");
  10408. #endif /* TOWER1 */
  10409. #ifdef UTEK
  10410.     makestr(&(optlist[noptlist++]),"UTEK");
  10411. #endif /* UTEK */
  10412. #ifdef ZILOG
  10413.     makestr(&(optlist[noptlist++]),"ZILOG");
  10414. #endif /* ZILOG */
  10415. #ifdef TRS16
  10416.     makestr(&(optlist[noptlist++]),"TRS16");
  10417. #endif /* TRS16 */
  10418. #ifdef MINIX
  10419.     makestr(&(optlist[noptlist++]),"MINIX");
  10420. #endif /* MINIX */
  10421. #ifdef C70
  10422.     makestr(&(optlist[noptlist++]),"C70");
  10423. #endif /* C70 */
  10424. #ifdef AIXPS2
  10425.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10426. #endif /* AIXPS2 */
  10427. #ifdef AIXRS
  10428.     makestr(&(optlist[noptlist++]),"AIXRS");
  10429. #endif /* AIXRS */
  10430. #ifdef UTSV
  10431.     makestr(&(optlist[noptlist++]),"UTSV");
  10432. #endif /* UTSV */
  10433. #ifdef ATTSV
  10434.     makestr(&(optlist[noptlist++]),"ATTSV");
  10435. #endif /* ATTSV */
  10436. #ifdef SVR3
  10437.     makestr(&(optlist[noptlist++]),"SVR3");
  10438. #endif /* SVR3 */
  10439. #ifdef SVR4
  10440.     makestr(&(optlist[noptlist++]),"SVR4");
  10441. #endif /* SVR4 */
  10442. #ifdef DELL_SVR4
  10443.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10444. #endif /* DELL_SVR4 */
  10445. #ifdef ICL_SVR4
  10446.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10447. #endif /* ICL_SVR4 */
  10448. #ifdef OSF
  10449.     makestr(&(optlist[noptlist++]),"OSF");
  10450. #endif /* OSF */
  10451. #ifdef OSF1
  10452.     makestr(&(optlist[noptlist++]),"OSF1");
  10453. #endif /* OSF1 */
  10454. #ifdef __OSF
  10455.     makestr(&(optlist[noptlist++]),"__OSF");
  10456. #endif /* __OSF */
  10457. #ifdef __OSF__
  10458.     makestr(&(optlist[noptlist++]),"__OSF__");
  10459. #endif /* __OSF__ */
  10460. #ifdef __osf__
  10461.     makestr(&(optlist[noptlist++]),"__osf__");
  10462. #endif /* __osf__ */
  10463. #ifdef __OSF1
  10464.     makestr(&(optlist[noptlist++]),"__OSF1");
  10465. #endif /* __OSF1 */
  10466. #ifdef __OSF1__
  10467.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10468. #endif /* __OSF1__ */
  10469. #ifdef PTX
  10470.     makestr(&(optlist[noptlist++]),"PTX");
  10471. #endif /* PTX */
  10472. #ifdef POSIX
  10473.     makestr(&(optlist[noptlist++]),"POSIX");
  10474. #endif /* POSIX */
  10475. #ifdef BSD44ORPOSIX
  10476.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10477. #endif /* BSD44ORPOSIX */
  10478. #ifdef SVORPOSIX
  10479.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10480. #endif /* SVORPOSIX */
  10481. #ifdef SVR4ORPOSIX
  10482.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10483. #endif /* SVR4ORPOSIX */
  10484. #ifdef OS2ORVMS
  10485.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10486. #endif /* OS2ORVMS */
  10487. #ifdef OS2ORUNIX
  10488.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10489. #endif /* OS2ORUNIX */
  10490. #ifdef VMSORUNIX
  10491.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10492. #endif /* VMSORUNIX */
  10493. #ifdef _POSIX_SOURCE
  10494.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10495. #endif /* _POSIX_SOURCE */
  10496. #ifdef _XOPEN_SOURCE
  10497.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10498. #endif
  10499. #ifdef _ALL_SOURCE
  10500.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10501. #endif
  10502. #ifdef _SVID3
  10503.     makestr(&(optlist[noptlist++]),"_SVID3");
  10504. #endif /* _SVID3 */
  10505. #ifdef Plan9
  10506.     makestr(&(optlist[noptlist++]),"Plan9");
  10507. #endif /* Plan9 */
  10508. #ifdef SOLARIS
  10509.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10510. #ifdef SOLARIS24
  10511.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10512. #endif /* SOLARIS24 */
  10513. #ifdef SOLARIS25
  10514.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10515. #endif /* SOLARIS25 */
  10516. #ifdef SOLARIS26
  10517.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10518. #endif /* SOLARIS26 */
  10519. #ifdef SOLARIS7
  10520.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10521. #endif /* SOLARIS7 */
  10522. #ifdef SOLARIS8
  10523.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10524. #endif /* SOLARIS8 */
  10525. #endif /* SOLARIS */
  10526.  
  10527. #ifdef SUNOS4
  10528.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10529. #endif /* SUNOS4 */
  10530. #ifdef SUN4S5
  10531.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10532. #endif /* SUN4S5 */
  10533. #ifdef IRIX
  10534.     makestr(&(optlist[noptlist++]),"IRIX");
  10535. #endif /* IRIX */
  10536. #ifdef ENCORE
  10537.     makestr(&(optlist[noptlist++]),"ENCORE");
  10538. #endif /* ENCORE */
  10539. #ifdef ultrix
  10540.     makestr(&(optlist[noptlist++]),"ultrix");
  10541. #endif
  10542. #ifdef sxaE50
  10543.     makestr(&(optlist[noptlist++]),"sxaE50");
  10544. #endif
  10545. #ifdef mips
  10546.     makestr(&(optlist[noptlist++]),"mips");
  10547. #endif
  10548. #ifdef MIPS
  10549.     makestr(&(optlist[noptlist++]),"MIPS");
  10550. #endif
  10551. #ifdef vax
  10552.     makestr(&(optlist[noptlist++]),"vax");
  10553. #endif
  10554. #ifdef VAX
  10555.     makestr(&(optlist[noptlist++]),"VAX");
  10556. #endif
  10557. #ifdef alpha
  10558.     makestr(&(optlist[noptlist++]),"alpha");
  10559. #endif
  10560. #ifdef ALPHA
  10561.     makestr(&(optlist[noptlist++]),"ALPHA");
  10562. #endif
  10563. #ifdef __ALPHA
  10564.     makestr(&(optlist[noptlist++]),"__ALPHA");
  10565. #endif
  10566. #ifdef __alpha
  10567.     makestr(&(optlist[noptlist++]),"__alpha");
  10568. #endif
  10569. #ifdef __AXP
  10570.     makestr(&(optlist[noptlist++]),"__AXP");
  10571. #endif
  10572. #ifdef AXP
  10573.     makestr(&(optlist[noptlist++]),"AXP");
  10574. #endif
  10575. #ifdef axp
  10576.     makestr(&(optlist[noptlist++]),"axp");
  10577. #endif
  10578. #ifdef __ALPHA__
  10579.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  10580. #endif
  10581. #ifdef __alpha__
  10582.     makestr(&(optlist[noptlist++]),"__alpha__");
  10583. #endif
  10584. #ifdef sun
  10585.     makestr(&(optlist[noptlist++]),"sun");
  10586. #endif
  10587. #ifdef sun3
  10588.     makestr(&(optlist[noptlist++]),"sun3");
  10589. #endif
  10590. #ifdef sun386
  10591.     makestr(&(optlist[noptlist++]),"sun386");
  10592. #endif
  10593. #ifdef _SUN
  10594.     makestr(&(optlist[noptlist++]),"_SUN");
  10595. #endif
  10596. #ifdef sun4
  10597.     makestr(&(optlist[noptlist++]),"sun4");
  10598. #endif
  10599. #ifdef sparc
  10600.     makestr(&(optlist[noptlist++]),"sparc");
  10601. #endif
  10602. #ifdef _CRAY
  10603.     makestr(&(optlist[noptlist++]),"_CRAY");
  10604. #endif /* _CRAY */
  10605. #ifdef NEXT33
  10606.     makestr(&(optlist[noptlist++]),"NEXT33");
  10607. #endif
  10608. #ifdef NEXT
  10609.     makestr(&(optlist[noptlist++]),"NEXT");
  10610. #endif
  10611. #ifdef NeXT
  10612.     makestr(&(optlist[noptlist++]),"NeXT");
  10613. #endif
  10614. #ifdef MACH
  10615.     makestr(&(optlist[noptlist++]),"MACH");
  10616. #endif
  10617. #ifdef sgi
  10618.     makestr(&(optlist[noptlist++]),"sgi");
  10619. #endif
  10620. #ifdef M_SYS5
  10621.     makestr(&(optlist[noptlist++]),"M_SYS5");
  10622. #endif
  10623. #ifdef __SYSTEM_FIVE
  10624.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  10625. #endif
  10626. #ifdef sysV
  10627.     makestr(&(optlist[noptlist++]),"sysV");
  10628. #endif
  10629. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  10630.     makestr(&(optlist[noptlist++]),"M_XENIX");
  10631. #endif
  10632. #ifdef M_UNIX                           /* SCO UNIX */
  10633.     makestr(&(optlist[noptlist++]),"M_UNIX");
  10634. #endif
  10635. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  10636.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  10637. #endif
  10638. #ifdef CK_SCOV5
  10639.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  10640. #endif
  10641. #ifdef SCO_OSR504
  10642.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  10643. #endif
  10644. #ifdef M_IA64
  10645.     makestr(&(optlist[noptlist++]),"M_IA64");
  10646. #endif
  10647. #ifdef _M_IA64
  10648.     makestr(&(optlist[noptlist++]),"_M_IA64");
  10649. #endif
  10650. #ifdef ia64
  10651.     makestr(&(optlist[noptlist++]),"ia64");
  10652. #endif
  10653. #ifdef _ia64
  10654.     makestr(&(optlist[noptlist++]),"_ia64");
  10655. #endif
  10656. #ifdef _ia64_
  10657.     makestr(&(optlist[noptlist++]),"_ia64_");
  10658. #endif
  10659. #ifdef M_I686
  10660.     makestr(&(optlist[noptlist++]),"M_I686");
  10661. #endif
  10662. #ifdef _M_I686
  10663.     makestr(&(optlist[noptlist++]),"_M_I686");
  10664. #endif
  10665. #ifdef i686
  10666.     makestr(&(optlist[noptlist++]),"i686");
  10667. #endif
  10668. #ifdef M_I586
  10669.     makestr(&(optlist[noptlist++]),"M_I586");
  10670. #endif
  10671. #ifdef _M_I586
  10672.     makestr(&(optlist[noptlist++]),"_M_I586");
  10673. #endif
  10674. #ifdef i586
  10675.     makestr(&(optlist[noptlist++]),"i586");
  10676. #endif
  10677. #ifdef M_I486
  10678.     makestr(&(optlist[noptlist++]),"M_I486");
  10679. #endif
  10680. #ifdef _M_I486
  10681.     makestr(&(optlist[noptlist++]),"_M_I486");
  10682. #endif
  10683. #ifdef i486
  10684.     makestr(&(optlist[noptlist++]),"i486");
  10685. #endif
  10686. #ifdef M_I386
  10687.     makestr(&(optlist[noptlist++]),"M_I386");
  10688. #endif
  10689. #ifdef _M_I386
  10690.     makestr(&(optlist[noptlist++]),"_M_I386");
  10691. #endif
  10692. #ifdef i386
  10693.     makestr(&(optlist[noptlist++]),"i386");
  10694. #endif
  10695. #ifdef i286
  10696.     makestr(&(optlist[noptlist++]),"i286");
  10697. #endif
  10698. #ifdef M_I286
  10699.     makestr(&(optlist[noptlist++]),"M_I286");
  10700. #endif
  10701. #ifdef mc68000
  10702.     makestr(&(optlist[noptlist++]),"mc68000");
  10703. #endif
  10704. #ifdef mc68010
  10705.     makestr(&(optlist[noptlist++]),"mc68010");
  10706. #endif
  10707. #ifdef mc68020
  10708.     makestr(&(optlist[noptlist++]),"mc68020");
  10709. #endif
  10710. #ifdef mc68030
  10711.     makestr(&(optlist[noptlist++]),"mc68030");
  10712. #endif
  10713. #ifdef mc68040
  10714.     makestr(&(optlist[noptlist++]),"mc68040");
  10715. #endif
  10716. #ifdef M_68000
  10717.     makestr(&(optlist[noptlist++]),"M_68000");
  10718. #endif
  10719. #ifdef M_68010
  10720.     makestr(&(optlist[noptlist++]),"M_68010");
  10721. #endif
  10722. #ifdef M_68020
  10723.     makestr(&(optlist[noptlist++]),"M_68020");
  10724. #endif
  10725. #ifdef M_68030
  10726.     makestr(&(optlist[noptlist++]),"M_68030");
  10727. #endif
  10728. #ifdef M_68040
  10729.     makestr(&(optlist[noptlist++]),"M_68040");
  10730. #endif
  10731. #ifdef m68k
  10732.     makestr(&(optlist[noptlist++]),"m68k");
  10733. #endif
  10734. #ifdef m88k
  10735.     makestr(&(optlist[noptlist++]),"m88k");
  10736. #endif
  10737. #ifdef pdp11
  10738.     makestr(&(optlist[noptlist++]),"pdp11");
  10739. #endif
  10740. #ifdef iAPX
  10741.     makestr(&(optlist[noptlist++]),"iAPX");
  10742. #endif
  10743. #ifdef hpux
  10744.     makestr(&(optlist[noptlist++]),"hpux");
  10745. #endif
  10746. #ifdef __hpux
  10747.     makestr(&(optlist[noptlist++]),"__hpux");
  10748. #endif
  10749. #ifdef __hp9000s800
  10750.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  10751. #endif
  10752. #ifdef __hp9000s700
  10753.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  10754. #endif
  10755. #ifdef __hp9000s500
  10756.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  10757. #endif
  10758. #ifdef __hp9000s300
  10759.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  10760. #endif
  10761. #ifdef __hp9000s200
  10762.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  10763. #endif
  10764. #ifdef AIX
  10765.     makestr(&(optlist[noptlist++]),"AIX");
  10766. #endif
  10767. #ifdef _AIXFS
  10768.     makestr(&(optlist[noptlist++]),"_AIXFS");
  10769. #endif
  10770. #ifdef u370
  10771.     makestr(&(optlist[noptlist++]),"u370");
  10772. #endif
  10773. #ifdef u3b
  10774.     makestr(&(optlist[noptlist++]),"u3b");
  10775. #endif
  10776. #ifdef u3b2
  10777.     makestr(&(optlist[noptlist++]),"u3b2");
  10778. #endif
  10779. #ifdef multimax
  10780.     makestr(&(optlist[noptlist++]),"multimax");
  10781. #endif
  10782. #ifdef balance
  10783.     makestr(&(optlist[noptlist++]),"balance");
  10784. #endif
  10785. #ifdef ibmrt
  10786.     makestr(&(optlist[noptlist++]),"ibmrt");
  10787. #endif
  10788. #ifdef _IBMRT
  10789.     makestr(&(optlist[noptlist++]),"_IBMRT");
  10790. #endif
  10791. #ifdef ibmrs6000
  10792.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  10793. #endif
  10794. #ifdef _AIX
  10795.     makestr(&(optlist[noptlist++]),"_AIX");
  10796. #endif /* _AIX */
  10797. #ifdef _IBMR2
  10798.     makestr(&(optlist[noptlist++]),"_IBMR2");
  10799. #endif
  10800. #ifdef UNIXWARE
  10801.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  10802. #endif
  10803. #ifdef QNX
  10804.     makestr(&(optlist[noptlist++]),"QNX");
  10805. #ifdef __QNX__
  10806.     makestr(&(optlist[noptlist++]),"__QNX__");
  10807. #ifdef __16BIT__
  10808.     makestr(&(optlist[noptlist++]),"__16BIT__");
  10809. #endif
  10810. #ifdef CK_QNX16
  10811.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  10812. #endif
  10813. #ifdef __32BIT__
  10814.     makestr(&(optlist[noptlist++]),"__32BIT__");
  10815. #endif
  10816. #ifdef CK_QNX32
  10817.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  10818. #endif
  10819. #endif /* __QNX__ */
  10820. #endif /* QNX */
  10821.  
  10822. #ifdef QNX6
  10823.     makestr(&(optlist[noptlist++]),"QNX6");
  10824. #endif /* QNX6 */
  10825.  
  10826. #ifdef NEUTRINO
  10827.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  10828. #endif /* NEUTRINO */
  10829.  
  10830. #ifdef __STRICT_BSD__
  10831.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  10832. #endif
  10833. #ifdef __STRICT_ANSI__
  10834.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  10835. #endif
  10836. #ifdef _ANSI_C_SOURCE
  10837.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  10838. #endif
  10839. #ifdef __STDC__
  10840.     makestr(&(optlist[noptlist++]),"__STDC__");
  10841. #endif
  10842. #ifdef __DECC
  10843.     makestr(&(optlist[noptlist++]),"__DECC");
  10844. #ifdef __DECC_VER
  10845.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  10846.     makestr(&(optlist[noptlist++]),line);
  10847. #endif /* __DECC_VER */
  10848. #endif /* __DECC */
  10849. #ifdef __CRTL_VER
  10850.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  10851.     makestr(&(optlist[noptlist++]),line);
  10852. #endif /* __CRTL_VER */
  10853. #ifdef __GNUC__                         /* gcc in ansi mode */
  10854.     makestr(&(optlist[noptlist++]),"__GNUC__");
  10855. #endif
  10856. #ifdef GNUC                             /* gcc in traditional mode */
  10857.     makestr(&(optlist[noptlist++]),"GNUC");
  10858. #endif
  10859. #ifdef __EGCS__                         /* egcs in ansi mode */
  10860.     makestr(&(optlist[noptlist++]),"__EGCS__");
  10861. #endif
  10862. #ifdef __egcs__                         /* egcs in ansi mode */
  10863.     makestr(&(optlist[noptlist++]),"__egcs__");
  10864. #endif
  10865. #ifdef __WATCOMC__
  10866.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  10867. #endif
  10868. #ifdef CK_ANSIC
  10869.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  10870. #endif
  10871. #ifdef CK_ANSILIBS
  10872.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  10873. #endif
  10874. #ifdef CKCONINTB4CB
  10875.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  10876. #endif /* CKCONINTB4CB */
  10877. #ifdef NOTERMCAP
  10878.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  10879. #endif /* NOTERMCAP */
  10880. #ifdef __GLIBC__
  10881.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  10882. #endif
  10883. #ifdef _SC_JOB_CONTROL
  10884.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  10885. #endif
  10886. #ifdef _POSIX_JOB_CONTROL
  10887.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  10888. #endif
  10889. #ifdef SIG_I
  10890.     makestr(&(optlist[noptlist++]),"SIG_I");
  10891. #endif /* SIG_I */
  10892. #ifdef SIG_V
  10893.     makestr(&(optlist[noptlist++]),"SIG_V");
  10894. #endif /* SIG_V */
  10895. #ifdef CK_POSIX_SIG
  10896.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  10897. #endif
  10898. #ifdef SVR3JC
  10899.     makestr(&(optlist[noptlist++]),"SVR3JC");
  10900. #endif
  10901. #ifdef _386BSD
  10902.     makestr(&(optlist[noptlist++]),"_386BSD");
  10903. #endif
  10904. #ifdef _BSD
  10905.     makestr(&(optlist[noptlist++]),"_BSD");
  10906. #endif
  10907. #ifdef USE_MEMCPY
  10908.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  10909. #endif /* USE_MEMCPY */
  10910. #ifdef USE_LSTAT
  10911.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  10912. #endif /* USE_LSTAT */
  10913. #ifdef TERMIOX
  10914.     makestr(&(optlist[noptlist++]),"TERMIOX");
  10915. #endif /* TERMIOX */
  10916. #ifdef STERMIOX
  10917.     makestr(&(optlist[noptlist++]),"STERMIOX");
  10918. #endif /* STERMIOX */
  10919. #ifdef CK_CURSES
  10920.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  10921. #endif /* CK_CURSES */
  10922. #ifdef CK_NEWTERM
  10923.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  10924. #endif /* CK_NEWTERM */
  10925. #ifdef CK_WREFRESH
  10926.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  10927. #endif /* CK_WREFRESH */
  10928. #ifdef CK_PCT_BAR
  10929.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  10930. #endif /* CK_PCT_BAR */
  10931. #ifdef CK_DTRCD
  10932.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  10933. #endif /* CK_DTRCD */
  10934. #ifdef CK_DTRCTS
  10935.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  10936. #endif /* CK_DTRCTS */
  10937. #ifdef CK_RTSCTS
  10938.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  10939. #endif /* CK_RTSCTS */
  10940. #ifdef POSIX_CRTSCTS
  10941.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  10942. #endif /* POSIX_CRTSCTS */
  10943. #ifdef FIXCRTSCTS
  10944.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  10945. #endif /* FIXCRTSCTS */
  10946. #ifdef HWPARITY
  10947.     makestr(&(optlist[noptlist++]),"HWPARITY");
  10948. #endif /* HWPARITY */
  10949. #ifdef CK_SYSINI
  10950. #ifdef CK_INI_A
  10951.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  10952.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10953.     makestr(&(optlist[noptlist++]),line);
  10954. #else
  10955. #ifdef CK_INI_B
  10956.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  10957.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10958.     makestr(&(optlist[noptlist++]),line);
  10959. #else
  10960.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  10961. #endif /* CK_INI_B */
  10962. #endif /* CK_INI_A */
  10963. #endif /* CK_DSYSINI */
  10964. #ifdef CK_DSYSINI
  10965.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  10966. #endif /* CK_DSYSINI */
  10967. #ifdef CK_TTGWSIZ
  10968.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  10969. #endif /* CK_TTGWSIZ */
  10970. #ifdef CK_NAWS
  10971.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  10972. #endif /* CK_NAWS */
  10973. #ifdef MDMHUP
  10974.     makestr(&(optlist[noptlist++]),"MDMHUP");
  10975. #endif /* MDMHUP */
  10976. #ifdef HUP_CLOSE_POSIX
  10977.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  10978. #endif /* HUP_CLOSE_POSIX */
  10979. #ifdef NO_HUP_CLOSE_POSIX
  10980.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  10981. #endif /* NO_HUP_CLOSE_POSIX */
  10982. #ifdef DCMDBUF
  10983.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  10984. #endif /* DCMDBUF */
  10985. #ifdef CK_RECALL
  10986.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  10987. #endif /* CK_RECALL */
  10988. #ifdef BROWSER
  10989.     makestr(&(optlist[noptlist++]),"BROWSER");
  10990. #endif /* BROWSER */
  10991. #ifdef CLSOPN
  10992.     makestr(&(optlist[noptlist++]),"CLSOPN");
  10993. #endif /* CLSOPN */
  10994. #ifdef STRATUS
  10995.     makestr(&(optlist[noptlist++]),"STRATUS");
  10996. #endif /* STRATUS */
  10997. #ifdef __VOS__
  10998.     makestr(&(optlist[noptlist++]),"__VOS__");
  10999. #endif /* __VOS__ */
  11000. #ifdef STRATUSX25
  11001.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  11002. #endif /* STRATUSX25 */
  11003. #ifdef OS2MOUSE
  11004.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  11005. #endif /* OS2MOUSE */
  11006. #ifdef CK_REXX
  11007.     makestr(&(optlist[noptlist++]),"CK_REXX");
  11008. #endif /* CK_REXX */
  11009. #ifdef CK_TIMERS
  11010.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  11011. #endif /* CK_TIMERS */
  11012. #ifdef TTSPDLIST
  11013.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  11014. #endif /* TTSPDLIST */
  11015. #ifdef CK_PERMS
  11016.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  11017. #endif /* CK_PERMS */
  11018. #ifdef CKTUNING
  11019.     makestr(&(optlist[noptlist++]),"CKTUNING");
  11020. #endif /* CKTUNING */
  11021. #ifdef NEWFTP
  11022.     makestr(&(optlist[noptlist++]),"NEWFTP");
  11023. #endif /* NEWFTP */
  11024. #ifdef SYSFTP
  11025.     makestr(&(optlist[noptlist++]),"SYSFTP");
  11026. #endif /* SYSFTP */
  11027. #ifdef NOFTP
  11028.     makestr(&(optlist[noptlist++]),"NOFTP");
  11029. #endif /* NOFTP */
  11030. #ifdef CKHTTP
  11031.     makestr(&(optlist[noptlist++]),"CKHTTP");
  11032. #endif /* CKHTTP */
  11033. #ifdef NOHTTP
  11034.     makestr(&(optlist[noptlist++]),"NOHTTP");
  11035. #endif /* NOHTTP */
  11036. #ifdef CKROOT
  11037.     makestr(&(optlist[noptlist++]),"CKROOT");
  11038. #endif /* CKROOT */
  11039. #ifdef CKREALPATH
  11040.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  11041. #endif /* CKREALPATH */
  11042. #ifdef STREAMING
  11043.     makestr(&(optlist[noptlist++]),"STREAMING");
  11044. #endif /* STREAMING */
  11045. #ifdef UNPREFIXZERO
  11046.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11047. #endif /* UNPREFIXZERO */
  11048. #ifdef CKREGEX
  11049.     makestr(&(optlist[noptlist++]),"CKREGEX");
  11050. #endif /* CKREGEX */
  11051. #ifdef ZXREWIND
  11052.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  11053. #endif /* ZXREWIND */
  11054. #ifdef CKSYSLOG
  11055.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11056. #endif /* CKSYSLOG */
  11057. #ifdef SYSLOGLEVEL
  11058.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11059.     makestr(&(optlist[noptlist++]),line);
  11060. #endif /* SYSLOGLEVEL */
  11061. #ifdef NOSEXP
  11062.     makestr(&(optlist[noptlist++]),"NOSEXP");
  11063. #endif /* NOSEXP */
  11064. #ifdef CKLEARN
  11065.     makestr(&(optlist[noptlist++]),"CKLEARN");
  11066. #else
  11067. #ifdef NOLOEARN
  11068.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  11069. #endif /* NOLOEARN */
  11070. #endif /* CKLEARN */
  11071. #ifdef NOFLOAT
  11072.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  11073. #else
  11074. #ifdef FNFLOAT
  11075.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  11076. #endif /* FNFLOAT */
  11077. #ifdef CKFLOAT
  11078. #ifdef GFTIMER
  11079.     makestr(&(optlist[noptlist++]),"GFTIMER");
  11080. #endif /* GFTIMER */
  11081. #ifdef CKFLOAT_S
  11082.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11083.     makestr(&(optlist[noptlist++]),line);
  11084. #else
  11085.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  11086. #endif /* CKFLOAT_S */
  11087. #endif /* CKFLOAT */
  11088. #endif /* NOFLOAT */
  11089.  
  11090. #ifdef SSH
  11091.     makestr(&(optlist[noptlist++]),"SSH");
  11092. #endif /* SSH */
  11093. #ifdef NETDLL
  11094.     makestr(&(optlist[noptlist++]),"NETDLL");
  11095. #endif /* NETDLL */
  11096. #ifdef NETFILE
  11097.     makestr(&(optlist[noptlist++]),"NETFILE");
  11098. #endif /* NETFILE */
  11099. #ifdef CK_TAPI
  11100.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  11101. #endif /* CK_TAPI */
  11102. #ifdef CK_SSL
  11103.     makestr(&(optlist[noptlist++]),"CK_SSL");
  11104. #endif /* CK_SSL */
  11105.  
  11106.     debug(F101,"initoptlist noptlist","",noptlist);
  11107.     sh_sort(optlist,NULL,noptlist,0,0,0);
  11108. }
  11109.  
  11110. int
  11111. shofea() {
  11112.     int i;
  11113.     int flag = 0;
  11114.     int lines = 1;
  11115. #ifdef FNFLOAT
  11116.     extern int fp_digits, fp_rounding;
  11117. #endif /* FNFLOAT */
  11118.     extern int byteorder;
  11119.     printf("%s\n",versio);
  11120.     if (inserver)
  11121.       return(1);
  11122.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11123.     initoptlist();
  11124.     debug(F101,"shofea noptlist","",noptlist);
  11125. #ifdef OS2
  11126. #ifdef NT
  11127. #ifdef _M_ALPHA
  11128.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11129. #else /* _M_ALPHA */
  11130. #ifdef _M_PPC
  11131.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11132. #else /* _M_PPC */
  11133. #ifdef _M_MRX000
  11134.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11135. #else /* _M_MRX000 */
  11136. #ifdef _M_IX86
  11137.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11138. #else /* _M_IX86 */
  11139.     UNKNOWN WINDOWS PLATFORM
  11140. #endif /* _M_IX86 */
  11141. #endif /* _M_MRX000 */
  11142. #endif /* _M_PPC */
  11143. #endif /* _M_ALPHA */
  11144. #else /* NT */
  11145. #ifdef M_I286
  11146.     printf("IBM OS/2 16-bit.\n");
  11147. #else
  11148.     printf("IBM OS/2 32-bit.\n");
  11149. #endif /* M_I286 */
  11150. #endif /* NT */
  11151.     lines++;
  11152. #endif /* OS2 */
  11153.     printf("\n");
  11154.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11155.     printf("Major optional features included:\n");
  11156.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11157.  
  11158. #ifdef NETCONN
  11159.     printf(" Network support (type SHOW NET for further info)\n");
  11160.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11161. #ifdef IKS_OPTION
  11162.     printf(" Telnet Kermit Option\n");
  11163.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11164. #endif /* IKS_OPTION */
  11165. #ifdef CK_AUTHENTICATION
  11166.     printf(" Telnet Authentication Option\n");
  11167.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11168. #ifdef CK_KERBEROS
  11169. #ifdef KRB4
  11170. #ifdef KRB5
  11171.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11172.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11173. #else /* KRB5 */
  11174.     printf(" Kerberos(TM) IV authentication\n");
  11175.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11176. #endif /* KRB5 */
  11177. #else /* KRB4 */
  11178. #ifdef KRB5
  11179.     printf(" Kerberos(TM) V authentication\n");
  11180.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11181. #endif /* KRB5 */
  11182. #endif /* KRB4 */
  11183. #endif /* CK_KERBEROS */
  11184. #ifdef CK_SRP
  11185.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11186.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11187. #endif /* CK_SRP */
  11188. #ifdef CK_SSL
  11189.     printf(" Secure Sockets Layer (SSL)\n");
  11190.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11191.     printf(" Transport Layer Security (TLS)\n");
  11192.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11193. #endif /* CK_SSL */
  11194. #ifdef SSHBUILTIN
  11195.     printf(" Secure Shell (SSH) [internal]\n");
  11196.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11197. #endif /* SSHBUILTIN */
  11198. #ifdef SSHCMD
  11199.     printf(" Secure Shell (SSH) [external]\n");
  11200.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11201. #endif /* SSHCMD */
  11202. #ifdef CK_ENCRYPTION
  11203.     printf(" Telnet Encryption Option\n");
  11204.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11205. #ifdef CK_DES
  11206.     printf(" DES Encryption\n");
  11207.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11208. #endif /* CK_DES */
  11209. #ifdef CK_CAST
  11210.     printf(" CAST Encryption\n");
  11211.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11212. #endif /* CK_CAST */
  11213. #endif /* CK_ENCRYPTION */
  11214. #endif /* CK_AUTHENTICATION */
  11215. #ifdef CK_FORWARD_X
  11216.     printf(" X Windows forwarding\n");
  11217.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11218. #endif /* CK_FORWARD_X */
  11219. #ifdef TN_COMPORT
  11220.     printf(" Telnet Remote Com Port Control Option\n");
  11221.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11222. #endif /* TN_COMPORT */
  11223. #ifdef CK_SOCKS
  11224. #ifdef CK_SOCKS5
  11225.     printf(" SOCKS 5\n");
  11226.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11227. #else /* CK_SOCKS5 */
  11228.     printf(" SOCKS 4\n");
  11229.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11230. #endif /* CK_SOCKS5 */
  11231. #endif /* CK_SOCKS */
  11232. #ifdef NEWFTP
  11233.     printf(" Built-in FTP client\n");
  11234.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11235. #endif /* NEWFTP */
  11236. #ifdef CKHTTP
  11237.     printf(" Built-in HTTP client\n");
  11238.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11239. #endif /* CKHTTP */
  11240. #endif /* NETCONN */
  11241.  
  11242. #ifdef CK_RTSCTS
  11243.     printf(" Hardware flow control\n");
  11244.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11245. #endif /* CK_RTSCTS */
  11246.  
  11247. #ifdef CK_XYZ
  11248. #ifdef XYZ_INTERNAL
  11249.     printf(" Built-in XYZMODEM protocols\n");
  11250. #else
  11251.     printf(" External XYZMODEM protocol support\n");
  11252. #endif /* XYZ_INTERNAL */
  11253.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11254. #endif /* CK_XYZ */
  11255.  
  11256. #ifndef NOCSETS
  11257.     printf(" Latin-1 (West European) character-set translation\n");
  11258.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11259. #ifdef LATIN2
  11260.     printf(" Latin-2 (East European) character-set translation\n");
  11261.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11262. #endif /* LATIN2 */
  11263. #ifdef CYRILLIC
  11264.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11265.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11266. #endif /* CYRILLIC */
  11267. #ifdef GREEK
  11268.     printf(" Greek character-set translation\n");
  11269.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11270. #endif /* GREEK */
  11271. #ifdef HEBREW
  11272.     printf(" Hebrew character-set translation\n");
  11273.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11274. #endif /* HEBREW */
  11275. #ifdef KANJI
  11276.     printf(" Japanese character-set translation\n");
  11277.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11278. #endif /* KANJI */
  11279. #ifdef UNICODE
  11280.     printf(" Unicode character-set translation\n");
  11281.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11282. #endif /* UNICODE */
  11283. #ifdef CKOUNI
  11284.     if (isunicode())
  11285.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11286.     else
  11287.       printf(" Unicode translation for Terminal Character-Sets\n");
  11288.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11289. #endif /* CKOUNI */
  11290. #endif /* NOCSETS */
  11291.  
  11292. #ifdef NETPTY
  11293.     printf(" Pseudoterminal control\n");
  11294.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11295. #endif /* NETPTY */
  11296.  
  11297. #ifdef CK_REDIR
  11298.     printf(" REDIRECT command\n");
  11299.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11300. #endif /* CK_REDIR */
  11301.  
  11302. #ifdef CK_RESEND
  11303.     printf(" RESEND command\n");
  11304.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11305. #endif /* CK_RESEND */
  11306.  
  11307. #ifndef NOXFER
  11308. #ifdef CK_CURSES
  11309.     printf(" Fullscreen file transfer display\n");
  11310.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11311. #endif /* CK_CURSES */
  11312. #endif /* NOXFER */
  11313.  
  11314. #ifdef CK_SPEED
  11315.     printf(" Control-character unprefixing\n");
  11316.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11317. #endif /* CK_SPEED */
  11318.  
  11319. #ifdef STREAMING
  11320.     printf(" Streaming\n");
  11321.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11322. #endif /* STREAMING */
  11323.  
  11324. #ifdef CK_AUTODL
  11325.     printf(" Autodownload\n");
  11326.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11327. #endif /* CK_AUTODL */
  11328.  
  11329. #ifdef OS2MOUSE
  11330.     printf(" Mouse support\n");
  11331.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11332. #endif /* OS2MOUSE */
  11333.  
  11334. #ifdef CK_REXX
  11335.     printf(" REXX script language interface\n");
  11336.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11337. #endif /* CK_REXX */
  11338.  
  11339. #ifdef IKSD
  11340. #ifdef CK_LOGIN
  11341.     printf(" Internet Kermit Service with user login support\n");
  11342. #else /* CK_LOGIN */
  11343.     printf(" Internet Kermit Service without user login support\n");
  11344. #endif /* CK_LOGIN */
  11345.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11346. #endif /* IKSD */
  11347.  
  11348.     printf("\n");
  11349.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11350.     printf("Major optional features not included:\n");
  11351.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11352.  
  11353. #ifdef NOXFER
  11354.     printf(" No file-transfer protocols\n");
  11355.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11356.     flag = 1;
  11357. #else
  11358. #ifndef CK_CURSES
  11359. #ifndef MAC
  11360.     printf(" No fullscreen file transfer display\n");
  11361.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11362.     flag = 1;
  11363. #endif /* MAC */
  11364. #endif /* CK_CURSES */
  11365.  
  11366. #ifdef NOSERVER
  11367.     printf(" No server mode\n");
  11368.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11369.     flag = 1;
  11370. #endif /* NOSERVER */
  11371.  
  11372. #ifndef CK_SPEED
  11373.     printf(" No control-character unprefixing\n");
  11374.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11375.     flag = 1;
  11376. #endif /* CK_SPEED */
  11377.  
  11378. #ifndef STREAMING
  11379.     printf(" No streaming\n");
  11380.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11381.     flag = 1;
  11382. #endif /* STREAMING */
  11383.  
  11384. #ifndef CK_AUTODL
  11385.     printf(" No autodownload\n");
  11386.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11387.     flag = 1;
  11388. #endif /* CK_AUTODL */
  11389.  
  11390. #ifndef CK_XYZ
  11391.     printf(" No built-in XYZMODEM protocols\n");
  11392.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11393.     flag = 1;
  11394. #endif /* CK_XYZ */
  11395.  
  11396. #ifdef NOTLOG
  11397.     printf(" No transaction log\n");
  11398.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11399.     flag = 1;
  11400. #endif /* NOTLOG */
  11401. #endif /* NOXFER */
  11402.  
  11403. #ifdef NODEBUG
  11404.     printf(" No debugging\n");
  11405.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11406.     flag = 1;
  11407. #endif /* NODEBUG */
  11408.  
  11409. #ifdef NOHELP
  11410.     printf(" No built-in help\n");
  11411.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11412.     flag = 1;
  11413. #endif /* NOHELP */
  11414.  
  11415. #ifdef NOLOCAL
  11416.     printf(" No making connections\n");
  11417.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11418.     flag = 1;
  11419. #else
  11420. #ifndef NETCONN
  11421.     printf(" No network support\n");
  11422.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11423.     flag = 1;
  11424. #else /* NETCONN */
  11425. #ifndef IKS_OPTION
  11426.     printf(" No Telnet Kermit Option\n");
  11427.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11428.     flag = 1;
  11429. #endif /* IKS_OPTION */
  11430. #endif /* NETCONN */
  11431.  
  11432. #ifdef NOSSH
  11433.     printf(" No Secure Shell (SSH)\n");
  11434.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11435. #endif /* NOSSH */
  11436. #ifndef CK_AUTHENTICATION
  11437.     printf(" No Kerberos(TM) authentication\n");
  11438.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11439.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11440.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11441.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11442.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11443.     printf(" No Transport Layer Security (TLS) protocol\n");
  11444.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11445.     printf(" No encryption\n");
  11446.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11447.     flag = 1;
  11448. #else /* CK_AUTHENTICATION */
  11449. #ifndef CK_KERBEROS
  11450.     printf(" No Kerberos(TM) authentication\n");
  11451.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11452.     flag = 1;
  11453. #else /* CK_KERBEROS */
  11454. #ifndef KRB4
  11455.     printf(" No Kerberos(TM) IV authentication\n");
  11456.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11457.     flag = 1;
  11458. #endif /* KRB4 */
  11459. #ifndef KRB5
  11460.     printf(" No Kerberos(TM) V authentication\n");
  11461.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11462.     flag = 1;
  11463. #endif /* KRB5 */
  11464. #endif /* CK_KERBEROS */
  11465. #ifndef CK_SRP
  11466.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11467.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11468.     flag = 1;
  11469. #endif /* CK_SRP */
  11470. #ifndef CK_SSL
  11471.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11472.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11473.     printf(" No Transport Layer Security (TLS) protocol\n");
  11474.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11475.     flag = 1;
  11476. #endif /* CK_SSL */
  11477. #ifndef CK_ENCRYPTION
  11478.     printf(" No encryption\n");
  11479.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11480.     flag = 1;
  11481. #else /* CK_ENCRYPTION */
  11482. #ifndef OS2
  11483. #ifndef CK_DES
  11484.     printf(" No DES encryption\n");
  11485.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11486.     flag = 1;
  11487. #endif /* CK_DES */
  11488. #ifndef CK_CAST
  11489.     printf(" No CAST encryption\n");
  11490.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11491.     flag = 1;
  11492. #endif /* CK_CAST */
  11493. #endif /* OS2 */
  11494. #endif /* CK_ENCRYPTION */
  11495. #endif /* CK_AUTHENTICATION */
  11496. #ifndef CK_FORWARD_X
  11497.     printf(" No X Windows forwarding\n");
  11498.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11499. #endif /* CK_FORWARD_X */
  11500. #ifndef TN_COMPORT
  11501.     printf(" No Telnet Remote Com Port Control Option\n");
  11502.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11503. #endif /* TN_COMPORT */
  11504. #ifndef CK_SOCKS
  11505.     printf(" No SOCKS\n");
  11506.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11507. #endif /* CK_SOCKS */
  11508. #ifndef NEWFTP
  11509.     printf(" No built-in FTP client\n");
  11510.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11511. #endif /* NEWFTP */
  11512. #ifdef NOHTTP
  11513.     printf(" No built-in HTTP client\n");
  11514.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11515. #endif /* NOHTTP */
  11516.  
  11517. #ifdef NODIAL
  11518.     printf(" No DIAL command\n");
  11519.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11520.     flag = 1;
  11521. #else
  11522. #ifdef MINIDIAL
  11523.     printf(" Support for most modem types excluded\n");
  11524.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11525.     flag = 1;
  11526. #endif /* MINIDIAL */
  11527. #endif /* NODIAL */
  11528. #endif /* NOLOCAL */
  11529.  
  11530. #ifndef CK_RTSCTS
  11531. #ifndef MAC
  11532.     printf(" No hardware flow control\n");
  11533.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11534.     flag = 1;
  11535. #endif /* MAC */
  11536. #endif /* CK_RTSCTS */
  11537.  
  11538. #ifdef NOXMIT
  11539.     printf(" No TRANSMIT command\n");
  11540.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11541.     flag = 1;
  11542. #endif /* NOXMIT */
  11543.  
  11544. #ifdef NOSCRIPT
  11545.     printf(" No SCRIPT command\n");
  11546.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11547.     flag = 1;
  11548. #endif /* NOSCRIPT */
  11549.  
  11550. #ifdef NOSPL
  11551.     printf(" No script programming features\n");
  11552.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11553.     flag = 1;
  11554. #endif /* NOSPL */
  11555.  
  11556. #ifdef NOCSETS
  11557.     printf(" No character-set translation\n");
  11558.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11559.     flag = 1;
  11560. #else
  11561.  
  11562. #ifndef LATIN2
  11563.     printf(" No Latin-2 character-set translation\n");
  11564.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11565.     flag = 1;
  11566. #endif /* LATIN2 */
  11567.  
  11568. #ifdef NOGREEK
  11569.     printf(" No Greek character-set translation\n");
  11570.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11571.     flag = 1;
  11572. #endif /* NOGREEK */
  11573.  
  11574. #ifdef NOHEBREW
  11575.     printf(" No Hebrew character-set translation\n");
  11576.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11577.     flag = 1;
  11578. #endif /* NOHEBREW */
  11579.  
  11580. #ifdef NOUNICODE
  11581.     printf(" No Unicode character-set translation\n");
  11582.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11583.     flag = 1;
  11584. #endif /* NOUNICODE */
  11585.  
  11586. #ifdef NOCYRIL
  11587.     printf(" No Cyrillic character-set translation\n");
  11588.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11589.     flag = 1;
  11590. #endif /* NOCYRIL */
  11591.  
  11592. #ifndef KANJI
  11593.     printf(" No Kanji character-set translation\n");
  11594.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11595.     flag = 1;
  11596. #endif /* KANJI */
  11597. #endif /* NOCSETS */
  11598.  
  11599. #ifdef NOCMDL
  11600.     printf(" No command-line arguments\n");
  11601.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11602.     flag = 1;
  11603. #endif /* NOCMDL */
  11604.  
  11605. #ifdef NOPUSH
  11606.     printf(" No escape to system\n");
  11607.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11608.     flag = 1;
  11609. #endif /* NOPUSH */
  11610.  
  11611. #ifdef NOJC
  11612. #ifdef UNIX
  11613.     printf(" No UNIX job control\n");
  11614.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11615.     flag = 1;
  11616. #endif /* UNIX */
  11617. #endif /* NOJC */
  11618.  
  11619. #ifdef NOSETKEY
  11620.     printf(" No SET KEY command\n");
  11621.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11622.     flag = 1;
  11623. #endif /* NOSETKEY */
  11624.  
  11625. #ifndef CK_REDIR
  11626.     printf(" No REDIRECT or PIPE command\n");
  11627.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11628.     flag = 1;
  11629. #endif /* CK_REDIR */
  11630.  
  11631. #ifdef UNIX
  11632. #ifndef NETPTY
  11633.     printf(" No pseudoterminal control\n");
  11634.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11635.     flag = 1;
  11636. #endif /* NETPTY */
  11637. #endif /* UNIX */
  11638.  
  11639. #ifndef CK_RESEND
  11640.     printf(" No RESEND command\n");
  11641.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11642.     flag = 1;
  11643. #endif /* CK_RESEND */
  11644.  
  11645. #ifdef OS2
  11646. #ifdef __32BIT__
  11647. #ifndef OS2MOUSE
  11648.     printf(" No Mouse support\n");
  11649.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11650.     flag = 1;
  11651. #endif /* __32BIT__ */
  11652. #endif /* OS2 */
  11653. #endif /* OS2MOUSE */
  11654.  
  11655. #ifdef OS2
  11656. #ifndef NT
  11657. #ifndef CK_REXX
  11658.     printf(" No REXX script language interface\n");
  11659.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11660.     flag = 1;
  11661. #endif /* CK_REXX */
  11662. #endif /* NT */
  11663. #endif /* OS2 */
  11664.  
  11665. #ifndef IKSD
  11666.     printf(" No Internet Kermit Service\n");
  11667.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11668.     flag = 1;
  11669. #endif /* IKSD */
  11670.  
  11671.     if (flag == 0) {
  11672.         printf(" None\n");
  11673.         if (++lines > cmd_rows - 3)
  11674.           { if (!askmore()) return(1); else lines = 0; }
  11675.     }
  11676.     printf("\n");
  11677.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11678.  
  11679. #ifdef CK_UTSNAME
  11680.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11681.     printf("Host info:\n");
  11682.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11683.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  11684.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11685.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  11686.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11687.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  11688.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11689.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  11690.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11691.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  11692.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11693.     printf("\n");
  11694.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11695. #endif /* CK_UTSNAME */
  11696.  
  11697. /*
  11698.   Print compile-time (-D) options, as well as C preprocessor
  11699.   predefined symbols that might affect us...
  11700. */
  11701. #ifdef KTARGET
  11702.     {
  11703.         char * s;                       /* Makefile target */
  11704.         s = KTARGET;
  11705.         if (!s) s = "";
  11706.         if (!*s) s = "(unknown)";
  11707.         printf("\n");
  11708.         if (++lines > cmd_rows - 3) {
  11709.             if (!askmore()) return(1); else lines = 0;
  11710.         }
  11711.         printf("Target: %s\n", s);
  11712.         if (++lines > cmd_rows - 3) {
  11713.             if (!askmore()) return(1); else lines = 0;
  11714.         }
  11715.     }
  11716. #endif /* KTARGET */
  11717.  
  11718. #ifdef __VERSION__
  11719. #ifdef __GNUC__
  11720.     printf("GCC version: %s\n", __VERSION__);
  11721. #else
  11722.     printf("Compiler version: %s\n", __VERSION__);
  11723. #endif /* __GNUC__ */
  11724.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11725. #endif /* __VERSION__ */
  11726.  
  11727. #ifdef __DATE__                         /* GNU and other ANSI */
  11728. #ifdef __TIME__
  11729.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  11730. #else
  11731.     printf("Compiled %s, options:\n", __DATE__);
  11732. #endif /* __TIME__ */
  11733. #else /* !__DATE__ */
  11734.     printf("Compiler options:\n");
  11735. #endif /* __DATE__ */
  11736.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11737.  
  11738.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  11739.       if (!prtopt(&lines,optlist[i]))
  11740.         return(0);
  11741.  
  11742.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11743.  
  11744. /* Sizes of data types */
  11745.  
  11746.     ckmakmsg(line,
  11747.              LINBUFSIZ,
  11748.              "byte order: ",
  11749.              byteorder ? "little" : "big",
  11750.              " endian",
  11751.              NULL
  11752.              );
  11753.     if (!prtopt(&lines,line)) return(0);
  11754.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11755.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  11756.     if (!prtopt(&lines,line)) return(0);
  11757.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  11758.     if (!prtopt(&lines,line)) return(0);
  11759.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  11760.     if (!prtopt(&lines,line)) return(0);
  11761.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  11762.     if (!prtopt(&lines,line)) return(0);
  11763.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  11764.     if (!prtopt(&lines,line)) return(0);
  11765. #ifdef LONG_MAX
  11766.     sprintf(line,"LONG_MAX=%d",LONG_MAX); /* SAFE */
  11767. #endif /* LONG_MAX */
  11768. #ifdef CKFLOAT
  11769.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  11770.     if (!prtopt(&lines,line)) return(0);
  11771.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  11772.     if (!prtopt(&lines,line)) return(0);
  11773. #ifdef FNFLOAT
  11774.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11775.     if (!prtopt(&lines,"floating-point:")) return(0);
  11776.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  11777.     if (!prtopt(&lines,line)) return(0);
  11778.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  11779.     if (!prtopt(&lines,line)) return(0);
  11780. #endif /* FNFLOAT */
  11781. #endif /* CKFLOAT */
  11782.  
  11783.     prtopt(&lines,"");
  11784.     return(0);
  11785. }
  11786. #endif /* NOSHOW */
  11787. #endif /* NOICP */
  11788.