home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / tar / x30.tar.gz / x30.tar / ckuus5.c < prev    next >
C/C++ Source or Header  |  2010-03-29  |  388KB  |  12,381 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.   Authors:
  13.     Frank da Cruz <fdc@columbia.edu>,
  14.       The Kermit Project, Columbia University, New York City
  15.     Jeffrey E Altman <jaltman@secure-endpoints.com>
  16.       Secure Endpoints Inc., New York City
  17.  
  18.   Copyright (C) 1985, 2010,
  19.     Trustees of Columbia University in the City of New York.
  20.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  21.     copyright text in the ckcmai.c module for disclaimer and permissions.
  22. */
  23.  
  24. /* Includes */
  25.  
  26. #include "ckcdeb.h"
  27. #include "ckcasc.h"
  28. #include "ckcker.h"
  29. #include "ckuusr.h"
  30.  
  31. #ifdef DCMDBUF
  32. char *line;                             /* Character buffer for anything */
  33. char *tmpbuf;
  34. #else
  35. char line[LINBUFSIZ+1];
  36. char tmpbuf[TMPBUFSIZ+1];               /* Temporary buffer */
  37. #endif /* DCMDBUF */
  38.  
  39. #ifndef NOICP
  40.  
  41. #include "ckcnet.h"
  42. #ifndef NOCSETS
  43. #include "ckcxla.h"
  44. #endif /* NOCSETS */
  45. #ifdef MAC
  46. #include "ckmasm.h"
  47. #endif /* MAC */
  48. #ifdef CK_SSL
  49. #include "ck_ssl.h"
  50. #endif /* CK_SSL */
  51.  
  52. #ifdef OS2
  53. #include "ckoetc.h"
  54. #ifndef NT
  55. #define INCL_NOPM
  56. #define INCL_VIO /* Needed for ckocon.h */
  57. #include <os2.h>
  58. #undef COMMENT
  59. #else /* NT */
  60. #include <windows.h>
  61. #define TAPI_CURRENT_VERSION 0x00010004
  62. #include <tapi.h>
  63. #include <mcx.h>
  64. #include "ckntap.h"
  65. #define APIRET ULONG
  66. extern int DialerHandle;
  67. extern int StartedFromDialer;
  68. #endif /* NT */
  69. #include "ckocon.h"
  70. #include "ckokey.h"
  71. #ifdef KUI
  72. #include "ikui.h"
  73. #endif /* KUI */
  74. #ifdef putchar
  75. #undef putchar
  76. #endif /* putchar */
  77. #define putchar(x) conoc(x)
  78. extern int cursor_save ;
  79. extern bool cursorena[] ;
  80. #endif /* OS2 */
  81.  
  82. /* 2010-03-09 SMS.  VAX C V3.1-051 needs <stat.h> for off_t. */
  83. #ifdef VMS
  84. #include <stat.h>
  85. #endif /* def VMS */
  86.  
  87. /* For formatted screens, "more?" prompting, etc. */
  88.  
  89. #ifdef FT18
  90. #define isxdigit(c) isdigit(c)
  91. #endif /* FT18 */
  92.  
  93. #ifdef STRATUS                          /* Stratus Computer, Inc.  VOS */
  94. #ifdef putchar
  95. #undef putchar
  96. #endif /* putchar */
  97. #define putchar(x) conoc(x)
  98. #ifdef getchar
  99. #undef getchar
  100. #endif /* getchar */
  101. #define getchar(x) coninc(0)
  102. #endif /* STRATUS */
  103.  
  104. /* External variables */
  105.  
  106. extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
  107.   binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  108.   inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  109.   zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  110.   debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
  111.   rcdactive, keepallchars, cmd_err;
  112.  
  113. #ifdef LOCUS
  114. extern int locus, autolocus;
  115. #endif /* LOCUS */
  116.  
  117. #ifndef NOMSEND
  118. extern int addlist;
  119. #endif /* NOMSEND */
  120.  
  121. #ifdef CK_SPEED
  122. extern int prefixing;
  123. #endif /* CK_SPEED */
  124.  
  125. extern int g_matchdot;
  126.  
  127. #ifdef RECURSIVE
  128. extern int recursive;
  129. #endif /* RECURSIVE */
  130. extern int xfiletype;
  131.  
  132. #ifdef IKSDCONF
  133. extern char * iksdconf;
  134. extern int iksdcf;
  135. #endif /* IKSDCONF */
  136.  
  137. #ifdef CK_RECALL
  138. extern int on_recall;
  139. #endif /* CK_RECALL */
  140.  
  141. extern int ngetpath, exitonclose;
  142. extern char * getpath[];
  143. extern CHAR * epktmsg;
  144.  
  145. extern char * snd_move;
  146. extern char * snd_rename;
  147. extern char * rcv_move;
  148. extern char * rcv_rename;
  149. extern char * g_snd_move;
  150. extern char * g_snd_rename;
  151. extern char * g_rcv_move;
  152. extern char * g_rcv_rename;
  153.  
  154. extern char * nm[];
  155.  
  156. #ifdef CK_UTSNAME
  157. extern char unm_mch[];
  158. extern char unm_mod[];
  159. extern char unm_nam[];
  160. extern char unm_rel[];
  161. extern char unm_ver[];
  162. #endif /* CK_UTSNAME */
  163.  
  164. #ifndef NOPUSH
  165. #ifndef NOFRILLS
  166. extern char editor[];
  167. extern char editfile[];
  168. extern char editopts[];
  169. #ifdef BROWSER
  170. extern char browser[];
  171. extern char browsopts[];
  172. extern char browsurl[];
  173. #endif /* BROWSER */
  174. #endif /*  NOFRILLS */
  175. #endif /* NOPUSH */
  176.  
  177. #ifndef NOFRILLS
  178. #ifndef NORENAME
  179. _PROTOTYP(VOID shorename, (void));
  180. #endif    /* NORENAME */
  181. #endif    /* NOFRILLS */
  182.  
  183. #ifndef NOSERVER
  184. extern char * x_user, * x_passwd, * x_acct;
  185. #endif /* NOSERVER */
  186.  
  187. #ifdef CKLOGDIAL
  188. extern int dialog;
  189. extern char diafil[];
  190. #endif /* CKLOGDIAL */
  191.  
  192. #ifdef CKROOT
  193. extern int ckrooterr;
  194. #endif /* CKROOT */
  195.  
  196. #ifndef NOSPL
  197. extern int cfilef, xxdot, vareval;
  198. extern char cmdfil[];
  199.  
  200. struct localvar * localhead[CMDSTKL];
  201. struct localvar * localtail = NULL;
  202. struct localvar * localnext = NULL;
  203.  
  204. _PROTOTYP( VOID shosexp, (void) );
  205. _PROTOTYP( static VOID shoinput, (void) );
  206. _PROTOTYP( static char gettok,   (void) );
  207. _PROTOTYP( static VOID factor,   (void) );
  208. _PROTOTYP( static VOID term,     (void) );
  209. _PROTOTYP( static VOID termp,    (void) );
  210. _PROTOTYP( static VOID exprp,    (void) );
  211. _PROTOTYP( static VOID expr,     (void) );
  212. _PROTOTYP( static VOID simple,   (void) );
  213. _PROTOTYP( static VOID simpler,  (void) );
  214. _PROTOTYP( static VOID simplest, (void) );
  215. _PROTOTYP( static CK_OFF_T xparse,   (void) );
  216. #endif /* NOSPL */
  217. #ifndef NOSHOW
  218. _PROTOTYP( int sho_iks, (void) );
  219. #endif /* NOSHOW */
  220.  
  221. #ifdef MAC
  222. char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
  223. char * ikprompt = "IKSD>";
  224. #else  /* Not MAC */
  225. #ifdef NOSPL
  226. #ifdef OS2
  227. char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
  228. char * ikprompt = "IKSD> ";
  229. #else
  230. char * ckprompt = "C-Kermit>";
  231. char * ikprompt = "IKSD>";
  232. #endif /* NT */
  233. #else  /* NOSPL */
  234. #ifdef OS2
  235. /* Default prompt for OS/2 and Win32 */
  236. #ifdef NT
  237. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
  238. char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
  239. #else  /* NT */
  240. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  241. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  242. #endif /* NT */
  243. #else  /* OS2 */
  244. #ifdef VMS
  245. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  246. char * ikprompt = "\\v(dir) IKSD>";
  247. #else
  248. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  249. char * ikprompt = "(\\v(dir)) IKSD>";
  250. #endif /* VMS */
  251. #endif /* NT */
  252. #endif /* NOSPL */
  253. #endif /* MAC */
  254.  
  255. #ifndef CCHMAXPATH
  256. #define CCHMAXPATH 257
  257. #endif /* CCHMAXPATH */
  258. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  259.  
  260. #ifdef TNCODE
  261. extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
  262. #endif /* TNCODE */
  263.  
  264. #ifndef NOKVERBS
  265. extern struct keytab kverbs[];          /* Table of \Kverbs */
  266. extern int nkverbs;                     /* Number of \Kverbs */
  267. #endif /* NOKVERBS */
  268.  
  269. #ifndef NOPUSH
  270. extern int nopush;
  271. #endif /* NOPUSH */
  272.  
  273. #ifdef CK_RECALL
  274. extern int cm_recall;
  275. #endif /* CK_RECALL */
  276.  
  277. extern char *ccntab[];
  278.  
  279. /* Printer stuff */
  280.  
  281. extern char *printername;
  282. extern int printpipe;
  283. #ifdef BPRINT
  284. extern int printbidi, pportparity, pportflow;
  285. extern long pportspeed;
  286. #endif /* BPRINT */
  287.  
  288. #ifdef OS2
  289. _PROTOTYP (int os2getcp, (void) );
  290. _PROTOTYP (int os2getcplist, (int *, int) );
  291. #ifdef OS2MOUSE
  292. extern int tt_mouse;
  293. #endif /* OS2MOUSE */
  294. extern int tt_update, tt_updmode, updmode, tt_utf8;
  295. #ifndef IKSDONLY
  296. extern int tt_status[];
  297. #endif /* IKSDONLY */
  298. #ifdef PCFONTS
  299. extern struct keytab term_font[];
  300. #else
  301. #ifdef KUI
  302. extern struct keytab * term_font;
  303. #endif /* KUI */
  304. #endif /* PCFONTS */
  305. extern int ntermfont, tt_font, tt_font_size;
  306. extern unsigned char colornormal, colorunderline, colorstatus,
  307.     colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  308.     colorreverse, colorcmd, coloritalic;
  309. extern int priority;
  310. extern struct keytab prtytab[];
  311. extern int nprty;
  312. char * cmdmac = NULL;
  313. #endif /* OS2 */
  314.  
  315. #ifdef VMS
  316. _PROTOTYP (int zkermini, (char *, int, char *) );
  317. #endif /* VMS */
  318.  
  319. extern long vernum;
  320. extern int inecho, insilence, inbufsize, nvars, inintr;
  321. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  322.  *cknetv, *clcmds;
  323. #ifdef OS2
  324. extern char *ckyv;
  325. #endif /* OS2 */
  326. #ifdef CK_AUTHENTICATION
  327. extern char * ckathv;
  328. #endif /* CK_AUTHENTICATION */
  329. #ifdef CK_SSL
  330. extern char * cksslv;
  331. #endif /* CK_SSL */
  332. #ifdef CK_ENCRYPTION
  333. #ifndef CRYPT_DLL
  334. extern char * ckcrpv;
  335. #endif /* CRYPT_DLL */
  336. #endif /* CK_ENCRYPTION */
  337.  
  338. #ifdef SSHBUILTIN
  339. extern char *cksshv;
  340. #ifdef SFTP_BUILTIN
  341. extern char *cksftpv;
  342. #endif /* SFTP_BUILTIN */
  343. #endif /* SSHBUILTIN */
  344.  
  345. #ifdef TNCODE
  346. extern char *cktelv;
  347. #endif /* TNCODE */
  348. #ifndef NOFTP
  349. #ifndef SYSFTP
  350. extern char * ckftpv;
  351. #endif /* SYSFTP */
  352. #endif /* NOFTP */
  353.  
  354. extern int srvidl;
  355.  
  356. #ifdef OS2
  357. extern char *ckonetv;
  358. extern int interm;
  359. #ifdef CK_NETBIOS
  360. extern char *ckonbiv;
  361. #endif /* CK_NETBIOS */
  362. #ifdef OS2MOUSE
  363. extern char *ckomouv;
  364. #endif /* OS2MOUSE */
  365. #endif /* OS2 */
  366.  
  367. #ifndef NOLOCAL
  368. extern char *connv;
  369. #endif /* NOLOCAL */
  370. #ifndef NODIAL
  371. extern char *dialv;
  372. #endif /* NODIAL */
  373. #ifndef NOSCRIPT
  374. extern char *loginv;
  375. extern int secho;
  376. #endif /* NOSCRIPT */
  377.  
  378. #ifndef NODIAL
  379. extern int nmdm, dirline;
  380. extern struct keytab mdmtab[];
  381. #endif /* NODIAL */
  382.  
  383. extern int network, nettype, ttnproto;
  384.  
  385. #ifdef OS2
  386. #ifndef NOTERM
  387. /* SET TERMINAL items... */
  388. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  389. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  390. extern char answerback[];
  391. extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
  392. extern int max_tt;
  393. #endif /* NOTERM */
  394. #endif /* OS2 */
  395.  
  396. _PROTOTYP( VOID shotrm, (void) );
  397. _PROTOTYP( int shofea, (void) );
  398.  
  399. #ifdef OS2
  400. extern int tt_rows[], tt_cols[];
  401. #else /* OS2 */
  402. extern int tt_rows, tt_cols;
  403. #endif /* OS2 */
  404. extern int cmd_rows, cmd_cols;
  405.  
  406. #ifdef CK_TMPDIR
  407. extern int f_tmpdir;                    /* Directory changed temporarily */
  408. extern char savdir[];                   /* Temporary directory */
  409. #endif /* CK_TMPDIR */
  410.  
  411. #ifndef NOLOCAL
  412. extern int tt_crd, tt_lfd, tt_escape;
  413. #endif /* NOLOCAL */
  414.  
  415. #ifndef NOCSETS
  416. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  417. extern struct keytab fcstab[];
  418. extern struct csinfo fcsinfo[];
  419. #ifndef MAC
  420. extern struct keytab ttcstab[];
  421. #endif /* MAC */
  422. #endif /* NOCSETS */
  423.  
  424. extern long speed;
  425.  
  426. #ifndef NOXMIT
  427. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  428. extern char xmitbuf[];
  429. #endif /* NOXMIT */
  430.  
  431. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  432.  
  433. #ifdef DCMDBUF
  434. extern char *cmdbuf, *atmbuf;           /* Command buffers */
  435. #ifndef NOSPL
  436. extern char *savbuf;                    /* Command buffers */
  437. #endif /* NOSPL */
  438. #else
  439. extern char cmdbuf[], atmbuf[];         /* Command buffers */
  440. #ifndef NOSPL
  441. extern char savbuf[];                   /* Command buffers */
  442. #endif /* NOSPL */
  443. #endif /* DCMDBUF */
  444.  
  445. extern char toktab[], ttname[], psave[];
  446. extern CHAR sstate, feol;
  447. extern int cmflgs, techo, repars, ncmd;
  448. extern struct keytab cmdtab[];
  449.  
  450. #ifndef NOSETKEY
  451. KEY *keymap;
  452. #ifndef OS2
  453. #define mapkey(x) keymap[x]
  454. #endif /* OS2 */
  455. MACRO *macrotab;
  456. _PROTOTYP( VOID shostrdef, (CHAR *) );
  457. #endif /* NOSETKEY */
  458.  
  459. extern int cmdlvl;
  460.  
  461. #ifndef NOSPL
  462. extern struct mtab *mactab;
  463. extern struct keytab mackey[];
  464. extern struct keytab vartab[], fnctab[], iftab[];
  465. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  466. #endif /* NOSPL */
  467.  
  468. FILE *tfile[MAXTAKE];                   /* TAKE file stack */
  469. char *tfnam[MAXTAKE];
  470. int tfline[MAXTAKE];
  471.  
  472. int topcmd = -1;                        /* cmdtab index of current command */
  473. int havetoken = 0;
  474. extern int dblquo;                      /* Doublequoting enabled */
  475.  
  476. #ifdef DCMDBUF                          /* Initialization filespec */
  477. char *kermrc = NULL;
  478. #else
  479. char kermrcb[KERMRCL];
  480. char *kermrc = kermrcb;
  481. #endif /* DCMDBUF */
  482.  
  483. int noherald = 0;
  484. int cm_retry = 1;                       /* Command retry enabled */
  485. xx_strp xxstring = zzstring;
  486.  
  487. #ifndef NOXFER
  488. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  489.   keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  490.   srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  491.   fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  492.  
  493. #ifdef CK_AUTODL
  494. extern int inautodl, cmdadl;
  495. #endif /* CK_AUTODL */
  496.  
  497. #ifndef NOSERVER
  498. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  499.   en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  500.   en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  501. #endif /* NOSERVER */
  502.  
  503. extern int atcapr,
  504.   atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  505.   attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  506.  
  507. #ifdef STRATUS
  508. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  509. #endif /* STRATUS */
  510.  
  511. #ifdef CK_PERMS
  512. extern int atlpri, atlpro, atgpri, atgpro;
  513. #endif /* CK_PERMS */
  514.  
  515. #ifdef CK_LOGIN
  516. extern char * anonfile;                 /* Anonymous login init file */
  517. extern char * anonroot;                 /* Anonymous file-system root */
  518. extern char * userfile;                 /* Forbidden user file */
  519. extern int isguest;                     /* Flag for anonymous user */
  520. #endif /* CK_LOGIN */
  521. #endif /* NOXFER */
  522.  
  523. #ifdef DCMDBUF
  524. int *xquiet = NULL;
  525. int *xvarev = NULL;
  526. #else
  527. int xquiet[CMDSTKL];
  528. int xvarev[CMDSTKL];
  529. #endif /* DCMDBUF */
  530.  
  531. char * prstring[CMDSTKL];
  532.  
  533. #ifndef NOSPL
  534.  
  535. extern long ck_alarm;
  536. extern char alrm_date[], alrm_time[];
  537.  
  538. /* Local declarations */
  539.  
  540. static int nulcmd = 0;                  /* Flag for next cmd to be ignored */
  541.  
  542. /* Definitions for predefined macros */
  543.  
  544. /* First, the single-line macros, installed with addmac()... */
  545.  
  546. /* IBM-LINEMODE macro */
  547. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  548.  
  549. /* FATAL macro */
  550. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  551.  
  552. #ifdef CK_SPEED
  553. #ifdef IRIX65
  554. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  555. #else
  556. #ifdef IRIX
  557. /* Because of bug in telnet server */
  558. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  559.  set pref cautious";
  560. #else
  561. #ifdef pdp11
  562. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  563. #else
  564. #ifdef BIGBUFOK
  565. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  566. #else
  567. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  568. #endif /* BIGBUFOK */
  569. #endif /* IRIX */
  570. #endif /* IRIX65 */
  571. #endif /* pdp11 */
  572. #ifdef pdp11
  573. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  574. #else
  575. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  576. #endif /* pdp11 */
  577. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  578. set reliable off, set clearchannel off";
  579. #else
  580. #ifdef BIGBUFOK
  581. #ifdef IRIX65
  582. char *m_fast = "set win 30, set rec pack 4000";
  583. #else
  584. #ifdef IRIX
  585. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  586. #else
  587. char *m_fast = "set win 30, set rec pack 4000";
  588. #endif /* IRIX */
  589. #endif /* IRIX65 */
  590. #else /* Not BIGBUFOK */
  591. char *m_fast = "set win 4, set rec pack 2200";
  592. #endif /* BIGBUFOK */
  593. char *m_cautious = "set win 4, set rec pack 1000";
  594. char *m_robust = "set win 1, set rec pack 90, set reliable off";
  595. #endif /* CK_SPEED */
  596.  
  597. #ifdef VMS
  598. char *m_purge = "run purge \\%*";
  599. #endif /* VMS */
  600.  
  601. #ifdef OS2
  602. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  603. #endif /* OS2 */
  604.  
  605. /* Now the multiline macros, defined with addmmac()... */
  606.  
  607. /* FOR macro for \%i-style loop variables (see dofor()...) */
  608.  
  609. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  610. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  611. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  612. "def break goto _..bot, def continue goto _..inc,",
  613. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  614. ""};
  615.  
  616. /* This is the FOR macro when the loop variable is itself a macro */
  617.  
  618. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  619. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  620. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  621. "def break goto _..bot, def continue goto _..inc,",
  622. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  623. ""};
  624.  
  625. /* WHILE macro */
  626. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  627. ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
  628. "_def break goto _..bot, _def continue goto _..inc,",
  629. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  630. ""};
  631.  
  632. /* SWITCH macro */
  633. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  634. "_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  635. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  636. ""};
  637.  
  638. /* XIF macro */
  639. char *xif_def[] = {
  640. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  641. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  642. ""};
  643.  
  644. /*
  645.   Variables declared here for use by other ckuus*.c modules.
  646.   Space is allocated here to save room in ckuusr.c.
  647. */
  648. #ifdef DCMDBUF
  649. struct cmdptr *cmdstk;
  650. int
  651.   *ifcmd  = NULL,
  652.   *count  = NULL,
  653.   *iftest = NULL,
  654.   *intime = NULL,
  655.   *inpcas = NULL,
  656.   *takerr = NULL,
  657.   *merror = NULL;
  658. #else
  659. struct cmdptr cmdstk[CMDSTKL];
  660. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  661.   inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  662. #endif /* DCMDBUF */
  663.  
  664. /* Macro stack */
  665.  
  666. #ifdef COMMENT
  667. char *topline = NULL;                   /* Program invocation arg line */
  668. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  669. #endif /* COMMENT */
  670.  
  671. char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
  672. int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
  673. char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
  674. int macargc[MACLEVEL];                  /* Argc of each level */
  675. char *macp[MACLEVEL];                   /* Current position in each macro */
  676. char *macx[MACLEVEL];                   /* Beginning of each macro def */
  677. char *mrval[MACLEVEL];                  /* RETURN value at each level */
  678. int lastcmd[MACLEVEL];                  /* Last command at each level */
  679. int topargc = 0;                        /* Argc at top level */
  680. char **topxarg = NULL;                  /* Argv at top level */
  681. char *toparg[MAXARGLIST+2];
  682.  
  683. /* Global Variables */
  684.  
  685. char *g_var[GVARS+1];                   /* Global \%a..z pointers */
  686. extern char varnam[];                   /* \%x variable name buffer */
  687.  
  688. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  689. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  690.  
  691. char **a_ptr[32];                       /* Array pointers, for arrays a-z */
  692. int a_dim[32];                          /* Dimensions for each array */
  693. int a_link[32];                         /* Link (index of linked-to-array) */
  694.  
  695. char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
  696. int aa_dim[CMDSTKL][32];                /* Dimensions for each array */
  697.  
  698. /* INPUT command buffers and variables */
  699.  
  700. char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
  701. extern char * inpbp;                    /* Global/static pointer to it  */
  702. char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
  703. int  incount = 0;                       /* INPUT character count */
  704. extern int instatus;                    /* INPUT status */
  705. static char * i_text[] = {              /* INPUT status text */
  706.     "success", "timeout", "interrupted", "internal error", "i/o error"
  707. };
  708.  
  709. char lblbuf[LBLSIZ];                    /* Buffer for labels */
  710.  
  711. #else  /* NOSPL */
  712.  
  713. int takerr[MAXTAKE];
  714. #endif /* NOSPL */
  715.  
  716. static char *prevdir = NULL;
  717.  
  718. int pacing = 0;                         /* OUTPUT pacing */
  719.  
  720. char *tp;                               /* Temporary buffer pointer */
  721.  
  722. int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */
  723.  
  724. #ifdef CK_APC                           /* Application Program Command (APC) */
  725. int apcactive = APC_INACTIVE;
  726. int apcstatus = APC_OFF;                /* OFF by default everywhere */
  727. #ifdef DCMDBUF
  728. char *apcbuf;
  729. #else
  730. char apcbuf[APCBUFLEN];
  731. #endif /* DCMDBUF */
  732. #endif /* CK_APC */
  733.  
  734. extern char pktfil[],
  735. #ifdef DEBUG
  736.   debfil[],
  737. #endif /* DEBUG */
  738. #ifdef TLOG
  739.   trafil[],
  740. #endif /* TLOG */
  741.   sesfil[];
  742.  
  743. #ifndef NOFRILLS
  744. extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
  745. extern char optbuf[];
  746. #endif /* NOFRILLS */
  747.  
  748. extern int noinit;            /* Flat to skip init file */
  749.  
  750. #ifndef NOSPL
  751. static struct keytab kcdtab[] = {    /* Symbolic directory names */
  752. #ifdef NT
  753.     { "appdata",  VN_APPDATA,   0 },
  754.     { "common",   VN_COMMON,    0 },
  755.     { "desktop",  VN_DESKTOP,   0 },
  756. #endif /* NT */
  757.     { "download", VN_DLDIR,     0 },
  758. #ifdef OS2ORUNIX
  759.     { "exedir",   VN_EXEDIR,    0 },
  760. #endif /* OS2ORUNIX */
  761.     { "home",     VN_HOME,      0 },
  762.     { "inidir",   VN_INI,       0 },
  763. #ifdef UNIX
  764.     { "lockdir",  VN_LCKDIR,    0 },
  765. #endif /* UNIX */
  766. #ifdef NT
  767.     { "my_documents",VN_PERSONAL,  0 },
  768.     { "personal", VN_PERSONAL,  CM_INV },
  769. #endif /* NT */
  770.     { "startup",  VN_STAR,      0 },
  771.     { "textdir",  VN_TXTDIR,    0 },
  772.     { "tmpdir",   VN_TEMP,      0 }
  773. };
  774. static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
  775. #endif /* NOSPL */
  776.  
  777. #ifndef NOSPL
  778. _PROTOTYP( VOID freelocal, (int) );
  779. _PROTOTYP( static CK_OFF_T expon, (CK_OFF_T, CK_OFF_T) );
  780. _PROTOTYP( static CK_OFF_T gcd, (CK_OFF_T, CK_OFF_T) );
  781. _PROTOTYP( static CK_OFF_T fact, (CK_OFF_T) );
  782.  
  783. int                     /* Initialize macro data structures. */
  784. macini() {              /* Allocate mactab and preset the first element. */
  785.     int i;
  786.     if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  787.       return(-1);
  788.     mactab[0].kwd = NULL;
  789.     mactab[0].mval = NULL;
  790.     mactab[0].flgs = 0;
  791.     for (i = 0; i < MACLEVEL; i++)
  792.       localhead[i] = NULL;
  793.     return(0);
  794. }
  795. #endif /* NOSPL */
  796.  
  797. /*  C M D S R C  --  Returns current command source  */
  798.  
  799. /*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  800.  
  801. /*
  802.   As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  803.   xcmdsrc can be checked instead to save the overhead of a function call.
  804. */
  805. int
  806. cmdsrc() {
  807. #ifdef COMMENT
  808.     return(xcmdsrc);
  809. #else
  810. #ifndef NOSPL
  811.     if (cmdlvl == 0)
  812.       return(0);
  813.     else if (cmdstk[cmdlvl].src == CMD_MD)
  814.       return(2);
  815.     else if (cmdstk[cmdlvl].src == CMD_TF)
  816.       return(1);
  817.     else
  818.       return(-1);
  819. #else
  820.     if (tlevel < 0)
  821.       return(0);
  822.     else
  823.       return(1);
  824. #endif /* NOSPL */
  825. #endif /* COMMENT */
  826. }
  827.  
  828. /*  C M D I N I  --  Initialize the interactive command parser  */
  829.  
  830. static int cmdinited = 0;               /* Command parser initialized */
  831. extern int cmdint;                      /* Interrupts are allowed */
  832. #ifdef CK_AUTODL
  833. int cmdadl = 1;                         /* Autodownload */
  834. #else
  835. int cmdadl = 0;
  836. #endif /* CK_AUTODL */
  837.  
  838. char * k_info_dir = NULL;               /* Where to find text files */
  839. #ifdef UNIX
  840. static char * txtdir[] = {
  841.     "/usr/local/doc/",                  /* Linux, SunOS, ... */
  842.     "/usr/share/lib/",                  /* HP-UX 10.xx... */
  843.     "/usr/share/doc/",                  /* Other possibilities... */
  844.     "/usr/local/lib/",                  /* NOTE: Each of these is tried */
  845.     "/usr/local/share/",                /* as is, and also with a kermit */
  846.     "/usr/local/share/doc/",            /* subdirectory. */
  847.     "/usr/local/share/lib/",
  848.     "/opt/kermit/",                     /* Solaris */
  849.     "/opt/kermit/doc/",
  850.     "/opt/",
  851.     "/usr/doc/",
  852.     "/doc/",
  853.     ""
  854. };
  855. #endif /* UNIX */
  856.  
  857. /*
  858.   lookup() cache to speed up script execution.
  859.  
  860.   This is a static cache.  Items are stored in decreasing frequency of
  861.   reference based on statistics from a range of scripts.  This gives
  862.   better performance than a dynamic cache, which would require a lot more
  863.   code and also would require system-dependent elements including system
  864.   calls (e.g. to get subsecond times for entry aging).
  865. */
  866. #ifdef USE_LUCACHE                      /* Set in ckuusr.h */
  867. #define LUCACHE 32                      /* Change this to reduce cache size */
  868. int lusize = 0;
  869. char * lucmd[LUCACHE];
  870. int luval[LUCACHE];
  871. int luidx[LUCACHE];
  872. struct keytab * lutab[LUCACHE];
  873. #endif /* USE_LUCACHE */
  874.  
  875. static VOID
  876. luinit() {                              /* Initialize lookup() cache */
  877.     int x, y;
  878.  
  879. #ifdef USE_LUCACHE
  880.     x = lookup(cmdtab,"if",ncmd,&y);
  881.     lucmd[lusize] = "if";
  882.     luval[lusize] = x;
  883.     luidx[lusize] = y;
  884.     lutab[lusize] = cmdtab;
  885.     if (++lusize > LUCACHE) return;
  886.  
  887.     x = lookup(iftab,"not",nif,&y);
  888.     lucmd[lusize] = "not";
  889.     luval[lusize] = x;
  890.     luidx[lusize] = y;
  891.     lutab[lusize] = iftab;
  892.     if (++lusize > LUCACHE) return;
  893.  
  894.     x = lookup(vartab,"cmdlevel",nvars,&y);
  895.     lucmd[lusize] = "cmdlevel";
  896.     luval[lusize] = x;
  897.     luidx[lusize] = y;
  898.     lutab[lusize] = vartab;
  899.     if (++lusize > LUCACHE) return;
  900.  
  901.     x = lookup(cmdtab,"goto",ncmd,&y);
  902.     lucmd[lusize] = "goto";
  903.     luval[lusize] = x;
  904.     luidx[lusize] = y;
  905.     lutab[lusize] = cmdtab;
  906.     if (++lusize > LUCACHE) return;
  907.  
  908.     x = lookup(iftab,">",nif,&y);
  909.     lucmd[lusize] = ">";
  910.     luval[lusize] = x;
  911.     luidx[lusize] = y;
  912.     lutab[lusize] = iftab;
  913.     if (++lusize > LUCACHE) return;
  914.  
  915.     x = lookup(cmdtab,"incr",ncmd,&y);
  916.     lucmd[lusize] = "incr";
  917.     luval[lusize] = x;
  918.     luidx[lusize] = y;
  919.     lutab[lusize] = cmdtab;
  920.     if (++lusize > LUCACHE) return;
  921.  
  922.     x = lookup(cmdtab,"def",ncmd,&y);
  923.     lucmd[lusize] = "def";
  924.     luval[lusize] = x;
  925.     luidx[lusize] = y;
  926.     lutab[lusize] = cmdtab;
  927.     if (++lusize > LUCACHE) return;
  928.  
  929.     x = lookup(cmdtab,"_assign",ncmd,&y);
  930.     lucmd[lusize] = "_assign";
  931.     luval[lusize] = x;
  932.     luidx[lusize] = y;
  933.     lutab[lusize] = cmdtab;
  934.     if (++lusize > LUCACHE) return;
  935.  
  936.     x = lookup(cmdtab,"echo",ncmd,&y);
  937.     lucmd[lusize] = "echo";
  938.     luval[lusize] = x;
  939.     luidx[lusize] = y;
  940.     lutab[lusize] = cmdtab;
  941.     if (++lusize > LUCACHE) return;
  942.  
  943.     x = lookup(fnctab,"eval",nfuncs,&y);
  944.     lucmd[lusize] = "eval";
  945.     luval[lusize] = x;
  946.     luidx[lusize] = y;
  947.     lutab[lusize] = fnctab;
  948.     if (++lusize > LUCACHE) return;
  949.  
  950.     x = lookup(fnctab,"lit",nfuncs,&y);
  951.     lucmd[lusize] = "lit";
  952.     luval[lusize] = x;
  953.     luidx[lusize] = y;
  954.     lutab[lusize] = fnctab;
  955.     if (++lusize > LUCACHE) return;
  956.  
  957.     x = lookup(cmdtab,"do",ncmd,&y);
  958.     lucmd[lusize] = "do";
  959.     luval[lusize] = x;
  960.     luidx[lusize] = y;
  961.     lutab[lusize] = cmdtab;
  962.     if (++lusize > LUCACHE) return;
  963.  
  964.     x = lookup(cmdtab,"_getargs",ncmd,&y);
  965.     lucmd[lusize] = "_getargs";
  966.     luval[lusize] = x;
  967.     luidx[lusize] = y;
  968.     lutab[lusize] = cmdtab;
  969.     if (++lusize > LUCACHE) return;
  970.  
  971.     x = lookup(iftab,"<",nif,&y);
  972.     lucmd[lusize] = "<";
  973.     luval[lusize] = x;
  974.     luidx[lusize] = y;
  975.     lutab[lusize] = iftab;
  976.     if (++lusize > LUCACHE) return;
  977.  
  978.     x = lookup(cmdtab,"_putargs",ncmd,&y);
  979.     lucmd[lusize] = "_putargs";
  980.     luval[lusize] = x;
  981.     luidx[lusize] = y;
  982.     lutab[lusize] = cmdtab;
  983.     if (++lusize > LUCACHE) return;
  984.  
  985.     x = lookup(cmdtab,"asg",ncmd,&y);
  986.     lucmd[lusize] = "asg";
  987.     luval[lusize] = x;
  988.     luidx[lusize] = y;
  989.     lutab[lusize] = cmdtab;
  990.     if (++lusize > LUCACHE) return;
  991.  
  992.     x = lookup(cmdtab,"else",ncmd,&y);
  993.     lucmd[lusize] = "else";
  994.     luval[lusize] = x;
  995.     luidx[lusize] = y;
  996.     lutab[lusize] = cmdtab;
  997. #endif /* USE_LUCACHE */
  998. }
  999.  
  1000. VOID
  1001. cmdini() {
  1002.     int i = 0, x = 0, y = 0, z = 0, skip = 0;
  1003.     char * p;
  1004. #ifdef TTSPDLIST
  1005.     long * ss = NULL;
  1006.     extern int nspd;
  1007.     extern struct keytab * spdtab;
  1008. #endif /* TTSPDLIST */
  1009.  
  1010. #ifndef NOSPL
  1011. /*
  1012.   On stack to allow recursion!
  1013. */
  1014.     char vnambuf[VNAML];                /* Buffer for variable names */
  1015. #endif /* NOSPL */
  1016.  
  1017.     if (cmdinited)                      /* Already initialized */
  1018.       return;                           /* Don't do it again */
  1019.  
  1020.     for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
  1021.       prstring[i] = NULL;               /* command level */
  1022.  
  1023. #ifndef NOCSETS
  1024.     p = getenv("K_CHARSET");            /* Set default file character set */
  1025.     if (p) {                            /* from environment */
  1026.         x = lookup(fcstab,p,nfilc,&y);
  1027.         if (x > -1)
  1028.           fcharset = x;
  1029.     }
  1030. #endif /* NOCSETS */
  1031.  
  1032.     p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
  1033.     if (p && *p && strlen(p) <= CKMAXPATH)
  1034.       makestr(&k_info_dir,p);
  1035.     if (!k_info_dir) {
  1036.         p = getenv("K_INFO_DIR");
  1037.         if (p && *p && strlen(p) <= CKMAXPATH)
  1038.           makestr(&k_info_dir,p);
  1039.     }
  1040. #ifdef UNIX
  1041.     if (k_info_dir) {                   /* Look for Kermit docs directory */
  1042.         if (zchki(k_info_dir) == -2) {
  1043.             char xbuf[CKMAXPATH+32], *s = "";
  1044.             if (ckrchar(k_info_dir) != '/')
  1045.               s = "/";
  1046.             ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  1047.             if (zchki(xbuf) < 0)
  1048.               makestr(&k_info_dir,NULL);
  1049.         }
  1050.     }
  1051.     if (!k_info_dir) {
  1052.         char xbuf[CKMAXPATH+32];
  1053.         int i;
  1054.         for (i = 0; *(txtdir[i]); i++) {
  1055.             ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  1056.             if (zchki(xbuf) > 0) {
  1057.                 makestr(&k_info_dir,txtdir[i]);
  1058.                 debug(F110,"k_info_dir 1",k_info_dir,0);
  1059.                 break;
  1060.             }
  1061.             ckmakmsg(xbuf,CKMAXPATH+32,
  1062.                      txtdir[i],"kermit/","ckubwr.txt",NULL);
  1063.             if (zchki(xbuf) > 0) {
  1064.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  1065.                 makestr(&k_info_dir,xbuf);
  1066.                 debug(F110,"k_info_dir 2",k_info_dir,0);
  1067.                 break;
  1068.             }
  1069.             ckmakmsg(xbuf,CKMAXPATH+32,
  1070.                      txtdir[i],"ckermit/","ckubwr.txt",NULL);
  1071.             if (zchki(xbuf) > 0) {
  1072.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
  1073.                 makestr(&k_info_dir,xbuf);
  1074.                 debug(F110,"k_info_dir 3",k_info_dir,0);
  1075.                 break;
  1076.             }
  1077.         }
  1078.         if (k_info_dir) {               /* Make sure it ends with "/" */
  1079.             if (ckrchar(k_info_dir) != '/') {
  1080.                 char xbuf[CKMAXPATH+32];
  1081.                 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1082.                 makestr(&k_info_dir,xbuf);
  1083.             }
  1084.         }
  1085.     }
  1086. #else
  1087. #ifdef OS2
  1088.     {
  1089.         char xdir[CKMAXPATH+8], *s = "";
  1090.         extern char startupdir[];
  1091.         xdir[0] = NUL;
  1092.         if (ckrchar(startupdir) != '/')
  1093.           s = "/";
  1094.         if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1095.           ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1096.         makestr(&k_info_dir,xdir);
  1097.     }
  1098. #endif /* OS2 */
  1099. #endif /* UNIX */
  1100.  
  1101. #ifdef TTSPDLIST
  1102.     if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1103.         int j, k, m = 0, n;             /* Create sorted keyword table */
  1104.         char buf[16];
  1105.         char * p;
  1106.         if ((spdtab =
  1107.              (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1108.             for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1109.                 if (ss[i] < 1L) break;     /* Shouldn't happen */
  1110.                 buf[0] = NUL;              /* Make string */
  1111.                 sprintf(buf,"%ld",ss[i]);  /* SAFE */
  1112.                 if (ss[i] == 8880L)
  1113.                   ckstrncpy(buf,"75/1200",sizeof(buf));
  1114.                 if (ss[i] == 134L)
  1115.                   ckstrncat(buf,".5",16);
  1116.                 n = strlen(buf);
  1117.                 if ((n > 0) && (p = (char *)malloc(n+1))) {
  1118.                     if (m > 0) {        /* Have at least one in list */
  1119.                         for (j = 0;     /* Find slot */
  1120.                              j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1121.                              j++
  1122.                              )
  1123.                           ;
  1124.                         if (j < m) {    /* Must insert */
  1125.                             for (k = m-1; k >= j; k--) { /* Move others down */
  1126.                                 spdtab[k+1].kwd = spdtab[k].kwd;
  1127.                                 spdtab[k+1].flgs = spdtab[k].flgs;
  1128.                                 spdtab[k+1].kwval = spdtab[k].kwval;
  1129.                             }
  1130.                         }
  1131.                     } else              /* First one */
  1132.                       j = 0;
  1133.                     ckstrncpy(p,buf,n+1); /* Add new speed */
  1134.                     spdtab[j].kwd = p;
  1135.                     spdtab[j].flgs = 0;
  1136.                     spdtab[j].kwval = (int) ss[i] / 10;
  1137.                     m++;                /* Count this one */
  1138.                 }
  1139.             }
  1140.         }
  1141.         nspd = m;
  1142.     }
  1143. #endif /* TTSPDLIST */
  1144.  
  1145. #ifndef NOSPL
  1146.     /* Allocate INPUT command buffer */
  1147.     if (!inpbuf) {
  1148.         if (!(inpbuf = (char *) malloc(INPBUFSIZ+8)))
  1149.           fatal("cmdini: no memory for INPUT buffer");
  1150.     }
  1151.     for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
  1152.       inpbuf[x] = NUL;
  1153.     inpbp = inpbuf;                     /* Initialize pointer */
  1154.     inbufsize = INPBUFSIZ;              /* and size. */
  1155. #endif /* NOSPL */
  1156.  
  1157. #ifdef DCMDBUF
  1158.     if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1159.  
  1160. #ifndef NOSPL
  1161.     /* Allocate command stack allowing command parser to call itself */
  1162.  
  1163.     if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1164.       fatal("cmdini: no memory for cmdstk");
  1165.     if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1166.       fatal("cmdini: no memory for ifcmd");
  1167.     if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1168.       fatal("cmdini: no memory for count");
  1169.     if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1170.       fatal("cmdini: no memory for iftest");
  1171.     if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1172.       fatal("cmdini: no memory for intime");
  1173.     if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1174.       fatal("cmdini: no memory for inpcas");
  1175.     if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1176.       fatal("cmdini: no memory for takerr");
  1177.     if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1178.       fatal("cmdini: no memory for merror");
  1179.     if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1180.       fatal("cmdini: no memory for xquiet");
  1181.     if (!(xvarev = (int *) malloc(sizeof(int)*CMDSTKL)))
  1182.       fatal("cmdini: no memory for xvarev");
  1183.     if (!kermrc)
  1184.       if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1185.         fatal("cmdini: no memory for kermrc");
  1186. #ifdef CK_APC
  1187. /* Application Program Command buffer */
  1188.     if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1189.         fatal("cmdini: no memory for apcbuf");
  1190. #endif /* CK_APC */
  1191. #endif /* NOSPL */
  1192.  
  1193. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1194.  
  1195.     if (!(line = malloc(LINBUFSIZ + 1)))
  1196.         fatal("cmdini: no memory for line");
  1197.     if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1198.         fatal("cmdini: no memory for tmpbuf");
  1199. #endif /* DCMDBUF */
  1200.  
  1201. #ifndef NOSPL
  1202. #ifdef CK_MINPUT
  1203.     {                                   /* Initialize MINPUT pointers */
  1204.         int i;
  1205.         extern char *ms[];
  1206.         for (i = 0; i < MINPMAX; i++)
  1207.           ms[i] = NULL;
  1208.     }
  1209. #endif /* CK_MINPUT */
  1210.  
  1211.     if (macini() < 0)                   /* Allocate macro buffers */
  1212.       fatal("Can't allocate macro buffers!");
  1213.  
  1214.     ifcmd[0] = 0;                       /* Command-level related variables. */
  1215.     iftest[0] = 0;                      /* Initialize variables at top level */
  1216.     count[0] = 0;                       /* of stack... */
  1217.     intime[0] = 0;
  1218.     inpcas[0] = 0;
  1219.     takerr[0] = 0;
  1220.     merror[0] = 0;
  1221.     xquiet[0] = quiet;
  1222.     xvarev[0] = vareval;
  1223. #endif /* NOSPL */
  1224.  
  1225. #ifndef NOSPL
  1226.     cmdlvl = 0;                         /* Initialize the command stack */
  1227.     xcmdsrc = CMD_KB;
  1228.     cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
  1229.     cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
  1230.     cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
  1231. #endif /* NOSPL */
  1232.  
  1233.     tlevel = -1;                        /* Take file level = keyboard */
  1234.     for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
  1235.       tfnam[i] = NULL;
  1236.  
  1237.     cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
  1238.                                         /* Can't set IKSD prompt here since */
  1239.                                         /* we do not yet know if we are IKSD */
  1240. #ifndef NOSPL
  1241.  
  1242.     initmac();                          /* Initialize macro table */
  1243.  
  1244. /* Predefine built-in one-line macros */
  1245.  
  1246.     addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
  1247.     addmac("fatal",m_fat);              /* FATAL macro */
  1248.     y = addmac("fast",m_fast);          /* FAST macro */
  1249.     addmac("cautious",m_cautious);      /* CAUTIOUS macro */
  1250.     addmac("robust",m_robust);          /* ROBUST macro */
  1251. #ifdef OS2
  1252.     addmac("manual",m_manual);          /* MANUAL macro */
  1253. #endif /* OS2 */
  1254. #ifdef VMS
  1255.     addmac("purge",m_purge);            /* PURGE macro */
  1256. #endif /* VMS */
  1257.  
  1258. /*
  1259.   Predefine built-in multiline macros; these are top-level commands
  1260.   that are implemented internally as macros.  NOTE: When adding a new
  1261.   one of these, remember to update the END and RETURN commands to
  1262.   account for it, or else END and RETURN from within it won't work right.
  1263. */
  1264.     x = addmmac("_forx",for_def);       /* FOR macro */
  1265.     if (x > -1) mactab[x].flgs = CM_INV;
  1266.     x = addmmac("_forz",foz_def);       /* Other FOR macro */
  1267.     if (x > -1) mactab[x].flgs = CM_INV;
  1268.     x = addmmac("_xif",xif_def);        /* XIF macro */
  1269.     if (x > -1) mactab[x].flgs = CM_INV;
  1270.     x = addmmac("_while",whil_def);     /* WHILE macro */
  1271.     if (x > -1) mactab[x].flgs = CM_INV;
  1272.     x = addmmac("_switx",sw_def);       /* SWITCH macro */
  1273.     if (x > -1) mactab[x].flgs = CM_INV;
  1274.  
  1275. /* Fill in command-line argument vector */
  1276.  
  1277.     sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
  1278.     if (inserver) {                     /* But hidden in IKSD */
  1279.         y = -1;
  1280.         xargs = 0;
  1281.     } else
  1282.       y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */
  1283.  
  1284.     tmpbuf[0] = NUL;
  1285.     if (y > -1) {
  1286.         int j = -1;
  1287.         int yy = 0;
  1288.         dclarray((char)x,z);            /* Declare the array */
  1289. #ifndef NOTAKEARGS
  1290.         /* Macro argument vector */
  1291.         sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
  1292.         yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
  1293.         if (yy > -1)                    /* Name is OK */
  1294.           dclarray((char)x,z);          /* Declare the array */
  1295. #endif /* NOTAKEARGS */
  1296.         skip = 0;
  1297.         for (i = 0; i < xargs; i++) {   /* Fill the arrays */
  1298.             sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1299.             addmac(vnambuf,xargv[i]);
  1300.             if (cfilef && i == 0)
  1301.               continue;
  1302. #ifdef KERBANG
  1303.             if (skip) {
  1304.                 j = 0;
  1305.                 skip = 0;
  1306.                 continue;
  1307.             }
  1308. #endif /* KERBANG */
  1309.             if (j < 0 &&                /* Assign items after "=" or "--"*/
  1310.                 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1311.                 ) {
  1312.                 j = 0;                  /* to \%1..\%9 */
  1313. #ifdef KERBANG
  1314.             } else if (j < 0 &&
  1315.                        (!strcmp(xargv[i],"+") ||
  1316.                         !strncmp(xargv[i],"+ ",2) ||
  1317.                         !strncmp(xargv[i],"+\t",2))
  1318.                         ) {
  1319.                 skip = 1;
  1320.                 continue;
  1321. #endif /* KERBANG */
  1322.             } else if (j > -1) {
  1323.                 j++;
  1324.                 if (j <= 9) {
  1325.                     vnambuf[0] = '\\';
  1326.                     vnambuf[1] = '%';
  1327.                     vnambuf[2] = (char)(j+'0');
  1328.                     vnambuf[3] = NUL;
  1329.                     addmac(vnambuf,xargv[i]);
  1330.                 }
  1331.                 if (yy > -1) {
  1332.                     char c, * p;
  1333.                     int flag = 0;
  1334.                     p = xargv[i];
  1335.                     makestr(&(toparg[j]),p);
  1336.                     while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1337.                     if (flag)
  1338.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1339.                     ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1340.                     if (flag)
  1341.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1342.                     ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1343.                 }
  1344.             }
  1345.         }
  1346.         if (cfilef) {
  1347.             addmac("\\%0",cmdfil);
  1348.             if (yy > -1)
  1349.               makestr(&(toparg[0]),cmdfil);
  1350.         } else {
  1351.             addmac("\\%0",xargv[0]);
  1352.             if (yy > -1)
  1353.               makestr(&(toparg[0]),xargv[0]);
  1354.         }
  1355.         if (yy > -1) {
  1356.             topargc = (j < 0) ? 1 : j + 1;
  1357.             topxarg = toparg;
  1358. #ifdef COMMENT
  1359.             /* This needs work */
  1360.             if (!cfilef)
  1361.               makestr(&topline,tmpbuf);
  1362. #endif /* COMMENT */
  1363.         } else {
  1364.             topargc = 0;
  1365.             topxarg = NULL;
  1366.         }
  1367.         a_dim[0] = topargc - 1;
  1368.         a_ptr[0] = topxarg;
  1369.     debug(F111,"a_dim[0]","A",a_dim[0]);
  1370.     }
  1371.     *vnambuf = NUL;
  1372. #endif /* NOSPL */
  1373.  
  1374.     luinit();                           /* Initialize lookup() cache */
  1375.  
  1376. /* Get our home directory now.  This needed in lots of places. */
  1377.  
  1378.     cmdinited = 1;
  1379. }
  1380.  
  1381. #ifdef NT
  1382. _PROTOTYP(char * GetAppData,(int));
  1383. #endif /* NT */
  1384.  
  1385. VOID
  1386. doinit() {
  1387. #ifdef CKROOT
  1388. extern int ckrooterr;
  1389. #endif /* CKROOT */
  1390.     int x = 0, ok = 0;
  1391. #ifdef OS2
  1392.     char * ptr = 0;
  1393. #endif /* OS2 */
  1394.  
  1395.     if (!cmdinited)
  1396.       cmdini();
  1397.  
  1398. #ifdef MAC
  1399.     return;                             /* Mac Kermit has no init file */
  1400.  
  1401. #else /* !MAC */
  1402.  
  1403. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1404.  
  1405.     if (noinit) {
  1406.         kermrc[0] = '\0';
  1407.         inidir[0] = '\0';
  1408. /*
  1409.   But returning from here results in inidir[] never being set to anything.
  1410.   Instead it should be set to wherever the init file *would* have been
  1411.   executed from.  So this bit of code should be removed, and then we should
  1412.   sprinkle "if (noinit)" tests throughout the following code until we have
  1413.   set inidir[], and then return without actually taking the init file.
  1414. */
  1415.         return;
  1416.     }
  1417.  
  1418. #ifdef OS2
  1419. /*
  1420.   The -y init file must be fully specified or in the current directory.
  1421.   KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  1422.   own executable file path is taken and the .EXE suffix is replaced by .INI
  1423.   and this is tried as the initialization file.
  1424. */
  1425. #ifdef CK_LOGIN
  1426.     debug(F101,"doinit inserver","",inserver);
  1427.     debug(F101,"doinit isguest","",isguest);
  1428.     debug(F110,"doinit anonfile",anonfile,0);
  1429.  
  1430.     if (isguest && anonfile) {
  1431.       ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1432.     } else
  1433. #endif /* CK_LOGIN */
  1434.       if (rcflag) {
  1435.           ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1436. #ifdef CK_LOGIN
  1437.       } else if (inserver) {
  1438.           char * appdata = NULL;
  1439. #ifdef NT
  1440.           appdata = GetAppData(1);
  1441.           if ( appdata ) {
  1442.               ckmakmsg(line,LINBUFSIZ+1,appdata,
  1443.                         "Kermit 95/k95.ini",NULL,NULL);
  1444.               if ( zchki(line) < 0 )
  1445.                   line[0] = '\0';
  1446.           }
  1447.           if (line[0] == 0) {
  1448.               appdata = GetAppData(0);
  1449.               if ( appdata ) {
  1450.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1451.                             "Kermit 95/k95.ini",NULL,NULL);
  1452.                   if ( zchki(line) < 0 )
  1453.                       line[0] = '\0';
  1454.               }
  1455.           }
  1456. #endif /* NT */
  1457.           if (line[0] == 0) {
  1458.               appdata = zhome();
  1459.               if ( appdata ) {
  1460.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1461. #ifdef NT
  1462.                           "k95.ini",
  1463. #else /* NT */
  1464.                           "k2.ini",
  1465. #endif /* NT */
  1466.                            NULL,NULL);
  1467.                   if ( zchki(line) < 0 )
  1468.                       line[0] = '\0';
  1469.               }
  1470.           }
  1471.           debug(F110,"doinit inserver inifile",line,0);
  1472. #endif /* CK_LOGIN */
  1473.     } else {
  1474.         char * env = 0;
  1475. #ifdef NT
  1476.         env = getenv("K95.KSC");
  1477. #else
  1478.         env = getenv("K2.KSC");
  1479. #endif /* NT */
  1480.         if (!env) {
  1481. #ifdef NT
  1482.             env = getenv("K95.INI");
  1483. #else
  1484.             env = getenv("K2.INI");
  1485. #endif /* NT */
  1486.         }
  1487.         if (!env)
  1488.           env = getenv("CKERMIT.INI");
  1489.         if (!env)
  1490.           env = getenv("CKERMIT_INI");
  1491.         line[0] = '\0';
  1492.  
  1493.         debug(F110,"doinit env",env,0);
  1494.         if (env)
  1495.           ckstrncpy(line,env,LINBUFSIZ+1);
  1496.  
  1497. #ifdef NT
  1498.         if (line[0] == 0) {
  1499.             env = GetAppData(1);
  1500.             if ( env ) {
  1501.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1502.                 if ( zchki(line) < 0 )
  1503.                     line[0] = '\0';
  1504.             }
  1505.         }
  1506.         if (line[0] == 0) {
  1507.             env = GetAppData(0);
  1508.             if ( env ) {
  1509.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1510.                 if ( zchki(line) < 0 )
  1511.                     line[0] = '\0';
  1512.             }
  1513.         }
  1514. #endif /* NT */
  1515.  
  1516.         if (line[0] == 0) {
  1517.             env = zhome();
  1518.             if ( env ) {
  1519.                 ckmakmsg(line,LINBUFSIZ+1,env,
  1520. #ifdef NT
  1521.                           "k95.ini",
  1522. #else /* NT */
  1523.                           "k2.ini",
  1524. #endif /* NT */
  1525.                           NULL,NULL);
  1526.                 if ( zchki(line) < 0 )
  1527.                     line[0] = '\0';
  1528.             }
  1529.         }
  1530.  
  1531.         if (line[0] == 0)
  1532.           _searchenv(kermrc,"INIT",line);
  1533.         if (line[0] == 0)
  1534.           _searchenv(kermrc,"DPATH",line);
  1535.         if (line[0] == 0)
  1536.           _searchenv(kermrc,"PATH",line);
  1537.         if (line[0] == 0) {
  1538.             char *pgmptr = GetLoadPath();
  1539.             if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1540.                 lp = strrchr(pgmptr, '\\');
  1541.                 if (lp) {
  1542.                     strncpy(line, pgmptr, lp - pgmptr);
  1543. #ifdef NT
  1544.                     strcpy(line + (lp - pgmptr), "/k95.ini");
  1545. #else /* NT */
  1546.                     strcpy(line + (lp - pgmptr), "/k2.ini");
  1547. #endif /* NT */
  1548.                 } else {
  1549.                     lp = strrchr(pgmptr, '.');
  1550.                     if (lp) {
  1551.                         strncpy(line, pgmptr, lp - pgmptr);
  1552.                         strcpy(line + (lp - pgmptr), ".ini");
  1553.                     }
  1554.                 }
  1555.             }
  1556.         }
  1557.     }
  1558.  
  1559. #ifdef CKROOT
  1560.     if (!zinroot(line)) {
  1561.         debug(F110,"doinit setroot violation",line,0);
  1562.         return;
  1563.     }
  1564. #endif /* CKROOT */
  1565.  
  1566.     debug(F110,"doinit fopen()",line,0);
  1567.     if ((tfile[0] = fopen(line,"r")) != NULL) {
  1568.         ok = 1;
  1569.         tlevel = 0;
  1570.         tfline[tlevel] = 0;
  1571.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1572.           strcpy(tfnam[tlevel],line);   /* safe */
  1573. #ifndef NOSPL
  1574.         cmdlvl++;
  1575.         xcmdsrc = CMD_TF;
  1576.         cmdstk[cmdlvl].src = CMD_TF;
  1577.         cmdstk[cmdlvl].lvl = tlevel;
  1578.         cmdstk[cmdlvl].ccflgs = 0;
  1579.         ifcmd[cmdlvl] = 0;
  1580.         iftest[cmdlvl] = 0;
  1581.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1582.         intime[cmdlvl] = intime[cmdlvl-1];
  1583.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1584.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1585.         merror[cmdlvl] = merror[cmdlvl-1];
  1586.         xquiet[cmdlvl] = quiet;
  1587.         xvarev[cmdlvl] = vareval;
  1588. #endif /* NOSPL */
  1589.         debug(F110,"doinit init file",line,0);
  1590.     } else {
  1591.         debug(F100,"doinit no init file","",0);
  1592.     }
  1593.     ckstrncpy(kermrc,line,KERMRCL);
  1594.     for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
  1595.        if (*ptr == '\\')
  1596.          *ptr = '/';
  1597. #else /* not OS2 */
  1598.     lp = line;
  1599.     lp[0] = '\0';
  1600.     debug(F101,"doinit rcflag","",rcflag);
  1601. #ifdef GEMDOS
  1602.     zkermini(line, rcflag, kermrc);
  1603. #else
  1604. #ifdef VMS
  1605.     {
  1606.     int x;
  1607.     x = zkermini(line,LINBUFSIZ,kermrc);
  1608.     debug(F111,"CUSTOM zkermini",line,x);
  1609.     if (x == 0)
  1610.       line[0] = NUL;
  1611.     }
  1612. #else /* not VMS */
  1613. #ifdef CK_LOGIN
  1614.     debug(F101,"doinit isguest","",isguest);
  1615.     if (isguest)
  1616.       ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1617.     else
  1618. #endif /* CK_LOGIN */
  1619.       if (rcflag) {                     /* If init file name from cmd line */
  1620.           ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1621.       } else {                          /* otherwise... */
  1622. #ifdef CK_INI_A                         /* If we've a system-wide init file */
  1623.           /* And it takes precedence over the user's... */
  1624.           ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1625.           if (zchki(lp) < 0) {          /* (if it exists...) */
  1626. #endif /* CK_INI_A */
  1627.               char * homdir;
  1628.               char * env = 0;
  1629.               line[0] = NUL;
  1630.  
  1631.               /* Add support for environment variable */
  1632.               env = getenv("CKERMIT.INI");
  1633.               if (!env)
  1634.                 env = getenv("CKERMIT_INI");
  1635.               if (env)
  1636.                 ckstrncpy(lp,env,KERMRCL);
  1637.  
  1638.               if (lp[0] == 0) {
  1639.                   homdir = zhome();
  1640.                   if (homdir) {         /* Home directory for init file. */
  1641.                       ckstrncpy(lp,homdir,KERMRCL);
  1642. #ifdef STRATUS
  1643.                       ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1644. #else
  1645.                       if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1646. #endif /* STRATUS */
  1647.                   }
  1648.                   ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1649.               }
  1650. #ifdef CK_INI_A
  1651.           }
  1652. #endif /* CK_INI_A */
  1653. #ifdef CK_INI_B                         /* System-wide init defined? */
  1654.           /* But user's ini file takes precedence */
  1655.           if (zchki(lp) < 0)            /* If user doesn't have her own, */
  1656.             ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1657. #endif /* CK_INI_B */
  1658.       }
  1659. #endif /* VMS */
  1660. #endif /* GEMDOS */
  1661.  
  1662. #ifdef AMIGA
  1663.     reqoff();                           /* Disable requestors */
  1664. #endif /* AMIGA */
  1665.  
  1666. #ifdef USE_CUSTOM
  1667.     /* If no init file was found, execute the customization file */
  1668.     debug(F111,"CUSTOM 1",line,rcflag);
  1669.     if ((!line[0] || zchki(line) < 0) && !rcflag) {
  1670.     int x;
  1671. #ifdef OS2
  1672.     x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1673.     debug(F111,"CUSTOM 2",line,x);
  1674.     if (zchki(line) < 0) {
  1675.         x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1676.         debug(F111,"CUSTOM 3",line,x);
  1677.     }
  1678. #else  /* OS2 */
  1679.     x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1680. #ifndef VMS
  1681.     /* VMS zhome() returns "SYS$LOGIN:" */
  1682.     if (line[x-1] != DIRSEP) {
  1683.         line[x++] = DIRSEP;
  1684.         line[x] = NUL;
  1685.     }
  1686. #endif /* VMS */
  1687.     x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1688.     debug(F111,"CUSTOM 4",line,x);
  1689. #endif /* OS2 */
  1690.     }
  1691.     debug(F110,"CUSTOM 5",line,0);
  1692. #endif /* USE_CUSTOM */
  1693.  
  1694. #ifdef CKROOT
  1695.     if (!zinroot(line)) {
  1696.         debug(F110,"doinit setroot violation",line,0);
  1697.         return;
  1698.     }
  1699. #endif /* CKROOT */
  1700.  
  1701.     debug(F110,"doinit ini file is",line,0);
  1702.     if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1703.         ok = 1;
  1704.         tlevel = 0;
  1705.         tfline[tlevel] = 0;
  1706.         if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1707.           strcpy(tfnam[tlevel],line);   /* safe */
  1708.  
  1709.         ckstrncpy(kermrc,line,KERMRCL);
  1710.  
  1711. #ifndef NOSPL
  1712.         cmdlvl++;
  1713.         ifcmd[cmdlvl] = 0;
  1714.         iftest[cmdlvl] = 0;
  1715.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1716.         intime[cmdlvl] = intime[cmdlvl-1];
  1717.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1718.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1719.         merror[cmdlvl] = merror[cmdlvl-1];
  1720.         xquiet[cmdlvl] = quiet;
  1721.         xvarev[cmdlvl] = vareval;
  1722.         debug(F101,"doinit open ok","",cmdlvl);
  1723.         xcmdsrc = CMD_TF;
  1724.         cmdstk[cmdlvl].src = CMD_TF;
  1725.         cmdstk[cmdlvl].lvl = tlevel;
  1726.         cmdstk[cmdlvl].ccflgs = 0;
  1727. #endif /* NOSPL */
  1728.     } else if (rcflag) {
  1729.         /* Print an error message only if a specific file was asked for. */
  1730.         printf("?%s - %s\n", ck_errstr(), line);
  1731.     }
  1732.  
  1733. #ifdef datageneral
  1734. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1735.     if (/* homdir && */ (tlevel < 0)) {
  1736.         ckstrncpy(lp,kermrc,LINBUFSIZ);
  1737.         if ((tfile[0] = fopen(line,"r")) != NULL) {
  1738.             ok = 1;
  1739.             tlevel = 0;
  1740.             tfline[tlevel] = 0;
  1741.             if (tfnam[tlevel] = malloc(strlen(line)+1))
  1742.               strcpy(tfnam[tlevel],line); /* safe */
  1743. #ifndef NOSPL
  1744.             cmdlvl++;
  1745.             xcmdsrc = CMD_TF;
  1746.             cmdstk[cmdlvl].src = CMD_TF;
  1747.             cmdstk[cmdlvl].lvl = tlevel;
  1748.             cmdstk[cmdlvl].ccflgs = 0;
  1749.             ifcmd[cmdlvl] = 0;
  1750.             iftest[cmdlvl] = 0;
  1751.             count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1752.             intime[cmdlvl] = intime[cmdlvl-1];
  1753.             inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1754.             takerr[cmdlvl] = takerr[cmdlvl-1];
  1755.             merror[cmdlvl] = merror[cmdlvl-1];
  1756.             xquiet[cmdlvl] = quiet;
  1757.         xvarev[cmdlvl] = vareval;
  1758. #endif /* NOSPL */
  1759.         }
  1760.     }
  1761. #endif /* datageneral */
  1762.  
  1763. #ifdef AMIGA                            /* Amiga... */
  1764.     reqpop();                           /* Restore requestors */
  1765. #endif /* AMIGA */
  1766. #endif /* OS2 */
  1767. #endif /* MAC */
  1768.  
  1769.     /* Assign value to inidir */
  1770.  
  1771.     if (!ok) {
  1772.         inidir[0] = NUL;
  1773.     } else {
  1774.         ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1775.         x = strlen(inidir);
  1776.         if (x > 0) {
  1777.             int i;
  1778.             for (i = x - 1; i > 0; i-- ) {
  1779.                 if (ISDIRSEP(inidir[i])) {
  1780.                     inidir[i+1] = NUL;
  1781.                     break;
  1782.                 }
  1783.             }
  1784.         }
  1785. #ifdef NT
  1786.         GetShortPathName(inidir,inidir,CCHMAXPATH);
  1787. #endif /* NT */
  1788.     }
  1789. }
  1790.  
  1791. VOID
  1792. doiksdinit() {
  1793. #ifdef CK_SSL
  1794.     /* IKSD doesn't request client certs */
  1795.     ssl_verify_flag = SSL_VERIFY_NONE;
  1796. #endif /* CK_SSL */
  1797.  
  1798.     if (!cmdinited)
  1799.       cmdini();
  1800.  
  1801. #ifdef IKSDCONF
  1802. #ifdef OS2
  1803.     line[0] = '\0';
  1804.     _searchenv(iksdconf,"INIT",line);
  1805.     if (line[0] == 0)
  1806.       _searchenv(iksdconf,"DPATH",line);
  1807.     if (line[0] == 0)
  1808.       _searchenv(iksdconf,"PATH",line);
  1809.     if (line[0] == 0) {
  1810.         char *pgmptr = GetLoadPath();
  1811.         if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1812.             lp = strrchr(pgmptr, '\\');
  1813.             if (lp) {
  1814.                 strncpy(line, pgmptr, lp - pgmptr);
  1815.                 strcpy(line + (lp - pgmptr), "\\");
  1816.                 strcpy(line + (lp - pgmptr + 1), iksdconf);
  1817.             } else {
  1818.                 lp = strrchr(pgmptr, '.');
  1819.                 if (lp) {
  1820.                     strncpy(line, pgmptr, lp - pgmptr);
  1821.                     strcpy(line + (lp - pgmptr), ".ksc");
  1822.                 }
  1823.             }
  1824.         }
  1825.     }
  1826.     debug(F110,"doiksdinit() line",line,0);
  1827.     tfile[0] = fopen(line,"r");
  1828. #else /* OS2 */
  1829.     tfile[0] = fopen(iksdconf,"r");
  1830. #endif /* OS2 */
  1831.     if (tfile[0] != NULL) {
  1832.         tlevel = 0;
  1833.         tfline[tlevel] = 0;
  1834. #ifdef OS2
  1835.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1836.           strcpy(tfnam[tlevel],line);
  1837. #else /* OS2 */
  1838.         if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1839.           strcpy(tfnam[tlevel],iksdconf);
  1840. #endif /* OS2 */
  1841. #ifndef NOSPL
  1842.         cmdlvl++;
  1843.         xcmdsrc = CMD_TF;
  1844.         cmdstk[cmdlvl].src = CMD_TF;
  1845.         cmdstk[cmdlvl].lvl = tlevel;
  1846.         cmdstk[cmdlvl].ccflgs = 0;
  1847.         ifcmd[cmdlvl]  = 0;
  1848.         iftest[cmdlvl] = 0;
  1849.         count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
  1850.         intime[cmdlvl] = intime[cmdlvl-1];
  1851.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1852.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1853.         merror[cmdlvl] = merror[cmdlvl-1];
  1854.         xquiet[cmdlvl] = quiet;
  1855.     xvarev[cmdlvl] = vareval;
  1856. #endif /* NOSPL */
  1857.         debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1858.     } else {
  1859.         debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1860.     }
  1861. #endif /* IKSDCONF */
  1862. }
  1863.  
  1864. #ifndef NOSPL
  1865. /*
  1866.   G E T N C M
  1867.  
  1868.   Get next command from current macro definition.  Command is copied
  1869.   into string pointed to by argument s, max length n.   Returns:
  1870.    0 if a string was copied;
  1871.   -1 if there was no string to copy.
  1872. */
  1873. int
  1874. getncm(s,n) char *s; int n; {
  1875.     int y = 0;                /* Character counter */
  1876.     int quote = 0;
  1877.     int kp = 0;                /* Brace up-down counter */
  1878.     int pp = 0;                /* Parenthesis up-down counter */
  1879. #ifndef NODQMACRO
  1880.     int dq = 0;                /* Doublequote counter */
  1881. #endif /* NODQMACRO */
  1882.     char *s2;                           /* Copy of destination pointer */
  1883.  
  1884.     s2 = s;                             /* Initialize string pointers */
  1885.     *s = NUL;                           /* and destination buffer */
  1886.  
  1887.     /* debug(F010,"getncm entry",macp[maclvl],0); */
  1888.  
  1889.     for (y = 0;                         /* Loop for n bytes max */
  1890.          macp[maclvl] && *macp[maclvl] && y < n;
  1891.          y++, s++, macp[maclvl]++) {
  1892.  
  1893.         *s = *macp[maclvl];             /* Get next char from macro def */
  1894.  
  1895. #ifndef COMMENT
  1896. /*
  1897.   This is to allow quoting of parentheses, commas, etc, in function
  1898.   arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  1899.   COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  1900.   everything again.)  <-- The preceding warning should be obsolete since the
  1901.   statements below have been fixed, but in case of fire, remove the "n" from
  1902.   the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the
  1903.   opening brace in \{nnn} from being treated as a quoted brace.
  1904. */
  1905.         if (!quote && *s == CMDQ) {
  1906.             quote = 1;
  1907.             continue;
  1908.         }
  1909.         if (quote) {
  1910.         int notquote = 0;
  1911.             quote = 0;
  1912.         if (*s == '{') {        /* Check for \{nnn} (8.0.203) */
  1913.         char c, * p;
  1914.         p = macp[maclvl] + 1;
  1915.         while ((c = *p++)) {
  1916.             if (isdigit(c))
  1917.               continue;
  1918.             else if (c == '}') {
  1919.             notquote++;
  1920.             break;
  1921.             } else {
  1922.             break;
  1923.             }
  1924.         }
  1925.         }
  1926.         if (notquote == 0)
  1927.           continue;
  1928.         }
  1929. #endif /* COMMENT */
  1930.  
  1931. /*
  1932.   Allow braces around macro definition to prevent commas from being turned to
  1933.   end-of-lines and also treat any commas within parens as text so that
  1934.   multiple-argument functions won't cause the command to break prematurely.
  1935.   19 Oct 2001: Similar treatment was added for doublequotes, so
  1936.  
  1937.      define foo { echo "one, two, three" }
  1938.  
  1939.   would work as expected.  This doesn't seem to have broken anything but
  1940.   if something comes up later, rebuild with NODQMACRO defined.
  1941. */
  1942.         if (*s == '{') kp++;            /* Count braces */
  1943.         if (*s == '}' && kp > 0) kp--;
  1944.         if (*s == '(') pp++;            /* Count parentheses. */
  1945.         if (*s == ')' && pp > 0) pp--;
  1946. #ifndef NODQMACRO
  1947. #ifndef COMMENT
  1948.     /* Too many false positives */
  1949.     /* No, not really -- this is indeed the best we can do */
  1950.     /* Reverted to this method Sun May 11 18:43:45 2003 */
  1951.     if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1952. #else  /* Fri Apr  4 13:21:29 2003 */
  1953.     /* The code below breaks the SWITCH statement */
  1954.     /* There is no way to make this work -- it would require */
  1955.     /* building in all the knowledge of command parser. */
  1956.         if (dblquo && (*s == '"')) {    /* Have doublequote */
  1957.             if (dq == 1) {        /* Close quote only if... */
  1958.                 if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
  1959.             (!*(macp[maclvl]+1)) ||      /* at end or ... */
  1960.             /* Next char is command separator... */
  1961.             /* Sun May 11 17:24:12 2003 */
  1962.             (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
  1963.             )             
  1964.                   dq = 0;        /* Close the quote */
  1965.             } else if (dq == 0) {
  1966.                 /* Open quote only if at beginning or preceded by space */
  1967.                 if (s > s2) {
  1968.                     if (*(s-1) == SP)
  1969.                       dq = 1;
  1970.                 } else if (s == s2) {
  1971.                       dq = 1;
  1972.                 }
  1973.             }
  1974.         }
  1975. #endif /* COMMENT */
  1976. #endif /* NODQMACRO */
  1977.         if (*s == ',' && pp <= 0 && kp <= 0
  1978. #ifndef NODQMACRO
  1979.             && dq == 0
  1980. #endif /* NODQMACRO */
  1981.             ) {
  1982.             macp[maclvl]++;             /* Comma not in {} or () */
  1983.             /* debug(F110,"next cmd",s,0); */
  1984.             kp = pp = 0;                /* so we have the next command */
  1985.             break;
  1986.         }
  1987.     }                                   /* Reached end. */
  1988. #ifdef COMMENT
  1989.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1990.     *s = NUL;
  1991. #endif /* COMMENT */
  1992.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1993.         /* debug(F100,"XXX getncm eom","",0); */
  1994.         popclvl();                      /* pop command level. */
  1995.         return(-1);
  1996.     } else {                            /* otherwise, tack CR onto end */
  1997.         *s++ = CR;
  1998.         *s = '\0';
  1999.         /* debug(F110,"XXX getncm OK",s,0); */
  2000.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  2001.           printf("%s\n",s2);
  2002.     }
  2003.     return(0);
  2004. }
  2005.  
  2006. /*  D O M A C  --  Define and then execute a macro */
  2007.  
  2008. int
  2009. domac(name, def, flags) char *name, *def; int flags; {
  2010.     int x, m;
  2011. #ifndef NOLOCAL
  2012. #ifdef OS2
  2013.     extern int term_io;
  2014.     int term_io_sav = term_io;
  2015.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  2016. #endif /* OS2 */
  2017. #endif /* NOLOCAL */
  2018.     m = maclvl;                         /* Current macro stack level */
  2019.     x = addmac(name, def);              /* Define a new macro */
  2020.     if (x > -1) {                       /* If successful, */
  2021.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  2022.         while (maclvl > m) {            /* Keep going till done with it, */
  2023.             debug(F101,"domac loop maclvl 1","",maclvl);
  2024.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  2025.             debug(F101,"domac loop maclvl 2","",maclvl);
  2026.             if (sstate) proto();        /* including protocol commands. */
  2027.         }
  2028.         debug(F101,"domac loop exit maclvl","",maclvl);
  2029.     }
  2030. #ifndef NOLOCAL
  2031. #ifdef OS2
  2032.     term_io = term_io_sav;
  2033. #endif /* OS2 */
  2034. #endif /* NOLOCAL */
  2035.     return(success);
  2036. }
  2037. #endif /* NOSPL */
  2038.  
  2039. /*
  2040.   G E T N C T
  2041.  
  2042.   Get next command from TAKE (command) file.
  2043.  
  2044.   Call with:
  2045.    s     Pointer to buffer to read into
  2046.    n     Length of buffer
  2047.    f     File descriptor of file to read from
  2048.    flag  0 == keep line terminator on and allow continuation
  2049.          1 == discard line terminator and don't allow continuation
  2050.  
  2051.   Call with flag == 0 to read a command from a TAKE file;
  2052.   Call with flag != 0 to read a line from a dialing or network directory.
  2053.  
  2054.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  2055.   If flag == 0, continued lines are combined into one line.  A continued line
  2056.   is one that ends in hypen, or any line in a "block", which starts with "{"
  2057.   at the end of a line and ends with a matching "}" at the beginning of a
  2058.   subsequent line; blocks may be nested.
  2059.  
  2060.   Returns:
  2061.    0 if a string was copied,
  2062.   -1 on EOF,
  2063.   -2 on malloc failure
  2064.   -3 if line is not properly terminated
  2065.   -4 if (possibly continued) line is too long.
  2066. */
  2067. static int lpxlen = 0;
  2068.  
  2069. int
  2070. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  2071.     int i = 0, len = 0, buflen = 0;
  2072.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  2073.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  2074.     char * prev = NULL;
  2075.     int bc = 0;                         /* Block counter */
  2076.  
  2077.     s2 = s;                             /* Remember original pointer */
  2078.     prev = s2;                /* Here too */
  2079.     buflen = n;                         /* Remember original buffer length */
  2080.  
  2081.     if (n < 0)
  2082.       return(-2);
  2083.  
  2084.     /* Allocate a line buffer only if we don't have one that's big enough */
  2085.  
  2086.     debug(F111,"getnct",ckitoa(lpxlen),n);
  2087.  
  2088.     if (lpx && (n > lpxlen)) {          /* Have one already */
  2089.         debug(F101,"getnct new buffer","",lpxlen);
  2090.         free(lpx);                      /* But it's not big enough */
  2091.         lpx = NULL;                     /* Free current one */
  2092.         lpxlen = 0;
  2093.     }
  2094.     if (!lpx) {                         /* Get new one */
  2095.         if (!(lpx = (char *) malloc(n))) {
  2096.             debug(F101,"getnct malloc failure","",0);
  2097.             printf("?Memory allocation failure [getnct:%d]\n",n);
  2098.             return(-2);
  2099.         }
  2100.         lpxlen = n;
  2101.     }
  2102.     lp2 = lpx;
  2103. #ifdef KLUDGE
  2104.     /* NOTE: No longer used as of 14 Aug 2000 */
  2105.     lp2++;
  2106. #endif /* KLUDGE */
  2107.  
  2108.     while (1) {                         /* Loop to read lines from file */
  2109.         debug(F101,"getnct while (1)","",n);
  2110.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  2111.             debug(F110,"getnct EOF",s2,0); /* EOF */
  2112.             free(lpx);                  /* Free temporary storage */
  2113.             lpx = NULL;
  2114.             *s = NUL;                   /* Make destination be empty */
  2115.             return(-1);                 /* Return failure code */
  2116.         }
  2117.  
  2118. #ifndef NODIAL
  2119.         if (flag)                       /* Count this line */
  2120.           dirline++;
  2121.         else
  2122. #endif /* NODIAL */
  2123.           tfline[tlevel]++;
  2124.         len = strlen(lp2) - 1;          /* Position of line terminator */
  2125.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  2126.             lp2[++len] = '\n';          /* that is not a newline */
  2127.             lp2[len] = NUL;
  2128.         }
  2129.         debug(F010,"getnct",lp2,0);
  2130.         if (len < 0)
  2131.           len = 0;
  2132.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2133.           printf("%3d. %s",             /* echo it this line. */
  2134. #ifndef NODIAL
  2135.                  flag ? dirline :
  2136. #endif /* NODIAL */
  2137.                  tfline[tlevel],
  2138.                  lp2
  2139.                  );
  2140.         lp3 = lp2;                      /* Working pointer */
  2141.         i = len;                        /* Get first nonwhitespace character */
  2142.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2143.             i--;
  2144.             lp3++;
  2145.         }
  2146.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2147.           continue;
  2148.  
  2149.         /* Isolate, remove, and check terminator */
  2150.  
  2151.         c = lp2[len];                   /* Value of line terminator */
  2152.         /* debug(F101,"getnct terminator","",c); */
  2153.         if (c < LF || c > CR) {         /* It's not a terminator */
  2154.             /* debug(F111,"getnct bad line",lp2,c); */
  2155.             if (feof(f) && len > 0 && len < n) {
  2156.                 /* Kludge Alert... */
  2157.                 if (!quiet)
  2158.                   printf("WARNING: Last line of %s lacks terminator\n",
  2159.                          s2 == cmdbuf ? "command file" : "directory file");
  2160.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2161.             } else {                    /* Something's wrong, fail. */
  2162.                 free(lpx);
  2163.                 lpx = NULL;
  2164.                 return(-3);
  2165.             }
  2166.         }
  2167.         /* Trim trailing whitespace */
  2168.  
  2169.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2170.           ;
  2171.         /* debug(F101,"getnct i","",i); */
  2172.         lp2[i+1] = NUL;                 /* Terminate the string */
  2173.         /* debug(F110,"getnct lp2",lp2,0); */
  2174.         lp = lp2;                       /* Make a working pointer */
  2175.  
  2176.         /* Remove trailing or full-line comment */
  2177.  
  2178.         while ((cc = *lp)) {
  2179.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2180.                 if (lp == lp2) {        /* First char on line */
  2181.                     *lp = NUL;
  2182.                     break;
  2183.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2184.                     lp--;
  2185.                     *lp = NUL;  /* Or preceded by whitespace */
  2186.                     break;
  2187.                 }
  2188.             }
  2189.             lp++;
  2190.         }
  2191.         if (lp > lp2)
  2192.           lp--;                         /* Back up over the NUL */
  2193.  
  2194.         /* Now trim any space that preceded the comment */
  2195.  
  2196.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2197.             *lp = NUL;
  2198.             if (lp <= lp2)
  2199.               break;
  2200.             lp--;
  2201.         }
  2202.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2203.  
  2204.         len = strlen(lp2);              /* Length after trimming */
  2205.  
  2206.         if (n - len < 2) {              /* Check remaining space */
  2207.             debug(F111,"getnct command too long",s2,buflen);
  2208.             printf("?Line too long, maximum length: %d.\n",buflen);
  2209.             free(lpx);
  2210.             return(-4);
  2211.         }
  2212.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2213.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2214.  
  2215. #ifdef COMMENT
  2216.         /* Line containing only whitespace and ,- */
  2217.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2218.           continue;
  2219. #endif /* COMMENT */
  2220.  
  2221. #ifdef KLUDGE
  2222. /*
  2223.   If it is a command and it begins with a token (like ! or .) that is not
  2224.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2225.   confused.
  2226. */
  2227.         if (s == s2 && !flag) {
  2228.             char *p = toktab;
  2229.             while (*p) {
  2230.                 if (*p == *lp3 && *(p+1) != SP) {
  2231.                     debug(F110,"getnct token",p,0);
  2232.                     *lp3-- = SP;
  2233.                     *lp3 = *p;
  2234.                     if (lp3 < lp2) {
  2235.                         lp2--;
  2236.                         len++;
  2237.                     }
  2238.                     break;
  2239.                 } else
  2240.                   p++;
  2241.             }
  2242.         }
  2243. #endif /* KLUDGE */
  2244.         lp = lp2;
  2245.  
  2246.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2247.           n--;                          /* accounting for length */
  2248.         s--;                            /* Back up over the NUL */
  2249.  
  2250.         /* Check whether this line is continued */
  2251.  
  2252.         if (flag)                       /* No line continuation when flag=1 */
  2253.           break;                        /* So break out of read-lines loop */
  2254.  
  2255. #ifdef COMMENT
  2256.         debug(F000,"getnct first char","",*lp3);
  2257.         debug(F000,"getnct last char","",ccl);
  2258.         debug(F000,"getnct next-to-last char","",ccx);
  2259. #endif /* COMMENT */
  2260.  
  2261.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2262.             bc--;            /* Decrement block counter */
  2263.         }
  2264.  
  2265.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2266. #ifdef COMMENT
  2267.             /* Not supported as of C-Kermit 6.0 */
  2268.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2269. #endif /* COMMENT */
  2270.             ccl != '-'  &&              /* or line ends with dash */
  2271.             ccl != '{')                 /* or line ends with opening brace */
  2272.           break;                        /* None of those, we're done. */
  2273.  
  2274.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2275.           if (ccx == CMDQ)              /* But it's quoted */
  2276.             break;                      /* so ignore it */
  2277.  
  2278.         if (ccl == '{') {               /* Last char on line is '{'? */
  2279.             bc++;                       /* Count the block opener. */
  2280.         } else if (ccl == '-') {        /* Explicit continue? */
  2281.             char c, * ss;
  2282.             int state = 0, nn;
  2283.             s--;                        /* Yes, back up over terminators */
  2284.             n++;                        /* and over continuation character */
  2285.             nn = n;                     /* Save current count */
  2286.             ss = s;                     /* and pointer */
  2287.             s--;                        /* Back up over dash */
  2288.             n++;
  2289.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2290.                 n++;
  2291.                 c = *s--;
  2292.                 if (c <= SP)
  2293.                   continue;
  2294.                 if (c != ',' && c != '{')
  2295.                   break;
  2296.                 switch (state) {
  2297.                   case 0:               /* Looking for comma */
  2298.                     if (c == ',')
  2299.                       state = 1;
  2300.                     break;
  2301.                   case 1:               /* Looking for left brace */
  2302.                     if (c == '{') {
  2303.                         state = 2;
  2304.                         s += 2;
  2305.                         *s = NUL;
  2306.                         bc++;
  2307.                     }
  2308.                     break;
  2309.                 }
  2310.             }
  2311.             if (state != 2) { s = ss; n = nn; }
  2312.             *s = NUL;
  2313.         } else {                        /* None of those but (bc > 0) */
  2314.             lastcomma = s;
  2315.             *s++ = ',';                 /* and insert a comma */
  2316.             n--;
  2317.         }
  2318. #ifdef COMMENT
  2319.         debug(F101,"getnct bc","",bc);
  2320.         debug(F100,"getnct continued","",0);
  2321. #endif /* COMMENT */
  2322.  
  2323.         *s = NUL;
  2324.         prev = s;
  2325.  
  2326.     } /* read-lines while loop */
  2327.  
  2328.     if (lastcomma)
  2329.       *lastcomma = SP;
  2330.     if (!flag)                          /* Tack line terminator back on */
  2331.       *s++ = c;
  2332.     *s++ = NUL;                         /* Terminate the string */
  2333.     untab(s2);                          /* Done, convert tabs to spaces */
  2334. #ifdef DEBUG
  2335.     if (!flag) {
  2336.         debug(F010,"CMD(F)",s2,0);
  2337.     }
  2338. #endif /* DEBUG */
  2339.     free(lpx);                          /* Free temporary storage */
  2340.     return(0);                          /* Return success */
  2341. }
  2342.  
  2343. VOID
  2344. shostack() {                            /* Dump the command stack */
  2345.     int i;
  2346.     char *p;
  2347. #ifndef NOSPL
  2348.     for (i = cmdlvl; i > 0; i--) {
  2349.         if (cmdstk[i].src == CMD_TF) {
  2350.             p = tfnam[cmdstk[i].lvl];
  2351.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2352.               p = tmpbuf;
  2353.             printf(" %2d. File  : %s (line %d)\n",
  2354.                    i,
  2355.                    p,
  2356.                    tfline[cmdstk[i].lvl]
  2357.                    );
  2358.         } else if (cmdstk[i].src == CMD_MD) {
  2359.             char * m;
  2360.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2361.             if (i > 0) {                 /* Special handling for 2-level */
  2362.                 char *s;                 /* built-in macros... */
  2363.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2364.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2365.                     if (!strcmp(s,"_forx"))
  2366.                       m = "FOR";
  2367.                     else if (!strcmp(s,"_xif"))
  2368.                       m = "XIF";
  2369.                     else if (!strcmp(s,"_while"))
  2370.                       m = "WHILE";
  2371.                     else if (!strcmp(s,"_switx"))
  2372.                       m = "SWITCH";
  2373.                 }
  2374.             }
  2375.             printf(" %2d. Macro : %s\n",i,m);
  2376.         } else if (cmdstk[i].src == CMD_KB) {
  2377.             printf(" %2d. Prompt:\n",i);
  2378.         } else {
  2379.             printf(" %2d. ERROR : Command source unknown\n",i);
  2380.         }
  2381.     }
  2382. #else
  2383.     for (i = tlevel; i > -1; i--) {
  2384.         p = tfnam[i];
  2385.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2386.           p = tmpbuf;
  2387.         printf(" %2d. File  : %s (line %d)\n",
  2388.                i,
  2389.                p,
  2390.                tfline[i]
  2391.                );
  2392.     }
  2393. #endif /* NOSPL */
  2394.     if (i == 0)
  2395.       printf(" %2d. Prompt: (top level)\n",0);
  2396. }
  2397.  
  2398. /* For command error messages - avoid dumping out the contents of some */
  2399. /* some huge FOR loop if it contains a syntax error. */
  2400.  
  2401. static char *
  2402. cmddisplay(s, cx) char * s; int cx; {
  2403.     static char buf[80];
  2404.     if ((int)strlen(s) > 70) {
  2405.     sprintf(buf,"%.64s...",s);    /* SAFE */
  2406.     s = buf;
  2407.     }
  2408.     return(s);
  2409. }
  2410.  
  2411. static VOID
  2412. cmderr() {
  2413.     if (xcmdsrc > 0) {
  2414.     switch (cmd_err) {        /* SET COMMAND ERROR-DISPLAY */
  2415.       case 0:
  2416.         break;
  2417.       case 1:
  2418.       case 2:
  2419.         if (tlevel > -1) {
  2420. #ifndef NOSPL
  2421.         if (xcmdsrc == 2)
  2422.           printf(
  2423. "In macro or block defined in file: %s starting about line %d\n",
  2424.              tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2425.              );
  2426.         else
  2427. #endif /* NOSPL */
  2428.           printf("File: %s, Line: %d\n",
  2429.              tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2430.              );
  2431.         }
  2432. #ifndef NOSPL
  2433.         if (cmd_err == 2) {
  2434.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2435.             int m;
  2436.             m = cmdstk[cmdlvl].lvl;
  2437.             if (mlook(mactab,m_arg[m][0],nmac) >= 0)
  2438.               printf("Macro name: %s\n", m_arg[m][0]);
  2439.         }
  2440.         }
  2441. #endif /* NOSPL */
  2442.         break;
  2443.  
  2444.       case 3:
  2445.         printf("Command stack:\n");
  2446.         shostack();                
  2447.     }
  2448.     }
  2449. }
  2450.  
  2451. /*  P A R S E R  --  Top-level interactive command parser.  */
  2452.  
  2453. /*
  2454.   Call with:
  2455.     m = 0 for normal behavior: keep parsing and executing commands
  2456.           until an action command is parsed, then return with a
  2457.           Kermit start-state as the value of this function.
  2458.     m = 1 to parse only one command, can also be used to call parser()
  2459.           recursively.
  2460.     m = 2 to read but do not execute one command.
  2461.   In all cases, parser() returns:
  2462.     0     if no Kermit protocol action required
  2463.     > 0   with a Kermit protocol start-state.
  2464.     < 0   upon error.
  2465. */
  2466. int
  2467. parser(m) int m; {
  2468.     int tfcode, xx, yy, zz;             /* Workers */
  2469.     int is_tn = 0;
  2470.     int cdlost = 0;
  2471.  
  2472. #ifndef NOSPL
  2473.     int inlevel;                        /* Level we were called at */
  2474.     extern int askflag, echostars;
  2475. #endif /* NOSPL */
  2476.     char *cbp;                          /* Command buffer pointer */
  2477. #ifdef MAC
  2478.     extern char *lfiles;                /* Fake extern cast */
  2479. #endif /* MAC */
  2480.     extern int interrupted;
  2481. #ifndef NOXFER
  2482.     extern int sndcmd, getcmd, fatalio, clearrq;
  2483. #endif /* NOXFER */
  2484.  
  2485. #ifdef AMIGA
  2486.     reqres();                           /* Restore AmigaDOS requestors */
  2487. #endif /* AMIGA */
  2488.  
  2489. #ifdef OS2
  2490.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2491.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2492.         cursor_save = -1;
  2493.     }
  2494. #endif /* OS2 */
  2495.  
  2496. #ifdef IKSDB
  2497.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2498. #endif /* IKSDB */
  2499.  
  2500.     is_tn = (local && network && IS_TELNET()) ||
  2501.       (!local && sstelnet);
  2502.  
  2503.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2504.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2505.  
  2506. #ifdef CK_TMPDIR
  2507. /* If we were cd'd temporarily to another device or directory ... */
  2508.     if (f_tmpdir) {
  2509.         int x;
  2510.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2511.         f_tmpdir = 0;                   /* and remember we did it. */
  2512.         debug(F111,"parser tmpdir restoring",savdir,x);
  2513.     }
  2514. #endif /* CK_TMPDIR */
  2515.  
  2516. #ifndef NOSPL
  2517.     inlevel = cmdlvl;           /* Current macro level */
  2518. #ifdef DEBUG
  2519.     if (deblog) {
  2520.         debug(F101,"&parser entry maclvl","",maclvl);
  2521.         debug(F101,"&parser entry inlevel","",inlevel);
  2522.         debug(F101,"&parser entry tlevel","",tlevel);
  2523.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2524.         debug(F101,"&parser entry m","",m);
  2525.     }
  2526. #endif /* DEBUG */
  2527. #endif /* NOSPL */
  2528.  
  2529. #ifndef NOXFER
  2530.     ftreset();                          /* Reset global file settings */
  2531. #endif /* NOXFER */
  2532. /*
  2533.   sstate becomes nonzero when a command has been parsed that requires some
  2534.   action from the protocol module.  Any non-protocol actions, such as local
  2535.   directory listing or terminal emulation, are invoked directly from below.
  2536. */
  2537.     sstate = 0;                         /* Start with no start state. */
  2538.  
  2539. #ifndef NOXFER
  2540. #ifndef NOSPL
  2541.     query = 0;                          /* QUERY not active */
  2542. #endif /* NOSPL */
  2543. #ifndef NOHINTS
  2544.     if (!success) {
  2545.         if (local && !network && carrier != CAR_OFF) {
  2546.             int x;                      /* Serial connection */
  2547.             x = ttgmdm();               /* with carrier checking */
  2548.             if (x > -1) {
  2549.                 if (!(x & BM_DCD)) {
  2550.                     cdlost = 1;
  2551.                     fatalio = 1;
  2552.                 }
  2553.             }
  2554.         }
  2555.     }
  2556. #ifdef DEBUG
  2557.     if (deblog) {
  2558.         debug(F101,"parser top what","",what);
  2559.         debug(F101,"parser top interrupted","",interrupted);
  2560.         debug(F101,"parser top cdlost","",cdlost);
  2561.         debug(F101,"parser top sndcmd","",sndcmd);
  2562.         debug(F101,"parser top getcmd","",getcmd);
  2563.     }
  2564. #endif /* DEBUG */
  2565.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2566.         printf("?Connection broken (carrier signal lost)\n");
  2567.     }
  2568.     if (sndcmd && protocol == PROTO_K &&
  2569.     !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2570.         int x = 0, n = 0;
  2571.         printf("\n*************************\n");
  2572.         printf("SEND-class command failed.\n");
  2573.         printf(" Packets sent: %d\n", spackets);
  2574.         printf(" Retransmissions: %d\n",retrans);
  2575.         printf(" Timeouts: %d\n", timeouts);
  2576.         printf(" Damaged packets: %d\n", crunched);
  2577.         if (epktrcvd) {
  2578.             printf(" Transfer canceled by receiver.\n");
  2579.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2580.             n++;
  2581.         } else {
  2582.             if (epktmsg) if (*epktmsg) {
  2583.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2584.                 n++;
  2585.             }
  2586.         }
  2587.         if (local && !network && carrier != CAR_OFF) {
  2588.             int xx;                     /* Serial connection */
  2589.             xx = ttgmdm();              /* with carrier checking */
  2590.             if (xx > -1) {
  2591.                 if (!(xx & BM_DCD))
  2592.                   cdlost = 1;
  2593.             }
  2594.         }
  2595.  
  2596. #ifdef UNIX
  2597.         if (errno != 0)
  2598. #endif /* UNIX */
  2599.           {
  2600.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2601.               n++;
  2602.           }
  2603.         printf(
  2604.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2605.                (n > 1) ? "s do" : " does"
  2606.                );
  2607. #ifndef NOLOCAL
  2608.         if (local) {
  2609.             if (rpackets == 0) {
  2610.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2611.             } else {
  2612.                 printf(
  2613.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2614.                 if (!network && mdmtyp > 0)
  2615.                   if ((3 * crunched) > spackets)
  2616.                     printf(
  2617.                 " . Try placing a new call to get a cleaner connection.\n");
  2618.             }
  2619.         } else if (rpackets > 0) {
  2620.             if (flow == FLO_NONE)
  2621.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2622.             else
  2623.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2624.         }
  2625.         x++;
  2626. #endif /* NOLOCAL */
  2627.  
  2628.         if ((3 * timeouts) > spackets)
  2629.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2630.         if ((3 * retrans) > spackets)
  2631.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2632.  
  2633. #ifdef CK_SPEED
  2634.         if (prefixing != PX_ALL && rpackets > 2) {
  2635.             printf(" . Try it again with: SET PREFIXING ALL\n");
  2636.             x++;
  2637.         }
  2638. #endif /* CK_SPEED */
  2639. #ifdef STREAMING
  2640.         if (streamed) {
  2641.             printf(" . Try it again with: SET STREAMING OFF\n");
  2642.             x++;
  2643.         } else if (reliable) {
  2644.             printf(" . Try it again with: SET RELIABLE OFF\n");
  2645.             x++;
  2646.         }
  2647. #endif /* STREAMING */
  2648.  
  2649. #ifdef CK_SPEED
  2650.         if (clearrq > 0 && prefixing == PX_NON) {
  2651.             printf(" . Try it again with: SET CLEAR-CHANNEL OFF\n");
  2652.             x++;
  2653.         }
  2654. #endif /* CK_SPEED */
  2655.         if (!parity) {
  2656.             printf(" . Try it again with: SET PARITY SPACE\n");
  2657.             x++;
  2658.         }
  2659.         printf(" . %sive a ROBUST command and try again.\n",
  2660.                (x > 0) ? "As a last resort, g" : "G"
  2661.                );
  2662.         printf("Also:\n");
  2663.         printf(" . Be sure the source file has read permission.\n");
  2664.         printf(" . Be sure the target directory has write permission.\n");
  2665. /*
  2666.         if the file was 2G or larger make sure other Kermit supports LFs...
  2667. */
  2668.         printf(" . Be sure the target disk has sufficient space.\n");
  2669.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2670.         printf("*************************\n\n");
  2671.     }
  2672.     debug(F101,"topcmd","",topcmd);
  2673.     if (getcmd && protocol == PROTO_K &&
  2674.     !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2675.         int x = 0;
  2676.         extern int urpsiz, wslotr;
  2677.         printf("\n*************************\n");
  2678.         printf("RECEIVE- or GET-class command failed.\n");
  2679.         printf(" Packets received: %d\n", rpackets);
  2680.         printf(" Damaged packets: %d\n", crunched);
  2681.         printf(" Timeouts: %d\n", timeouts);
  2682.         if (rpackets > 0)
  2683.           printf(" Packet length: %d\n", urpsiz);
  2684.         if (epktrcvd) {
  2685.             printf(" Transfer canceled by sender.\n");
  2686.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2687.         }
  2688. #ifdef UNIX
  2689.         if (errno != 0)
  2690. #endif /* UNIX */
  2691.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2692.         printf(
  2693.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2694.                epktrcvd ? "s do" : " does"
  2695.                );
  2696. #ifndef NOLOCAL
  2697.         if (local) {
  2698.             if (topcmd == XXGET)
  2699.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2700.             if (rpackets == 0) {
  2701.                 if (topcmd != XXGET)
  2702.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2703.             } else {
  2704.                 printf(
  2705.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2706.             }
  2707.         } else if (topcmd == XXGET)
  2708.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2709.         if (rpackets > 0 && urpsiz > 90)
  2710.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2711.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2712.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2713.         if (!local && rpackets > 0) {
  2714.             if (flow == FLO_NONE)
  2715.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2716.             else
  2717.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2718.         }
  2719.         x++;
  2720. #endif /* NOLOCAL */
  2721. #ifdef STREAMING
  2722.         if (streamed) {
  2723.             printf(" . Try it again with: SET STREAMING OFF\n");
  2724.             x++;
  2725.         } else if (reliable && local) {
  2726.             printf(" . Try it again with: SET RELIABLE OFF\n");
  2727.             x++;
  2728.         } else
  2729. #endif /* STREAMING */
  2730.         if (!parity) {
  2731.             printf(" . Try it again with: SET PARITY SPACE\n");
  2732.             x++;
  2733.         }
  2734.         printf((x > 0) ?
  2735.                " . As a last resort, give a ROBUST command and try again.\n" :
  2736.                " . Give a ROBUST command and try again.\n"
  2737.                );
  2738.         printf("Also:\n");
  2739.         printf(" . Be sure the target directory has write permission.\n");
  2740.         printf(" . Be sure the target disk has sufficient space.\n");
  2741.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2742.                topcmd == XXGET ? "server" : "sender"
  2743.                );
  2744.         printf(" . Try giving a ROBUST command to the %s.\n",
  2745.                topcmd == XXGET ? "server" : "sender"
  2746.                );
  2747.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2748.         printf("*************************\n\n");
  2749.     }
  2750. #endif /* NOHINTS */
  2751.     getcmd = 0;
  2752.     sndcmd = 0;
  2753.     interrupted = 0;
  2754. #endif /* NOXFER */
  2755.  
  2756.     while (sstate == 0) {               /* Parse cmds until action requested */
  2757.         debug(F100,"parse top","",0);
  2758.     what = W_COMMAND;        /* Now we're parsing commands. */
  2759.     rcdactive = 0;            /* REMOTE CD not active */
  2760.     keepallchars = 0;        /* MINPUT not active */
  2761.  
  2762. #ifdef OS2
  2763.         if (apcactive == APC_INACTIVE)
  2764.           WaitCommandModeSem(-1);
  2765. #endif /* OS2 */
  2766. #ifdef IKS_OPTION
  2767.         if ((local &&
  2768.              !xcmdsrc &&
  2769.              is_tn &&
  2770.              TELOPT_ME(TELOPT_KERMIT) &&
  2771.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2772.             (!local &&
  2773.              !cmdadl &&
  2774.              TELOPT_ME(TELOPT_KERMIT) &&
  2775.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2776.             ) {
  2777.             tn_siks(KERMIT_STOP);
  2778.         }
  2779. #endif /* IKS_OPTION */
  2780.  
  2781. #ifndef NOXFER
  2782.         if (autopath) {
  2783.             fnrpath = PATH_AUTO;
  2784.             autopath = 0;
  2785.         }
  2786.         remfile = 0;                    /* Clear these in case REMOTE */
  2787.         remappd = 0;                    /* command was interrupted... */
  2788.         rempipe = 0;
  2789.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2790.         makestr(&rcv_move,g_rcv_move);
  2791.         makestr(&snd_rename,g_snd_rename);
  2792.         makestr(&rcv_rename,g_rcv_rename);
  2793. #endif /* NOXFER */
  2794.  
  2795.     /* Take requested action if there was an error in the previous command */
  2796.  
  2797.         setint();
  2798.         debug(F101,"parser tlevel","",tlevel);
  2799.         debug(F101,"parser cmd_rows","",cmd_rows);
  2800.  
  2801. #ifndef NOLOCAL
  2802.         debug(F101,"parser wasclosed","",wasclosed);
  2803.         if (wasclosed) {                /* If connection was just closed */
  2804. #ifndef NOSPL
  2805.             int k;
  2806.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2807.             if (k >= 0) {               /* If found, */
  2808.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2809.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2810.             }
  2811. #endif /* NOSPL */
  2812.             whyclosed = WC_REMO;
  2813.             wasclosed = 0;
  2814.         }
  2815. #endif /* NOLOCAL */
  2816.  
  2817. #ifndef NOSPL
  2818.         xxdot = 0;                      /* Clear this... */
  2819.  
  2820.         debug(F101,"parser success","",success);
  2821.         if (success == 0) {
  2822.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2823.                 printf("Command file terminated by error.\n");
  2824.                 popclvl();
  2825.                 if (cmdlvl == 0) return(0);
  2826.             }
  2827.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2828.                 printf("Command error: macro terminated.\n");
  2829.                 popclvl();
  2830.                 if (m && (cmdlvl < inlevel))
  2831.                   return((int) sstate);
  2832.             }
  2833.         }
  2834.         nulcmd = (m == 2);
  2835.         debug(F101,"parser nulcmd","",nulcmd);
  2836. #else
  2837.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2838.             printf("Command file terminated by error.\n");
  2839.             popclvl();
  2840.             cmini(ckxech);              /* Clear the cmd buffer. */
  2841.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2842.               return(0);                /* End of init file or whatever. */
  2843.         }
  2844. #endif /* NOSPL */
  2845.  
  2846. #ifdef MAC
  2847.         /* Check for TAKE initiated by menu. */
  2848.         if ((tlevel == -1) && lfiles)
  2849.             startlfile();
  2850. #endif /* MAC */
  2851.  
  2852.         /* If in TAKE file, check for EOF */
  2853. #ifndef NOSPL
  2854. #ifdef MAC
  2855.         if
  2856. #else
  2857.         while
  2858. #endif /* MAC */
  2859.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2860.                && (tlevel > -1)
  2861.                && feof(tfile[tlevel])) {
  2862.             popclvl();                  /* pop command level */
  2863.             cmini(ckxech);              /* and clear the cmd buffer. */
  2864.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2865.                 return(0);              /* End of init file or whatever. */
  2866.             }
  2867.         }
  2868. #ifdef MAC
  2869.         miniparser(1);
  2870.         if (sstate == 'a') {            /* if cmd-. cancel */
  2871.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2872.             sstate = '\0';
  2873.             dostop();
  2874.             return(0);                  /* End of init file or whatever. */
  2875.         }
  2876. #endif /*  MAC */
  2877.  
  2878. #else /* NOSPL */
  2879.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2880.             popclvl();                  /* Pop up one level. */
  2881.             cmini(ckxech);              /* and clear the cmd buffer. */
  2882.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2883.               return(0);                /* End of init file or whatever. */
  2884.         }
  2885. #endif /* NOSPL */
  2886.  
  2887.  
  2888. #ifndef NOSPL
  2889.         debug(F101,"parser cmdlvl","",cmdlvl);
  2890.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2891.  
  2892.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2893.             debug(F100,"parser macro","",0);
  2894.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2895.             debug(F101,"parser maclvl","",maclvl);
  2896.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2897.             *cbp = NUL;
  2898.             if (*savbuf) {              /* In case then-part of 'if' command */
  2899.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2900.                 *savbuf = '\0';
  2901.             } else {                    /* Else get next cmd from macro def */
  2902.                 if (getncm(cbp,CMDBL) < 0) {
  2903. #ifdef DEBUG
  2904.                     if (deblog) {
  2905.                         debug(F101,"parser end of macro m","",m);
  2906.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2907.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2908.                     }
  2909. #endif /* DEBUG */
  2910.                     if (m && (cmdlvl < inlevel))
  2911.                       return((int) sstate);
  2912.                     else /* if (!m) */ continue;
  2913.                 }
  2914.             }
  2915.             debug(F010,"CMD(M)",cmdbuf,0);
  2916.  
  2917.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2918. #else
  2919.           if (tlevel > -1)
  2920. #endif /* NOSPL */
  2921.           {
  2922. #ifndef NOSPL
  2923.             debug(F111,"parser savbuf",savbuf,tlevel);
  2924.             if (*savbuf) {              /* In case THEN-part of IF command */
  2925.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2926.                 *savbuf = '\0';
  2927.             } else
  2928. #endif /* NOSPL */
  2929.  
  2930.               /* Get next line from TAKE file */
  2931.  
  2932.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2933.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2934.                   if (tfcode < -1) {    /* Error */
  2935.                       printf("?Error in TAKE command file: %s\n",
  2936.                              (tfcode == -2) ? "Memory allocation failure" :
  2937.                              "Line too long or contains NUL characters"
  2938.                              );
  2939.                       dostop();
  2940.                   }
  2941.                   continue;             /* -1 means EOF */
  2942.               }
  2943.  
  2944.         /* If interactive, get next command from user. */
  2945.  
  2946.         } else {                        /* User types it in. */
  2947.             if (pflag) prompt(xxstring);
  2948.             cmini(ckxech);
  2949.         }
  2950.  
  2951.     /* Now we know where next command is coming from. Parse and execute it. */
  2952.  
  2953.         repars = 1;                     /* 1 = command needs parsing */
  2954. #ifndef NOXFER
  2955.         displa = 0;                     /* Assume no file transfer display */
  2956. #endif /* NOXFER */
  2957.  
  2958.         while (repars) {                /* Parse this cmd until entered. */
  2959.  
  2960.             debug(F101,"parser top of while loop","",0);
  2961.         xaskmore = saveask;        /* Restore global more-prompting */
  2962.         diractive = 0;        /* DIR command not active */
  2963.         cdactive = 0;        /* CD command not active */
  2964. #ifndef NOSPL
  2965.         askflag = 0;        /* ASK command not active */
  2966.         echostars = 0;        /* Nor ASKQ */
  2967.         debok = 1;            /* Undisable debugging */
  2968. #endif /* NOSPL */
  2969.  
  2970. #ifdef RECURSIVE
  2971.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2972.             recursive = 0;              /* This is never sticky */
  2973. #endif /* RECURSIVE */
  2974.             xfiletype = -1;             /* Reset this between each command */
  2975. #ifndef NOMSEND
  2976.             addlist = 0;
  2977. #endif /* NOMSEND */
  2978. #ifdef CK_RECALL
  2979.             on_recall = 1;
  2980. #endif /* CK_RECALL */
  2981.             /* This might have been changed by a switch */
  2982.             if (g_matchdot > -1) {
  2983.                 matchdot = g_matchdot;
  2984.                 g_matchdot = -1;
  2985.             }
  2986.             cmres();                    /* Reset buffer pointers. */
  2987.  
  2988. #ifdef OS2
  2989. #ifdef COMMENT
  2990.             /* we check to see if a macro is waiting to be executed */
  2991.             /* if so, we call domac on it */
  2992.             if (cmdmac) {
  2993.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2994.                 free(cmdmac);
  2995.                 cmdmac = NULL;
  2996.             }
  2997. #endif /* COMMENT */
  2998. #endif /* OS2 */
  2999. #ifndef NOXFER
  3000.             bye_active = 0;
  3001. #endif /* NOXFER */
  3002.             havetoken = 0;
  3003.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  3004.             debug(F101,"top-level cmkey2","",xx);
  3005.             if (xx == -5) {
  3006.                 yy = chktok(toktab);
  3007.                 debug(F101,"top-level cmkey token","",yy);
  3008. #ifndef COMMENT
  3009.                 /* Either way makes absolutely no difference */
  3010.                 debug(F110,"NO UNGWORD",atmbuf,0);
  3011.                 /* ungword(); */
  3012. #else
  3013.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  3014.                 ungword();
  3015. #endif /* COMMENT */
  3016.                 switch (yy) {
  3017.                   case '#': xx = XXCOM; break; /* Comment */
  3018.                   case ';': xx = XXCOM; break; /* Comment */
  3019. #ifndef NOSPL
  3020.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  3021.                   case ':': xx = XXLBL; break; /* GOTO label */
  3022. #endif /* NOSPL */
  3023.  
  3024. #ifndef NOPUSH
  3025. #ifdef CK_REDIR
  3026.                   case '<':
  3027. #endif /* CK_REDIR */
  3028.                   case '@':
  3029.                   case '!':
  3030.                     if (nopush) {
  3031.                         char *s; int x;
  3032.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  3033.                           return(x);
  3034.                         success = 0;
  3035.                         xx = XXCOM;
  3036.                     } else {
  3037.                         switch(yy) {
  3038. #ifdef CK_REDIR
  3039.                           case '<': xx = XXFUN; break; /* REDIRECT */
  3040. #endif /* CK_REDIR */
  3041.                           case '@':
  3042.                           case '!': xx = XXSHE; break; /* Shell escape */
  3043.                         }
  3044.                     }
  3045.                     break;
  3046. #endif /* NOPUSH */
  3047. #ifdef CK_RECALL
  3048.                   case '^': xx = XXREDO;  break;
  3049. #endif /* CK_RECALL */
  3050. #ifndef NOSPL
  3051.                   case '{': xx = XXMACRO; break;
  3052.                   case '(': xx = XXSEXP;  break;
  3053. #endif /* NOSPL */
  3054.  
  3055.                   default:
  3056.                     if (!quiet && !cmd_err) {
  3057.                         printf("\n?Invalid - \"%s\"\n",
  3058.                    cmddisplay((char *)cmdbuf,xx)
  3059.                    );
  3060.             cmderr();
  3061.                     }
  3062.                     xx = -2;
  3063.                 }
  3064.                 havetoken = 1;
  3065.                 debug(F101,"HAVE TOKEN","",xx);
  3066.             }
  3067.             if (xx > -1) {
  3068.                 topcmd = xx;            /* Top-level command index */
  3069. #ifndef NOSPL
  3070.                 if (maclvl > -1)
  3071.                   lastcmd[maclvl] = xx;
  3072. #endif /* NOSPL */
  3073.                 debug(F101,"topcmd","",topcmd);
  3074.                 debug(F101,"cmflgs","",cmflgs);
  3075.             }
  3076.  
  3077. #ifndef NOSPL
  3078.             /* Special handling for IF..ELSE */
  3079.  
  3080.             debug(F101,"cmdlvl","",cmdlvl);
  3081.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  3082.  
  3083.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  3084.               ifcmd[cmdlvl]++;
  3085.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  3086.               ifcmd[cmdlvl] = 0;
  3087.  
  3088.             /* Execute the command and take action based on return code. */
  3089.  
  3090.             if (nulcmd) {               /* Ignoring this command? */
  3091.                 xx = XXCOM;             /* Make this command a comment. */
  3092.             }
  3093.             fnsuccess = 1;              /* For catching \function() errors */
  3094. #endif /* NOSPL */
  3095.  
  3096.             debug(F101,"calling docmd()","",xx);
  3097.             zz = docmd(xx);             /* Parse rest of command & execute. */
  3098.  
  3099. #ifndef NOSPL
  3100.         {                /* For \v(lastcommand) */
  3101.         extern char * prevcmd;
  3102.         /* The exception list kind of a hack but let's try it... */
  3103.         if (ckstrcmp(cmdbuf,"_getarg",7,0) &&
  3104.             ckstrcmp(cmdbuf,"if ",3,0) &&
  3105.             ckstrcmp(cmdbuf,"xif ",4,0) &&
  3106.             ckstrcmp(cmdbuf,"do _if",6,0) &&
  3107.             ckstrcmp(cmdbuf,"_assign _if",11,0))
  3108.           ckstrncpy(prevcmd,cmdbuf,CMDBL);
  3109.         }
  3110. #endif    /* NOSPL */
  3111.  
  3112. #ifndef NOSPL
  3113.             if (fnerror && !fnsuccess)
  3114.               success = 0;
  3115. #endif /* NOSPL */
  3116.             debug(F101,"docmd returns","",zz);
  3117.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  3118.             /* debug(F011,"atmbuf",atmbuf,30); */
  3119. #ifdef MAC
  3120.             if (tlevel > -1) {
  3121.                 if (sstate == 'a') {    /* if cmd-. cancel */
  3122.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  3123.                     sstate = '\0';
  3124.                     dostop();
  3125.                     return(0);          /* End of init file or whatever. */
  3126.                 }
  3127.             }
  3128. #endif /* MAC */
  3129.             switch (zz) {
  3130.               case -4:                  /* EOF (e.g. on redirected stdin) */
  3131.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  3132.               case -1:                  /* Reparse needed */
  3133.                 repars = 1;             /* Just set reparse flag and... */
  3134.                 continue;
  3135. #ifdef OS2
  3136.               case -7:                  /* They typed a disk letter */
  3137.                 if (!zchdir((char *)cmdbuf)) {
  3138.                     perror((char *)cmdbuf);
  3139.                     success = 0;
  3140.                 } else success = 1;
  3141.                 repars = 0;
  3142.                 continue;
  3143.  
  3144. #endif /* OS2 */
  3145.               case -6:                  /* Invalid command given w/no args */
  3146.               case -2: {        /* Invalid command given w/args */
  3147.           int x = 0;
  3148.           char * eol = "";
  3149.           x = strlen(cmdbuf);    /* Avoid blank line */
  3150.           if (x > 0) {
  3151.               if (cmdbuf[x-1] != LF)
  3152.             eol = "\n";
  3153.               printf("?Invalid: %s%s",
  3154.                  cmddisplay(cmdbuf,xx),eol
  3155.                  );
  3156.           } else
  3157.             printf("?Invalid\n");
  3158.           }
  3159.           case -9:            /* Bad, error message already done */
  3160.         success = 0;
  3161.         debug(F110,"top-level cmkey failed",cmdbuf,0);
  3162.         /* If in background w/ commands coming stdin, terminate */
  3163.         if (pflag == 0 && tlevel < 0)
  3164.           fatal("Kermit command error in background execution");
  3165. /*
  3166.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3167.   reprompt the user with as much of the command as didn't fail.
  3168. */
  3169. #ifdef CK_RECALL
  3170.         if (cm_retry && !xcmdsrc) { /* If at top level */
  3171.             int len;
  3172.             char *p, *s;
  3173.             len = strlen(cmdbuf); /* Length of command buffer */
  3174.             p = malloc(len + 1);  /* Allocate space for copy */
  3175.             if (p) {              /* If we got the space copy */
  3176.             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3177.             /* Chop off final field, the one that failed. */
  3178.             s = p + len - 1;          /* Point to end */
  3179.             while (*s == SP && s > p) /* Trim blanks */
  3180.               s--;
  3181.             while (*s != SP && s > p) /* Trim last field */
  3182.               s--;
  3183.             if (s > p)        /* Keep the space */
  3184.               s++;            /* after last good field */
  3185.             if (s >= p)       /* Cut off remainder */
  3186.               *s = NUL;
  3187.             cmini(ckxech);    /* Reinitialize the parser */
  3188.             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3189.             free(p);          /* Free temporary storage */
  3190.             p = NULL;
  3191.             prompt(xxstring); /* Reprint the prompt */
  3192.             printf("%s",cmdbuf); /* Reprint partial command */
  3193.             repars = 1;          /* Force reparse */
  3194.             continue;
  3195.             }
  3196.         } else
  3197. #endif /* CK_RECALL */
  3198.           cmderr();
  3199.  
  3200.         cmini(ckxech);        /* (fall thru) */
  3201.  
  3202.           case -3:            /* Empty command OK at top level */
  3203.         repars = 0;        /* Don't need to reparse. */
  3204.         continue;        /* Go back and get another command. */
  3205.  
  3206.           default:            /* Command was successful. */
  3207. #ifndef NOSPL
  3208.         debug(F101,"parser preparing to continue","",maclvl);
  3209. #endif /* NOSPL */
  3210.         debug(F101,"parser success","",success);
  3211.         repars = 0;        /* Don't need to reparse. */
  3212.         continue;        /* Go back and get another command. */
  3213.         }
  3214.         }
  3215. #ifndef NOSPL
  3216.         debug(F101,"parser breaks out of while loop","",maclvl);
  3217.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3218. #endif /* NOSPL */
  3219.     }
  3220.  
  3221. /* Got an action command, return start state. */
  3222.  
  3223.     return((int) sstate);
  3224. }
  3225.  
  3226. #ifndef NOSPL
  3227. /*
  3228.   OUTPUT command.
  3229.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3230. */
  3231. #define OBSIZE 80                       /* Size of local character buffer */
  3232.  
  3233. static int obn;                         /* Buffer offset (high water mark) */
  3234. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3235. static char *obp;                       /* Pointer to output buffer. */
  3236. _PROTOTYP( static int oboc, (char) );
  3237. _PROTOTYP( static int xxout, (char *, int) );
  3238.  
  3239. static int
  3240. #ifdef CK_ANSIC
  3241. xxout(char *obuf, int obsize)
  3242. #else
  3243. xxout(obuf, obsize) char *obuf; int obsize;
  3244. #endif /* CK_ANSIC */
  3245. /* xxout */ {                           /* OUTPUT command's output function */
  3246.     int i, rc;
  3247.  
  3248.     debug(F101,"xxout obsize","",obsize);
  3249.     debug(F101,"xxout pacing","",pacing);
  3250.     debug(F111,"xxout string",obuf,strlen(obuf));
  3251.  
  3252.     rc = 0;                             /* Initial return code. */
  3253.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3254.       goto xxout_x;                     /* Return successfully */
  3255.  
  3256.     rc = -1;                              /* Now assume failure */
  3257.     if (pacing == 0) {                    /* Is pacing enabled? */
  3258.         if ((local ?                      /* No, write entire string at once */
  3259.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3260.              conxo(obsize, obuf))         /* or to console */
  3261.             != obsize)
  3262.           goto xxout_x;
  3263.     } else {
  3264.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3265.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3266.               goto xxout_x;
  3267.             msleep(pacing);
  3268.         }
  3269.     }
  3270.     if (duplex) {
  3271. #ifdef OS2
  3272.         if (inecho && local) {
  3273. #ifndef NOLOCAL
  3274.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3275.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3276.             }
  3277. #endif /* NOLOCAL */
  3278.             conxo(obsize,obuf);
  3279.         } else if (seslog) {            /* or log session here */
  3280.             logstr((char *) obuf, obsize);
  3281.         }
  3282. #else /* OS2 */
  3283.         if (seslog) {
  3284.             logstr((char *) obuf, obsize);
  3285.         }
  3286.         if (inecho && local) {
  3287.             conxo(obsize,obuf);
  3288.         }
  3289. #endif /* OS2 */
  3290.     }
  3291.     rc = 0;                             /* Success */
  3292.   xxout_x:
  3293.     obn = 0;                            /* Reset count */
  3294.     obp = obuf;                         /* and pointers */
  3295.     return(rc);                         /* return our return code */
  3296. }
  3297.  
  3298. #ifdef COMMENT
  3299. /*
  3300.   Macros for OUTPUT command execution, to make it go faster.
  3301. */
  3302. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3303. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3304.  
  3305. #else /* The macros cause some compilers to generate bad code. */
  3306.  
  3307. static int
  3308. #ifdef CK_ANSIC
  3309. oboc(char c)
  3310. #else
  3311. oboc(c) char c;
  3312. #endif /* CK_ANSIC */
  3313. /* oboc */ {                            /* OUTPUT command's output function */
  3314.  
  3315.     *obp++ = c;                         /* Deposit character */
  3316.     *obp = NUL;                         /* Flush buffer if it's now full */
  3317.  
  3318.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3319. }
  3320. #endif /* COMMENT */
  3321.  
  3322. /*  Routines for handling local variables -- also see popclvl().  */
  3323.  
  3324. VOID
  3325. freelocal(m) int m; {                   /* Free local variables */
  3326.     struct localvar * v, * tv;          /* at macro level m... */
  3327.     debug(F101,"freelocal level","",m);
  3328.     if (m < 0) return;
  3329.     v = localhead[m];                   /* List head for level m */
  3330.     while (v) {
  3331.         if (v->lv_name)                 /* Variable name */
  3332.           free(v->lv_name);
  3333.         if (v->lv_value)                /* Value */
  3334.           free(v->lv_value);
  3335.         tv = v;                         /* Save pointer to this node */
  3336.         v = v->lv_next;                 /* Get next one */
  3337.         if (tv)                         /* Free this one */
  3338.           free((char *)tv);
  3339.     }
  3340.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3341. }
  3342.  
  3343. #define MAXLOCALVAR 64
  3344.  
  3345. /* Return a pointer to the definition of a user-defined variable */
  3346.  
  3347. static char *
  3348. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3349.     char * p;
  3350.     char c;
  3351.     *isarray = 0;
  3352.     if (!s) return(NULL);
  3353.     if (!*s) return(NULL);
  3354.     p = s;
  3355.     if (*s == CMDQ) {
  3356.         p++;
  3357.         if (!*p)
  3358.           return(NULL);
  3359.         if ((c = *p) == '%') {          /* Scalar variable. */
  3360.             c = *++p;                   /* Get ID character. */
  3361.             p = "";                     /* Assume definition is empty */
  3362.             if (!c)
  3363.               return(NULL);
  3364.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3365.                 if (maclvl < 0)         /* Digit variables are global */
  3366.                   return(g_var[c]);     /* if no macro is active */
  3367.                 else                    /* otherwise */
  3368.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3369.             } else if (isalpha(c)) {
  3370.                 if (isupper(c)) c -= ('a'-'A');
  3371.                 return(g_var[c]);           /* Letter for global variable */
  3372.             } else
  3373.               return(NULL);
  3374.         } else if (c == '&') {          /* Array reference. */
  3375.             int x, vbi, d;
  3376.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3377.             if (x > -1 || d == -17) {
  3378.                 *isarray = 1;
  3379.                 *x1 = vbi;
  3380.                 *x2 = (d == -17) ? 0 : d;
  3381.             }
  3382.             if (x < 0)
  3383.               return(NULL);
  3384.             if (chkarray(vbi,d) >= 0) {    /* Array is declared? */
  3385.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3386.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3387.                     char **ap;
  3388.                     ap = a_ptr[vbi];
  3389.                     return((ap) ? ap[d] : NULL);
  3390.                 }
  3391.             }
  3392.         }
  3393.         return(NULL);
  3394.     } else {
  3395.         int k;
  3396.         k = mxlook(mactab,s,nmac);
  3397.         return((k > -1) ? mactab[k].mval : NULL);
  3398.     }
  3399. }
  3400.  
  3401.  
  3402. int
  3403. addlocal(p) char * p; {
  3404.     int x, z, isarray = 0;
  3405.     char * s;
  3406.     struct localvar * v, *prev = (struct localvar *)NULL;
  3407.     extern int tra_asg; int tra_tmp;
  3408.  
  3409.     tra_tmp = tra_asg;
  3410.  
  3411.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3412.     if (isarray) {                      /* Arrays are handled specially */
  3413.         pusharray(x,z);
  3414.         return(0);
  3415.     }
  3416.     if (!s) s = "";
  3417.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3418.         while (v) {                     /* Find end of list */
  3419.             prev = v;
  3420.             v = v->lv_next;
  3421.         }
  3422.     }
  3423.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3424.     if (!v) {
  3425.         printf("?Failure to allocate storage for local variables");
  3426.         return(-9);
  3427.     }
  3428.     if (!localhead[cmdlvl])             /* If first, set list head */
  3429.       localhead[cmdlvl] = v;
  3430.     else                                /* Otherwise link previous to this */
  3431.       prev->lv_next = v;
  3432.     prev = v;                           /* And make this previous */
  3433.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3434.  
  3435.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3436.       return(-1);
  3437.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3438.  
  3439.     if (*s) {
  3440.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3441.           return(-1);
  3442.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3443.     } else
  3444.       v->lv_value = NULL;
  3445.  
  3446.     tra_asg = 0;
  3447.     delmac(p,1);                        /* Delete the original macro */
  3448.     tra_asg = tra_tmp;
  3449.     return(0);
  3450. }
  3451.  
  3452. int
  3453. dolocal() {                             /* Do the LOCAL command */
  3454.     int i, x;
  3455.     char * s;
  3456.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3457.  
  3458.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3459.       return(x);
  3460.  
  3461.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3462.  
  3463.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3464.  
  3465.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3466.         if (addlocal(list[i]) < 0)
  3467.           goto localbad;
  3468.     }
  3469.     return(success = 1);
  3470.  
  3471.   localbad:
  3472.     printf("?Failure to allocate storage for local variables");
  3473.     freelocal(cmdlvl);
  3474.     return(-9);
  3475. }
  3476.  
  3477. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3478.  
  3479. #ifndef NOKVERBS
  3480. #define K_BUFLEN 30
  3481. #define SEND_BUFLEN 255
  3482. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3483.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3484. #endif /* NOKVERBS */
  3485.  
  3486. int outesc = 1;                         /* Process special OUTPUT escapes */
  3487.  
  3488. int
  3489. dooutput(s, cx) char *s; int cx; {
  3490. #ifdef SSHBUILTIN
  3491.     extern int ssh_cas;
  3492.     extern char * ssh_cmd;
  3493. #endif /* SSHBUILTIN */
  3494.     int x, xx, y, quote;                /* Workers */
  3495.     int is_tn = 0;
  3496.  
  3497.     is_tn = (local && network && IS_TELNET()) ||
  3498.       (!local && sstelnet);
  3499.  
  3500.     debug(F111,"dooutput s",s,(int)strlen(s));
  3501.  
  3502.     if (local) {                        /* Condition external line */
  3503. #ifdef NOLOCAL
  3504.         goto outerr;
  3505. #else
  3506.     if (ttchk() < 0) {
  3507.         if (!network) {
  3508.         if (carrier != CAR_OFF) {
  3509.             int x;
  3510.             x = ttgmdm();
  3511.             if ((x > -1) && ((x & BM_DCD) == 0)) {
  3512.             printf(
  3513. "?Carrier signal required but not present - Try SET CARRIER-WATCH OFF.\n"
  3514.                               );
  3515.             return(0);
  3516.             }
  3517.         } else {
  3518.             printf(
  3519. "?Problem with serial port or modem or cable - Try SHOW COMMUNICATIONS.\n"
  3520.                           );
  3521.             return(0);
  3522.         }
  3523.         }
  3524.         printf("?Connection %s %s is not open or not functioning.\n",
  3525.            network ? "to" : "on",
  3526.            ttname
  3527.            );
  3528.         return(0);
  3529.     }
  3530.         if (ttvt(speed,flow) < 0) {
  3531.             printf("?OUTPUT initialization error\n");
  3532.             return(0);
  3533.         }
  3534. #endif /* NOLOCAL */
  3535.     }
  3536. #ifdef SSHBUILTIN
  3537.     if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd && 
  3538.          !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
  3539.         if (!quiet)
  3540.             printf("?SSH Subsystem active: %s\n", ssh_cmd);
  3541.         return(0);
  3542.     }
  3543. #endif /* SSHBUILTIN */
  3544.  
  3545.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3546.         x = strlen(s);                  /* Just send the string literally */
  3547.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3548.         return(success = (xx == x) ? 1 : 0);
  3549.     }
  3550.     quote = 0;                          /* Initialize backslash (\) quote */
  3551.     obn = 0;                            /* Reset count */
  3552.     obp = obuf;                         /* and pointers */
  3553.  
  3554.   outagain:
  3555.     while ((x = *s++)) {                /* Loop through the string */
  3556.         y = 0;                          /* Error code, 0 = no error. */
  3557.         debug(F000,"dooutput","",x);
  3558.         if (quote) {                    /* This character is quoted */
  3559. #ifndef NOKVERBS
  3560.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3561.                extern struct keytab kverbs[];
  3562.                extern int nkverbs;
  3563.                extern char * keydefptr;
  3564.                extern int keymac;
  3565.                extern int keymacx;
  3566.                int x, y, brace = 0;
  3567.                int pause;
  3568.                char * p, * b;
  3569.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3570.                char osendbuf[SEND_BUFLEN +1];
  3571.                int  sendndx = 0;
  3572.  
  3573.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3574.                  goto outerr;
  3575.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3576.                {                        /* Have K verb? */
  3577.                    if (!*s) {
  3578.                        break;
  3579.                    }
  3580. /*
  3581.   We assume that the verb name is {braced}, or it extends to the end of the
  3582.   string, s, or it ends with a space, control character, or backslash.
  3583. */
  3584.                    p = kbuf;            /* Copy verb name into local buffer */
  3585.                    x = 0;
  3586.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3587.                        if (brace && *s == '}') {
  3588.                            break;
  3589.                        }
  3590.                        *p++ = *s++;
  3591.                    }
  3592.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3593.                      s--;               /*  back up so we get another look. */
  3594.                    brace = 0;
  3595.                    *p = NUL;            /* Terminate. */
  3596.                    p = kbuf;            /* Point back to beginning */
  3597.                    debug(F110,"dooutput kverb",p,0);
  3598.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3599.                    debug(F101,"dooutput lookup",0,y);
  3600.                    if (y > -1) {
  3601.                        if (sendndx) {
  3602.                            dooutput(osendbuf,cx);
  3603.                            sendndx = 0;
  3604.                        }
  3605.                        dokverb(VCMD,y);
  3606. #ifndef NOSPL
  3607.                    } else {             /* Is it a macro? */
  3608.                        y = mxlook(mactab,p,nmac);
  3609.                        if (y > -1) {
  3610.                            cmpush();
  3611.                            keymac = 1;  /* Flag for key macro active */
  3612.                            keymacx = y; /* Key macro index */
  3613.                            keydefptr = s; /* Where to resume next time */
  3614.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3615.                            parser(1);
  3616.                            cmpop();
  3617.                        }
  3618. #endif /* NOSPL */
  3619.                    }
  3620.                }
  3621.                quote = 0;
  3622.                continue;
  3623.            } else
  3624. #endif /* NOKVERBS */
  3625.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3626.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3627.                    goto outerr;
  3628.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3629.                  if (local)
  3630.                    ttoc(NUL);
  3631.                  else
  3632.                    conoc(NUL);
  3633.                  quote = 0;
  3634.                  continue;
  3635.  
  3636.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3637.  
  3638.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3639.                   goto outerr;
  3640.                 debug(F100,"OUTPUT BREAK","",0);
  3641. #ifndef NOLOCAL
  3642.                 ttsndb();               /* Send BREAK signal */
  3643. #else
  3644.                  if (local)
  3645.                    ttoc(NUL);
  3646.                  else
  3647.                    conoc(NUL);
  3648. #endif /* NOLOCAL */
  3649.                 quote = 0;              /* Turn off quote flag */
  3650.                 continue;               /* and not the b or B */
  3651. #ifdef CK_LBRK
  3652.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3653.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3654.                    goto outerr;
  3655.                  debug(F100,"OUTPUT Long BREAK","",0);
  3656. #ifndef NOLOCAL
  3657.                  ttsndlb();             /* Send Long BREAK signal */
  3658. #else
  3659.                  if (local)
  3660.                    ttoc(NUL);
  3661.                  else
  3662.                    conoc(NUL);
  3663. #endif /* NOLOCAL */
  3664.                  quote = 0;             /* Turn off quote flag */
  3665.                  continue;              /* and not the l or L */
  3666. #endif /* CK_LBRK */
  3667.  
  3668.              } else if (x == CMDQ) {    /* Backslash itself */
  3669.                  debug(F100,"OUTPUT CMDQ","",0);
  3670.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3671.                  if (xx < 0)
  3672.                    goto outerr;
  3673.                  quote = 0;
  3674.                  continue;
  3675.  
  3676.              } else {                   /* if \ not followed by special esc */
  3677.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3678.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3679.                  if (xx < 0)
  3680.                    goto outerr;
  3681.                  quote = 0;             /* Turn off quote flag */
  3682.              }
  3683.         } else if (x == CMDQ) {         /* This is the quote character */
  3684.             quote = 1;                  /* Go back and get next character */
  3685.             continue;                   /* which is quoted */
  3686.         }
  3687.         xx = oboc(dopar((char)x));      /* Output this character */
  3688.         debug(F111,"dooutput",obuf,obn);
  3689.         if (xx < 0)
  3690.           goto outerr;
  3691. #ifdef COMMENT
  3692.         if (seslog && duplex) {         /* Log the character if log is on */
  3693.             logchar((char)x);
  3694.         }
  3695. #endif /* COMMENT */
  3696.         if (x == '\015') {              /* String contains carriage return */
  3697.             int stuff = -1, stuff2 = -1;
  3698.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3699.                 stuff = LF;             /* Stuff LF */
  3700.             }
  3701. #ifdef TNCODE
  3702.             /* TELNET NEWLINE ON/OFF/RAW */
  3703.             if (is_tn) {
  3704.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3705.                         tn_b_nlm :
  3706.                         tn_nlm
  3707.                         ) {
  3708.                   case TNL_CR:
  3709.                     break;
  3710.                   case TNL_CRNUL:
  3711.                     stuff2 = stuff;
  3712.                     stuff  = NUL;
  3713.                     break;
  3714.                   case TNL_CRLF:
  3715.                     stuff2 = stuff;
  3716.                     stuff = LF;
  3717.                     break;
  3718.                 }
  3719.             }
  3720. #endif /* TNCODE */
  3721.             if (stuff > -1) {           /* Stuffing another character... */
  3722.                 xx = oboc(dopar((CHAR)stuff));
  3723.                 if (xx < 0)
  3724.                   goto outerr;
  3725. #ifdef COMMENT
  3726.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3727.                     logchar((char)stuff);
  3728.                 }
  3729. #endif /* COMMENT */
  3730.             }
  3731.             if (stuff2 > -1) {          /* Stuffing another character... */
  3732.                 xx = oboc(dopar((CHAR)stuff2));
  3733.                 if (xx < 0)
  3734.                   goto outerr;
  3735. #ifdef COMMENT
  3736.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3737.                     logchar((char)stuff2);
  3738.                 }
  3739. #endif /* COMMENT */
  3740.             }
  3741.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3742.               goto outerr;
  3743.         }
  3744.     }
  3745.     if (cx == XXLNOUT) {
  3746.         s = "\015";
  3747.         cx = 0;
  3748.         goto outagain;
  3749.     }
  3750.     if (quote == 1)                     /* String ended with backslash */
  3751.       xx = oboc(dopar(CMDQ));
  3752.  
  3753.     if (obn > 0)                        /* OUTPUT done */
  3754.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3755.         goto outerr;
  3756.     return(1);
  3757.  
  3758. outerr:                                 /* OUTPUT command error handler */
  3759.     if (msgflg) printf("?OUTPUT execution error\n");
  3760.     return(0);
  3761.  
  3762. /* Remove "local" OUTPUT macro defininitions */
  3763.  
  3764. #ifdef COMMENT
  3765. /* No more macros ... */
  3766. #undef oboc
  3767. #undef obfls
  3768. #endif /* COMMENT */
  3769. }
  3770. #endif /* NOSPL */
  3771.  
  3772. /* Display version herald and initial prompt */
  3773.  
  3774. VOID
  3775. herald() {
  3776.     int x = 0, i;
  3777.     extern int srvcdmsg;
  3778.     extern char * cdmsgfile[];
  3779. #ifndef NOCMDL
  3780.     char * ssl;
  3781.     char * krb4;
  3782.     char * krb5;
  3783.     extern char * bannerfile;
  3784.     debug(F110,"herald bannerfile",bannerfile,0);
  3785.     if (bannerfile) {
  3786.         concb((char)escape);
  3787.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3788.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3789.             if (srvcdmsg) {
  3790.                 for (i = 0; i < 8; i++) {
  3791.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3792.                     if (zchki(cdmsgfile[i]) > -1) {
  3793.                         printf("\n");
  3794.                         dotype(cdmsgfile[i],
  3795.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3796.                         break;
  3797.                     }
  3798.                 }
  3799.             }
  3800.             return;
  3801.         }
  3802.     }
  3803. #endif /* NOCMDL */
  3804.  
  3805. #ifdef COMMENT
  3806.     /* The following generates bad code in SCO compilers. */
  3807.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3808.     /* statement when all conditions are false, x has a value of -32. */
  3809.     if (noherald || quiet || bgset > 0 || (bgset != 0 && backgrd != 0))
  3810.       x = 1;
  3811. #else
  3812.     x = 0;
  3813.     if (noherald || quiet)
  3814.       x = 1;
  3815.     else if (bgset > 0)
  3816.       x = 1;
  3817.     else if (bgset < 0 && backgrd > 0)
  3818.       x = 1;
  3819. #endif /* COMMENT */
  3820.  
  3821.     ssl = "";
  3822.     krb4 = "";
  3823.     krb5 = "";
  3824. #ifdef CK_AUTHENTICATION
  3825. #ifdef CK_SSL    
  3826.     ssl = "+SSL";
  3827. #endif    /* CK_SSL */
  3828. #ifdef KRB4
  3829.     krb4 = "+KRB4";
  3830. #endif    /* KRB4 */
  3831. #ifdef KRB5
  3832.     krb5 = "+KRB5";
  3833. #endif    /* KRB5 */
  3834. #endif    /* CK_AUTHENTICATION */
  3835.  
  3836.     if (x == 0) {
  3837. #ifdef datageneral
  3838.         printf("%s, for%s\n",versio,ckxsys);
  3839. #else
  3840. #ifdef OSK
  3841.         printf("%s, for%s\n",versio,ckxsys);
  3842. #else
  3843. #ifdef CK_64BIT
  3844.         printf("%s, for%s%s%s%s (64-bit)\n\r",versio,ckxsys,ssl,krb4,krb5);
  3845. #else
  3846.         printf("%s, for%s%s%s%s\n\r",versio,ckxsys,ssl,krb4,krb5);
  3847. #endif/* CK_64BIT */
  3848. #endif /* OSK */
  3849. #endif /* datageneral */
  3850.         printf(" Copyright (C) 1985, 2010,\n");
  3851.         printf("  Trustees of Columbia University in the City of New York.\n");
  3852. #ifdef OS2
  3853.        shoreg();
  3854. #endif /* OS2 */
  3855.  
  3856.         if (!quiet && !backgrd) {
  3857. #ifdef COMMENT
  3858. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3859.             char * s;
  3860.             extern int xfermode;
  3861. #ifdef VMS
  3862.             s = "AUTOMATIC";
  3863. #else
  3864.             if (xfermode == XMODE_A) {
  3865.                 s = "AUTOMATIC";
  3866.             } else {
  3867.                 s = gfmode(binary,1);
  3868.             }
  3869.             if (!s) s = "";
  3870. #endif /* VMS */
  3871.             if (*s)
  3872.               printf("Default file-transfer mode is %s\n", s);
  3873. #endif /* COMMENT */
  3874.  
  3875.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3876.             if (srvcdmsg) {
  3877.                 for (i = 0; i < 8; i++) {
  3878.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3879.                     if (zchki(cdmsgfile[i]) > -1) {
  3880.                         printf("\n");
  3881.                         dotype(cdmsgfile[i],
  3882.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3883.                         break;
  3884.                     }
  3885.                 }
  3886.             }
  3887.             printf("Type ? or HELP for help.\n");
  3888.         }
  3889.     }
  3890. }
  3891.  
  3892. /*  G F M O D E  --  Get File (transfer) Mode  */
  3893.  
  3894. char *
  3895. gfmode(binary,upcase) int binary, upcase; {
  3896.     char * s;
  3897.     switch (binary) {
  3898.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3899. #ifdef VMS
  3900.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3901.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3902.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3903.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3904. #else
  3905. #ifdef MAC
  3906.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3907.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3908. #else
  3909.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3910. #ifdef CK_LABELED
  3911.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3912. #endif /* CK_LABELED */
  3913. #endif /* MAC */
  3914. #endif /* VMS */
  3915.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3916.       default: s = "";
  3917.     }
  3918.     return(s);
  3919. }
  3920.  
  3921. #ifndef NOSPL
  3922. static int
  3923. isaa(s) char * s; {                     /* Is associative array */
  3924.     char c;
  3925.     int x;
  3926.     if (!s) s = "";
  3927.     if (!*s) return(0);
  3928.     s++;
  3929.     while ((c = *s++)) {
  3930.         if (c == '<') {
  3931.             x = strlen(s);
  3932.             return ((*(s+x-1) == '>') ? 1 : 0);
  3933.         }
  3934.     }
  3935.     return(0);
  3936. }
  3937.  
  3938. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3939.  
  3940. /*
  3941.   Call this way:  v = mlook(table,word,n);
  3942.  
  3943.     table - a 'struct mtab' table.
  3944.     word  - the target string to look up in the table.
  3945.     n     - the number of elements in the table.
  3946.  
  3947.   The keyword table must be arranged in ascending alphabetical order, and
  3948.   all letters must be lowercase.
  3949.  
  3950.   Returns the table index, 0 or greater, if the name was found, or:
  3951.  
  3952.    -3 if nothing to look up (target was null),
  3953.    -2 if ambiguous,
  3954.    -1 if not found.
  3955.  
  3956.   A match is successful if the target matches a keyword exactly, or if
  3957.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3958.   target matches two or more keywords from the table.
  3959. */
  3960. int
  3961. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3962.     register int i;
  3963.     int v, w, cmdlen = 0;
  3964.     char c = 0, c1, * s;
  3965.     if (!cmd) cmd = "";
  3966.  
  3967.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3968.     debug(F111,"MLOOK",cmd,cmdlen);
  3969.  
  3970.     c1 = *cmd;
  3971.     if (isupper(c1))
  3972.       c1 = tolower(c1);
  3973.     if (cmdlen < 1)
  3974.       return(-3);
  3975.  
  3976. /* Not null, look it up */
  3977.  
  3978.     if (n < 12) {                       /* Not worth it for small tables */
  3979.         i = 0;
  3980.     } else {                            /* Binary search for where to start */
  3981.         int lo = 0;
  3982.         int hi = n;
  3983.         int count = 0;
  3984.         while (lo+2 < hi && ++count < 12) {
  3985.             i = lo + ((hi - lo) / 2);
  3986.             c = *(table[i].kwd);
  3987.             if (isupper(c)) c = tolower(c);
  3988.             if (c < c1) {
  3989.                 lo = i;
  3990.             } else {
  3991.                 hi = i;
  3992.             }
  3993.         }
  3994.         i = (c < c1) ? lo+1 : lo;
  3995.     }
  3996.     for ( ; i < n-1; i++) {
  3997.         s = table[i].kwd;
  3998.         if (!s) s = "";
  3999.         if (!*s) continue;              /* Empty table entry */
  4000.         c = *s;
  4001.         if (isupper(c)) c = tolower(c);
  4002.         if (c1 != c) continue;          /* First char doesn't match */
  4003.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  4004.           return(i);
  4005.         v = !ckstrcmp(s,cmd,cmdlen,0);
  4006.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  4007.         if (v && w)                     /* Have abbreviated match? */
  4008.           return(i);
  4009.         if (v)                          /* Ambiguous? */
  4010.           return(-2);
  4011.         if (w > 0)                      /* Past our alphabetic area? */
  4012.           return(-1);
  4013.     }
  4014.  
  4015. /* Last (or only) element */
  4016.  
  4017.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  4018.       return(n-1);
  4019.  
  4020.     return(-1);
  4021. }
  4022.  
  4023. /* mxlook is like mlook, but an exact full-length match is required */
  4024.  
  4025. int
  4026. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  4027.     register int i;
  4028.     int w, cmdlen = 0, one = 0;
  4029.     register char c = 0, c1, * s;
  4030.  
  4031.     if (!cmd) cmd = "";                 /* Check args */
  4032.  
  4033.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  4034.     debug(F111,"MXLOOK",cmd,cmdlen);
  4035.  
  4036.     c1 = *cmd;                          /* First char of string to look up */
  4037.     if (isupper(c1))
  4038.       c1 = tolower(c1);
  4039.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  4040.       one = 1;
  4041.  
  4042.     if (cmdlen < 1)                     /* Nothing to look up */
  4043.       return(-3);
  4044.  
  4045.     if (n < 12) {                       /* Not worth it for small tables */
  4046.         i = 0;
  4047.     } else {                            /* Binary search for where to start */
  4048.         int lo = 0;
  4049.         int hi = n;
  4050.         int count = 0;
  4051.         while (lo+2 < hi && ++count < 12) {
  4052.             i = lo + ((hi - lo) / 2);
  4053.             c = *(table[i].kwd);
  4054.             if (isupper(c)) c = tolower(c);
  4055.             if (c < c1) {
  4056.                 lo = i;
  4057.             } else {
  4058.                 hi = i;
  4059.             }
  4060.         }
  4061.         i = (c < c1) ? lo+1 : lo;
  4062.     }
  4063.     for ( ; i < n; i++) {               /* Look thru table */
  4064.         s = table[i].kwd;               /* This entry */
  4065.         if (!s) s = "";
  4066.         if (!*s) continue;              /* Empty table entry */
  4067.         c = *s;
  4068.         if (isupper(c)) c = tolower(c);
  4069.         if (c1 != c) continue;          /* First char doesn't match */
  4070.         if (one) {                      /* Name is one char long */
  4071.             if (!*(s+1))
  4072.               return(i);                /* So is table entry */
  4073.         }
  4074. #ifdef COMMENT
  4075.         if (((int)strlen(s) == cmdlen) &&
  4076.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  4077. #else
  4078.         w = ckstrcmp(s,cmd,-1,0);
  4079.         if (!w) return(i);
  4080.         if (w > 0) return(-1);
  4081. #endif /* COMMENT */
  4082.     }
  4083.     return(-1);
  4084. }
  4085.  
  4086. /* mxxlook is like mxlook, but case-sensitive */
  4087.  
  4088. int
  4089. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  4090.     int i, cmdlen;
  4091.     if (!cmd) cmd = "";
  4092.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  4093.     /* debug(F111,"mxxlook target",cmd,n); */
  4094.     for (i = 0; i < n; i++) {
  4095.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  4096.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  4097.           return(i);
  4098.     }
  4099.     return(-1);
  4100. }
  4101.  
  4102. static int
  4103. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  4104.     if (val)
  4105.       printf(">>> %s: \"%s\"\n", nam, val);
  4106.     else
  4107.       printf(">>> %s: (undef)\n", nam);
  4108.     return(0);
  4109. }
  4110.  
  4111. #ifdef USE_VARLEN                       /* Not used */
  4112.  
  4113. /*  V A R L E N  --  Get length of variable's value.
  4114.  
  4115.   Given a variable name, return the length of its definition or 0 if the
  4116.   variable is not defined.  If it is defined, set argument s to point to its
  4117.   definition.  Otherwise set s to NULL.
  4118. */
  4119. int
  4120. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  4121.     int x, z;
  4122.     char *p = NULL, c;
  4123.  
  4124.     *s = NULL;
  4125.     if (!nam) return(0);                /* Watch out for null pointer */
  4126.     if (*nam == CMDQ) {
  4127.         nam++;
  4128.         if (*nam == '%') {              /* If it's a variable name */
  4129.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  4130.             p = (char *)0;              /* Initialize value pointer */
  4131.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4132.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  4133.             } else {                    /* It's a global variable */
  4134.                 if (c < 33 || c > GVARS) return(0);
  4135.                 p = g_var[c];           /* Get pointer from global-var table */
  4136.             }
  4137.         } else if (*nam == '&') {               /* An array reference? */
  4138.             char **q;
  4139.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4140.               return(-1);               /* return -1. */
  4141.             x -= ARRAYBASE;             /* Convert name to number. */
  4142.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4143.               return(0);                /* return -2. */
  4144.             if (z > a_dim[x])           /* If subscript out of range, */
  4145.               return(0);                /* return -3. */
  4146.             p = q[z];
  4147.         }
  4148.     } else {                            /* Macro */
  4149.         z = isaa(nam);
  4150.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  4151.         if (x < 0)
  4152.           return(0);
  4153.         p = mactab[x].mval;
  4154.     }
  4155.     if (p)
  4156.       *s = p;
  4157.     else
  4158.       p = "";
  4159.     return((int)strlen(p));
  4160. }
  4161. #endif /* USE_VARLEN */
  4162.  
  4163. /*
  4164.   This routine is for the benefit of those compilers that can't handle
  4165.   long string constants or continued lines within them.  Long predefined
  4166.   macros like FOR, WHILE, and XIF have their contents broken up into
  4167.   arrays of string pointers.  This routine concatenates them back into a
  4168.   single string again, and then calls the real addmac() routine to enter
  4169.   the definition into the macro table.
  4170. */
  4171. int
  4172. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  4173.     int i, x, y; char *p;
  4174.     x = 0;                              /* Length counter */
  4175.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  4176.         debug(F111,"addmmac line",s[i],y);
  4177.         x += y;
  4178.     }
  4179.     debug(F101,"addmmac lines","",i);
  4180.     debug(F101,"addmmac loop exit","",y);
  4181.     debug(F111,"addmmac length",nam,x);
  4182.     if (x < 0) return(-1);
  4183.  
  4184.     p = malloc(x+1);                    /* Allocate space for all of it. */
  4185.     if (!p) {
  4186.         printf("?addmmac malloc error: %s\n",nam);
  4187.         debug(F110,"addmmac malloc error",nam,0);
  4188.         return(-1);
  4189.     }
  4190.     *p = '\0';                          /* Start off with null string. */
  4191.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4192.       ckstrncat(p,s[i],x+1);
  4193.     y = (int)strlen(p);                 /* Final precaution. */
  4194.     debug(F111,"addmmac constructed string",p,y);
  4195.     if (y == x) {
  4196.         y = addmac(nam,p);              /* Add result to the macro table. */
  4197.     } else {
  4198.         debug(F100,"addmmac length mismatch","",0);
  4199.         printf("\n!addmmac internal error!\n");
  4200.         y = -1;
  4201.     }
  4202.     free(p);                            /* Free the temporary copy. */
  4203.     return(y);
  4204. }
  4205.  
  4206. /* Here is the real addmac routine. */
  4207.  
  4208. /* Returns -1 on failure, macro table index >= 0 on success. */
  4209.  
  4210. int mtchanged = 0;
  4211.  
  4212. int
  4213. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4214.     int i, x, y, z, namlen, deflen, flag = 0;
  4215.     int replacing = 0, deleting = 0;
  4216.     char * p = NULL, c, *s;
  4217.     extern int tra_asg; int tra_tmp;
  4218.  
  4219.     if (!nam) return(-1);
  4220.     if (!*nam) return(-1);
  4221.  
  4222. #ifdef IKSD
  4223.     if (inserver &&
  4224. #ifdef IKSDCONF
  4225.         iksdcf
  4226. #else /* IKSDCONF */
  4227.         1
  4228. #endif /* IKSDCONF */
  4229.         ) {
  4230.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4231.             !ckstrcmp("on_logout",nam,-1,0))
  4232.           return(-1);
  4233.     }
  4234. #endif /* IKSD */
  4235.  
  4236.     namlen = 0;
  4237.     p = nam;
  4238.     while (*p++) namlen++;              /* (instead of strlen) */
  4239.  
  4240.     tra_tmp = tra_asg;                  /* trace... */
  4241.     debug(F111,"addmac nam",nam,namlen);
  4242.     if (!def) {                         /* Watch out for null pointer */
  4243.         deflen = 0;
  4244.         debug(F111,"addmac def","(null pointer)",deflen);
  4245.     } else {
  4246.         deflen = 0;
  4247.         p = def;
  4248.         while (*p++) deflen++;          /* (instead of strlen) */
  4249.         debug(F010,"addmac def",def,0);
  4250.     }
  4251. #ifdef USE_VARLEN                       /* NOT USED */
  4252.     /* This does not boost performance much because varlen() does a lot */
  4253.     x = varlen(nam,&s);
  4254.     if (x > 0 && x >= deflen) {
  4255.         strcpy(s,def);                  /* NOT USED */
  4256.         flag = 1;
  4257.         p = s;
  4258.     }
  4259. #endif /* USE_VARLEN */
  4260.  
  4261.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4262.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4263.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4264.         if (!flag) {
  4265.             tra_asg = 0;
  4266.             delmac(nam,0);              /* Delete any old value. */
  4267.             tra_asg = tra_tmp;
  4268.         }
  4269.         if (deflen < 1) {               /* Null definition */
  4270.             p = NULL;                   /* Better not malloc or strcpy! */
  4271.         } else if (!flag) {             /* A substantial definition */
  4272.             p = malloc(deflen + 1);     /* Allocate space for it */
  4273.             if (!p) {
  4274.                 printf("?addmac malloc error 2\n");
  4275.                 return(-1);
  4276.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4277.         }
  4278.  
  4279.         /* Now p points to the definition, or is a null pointer */
  4280.  
  4281.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4282.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4283.                 g_var[c] = p;           /* No, it's top level one */
  4284.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4285.             } else {                    /* Yes, it's a macro argument */
  4286.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4287.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4288.             }
  4289.         } else {                        /* It's a \%a-z variable */
  4290.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4291.             if (isupper(c)) c = (char) tolower(c);
  4292.             g_var[c] = p;               /* Put pointer in global-var table */
  4293.         }
  4294.         if (tra_asg) traceval(nam,p);
  4295.         return(0);
  4296.     } else if (*nam == '&') {           /* An array reference? */
  4297.         char **q = NULL;
  4298.         int rc = 0;
  4299.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4300.           return(-1);                   /* return -1. */
  4301.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4302.           rc = -2;                      /* subscript out of range, ret -2 */
  4303.         if (!flag) {
  4304.             tra_asg = 0;
  4305.             delmac(nam,0);              /* Delete any old value. */
  4306.             tra_asg = tra_tmp;
  4307.         }
  4308.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4309.         if (x > 'z' - ARRAYBASE + 1)
  4310.           rc = -1;
  4311.         if (rc != -1) {
  4312.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4313.               return(-3);               /* return -3. */
  4314.         }
  4315.         if (rc < 0)
  4316.           return(rc);
  4317.         if (!flag) {
  4318.             if (deflen > 0) {
  4319.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4320.                     printf("addmac macro error 7: %s\n",nam);
  4321.                     return(-4);         /* for new def, return -4 on fail. */
  4322.                 }
  4323.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4324.             } else p = NULL;
  4325.         }
  4326.         q[z] = p;                       /* Store pointer to it. */
  4327.         if (x == 0) {                   /* Arg vector array */
  4328.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4329.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4330.                     makestr(&(toparg[z]),p);
  4331.                 } else {
  4332.                     makestr(&(m_arg[maclvl][z]),p);
  4333.                 }
  4334.             }
  4335.         }
  4336.         if (tra_asg) traceval(nam,p);
  4337.         return(0);                      /* Done. */
  4338.     }
  4339.  
  4340. /* Not a macro argument or a variable, so it's a macro definition */
  4341.  
  4342. #ifdef USE_VARLEN
  4343.     if (flag) {
  4344.         if (tra_asg) traceval(nam,p);
  4345.         return(0);
  4346.     }
  4347. #endif /* USE_VARLEN */
  4348.     x = isaa(nam) ?                     /* If it's an associative array */
  4349.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4350.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4351.     if (x > -1) {                       /* If found... */
  4352.         if (deflen > 0)                 /* and a new definition was given */
  4353.           replacing = 1;                /* we're replacing */
  4354.         else                            /* otherwise */
  4355.           deleting = 1;                 /* we're deleting */
  4356.     }
  4357.     if (deleting) {                     /* Deleting... */
  4358.         if (delmac(nam,0) < 0)
  4359.           return(-1);
  4360.         mtchanged++;
  4361.         if (tra_asg) traceval(nam,p);
  4362.         return(0);
  4363.     } else if (deflen < 1)              /* New macro with no definition */
  4364.       return(0);                        /* Nothing to do. */
  4365.  
  4366.     if (replacing) {                    /* Replacing an existing macro */
  4367.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4368.             free(mactab[x].mval);       /* free it. */
  4369.             mactab[x].mval = NULL;
  4370.         }
  4371.         mtchanged++;
  4372.         y = x;                          /* Replacement index. */
  4373.  
  4374.     } else {                            /* Adding a new macro... */
  4375.         char c1, c2;                    /* Use fast lookup to find the */
  4376.         c1 = *nam;                      /* alphabetical slot. */
  4377.         if (isupper(c1)) c1 = (char) tolower(c1);
  4378.  
  4379.         if (nmac < 5) {                 /* Not worth it for small tables */
  4380.             y = 0;
  4381.         } else {                        /* First binary search to find */
  4382.             int lo = 0;                 /* where to start */
  4383.             int hi = nmac;
  4384.             int count = 0;
  4385.             char c = 0;
  4386.             while (lo+2 < hi && ++count < 12) {
  4387.                 y = lo + ((hi - lo) / 2);
  4388.                 c = *(mactab[y].kwd);
  4389.                 if (isupper(c)) c = (char) tolower(c);
  4390.                 if (c < c1) {
  4391.                     lo = y;
  4392.                 } else {
  4393.                     hi = y;
  4394.                 }
  4395.             }
  4396.             y = (c < c1) ? lo+1 : lo;
  4397.         }
  4398.         /* Now search linearly from starting location */
  4399.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4400.             c2 = *(mactab[y].kwd);
  4401.             if (isupper(c2)) c2 = (char) tolower(c2);
  4402.             if (c1 > c2)
  4403.               continue;
  4404.             if (c1 < c2)
  4405.               break;
  4406.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4407.               break;
  4408.         }
  4409.         if (y == MAC_MAX) {             /* Macro table is full. */
  4410.             debug(F101,"addmac table overflow","",y);
  4411.             printf("?Macro table overflow\n");
  4412.             return(-1);
  4413.         }
  4414.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4415.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4416.                 mactab[i].kwd = mactab[i-1].kwd;
  4417.                 mactab[i].mval = mactab[i-1].mval;
  4418.                 mactab[i].flgs = mactab[i-1].flgs;
  4419.             }
  4420.         }
  4421.         mtchanged++;
  4422.         p = malloc(namlen + 1);         /* Allocate space for name */
  4423.         if (!p) {
  4424.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4425.             return(-1);
  4426.         }
  4427.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4428.         mactab[y].kwd = p;              /* Add pointer to table */
  4429.     }
  4430.     if (deflen > 0) {                   /* If we have a definition */
  4431.         p = malloc(deflen + 1);         /* Get space */
  4432.         if (p == NULL) {
  4433.             printf("?Space exhausted - \"%s\"\n", nam);
  4434.             if (mactab[y].kwd) {
  4435.                 free(mactab[y].kwd);
  4436.                 mactab[y].kwd = NULL;
  4437.             }
  4438.             return(-1);
  4439.         } else {
  4440.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4441.         }
  4442.     } else {                            /* definition is empty */
  4443.         p = NULL;
  4444.     }
  4445.     mactab[y].mval = p;                 /* Macro points to definition */
  4446.     mactab[y].flgs = 0;                 /* No flags */
  4447.     if (!replacing)                     /* If new macro */
  4448.       nmac++;                           /* count it */
  4449.     if (tra_asg) traceval(nam,p);
  4450.     return(y);
  4451. }
  4452.  
  4453. int
  4454. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4455.     int i;
  4456.     extern int tra_asg;
  4457.     if (x < 0) return(x);
  4458.     if (tra_asg)
  4459.       traceval(mactab[x].kwd,NULL);
  4460.  
  4461.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4462.         free(mactab[x].kwd);
  4463.         mactab[x].kwd = NULL;
  4464.     }
  4465.     if (mactab[x].mval) {               /* and for the definition */
  4466.         free(mactab[x].mval);
  4467.         mactab[x].mval = NULL;
  4468.     }
  4469.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4470.         mactab[i].kwd = mactab[i+1].kwd;
  4471.         mactab[i].mval = mactab[i+1].mval;
  4472.         mactab[i].flgs = mactab[i+1].flgs;
  4473.     }
  4474.     nmac--;                             /* One less macro */
  4475.  
  4476.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4477.     mactab[nmac].mval = NULL;
  4478.     mactab[nmac].flgs = 0;
  4479.     mtchanged++;
  4480.     return(0);
  4481. }
  4482.  
  4483. int
  4484. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4485.     int x, z;
  4486.     char *p, c;
  4487.     extern int tra_asg;
  4488.  
  4489.     if (!nam) return(0);                /* Watch out for null pointer */
  4490.     debug(F110,"delmac nam",nam,0);
  4491. #ifdef IKSD
  4492.     if ( inserver &&
  4493. #ifdef IKSDCONF
  4494.         iksdcf
  4495. #else /* IKSDCONF */
  4496.         1
  4497. #endif /* IKSDCONF */
  4498.         ) {
  4499.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4500.             !ckstrcmp("on_logout",nam,-1,0))
  4501.           return(-1);
  4502.     }
  4503. #endif /* IKSD */
  4504.  
  4505.     if (*nam == CMDQ) nam++;
  4506.     if (*nam == '%') {                  /* If it's a variable name */
  4507.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4508.         p = (char *)0;                  /* Initialize value pointer */
  4509.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4510.             p = toparg[c - '0'];
  4511.             if (p) if (p != g_var[c]) {
  4512.                 free(p);
  4513.                 toparg[c - '0'] = NULL;
  4514.             }
  4515.             p = g_var[c];
  4516.             g_var[c] = NULL;            /* Zero the table entry */
  4517.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4518.             p = m_xarg[maclvl][c - '0'];
  4519.             if (p) if (p != g_var[c]) {
  4520.                 free(p);
  4521.                 m_xarg[maclvl][c - '0'] = NULL;
  4522.             }
  4523.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4524.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4525.         } else {                        /* It's a global variable */
  4526.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4527.             p = g_var[c];               /* Get pointer from global-var table */
  4528.             g_var[c] = NULL;            /* Zero the table entry */
  4529.         }
  4530.         if (p) {
  4531.             debug(F010,"delmac def",p,0);
  4532.             free(p);                    /* Free the storage */
  4533.             p = NULL;
  4534.         } else debug(F110,"delmac def","(null pointer)",0);
  4535.         if (tra_asg) traceval(nam,NULL);
  4536.         return(0);
  4537.     }
  4538.     if (*nam == '&') {                  /* An array reference? */
  4539.         char **q;
  4540.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4541.           return(-1);                   /* return -1. */
  4542.         x -= ARRAYBASE;                 /* Convert name to number. */
  4543.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4544.           return(-2);                   /* return -2. */
  4545.         if (z > a_dim[x])               /* If subscript out of range, */
  4546.           return(-3);                   /* return -3. */
  4547.         if (q[z]) {                     /* If there is an old value, */
  4548.             debug(F010,"delmac def",q[z],0);
  4549.             if (x != 0)                 /* Macro arg vector is just a copy */
  4550.               free(q[z]);               /* Others are real so free them */
  4551.             q[z] = NULL;
  4552.             if (x == 0) {               /* Arg vector array */
  4553.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4554.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4555.                         makestr(&(toparg[z]),NULL);
  4556.                     } else {
  4557.                         makestr(&(m_arg[maclvl][z]),NULL);
  4558.                     }
  4559.                 }
  4560.             }
  4561.             if (tra_asg) traceval(nam,NULL);
  4562.         } else debug(F010,"delmac def","(null pointer)",0);
  4563.     }
  4564.  
  4565.    /* Not a variable or an array, so it must be a macro. */
  4566.  
  4567.     z = isaa(nam);
  4568.     debug(F111,"delmac isaa",nam,z);
  4569.     debug(F111,"delmac exact",nam,exact);
  4570.     x = z ? mxxlook(mactab,nam,nmac) :
  4571.       exact ? mxlook(mactab,nam,nmac) :
  4572.         mlook(mactab,nam,nmac);
  4573.     if (x < 0) {
  4574.         debug(F111,"delmac mlook",nam,x);
  4575.         return(x);
  4576.     }
  4577.     return(xdelmac(x));
  4578. }
  4579.  
  4580. VOID
  4581. initmac() {                             /* Init macro & variable tables */
  4582.     int i, j, x;
  4583.  
  4584.     nmac = 0;                           /* No macros */
  4585.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4586.         mactab[i].kwd = NULL;
  4587.         mactab[i].mval = NULL;
  4588.         mactab[i].flgs = 0;
  4589.     }
  4590.     mtchanged++;
  4591.     x = (MAXARGLIST + 1) * sizeof(char **);
  4592.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4593.         m_xarg[i] = (char **) malloc(x);
  4594.         mrval[i] = NULL;                /* Macro return value */
  4595.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4596.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4597.             if (j < 10)                 /* For the \%0..\%9 variables */
  4598.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4599.             if (m_xarg[i])              /* For \&_[] - all args. */
  4600.               m_xarg[i][j] = NULL;
  4601.         }
  4602.     }
  4603.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4604.         g_var[i] = NULL;
  4605.     }
  4606.     /* And the table of arrays */
  4607.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4608.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4609.         a_dim[i] = 0;                   /* and a dimension of zero */
  4610.         a_link[i] = -1;
  4611.         for (j = 0; j < CMDSTKL; j++) {
  4612.             aa_ptr[j][i] = (char **) NULL;
  4613.             aa_dim[j][i] = 0;
  4614.         }
  4615.     }
  4616. }
  4617.  
  4618. int
  4619. popclvl() {                             /* Pop command level, return cmdlvl */
  4620.     extern int tra_cmd;
  4621.     struct localvar * v;
  4622.     int i, topcmd;
  4623.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4624.     if (cmdlvl > 0) {
  4625.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4626.             while (v) {                 /* Yes */
  4627.                 if (v->lv_value)        /* Copy old ones back */
  4628.                   addmac(v->lv_name,v->lv_value);
  4629.                 else
  4630.                   delmac(v->lv_name,1);
  4631.                 v = v->lv_next;
  4632.             }
  4633.             freelocal(cmdlvl);          /* Free local storage */
  4634.         }
  4635.         /* Automatic arrays do not use the localhead list */
  4636.  
  4637.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4638.             if (aa_ptr[cmdlvl][i]) {    /* Does this one exist? */
  4639.                 dclarray((char)(i+ARRAYBASE),-1); /* Destroy global one */
  4640.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4641.                 a_dim[i] = aa_dim[cmdlvl][i];
  4642.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4643.                 aa_dim[cmdlvl][i] = 0;
  4644.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4645.                 dclarray((char)(i+ARRAYBASE),-1); /* (see pusharray()) */
  4646.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4647.                 aa_dim[cmdlvl][i] = 0;
  4648.             }
  4649.  
  4650.             /* Otherwise do nothing - it is a local array that was declared */
  4651.             /* at a level above this one so leave it alone. */
  4652.         }
  4653.     }
  4654.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4655.         cmdlvl = 0;                     /* just make sure all the */
  4656.         tlevel = -1;                    /* stack pointers are set right */
  4657.         maclvl = -1;                    /* and return */
  4658.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4659.         debug(F101,"popclvl tlevel","",tlevel);
  4660.         if (tlevel > -1) {              /* Yes, */
  4661.             fclose(tfile[tlevel]);      /* close it */
  4662.  
  4663.             if (tra_cmd)
  4664.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4665.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4666.             if (tfnam[tlevel]) {        /* free storage for name */
  4667.                 free(tfnam[tlevel]);
  4668.                 tfnam[tlevel] = NULL;
  4669.             }
  4670.             tlevel--;                   /* and pop take level */
  4671.             cmdlvl--;                   /* and command level */
  4672.             quiet = xquiet[cmdlvl];
  4673.             vareval = xvarev[cmdlvl];
  4674.         } else
  4675.           tlevel = -1;
  4676.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4677.         topcmd = lastcmd[maclvl];
  4678.         debug(F101,"popclvl maclvl","",maclvl);
  4679.         if (maclvl > -1) {              /* Yes, */
  4680. #ifdef COMMENT
  4681.             int i;
  4682.             char **q;
  4683. #endif /* COMMENT */
  4684.             macp[maclvl] = "";          /* set macro pointer to null string */
  4685.             *cmdbuf = '\0';             /* clear the command buffer */
  4686.  
  4687.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4688.                 (m_arg[maclvl-1][0]) &&
  4689.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4690.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4691.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4692.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4693.                 mrval[maclvl+1]) {
  4694.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4695.             }
  4696.             if (maclvl+1 < MACLEVEL) {
  4697.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4698.                     free(mrval[maclvl+1]);
  4699.                     mrval[maclvl+1] = NULL;
  4700.                 }
  4701.             }
  4702.             if (tra_cmd)
  4703.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4704.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4705.  
  4706.             maclvl--;                   /* Pop macro level */
  4707.             cmdlvl--;                   /* and command level */
  4708.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4709.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4710.  
  4711.             quiet = xquiet[cmdlvl];
  4712.         vareval = xvarev[cmdlvl];
  4713.             if (maclvl > -1) {
  4714.                 a_ptr[0] = m_xarg[maclvl];
  4715.                 a_dim[0] = n_xarg[maclvl] - 1;
  4716.         debug(F111,"a_dim[0]","B",a_dim[0]);
  4717.             } else {
  4718.                 a_ptr[0] = topxarg;
  4719.                 a_dim[0] = topargc - 1;
  4720.         debug(F111,"a_dim[0]","C",a_dim[0]);
  4721.             }
  4722.         } else {
  4723.             maclvl = -1;
  4724.         }
  4725. #ifndef NOSEXP
  4726.         debug(F101,"popclvl topcmd","",topcmd);
  4727.         if (topcmd == XXSEXP) {
  4728.             extern char * sexpval;
  4729.             makestr(&(mrval[maclvl+1]),sexpval);
  4730.         }
  4731. #endif /* NOSEXP */
  4732.     } else {
  4733.         cmdlvl--;
  4734.     }
  4735.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4736.     if (prstring[cmdlvl]) {
  4737.         cmsetp(prstring[cmdlvl]);
  4738.         makestr(&(prstring[cmdlvl]),NULL);
  4739.     }
  4740. #ifndef MAC
  4741.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4742.         setint();
  4743.         concb((char)escape);            /* Go into cbreak mode */
  4744.     }
  4745. #endif /* MAC */
  4746.     xcmdsrc = cmdstk[cmdlvl].src;
  4747.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4748.     debug(F101,"popclvl tlevel","",tlevel);
  4749.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4750. }
  4751. #else /* No script programming language */
  4752. int popclvl() {                         /* Just close current take file. */
  4753.     if (tlevel > -1) {                  /* if any... */
  4754.         if (tfnam[tlevel]) {
  4755.             free(tfnam[tlevel]);
  4756.             tfnam[tlevel] = NULL;
  4757.         }
  4758.         fclose(tfile[tlevel--]);
  4759.     }
  4760.     if (tlevel == -1) {                 /* And if back at top level */
  4761.         setint();
  4762.         concb((char)escape);            /* and go back into cbreak mode. */
  4763.     }
  4764.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4765.     return(tlevel + 1);
  4766. }
  4767. #endif /* NOSPL */
  4768.  
  4769.  
  4770. #ifndef NOSPL
  4771. static int
  4772. iseom(m) char * m; {                    /* Test if at end of macro def */
  4773.     if (!m)
  4774.       m = "";
  4775.     debug(F111,"iseom",m,maclvl);
  4776.     while (*m) {
  4777.         /* Anything but Space and Comma means more macro is left */
  4778.         if ((*m > SP) && (*m != ',')) {
  4779.             debug(F111,"iseom return",m,0);
  4780.             return(0);
  4781.         }
  4782.         m++;
  4783.     }
  4784.     debug(F111,"iseom return",m,1);
  4785.     return(1);                          /* Nothing left */
  4786. }
  4787. #endif /* NOSPL */
  4788.  
  4789. /* Pop all command levels that can be popped */
  4790.  
  4791. int
  4792. prepop() {
  4793.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4794.         while (
  4795. #ifndef NOSPL
  4796.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4797. #endif /* NOSPL */
  4798.             (tlevel > -1) &&
  4799.             feof(tfile[tlevel]))        /* And at end of file... */
  4800. #ifndef NOSPL
  4801.                /* Or command source is macro... */
  4802.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4803.                 (maclvl > -1) &&
  4804.                 iseom(macp[maclvl])))  /* and at end of macro, then... */
  4805. #endif /* NOSPL */
  4806.         {
  4807.               popclvl();                /* pop command level. */
  4808.         }
  4809.     }
  4810.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4811. }
  4812.  
  4813. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4814.  
  4815. int
  4816. dostop() {
  4817.     extern int cmddep;
  4818.     while (popclvl()) ;         /* Pop all macros & take files */
  4819. #ifndef NOSPL
  4820.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4821.       while (cmpop() > -1) ;
  4822. #endif /* NOSPL */
  4823.     cmini(ckxech);              /* Clear the command buffer. */
  4824.     return(0);
  4825. }
  4826.  
  4827. /* Close the given log */
  4828.  
  4829. int
  4830. doclslog(x) int x; {
  4831.     int y;
  4832.     switch (x) {
  4833. #ifdef DEBUG
  4834.       case LOGD:
  4835.         if (deblog <= 0) {
  4836.             printf("?Debugging log wasn't open\n");
  4837.             return(0);
  4838.         }
  4839.         debug(F100,"Debug Log Closed","",0L);
  4840.         *debfil = '\0';
  4841.         deblog = 0;
  4842.         return(zclose(ZDFILE));
  4843. #endif /* DEBUG */
  4844.  
  4845. #ifndef NOXFER
  4846.       case LOGP:
  4847.         if (pktlog <= 0) {
  4848.             printf("?Packet log wasn't open\n");
  4849.             return(0);
  4850.         }
  4851.         *pktfil = '\0';
  4852.         pktlog = 0;
  4853.         return(zclose(ZPFILE));
  4854. #endif /* NOXFER */
  4855.  
  4856. #ifndef NOLOCAL
  4857.       case LOGS:
  4858.         if (seslog <= 0) {
  4859.             printf("?Session log wasn't open\n");
  4860.             return(0);
  4861.         }
  4862.         *sesfil = '\0';
  4863.         setseslog(0);
  4864.         return(zclose(ZSFILE));
  4865. #endif /* NOLOCAL */
  4866.  
  4867. #ifdef TLOG
  4868.       case LOGT: {
  4869. #ifdef IKSD
  4870.           extern int iklogopen, xferlog;
  4871. #endif /* IKSD */
  4872.           if (tralog <= 0
  4873. #ifdef IKSD
  4874.               && !iklogopen
  4875. #endif /* IKSD */
  4876.               ) {
  4877.               if (msgflg)
  4878.                 printf("?Transaction log wasn't open\n");
  4879.               return(0);
  4880.           }
  4881. #ifdef IKSD
  4882.           if (iklogopen && !inserver) {
  4883.               close(xferlog);
  4884.               iklogopen = 0;
  4885.           }
  4886. #endif /* IKSD */
  4887.           if (tralog) {
  4888.               tlog(F100,"Transaction Log Closed","",0L);
  4889.               zclose(ZTFILE);
  4890.           }
  4891.           *trafil = '\0';
  4892.           tralog = 0;
  4893.           return(1);
  4894.       }
  4895. #endif /* TLOG */
  4896.  
  4897. #ifdef CKLOGDIAL
  4898.       case LOGM:
  4899.         if (dialog <= 0) {
  4900.             if (msgflg) printf("?Connection log wasn't open\n");
  4901.             return(0);
  4902.         }
  4903.         *diafil = '\0';
  4904.         dialog = 0;
  4905.         return(zclose(ZDIFIL));
  4906. #endif /* CKLOGDIAL */
  4907.  
  4908. #ifndef NOSPL
  4909.       case LOGW:                        /* WRITE file */
  4910.       case LOGR:                        /* READ file */
  4911.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4912.         if (chkfn(y) < 1)               /* If no file to close */
  4913.           return(1);                    /* succeed silently. */
  4914.         return(zclose(y));              /* Otherwise, close the file. */
  4915. #endif /* NOSPL */
  4916.  
  4917.       default:
  4918.         printf("\n?Unexpected log designator - %d\n", x);
  4919.         return(0);
  4920.     }
  4921. }
  4922.  
  4923. static int slc = 0;                     /* Screen line count */
  4924.  
  4925. char *
  4926. showstring(s) char * s; {
  4927.     return(s ? s : "(null)");
  4928. }
  4929.  
  4930. char *
  4931. showoff(x) int x; {
  4932.     return(x ? "on" : "off");
  4933. }
  4934.  
  4935. char *
  4936. showooa(x) int x; {
  4937.     switch (x) {
  4938.       case SET_OFF:  return("off");
  4939.       case SET_ON:   return("on");
  4940.       case SET_AUTO: return("automatic");
  4941.       default:       return("(unknown)");
  4942.     }
  4943. }
  4944.  
  4945. #ifdef GEMDOS
  4946. isxdigit(c) int c; {
  4947.     return(isdigit(c) ||
  4948.            (c >= 'a' && c <= 'f') ||
  4949.            (c >= 'A' && c <= 'F'));
  4950. }
  4951. #endif /* GEMDOS */
  4952.  
  4953. #ifndef NOSETKEY
  4954. #ifdef OS2
  4955. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4956.     "all",    1, 0,
  4957.     "one",    0, 0
  4958. };
  4959. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4960.  
  4961. #define SHKEYDEF TT_MAX+5
  4962. struct keytab shokeymtab[] = {
  4963.     "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
  4964.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4965.     "adm5",      TT_ADM5,    0,         /* LSI ADM-5 */
  4966.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4967.     "annarbor",  TT_AAA,     0,         /* AnnArbor */
  4968.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4969.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4970.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4971.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4972.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4973.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4974.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4975.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4976.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4977.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4978.     "default",   SHKEYDEF,   0,
  4979.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4980.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4981.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4982.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4983.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4984.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4985.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4986.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4987.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4988.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4989.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4990.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4991.     "linux",     TT_LINUX,   0,         /* Linux */
  4992.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4993.     "qnx",       TT_QNX,     0,         /* QNX */
  4994.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4995.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4996.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4997.     "sun",       TT_SUN,     0,         /* Sun Console */
  4998. #ifdef OS2PM
  4999. #ifdef COMMENT
  5000.     "tek4014", TT_TEK40, 0,
  5001. #endif /* COMMENT */
  5002. #endif /* OS2PM */
  5003.     "tty",     TT_NONE,  0,
  5004.     "tvi910+", TT_TVI910, 0,
  5005.     "tvi925",  TT_TVI925, 0,
  5006.     "tvi950",  TT_TVI950, 0,
  5007.     "vc404",   TT_VC4404, 0,
  5008.     "vc4404",  TT_VC4404, CM_INV,
  5009.     "vip7809", TT_VIP7809, 0,
  5010.     "vt100",   TT_VT100, 0,
  5011.     "vt102",   TT_VT102, 0,
  5012.     "vt220",   TT_VT220, 0,
  5013.     "vt220pc", TT_VT220PC, 0,
  5014.     "vt320",   TT_VT320, 0,
  5015.     "vt320pc", TT_VT320PC, 0,
  5016.     "vt52",    TT_VT52,  0,
  5017.     "wp",      TT_KBM_WP, 0,
  5018.     "wy160",   TT_WY160,  0,
  5019.     "wy30",    TT_WY30,  0,
  5020.     "wy370",   TT_WY370, 0,
  5021.     "wy50",    TT_WY50,  0,
  5022.     "wy60",    TT_WY60,  0,
  5023.     "wyse30",  TT_WY30,  CM_INV,
  5024.     "wyse370", TT_WY370, CM_INV,
  5025.     "wyse50",  TT_WY50,  CM_INV,
  5026.     "wyse60",  TT_WY60,  CM_INV
  5027. };
  5028. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  5029. #endif /* OS2 */
  5030.  
  5031. VOID
  5032. #ifdef OS2
  5033. shokeycode(c,m) int c, m;
  5034. #else
  5035. shokeycode(c) int c;
  5036. #endif
  5037. /* shokeycode */ {
  5038.     KEY ch;
  5039.     CHAR *s;
  5040. #ifdef OS2
  5041.     int i;
  5042.     con_event km;
  5043. #else /* OS2 */
  5044.     int km;
  5045. #endif /* OS2 */
  5046.  
  5047. #ifdef OS2
  5048.     extern int mskkeys;
  5049.     char * mstr = "";
  5050.  
  5051.     if (c >= KMSIZE) {
  5052.         bleep(BP_FAIL);
  5053.         return;
  5054.     }
  5055. #else /* OS2 */
  5056.     printf(" Key code \\%d => ", c);
  5057. #endif /* OS2 */
  5058.  
  5059. #ifndef OS2
  5060.     km = mapkey(c);
  5061.  
  5062. #ifndef NOKVERBS
  5063.     if (IS_KVERB(km)) {                 /* \Kverb? */
  5064.         int i, kv;
  5065.         kv = km & ~(F_KVERB);
  5066.         printf("Verb: ");
  5067.         for (i = 0; i < nkverbs; i++)
  5068.           if (kverbs[i].kwval == kv) {
  5069.               printf("\\K%s",kverbs[i].kwd);
  5070.               break;
  5071.           }
  5072.         printf("\n");
  5073.     } else
  5074. #endif /* NOKVERBS */
  5075.       if (IS_CSI(km)) {
  5076.           int xkm = km & 0xFF;
  5077.           if (xkm <= 32 || xkm >= 127)
  5078.             printf("String: \\{27}[\\{%d}\n",xkm);
  5079.           else
  5080.             printf("String: \\{27}[%c\n",xkm);
  5081.       } else if (IS_ESC(km)) {
  5082.           int xkm = km & 0xFF;
  5083.           if (xkm <= 32 || xkm >= 127)
  5084.             printf("String: \\{27}\\{%d}\n",xkm);
  5085.           else
  5086.             printf("String: \\{27}%c\n",xkm);
  5087.       } else if (macrotab[c]) {         /* See if there's a macro */
  5088.           printf("String: ");           /* If so, display its definition */
  5089.           s = macrotab[c];
  5090.           shostrdef(s);
  5091.           printf("\n");
  5092. #ifndef NOKVERBS
  5093.     } else if (km >= 0x100) {           /* This means "undefined" */
  5094.         printf("Undefined\n");
  5095. #endif /* NOKVERBS */
  5096.     } else {                            /* No macro, show single character */
  5097.         printf("Character: ");
  5098.         ch = km;
  5099.         if (ch < 32 || ch == 127
  5100. #ifdef OS2
  5101.             || ch > 255
  5102. #endif /* OS2 */
  5103. #ifndef NEXT
  5104. #ifndef AUX
  5105. #ifndef XENIX
  5106. #ifndef OS2
  5107.             || (ch > 127 && ch < 160)
  5108. #endif /* OS2 */
  5109. #endif /* XENIX */
  5110. #endif /* AUX */
  5111. #endif /* NEXT */
  5112.             )
  5113. /*
  5114.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5115.   %u is supposed to be totally portable.
  5116. */
  5117.           printf("\\%u",(unsigned int) ch);
  5118.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5119.         if (ch == (KEY) c)
  5120.           printf(" (self, no translation)\n");
  5121.         else
  5122.           printf("\n");
  5123.     }
  5124. #else /* OS2 */
  5125.     if (m < 0) {
  5126.         km = mapkey(c);
  5127.         mstr = "default";
  5128.     } else {
  5129.         km = maptermkey(c,m);
  5130.         for (i = 0; i < nshokeym; i++) {
  5131.             if (m == shokeymtab[i].kwval) {
  5132.                 mstr = shokeymtab[i].kwd;
  5133.                 break;
  5134.             }
  5135.         }
  5136.     }
  5137.     s = keyname(c);
  5138.     debug(F111,"shokeycode mstr",mstr,m);
  5139.     debug(F111,"shokeycode keyname",s,c);
  5140.     printf(" %sKey code \\%d %s (%s) => ",
  5141.             mskkeys ? "mskermit " : "",
  5142.             mskkeys ? cktomsk(c) : c,
  5143.             s == NULL ? "" : s, mstr);
  5144.  
  5145.     switch (km.type) {
  5146. #ifndef NOKVERBS
  5147.       case kverb: {
  5148.           int i, kv;
  5149.           kv = km.kverb.id & ~(F_KVERB);
  5150.           printf("Verb: ");
  5151.           for (i = 0; i < nkverbs; i++) {
  5152.               if (kverbs[i].kwval == kv) {
  5153.                   printf("\\K%s",kverbs[i].kwd);
  5154.                   break;
  5155.               }
  5156.           }
  5157.           printf("\n");
  5158.           break;
  5159.       }
  5160. #endif /* NOKVERBS */
  5161.       case csi: {
  5162.           int xkm = km.csi.key & 0xFF;
  5163.           if (xkm <= 32 || xkm >= 127)
  5164.             printf("String: \\{27}[\\{%d}\n",xkm);
  5165.           else
  5166.             printf("String: \\{27}[%c\n",xkm);
  5167.           break;
  5168.       }
  5169.       case esc: {
  5170.           int xkm = km.esc.key & 0xFF;
  5171.           if (xkm <= 32 || xkm >= 127)
  5172.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  5173.           else
  5174.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  5175.           break;
  5176.       }
  5177.       case macro: {
  5178.           printf("String: ");           /* Macro, display its definition */
  5179.           shostrdef(km.macro.string);
  5180.           printf("\n");
  5181.           break;
  5182.       }
  5183.       case literal: {
  5184.           printf("Literal string: ");   /* Literal, display its definition */
  5185.           shostrdef(km.literal.string);
  5186.           printf("\n");
  5187.           break;
  5188.       }
  5189.       case error: {
  5190.           if (c >= 0x100) {
  5191.               printf("Undefined\n");
  5192.           } else {
  5193.               printf("Character: ");
  5194.               ch = c;
  5195.               if (ch < 32 || ch == 127 || ch > 255
  5196. #ifndef NEXT
  5197. #ifndef AUX
  5198. #ifndef XENIX
  5199. #ifndef OS2
  5200.                    || (ch > 127 && ch < 160)
  5201. #endif /* OS2 */
  5202. #endif /* XENIX */
  5203. #endif /* AUX */
  5204. #endif /* NEXT */
  5205.                    )
  5206. /*
  5207.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5208.   %u is supposed to be totally portable.
  5209. */
  5210.                   printf("\\%u",(unsigned int) ch);
  5211.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5212.               printf(" (self, no translation)\n");
  5213.           }
  5214.           break;
  5215.       }
  5216.       case key: {
  5217.           printf("Character: ");
  5218.           ch = km.key.scancode;
  5219.           if (ch < 32 || ch == 127 || ch > 255
  5220. #ifndef NEXT
  5221. #ifndef AUX
  5222. #ifndef XENIX
  5223. #ifndef OS2
  5224.               || (ch > 127 && ch < 160)
  5225. #else
  5226.                || (ch > 127)
  5227. #endif /* OS2 */
  5228. #endif /* XENIX */
  5229. #endif /* AUX */
  5230. #endif /* NEXT */
  5231.               )
  5232. /*
  5233.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5234.   %u is supposed to be totally portable.
  5235. */
  5236.             printf("\\%u",(unsigned int) ch);
  5237.           else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5238.           if (ch == (KEY) c)
  5239.             printf(" (self, no translation)\n");
  5240.           else
  5241.             printf("\n");
  5242.           break;
  5243.       }
  5244.     }
  5245. #endif /* OS2 */
  5246. }
  5247. #endif /* NOSETKEY */
  5248.  
  5249. VOID
  5250. shostrdef(s) CHAR * s; {
  5251.     CHAR ch;
  5252.     if (!s) s = (CHAR *)"";
  5253.     while ((ch = *s++)) {
  5254.         if (ch < 32 || ch == 127 || ch == 255
  5255. /*
  5256.   Systems whose native character sets have graphic characters in C1...
  5257. */
  5258. #ifndef NEXT                            /* NeXT */
  5259. #ifndef AUX                             /* Macintosh */
  5260. #ifndef XENIX                           /* IBM PC */
  5261. #ifdef OS2
  5262. /*
  5263.   It doesn't matter whether the local host can display 8-bit characters;
  5264.   they are not portable among character-sets and fonts.  Who knows what
  5265.   would be displayed...
  5266. */
  5267.             || (ch > 127)
  5268. #else /* OS2 */
  5269.             || (ch > 127 && ch < 160)
  5270. #endif /* OS2 */
  5271. #endif /* XENIX */
  5272. #endif /* AUX */
  5273. #endif /* NEXT */
  5274.             )
  5275.           printf("\\{%d}",ch);          /* Display control characters */
  5276.         else putchar((char) ch);        /* in backslash notation */
  5277.     }
  5278. }
  5279.  
  5280. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5281.  
  5282. #ifndef NOSHOW
  5283. VOID
  5284. shover() {
  5285. #ifdef OS2
  5286.     extern char ckxsystem[];
  5287. #endif /* OS2 */
  5288.     extern char *ck_patch, * cklibv;
  5289.     printf("\nVersions:\n %s\n",versio);
  5290.     printf(" Numeric: %ld\n",vernum);
  5291. #ifdef OS2
  5292.     printf(" Operating System: %s\n", ckxsystem);
  5293. #else /* OS2 */
  5294.     printf(" Built for: %s\n", ckxsys);
  5295. #ifdef CK_UTSNAME
  5296.     if (unm_nam[0])
  5297.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5298. #endif /* CK_UTSNAME */
  5299.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5300. #endif /* OS2 */
  5301.     if (xxdiff(ckxv,ckxsys))
  5302.       printf(" %s for%s\n",ckxv,ckxsys);
  5303.     else
  5304.       printf(" %s\n",ckxv);
  5305.     if (xxdiff(ckzv,ckzsys))
  5306.       printf(" %s for%s\n",ckzv,ckzsys);
  5307.     else
  5308.       printf(" %s\n",ckzv);
  5309.     printf(" %s\n",cklibv);
  5310.     printf(" %s\n",protv);
  5311.     printf(" %s\n",fnsv);
  5312.     printf(" %s\n %s\n",cmdv,userv);
  5313. #ifndef NOCSETS
  5314.     printf(" %s\n",xlav);
  5315. #endif /* NOCSETS */
  5316. #ifndef MAC
  5317. #ifndef NOLOCAL
  5318.     printf(" %s\n",connv);
  5319. #ifdef OS2
  5320.     printf(" %s\n",ckyv);
  5321. #endif /* OS2 */
  5322. #endif /* NOLOCAL */
  5323. #endif /* MAC */
  5324. #ifndef NODIAL
  5325.     printf(" %s\n",dialv);
  5326. #endif /* NODIAL */
  5327. #ifndef NOSCRIPT
  5328.     printf(" %s\n",loginv);
  5329. #endif /* NOSCRIPT */
  5330. #ifdef NETCONN
  5331.     printf(" %s\n",cknetv);
  5332. #ifdef OS2
  5333.     printf(" %s\n",ckonetv);
  5334. #ifdef CK_NETBIOS
  5335.     printf(" %s\n",ckonbiv);
  5336. #endif /* CK_NETBIOS */
  5337. #endif /* OS2 */
  5338. #endif /* NETCONN */
  5339. #ifdef TNCODE
  5340.     printf(" %s\n",cktelv);
  5341. #endif /* TNCODE */
  5342. #ifdef SSHBUILTIN
  5343.     printf(" %s\n",cksshv);
  5344. #ifdef SFTP_BUILTIN
  5345.     printf(" %s\n",cksftpv);
  5346. #endif /* SFTP_BUILTIN */
  5347. #endif /* SSHBUILTIN */
  5348. #ifdef OS2
  5349. #ifdef OS2MOUSE
  5350.     printf(" %s\n",ckomouv);
  5351. #endif /* OS2MOUSE */
  5352. #endif /* OS2 */
  5353. #ifdef NEWFTP
  5354.     printf(" %s\n",ckftpv);
  5355. #endif /* NEWFTP */
  5356. #ifdef CK_AUTHENTICATION
  5357.     printf(" %s\n",ckathv);
  5358. #endif /* CK_AUTHENTICATION */
  5359. #ifdef CK_ENCRYPTION
  5360. #ifdef CRYPT_DLL
  5361.     printf(" %s\n",ck_crypt_dll_version());
  5362. #else /* CRYPT_DLL */
  5363.     printf(" %s\n",ckcrpv);
  5364. #endif /* CRYPT_DLL */
  5365. #endif /* CK_ENCRYPTION */
  5366. #ifdef CK_SSL
  5367.     printf(" %s\n",cksslv);
  5368. #endif /* CK_SSL */
  5369.     printf("\n");
  5370. }
  5371.  
  5372. #ifdef CK_LABELED
  5373. VOID
  5374. sholbl() {
  5375. #ifdef VMS
  5376.     printf("VMS Labeled File Features:\n");
  5377.     printf(" acl %s (ACL info %s)\n",
  5378.            showoff(lf_opts & LBL_ACL),
  5379.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5380.     printf(" backup-date %s (backup date/time %s)\n",
  5381.            showoff(lf_opts & LBL_BCK),
  5382.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5383.     printf(" name %s (original filename %s)\n",
  5384.            showoff(lf_opts & LBL_NAM),
  5385.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5386.     printf(" owner %s (original file owner id %s)\n",
  5387.            showoff(lf_opts & LBL_OWN),
  5388.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5389.     printf(" path %s (original file's disk:[directory] %s)\n",
  5390.            showoff(lf_opts & LBL_PTH),
  5391.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5392. #else
  5393. #ifdef OS2
  5394.     printf("OS/2 Labeled File features (attributes):\n");
  5395.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5396.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5397.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5398.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5399.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5400. #endif /* OS2 */
  5401. #endif /* VMS */
  5402. }
  5403. #endif /* CK_LABELED */
  5404.  
  5405. VOID
  5406. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5407. #ifndef NOCSETS
  5408. #ifdef OS2
  5409. #ifndef NOTERM
  5410.     extern struct _vtG G[4], *GL, *GR;
  5411.     extern int decnrcm, sni_chcode;
  5412.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5413.     extern prncs;
  5414.  
  5415.     printf(" Terminal character-sets:\n");
  5416.     if (IS97801(tt_type_mode)) {
  5417.         if (cmask == 0377)
  5418.           printf("     Mode: 8-bit Mode\n");
  5419.         else
  5420.           printf("     Mode: 7-bit Mode\n");
  5421.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5422.     } else if (ISVT100(tt_type_mode)) {
  5423.         if (decnrcm)
  5424.           printf("     Mode: 7-bit National Mode\n");
  5425.         else
  5426.           printf("     Mode: 8-bit Multinational Mode\n");
  5427.     }
  5428.     if ( isunicode() )
  5429.         printf("    Local: Unicode display / %s input\n",
  5430.                 csl == TX_TRANSP ? "transparent" :
  5431.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5432.     else
  5433.         printf("    Local: %s\n",
  5434.                 csl == TX_TRANSP ? "transparent" :
  5435.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5436.  
  5437.     if ( tt_utf8 ) {
  5438.         printf("   Remote: UTF-8\n");
  5439.     } else {
  5440.         printf("   Remote: %sG0: %s (%s)\n",
  5441.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5442.            txrinfo[G[0].designation]->keywd,
  5443.            G[0].designation == TX_TRANSP ? "" :
  5444.            G[0].size == cs94 ? "94 chars" :
  5445.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5446.         printf("           %sG1: %s (%s)\n",
  5447.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5448.            txrinfo[G[1].designation]->keywd,
  5449.            G[1].designation == TX_TRANSP ? "" :
  5450.            G[1].size == cs94 ? "94 chars" :
  5451.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5452.         printf("           %sG2: %s (%s)\n",
  5453.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5454.            txrinfo[G[2].designation]->keywd,
  5455.            G[2].designation == TX_TRANSP ? "" :
  5456.            G[2].size == cs94 ? "94 chars" :
  5457.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5458.         printf("           %sG3: %s (%s)\n",
  5459.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5460.            txrinfo[G[3].designation]->keywd,
  5461.            G[3].designation == TX_TRANSP ? "" :
  5462.            G[3].size == cs94 ? "94 chars" :
  5463.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5464.     }
  5465.     printf("\n");
  5466.     printf(" Keyboard character-sets:\n");
  5467.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5468.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5469.     printf("\n");
  5470.     printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5471. #endif /* NOTERM */
  5472. #else /* OS2 */
  5473. #ifndef MAC
  5474.     char *s;
  5475.  
  5476.     debug(F101,"TERM LOCAL CSET","",csl);
  5477.     debug(F101,"TERM REMOTE CSET","",csr);
  5478.     printf(" Terminal character-set: ");
  5479.     if (tcs_transp) {                   /* No translation */
  5480.         printf("transparent\n");
  5481.     } else {                            /* Translation */
  5482.         printf("%s (remote) %s (local)\n",
  5483.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5484.         if (csr != csl) {
  5485.             switch(gettcs(csr,csl)) {
  5486.               case TC_USASCII:  s = "ascii";        break;
  5487.               case TC_1LATIN:   s = "latin1-iso";   break;
  5488.               case TC_2LATIN:   s = "latin2-iso";   break;
  5489.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5490.               case TC_JEUC:     s = "japanese-euc"; break;
  5491.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5492.               case TC_GREEK:    s = "greek-iso";    break;
  5493.               case TC_9LATIN:   s = "latin9-iso";   break;
  5494.               default:          s = "transparent";  break;
  5495.             }
  5496.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5497.                 strcmp(s,fcsinfo[csr].keyword))
  5498.               printf("                         (via %s)\n",s);
  5499.         }
  5500.     }
  5501. #endif /* MAC */
  5502. #endif /* OS2 */
  5503. #endif /* NOCSETS */
  5504. }
  5505.  
  5506. #ifndef NOLOCAL
  5507. #ifdef OS2
  5508. extern char htab[];
  5509. VOID
  5510. shotabs() {
  5511.     int i,j,k,n;
  5512.  
  5513.     printf("Tab Stops:\n\n");
  5514.     for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5515.         do {
  5516.             printf("%c",htab[++i]=='T'?'T':'-');
  5517.         } while (i % k && i < MAXTERMCOL);
  5518.         printf("\n");
  5519.         for ( ; j <= i; j++) {
  5520.             switch ( j%10 ) {
  5521.           case 1:
  5522.                 printf("%c",j == 1 ? '1' : '.');
  5523.                 break;
  5524.           case 2:
  5525.           case 3:
  5526.           case 4:
  5527.           case 5:
  5528.           case 6:
  5529.           case 7:
  5530.                 printf("%c",'.');
  5531.                 break;
  5532.           case 8:
  5533.                 n = (j+2)/100;
  5534.                 if (n)
  5535.           printf("%d",n);
  5536.                 else 
  5537.           printf("%c",'.');
  5538.                 break;
  5539.           case 9:
  5540.                 n = (j+1)%100/10;
  5541.                 if (n)
  5542.           printf("%d",n);
  5543.                 else if (j>90)
  5544.           printf("0");
  5545.                 else 
  5546.           printf("%c",'.');
  5547.                 break;
  5548.           case 0:
  5549.                 printf("0");
  5550.                 break;
  5551.             }
  5552.         }
  5553.         printf("\n");
  5554.     }
  5555. #ifdef COMMENT
  5556.     for (i = 1; i <= 70; i++)
  5557.       printf("%c",htab[i]=='T'?'T':'-');
  5558.     printf("\n1.......10........20........30........40........50........60\
  5559. ........70\n\n");
  5560.     for (; i <= 140; i++)
  5561.       printf("%c",htab[i]=='T'?'T':'-');
  5562.     printf("\n........80........90.......100.......110.......120.......130\
  5563. .......140\n\n");
  5564.     for (; i <= 210; i++)
  5565.       printf("%c",htab[i]=='T'?'T':'-');
  5566.     printf("\n.......150.......160.......170.......180.......190.......200\
  5567. .......210\n\n");
  5568.     for (; i <= 255; i++)
  5569.       printf("%c",htab[i]=='T'?'T':'-');
  5570.     printf("\n.......220.......230.......240.......250..255\n");
  5571. #endif
  5572.  
  5573. }
  5574. #endif /* OS2 */
  5575. #endif /* NOLOCAL */
  5576.  
  5577. #ifdef OS2MOUSE
  5578. VOID
  5579. shomou() {
  5580.     int button, event, id, i;
  5581.     char * name = "";
  5582.  
  5583.     printf("Mouse settings:\n");
  5584.     printf("   Button Count:   %d\n",mousebuttoncount());
  5585.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5586.  
  5587.     for (button = 0; button < MMBUTTONMAX; button++)
  5588.       for (event = 0; event < MMEVENTSIZE; event++)
  5589.         if (mousemap[button][event].type != error)
  5590.           switch (mousemap[button][event].type) {
  5591.             case key:
  5592.               printf("   %s = Character: %c \\%d\n",
  5593.                      mousename(button,event),
  5594.                      mousemap[button][event].key.scancode,
  5595.                      mousemap[button][event].key.scancode );
  5596.               break;
  5597.             case kverb:
  5598.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5599.               if (id != K_IGNORE) {
  5600.                   for (i = 0; i< nkverbs; i++)
  5601.                     if (id == kverbs[i].kwval) {
  5602.                         name = kverbs[i].kwd;
  5603.                         break;
  5604.                     }
  5605.                   printf("   %s = Kverb: \\K%s\n",
  5606.                          mousename(button,event),
  5607.                          name
  5608.                          );
  5609.               }
  5610.               break;
  5611.             case macro:
  5612.               printf("   %s = Macro: ",
  5613.                      mousename(button,event) );
  5614.               shostrdef(mousemap[button][event].macro.string);
  5615.               printf("\n");
  5616.               break;
  5617.           }
  5618. }
  5619. #endif /* OS2MOUSE */
  5620.  
  5621. #ifndef NOLOCAL
  5622. VOID
  5623. shotrm() {
  5624.     char *s;
  5625.     extern char * getiact();
  5626.     extern int tt_print, adl_err;
  5627. #ifndef NOTRIGGER
  5628.     extern char * tt_trigger[];
  5629. #endif /* NOTRIGGER */
  5630. #ifdef CKTIDLE
  5631.     extern char * tt_idlesnd_str;
  5632.     extern int tt_idlesnd_tmo;
  5633.     extern int tt_idlelimit, tt_idleact;
  5634. #endif /* CKTIDLE */
  5635. #ifdef OS2
  5636.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5637.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5638.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5639.     int lines = 0;
  5640. #ifdef KUI
  5641.     extern CKFLOAT tt_linespacing[];
  5642.     extern tt_cursor_blink;
  5643. #endif /* KUI */
  5644. #ifdef PCFONTS
  5645.     int i;
  5646.     char *font;
  5647.  
  5648.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5649.         if (!os2LoadPCFonts()) {
  5650.             for (i = 0; i < ntermfont; i++) {
  5651.                 if (tt_font == term_font[i].kwval) {
  5652.                     font = term_font[i].kwd;
  5653.                     break;
  5654.                 }
  5655.             }
  5656.         } else {
  5657.             font = "(DLL not available)";
  5658.         }
  5659.     } else {
  5660.         font =     "(full screen only)";
  5661.     }
  5662. #endif /* PCFONTS */
  5663. #ifdef KUI
  5664.     char font[64] = "(unknown)";
  5665.     if ( ntermfont > 0 ) {
  5666.         int i;
  5667.         for (i = 0; i < ntermfont; i++) {
  5668.             if (tt_font == term_font[i].kwval) {
  5669.                 ckstrncpy(font,term_font[i].kwd,59);
  5670.                 ckstrncat(font," ",64);
  5671.                 ckstrncat(font,ckitoa(tt_font_size/2),64);
  5672.                 if ( tt_font_size % 2 )
  5673.                     ckstrncat(font,".5",64);
  5674.                 break;
  5675.             }
  5676.         }
  5677.     }
  5678. #endif /* KUI */
  5679.  
  5680.     printf("Terminal parameters:\n");
  5681.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5682.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5683.            "Bytesize: Command",
  5684.            (cmdmsk == 0377) ? 8 : 7,
  5685.            " bits","Terminal",
  5686.            (cmask == 0377) ? 8 : 7," bits");
  5687.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5688.     printf(" %19s: %-13s","Type",
  5689.            (tt_type >= 0 && tt_type <= max_tt) ?
  5690.            tt_info[tt_type].x_name :
  5691.            "unknown" );
  5692.     if (tt_type >= 0 && tt_type <= max_tt)
  5693.       if (strlen(tt_info[tt_type].x_id))
  5694.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5695.     printf("\n");
  5696.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5697.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5698.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5699.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5700.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode", showoff(tnlm),
  5701.        "Cr-display",tt_crd ? "crlf" : "normal");
  5702.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5703.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5704. #ifdef KUI
  5705.         (tt_cursor == 2) ? (tt_cursor_blink ? 
  5706.                  "full (*)" : "full (.)") :
  5707.         (tt_cursor == 1) ? (tt_cursor_blink ? 
  5708.                  "half (*)" : "half (.)") :
  5709.         (tt_cursor_blink ? "underline (*)" : "underline (.)"),
  5710. #else /* KUI */
  5711.            (tt_cursor == 2) ? "full" :
  5712.            (tt_cursor == 1) ? "half" : "underline",
  5713. #endif /* KUI */
  5714. #ifdef CK_AUTODL
  5715.            "autodownload",autodl == TAD_ON ?
  5716.            (adl_err ? "on, error stop" : "on, error continue") : 
  5717.            autodl == TAD_ASK ? 
  5718.            (adl_err ? "ask, error stop" : "ask, error continue") :
  5719.            "off"
  5720. #else /* CK_AUTODL */
  5721.            "", ""
  5722. #endif /* CK_AUTODL */
  5723.            );
  5724.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5725.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5726.            tt_arrow ? "application" : "cursor",
  5727.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5728.            );
  5729.  
  5730.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5731.  
  5732.     /* Just to make sure we are using current info */
  5733.     updanswerbk();
  5734.  
  5735.     /*
  5736.        This line doesn't end with '\n' because the answerback string
  5737.        is terminated with a newline
  5738.     */
  5739.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5740.            showoff(tt_answer),"response",answerback);
  5741.     switch (tt_bell) {
  5742.       case XYB_NONE:
  5743.         s = "none";
  5744.         break;
  5745.       case XYB_VIS:
  5746.         s= "visible";
  5747.         break;
  5748.       case XYB_AUD | XYB_BEEP:
  5749.         s="beep";
  5750.         break;
  5751.       case XYB_AUD | XYB_SYS:
  5752.         s="system sounds";
  5753.         break;
  5754.       default:
  5755.         s="(unknown)";
  5756.     }
  5757.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5758.            "Wrap",showoff(tt_wrap));
  5759.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5760.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5761.            "Autoscroll",showoff(autoscroll));
  5762.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5763.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5764.            "ESC[0m color",colorreset?"default-color":"current-color");
  5765.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5766.     printf(" %19s: %-13s  %13s: %-15s\n",
  5767.             "Erase color",user_erasemode?"default-color":"current-color",
  5768.            "Screen mode",decscnm?"reverse":"normal");
  5769.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5770.  
  5771.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5772.            "Output-pacing",tt_pacing);
  5773.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5774.  
  5775.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5776.            "Idle-action", getiact());
  5777.  
  5778.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5779.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5780.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5781.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5782. #ifndef NOTRIGGER
  5783.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5784.            tt_trigger[0],"Output pacing",tt_pacing );
  5785.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5786. #endif /* NOTRIGGER */
  5787.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5788.            showoff(marginbell),"at column", marginbellcol);
  5789.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5790.     switch (tt_modechg) {
  5791.       case TVC_DIS: s = "disabled"; break;
  5792.       case TVC_ENA: s = "enabled";  break;
  5793.       case TVC_W95: s = "win95-restricted"; break;
  5794.       default: s = "(unknown)";
  5795.     }
  5796.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5797.            showoff(dgunix),"Video change", s);
  5798.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5799.  
  5800. #ifdef CK_APC
  5801.     if (apcstatus == APC_ON) s = "on";
  5802.     else if (apcstatus == APC_OFF) s = "off";
  5803.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5804.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5805.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5806.     printf(" %19s: %-13s  %13s: %-15s\n",
  5807.            "APC", s,
  5808. #ifdef PCFONTS
  5809.            "Font (VGA)",font
  5810. #else /* PCFONTS */
  5811. #ifdef KUI
  5812.            "Font",font
  5813. #else
  5814.            "Font","(not supported)"
  5815. #endif /* KUI */
  5816. #endif /* PCFONTS */
  5817.  
  5818.            );
  5819. #endif /* CK_APC */
  5820.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5821.  
  5822. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5823.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5824.       ttgwsiz();                        /* Try to get latest size */
  5825. #endif /* CK_TTGWSIZ */
  5826.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5827.            "Width",tt_cols[VTERM]);
  5828.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5829. #ifdef KUI
  5830.     printf(" %19s: %-12f  %14s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5831.            "Display Height",VscrnGetDisplayHeight(VTERM));
  5832.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5833. #endif /* KUI */
  5834.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5835.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5836.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5837.  
  5838.     if (updmode == tt_updmode)
  5839.       if (updmode == TTU_FAST)
  5840.         s = "fast (fast)";
  5841.       else
  5842.         s = "smooth (smooth)";
  5843.     else
  5844.       if (updmode == TTU_FAST)
  5845.         s = "fast (smooth)";
  5846.       else
  5847.         s = "smooth (fast)";
  5848.  
  5849.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5850.            "interval",tt_update);
  5851.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5852.     printf(" %19s: %-13s  %13s: %-15s\n",
  5853.            "Screen-optimization",showoff(tt_diff_upd),
  5854.            "Status line",showoff(tt_status[VTERM]));
  5855.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5856.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5857.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5858.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5859.  
  5860.     /* Display colors (should become SHOW COLORS) */
  5861.     {
  5862.         USHORT row, col;
  5863.         char * colors[16] = {
  5864.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5865.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5866.         };
  5867.         printf("\n");
  5868.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5869.  
  5870.         printf(" Color:");
  5871. #ifndef ONETERMUPD
  5872.         GetCurPos(&row, &col);
  5873.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5874.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5875.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5876.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5877.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5878.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5879.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5880.         WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5881. #endif /* ONETERMUPD */
  5882.         row = VscrnGetCurPos(VCMD)->y+1;
  5883.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5884.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5885.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5886.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5887.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5888.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5889.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5890.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5891.         printf("\n");
  5892.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5893.  
  5894.         /* Foreground color names */
  5895.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5896.                 "",
  5897.                 colors[colordebug&0x0F],
  5898.                 colors[colorhelp&0x0F],
  5899.                 colors[colorreverse&0x0F],
  5900.                 colors[colorselect&0x0F],
  5901.                 colors[colorstatus&0x0F],
  5902.                 colors[colornormal&0x0F],
  5903.                 colors[colorunderline&0x0F]);
  5904.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5905.  
  5906.         /* Background color names */
  5907.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5908.                 colors[colorborder],
  5909.                 colors[colordebug>>4],
  5910.                 colors[colorhelp>>4],
  5911.                 colors[colorreverse>>4],
  5912.                 colors[colorselect>>4],
  5913.                 colors[colorstatus>>4],
  5914.                 colors[colornormal>>4],
  5915.                 colors[colorunderline>>4] );
  5916.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5917.         printf("\n");
  5918.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5919.         printf(" Color:");
  5920. #ifndef ONETERMUPD
  5921.         GetCurPos(&row, &col);
  5922.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5923.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5924.         WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
  5925. #endif /* ONETERMUPD */
  5926.         row = VscrnGetCurPos(VCMD)->y+1;
  5927.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5928.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5929.         VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
  5930.         printf("\n");
  5931.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5932.  
  5933.         /* Foreground color names */
  5934.         printf("%6s: %-8s%-8s%-8s\n","fore",
  5935.                 colors[colorgraphic&0x0F],
  5936.                 colors[colorcmd&0x0F],
  5937.                 colors[coloritalic&0x0F]);
  5938.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5939.  
  5940.         /* Background color names */
  5941.         printf("%6s: %-8s%-8s%-8s\n","back",
  5942.                 colors[colorgraphic>>4],
  5943.                 colors[colorcmd>>4],
  5944.                 colors[coloritalic>>4]);
  5945.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5946.     }
  5947.     printf("\n");
  5948.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5949.     {
  5950.         extern int trueblink, truedim, truereverse, trueunderline, trueitalic;
  5951.         printf(
  5952.         " Attribute:  \
  5953. blink: %-3s  dim: %-3s  italic: %-3s  reverse: %-3s  underline: %-3s\n",
  5954.         trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", 
  5955.         truereverse?"on":"off", trueunderline?"on":"off");
  5956.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5957.     }
  5958.     {
  5959.         extern vtattrib WPattrib;
  5960.         printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5961.                 WPattrib.blinking?"blink ":"",
  5962.                 WPattrib.italic?"italic ":"",
  5963.                 WPattrib.reversed?"reverse ":"",
  5964.                 WPattrib.underlined?"underline ":"",
  5965.                 WPattrib.bold?"bold ":"",
  5966.                 WPattrib.dim?"dim ":"",
  5967.                 WPattrib.invisible?"invisible ":"");
  5968.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5969.     }
  5970.  
  5971.     printf("\n");
  5972.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5973.     (VOID) shoesc(escape);
  5974.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5975.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5976.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5977.  
  5978. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5979.  
  5980.     printf("\n");
  5981.     printf("Terminal parameters:\n");
  5982.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5983.            "Bytesize: Command",
  5984.            (cmdmsk == 0377) ? 8 : 7,
  5985.            " bits","Terminal",
  5986.            (cmask == 0377) ? 8 : 7," bits");
  5987.     s = getenv("TERM");
  5988. #ifdef XPRINT
  5989.     printf(" %19s: %-13s  %13s: %-15s\n",
  5990.            "Type",
  5991.            s ? s : "(unknown)",
  5992.            "Print",
  5993.            showoff(tt_print)
  5994.            );
  5995. #else
  5996.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5997. #endif /* XPRINT */
  5998.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5999.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  6000.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  6001.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  6002.  
  6003. #ifdef CK_APC
  6004.     if (apcstatus == APC_ON) s = "on";
  6005.     else if (apcstatus == APC_OFF) s = "off";
  6006.     else if (apcstatus == (APC_ON|APC_UNCH)) s = "unchecked";
  6007.     else if (apcstatus == (APC_ON|APC_NOINP)) s = "no-input";
  6008.     else if (apcstatus == (APC_ON|APC_UNCH|APC_NOINP))
  6009.       s = "unchecked-no-input";
  6010.     printf(" %19s: %-13s  %13s: %-15s\n",
  6011.            "APC", s,
  6012. #ifdef CK_AUTODL
  6013.            "Autodownload", autodl ?
  6014.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  6015. #else
  6016.            "",""
  6017. #endif /* CK_AUTODL */
  6018.            );
  6019. #endif /* CK_APC */
  6020.  
  6021. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  6022.     ttgwsiz();                          /* Try to get latest size */
  6023.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  6024. #endif /* CK_TTGWSIZ */
  6025.  
  6026.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  6027.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  6028.  
  6029. #ifdef CKTIDLE
  6030.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  6031.            "Idle-action", getiact());
  6032. #endif /* CKTIDLE */
  6033.  
  6034.     printf(" %19s: %-13s  ","Lf-display", tt_lfd ? "crlf" : "normal");
  6035. #ifdef UNIX
  6036. #ifndef NOJC
  6037.     printf("%13s: %-15s","Suspend", showoff(xsuspend));
  6038. #endif /* NOJC */
  6039. #endif /* UNIX */
  6040.     printf("\n");
  6041.  
  6042. #ifndef NOTRIGGER
  6043.     printf(" %19s: %-13s\n","Trigger",
  6044.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  6045. #endif /* NOTRIGGER */
  6046.     printf("\n");
  6047.  
  6048.     (VOID) shoesc(escape);
  6049. #ifndef NOCSETS
  6050.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  6051. #endif /* NOCSETS */
  6052.  
  6053. #endif /* OS2 */
  6054. }
  6055.  
  6056. VOID
  6057. shmdmlin() {                            /* Briefly show modem & line */
  6058. #ifndef NODIAL
  6059. #ifndef MINIDIAL
  6060. #ifdef OLDTBCODE
  6061.     extern int tbmodel;
  6062.     _PROTOTYP( char * gtbmodel, (void) );
  6063. #endif /* OLDTBCODE */
  6064. #endif /* MINIDIAL */
  6065. #endif /* NODIAL */
  6066.     if (local)
  6067. #ifdef OS2
  6068.       printf(" Port: %s, Modem type: ",ttname);
  6069. #else
  6070.       printf(" Line: %s, Modem type: ",ttname);
  6071. #endif /* OS2 */
  6072.     else
  6073.       printf(
  6074. #ifdef OS2
  6075. " Communication device not yet selected with SET PORT\n Modem type: "
  6076. #else
  6077. " Communication device not yet selected with SET LINE\n Modem type: "
  6078. #endif /* OS2 */
  6079.              );
  6080. #ifndef NODIAL
  6081.     printf("%s",gmdmtyp());
  6082. #ifndef MINIDIAL
  6083. #ifdef OLDTBCODE
  6084.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  6085. #endif /* OLDTBCODE */
  6086. #endif /* MINIDIAL */
  6087. #else
  6088.     printf("(disabled)");
  6089. #endif /* NODIAL */
  6090. }
  6091.  
  6092. #ifdef CK_TAPI
  6093. void
  6094. shotapi(int option) {
  6095.     int rc=0,k ;
  6096.     char *s=NULL;
  6097.     LPDEVCFG        lpDevCfg = NULL;
  6098.     LPCOMMCONFIG    lpCommConfig = NULL;
  6099.     LPMODEMSETTINGS lpModemSettings = NULL;
  6100.     DCB *           lpDCB = NULL;
  6101.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  6102.     extern int ntapiloc;
  6103.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  6104.     extern int ntapiline;
  6105.     extern int tttapi;                  /* TAPI in use */
  6106.     extern int tapipass;                /* TAPI Passthrough mode */
  6107.     extern int tapiconv;                /* TAPI Conversion mode */
  6108.     extern int tapilights;
  6109.     extern int tapipreterm;
  6110.     extern int tapipostterm;
  6111.     extern int tapimanual;
  6112.     extern int tapiinactivity;
  6113.     extern int tapibong;
  6114.     extern int tapiusecfg;
  6115.     extern char tapiloc[];
  6116.     extern int tapilocid;
  6117.     extern int TAPIAvail;
  6118.  
  6119.     if (!TAPIAvail) {
  6120.         printf("TAPI Support not enabled\r\n");
  6121.         return;
  6122.     }
  6123.     switch (option) {
  6124.       case 0:
  6125.         printf("TAPI Settings:\n");
  6126.         printf("  Line:                      %s\n",
  6127.                tttapi ? ttname : "(none in use)");
  6128.  
  6129.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  6130.         if (tapilocid == -1)
  6131.           tapilocid = cktapiGetCurrentLocationID();
  6132.  
  6133.         /* Find the current tapiloc entry */
  6134.         /* and use it as the default. */
  6135.         for (k = 0; k < ntapiloc; k++) {
  6136.             if (tapiloctab[k].kwval == tapilocid)
  6137.               break;
  6138.         }
  6139.         if (k >= 0 && k < ntapiloc)
  6140.           s = tapiloctab[k].kwd;
  6141.         else
  6142.           s = "(unknown)";
  6143.         printf("  Location:                  %s\n",s);
  6144.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  6145.         printf("  Phone-number-conversions:  %s\n",
  6146.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  6147.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  6148.                 tapipass?"(n/a)":"");
  6149.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  6150.                 tapipass?"(n/a)":"");
  6151.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  6152.                 tapipass?"(n/a)":"");
  6153.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  6154.                 tapipass?"(n/a)":"");
  6155.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  6156.                 tapipass?"(n/a)":"");
  6157.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  6158.                 tapipass?"(n/a)":"");
  6159.         printf("  Use-windows-configuration: %s %s\n",
  6160.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  6161.         printf("\n");
  6162.  
  6163. #ifdef BETATEST
  6164.         if (tapipass) {
  6165. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  6166. printf("may open the device but may not place calls nor answer calls.\n");
  6167. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  6168. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  6169. printf("definition associated with the active TAPI LINE device.\n\n");
  6170.  
  6171.         } else {
  6172.  
  6173. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  6174. printf("may open the device, place and answer calls.  Dialing is performed\n");
  6175. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  6176.         }
  6177.  
  6178.         if (tapiconv == CK_ON ||
  6179.             tapiconv == CK_AUTO && !tapipass) {
  6180. printf(
  6181. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  6182. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  6183. printf("dialog.\n\n");
  6184.  
  6185.         } else {
  6186.  
  6187. printf(
  6188. "Phone numbers are converted from canonical to dialable form by K-95\n");
  6189. printf(
  6190. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  6191. printf(
  6192. "Dialing Properties are imported automaticly upon startup and whenever\n");
  6193. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  6194. printf("is changed.\n\n");
  6195.         }
  6196. #endif /* BETATEST */
  6197.  
  6198.         if (tapipass) {
  6199.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  6200.             if (tapiconv == CK_ON)
  6201.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6202.         } else {
  6203.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  6204.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6205.         }
  6206.         break;
  6207.       case 1:
  6208.         cktapiDisplayTapiLocationInfo();
  6209.         break;
  6210.       case 2:
  6211.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  6212.                                      &lpCommConfig,&lpDCB);
  6213.         if (rc) {
  6214.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  6215.                                          lpCommConfig,lpDCB);
  6216.         } else {
  6217.             printf("?Unable to retrieve Modem Settings\n");
  6218.         }
  6219.         break;
  6220.       case 3: {
  6221.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  6222.           if (hModem)
  6223.             DisplayCommProperties(hModem);
  6224.           else
  6225.             printf("?Unable to retrieve a valid Modem Handle\n");
  6226.           CloseHandle(hModem);
  6227.           break;
  6228.       }
  6229.     }
  6230.     printf("\n");
  6231. }
  6232. #endif /* CK_TAPI */
  6233. #endif /* NOLOCAL */
  6234.  
  6235. #ifdef PATTERNS
  6236. static VOID
  6237. shopat() {
  6238.     extern char * binpatterns[], * txtpatterns[];
  6239.     extern int patterns, filepeek;
  6240.     char **p, *s;
  6241.     int i, j, k, n, flag, width;
  6242. #ifdef CK_TTGWSIZ
  6243.     ttgwsiz();                          /* Try to get latest size */
  6244. #ifdef OS2
  6245.     width = tt_cols[VCMD];
  6246. #else /* OS2 */
  6247.     width = tt_cols;
  6248. #endif /* OS2 */
  6249.     if (width < 1)
  6250. #endif /* CK_TTGWSIZ */
  6251.       width = 80;
  6252.     printf("\n");
  6253.     printf(" Set file type:            %s\n",gfmode(binary,1));
  6254.     printf(" Set file patterns:        %s", showooa(patterns));
  6255. #ifdef CK_LABELED
  6256.     if (binary == XYFT_L)
  6257.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  6258.     else
  6259. #endif /* CK_LABELED */
  6260. #ifdef VMS
  6261.     if (binary == XYFT_I)
  6262.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  6263.     else
  6264. #endif /* VMS */
  6265.     if (filepeek)
  6266.       printf(" (but SET FILE SCAN ON overrides)\n");
  6267.     else
  6268.       printf("\n");
  6269.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  6270.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  6271.         printf("\n");
  6272.         if (k == 0) {                   /* binary... */
  6273.             printf(" File binary-patterns: ");
  6274.             p = binpatterns;
  6275.         } else {                        /* text... */
  6276.             printf(" File text-patterns:   ");
  6277.             p = txtpatterns;
  6278.         }
  6279.         if (!p[0]) {
  6280.             printf("(none)\n");
  6281.         } else {
  6282.             printf("\n ");
  6283.             n = 2;
  6284.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  6285.                 if (!p[i])              /* Done */
  6286.                   break;
  6287.                 s = p[i];               /* Look for embedded space */
  6288.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  6289.                   if (*s == SP)
  6290.                     flag = 3;
  6291.                 n += j + flag;          /* Length of this line */
  6292.                 if (n >= width - 1) {
  6293.                     printf("\n ");
  6294.                     n = j+2;
  6295.                 }
  6296.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6297.             }
  6298.             if (n > 2)
  6299.               printf("\n");
  6300.         }
  6301.     }
  6302.     printf("\n");
  6303. }
  6304. #endif /* PATTERNS */
  6305.  
  6306. #ifndef NOSPL
  6307. static VOID
  6308. shooutput() {
  6309.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6310.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6311. }
  6312.  
  6313. static VOID
  6314. shoinput() {
  6315. #ifdef CKFLOAT
  6316.     extern char * inpscale;
  6317. #endif    /* CKFLOAT */
  6318.  
  6319. #ifdef CK_AUTODL
  6320.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6321. #endif /* CK_AUTODL */
  6322.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6323.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6324.            "observe" : "ignore");
  6325.     printf(" Input buffer-length:    %d\n", inbufsize);
  6326.     printf(" Input echo:             %s\n", showoff(inecho));
  6327.     printf(" Input silence:          %d (seconds)\n", insilence);
  6328. #ifdef OS2
  6329.     printf(" Input terminal:         %s\n", showoff(interm));
  6330. #endif /* OS2 */
  6331.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6332.            "quit" : "proceed");
  6333. #ifdef CKFLOAT
  6334.     printf(" Input scale-factor:     %s\n", inpscale ? inpscale : "1.0");
  6335. #endif    /* CKFLOAT */
  6336.  
  6337.     if (instatus < 0)
  6338.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6339.     else
  6340.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6341. }
  6342. #endif /* NOSPL */
  6343.  
  6344. #ifndef NOSPL
  6345. int
  6346. showarray() {
  6347. #ifdef COMMENT
  6348.     char * p, * q, ** ap;
  6349.     int i;
  6350. #endif /* COMMENT */
  6351.     char *s; int x = 0, y;
  6352.     int range[2];
  6353.  
  6354.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6355.       if (y != -3)
  6356.         return(y);
  6357.     ckstrncpy(line,s,LINBUFSIZ);
  6358.     s = line;
  6359.     if ((y = cmcfm()) < 0)
  6360.       return(y);
  6361.     if (*s) {
  6362.         char ** ap;
  6363.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6364.             printf("?Bad array: %s\n",s);
  6365.             return(-9);
  6366.         }
  6367.         ap = a_ptr[x];
  6368.         if (!ap) {
  6369.             printf("Array not declared: %s\n", s);
  6370.             return(success = 1);
  6371.         } else {
  6372.             int i, n, max;
  6373.             max = (range[1] > 0) ?
  6374.               range[1] :
  6375.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6376.             if (range[0] < 0)
  6377.               range[0] = 0;
  6378.             if (max > a_dim[x])
  6379.               max = a_dim[x];
  6380.             n = 1;
  6381.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6382.             if (a_link[x] > -1)
  6383.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6384.             printf("\n");
  6385.             for (i = range[0]; i <= max; i++) {
  6386.                 if (ap[i]) {
  6387.                     printf("%3d. %s\n",i,ap[i]);
  6388.                     if (xaskmore) {
  6389.                         if (cmd_cols > 0) {
  6390.                             x = strlen(ap[i]) + 5;
  6391.                             y = (x % cmd_cols) ? 1 : 0;
  6392.                             n += (x / cmd_cols) + y;
  6393.                         } else {
  6394.                             n++;
  6395.                         }
  6396.                         if (n > (cmd_rows - 3)) {
  6397.                             if (!askmore())
  6398.                               break;
  6399.                             else
  6400.                               n = 0;
  6401.                         }
  6402.                     }
  6403.                 }
  6404.             }
  6405.         }
  6406.         return(1);
  6407.     }
  6408.  
  6409.     /* All arrays - just show name and dimension */
  6410.  
  6411.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6412.         if (a_ptr[y]) {
  6413.             if (x == 0) printf("Declared arrays:\n");
  6414.             x = 1;
  6415.             printf(" \\&%c[%d]",
  6416.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6417.             if (a_link[y] > -1)
  6418.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6419.             printf("\n");
  6420.         }
  6421.         if (!x) printf(" No arrays declared\n");
  6422.     }
  6423.     return(1);
  6424. }
  6425. #endif /* NOSPL */
  6426.  
  6427. int
  6428. doshow(x) int x; {
  6429.     int y, z, i; long zz;
  6430.     extern int optlines;
  6431.     char *s;
  6432. #ifdef OS2
  6433.     extern int os2gks;
  6434.     extern int tt_kb_mode;
  6435. #endif /* OS2 */
  6436.     extern int srvcdmsg;
  6437.     extern char * cdmsgstr, * ckcdpath;
  6438.  
  6439. #ifndef NOSETKEY
  6440.     if (x == SHKEY) {                   /* SHOW KEY */
  6441.         int c;
  6442. #ifdef OS2
  6443.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6444.                         "one",xxstring)) < 0) return(x);
  6445.         switch (tt_kb_mode) {
  6446.           case KBM_EM:
  6447.             s = "emacs";
  6448.             break;
  6449.           case KBM_HE:
  6450.             s = "hebrew";
  6451.             break;
  6452.           case KBM_RU:
  6453.             s = "russian";
  6454.             break;
  6455.           case KBM_EN:
  6456.           default:
  6457.             s = "default";
  6458.             break;
  6459.         }
  6460.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6461.                         s,xxstring)) < 0) return(z);
  6462.         if (z == SHKEYDEF)
  6463.           z = -1;
  6464. #endif /* OS2 */
  6465.         if ((y = cmcfm()) < 0) return(y);
  6466. #ifdef IKSD
  6467.         if (inserver) {
  6468.             printf("Sorry, command disabled.\r\n");
  6469.             return(success = 0);
  6470.         }
  6471. #endif /* IKSD */
  6472.  
  6473. #ifdef MAC
  6474.         printf("Not implemented\n");
  6475.         return(0);
  6476. #else /* Not MAC */
  6477. #ifdef OS2
  6478.         if (x) {
  6479.             con_event evt;
  6480.             for (c = 0; c < KMSIZE; c++) {
  6481.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6482.                 if (evt.type != error) {
  6483.                     shokeycode(c,z);
  6484.                 }
  6485.             }
  6486.         } else {
  6487. #endif /* OS2 */
  6488.             printf(" Press key: ");
  6489. #ifdef UNIX
  6490. #ifdef NOSETBUF
  6491.             fflush(stdout);
  6492. #endif /* NOSETBUF */
  6493. #endif /* UNIX */
  6494.             conbin((char)escape);       /* Put terminal in binary mode */
  6495. #ifdef OS2
  6496.             os2gks = 0;                 /* Raw scancode processing */
  6497. #endif /* OS2 */
  6498.             c = congks(0);              /* Get character or scan code */
  6499. #ifdef OS2
  6500.             os2gks = 1;                 /* Cooked scancode processing */
  6501. #endif /* OS2 */
  6502.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6503.             if (c < 0) {                /* Check for error */
  6504.                 printf("?Error reading key\n");
  6505.                 return(0);
  6506.             }
  6507. #ifndef OS2
  6508. /*
  6509.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6510. */
  6511.             c &= cmdmsk;                /* Apply command mask */
  6512. #endif /* OS2 */
  6513.             printf("\n");
  6514. #ifdef OS2
  6515.             shokeycode(c,z);
  6516. #else /* OS2 */
  6517.             shokeycode(c);
  6518. #endif /* OS2 */
  6519. #ifdef OS2
  6520.         }
  6521. #endif /* OS2 */
  6522.         return(1);
  6523. #endif /* MAC */
  6524.     }
  6525. #ifndef NOKVERBS
  6526.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6527.         if ((y = cmcfm()) < 0) return(y);
  6528. #ifdef IKSD
  6529.         if (inserver) {
  6530.             printf("Sorry, command disabled.\r\n");
  6531.             return(success = 0);
  6532.         }
  6533. #endif /* IKSD */
  6534.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6535.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6536.         printf("\n");
  6537.         return(1);
  6538.     }
  6539. #ifdef OS2
  6540.     if (x == SHUDK) {                   /* SHOW UDKs */
  6541.         extern void showudk(void);
  6542.         if ((y = cmcfm()) < 0) return(y);
  6543. #ifdef IKSD
  6544.         if (inserver) {
  6545.             printf("Sorry, command disabled.\r\n");
  6546.             return(success = 0);
  6547.         }
  6548. #endif /* IKSD */
  6549.         showudk();
  6550.         return(1);
  6551.     }
  6552. #endif /* OS2 */
  6553. #endif /* NOKVERBS */
  6554. #endif /* NOSETKEY */
  6555.  
  6556. #ifndef NOSPL
  6557.     if (x == SHMAC) {                   /* SHOW MACRO */
  6558.         struct FDB kw, fl, cm;
  6559.         int i, k, n = 0, left, flag, confirmed = 0;
  6560.         char * p, *q[64];
  6561.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6562.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6563.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6564.             mackey[i].flgs = mactab[i].flgs;
  6565.         }
  6566.         p = line;
  6567.         left = LINBUFSIZ;
  6568.         while (!confirmed && n < 64) {
  6569.             cmfdbi(&kw,                 /* First FDB - macro table */
  6570.                    _CMKEY,              /* fcode */
  6571.                    "Macro name",        /* hlpmsg */
  6572.                    "",                  /* default */
  6573.                    "",                  /* addtl string data */
  6574.                    nmac,                /* addtl numeric data 1: tbl size */
  6575.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6576.                    xxstring,            /* Processing function */
  6577.                    mackey,              /* Keyword table */
  6578.                    &fl                  /* Pointer to next FDB */
  6579.                    );
  6580.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6581.                    _CMFLD,              /* fcode */
  6582.                    "",                  /* hlpmsg */
  6583.                    "",                  /* default */
  6584.                    "",                  /* addtl string data */
  6585.                    0,                   /* addtl numeric data 1 */
  6586.                    0,                   /* addtl numeric data 2 */
  6587.                    xxstring,
  6588.                    NULL,
  6589.                    &cm
  6590.                    );
  6591.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6592.                    _CMCFM,              /* fcode */
  6593.                    "",                  /* hlpmsg */
  6594.                    "",                  /* default */
  6595.                    "",                  /* addtl string data */
  6596.                    0,                   /* addtl numeric data 1 */
  6597.                    0,                   /* addtl numeric data 2 */
  6598.                    NULL,
  6599.                    NULL,
  6600.                    NULL
  6601.                    );
  6602.             x = cmfdb(&kw);             /* Parse something */
  6603.             if (x < 0)
  6604.               return(x);
  6605.             s = atmbuf;                 /* What the user typed */
  6606.             switch (cmresult.fcode) {
  6607.               case _CMKEY:              /* If it was a keyword */
  6608.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6609.                 if (y > -1)
  6610.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6611.               case _CMFLD:
  6612.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6613.                 left -= k;
  6614.                 if (left <= 0) {
  6615.                     *p = NUL;
  6616.                     break;
  6617.                 }
  6618.                 q[n++] = p;             /* Point to this item */
  6619.                 p += k;                 /* Move buffer pointer past it */
  6620.                 break;
  6621.               case _CMCFM:              /* End of command */
  6622.                 confirmed++;
  6623.               default:
  6624.                 break;
  6625.             }
  6626.         }
  6627.         if (n == 0) {
  6628.             printf("Macros:\n");
  6629.             slc = 1;
  6630.             for (y = 0; y < nmac; y++)
  6631.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6632.             return(1);
  6633.         }
  6634.         slc = 0;
  6635.         for (i = 0; i < n; i++) {
  6636.             flag = 0;
  6637.             s = q[i];
  6638.             if (!s) s = "";
  6639.             if (!*s) continue;
  6640.             if (iswild(s)) {            /* Pattern match */
  6641.                 for (k = 0, x = 0; x < nmac; x++) {
  6642.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6643.                         shomac(mactab[x].kwd,mactab[x].mval);
  6644.                         k++;
  6645.                     }
  6646.                 }
  6647.                 if (!k)
  6648.                   x = -1;
  6649.                 else
  6650.                   continue;
  6651.             } else {                    /* Exact match */
  6652.                 x = mxlook(mactab,s,nmac);
  6653.                 flag = 1;
  6654.             }
  6655.             if (flag && x == -1)
  6656.               x = mlook(mactab,s,nmac);
  6657.             switch (x) {
  6658.               case -3:                  /* Nothing to look up */
  6659.               case -1:                  /* Not found */
  6660.                 printf("%s - (not defined)\n",s);
  6661.                 break;
  6662.               case -2:                  /* Ambiguous, matches more than one */
  6663.                 printf("%s - ambiguous\n",s);
  6664.                 break;
  6665.               default:                  /* Matches one exactly */
  6666.                 shomac(mactab[x].kwd,mactab[x].mval);
  6667.                 break;
  6668.             }
  6669.         }
  6670.         return(1);
  6671.     }
  6672. #endif /* NOSPL */
  6673.  
  6674. /*
  6675.   Other SHOW commands only have two fields.  Get command confirmation here,
  6676.   then handle with big switch() statement.
  6677. */
  6678. #ifndef NOSPL
  6679.     if (x != SHBUI && x != SHARR)
  6680. #endif /* NOSPL */
  6681.       if ((y = cmcfm()) < 0)
  6682.         return(y);
  6683.  
  6684. #ifdef COMMENT
  6685.     /* This restriction is too general. */
  6686. #ifdef IKSD
  6687.     if (inserver &&
  6688. #ifdef CK_LOGIN
  6689.         isguest
  6690. #else
  6691.         0
  6692. #endif /* CK_LOGIN */
  6693.         ) {
  6694.         printf("Sorry, command disabled.\r\n");
  6695.         return(success = 0);
  6696.     }
  6697. #endif /* IKSD */
  6698. #endif /* COMMENT */
  6699.  
  6700.     switch (x) {
  6701.  
  6702. #ifdef ANYX25
  6703. #ifndef IBMX25
  6704.       case SHPAD:
  6705.         shopad(0);
  6706.         break;
  6707. #endif /* IBMX25 */
  6708. #endif /* ANYX25 */
  6709.  
  6710.       case SHNET:
  6711. #ifdef NOLOCAL
  6712.         printf(" No network support in this version of C-Kermit.\n");
  6713. #else
  6714. #ifndef NETCONN
  6715.         printf(" No network support in this version of C-Kermit.\n");
  6716. #else
  6717.         shonet();
  6718. #endif /* NETCONN */
  6719. #endif /* NOLOCAL */
  6720.         break;
  6721.  
  6722.       case SHPAR:
  6723.         shopar();
  6724.         break;
  6725.  
  6726. #ifndef NOXFER
  6727.       case SHATT:
  6728.         shoatt();
  6729.         break;
  6730. #endif /* NOXFER */
  6731.  
  6732. #ifndef NOSPL
  6733.       case SHCOU:
  6734.         printf(" %d\n",count[cmdlvl]);
  6735.         break;
  6736. #endif /* NOSPL */
  6737.  
  6738. #ifndef NOSERVER
  6739.       case SHSER:                       /* Show Server */
  6740.         i = 0;
  6741. #ifndef NOFRILLS
  6742.         printf("Function:          Status:\n");
  6743.         i++;
  6744.         printf(" GET                %s\n",nm[en_get]);
  6745.         i++;
  6746.         printf(" SEND               %s\n",nm[en_sen]);
  6747.         i++;
  6748.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6749.         i++;
  6750.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6751.         i++;
  6752. #ifndef NOSPL
  6753.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6754.         i++;
  6755. #endif /* NOSPL */
  6756.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6757.         i++;
  6758. #ifdef ZCOPY
  6759.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6760.         i++;
  6761. #endif /* ZCOPY */
  6762.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6763.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6764.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6765.         i += 3;
  6766. #ifndef NOSPL
  6767.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6768.         i++;
  6769. #endif /* NOSPL */
  6770.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6771.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6772.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6773.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6774.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6775.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6776.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6777.         printf(" BYE                %s\n",nm[en_bye]);
  6778.         printf(" FINISH             %s\n",nm[en_fin]);
  6779.         printf(" EXIT               %s\n",nm[en_xit]);
  6780.         printf(" ENABLE             %s\n",nm[en_ena]);
  6781.         i += 11;
  6782. #endif /* NOFRILLS */
  6783.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6784.         printf("Server timeout:      %d\n",srvtim);
  6785.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6786.         printf("Server idle-timeout: %d\n",srvidl);
  6787.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6788.         printf("Server keepalive     %s\n", showoff(srvping));
  6789.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6790.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6791.         if (srvcdmsg && cdmsgstr)
  6792.           printf("Server cd-message    %s\n", cdmsgstr);
  6793.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6794.         printf("Server display:      %s\n", showoff(srvdis));
  6795.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6796.         printf("Server login:        ");
  6797.         if (!x_user) {
  6798.             printf("(none)\n");
  6799.         } else {
  6800.             printf("\"%s\", \"%s\", \"%s\"\n",
  6801.                    x_user,
  6802.                    x_passwd ? x_passwd : "",
  6803.                    x_acct ? x_acct : ""
  6804.                    );
  6805.         }
  6806.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6807.         printf("Server get-path: ");
  6808.         if (ngetpath == 0) {
  6809.             printf("    (none)\n");
  6810.         } else {
  6811.             printf("\n");
  6812.             i += 3;
  6813.             for (x = 0; x < ngetpath; x++) {
  6814.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6815.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6816.                     if (!askmore())
  6817.                       break;
  6818.                     else
  6819.                       i = 0;
  6820.                 }
  6821.             }
  6822.         }
  6823.         break;
  6824. #endif /* NOSERVER */
  6825.  
  6826.       case SHSTA:                       /* Status of last command */
  6827.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6828.         return(0);                      /* Don't change it */
  6829.  
  6830.       case SHSTK: {                     /* Stack for MAC debugging */
  6831. #ifdef MAC
  6832.           long sp;
  6833.           sp = -1;
  6834.           loadA0 ((char *)&sp);         /* set destination address */
  6835.           SPtoaA0();                    /* move SP to destination */
  6836.           printf("Stack at 0x%x\n", sp);
  6837.           show_queue();                 /* more debugging */
  6838.           break;
  6839. #else
  6840.           shostack();
  6841. #endif /* MAC */
  6842.           break;
  6843.       }
  6844.  
  6845.  
  6846. #ifndef NOLOCAL
  6847. #ifdef OS2
  6848.       case SHTAB:                       /* SHOW TABS */
  6849. #ifdef IKSD
  6850.         if (inserver) {
  6851.             printf("Sorry, command disabled.\r\n");
  6852.             return(success = 0);
  6853.         }
  6854. #endif /* IKSD */
  6855.         shotabs();
  6856.         break;
  6857. #endif /* OS2 */
  6858.  
  6859.       case SHTER:                       /* SHOW TERMINAL */
  6860. #ifdef IKSD
  6861.         if (inserver) {
  6862.             printf("Sorry, command disabled.\r\n");
  6863.             return(success = 0);
  6864.         }
  6865. #endif /* IKSD */
  6866.         shotrm();
  6867.         break;
  6868.  
  6869. #ifdef OS2
  6870.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6871.         shovscrn();
  6872.         break;
  6873. #endif /* OS2 */
  6874. #endif /* NOLOCAL */
  6875.  
  6876. #ifdef OS2MOUSE
  6877.       case SHMOU:                       /* SHOW MOUSE */
  6878. #ifdef IKSD
  6879.         if (inserver) {
  6880.             printf("Sorry, command disabled.\r\n");
  6881.             return(success = 0);
  6882.         }
  6883. #endif /* IKSD */
  6884.         shomou();
  6885.         break;
  6886. #endif /* OS2MOUSE */
  6887.  
  6888. #ifndef NOFRILLS
  6889.       case SHVER:
  6890.         shover();
  6891.         break;
  6892. #endif /* NOFRILLS */
  6893.  
  6894. #ifndef NOSPL
  6895.       case SHBUI:                       /* Built-in variables */
  6896.     line[0] = NUL;
  6897.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6898.           return(y);
  6899.         ckstrncpy(line,s,LINBUFSIZ);
  6900.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6901.  
  6902.       case SHFUN:                       /* or built-in functions */
  6903. #ifdef CK_TTGWSIZ
  6904. #ifdef OS2
  6905.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6906.           ttgwsiz();
  6907. #else /* OS2 */
  6908.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6909.             if (tt_rows > 0 && tt_cols > 0) {
  6910.                 cmd_rows = tt_rows;
  6911.                 cmd_cols = tt_cols;
  6912.             }
  6913.         }
  6914. #endif /* OS2 */
  6915. #endif /* CK_TTGWSIZ */
  6916.  
  6917.         if (x == SHFUN) {               /* Functions */
  6918.             printf("\nThe following functions are available:\n\n");
  6919.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6920.             printf("\n");
  6921. #ifndef NOHELP
  6922.             printf(
  6923. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6924.                    );
  6925. #endif /* NOHELP */
  6926.             break;
  6927.         } else {                        /* Variables */
  6928.         int j, flag = 0, havearg = 0;
  6929.         struct stringarray * q = NULL;
  6930.         char ** pp;
  6931.         if (line[0]) {        /* Have something to search for */
  6932.         havearg = 1;        /* Maybe a list of things */
  6933.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6934.         if (!q) break;
  6935.         pp = q->a_head;
  6936.         }
  6937.         i = 0;
  6938.         for (y = 0; y < nvars; y++) {
  6939.         if ((vartab[y].flgs & CM_INV))
  6940.           continue;
  6941.         if (havearg) {        /* If I have something to match */
  6942.             char * s2;
  6943.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6944.             s2 = pp[j] ? pp[j] : "";
  6945. #ifdef COMMENT
  6946. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6947.             len = strlen(s2);
  6948.             if (len > 0) {
  6949.                 if (s2[len-1] != '$') {/* To allow anchors */
  6950.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6951.                 s2 = line;
  6952.                 }
  6953.             }
  6954. #endif /* COMMENT */
  6955.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6956.                 flag = 1;    /* Matches */
  6957.                 break;
  6958.             }
  6959.             }
  6960.             if (!flag)        /* Doesn't match */
  6961.               continue;
  6962.         }
  6963.         s = nvlook(vartab[y].kwd);
  6964.         printf(" \\v(%s) = ",vartab[y].kwd);
  6965.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6966.             while (*s)        /* Show control chars symbolically */
  6967.               printf("\\{%d}",*s++);
  6968.             printf("\n");
  6969.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6970.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6971. #ifdef OS2
  6972.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6973. #endif /* OS2 */
  6974.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6975.                 vartab[y].kwval <= VN_M_ZZZ)
  6976.                ) {
  6977.             int r = 12;        /* This one can wrap around */
  6978.             char buf[10];
  6979.             while (*s) {
  6980.             if (isprint(*s)) {
  6981.                 buf[0] = *s;
  6982.                 buf[1] = NUL;
  6983.                 r++;
  6984.             } else {
  6985.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6986.                 r += (int) strlen(buf);
  6987.             }
  6988.             if (r >= cmd_cols - 1) {
  6989.                 printf("\n");
  6990.                 r = 0;
  6991.                 i++;
  6992.             }
  6993.             printf("%s",buf);
  6994.             s++;
  6995.             }
  6996.             printf("\n");
  6997.         } else
  6998.           printf("%s\n",s);
  6999.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  7000.             if ((y >= nvars - 1) || !askmore())
  7001.               break;
  7002.             else
  7003.               i = 0;
  7004.         }
  7005.         }
  7006.         }
  7007.         break;
  7008.  
  7009.       case SHVAR:                       /* Global variables */
  7010.         x = 0;                          /* Variable count */
  7011.         slc = 1;                        /* Screen line count for "more?" */
  7012.         for (y = 33; y < GVARS; y++)
  7013.           if (g_var[y]) {
  7014.               if (x++ == 0) printf("Global variables:\n");
  7015.               sprintf(line," \\%%%c",y); /* SAFE */
  7016.               if (shomac(line,g_var[y]) < 0) break;
  7017.           }
  7018.         if (!x) printf(" No variables defined\n");
  7019.         break;
  7020.  
  7021.       case SHARG: {                     /* Args */
  7022.           char * s1, * s2;
  7023.           if (maclvl > -1) {
  7024.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  7025.                      maclvl,
  7026.                      macargc[maclvl]
  7027.                      );
  7028.               for (y = 0; y < macargc[maclvl]; y++) {
  7029.                   s1 = m_arg[maclvl][y];
  7030.                   if (!s1) s1 = "(NULL)";
  7031.                   s2 = m_xarg[maclvl][y];
  7032.                   if (!s2) s2 = "(NULL)";
  7033.                   if (y < 10)
  7034.                     printf(" \\%%%d = %s\n",y,s1);
  7035.                   else
  7036.                     printf(" \\&_[%d] = %s\n",y,s2);
  7037.               }
  7038.           } else {
  7039.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  7040.               for (y = 0; y < topargc; y++) {
  7041.                   s1 = g_var[y + '0'];
  7042.                   if (!s1) s1 = "(NULL)";
  7043.                   s2 = toparg[y];
  7044.                   if (!s2) s2 = "(NULL)";
  7045.                   if (y < 10 && g_var[y])
  7046.                     printf(" \\%%%d = %s\n",y,s1);
  7047.                   if (toparg[y])
  7048.                     printf(" \\&_[%d] = %s\n",y,s2);
  7049.               }
  7050.           }
  7051.         }
  7052.         break;
  7053.  
  7054.       case SHARR:                       /* Arrays */
  7055.         return(showarray());
  7056. #endif /* NOSPL */
  7057.  
  7058. #ifndef NOXFER
  7059.       case SHPRO:                       /* Protocol parameters */
  7060.         shoparp();
  7061.         printf("\n");
  7062.         break;
  7063. #endif /* NOXFER */
  7064.  
  7065. #ifndef NOLOCAL
  7066.       case SHCOM:                       /* Communication parameters */
  7067.         printf("\n");
  7068.         shoparc();
  7069. #ifdef OS2
  7070.         {
  7071.             int i;
  7072.             char *s = "(unknown)";
  7073.             for (i = 0; i < nprty; i++)
  7074.               if (prtytab[i].kwval == priority) {
  7075.                   s = prtytab[i].kwd;
  7076.                   break;
  7077.               }
  7078.             printf(" Priority: %s\n", s );
  7079.         }
  7080. #endif /* OS2 */
  7081.  
  7082.         printf("\n");
  7083. #ifdef NETCONN
  7084.         if (!network
  7085. #ifdef IKSD
  7086.              && !inserver
  7087. #endif /* IKSD */
  7088.              ) {
  7089. #endif /* NETCONN */
  7090.             shomdm();
  7091.             printf("\n");
  7092. #ifdef NETCONN
  7093.         }
  7094. #endif /* NETCONN */
  7095.  
  7096. #ifndef NODIAL
  7097. #ifdef IKSD
  7098.         if ( !inserver )
  7099. #endif /* IKSD */
  7100.         {
  7101.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  7102.             printf("Type SHOW MODEM to see modem-related items.\n");
  7103. #ifdef CK_TAPI
  7104.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  7105. #endif /* CK_TAPI */
  7106.             printf("\n");
  7107.         }
  7108. #endif /* NODIAL */
  7109.         break;
  7110. #endif /* NOLOCAL */
  7111.  
  7112.       case SHFIL:                       /* File parameters */
  7113.         shofil();
  7114.         /* printf("\n"); */             /* (out o' space) */
  7115.         break;
  7116.  
  7117. #ifndef NOCSETS
  7118.       case SHLNG:                       /* Languages */
  7119.         shoparl();
  7120.         break;
  7121. #endif /* NOCSETS */
  7122.  
  7123. #ifndef NOSPL
  7124.       case SHSCR:                       /* Scripts */
  7125.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  7126.         printf(" Take  echo:             %s\n", showoff(techo));
  7127.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  7128.         printf(" Macro echo:             %s\n", showoff(mecho));
  7129.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  7130.         printf(" Quiet:                  %s\n", showoff(quiet));
  7131.         printf(" Variable evaluation:    %s [\\%%x and \\&x[] variables]\n",
  7132.            vareval ? "recursive" : "simple");
  7133.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  7134.         printf(" Function error:         %s\n", showoff(fnerror));
  7135. #ifdef CKLEARN
  7136.         {
  7137.             extern char * learnfile;
  7138.             extern int learning;
  7139.             if (learnfile) {
  7140.                 printf(" LEARN file:             %s (%s)\n",
  7141.                        learnfile,
  7142.                        learning ? "ON" : "OFF"
  7143.                        );
  7144.             } else
  7145.               printf(" LEARN file:             (none)\n");
  7146.         }
  7147. #endif /* CKLEARN */
  7148.         shoinput();
  7149.         shooutput();
  7150. #ifndef NOSCRIPT
  7151.         printf(" Script echo:            %s\n", showoff(secho));
  7152. #endif /* NOSCRIPT */
  7153.         printf(" Command buffer length:  %d\n", CMDBL);
  7154.         printf(" Atom buffer length:     %d\n", ATMBL);
  7155.         break;
  7156. #endif /* NOSPL */
  7157.  
  7158. #ifndef NOXMIT
  7159.       case SHXMI:
  7160.         printf("\n");
  7161.         printf(" File type:                       %s\n",
  7162.                binary ? "binary" : "text");
  7163. #ifndef NOCSETS
  7164.         printf(" File character-set:              %s\n",
  7165.                fcsinfo[fcharset].keyword);
  7166. #ifdef OS2
  7167.         if ( isunicode() ) {
  7168.         printf(" Terminal Character (remote):     %s\n",
  7169.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7170.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7171.         printf(" Terminal Character (local):      %s\n",
  7172.               tcsl == TX_TRANSP ? "transparent" :
  7173.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7174.         } else {
  7175.         printf(" Terminal Character (remote):     %s\n",
  7176.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7177.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7178.         printf(" Terminal Character (local):      %s\n",
  7179.               tcsl == TX_TRANSP ? "transparent" :
  7180.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7181.         }
  7182. #else /* OS2 */
  7183.         printf(" Terminal character-set (remote): %s\n",
  7184.                fcsinfo[tcsr].keyword);
  7185.         printf(" Terminal character-set (local):  %s\n",
  7186.                fcsinfo[tcsl].keyword);
  7187. #endif /* OS2 */
  7188. #endif /* NOCSETS */
  7189.         printf(" Terminal bytesize:               %d\n",
  7190.                (cmask == 0xff) ? 8 : 7);
  7191.         printf(" Terminal echo:                   %s\n",
  7192.                duplex ? "local" : "remote");
  7193.         printf(" Transmit EOF:                    ");
  7194.         if (*xmitbuf == NUL) {
  7195.             printf("(none)\n");
  7196.         } else {
  7197.             char *p;
  7198.             p = xmitbuf;
  7199.             while (*p) {
  7200.                 if (*p < SP)
  7201.                   printf("^%c",ctl(*p));
  7202.                 else
  7203.                   printf("%c",*p);
  7204.                 p++;
  7205.             }
  7206.             printf("\n");
  7207.         }
  7208.         if (xmitf)
  7209.           printf(" Transmit Fill:                   %d\n", xmitf);
  7210.         else
  7211.           printf(" Transmit Fill:                   (none)\n");
  7212.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  7213.         if (xmitp)
  7214.           printf(" Transmit Prompt:                 %d (%s)\n",
  7215.                  xmitp,
  7216.                  chartostr(xmitp)
  7217.                  );
  7218.         else
  7219.           printf(" Transmit Prompt:                 (none)\n");
  7220.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  7221.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  7222.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  7223.                xmitw,
  7224.                (xmitw == 1) ? "" : "s"
  7225.                );
  7226.         printf(" Transmit Timeout:                %d (second%s)\n",
  7227.                xmitt,
  7228.                (xmitt == 1) ? "" : "s"
  7229.                );
  7230.         printf("\n");
  7231.         break;
  7232. #endif /* NOXMIT */
  7233.  
  7234. #ifndef NODIAL
  7235.       case SHMOD:                       /* SHOW MODEM */
  7236. #ifdef IKSD
  7237.         if (inserver) {
  7238.             printf("Sorry, command disabled.\r\n");
  7239.             return(success = 0);
  7240.         }
  7241. #endif /* IKSD */
  7242.         shomodem();                     /* Show SET MODEM items */
  7243.         break;
  7244. #endif /* NODIAL */
  7245.  
  7246. #ifndef MAC
  7247.       case SHDFLT:
  7248.         printf("%s\n",zgtdir());
  7249.         break;
  7250. #endif /* MAC */
  7251.  
  7252. #ifndef NOLOCAL
  7253.       case SHESC:
  7254. #ifdef IKSD
  7255.         if (inserver) {
  7256.             printf("Sorry, command disabled.\r\n");
  7257.             return(success = 0);
  7258.         }
  7259. #endif /* IKSD */
  7260.         return(shoesc(escape));
  7261.  
  7262. #ifndef NODIAL
  7263.       case SHDIA:                       /* SHOW DIAL */
  7264. #ifdef IKSD
  7265.         if (inserver) {
  7266.             printf("Sorry, command disabled.\r\n");
  7267.             return(success = 0);
  7268.         }
  7269. #endif /* IKSD */
  7270.         shmdmlin();
  7271.         printf(", speed: ");
  7272.         if ((zz = ttgspd()) < 0) {
  7273.             printf("unknown");
  7274.         } else {
  7275.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  7276.         }
  7277.         if (carrier == CAR_OFF) s = "off";
  7278.         else if (carrier == CAR_ON) s = "on";
  7279.         else if (carrier == CAR_AUT) s = "auto";
  7280.         else s = "unknown";
  7281.         printf(", carrier: %s", s);
  7282.         if (carrier == CAR_ON) {
  7283.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  7284.             else printf(", timeout: none");
  7285.         }
  7286.         printf("\n");
  7287.         doshodial();
  7288.         if (local
  7289. #ifdef NETCONN
  7290.             && !network
  7291. #endif /* NETCONN */
  7292.             ) {
  7293.             printf("Type SHOW MODEM to see modem settings.\n");
  7294. #ifdef CK_TAPI
  7295.             printf("Type SHOW TAPI to see TAPI-related items\n");
  7296. #endif /* CK_TAPI */
  7297.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  7298.         }
  7299.         break;
  7300. #endif /* NODIAL */
  7301. #endif /* NOLOCAL */
  7302.  
  7303. #ifndef NOXFER
  7304. #ifdef CK_LABELED
  7305.       case SHLBL:                       /* Labeled file info */
  7306.         sholbl();
  7307.         break;
  7308. #endif /* CK_LABELED */
  7309. #endif /* NOXFER */
  7310.  
  7311.       case SHCSE:                       /* Character sets */
  7312. #ifdef NOCSETS
  7313.         printf(
  7314. " Character set translation is not supported in this version of C-Kermit\n");
  7315. #else
  7316.         shocharset();
  7317. #ifndef NOXFER
  7318.         printf("\n Unknown-Char-Set: %s\n",
  7319.                unkcs ? "Keep" : "Discard");
  7320. #endif /* NOXFER */
  7321. #ifdef OS2
  7322.         printf("\n");
  7323. #endif /* OS2 */
  7324.         shotcs(tcsl,tcsr);
  7325.         printf("\n");
  7326. #ifdef OS2
  7327.         /* PC Code Page information */
  7328.         {
  7329.             char cpbuf[128];
  7330.             int cplist[16], cps;
  7331.             int activecp;
  7332.             cps = os2getcplist(cplist, sizeof(cplist));
  7333.  
  7334.             sprintf(cpbuf,              /* SAFE */
  7335.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7336.                      cps > 1 ? cplist[1] : 0,
  7337.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7338.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7339.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7340.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7341.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7342.                      cps > 12 ? cplist[12] : 0
  7343.                      );
  7344.             printf(" Code Pages:\n");
  7345.             activecp = os2getcp();
  7346.             if ( activecp ) {
  7347.               printf("     Active: %d\n",activecp);
  7348.               if (!isWin95())
  7349.                 printf("  Available: %s\n",cpbuf);
  7350.             } else
  7351.               printf("     Active: n/a\n");
  7352.             printf("\n");
  7353.         }
  7354. #endif /* OS2 */
  7355. #endif /* NOCSETS */
  7356.         break;
  7357.  
  7358.       case SHFEA:                       /* Features */
  7359.         shofea();
  7360.         break;
  7361.  
  7362. #ifdef CK_SPEED
  7363.       case SHCTL:                       /* Control-Prefix table */
  7364.         shoctl();
  7365.         break;
  7366. #endif /* CK_SPEED */
  7367.  
  7368.       case SHEXI: {
  7369.           extern int exithangup;
  7370.           printf("\n Exit warning %s\n", xitwarn ?
  7371.                  (xitwarn == 1 ? "on" : "always") : "off");
  7372.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7373.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7374.           printf(" Current exit status: %d\n\n", xitsta);
  7375.           break;
  7376.       }
  7377.       case SHPRT: {
  7378. #ifdef PRINTSWI
  7379.           extern int printtimo, printertype, noprinter;
  7380.           extern char * printterm, * printsep;
  7381.           extern int prncs;
  7382. #ifdef BPRINT
  7383.           extern int printbidi;
  7384. #endif /* BPRINT */
  7385. #endif /* PRINTSWI */
  7386.  
  7387. #ifdef IKSD
  7388.         if (inserver &&
  7389. #ifdef CK_LOGIN
  7390.             isguest
  7391. #else /* CK_LOGIN */
  7392.             0
  7393. #endif /* CK_LOGIN */
  7394.              ) {
  7395.             printf("Sorry, command disabled.\r\n");
  7396.             return(success = 0);
  7397.         }
  7398. #endif /* IKSD */
  7399. #ifdef PRINTSWI
  7400.           if (noprinter) {
  7401.               printf("Printer: (none)\n\n");
  7402.               break;
  7403.           }
  7404. #endif /* PRINTSWI */
  7405.  
  7406.           printf("Printer: %s%s\n",
  7407.  
  7408.                  printpipe ? "| " : "",
  7409.                  printername ? printername :
  7410. #ifdef OS2
  7411.                  "PRN"
  7412. #else
  7413.                  "(default)"
  7414. #endif /* OS2 */
  7415.                  );
  7416. #ifdef PRINTSWI
  7417. #ifdef BPRINT
  7418.           if (printbidi) {
  7419.               printf(" /BIDIRECTIONAL\n");
  7420.               if (pportspeed > 0)
  7421.                 printf(" /SPEED:%ld\n",pportspeed);
  7422.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7423.               printf(" /FLOW:%s\n",
  7424.                      pportflow == FLO_NONE ? "NONE" :
  7425.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7426.                      );
  7427.           } else
  7428.             printf(" /OUTPUT-ONLY\n");
  7429. #endif /* BPRINT */
  7430.           switch (printertype) {
  7431.             case PRT_NON: printf(" /NONE\n"); break;
  7432.             case PRT_FIL: printf(" /FILE\n"); break;
  7433.             case PRT_PIP: printf(" /PIPE\n"); break;
  7434.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7435.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7436.           }
  7437.           printf(" /TIMEOUT:%d\n",printtimo);
  7438.           if (printterm) {
  7439.               printf(" /END-OF-JOB-STRING:");
  7440.               shostrdef(printterm);
  7441.               printf("\n");
  7442.           } else
  7443.             printf(" /END-OF-JOB-STRING:(none)\n");
  7444.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7445.           printf(" /CHARACTER-SET: %s\n",txrinfo[prncs]->keywd);
  7446. #endif /* PRINTSWI */
  7447.           printf("\n");
  7448.           break;
  7449.       }
  7450.  
  7451.       case SHCMD: {
  7452. #ifdef DOUBLEQUOTING
  7453.           extern int dblquo;
  7454. #endif /* DOUBLEQUOTING */
  7455. #ifdef CK_AUTODL
  7456.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7457. #else
  7458.           printf(" Command autodownload: (not available)\n");
  7459. #endif /* CK_AUTODL */
  7460.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7461.           printf(" Command error-display: %d\n", cmd_err);
  7462. #ifdef CK_RECALL
  7463.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7464. #else
  7465.           printf(" Command recall-buffer not available in this version\n");
  7466. #endif /* CK_RECALL */
  7467. #ifdef CK_RECALL
  7468.           printf(" Command retry: %s\n",showoff(cm_retry));
  7469. #else
  7470.           printf(" Command retry not available in this version\n");
  7471. #endif /* CK_RECALL */
  7472.           printf(" Command interruption: %s\n", showoff(cmdint));
  7473.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7474. #ifdef DOUBLEQUOTING
  7475.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7476. #endif /* DOUBLEQUOTING */
  7477.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7478.           printf(" Command height: %d\n", cmd_rows);
  7479.           printf(" Command width:  %d\n", cmd_cols);
  7480. #ifndef IKSDONLY
  7481. #ifdef OS2
  7482.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7483. #endif /* OS2 */
  7484. #endif /* IKSDONLY */
  7485. #ifdef LOCUS
  7486.           printf(" Locus:          %s",
  7487.                  autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7488.          (locus ? "local" : "remote"));
  7489.           if (autolocus)
  7490.             printf(" (%s)", locus ? "local" : "remote");
  7491.           printf("\n");
  7492. #endif /* LOCUS */
  7493.           printf(" Hints:          %s\n", showoff(hints));
  7494.           printf(" Quiet:          %s\n", showoff(quiet));
  7495.           printf(" Maximum command length: %d\n", CMDBL);
  7496. #ifndef NOSPL
  7497.           {
  7498.               char * s;
  7499.               int k;
  7500.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7501.               printf(" Macros defined: %d\n", nmac);
  7502.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7503.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7504.               s = "(not defined)";
  7505.               k = mlook(mactab,"on_unknown_command",nmac);
  7506.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7507.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7508.           }
  7509. #endif /* NOSPL */
  7510. #ifdef UNIX
  7511. #ifndef NOJC
  7512.           printf(" Suspend: %s\n", showoff(xsuspend));
  7513. #endif /* NOJC */
  7514. #endif /* UNIX */
  7515.           printf(" Access to external commands and programs%s allowed\n",
  7516. #ifndef NOPUSH
  7517.                  !nopush ? "" :
  7518. #endif /* NOPUSH */
  7519.                   " not");
  7520.           break;
  7521.       }
  7522.  
  7523. #ifndef NOSPL
  7524.       case SHALRM:
  7525.         if (ck_alarm)
  7526.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7527.         else
  7528.           printf("(no alarm set)\n");
  7529.         break;
  7530. #endif /* NOSPL */
  7531.  
  7532. #ifndef NOMSEND
  7533.       case SHSFL: {
  7534.           extern struct filelist * filehead;
  7535.           if (!filehead) {
  7536.               printf("send-list is empty\n");
  7537.           } else {
  7538.               struct filelist * flp;
  7539.               char * s;
  7540.               flp = filehead;
  7541.               while (flp) {
  7542.                   s = flp->fl_alias;
  7543.                   if (!s) s = "(none)";
  7544.                   printf("%s, mode: %s, alias: %s\n",
  7545.                          flp->fl_name,
  7546.                          gfmode(flp->fl_mode,0),
  7547.                          s
  7548.                          );
  7549.                   flp = flp->fl_next;
  7550.               }
  7551.           }
  7552.       }
  7553.       break;
  7554. #endif /* NOMSEND */
  7555.  
  7556. #ifdef CKXXCHAR
  7557.       case SHDBL:
  7558.         shodbl();
  7559.         break;
  7560. #endif /* CKXXCHAR */
  7561.  
  7562. #ifndef NOPUSH
  7563. #ifndef NOFRILLS
  7564.       case SHEDIT:
  7565.         if (!editor[0]) {
  7566.             s = getenv("EDITOR");
  7567.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7568.         }
  7569.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7570.         if (editor[0]) {
  7571.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7572.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7573.         }
  7574.         printf("\n");
  7575.         break;
  7576.  
  7577. #ifdef BROWSER
  7578.       case SHBROWSE:
  7579.         if (!browser[0]) {
  7580.             s = getenv("BROWSER");
  7581.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7582.         }
  7583.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7584.         if (browser[0]) {
  7585.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7586.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7587.         }
  7588.         printf("\n");
  7589.         break;
  7590. #endif /* BROWSER */
  7591. #endif /*  NOFRILLS */
  7592. #endif /* NOPUSH */
  7593.  
  7594. #ifndef NOLOCAL
  7595. #ifdef CK_TAPI
  7596.       case SHTAPI:                      /* TAPI options */
  7597. #ifdef IKSD
  7598.         if (inserver) {
  7599.             printf("Sorry, command disabled.\r\n");
  7600.             return(success = 0);
  7601.         }
  7602. #endif /* IKSD */
  7603.         shotapi(0);
  7604.         break;
  7605.       case SHTAPI_L:                    /* TAPI Locations */
  7606. #ifdef IKSD
  7607.         if (inserver) {
  7608.             printf("Sorry, command disabled.\r\n");
  7609.             return(success = 0);
  7610.         }
  7611. #endif /* IKSD */
  7612.         shotapi(1);
  7613.         break;
  7614.       case SHTAPI_M:                    /* TAPI Modem */
  7615. #ifdef IKSD
  7616.         if (inserver) {
  7617.             printf("Sorry, command disabled.\r\n");
  7618.             return(success = 0);
  7619.         }
  7620. #endif /* IKSD */
  7621.         shotapi(2);
  7622.         break;
  7623.       case SHTAPI_C:                    /* TAPI Comm */
  7624. #ifdef IKSD
  7625.         if (inserver) {
  7626.             printf("Sorry, command disabled.\r\n");
  7627.             return(success = 0);
  7628.         }
  7629. #endif /* IKSD */
  7630.         shotapi(3);
  7631.         break;
  7632. #endif /* CK_TAPI */
  7633.  
  7634.       case SHTCP:                       /* SHOTCP */
  7635.         printf("\n");
  7636.         shotcp(0);
  7637.         printf("\n");
  7638.         break;
  7639.  
  7640. #ifdef TNCODE
  7641.       case SHTEL:                       /* TELNET */
  7642.         printf("\n");
  7643.         shotel(0);
  7644.         printf("\n");
  7645.         break;
  7646.  
  7647.       case SHTOPT:                      /* TELNET OPTIONS */
  7648.         printf("\n");
  7649.         shotopt(0);
  7650.         printf("\n");
  7651.         break;
  7652. #endif /* TNCODE */
  7653.  
  7654. #ifdef CK_TRIGGER
  7655.       case SHTRIG: {
  7656.           extern char * tt_trigger[], * triggerval;
  7657.           int i;
  7658.           if (!tt_trigger[0]) {
  7659.               printf(" Triggers: (none)\n");
  7660.           } else {
  7661.               printf(" Triggers:\n");
  7662.               for (i = 0; i < TRIGGERS; i++) {
  7663.                   if (!tt_trigger[i])
  7664.                     break;
  7665.                   printf("  \"%s\"\n",tt_trigger[i]);
  7666.               }
  7667.               printf(" Most recent trigger encountered: ");
  7668.               if (triggerval)
  7669.                 printf("\"%s\"\n",triggerval);
  7670.               else
  7671.                 printf("(none)\n");
  7672.           }
  7673.           break;
  7674.       }
  7675. #endif /* CK_TRIGGER */
  7676. #endif /* NOLOCAL */
  7677.  
  7678. #ifndef NOSPL
  7679.       case SHINP:
  7680.         shoinput();
  7681.         break;
  7682. #endif /* NOSPL */
  7683.  
  7684.       case SHLOG: {
  7685. #ifndef MAC
  7686. #ifdef IKSD
  7687.           if (inserver &&
  7688. #ifdef CK_LOGIN
  7689.               isguest
  7690. #else /* CK_LOGIN */
  7691.               0
  7692. #endif /* CK_LOGIN */
  7693.              ) {
  7694.             printf("Sorry, command disabled.\r\n");
  7695.             return(success = 0);
  7696.         }
  7697. #endif /* IKSD */
  7698. #ifdef DEBUG
  7699.           printf("\n Debug log:       %s", deblog ? debfil : "(none)");
  7700.       {
  7701.           extern int debtim;
  7702.           if (debtim) printf(" (timestamps)");
  7703.           printf("\n");
  7704.       }
  7705. #endif /* DEBUG */
  7706. #ifndef NOXFER
  7707.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7708. #endif /* NOXFER */
  7709. #ifndef NOLOCAL
  7710.           printf(" Session log:     %s",   seslog ? sesfil : "(none)");
  7711.       {
  7712.           extern int sessft, slogts, slognul;
  7713.           switch (sessft) {
  7714.         case XYFT_T: printf(" (text)"); break;
  7715.         case XYFT_B: printf(" (binary)"); break;
  7716.         case XYFT_D: printf(" (debug)"); break;
  7717.           }
  7718.           if (slogts) printf("(timestamped)");
  7719.           if (slognul) printf("(null-padded)");
  7720.           printf("\n");
  7721.       }
  7722.  
  7723. #endif /* NOLOCAL */
  7724. #ifdef TLOG
  7725.           printf(" Transaction log: %s (%s)\n",
  7726.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7727.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7728.                  );
  7729. #endif /* TLOG */
  7730. #ifdef CKLOGDIAL
  7731.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7732. #endif /* CKLOGDIAL */
  7733.           printf("\n");
  7734. #endif /* MAC */
  7735.           break;
  7736.       }
  7737.  
  7738. #ifndef NOSPL
  7739.       case SHOUTP:                      /* OUTPUT */
  7740.         shooutput();
  7741.         break;
  7742. #endif /* NOSPL */
  7743.  
  7744. #ifdef PATTERNS
  7745.       case SHOPAT:                      /* PATTERNS */
  7746.         shopat();
  7747.         break;
  7748. #endif /* PATTERNS */
  7749.  
  7750. #ifdef STREAMING
  7751.       case SHOSTR: {                    /* STREAMING */
  7752.           extern int streamrq, clearrq, cleared;
  7753.           extern long tfcps;
  7754.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7755.           printf("\n Reliable:     %s\n",showooa(reliable));
  7756.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7757.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7758.           if ((!local && (streamrq == SET_ON)) ||
  7759.               (streamrq == SET_AUTO && reliable))
  7760.             printf(" Streaming will be done if requested.\n");
  7761.           else if ((streamrq == SET_OFF) ||
  7762.                    ((streamrq == SET_AUTO) && !reliable))
  7763.             printf(" Streaming will not be requested and will not be done.\n");
  7764.           else if ((streamrq == SET_ON) ||
  7765.                    ((streamrq == SET_AUTO) && reliable))
  7766.             printf(
  7767. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7768.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7769.                  streamed > 0 ? "" : "no ",
  7770.                  cleared ? ", clearchannel" : "",
  7771.                  tfcps
  7772.                  );
  7773.           printf("\n");
  7774.           break;
  7775.       }
  7776. #endif /* STREAMING */
  7777.  
  7778.       case SHOIKS:
  7779.         return(sho_iks());
  7780.         break;
  7781.  
  7782. #ifdef CK_AUTHENTICATION
  7783.       case SHOAUTH:
  7784.         return(sho_auth(0));
  7785. #endif /* CK_AUTHENTICATION */
  7786.  
  7787. #ifndef NOFTP
  7788.       case SHOFTP: {
  7789. #ifdef IKSD
  7790.         if (inserver) {
  7791.             printf("Sorry, command disabled.\r\n");
  7792.             return(success = 0);
  7793.         }
  7794. #endif /* IKSD */
  7795. #ifdef SYSFTP
  7796.         {
  7797.             extern char ftpapp[], ftpopts[];
  7798.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7799.             if (ftpapp[0])
  7800.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7801.         }
  7802. #else
  7803. #ifdef NEWFTP
  7804.         shoftp(0);
  7805. #else
  7806.         printf("(No FTP client included in this version of Kermit.)\n");
  7807. #endif /* NEWFTP */
  7808. #endif /* SYSFTP */
  7809.         break;
  7810.       }
  7811. #endif /* NOFTP */
  7812.  
  7813. #ifndef NOCMDL
  7814.       case SHXOPT: {
  7815. #ifdef IKSDB
  7816.           extern int dbenabled;
  7817.           extern char * dbfile, * dbdir;
  7818. #endif /* IKSDB */
  7819. #ifdef CKWTMP
  7820.           extern int ckxwtmp;
  7821.           extern char * wtmpfile;
  7822. #endif /* CKWTMP */
  7823. #ifdef CK_LOGIN
  7824.           extern int ckxanon, xferlog, logintimo;
  7825.           extern char * xferfile;
  7826. #ifdef UNIX
  7827.           extern int ckxpriv;
  7828. #endif /* UNIX */
  7829. #ifdef CK_PERMS
  7830.           extern int ckxperms;
  7831. #endif /* CK_PERMS */
  7832. #endif /* CK_LOGIN */
  7833.           extern char * bannerfile, * helpfile;
  7834.  
  7835. #ifdef IKSD
  7836.           if (inserver &&
  7837. #ifdef CK_LOGIN
  7838.               isguest
  7839. #else /* CK_LOGIN */
  7840.               0
  7841. #endif /* CK_LOGIN */
  7842.               ) {
  7843.               printf("Sorry, command disabled.\r\n");
  7844.               return(success = 0);
  7845.           }
  7846. #endif /* IKSD */
  7847.           printf("\n");
  7848.           if (!cmdint)
  7849.             printf(" --nointerrupts\n");
  7850.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7851.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7852.           printf(" --cdmessage:%d\n",srvcdmsg);
  7853.           printf(" --helpfile:%d\n",helpfile);
  7854.           if (inserver) {
  7855.               printf("\n");
  7856.               break;
  7857.           }
  7858. #ifdef CKSYSLOG
  7859. #ifdef SYSLOGLEVEL
  7860.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7861. #else
  7862.           printf(" --syslog:%d\n",ckxsyslog);
  7863. #endif /* SYSLOGLEVEL */
  7864. #endif /* CKSYSLOG */
  7865. #ifdef CKWTMP
  7866.           printf(" --wtmplog:%d\n",ckxwtmp);
  7867.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7868. #endif /* CKWTMP */
  7869. #ifdef IKSD
  7870. #ifdef CK_LOGIN
  7871.           printf(" --anonymous:%d\n",ckxanon);
  7872. #ifdef UNIX
  7873.           printf(" --privid:%d\n",ckxpriv);
  7874. #endif /* UNIX */
  7875. #ifdef CK_PERMS
  7876.           printf(" --permission:%04o\n",ckxperms);
  7877. #endif /* CK_PERMS */
  7878.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7879.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7880.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7881.           printf(" --xferlog=%d\n",xferlog);
  7882.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7883.           printf(" --timeout=%d\n",logintimo);
  7884. #endif /* CK_LOGIN */
  7885. #ifdef IKSDB
  7886.           printf(" --database=%d\n",dbenabled);
  7887.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7888.           if (dbdir)
  7889.             printf("   (db directory=[%s])\n",dbdir);
  7890. #endif /* IKSDB */
  7891. #ifdef IKSDCONF
  7892.           printf(" IKSD conf=%s\n",iksdconf);
  7893. #endif /* IKSDCONF */
  7894. #endif /* IKSD */
  7895.           printf("\n");
  7896.           break;
  7897.       }
  7898. #endif /* NOCMDL */
  7899.  
  7900.       case SHCD: {
  7901.       extern char * myhome;
  7902.       s = getenv("CDPATH");
  7903.       if (!s) s = "(none)";
  7904.       printf("\n current directory:  %s\n", zgtdir());
  7905.       printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7906.       printf(" cd home:            %s\n", homepath());
  7907.       printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7908.       printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7909.       printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7910.       printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7911.       break;
  7912.       }
  7913. #ifndef NOCSETS
  7914.       case SHASSOC:
  7915.         (VOID) showassoc();
  7916.         break;
  7917. #endif /* NOCSETS */
  7918.  
  7919. #ifdef CKLOGDIAL
  7920.       case SHCONNX:
  7921. #ifdef NEWFTP
  7922.         if (ftpisconnected()) {
  7923.             extern char cxlogbuf[];
  7924.             dologshow(W_FTP | 1);
  7925.             if (cxlogbuf[0])
  7926.               dologshow(1);
  7927.         } else {
  7928. #endif /* NEWFTP */
  7929.             dologshow(1);
  7930. #ifdef NEWFTP
  7931.         }
  7932. #endif /* NEWFTP */
  7933.         break;
  7934. #endif /* CKLOGDIAL */
  7935.  
  7936.       case SHOPTS:
  7937.         optlines = 0;
  7938. #ifndef NOFRILLS
  7939.         (VOID) showdelopts();
  7940. #endif /* NOFRILLS */
  7941. #ifdef DOMYDIR
  7942.         (VOID) showdiropts();
  7943. #endif /* DOMYDIR */
  7944. #ifdef CKPURGE
  7945.         (VOID) showpurgopts();
  7946. #endif /* CKPURGE */
  7947.         (VOID) showtypopts();
  7948.         break;
  7949.  
  7950. #ifndef NOLOCAL
  7951.       case SHOFLO:
  7952.         (VOID) shoflow();
  7953.         break;
  7954. #endif /* NOLOCAL */
  7955.  
  7956. #ifndef NOXFER
  7957.       case SHOXFER:
  7958.         (VOID) shoxfer();
  7959.         break;
  7960. #endif /* NOXFER */
  7961.  
  7962. #ifdef CK_RECALL
  7963.       case SHHISTORY:
  7964.         (VOID) cmhistory();
  7965.         break;
  7966. #endif /* CK_RECALL */
  7967.  
  7968. #ifndef NOSEXP
  7969. #ifndef NOSPL
  7970.       case SHSEXP:
  7971.         (VOID) shosexp();
  7972.         break;
  7973. #endif /* NOSPL */
  7974. #endif /* NOSEXP */
  7975.  
  7976. #ifdef ANYSSH
  7977.       case SHOSSH:
  7978.         (VOID) shossh();
  7979.         break;
  7980. #endif /* ANYSSH */
  7981.  
  7982. #ifdef KUI
  7983.       case SHOGUI:
  7984.         (VOID) shogui();
  7985.         break;
  7986. #endif /* KUI */
  7987.  
  7988. #ifndef NOFRILLS
  7989. #ifndef NORENAME
  7990.       case SHOREN:
  7991.         (VOID) shorename();
  7992.         break;
  7993. #endif    /* NORENAME */
  7994. #endif    /* NOFRILLS */
  7995.  
  7996.       default:
  7997.         printf("\nNothing to show...\n");
  7998.         return(-2);
  7999.     }
  8000.     return(success = 1);
  8001. }
  8002.  
  8003. #ifndef NOXFER
  8004. int
  8005. shoatt() {
  8006.     printf("Attributes: %s\n", showoff(atcapr));
  8007.     if (!atcapr) return(0);
  8008.     printf(" Blocksize: %s\n", showoff(atblki));
  8009.     printf(" Date: %s\n", showoff(atdati));
  8010.     printf(" Disposition: %s\n", showoff(atdisi));
  8011.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  8012.     printf(" Length: %s\n", showoff(atleni));
  8013.     printf(" Type (text/binary): %s\n", showoff(attypi));
  8014.     printf(" System ID: %s\n", showoff(atsidi));
  8015.     printf(" System Info: %s\n", showoff(atsysi));
  8016. #ifdef CK_PERMS
  8017.     printf(" Permissions In:  %s\n", showoff(atlpri));
  8018.     printf(" Permissions Out: %s\n", showoff(atlpro));
  8019. #endif /* CK_PERMS */
  8020. #ifdef STRATUS
  8021.     printf(" Format: %s\n", showoff(atfrmi));
  8022.     printf(" Creator: %s\n", showoff(atcrei));
  8023.     printf(" Account: %s\n", showoff(atacti));
  8024. #endif /* STRATUS */
  8025.     return(0);
  8026. }
  8027. #endif /* NOXFER */
  8028.  
  8029. #ifndef NOSPL
  8030. int                                     /* SHOW MACROS */
  8031. shomac(s1, s2) char *s1, *s2; {
  8032.     int x, n, pp;
  8033.     pp = 0;                             /* Parenthesis counter */
  8034.  
  8035.     debug(F110,"shomac s1",s1,0);
  8036.     debug(F110,"shomac s2",s2,0);
  8037.  
  8038. #ifdef IKSD
  8039.     if ( inserver &&
  8040. #ifdef IKSDCONF
  8041.         iksdcf
  8042. #else /* IKSDCONF */
  8043.         1
  8044. #endif /* IKSDCONF */
  8045.         ) {
  8046.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  8047.             !ckstrcmp("on_logout",s1,-1,0))
  8048.           return(0);
  8049.     }
  8050. #endif /* IKSD */
  8051.  
  8052.     if (!s1)
  8053.       return(0);
  8054.     else
  8055.       printf("%s = ",s1);               /* Print blank line and macro name */
  8056.     n = (int)strlen(s1) + 4;            /* Width of current line */
  8057.     if (!s2) s2 = "(not defined)";
  8058.  
  8059.     while ((x = *s2++)) {               /* Loop thru definition */
  8060.         if (x == '(') pp++;             /* Treat commas within parens */
  8061.         if (x == ')') pp--;             /* as ordinary text */
  8062.         if (pp < 0) pp = 0;             /* Outside parens, */
  8063.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  8064.             putchar(',');
  8065.             putchar('-');
  8066.             x = '\n';
  8067.         }
  8068.         if (inserver && (x == '\n'))    /* Send CR before LF */
  8069.           putchar(CR);
  8070.         putchar((CHAR)x);               /* Output the character */
  8071.         if (x == '\n') {                /* If it was a newline */
  8072. #ifdef UNIX
  8073. #ifdef NOSETBUF
  8074.             fflush(stdout);
  8075. #endif /* NOSETBUF */
  8076. #endif /* UNIX */
  8077.             putchar(' ');               /* Indent the next line 1 space */
  8078.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  8079.             n = 2;                      /* restart the character counter */
  8080.             slc++;                      /* and increment the line counter. */
  8081.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  8082.             putchar('-');               /* output a dash */
  8083.             if (inserver)
  8084.               putchar(CR);              /* and a carriage return */
  8085.             putchar(NL);                /* and a newline */
  8086. #ifdef UNIX
  8087. #ifdef NOSETBUF
  8088.             fflush(stdout);
  8089. #endif /* NOSETBUF */
  8090. #endif /* UNIX */
  8091.             n = 1;                      /* and restart the char counter */
  8092.             slc++;                      /* and increment the line counter */
  8093.         }
  8094.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  8095.             if (!askmore()) return(-1); /* ask if they want more. */
  8096.             n = 1;                      /* They do, start a new line */
  8097.             slc = 0;                    /* and restart line counter */
  8098.         }
  8099.     }
  8100.     if (inserver)
  8101.       putchar(CR);
  8102.     putchar(NL);                        /* End of definition */
  8103.     if (++slc > (cmd_rows - 3)) {
  8104.         if (!askmore()) return(-1);
  8105.         slc = 0;
  8106.     }
  8107.     return(0);
  8108. }
  8109. #endif /* NOSPL */
  8110. #endif /* NOSHOW */
  8111.  
  8112. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  8113.  
  8114. #ifndef NOSPL
  8115. /* Evaluate an arithmetic expression. */
  8116. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  8117.  
  8118. static int xerror = 0;
  8119. int divbyzero = 0;
  8120. static char *cp;
  8121. static CK_OFF_T tokval;
  8122. static char curtok;
  8123. static CK_OFF_T expval;
  8124.  
  8125. #define LONGBITS (8*sizeof (CK_OFF_T))
  8126. #define NUMBER 'N'
  8127. #define N_EOT 'E'
  8128.  
  8129. /*
  8130.  Replacement for strchr() and index(), neither of which seem to be universal.
  8131. */
  8132.  
  8133. static char *
  8134. #ifdef CK_ANSIC
  8135. windex(char * s, char c)
  8136. #else
  8137. windex(s,c) char *s, c;
  8138. #endif /* CK_ANSIC */
  8139. /* windex */ {
  8140.     while (*s != NUL && *s != c) s++;
  8141.     if (*s == c) return(s); else return(NULL);
  8142. }
  8143.  
  8144.  
  8145. /*
  8146.  g e t t o k
  8147.  
  8148.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  8149. */
  8150. static char
  8151. gettok() {
  8152.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  8153.  
  8154.     while (isspace(*cp))                /* Skip past leading spaces */
  8155.       cp++;
  8156.  
  8157.     debug(F110,"GETTOK",cp,0);
  8158.  
  8159.     switch (*cp) {
  8160.       case '$':                         /* ??? */
  8161.       case '+':                         /* Add */
  8162.       case '-':                         /* Subtract or Negate */
  8163.       case '@':                         /* Greatest Common Divisor */
  8164.       case '*':                         /* Multiply */
  8165.       case '/':                         /* Divide */
  8166.       case '%':                         /* Modulus */
  8167.       case '<':                         /* Left shift */
  8168.       case '>':                         /* Right shift */
  8169.       case '&':                         /* And */
  8170.       case '|':                         /* Or */
  8171.       case '#':                         /* Exclusive Or */
  8172.       case '~':                         /* Not */
  8173.       case '^':                         /* Exponent */
  8174.       case '!':                         /* Factorial */
  8175.       case '(':                         /* Parens for grouping */
  8176.       case ')': return(*cp++);          /* operator, just return it */
  8177.       case '\n':
  8178.       case '\0': return(N_EOT);         /* End of line, return that */
  8179.     }
  8180. #ifdef COMMENT
  8181. /* This is the original code, which allows only integer numbers. */
  8182.  
  8183.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  8184.         int radix = 10;                 /* Default radix */
  8185.         for (tp = tbuf; isxdigit(*cp); cp++)
  8186.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  8187.         *tp = '\0';                     /* End number */
  8188.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  8189.           case 'h':
  8190.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  8191.           case 'o':
  8192.           case 'q': radix = 8; cp++; break;
  8193.           case 't': radix = 2; cp++; break;
  8194.         }
  8195.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  8196.             int dig;
  8197.             dig = *tp - '0';            /* Convert number */
  8198.             if (dig > 10) dig -= 'a'-'0'-10;
  8199.             if (dig >= radix) {
  8200.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8201.                   printf("?Invalid digit '%c' in number\n",*tp);
  8202.                 xerror = 1;
  8203.                 return(NUMBER);
  8204.             }
  8205.             tokval = radix*tokval + dig;
  8206.         }
  8207.         return(NUMBER);
  8208.     }
  8209.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  8210.       printf("Invalid character '%c' in input\n",*cp);
  8211.     xerror = 1;
  8212.     cp++;
  8213.     return(gettok());
  8214. #else
  8215. /* This code allows non-numbers to be treated as macro names */
  8216.     {
  8217.         int i, x;
  8218.         char * s, * cp1;
  8219.         cp1 = cp;
  8220.         tp = tbuf;
  8221.         for (i = 0; i < 80; i++) {
  8222.             /* Look ahead to next break character */
  8223.             /* pretty much anything that is not in the switch() above. */
  8224.             if (isalpha(*cp) || isdigit(*cp) ||
  8225.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  8226.                 *cp == '[' || *cp == ']' ||
  8227.                 *cp == '{' || *cp == '}'
  8228.                 )
  8229.               tbuf[i] = *cp++;
  8230.             else
  8231.               break;
  8232.         }
  8233.         if (i >= 80) {
  8234.             printf("Too long - \"%s\"\n", cp1);
  8235.             xerror = 1;
  8236.             cp++;
  8237.             return(gettok());
  8238.         }
  8239.         if (xerror) return(NUMBER);
  8240.  
  8241.         tbuf[i] = NUL;
  8242.         s = tbuf;
  8243.         if (!isdigit(tbuf[0])) {
  8244.             char * s2 = NULL;
  8245.             x = mxlook(mactab,tbuf,nmac);
  8246.             debug(F111,"gettok mxlook",tbuf,x);
  8247.             if (x < 0) {
  8248.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8249.                   printf("Bad number - \"%s\"\n",tbuf);
  8250.                 xerror = 1;
  8251.                 cp++;
  8252.                 return(gettok());
  8253.             }
  8254.             s2 = mactab[x].mval;
  8255.             if (!s2) s2 = "";
  8256.             if (*s2) s = s2;
  8257.         }
  8258. #ifdef CKFLOAT
  8259.         x = isfloat(s,0);
  8260. #else
  8261.         x = chknum(s);
  8262. #endif /* CKFLOAT */
  8263.         if (x > 0) {
  8264.             tokval = ckatofs(s);
  8265.         } else {
  8266.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8267.               printf("Bad number - \"%s\"\n",tbuf);
  8268.             xerror = 1;
  8269.             cp++;
  8270.             return(gettok());
  8271.         }
  8272.         return(NUMBER);
  8273.     }
  8274. #endif /* COMMENT */
  8275. }
  8276.  
  8277. static CK_OFF_T
  8278. #ifdef CK_ANSIC
  8279. expon(CK_OFF_T x, CK_OFF_T y)
  8280. #else
  8281. expon(x,y) CK_OFF_T x,y;
  8282. #endif /* CK_ANSIC */
  8283. /* expon */ {
  8284.     CK_OFF_T result = 1;
  8285.     int sign = 1;
  8286.     if (y < 0) return(0);
  8287.     if (x < 0) {
  8288.         x = -x;
  8289.         if (y & 1) sign = -1;
  8290.     }
  8291.     while (y != 0) {
  8292.         if (y & 1) result *= x;
  8293.         y >>= 1;
  8294.         if (y != 0) x *= x;
  8295.   }
  8296.   return(result * sign);
  8297. }
  8298.  
  8299. /*
  8300.  * factor ::= simple | simple ^ factor
  8301.  *
  8302.  */
  8303. static VOID
  8304. factor() {
  8305.     CK_OFF_T oldval;
  8306.     simple();
  8307.     if (curtok == '^') {
  8308.         oldval = expval;
  8309.         curtok = gettok();
  8310.         factor();
  8311.         expval = expon(oldval,expval);
  8312.     }
  8313. }
  8314.  
  8315. /*
  8316.  * termp ::= NULL | {*,/,%,&} factor termp
  8317.  *
  8318.  */
  8319. static VOID
  8320. termp() {
  8321.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  8322.         CK_OFF_T oldval;
  8323.         char op;
  8324.         op = curtok;
  8325.         curtok = gettok();              /* skip past operator */
  8326.         oldval = expval;
  8327.         factor();
  8328.         switch(op) {
  8329.           case '*': expval = oldval * expval; break;
  8330.           case '/':
  8331.           case '%':
  8332.             if (expval == 0) {
  8333.                 if (!x_ifnum)
  8334.                   printf("?Divide by zero\n");
  8335.                 xerror = 1;
  8336.                 divbyzero = 1;
  8337.                 expval = -1;
  8338.             } else
  8339.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  8340.             break;
  8341.           case '&':
  8342.             expval = oldval & expval; break;
  8343.         }
  8344.     }
  8345. }
  8346.  
  8347. static CK_OFF_T
  8348. #ifdef CK_ANSIC
  8349. fact(CK_OFF_T x)
  8350. #else
  8351. fact(x) CK_OFF_T x;
  8352. #endif /* CK_ANSIC */
  8353. /* fact */ {                            /* factorial */
  8354.     CK_OFF_T result = 1;
  8355.     while (x > 1)
  8356.       result *= x--;
  8357.     return(result);
  8358. }
  8359.  
  8360. /*
  8361.  * term ::= factor termp
  8362.  *
  8363.  */
  8364. static VOID
  8365. term() {
  8366.     factor();
  8367.     termp();
  8368. }
  8369.  
  8370. static CK_OFF_T
  8371. #ifdef CK_ANSIC
  8372. gcd(CK_OFF_T x, CK_OFF_T y)
  8373. #else
  8374. gcd(x,y) CK_OFF_T x,y;
  8375. #endif /* CK_ANSIC */
  8376. /* gcd */ {                             /* Greatest Common Divisor */
  8377.     int nshift = 0;
  8378.     if (x < 0) x = -x;
  8379.     if (y < 0) y = -y;                  /* validate arguments */
  8380.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8381.  
  8382.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8383.         nshift++;
  8384.         x >>= 1;
  8385.         y >>= 1;
  8386.     }
  8387.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8388.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8389.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8390.         if (x < y) {                    /* force x to be larger */
  8391.             CK_OFF_T t;
  8392.             t = x;
  8393.             x = y;
  8394.             y = t;
  8395.         }
  8396.         x -= y;
  8397.     }
  8398.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8399.     else return((CK_OFF_T) 1 << nshift);    /* else gcd is 1 */
  8400. }
  8401.  
  8402. /*
  8403.  * exprp ::= NULL | {+,-,|,...} term exprp
  8404.  *
  8405.  */
  8406. static VOID
  8407. exprp() {
  8408.     while (windex("+-|<>#@",curtok) != NULL) {
  8409.         CK_OFF_T oldval;
  8410.         char op;
  8411.         op = curtok;
  8412.         curtok = gettok();              /* skip past operator */
  8413.         oldval = expval;
  8414.         term();
  8415.         switch(op) {
  8416.           case '+' : expval = oldval + expval; break;
  8417.           case '-' : expval = oldval - expval; break;
  8418.           case '|' : expval = oldval | expval; break;
  8419.           case '#' : expval = oldval ^ expval; break;
  8420.           case '@' : expval = gcd(oldval,expval); break;
  8421.           case '<' : expval = oldval << expval; break;
  8422.           case '>' : expval = oldval >> expval; break;
  8423.         }
  8424.     }
  8425. }
  8426.  
  8427. /*
  8428.  * expr ::= term exprp
  8429.  *
  8430.  */
  8431. static VOID
  8432. expr() {
  8433.     term();
  8434.     exprp();
  8435. }
  8436.  
  8437. static CK_OFF_T
  8438. xparse() {
  8439.     curtok = gettok();
  8440.     expr();
  8441. #ifdef COMMENT
  8442.     if (curtok == '$') {
  8443.         curtok = gettok();
  8444.         if (curtok != NUMBER) {
  8445.             if (cmdlvl == 0 && !x_ifnum)
  8446.               printf("?Illegal radix\n");
  8447.             xerror = 1;
  8448.             return(0);
  8449.         }
  8450.         curtok = gettok();
  8451.     }
  8452. #endif /* COMMENT */
  8453.     if (curtok != N_EOT) {
  8454.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8455.           printf("?Extra characters after expression\n");
  8456.         xerror = 1;
  8457.     }
  8458.     return(expval);
  8459. }
  8460.  
  8461. char *                                  /* Silent front end for evala() */
  8462. evalx(s) char *s; {
  8463.     char * p;
  8464.     int t;
  8465.     t = x_ifnum;
  8466.     x_ifnum = 1;
  8467.     p = evala(s);
  8468.     x_ifnum = t;
  8469.     return(p);
  8470. }
  8471.  
  8472. char *
  8473. evala(s) char *s; {
  8474.     CK_OFF_T v;                /* Numeric value */
  8475.     if (!s) return("");
  8476.     xerror = 0;                         /* Start out with no error */
  8477.     divbyzero = 0;
  8478.     cp = s;                             /* Make the argument global */
  8479.     v = xparse();                       /* Parse the string */
  8480.     return(xerror ? "" : ckfstoa(v));    /* Return empty string on error */
  8481. }
  8482.  
  8483. /*
  8484.  * simplest ::= NUMBER | ( expr )
  8485.  *
  8486.  */
  8487. static VOID
  8488. simplest() {
  8489.     char * p;
  8490.     p = cp;
  8491.     if (curtok == NUMBER)
  8492.       expval = tokval;
  8493.     else if (curtok == '(') {
  8494.         curtok = gettok();              /* skip over paren */
  8495.         expr();
  8496.         if (curtok != ')') {
  8497.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8498.               printf("?Missing right parenthesis\n");
  8499.             xerror = 1;
  8500.         }
  8501.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8502.  
  8503.     } else {
  8504.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8505.           printf("?Operator unexpected\n");
  8506.         xerror = 1;
  8507.     }
  8508.     curtok = gettok();
  8509. }
  8510.  
  8511. /*
  8512.  * simpler ::= simplest | simplest !
  8513.  *
  8514.  */
  8515. static VOID
  8516. simpler() {
  8517.     simplest();
  8518.     if (curtok == '!') {
  8519.         curtok = gettok();
  8520.         expval = fact(expval);
  8521.     }
  8522. }
  8523.  
  8524. /*
  8525.  * simple ::= {-,~,!} simpler | simpler
  8526.  *
  8527.  */
  8528.  
  8529. static VOID
  8530. simple() {
  8531.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8532.         int op = curtok;
  8533.         curtok = gettok();              /* skip over - sign */
  8534.         simpler();                      /* parse the factor again */
  8535.         if (op != '+')
  8536.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8537.     } else simpler();
  8538. }
  8539.  
  8540. /*  D C L A R R A Y  --  Declare an array  */
  8541. /*
  8542.   Call with:
  8543.    char a = single character designator for the array, e.g. "a".
  8544.    int  n = size of array.  -1 means to undeclare the array.
  8545.   Returns:
  8546.    0 or greater on success, having created the requested array with
  8547.      with n+1 elements, 0..n.  If an array of the same name existed
  8548.      previously, it is destroyed.  The new array has all its elements
  8549.      initialized to NULL pointers.  When an array is successfully created,
  8550.      the return value is its index (0 = 'a', 1 = 'b', and so on.)
  8551.   -1 on failure (because 'a' out of range or malloc failure).
  8552. */
  8553. int
  8554. #ifdef CK_ANSIC
  8555. dclarray(char a, int n)
  8556. #else
  8557. dclarray(a,n) char a; int n;
  8558. #endif /* CK_ANSIC */
  8559. /* dclarray */ {
  8560.     char c, **p; int i, n2, rc;
  8561.  
  8562.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8563.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8564.       return(-1);
  8565.  
  8566.     if (n < 0)                          /* Check arg */
  8567.       return(-1);
  8568.     if (n+1 < 0)                        /* MAXINT+1 wraps around */
  8569.       return(-1);
  8570.  
  8571.     c = a;
  8572.     a -= ARRAYBASE;                     /* Convert name to number */
  8573.     rc = a;                /* Array index will be return code */
  8574.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8575.         if (a_link[a] > -1) {           /* Is it a link? */
  8576.             if (n == 0) {               /* If we're just deleting it */
  8577.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8578.                 a_dim[a] = 0;
  8579.                 a_link[a] = -1;
  8580.                 return(0);
  8581.             }                           /* Not deleting */
  8582.             a = a_link[a];              /* Switch to linked-to array */
  8583.         }
  8584.         n2 = a_dim[a];                  /* Real array */
  8585.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8586.             if (p[i]) {
  8587.                 free(p[i]);
  8588.                 p[i] = NULL;
  8589.             }
  8590.         }
  8591.         free((char *)a_ptr[a]);         /* Then the element list */
  8592.         if (n == 0) {                   /* If undeclaring this array... */
  8593.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8594.                 if (i != a && a_link[i] == a) {     /* Find them */
  8595.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8596.                     a_dim[i] = 0;
  8597.                     a_link[i] = -1;
  8598.                 }
  8599.             }
  8600.         }
  8601.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8602.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8603.         a_link[a] = -1;                 /* Unset link word */
  8604.     }
  8605.     if (n < 0)                /* If only undeclaring, */
  8606.       return(0);            /*  we're done. */
  8607.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8608.     if (p == NULL) return(-1);          /* Check */
  8609.     a_ptr[a] = p;                       /* Save pointer to member list */
  8610.     a_dim[a] = n;                       /* Save dimension */
  8611.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8612.       p[i] = NULL;
  8613.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8614.         if (i != a && a_link[i] == a) { /* Find and update them */
  8615.             a_ptr[i] = p;
  8616.             a_dim[i] = n;
  8617.         }
  8618.     }
  8619.     return(rc);
  8620. }
  8621.  
  8622. /*  X A R R A Y  -- Convert array name to array index  */
  8623.  
  8624. int
  8625. xarray(s) char * s; {
  8626.     char buf[8];
  8627.     int x;
  8628.     char c;
  8629.  
  8630.     if (!s) s = "";
  8631.     debug(F110,"xarray",s,0);
  8632.     if (!*s)
  8633.       return(-1);
  8634.     x = strlen(s);
  8635.  
  8636.     buf[0] = NUL;
  8637.     buf[1] = NUL;
  8638.     buf[2] = s[0];
  8639.     buf[3] = (x > 0) ? s[1] : NUL;
  8640.     buf[4] = (x > 1) ? s[2] : NUL;
  8641.     buf[5] = (x > 2) ? s[3] : NUL;
  8642.     buf[6] = NUL;
  8643.     debug(F110,"xarray buf[3]",&buf[3],0);
  8644.     s = buf+2;
  8645.     if (*s == '&') {
  8646.         buf[1] = CMDQ;
  8647.         s--;
  8648.     } else if (*s != CMDQ) {
  8649.         buf[0] = CMDQ;
  8650.         buf[1] = '&';
  8651.         s = buf;
  8652.     }
  8653.     debug(F110,"xarray s",s,0);
  8654.     c = *(s+2);
  8655.     if (isupper(c))
  8656.       c = tolower(c);
  8657.     if (c == '@')
  8658.       c = 96;
  8659.     x = (int)c - ARRAYBASE;
  8660.     if (*(s+3) == '[')
  8661.       *(s+3) = NUL;
  8662.     if (x < 0) {
  8663.     return(-1);
  8664.     }
  8665.     if (x > ('z' - ARRAYBASE)) {
  8666.     debug(F101,"xarray x out of range","",x);
  8667.     return(-1);
  8668.     }
  8669.     if (*(s+3)) {
  8670.     debug(F110,"xarray syntax",s,0);
  8671.     return(-1);
  8672.     }
  8673.     return(x);
  8674. }
  8675.  
  8676. /*
  8677.   boundspair() -- parses blah[n:m]
  8678.  
  8679.   For use with array segment specifiers and compact substring notation.
  8680.   Ignores the "blah" part, gets the values of n and m, which can be
  8681.   numbers, variables, or arithmetic expressions; anything that resolves
  8682.   to a number.
  8683.  
  8684.   Call with:
  8685.    s    - string to parse
  8686.    sep  - array of permissible bounds separator chars
  8687.    lo   - pointer to low-bound result (or -1)
  8688.    hi   - pointer to hi-bound result (or -1)
  8689.    zz   - pointer to separator char that was encountered (or NUL)
  8690.   Returns:
  8691.    -1 on failure
  8692.     0 on success
  8693. */      
  8694.  
  8695. int
  8696. #ifdef CK_ANSIC
  8697. boundspair(char *s, char *sep, int *lo, int *hi, char *zz)
  8698. #else
  8699. boundspair(s,sep,lo,hi,zz) char *s, *sep, *zz; int *lo, *hi;
  8700. #endif /* CK_ANSIC */
  8701. {
  8702.     int i, x, y, range[2], bc = 0;
  8703.     char c = NUL, *s2 = NULL, buf[256], *p, *q, *r, *e[2], *tmp = NULL;
  8704.  
  8705.     debug(F110,"boundspair s",s,0);
  8706.     debug(F110,"boundspair sep",sep,0);
  8707.  
  8708.     *lo = -1;                           /* Default bounds */
  8709.     *hi = -1;
  8710.     *zz = 0;                /* Default bounds separator */
  8711.  
  8712.     range[0] = -1;                      /* It's OK -- get contents */
  8713.     range[1] = -1;                      /* of subscript brackets */
  8714.     if (!s) s = "";
  8715.     if (!*s)
  8716.       return(-1);
  8717.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8718.     p = tmp;
  8719.     q = NULL;
  8720.     r = NULL;
  8721.     for (p = s; *p; p++) {        /* Get the two elements */
  8722.     if (*p == '[') {
  8723.         bc++;
  8724.         if (bc == 1 && !q) q = p+1;
  8725.     } else if (*p == ']') {
  8726.         bc--;
  8727.         if (bc == 0 && q) *p = NUL;
  8728.     } else if (bc == 1) {        /* Check for separator */
  8729.         s2 = ckstrchr(sep,*p);
  8730.         if (s2) {
  8731.         debug(F000,"boundspair *s2","",*s2);
  8732.         if (c) {        
  8733.             debug(F000,"boundspair","Too many separators",*s2);
  8734.             makestr(&tmp,NULL);
  8735.             return(-1);
  8736.         }
  8737.         c = *s2;
  8738.         *p = NUL;
  8739.         r = p+1;
  8740.         }
  8741.     }
  8742.     }
  8743.     if (bc == 0 && !q) {
  8744.     /* This allows such constructions as "show array a" */
  8745.     debug(F110,"boundspair","no brackets",0);
  8746.     makestr(&tmp,NULL);
  8747.     return(0);
  8748.     }
  8749.     if (bc != 0 || !q) {
  8750.     debug(F110,"boundspair","unbalanced or missing brackets",0);
  8751.     makestr(&tmp,NULL);
  8752.     return(-1);
  8753.     }
  8754.     if (!*q) q = "-1";
  8755.     if (!r) r = "-1";
  8756.  
  8757.     e[0] = q;
  8758.     e[1] = r;
  8759.  
  8760.     debug(F000,"boundspair c","",c);
  8761.     debug(F110,"boundspair q",q,0);
  8762.     debug(F110,"boundspair r",r,0);
  8763.  
  8764.     for (i = 0; i < 2 && e[i]; i++) {
  8765.     y = 255;            /* Expand variables, etc. */
  8766.     s = buf;
  8767.     zzstring(e[i],&s,&y);
  8768.     s = evalx(buf);            /* Evaluate it arithmetically */
  8769.     if (s) if (*s)
  8770.       ckstrncpy(buf,s,256);
  8771.     if (!chknum(buf)) {        /* Did we get a number? */
  8772.         debug(F110,"boundspair element not numeric",buf,0);
  8773.         makestr(&tmp,NULL);        /* No, fail. */
  8774.         return(-1);
  8775.     }
  8776.     range[i] = atoi(buf);
  8777.     }
  8778.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8779.     *lo = range[0];                     /* Return what we got */
  8780.     *hi = range[1];
  8781.     *zz = c;
  8782.     debug(F101,"boundspair lo","",*lo);
  8783.     debug(F101,"boundspair hi","",*hi);
  8784.     return(0);
  8785. }
  8786.  
  8787. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8788.  
  8789. /*
  8790.   Call with s = array reference, plus two pointers to ints.
  8791.   Returns -1 on error, or array index, with the two ints set as follows:
  8792.    \&a[]     -1, -1
  8793.    \&a[3]     3, -1
  8794.    \&a[3:17]  3, 17
  8795.   The array need not be declared -- this routine is just for parsing.
  8796. */
  8797. int
  8798. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8799.     int i, x, y, range[2];
  8800.     char zz, buf[256], * p, * q;
  8801.     char * tmp = NULL;
  8802.  
  8803.     *lo = -1;                           /* Default bounds */
  8804.     *hi = -1;
  8805.  
  8806.     if (!s) s = "";                     /* Defense de null args */
  8807.     if (!*s)
  8808.       return(-1);
  8809.  
  8810.     x = xarray(s);                      /* Check basic structure */
  8811.     debug(F111,"arraybounds xarray",s,x);
  8812.     if (x < 0)                          /* Not OK, fail. */
  8813.       return(-1);
  8814.     y = boundspair(s,":",lo,hi,&zz);
  8815.     debug(F111,"arraybounds boundspair",s,y);
  8816.     debug(F101,"arraybounds lo","",*lo);
  8817.     debug(F101,"arraybounds hi","",*hi);
  8818.     if (y < 0)                /* Get bounds */
  8819.       return(-1);
  8820.     return(x);
  8821. }
  8822.  
  8823. /*  A R R A Y N A M  --  Parse an array name  */
  8824.  
  8825. /*
  8826.   Call with pointer to string that starts with the array reference.
  8827.   String may begin with either \& or just &.
  8828.   On success,
  8829.     Returns letter ID (always lowercase) in argument c,
  8830.       which can also be accent grave (` = 96; '@' is converted to grave);
  8831.     Dimension or subscript in argument n;
  8832.     IMPORTANT: These arguments must be provided by the caller as addresses
  8833.     of ints (not chars), for example:
  8834.       char *s; int x, y;
  8835.       arraynam(s,&x,&y);
  8836.   On failure, returns a negative number, with args n and c set to zero.
  8837. */
  8838. int
  8839. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8840.     int i, y, pp, len;
  8841.     char x;
  8842.     char *s, *p, *sx, *vnp;
  8843.     /* On stack to allow for recursive calls... */
  8844.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8845.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8846.     char sxbuf[16];                     /* Evaluated subscript */
  8847.  
  8848.     *c = *n = 0;                        /* Initialize return values */
  8849.     len = strlen(ss);
  8850.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8851.         if (ss[i] == '[') {
  8852.             pp++;
  8853.         } else if (ss[i] == ']') {
  8854.             if (--pp == 0)
  8855.               break;
  8856.         }
  8857.     }
  8858.     if (i > ARRAYREFLEN) {
  8859.         printf("?Array reference too long - %s\n",ss);
  8860.         return(-9);
  8861.     }
  8862.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8863.     vnp = vnbuf;
  8864.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8865.     if (*vnp != '&') {
  8866.         printf("?Not an array - %s\n",vnbuf);
  8867.         return(-9);
  8868.     }
  8869.     x = *(vnp + 1);                     /* Fold case of array name */
  8870.  
  8871.     /* We don't use isupper & tolower here on purpose because these */
  8872.     /* would produce undesired effects with accented letters. */
  8873.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8874.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8875.         if (msgflg) {
  8876.             printf("?Invalid format for array name - %s\n",vnbuf);
  8877.             return(-9);
  8878.         } else
  8879.           return(-2);
  8880.     }
  8881.     *c = x;                             /* Return the array name */
  8882.     s = vnp+3;                          /* Get dimension */
  8883.     p = ssbuf;
  8884.     pp = 1;                             /* Bracket counter */
  8885.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8886.         if (*s == '[') pp++;
  8887.         if (*s == ']' && --pp == 0) break;
  8888.         *p++ = *s++;
  8889.     }
  8890.     if (*s != ']') {
  8891.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8892.         return(-9);
  8893.     }
  8894.     p--;                                /* Trim whitespace from end */
  8895.     while (*p == SP || *p == HT)
  8896.       p--;
  8897.     p++;
  8898.     *p = NUL;                           /* Terminate subscript with null */
  8899.     p = ssbuf;                          /* Point to beginning of subscript */
  8900.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8901.       p++;
  8902.     sx = sxbuf;                         /* Where to put expanded subscript */
  8903.     y = 16;
  8904.     {
  8905.     /* Even if VARIABLE-EVALUATION SIMPLE use RECURSIVE for subscripts */
  8906.     /* NOTE: This is vulnerable to SIGINT and whatnot... */
  8907.     int tmp = vareval;        /* Save VARIABLE-EVALUATION setting */
  8908.     vareval = 1;            /* Force it to RECURSIVE */
  8909.     zzstring(p,&sx,&y);        /* Convert variables, etc. */
  8910.     vareval = tmp;            /* Restore VARIABLE-EVALUATION */
  8911.     }
  8912.     sx = sxbuf;
  8913.     while (*sx == SP) sx++;
  8914.     /* debug(F110,"arraynam sx","",sx); */
  8915.     if (!*sx) {                         /* Empty brackets... */
  8916.         *n = -17;                       /* (Secret code :-) */
  8917.         return(-2);
  8918.     }
  8919.     p = evala(sx);                      /* Run it thru \fneval()... */
  8920.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8921.  
  8922.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8923.         if (msgflg) {
  8924.             printf("?Array dimension or subscript missing or not numeric\n");
  8925.             return(-9);
  8926.         } else
  8927.           return(-2);
  8928.     }
  8929.     if ((y = atoi(sxbuf)) < 0) {
  8930.         if (cmflgs == 0) printf("\n");
  8931.         if (msgflg) {
  8932.             printf("?Array dimension or subscript not positive or zero\n");
  8933.             return(-9);
  8934.         } else
  8935.           return(-2);
  8936.     }
  8937.     *n = y;                             /* Return the subscript or dimension */
  8938.     return(0);
  8939. }
  8940.  
  8941. /* chkarray returns 0 or greater if array exists, negative otherwise */
  8942.  
  8943. int
  8944. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8945.     int x;                              /* and if subscript is in range */
  8946.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8947.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8948. #ifdef COMMENT
  8949.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8950.       return(0);
  8951. #endif /* COMMENT */
  8952.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8953.       return(-2);
  8954.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8955.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8956.     return(a_dim[x]);                   /* All ok, return dimension */
  8957. }
  8958.  
  8959. #ifdef COMMENT                          /* This isn't used. */
  8960. char *
  8961. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8962.     int x; char **p;                    /* (possibly NULL) */
  8963.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8964.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8965.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8966.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8967.       return(NULL);
  8968.     if (i > a_dim[x])                   /* Subscript out of range. */
  8969.       return(NULL);
  8970.     return(p[i]);                       /* All ok, return pointer to value. */
  8971. }
  8972. #endif /* COMMENT */
  8973.  
  8974. /*
  8975.   pusharray() is called when an array name is included in a LOCAL statement.
  8976.   It moves the pointers from the global definition to the stack, and removes
  8977.   the global definition.  Later, if the same array is declared in the local
  8978.   context, it occupies the global definition in the normal way.  But when
  8979.   popclvl() is called, it replaces the global definition with the one saved
  8980.   here.  The "secret code" is used to indicate to popclv() that it should
  8981.   remove the global array when popping through this level -- otherwise if a
  8982.   local array were declared that had no counterpart at any higher level, it
  8983.   would never be deleted.  This allows Algol-like inheritance to work both
  8984.   on the way down and on the way back up.
  8985. */
  8986. int
  8987. pusharray(x,z) int x, z; {
  8988.     int y;
  8989.     debug(F000,"pusharray x","",x);
  8990.     debug(F101,"pusharray z","",z);
  8991.     y = chkarray(x,z);
  8992.     debug(F101,"pusharray y","",y);
  8993.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8994.     if (x < 0 || x > 27)
  8995.       return(-1);
  8996.     if (y < 0) {
  8997.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8998.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8999.     } else {
  9000.         aa_ptr[cmdlvl][x] = a_ptr[x];
  9001.         aa_dim[cmdlvl][x] = y;
  9002.     }
  9003.     a_ptr[x] = (char **) NULL;
  9004.     a_dim[x] = 0;
  9005.     return(0);
  9006. }
  9007.  
  9008. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  9009. /*
  9010.  Call with:
  9011.    s  = pointer to candidate variable name or array reference.
  9012.    *c = address of integer in which to return variable ID.
  9013.    *i = address of integer in which to return array subscript.
  9014.  Returns:
  9015.    -2:  syntax error in variable name or array reference.
  9016.     1:  successful parse of a simple variable, with ID in c.
  9017.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  9018. */
  9019. int
  9020. parsevar(s,c,i) char *s; int *c, *i; {
  9021.     char *p;
  9022.     int x,y,z;
  9023.  
  9024.     p = s;
  9025.     if (*s == CMDQ) s++;                /* Point after backslash */
  9026.  
  9027.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  9028.         printf("?Not a variable name - %s\n",p);
  9029.         return(-9);
  9030.     }
  9031.     if ((int)strlen(s) < 2) {
  9032.         printf("?Incomplete variable name - %s\n",p);
  9033.         return(-9);
  9034.     }
  9035.     if (*s == '%' && *(s+2) != '\0') {
  9036.         printf("?Only one character after '%%' in variable name, please\n");
  9037.         return(-9);
  9038.     }
  9039.     if (*s == '&' && *(s+2) != '[') {
  9040.         printf("?Array subscript expected - %s\n",p);
  9041.         return(-9);
  9042.     }
  9043.     if (*s == '%') {                    /* Simple variable. */
  9044.         y = *(s+1);                     /* Get variable ID letter/char */
  9045.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  9046.         *c = y;                         /* Set the return values. */
  9047.         *i = -1;                        /* No array subscript. */
  9048.         return(1);                      /* Return 1 = simple variable */
  9049.     }
  9050.     if (*s == '&') {                    /* Array reference. */
  9051.         y = arraynam(s,&x,&z);          /* Go parse it. */
  9052.         debug(F101,"parsevar arraynam","",y);
  9053.         if ((y) < 0) {
  9054.             if (y == -2)
  9055.               return(pusharray(x,z));
  9056.             if (y != -9)
  9057.               printf("?Invalid array reference - %s\n",p);
  9058.             return(-9);
  9059.         }
  9060.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  9061.             printf("?Array not declared or subscript out of range\n");
  9062.             return(-9);
  9063.         }
  9064.         *c = x;                         /* Return array letter */
  9065.         *i = z;                         /* and subscript. */
  9066.         return(2);
  9067.     }
  9068.     return(-2);                         /* None of the above. */
  9069. }
  9070.  
  9071.  
  9072. #define VALN 32
  9073.  
  9074. /* Get the numeric value of a variable */
  9075. /*
  9076.   Call with pointer to variable name, pointer to int for return value.
  9077.   Returns:
  9078.     0 on success with second arg containing the value.
  9079.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  9080. */
  9081. int
  9082. varval(s,v) char *s; CK_OFF_T *v; {
  9083.     char valbuf[VALN+1];                /* s is pointer to variable name */
  9084.     char name[256];
  9085.     char *p;
  9086.     int y;
  9087.  
  9088.     if (*s != CMDQ) {                   /* Handle macro names too */
  9089.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  9090.         s = name;
  9091.     }
  9092.     p = valbuf;                         /* Expand variable into valbuf. */
  9093.     y = VALN;
  9094.     if (zzstring(s,&p,&y) < 0) return(-1);
  9095.     p = valbuf;                         /* Make sure value is numeric  */
  9096.     if (!*p) {                          /* Be nice -- let an undefined */
  9097.         valbuf[0] = '0';                /* variable be treated as 0.   */
  9098.         valbuf[1] = NUL;
  9099.     }
  9100.     if (chknum(p)) {                    /* Convert numeric string to int */
  9101.         *v = ckatofs(p);        /* OK */
  9102.     } else {                            /* Not OK */
  9103.         p = evala(p);                   /* Maybe it's an expression */
  9104.         if (!chknum(p))                 /* Did it evaluate? */
  9105.           return(-1);                   /* No, failure. */
  9106.         else                            /* Yes, */
  9107.           *v = ckatofs(p);        /* success */
  9108.     }
  9109.     return(0);
  9110. }
  9111.  
  9112. /* Increment or decrement a variable */
  9113. /* Returns -1 on failure, 0 on success */
  9114.  
  9115. int
  9116. incvar(s,x,z) char *s; CK_OFF_T x; int z; {  /* Increment a numeric variable */
  9117.     CK_OFF_T n;                /* s is pointer to variable name */
  9118.                                         /* x is amount to increment by */
  9119.                                         /* z != 0 means add */
  9120.                                         /* z = 0 means subtract */
  9121.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  9122.       return(-1);
  9123.     if (z)                              /* Increment it by the given amount */
  9124.       n += x;
  9125.     else                                /* or decrement as requested. */
  9126.       n -= x;
  9127.     addmac(s,ckfstoa(n));        /* Replace old variable */
  9128.     return(0);
  9129. }
  9130.  
  9131. /* D O D O  --  Do a macro */
  9132.  
  9133. /*
  9134.   Call with x = macro table index, s = pointer to arguments.
  9135.   Returns 0 on failure, 1 on success.
  9136. */
  9137.  
  9138. int
  9139. dodo(x,s,flags) int x; char *s; int flags; {
  9140.     int y;
  9141.     extern int tra_asg, tra_cmd; int tra_tmp;
  9142. #ifndef NOLOCAL
  9143. #ifdef OS2
  9144.     extern int term_io;
  9145.     int term_io_sav = term_io;
  9146. #endif /* OS2 */
  9147. #endif /* NOLOCAL */
  9148.  
  9149.     if (x < 0)                          /* It can happen! */
  9150.       return(-1);
  9151.  
  9152.     tra_tmp = tra_asg;
  9153.  
  9154.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  9155.         debug(F101,"dodo maclvl too deep","",maclvl);
  9156.         --maclvl;
  9157.         printf("Macros nested too deeply\n");
  9158.         return(0);
  9159.     }
  9160.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  9161.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  9162.  
  9163. #ifdef COMMENT
  9164.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  9165. #endif /* COMMENT */
  9166.  
  9167.     cmdlvl++;                           /* Entering a new command level */
  9168.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  9169.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  9170.         cmdlvl--;
  9171.         printf("?TAKE files and DO commands nested too deeply\n");
  9172.         return(0);
  9173.     }
  9174. #ifdef DEBUG
  9175.     if (deblog) {
  9176.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  9177.         debug(F010,"CMD ->",s,0);
  9178.     }
  9179. #endif /* DEBUG */
  9180.  
  9181. #ifdef VMS
  9182.     conres();                           /* So Ctrl-C, etc, will work. */
  9183. #endif /* VMS */
  9184. #ifndef NOLOCAL
  9185. #ifdef OS2
  9186.     term_io = 0;                        /* Disable terminal emulator I/O */
  9187. #endif /* OS2 */
  9188. #endif /* NOLOCAL */
  9189.     ifcmd[cmdlvl] = 0;
  9190.     iftest[cmdlvl] = 0;
  9191.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  9192.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  9193.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  9194.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  9195.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  9196.     xquiet[cmdlvl] = quiet;
  9197.     xvarev[cmdlvl] = vareval;
  9198.     xcmdsrc = CMD_MD;
  9199.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  9200.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  9201.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  9202.  
  9203.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  9204.  
  9205.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  9206.         free(mrval[maclvl]);
  9207.         mrval[maclvl] = NULL;
  9208.     }
  9209.  
  9210.     /* Clear old %0..%9 arguments */
  9211.  
  9212.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  9213.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  9214.     varnam[0] = '%';
  9215.     varnam[2] = '\0';
  9216.     tra_asg = 0;
  9217.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  9218.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  9219.             varnam[1] = (char) (y + '0'); /* we have to... */
  9220.             delmac(varnam,0);
  9221.         }
  9222.     }
  9223.     tra_asg = tra_tmp;
  9224.  
  9225. /* Assign the new args one word per arg, allowing braces to group words */
  9226.  
  9227.     xwords(s,MAXARGLIST,NULL,0);
  9228.  
  9229. #ifndef NOLOCAL
  9230. #ifdef OS2
  9231.     term_io = term_io_sav;
  9232. #endif /* OS2 */
  9233. #endif /* NOLOCAL */
  9234.     if (tra_cmd)
  9235.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  9236.     return(1);
  9237. }
  9238.  
  9239. /* Insert "literal" quote around each comma-separated command to prevent */
  9240. /* its premature expansion.  Only do this if object command is surrounded */
  9241. /* by braces. */
  9242.  
  9243. static char* flit = "\\flit(";
  9244.  
  9245. int
  9246. litcmd(src,dest,n) char **src, **dest; int n; {
  9247.     int bc = 0, pp = 0;
  9248.     char c, *s, *lp, *ss;
  9249.  
  9250.     s = *src;
  9251.     lp = *dest;
  9252.  
  9253.     debug(F010,"litcmd",s,0);
  9254.  
  9255.     while (*s == SP) s++;               /* Strip extra leading spaces */
  9256.  
  9257.     if (*s == '{') {                    /* Starts with brace */
  9258.         pp = 0;                         /* Paren counter */
  9259.         bc = 1;                         /* Count leading brace */
  9260.         *lp++ = *s++;                   /* Copy it */
  9261.         if (--n < 1) return(-1);        /* Check space */
  9262.         while (*s == SP) s++;           /* Strip interior leading spaces */
  9263.         ss = flit;                      /* Point to "\flit(" */
  9264.         while ((*lp++ = *ss++))         /* Copy it */
  9265.           if (--n < 1)                  /* and check space */
  9266.             return(-1);
  9267.         lp--;                           /* Back up over null */
  9268.  
  9269.         while (*s) {                    /* Go thru rest of text */
  9270.             c = *s;
  9271.             if (c == '{') bc++;         /* Count brackets */
  9272.             if (c == '(') pp++;         /* and parens */
  9273.             if (c == ')') {             /* Right parenthesis. */
  9274.                 pp--;                   /* Count it. */
  9275.                 if (pp < 0) {           /* An unbalanced right paren... */
  9276. #ifdef COMMENT
  9277. /*
  9278.   The problem here is that "\{" appears to be a quoted brace and therefore
  9279.   isn't counted; then the "}" matches an earlier opening brace, causing
  9280.   (e.g.) truncation of macros by getncm().
  9281. */
  9282.                     if (n < 5)          /* Out of space in dest buffer? */
  9283.                       return(-1);       /* If so, give up. */
  9284.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9285.                     *lp++ = '}';        /* premature termination of */
  9286.                     *lp++ = '4';        /* \flit(...) */
  9287.                     *lp++ = '1';
  9288.                     *lp++ = '}';
  9289.                     n -= 5;
  9290. #else
  9291. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  9292.                     if (n < 4)          /* Out of space in dest buffer? */
  9293.                       return(-1);       /* If so, give up. */
  9294.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9295.                     *lp++ = '0';        /* premature termination of */
  9296.                     *lp++ = '4';        /* \flit(...) */
  9297.                     *lp++ = '1';
  9298.                     n -= 4;
  9299. #endif /* COMMENT */
  9300.                     pp++;               /* Uncount it. */
  9301.                     s++;
  9302.                     continue;
  9303.                 }
  9304.             }
  9305.             if (c == '}') {             /* Closing brace. */
  9306.                 if (--bc == 0) {        /* Final one? */
  9307.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  9308.                     if (--n < 1) return(-1);
  9309.                     *lp++ = c;
  9310.                     if (--n < 1) return(-1);
  9311.                     s++;
  9312.                     break;
  9313.                 }
  9314.             }
  9315.             *lp++ = c;                  /* General case */
  9316.             if (--n < 1) return(-1);
  9317.             s++;
  9318.         }
  9319.         *lp = NUL;
  9320.     } else {                            /* No brackets around, */
  9321.         while ((*lp++ = *s++))          /* just copy. */
  9322.           if (--n < 1)
  9323.             return(-1);
  9324.         lp--;
  9325.     }
  9326.     *src = s;                           /* Return updated source */
  9327.     *dest = lp;                         /* and destination pointers */
  9328.     if (bc)                             /* Fail if braces unbalanced */
  9329.       return(-1);
  9330.     else                                /* Otherwise succeed. */
  9331.       return(0);
  9332. }
  9333. #endif /* NOSPL */
  9334.  
  9335. /* Functions moved here from ckuusr.c to even out the module sizes... */
  9336.  
  9337. /*
  9338.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  9339.   Pointers to each word go into the array list[].
  9340.   max is the maximum number of words (pointers).
  9341.   If list is NULL, then they are added to the macro table.
  9342.   flag = 0 means the last field is to be one word, like all the other fields,
  9343.          so anything after it is discarded.
  9344.   flag = 1 means the last field extends to the end of the string, even if
  9345.          there are lots of words left, so the last field contains the
  9346.          remainder of the string.
  9347. */
  9348. VOID
  9349. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  9350.     char *p;
  9351.     int b, i, k, q, y, z;
  9352. #ifndef NOSPL
  9353.     int macro;
  9354.     macro = (list == NULL);
  9355.     debug(F010,"xwords",s,0);
  9356. #endif /* NOSPL */
  9357.  
  9358. #ifdef XWORDSDEBUG
  9359.     printf("XWORDS string=%s\n",s);
  9360.     printf("XWORDS max=%d\n",max);
  9361. #endif /* XWORDSDEBUG */
  9362.     p = s;                              /* Pointer to beginning of string */
  9363.     q = 0;                              /* Flag for doublequote removal */
  9364.     b = 0;                              /* Flag for outer brace removal */
  9365.     k = 0;                              /* Flag for in-word */
  9366.     y = 0;                              /* Brace nesting level */
  9367.     z = 0;                              /* "Word" counter, 0 thru max */
  9368.  
  9369.     if (list)
  9370.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  9371.         list[i] = NULL;
  9372.  
  9373.     if (flag) max--;
  9374.  
  9375.     while (1) {                         /* Go thru word list */
  9376.         if (!s || (*s == '\0')) {       /* No more characters? */
  9377.             if (k != 0) {               /* Was I in a word? */
  9378.                 if (z == max) break;    /* Yes, only go up to max. */
  9379.                 z++;                    /* Count this word. */
  9380. #ifdef XWORDSDEBUG
  9381.                 printf("1 z++ = %d\n", z);
  9382. #endif /* XWORDSDEBUG */
  9383. #ifndef NOSPL
  9384.                 if (macro) {            /* Doing macro args */
  9385.                     if (z < 10) {
  9386.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  9387.                         addmac(varnam,p);
  9388.                     }
  9389.                     if (z <= max) {
  9390. #ifdef COMMENT
  9391.                         if (maclvl < 0)
  9392.                           addmac(varnam,p);
  9393.                         else
  9394. #endif /* COMMENT */
  9395.                           makestr(&(m_xarg[maclvl][z]),p);
  9396.                     }
  9397.                 } else {                /* Not doing macro args */
  9398. #endif /* NOSPL */
  9399.                     list[z] = p;        /* Assign pointer. */
  9400. #ifdef XWORDSDEBUG
  9401.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  9402. #endif /* XWORDSDEBUG */
  9403. #ifndef NOSPL
  9404.                 }
  9405. #endif /* NOSPL */
  9406.                 break;                  /* And get out. */
  9407.             } else break;               /* Was not in a word */
  9408.         }
  9409.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  9410.             s++;
  9411.             continue;
  9412.         } else if (q == 0 && *s == '{') { /* An opening brace */
  9413.             if (k == 0 && y == 0) {     /* If leading brace */
  9414.                 p = s+1;                /* point past it */
  9415.                 b = 1;                  /* and flag that we did this */
  9416.             }
  9417.             k = 1;                      /* Flag that we're in a word */
  9418.             y++;                        /* Count the brace. */
  9419.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  9420.             y--;                        /* Count it. */
  9421.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  9422.                 char c;
  9423.                 c = *(s+1);
  9424.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9425.                     *s = SP;            /* change it to a space */
  9426.                     b = 0;              /* and we're not in braces any more */
  9427.                 }
  9428.             }
  9429. #ifdef DOUBLEQUOTING
  9430.         /* Opening doublequote */
  9431.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9432.             y++;
  9433.             p = s+1;                    /* point past it */
  9434.             q = 1;                      /* and flag that we did this */
  9435.             k = 1;                      /* Flag that we're in a word */
  9436.         /* Closing double quote */
  9437.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9438.             char c;
  9439.             c = *(s+1);
  9440.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9441.                 y--;
  9442.                 *s = SP;                /* change it to a space */
  9443.                 q = 0;                  /* and we're not in quotes any more */
  9444.             }
  9445. #endif /* DOUBLEQUOTING */
  9446.  
  9447.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9448.             if (k == 0) {               /* If we weren't in a word before, */
  9449.                 p = s;                  /* Mark the beginning */
  9450.                 if (flag && z == max) { /* Want last word to be remainder? */
  9451.                     z++;
  9452. #ifdef XWORDSDEBUG
  9453.                     printf("1 z++ = %d\n", z);
  9454. #endif /* XWORDSDEBUG */
  9455.                     list[z] = p;        /* Yes, point to it */
  9456. #ifdef XWORDSDEBUG
  9457.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9458. #endif /* XWORDSDEBUG */
  9459.                     break;              /* and quit */
  9460.                 }
  9461.                 k = 1;                  /* Set in-word flag */
  9462.             }
  9463.         }
  9464.         /* If we're not inside a braced quantity, and we are in a word, and */
  9465.         /* we have hit whitespace, then we have a word. */
  9466.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9467.             if (!flag || z < max)       /* if we don't want to keep rest */
  9468.               *s = '\0';                /* terminate the arg with null */
  9469.             k = 0;                      /* say we're not in a word any more */
  9470.             y = 0;                      /* start braces off clean again */
  9471.             if (z == max) break;        /* Only go up to max. */
  9472.             z++;                        /* count this arg */
  9473. #ifdef XWORDSDEBUG
  9474.             printf("1 z++ = %d\n", z);
  9475. #endif /* XWORDSDEBUG */
  9476.  
  9477. #ifndef NOSPL
  9478.             if (macro) {
  9479.                 if (z < 10) {
  9480.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9481.                     addmac(varnam,p);   /* add it to the macro table */
  9482.                 }
  9483.                 if (z <= max) {
  9484. #ifdef COMMENT
  9485.                     if (maclvl < 0)
  9486.                       addmac(varnam,p);
  9487.                     else
  9488. #endif /* COMMENT */
  9489.                       makestr(&(m_xarg[maclvl][z]),p);
  9490.                 }
  9491.             } else {
  9492. #endif /* NOSPL */
  9493.                 list[z] = p;
  9494. #ifdef XWORDSDEBUG
  9495.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9496. #endif /* XWORDSDEBUG */
  9497. #ifndef NOSPL
  9498.             }
  9499. #endif /* NOSPL */
  9500.             p = s+1;
  9501.         }
  9502.         s++;                            /* Point past this character */
  9503.     }
  9504.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9505.         z++;
  9506. #ifndef NOSPL
  9507.         if (macro) {
  9508.             if (z < 10) {
  9509.                 varnam[1] = z + '0';    /* compute its name */
  9510.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9511.             }
  9512.             if (z <= max) {
  9513. #ifdef COMMENT
  9514.                 if (maclvl < 0)
  9515.                   addmac(varnam,p);
  9516.                 else
  9517. #endif /* COMMENT */
  9518.                   makestr(&(m_xarg[maclvl][z]),p);
  9519.             }
  9520.         } else {
  9521. #endif /* NOSPL */
  9522.             list[z] = p;
  9523. #ifdef XWORDSDEBUG
  9524.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9525. #endif /* XWORDSDEBUG */
  9526. #ifndef NOSPL
  9527.         }
  9528. #endif /* NOSPL */
  9529.     }
  9530. #ifndef NOSPL
  9531.     if (macro) {                        /* Macro */
  9532.         if (maclvl < 0) {
  9533.             a_dim[0] = z;               /* Array dimension is one less */
  9534.             topargc = z + 1;            /* than \v(argc) */
  9535.         debug(F111,"a_dim[0]","D",a_dim[0]);
  9536.         } else {
  9537.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9538.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9539.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9540.             a_dim[0] = z;               /* And give it this dimension */
  9541.         debug(F111,"a_dim[0]","E",a_dim[0]);
  9542.         }
  9543.     }
  9544. #endif /* NOSPL */
  9545.     return;
  9546. }
  9547.  
  9548. #ifndef NOSPL
  9549.  
  9550. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9551.  
  9552. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9553.  
  9554. int
  9555. doshift(n) int n; {                     /* n = shift count */
  9556.     int i, top, level;
  9557.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9558.     char * sx = tmpbuf;
  9559.     int nx = TMPBUFSIZ;
  9560.  
  9561.     debug(F101,"SHIFT count","",n);
  9562.     debug(F101,"SHIFT topargc","",topargc);
  9563.  
  9564.     if (n < 1)                          /* Stay in range */
  9565.       return(n == 0 ? 1 : 0);
  9566.  
  9567.     level = maclvl;
  9568.     top = (level < 0) ? topargc : macargc[level];
  9569.  
  9570.     if (n >= top)
  9571.       n = top - 1;
  9572.  
  9573. #ifdef DEBUG
  9574.     if (deblog) {
  9575.         debug(F101,"SHIFT count 2","",n);
  9576.         debug(F101,"SHIFT level","",level);
  9577.         if (level > -1)
  9578.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9579.     }
  9580. #endif /* DEBUG */
  9581.  
  9582.     buf[0] = '\\';                      /* Initialize name template */
  9583.     buf[1] = '%';
  9584.     buf[2] = NUL;
  9585.     buf[3] = NUL;
  9586.  
  9587.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9588.         if (level < 0) {
  9589.             makestr(&(toparg[i]),NULL);
  9590.         } else {
  9591.             makestr(&(m_xarg[level][i]),NULL);
  9592.         }
  9593.         if (i < 10) {                   /* Is this necessary? */
  9594.             buf[2] = (char)(i+'0');
  9595.             delmac(buf,0);
  9596.         }
  9597.     }
  9598.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9599.         if (level < 0) {
  9600. #ifdef COMMENT
  9601.             toparg[i] = toparg[i+n];    /* Full vector */
  9602. #else
  9603.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9604. #endif /* COMMENT */
  9605.             if (i < 10)                 /* Scalars... */
  9606.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9607.         } else {
  9608. #ifdef COMMENT
  9609.             m_xarg[level][i] = m_xarg[level][i+n];
  9610. #else
  9611.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9612. #endif /* COMMENT */
  9613.             if (i < 10) {
  9614.                 buf[2] = (char)(i+'0');
  9615.                 debug(F010,"SHIFT buf",buf,0);
  9616.                 addmac(buf,m_xarg[level][i+n]);
  9617.             }
  9618.         }
  9619.     }
  9620.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9621.         if (level < 0) {
  9622. #ifdef COMMENT
  9623.             toparg[i] = NULL;
  9624. #else
  9625.             makestr(&(toparg[i]),NULL);
  9626. #endif /* COMMENt */
  9627.             if (i < 10)
  9628.               makestr(&(g_var[i+'0']),NULL);
  9629.         } else {
  9630. #ifdef COMMENT
  9631.             m_xarg[level][i] = NULL;
  9632. #else
  9633.             makestr(&(m_xarg[level][i]),NULL);
  9634. #endif /* COMMENt */
  9635.             if (i < 10) {
  9636.                 buf[2] = (char)(i+'0');
  9637.                 delmac(buf,0);
  9638.             }
  9639.         }
  9640.     }
  9641.     if (level > -1) {                   /* Macro args */
  9642.         macargc[level] -= n;            /* Adjust count */
  9643.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9644.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9645.     debug(F111,"a_dim[0]","F",a_dim[0]);
  9646.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9647. #ifdef COMMENT
  9648.         makestr(&(m_line[level]),tmpbuf);
  9649. #endif /* COMMENT */
  9650.     } else {                            /* Ditto for top level */
  9651.         topargc -= n;
  9652.         a_dim[0] = topargc - 1;
  9653.     debug(F111,"a_dim[0]","G",a_dim[0]);
  9654.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9655. #ifdef COMMENT
  9656.         makestr(&topline,tmpbuf);
  9657. #endif /* COMMENT */
  9658.     }
  9659.     return(1);
  9660. }
  9661. #endif /* NOSPL */
  9662.  
  9663. int
  9664. docd(cx) int cx; {                      /* Do the CD command */
  9665.     int x;
  9666.     extern int server, srvcdmsg, cdactive;
  9667.     extern char * cdmsgfile[], * ckcdpath;
  9668.     char *s, *p;
  9669. #ifdef MAC
  9670.     char temp[34];
  9671. #endif /* MAC */
  9672. #ifdef IKSDCONF
  9673. extern int iksdcf;
  9674. #endif /* IKSDCONF */
  9675.  
  9676. #ifndef NOFRILLS
  9677.     if (cx == XXBACK) {
  9678.         if ((x = cmcfm()) < 0)
  9679.         cwdf = 1;
  9680.         if (prevdir) {
  9681.             s = zgtdir();
  9682.             if (!zchdir(prevdir)) {
  9683.                 cwdf = 0;
  9684.                 perror(s);
  9685.             } else {
  9686.                 makestr(&prevdir,s);
  9687.             }
  9688.         }
  9689.         return(cwdf);
  9690.     }
  9691. #endif /* NOFRILLS */
  9692.  
  9693.     if (cx == XXCDUP) {
  9694. #ifdef VMS
  9695.         s = "[-]";
  9696. #else
  9697. #ifdef datageneral
  9698.         s = "^";
  9699. #else
  9700.         s = "..";
  9701. #endif /* datageneral */
  9702. #endif /* VMS */
  9703.         ckstrncpy(line,s,LINBUFSIZ);
  9704.         goto gocd;
  9705.     }
  9706. #ifndef NOSPL
  9707.     if (cx == XXKCD) {            /* Symbolic (Kermit) CD */
  9708.     char * p;
  9709.     int n, k;
  9710.     x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9711.     if (x < 0)
  9712.       return(x);
  9713.     x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9714.     if (x < 0) {
  9715.         printf("?Lookup error\n");    /* shouldn't happen */
  9716.         return(-9);
  9717.     }
  9718.         if ((x = cmcfm()) < 0)
  9719.       return(x);
  9720.     if (k == VN_HOME) {        /* HOME: allow SET HOME to override */
  9721.         ckstrncpy(line,homepath(),LINBUFSIZ);
  9722.     } else {            /* Other symbolic name */
  9723.         /* Convert to variable syntax */
  9724.         ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9725.         p = line;            /* Expand the variable */
  9726.         n = LINBUFSIZ;
  9727.         zzstring(tmpbuf,&p,&n);
  9728.         if (!line[0]) {        /* Fail if variable not defined */
  9729.         printf("?%s - not defined\n",tmpbuf);
  9730.         return(success = 0);
  9731.         }
  9732.     }
  9733.     s = line;            /* All OK, go try to CD... */
  9734.     goto gocd;
  9735.     }
  9736. #endif /* NOSPL */
  9737.  
  9738.     cdactive = 1;
  9739. #ifdef GEMDOS
  9740.     if ((x = cmdir("Name of local directory, or carriage return",
  9741.                    homepath(),
  9742.                    &s,
  9743.                    NULL
  9744.                    )
  9745.          ) < 0 )
  9746.       return(x);
  9747. #else
  9748. #ifdef OS2
  9749.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9750.        or press the Enter key for the default",
  9751.                     homepath(),
  9752.                     &s,
  9753.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9754.                     xxstring
  9755.                     )
  9756.          ) < 0 )
  9757.       return(x);
  9758. #else
  9759. #ifdef MAC
  9760.     x = ckstrncpy(temp,homepath(),32);
  9761.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9762.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9763.  or press the Return key for the desktop on the boot disk",
  9764.                    temp,&s, xxstring)) < 0 )
  9765.       return(x);
  9766. #else
  9767.     if ((x = cmdirp("Carriage return for home directory,\n\
  9768. or name of directory on this computer",
  9769. #ifdef VMS
  9770.                     "SYS$LOGIN",        /* With no colon */
  9771. #else
  9772.                     homepath(),        /* In VMS this is "SYS$LOGIN:" */
  9773. #endif /* VMS */
  9774.                     &s,
  9775.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9776.                     xxstring
  9777.                     )) < 0)
  9778.       return(x);
  9779. #endif /* MAC */
  9780. #endif /* OS2 */
  9781. #endif /* GEMDOS */
  9782.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9783.     s = line;
  9784. #ifdef VMS
  9785.     if (ckmatch("*.DIR;1$",s,0,0))
  9786.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9787.         s = tmpbuf;
  9788. #endif /* VMS */
  9789.     debug(F110,"docd",s,0);
  9790. #ifndef MAC
  9791.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9792.       return(x);
  9793. #endif /* MAC */
  9794.  
  9795.   gocd:
  9796.  
  9797. #ifdef datageneral
  9798.     x = strlen(line);                   /* homdir ends in colon, */
  9799.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9800.       line[x-1] = NUL;
  9801. #endif /* datageneral */
  9802.  
  9803. #ifdef MAC
  9804.     cwdf = 1;
  9805.     if (!zchdir(s)) {
  9806.         cwdf = 0;
  9807.         if (*s != ':') {                /* If it failed, */
  9808.             char *p;                    /* supply leading colon */
  9809.             int len = (int)strlen(s) + 2;
  9810.             p = malloc(len);            /* and try again... */
  9811.             if (p) {
  9812.                 strcpy(p,":");          /* safe */
  9813.                 strcat(p,s);            /* safe */
  9814.                 if (zchdir(p))
  9815.                   cwdf = 1;
  9816.                 free(p);
  9817.                 p = NULL;
  9818.             }
  9819.         }
  9820.     }
  9821.     if (!cwdf)
  9822.       perror(s);
  9823. #else
  9824.     p = zgtdir();
  9825.     if (!zchdir(s)) {
  9826.         cwdf = 0;
  9827. #ifdef CKROOT
  9828.         if (ckrooterr)
  9829.           printf("?Off limits: \"%s\"\n",s);
  9830.         else
  9831. #endif /* CKROOT */
  9832.           perror(s);
  9833.     } else cwdf = 1;
  9834. #endif /* MAC */
  9835.  
  9836.     x = 0;
  9837.     if (cwdf) {
  9838.         makestr(&prevdir,p);
  9839.         debug(F111,"docd","srvcdmsg",srvcdmsg);
  9840.         if (srvcdmsg
  9841. #ifdef IKSDCONF
  9842.             && !(inserver && !iksdcf)
  9843. #endif /* IKSDCONF */
  9844.             ) {
  9845.             int i;
  9846.             for (i = 0; i < 8; i++) {
  9847.                 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9848.                 if (zchki(cdmsgfile[i]) > -1) {
  9849.                     x = 1;
  9850.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9851.                     break;
  9852.                 }
  9853.             }
  9854.         }
  9855.     }
  9856. /* xdocd: */
  9857.     if (!x && srvcdmsg && !server
  9858. #ifdef IKSDCONF
  9859.         && !(inserver && !iksdcf)
  9860. #endif /* IKSDCONF */
  9861.         && !quiet && !xcmdsrc)
  9862.       printf("%s\n", zgtdir());
  9863.  
  9864.     return(cwdf);
  9865. }
  9866.  
  9867. static int on_ctrlc = 0;
  9868.  
  9869. VOID
  9870. fixcmd() {                      /* Fix command parser after interruption */
  9871. #ifndef NOSPL
  9872. #ifndef NOONCTRLC
  9873.     if (nmac) {                         /* Any macros defined? */
  9874.         int k;                          /* Yes */
  9875.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9876.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9877.         if (k >= 0) {                   /* If found, */
  9878.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9879.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9880.                   parser(1);            /* execute it, */
  9881.             }
  9882.             delmac(s,1);                /* and undefine it. */
  9883.         }
  9884.     }
  9885.     on_ctrlc = 0;
  9886. #endif /* NOONCTRLC */
  9887. #endif /* NOSPL */
  9888.     dostop();                   /* Back to top level (also calls conint()). */
  9889.     bgchk();                    /* Check background status */
  9890.     if (*psave) {               /* If old prompt saved, */
  9891.         cmsetp(psave);          /* restore it. */
  9892.         *psave = NUL;
  9893.     }
  9894.     success = 0;                /* Tell parser last command failed */
  9895. }
  9896.  
  9897. #ifndef NOSHOW                          /* SHOW FEATURES */
  9898. /*
  9899.   Note, presently optlist[] index overflow is not checked.
  9900.   There is plenty of room (less than 360 entries for 1000 slots).
  9901.   When space starts to get tight, check for noptlist >= NOPTLIST
  9902.   every time noptlist is incremented.
  9903. */
  9904. #define NOPTLIST 1024
  9905. static int noptlist = 0;
  9906. static char * optlist[NOPTLIST+1];
  9907. static int hpos = 0;
  9908.  
  9909. int
  9910. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9911.     int y, i;                           /* Does word wrap. */
  9912.     if (!s) s = "";
  9913.     i = *lines;
  9914.     if (!*s) {                          /* Empty argument */
  9915.         if (hpos > 0) {                 /* means to end this line. */
  9916.             printf("\n");               /* Not needed if already at */
  9917.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9918.                 if (!askmore())
  9919.                   return(0);
  9920.                 else
  9921.                   i = 0;
  9922.             }
  9923.         }
  9924.         printf("\n");                   /* And then make a blank line */
  9925.         if (++i > (cmd_rows - 3)) {
  9926.             if (!askmore())
  9927.               return(0);
  9928.             else
  9929.               i = 0;
  9930.         }
  9931.         hpos = 0;
  9932.         *lines = i;
  9933.         return(1);
  9934.     }
  9935.     y = (int)strlen(s) + 1;
  9936.     hpos += y;
  9937.     debug(F101,"prtopt hpos","",hpos);
  9938.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9939.  
  9940.     if (
  9941. #ifdef OS2
  9942.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9943. #else /* OS2 */
  9944.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9945. #endif /* OS2 */
  9946.         ) {
  9947.         printf("\n");
  9948.         if (++i > (cmd_rows - 3)) {
  9949.             if (!askmore())
  9950.               return(0);
  9951.             else
  9952.               i = 0;
  9953.         }
  9954.         printf(" %s",s);
  9955.         hpos = y;
  9956.     } else
  9957.       printf(" %s",s);
  9958.     *lines = i;
  9959.     return(1);
  9960. }
  9961.  
  9962. static VOID
  9963. initoptlist() {
  9964.     int i;
  9965.     if (noptlist > 0)
  9966.       return;
  9967.     for (i = 0; i < NOPTLIST; i++)
  9968.       optlist[i] = NULL;
  9969.  
  9970. #ifdef MAC
  9971. #ifdef MPW
  9972.     makestr(&(optlist[noptlist++]),"MPW");
  9973. #endif /* MPW */
  9974. #endif /* MAC */
  9975.  
  9976. #ifdef MAC
  9977. #ifdef THINK_C
  9978.     makestr(&(optlist[noptlist++]),"THINK_C");
  9979. #endif /* THINK_C */
  9980. #endif /* MAC */
  9981.  
  9982. #ifdef __386__
  9983.     makestr(&(optlist[noptlist++]),"__386__");
  9984. #endif /* __386__ */
  9985.  
  9986. /* Memory models... */
  9987.  
  9988. #ifdef __FLAT__
  9989.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9990. #endif /* __FLAT__ */
  9991. #ifdef __SMALL__
  9992.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9993. #endif /* __SMALL__ */
  9994. #ifdef __MEDIUM__
  9995.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9996. #endif /* __MEDIUM__ */
  9997. #ifdef __COMPACT__
  9998.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9999. #endif /* __COMPACT__ */
  10000. #ifdef __LARGE__
  10001.     makestr(&(optlist[noptlist++]),"__LARGE__");
  10002. #endif /* __LARGE__ */
  10003.  
  10004. #ifdef DEBUG
  10005. #ifdef IFDEBUG
  10006.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  10007. #else
  10008.     makestr(&(optlist[noptlist++]),"DEBUG");
  10009. #endif /* IFDEBUG */
  10010. #endif /* DEBUG */
  10011. #ifdef TLOG
  10012.     makestr(&(optlist[noptlist++]),"TLOG");
  10013. #endif /* TLOG */
  10014. #ifdef BIGBUFOK
  10015.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  10016. #endif /* BIGBUFOK */
  10017. #ifdef INPBUFSIZ
  10018.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  10019.     makestr(&(optlist[noptlist++]),line);
  10020. #endif /* INPBUFSIZE */
  10021. #ifdef LINBUFSIZ
  10022.     sprintf(line,"LINBUFSIZ=%d",LINBUFSIZ); /* SAFE */
  10023.     makestr(&(optlist[noptlist++]),line);
  10024. #endif /* LINBUFSIZE */
  10025. #ifdef INBUFSIZE
  10026.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  10027.     makestr(&(optlist[noptlist++]),line);
  10028. #endif /* INBUFSIZE */
  10029. #ifdef OBUFSIZE
  10030.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  10031.     makestr(&(optlist[noptlist++]),line);
  10032. #endif /* OBUFSIZE */
  10033. #ifdef FD_SETSIZE
  10034.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  10035.     makestr(&(optlist[noptlist++]),line);
  10036. #endif /* FD_SETSIZE */
  10037. #ifdef XFRCAN
  10038.     makestr(&(optlist[noptlist++]),"XFRCAN");
  10039. #endif /* XFRCAN */
  10040. #ifdef XPRINT
  10041.     makestr(&(optlist[noptlist++]),"XPRINT");
  10042. #endif /* XPRINT */
  10043. #ifdef PIPESEND
  10044.     makestr(&(optlist[noptlist++]),"PIPESEND");
  10045. #endif /* PIPESEND */
  10046. #ifdef CK_SPEED
  10047.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  10048. #endif /* CK_SPEED */
  10049. #ifdef CK_FAST
  10050.     makestr(&(optlist[noptlist++]),"CK_FAST");
  10051. #endif /* CK_FAST */
  10052. #ifdef CK_APC
  10053.     makestr(&(optlist[noptlist++]),"CK_APC");
  10054. #endif /* CK_APC */
  10055. #ifdef CK_AUTODL
  10056.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  10057. #endif /* CK_AUTODL */
  10058. #ifdef CK_MKDIR
  10059.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  10060. #endif /* CK_MKDIR */
  10061. #ifdef NOMKDIR
  10062.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  10063. #endif /* NOMKDIR */
  10064. #ifdef CK_LABELED
  10065.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  10066. #endif /* CK_LABELED */
  10067. #ifdef NODIAL
  10068.     makestr(&(optlist[noptlist++]),"NODIAL");
  10069. #endif /* NODIAL */
  10070. #ifdef MINIDIAL
  10071.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  10072. #endif /* MINIDIAL */
  10073. #ifdef WHATAMI
  10074.     makestr(&(optlist[noptlist++]),"WHATAMI");
  10075. #endif /* WHATAMI */
  10076. #ifdef DYNAMIC
  10077.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  10078. #endif /* DYNAMIC */
  10079. #ifndef NOSPL
  10080.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  10081.     makestr(&(optlist[noptlist++]),line);
  10082. #endif /* NOSPL */
  10083.  
  10084. #ifdef MAXPATHLEN
  10085.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  10086.     makestr(&(optlist[noptlist++]),line);
  10087. #endif /* MAXPATHLEN */
  10088.  
  10089. #ifdef DEVNAMLEN
  10090.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  10091.     makestr(&(optlist[noptlist++]),line);
  10092. #endif /* DEVNAMLEN */
  10093.  
  10094. #ifdef NO_PARAM_H
  10095.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  10096. #endif /* NO_PARAM_H */
  10097.  
  10098. #ifdef INCL_PARAM_H
  10099.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  10100. #endif /* INCL_PARAM_H */
  10101.  
  10102.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  10103.     makestr(&(optlist[noptlist++]),line);
  10104.  
  10105.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  10106.     makestr(&(optlist[noptlist++]),line);
  10107.  
  10108.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  10109.     makestr(&(optlist[noptlist++]),line);
  10110.  
  10111. #ifdef OPEN_MAX
  10112.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  10113.     makestr(&(optlist[noptlist++]),line);
  10114. #endif /* OPEN_MAX */
  10115.  
  10116. #ifdef _POSIX_OPEN_MAX
  10117.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  10118.     makestr(&(optlist[noptlist++]),line);
  10119. #endif /* _POSIX_OPEN_MAX */
  10120.  
  10121. #ifdef CKCHANNELIO
  10122.     {
  10123.         extern int z_maxchan;
  10124. #ifdef UNIX
  10125.         extern int ckmaxfiles;
  10126.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  10127.         makestr(&(optlist[noptlist++]),line);
  10128. #endif /* UNIX */
  10129.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  10130.         makestr(&(optlist[noptlist++]),line);
  10131.     }
  10132. #endif /* CKCHANNELIO */
  10133.  
  10134. #ifdef FOPEN_MAX
  10135.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  10136.     makestr(&(optlist[noptlist++]),line);
  10137. #endif /* FOPEN_MAX */
  10138.  
  10139. #ifdef MAXGETPATH
  10140.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  10141.     makestr(&(optlist[noptlist++]),line);
  10142. #endif /* MAXGETPATH */
  10143.  
  10144. #ifdef CMDBL
  10145.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  10146.     makestr(&(optlist[noptlist++]),line);
  10147. #endif /* CMDBL */
  10148.  
  10149. #ifdef VNAML
  10150.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  10151.     makestr(&(optlist[noptlist++]),line);
  10152. #endif /* VNAML */
  10153.  
  10154. #ifdef ARRAYREFLEN
  10155.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  10156.     makestr(&(optlist[noptlist++]),line);
  10157. #endif /* ARRAYREFLEN */
  10158.  
  10159. #ifdef UIDBUFLEN
  10160.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  10161.     makestr(&(optlist[noptlist++]),line);
  10162. #endif /* UIDBUFLEN */
  10163.  
  10164. #ifdef FORDEPTH
  10165.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  10166.     makestr(&(optlist[noptlist++]),line);
  10167. #endif /* FORDEPTH */
  10168.  
  10169. #ifdef MAXTAKE
  10170.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  10171.     makestr(&(optlist[noptlist++]),line);
  10172. #endif /* MAXTAKE */
  10173.  
  10174. #ifdef MACLEVEL
  10175.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  10176.     makestr(&(optlist[noptlist++]),line);
  10177. #endif /* MACLEVEL */
  10178.  
  10179. #ifdef MAC_MAX
  10180.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  10181.     makestr(&(optlist[noptlist++]),line);
  10182. #endif /* MAC_MAX */
  10183.  
  10184. #ifdef _LARGEFILE_SOURCE
  10185.     makestr(&(optlist[noptlist++]),"_LARGEFILE_SOURCE");
  10186. #endif    /* _LARGEFILE_SOURCE */
  10187.  
  10188. #ifdef _FILE_OFFSET_BITS
  10189.     sprintf(line,"_FILE_OFFSET_BITS=%d",_FILE_OFFSET_BITS); /* SAFE */
  10190.     makestr(&(optlist[noptlist++]),line);
  10191. #endif    /* _FILE_OFFSET_BITS */
  10192.  
  10193. #ifdef __USE_FILE_OFFSET64
  10194.     makestr(&(optlist[noptlist++]),"__USE_FILE_OFFSET64");
  10195. #endif    /* __USE_FILE_OFFSET64 */
  10196.  
  10197. #ifdef __USE_LARGEFILE64
  10198.     makestr(&(optlist[noptlist++]),"__USE_LARGEFILE64");
  10199. #endif    /* __USE_LARGEFILE64 */
  10200.  
  10201. #ifdef COMMENT
  10202. #ifdef CHAR_MAX
  10203.     sprintf(line,"CHAR_MAX=%llx",CHAR_MAX); /* SAFE */
  10204.     makestr(&(optlist[noptlist++]),line);
  10205. #endif /* CHAR_MAX */
  10206. #ifdef UCHAR_MAX
  10207.     sprintf(line,"UCHAR_MAX=%llx",UCHAR_MAX); /* SAFE */
  10208.     makestr(&(optlist[noptlist++]),line);
  10209. #endif /* UCHAR_MAX */
  10210. #ifdef SHRT_MAX
  10211.     sprintf(line,"SHRT_MAX=%llx",SHRT_MAX); /* SAFE */
  10212.     makestr(&(optlist[noptlist++]),line);
  10213. #endif /* SHRT_MAX */
  10214. #ifdef USHRT_MAX
  10215.     sprintf(line,"USHRT_MAX=%llx",USHRT_MAX); /* SAFE */
  10216.     makestr(&(optlist[noptlist++]),line);
  10217. #endif /* USHRT_MAX */
  10218. #ifdef INT_MAX
  10219.     sprintf(line,"INT_MAX=%llx",INT_MAX); /* SAFE */
  10220.     makestr(&(optlist[noptlist++]),line);
  10221. #endif /* INT_MAX */
  10222. #ifdef UINT_MAX
  10223.     sprintf(line,"UINT_MAX=%llx",UINT_MAX); /* SAFE */
  10224.     makestr(&(optlist[noptlist++]),line);
  10225. #endif /* UINT_MAX */
  10226. #ifdef MAX_LONG
  10227.     sprintf(line,"MAX_LONG=%llx",MAX_LONG); /* SAFE */
  10228.     makestr(&(optlist[noptlist++]),line);
  10229. #endif /* MAX_LONG */
  10230. #ifdef LONG_MAX
  10231.     sprintf(line,"LONG_MAX=%llx",LONG_MAX); /* SAFE */
  10232.     makestr(&(optlist[noptlist++]),line);
  10233. #endif /* LONG_MAX */
  10234. #ifdef ULONG_MAX
  10235.     sprintf(line,"ULONG_MAX=%llx",ULONG_MAX); /* SAFE */
  10236.     makestr(&(optlist[noptlist++]),line);
  10237. #endif /* ULONG_MAX */
  10238. #ifdef MAXINT
  10239.     sprintf(line,"MAXINT=%llx",MAXINT); /* SAFE */
  10240.     makestr(&(optlist[noptlist++]),line);
  10241. #endif /* MAXINT */
  10242. #ifdef MAXLONG
  10243.     sprintf(line,"MAXLONG=%llx",MAXLONG); /* SAFE */
  10244.     makestr(&(optlist[noptlist++]),line);
  10245. #endif /* MAXLONG */
  10246. #ifdef NT
  10247. #ifdef LLONG_MAX
  10248.     sprintf(line,"LLONG_MAX=%I64x",LLONG_MAX); /* SAFE */
  10249.     makestr(&(optlist[noptlist++]),line);
  10250. #endif /* LLONG_MAX */
  10251. #ifdef ULLONG_MAX
  10252.     sprintf(line,"ULLONG_MAX=%I64x",ULLONG_MAX); /* SAFE */
  10253.     makestr(&(optlist[noptlist++]),line);
  10254. #endif /* ULLONG_MAX */
  10255. #ifdef MAXLONGLONG
  10256.     sprintf(line,"MAXLONGLONG=%I64x",MAXLONGLONG);  /* SAFE */
  10257.     makestr(&(optlist[noptlist++]),line);
  10258. #endif /* MAXLONGLONG */
  10259. #else
  10260. #ifdef LLONG_MAX
  10261.     sprintf(line,"LLONG_MAX=%llx",LLONG_MAX); /* SAFE */
  10262.     makestr(&(optlist[noptlist++]),line);
  10263. #endif /* LLONG_MAX */
  10264. #ifdef ULLONG_MAX
  10265.     sprintf(line,"ULLONG_MAX=%llx",ULLONG_MAX); /* SAFE */
  10266.     makestr(&(optlist[noptlist++]),line);
  10267. #endif /* ULLONG_MAX */
  10268. #ifdef MAXLONGLONG
  10269.     sprintf(line,"MAXLONGLONG=%llx",MAXLONGLONG);  /* SAFE */
  10270.     makestr(&(optlist[noptlist++]),line);
  10271. #endif /* MAXLONGLONG */
  10272. #endif
  10273. #ifdef _INTEGRAL_MAX_BITS
  10274.     sprintf(line,"_INTEGRAL_MAX_BITS=%d",_INTEGRAL_MAX_BITS);  /* SAFE */
  10275.     makestr(&(optlist[noptlist++]),line);
  10276. #endif /* _INTEGRAL_MAX_BITS */
  10277. #endif    /* COMMENT */
  10278.  
  10279. #ifdef MINPUTMAX
  10280.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  10281.     makestr(&(optlist[noptlist++]),line);
  10282. #endif /* MINPUTMAX */
  10283.  
  10284. #ifdef MAXWLD
  10285.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  10286.     makestr(&(optlist[noptlist++]),line);
  10287. #else
  10288. #ifdef OS2
  10289.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  10290. #endif /* OS2 */
  10291. #endif /* MAXWLD */
  10292.  
  10293. #ifdef MSENDMAX
  10294.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  10295.     makestr(&(optlist[noptlist++]),line);
  10296. #endif /* MSENDMAX */
  10297.  
  10298. #ifdef MAXDDIR
  10299.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  10300.     makestr(&(optlist[noptlist++]),line);
  10301. #endif /* MAXDDIR */
  10302.  
  10303. #ifdef MAXDNUMS
  10304.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  10305.     makestr(&(optlist[noptlist++]),line);
  10306. #endif /* MAXDNUMS */
  10307.  
  10308. #ifdef UNIX
  10309.     makestr(&(optlist[noptlist++]),"UNIX");
  10310. #endif /* UNIX */
  10311.  
  10312. #ifdef VMS
  10313.     makestr(&(optlist[noptlist++]),"VMS");
  10314. #ifdef __VMS_VER
  10315.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  10316.     makestr(&(optlist[noptlist++]),line);
  10317. #endif /* __VMS_VER */
  10318. #ifdef VMSV70
  10319.     makestr(&(optlist[noptlist++]),"VMSV70");
  10320. #endif /* VMSV70 */
  10321. #ifdef OLD_VMS
  10322.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  10323. #endif /* OLD_VMS */
  10324. #ifdef vms
  10325.     makestr(&(optlist[noptlist++]),"vms");
  10326. #endif /* vms */
  10327. #ifdef VMSV60
  10328.     makestr(&(optlist[noptlist++]),"VMSV60");
  10329. #endif /* VMSV60 */
  10330. #ifdef VMSV80
  10331.     makestr(&(optlist[noptlist++]),"VMSV80");
  10332. #endif /* VMSV80 */
  10333. #ifdef VMSSHARE
  10334.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  10335. #endif /* VMSSHARE */
  10336. #ifdef NOVMSSHARE
  10337.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  10338. #endif /* NOVMSSHARE */
  10339. #endif /* VMS */
  10340.  
  10341. #ifdef datageneral
  10342.     makestr(&(optlist[noptlist++]),"datageneral");
  10343. #endif /* datageneral */
  10344. #ifdef apollo
  10345.     makestr(&(optlist[noptlist++]),"apollo");
  10346. #endif /* apollo */
  10347. #ifdef aegis
  10348.     makestr(&(optlist[noptlist++]),"aegis");
  10349. #endif /* aegis */
  10350. #ifdef A986
  10351.     makestr(&(optlist[noptlist++]),"A986");
  10352. #endif /* A986 */
  10353. #ifdef AMIGA
  10354.     makestr(&(optlist[noptlist++]),"AMIGA");
  10355. #endif /* AMIGA */
  10356. #ifdef CONVEX9
  10357.     makestr(&(optlist[noptlist++]),"CONVEX9");
  10358. #endif /* CONVEX9 */
  10359. #ifdef CONVEX10
  10360.     makestr(&(optlist[noptlist++]),"CONVEX10");
  10361. #endif /* CONVEX9 */
  10362. #ifdef MAC
  10363.     makestr(&(optlist[noptlist++]),"MAC");
  10364. #endif /* MAC */
  10365. #ifdef AUX
  10366.     makestr(&(optlist[noptlist++]),"AUX");
  10367. #endif /* AUX */
  10368.  
  10369. #ifdef OS2
  10370.     makestr(&(optlist[noptlist++]),"OS2");
  10371. #ifdef NT
  10372.     makestr(&(optlist[noptlist++]),"NT");
  10373. #endif /* NT */
  10374. #endif /* OS2 */
  10375.  
  10376. #ifdef OSK
  10377.     makestr(&(optlist[noptlist++]),"OS9");
  10378. #endif /* OSK */
  10379.  
  10380. #ifdef MSDOS
  10381.     makestr(&(optlist[noptlist++]),"MSDOS");
  10382. #endif /* MSDOS */
  10383.  
  10384. #ifdef DIRENT
  10385.     makestr(&(optlist[noptlist++]),"DIRENT");
  10386. #endif /* DIRENT */
  10387.  
  10388. #ifdef SDIRENT
  10389.     makestr(&(optlist[noptlist++]),"SDIRENT");
  10390. #endif /* SDIRENT */
  10391.  
  10392. #ifdef NDIR
  10393.     makestr(&(optlist[noptlist++]),"NDIR");
  10394. #endif /* NDIR */
  10395.  
  10396. #ifdef XNDIR
  10397.     makestr(&(optlist[noptlist++]),"XNDIR");
  10398. #endif /* XNDIR */
  10399.  
  10400. #ifdef SAVEDUID
  10401.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  10402. #endif /* SAVEDUID */
  10403.  
  10404. #ifdef RENAME
  10405.     makestr(&(optlist[noptlist++]),"RENAME");
  10406. #endif /* RENAME */
  10407.  
  10408. #ifdef CK_TMPDIR
  10409.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  10410. #endif /* CK_TMPDIR */
  10411.  
  10412. #ifdef NOCCTRAP
  10413.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  10414. #endif /* NOCCTRAP */
  10415.  
  10416. #ifdef NOCOTFMC
  10417.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  10418. #endif /* NOCOTFMC */
  10419.  
  10420. #ifdef NOFRILLS
  10421.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  10422. #endif /* NOFRILLS */
  10423.  
  10424. #ifdef PARSENSE
  10425.     makestr(&(optlist[noptlist++]),"PARSENSE");
  10426. #endif /* PARSENSE */
  10427.  
  10428. #ifdef TIMEH
  10429.     makestr(&(optlist[noptlist++]),"TIMEH");
  10430. #endif /* TIMEH */
  10431.  
  10432. #ifdef NOTIMEH
  10433.     makestr(&(optlist[noptlist++]),"TIMEH");
  10434. #endif /* NOTIMEH */
  10435.  
  10436. #ifdef SYSTIMEH
  10437.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10438. #endif /* SYSTIMEH */
  10439.  
  10440. #ifdef NOSYSTIMEH
  10441.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10442. #endif /* NOSYSTIMEH */
  10443.  
  10444. #ifdef SYSTIMEBH
  10445.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10446. #endif /* SYSTIMEBH */
  10447.  
  10448. #ifdef NOSYSTIMEBH
  10449.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10450. #endif /* NOSYSTIMEBH */
  10451.  
  10452. #ifdef UTIMEH
  10453.     makestr(&(optlist[noptlist++]),"UTIMEH");
  10454. #endif /* UTIMEH */
  10455.  
  10456. #ifdef SYSUTIMEH
  10457.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  10458. #endif /* SYSUTIMEH */
  10459.  
  10460. #ifdef CK_NEED_SIG
  10461.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  10462. #endif /* CK_NEED_SIG */
  10463.  
  10464. #ifdef CK_TTYFD
  10465.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  10466. #endif /* CK_TTYFD */
  10467.  
  10468. #ifdef NETCONN
  10469.     makestr(&(optlist[noptlist++]),"NETCONN");
  10470. #endif /* NETCONN */
  10471.  
  10472. #ifdef TCPSOCKET
  10473.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  10474. #ifdef NOTCPOPTS
  10475.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  10476. #endif /* NOTCPOPTS */
  10477. #ifdef CK_DNS_SRV
  10478.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  10479. #endif /* CK_DNS_SRV */
  10480. #ifdef NO_DNS_SRV
  10481.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  10482. #endif /* NO_DNS_SRV */
  10483. #ifdef CKGHNLHOST
  10484.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  10485. #endif /* CKGHNLHOST */
  10486. #ifdef NOLISTEN
  10487.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  10488. #endif /* NOLISTEN */
  10489. #ifdef SOL_SOCKET
  10490.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  10491. #endif /* SOL_SOCKET */
  10492. #ifdef SO_OOBINLINE
  10493.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  10494. #endif /* SO_OOBINLNE */
  10495. #ifdef SO_DONTROUTE
  10496.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  10497. #endif /* SO_DONTROUTE */
  10498. #ifdef SO_KEEPALIVE
  10499.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  10500. #endif /* SO_KEEPALIVE */
  10501. #ifdef SO_LINGER
  10502.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  10503. #endif /* SO_LINGER */
  10504. #ifdef TCP_NODELAY
  10505.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  10506. #endif /* TCP_NODELAY */
  10507. #ifdef SO_SNDBUF
  10508.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  10509. #endif /* SO_SNDBUF */
  10510. #ifdef SO_RCVBUF
  10511.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  10512. #endif /* SO_RCVBUF */
  10513. #ifdef h_addr
  10514.     makestr(&(optlist[noptlist++]),"h_addr");
  10515. #endif /* h_addr */
  10516. #ifdef HADDRLIST
  10517.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  10518. #endif /* HADDRLIST */
  10519. #ifdef CK_SOCKS
  10520.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  10521. #ifdef CK_SOCKS5
  10522.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  10523. #endif /* CK_SOCKS5 */
  10524. #ifdef CK_SOCKS_NS
  10525.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  10526. #endif /* CK_SOCKS_NS */
  10527. #endif /* CK_SOCKS */
  10528. #ifdef RLOGCODE
  10529.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  10530. #endif /* RLOGCODE */
  10531. #ifdef NETCMD
  10532.     makestr(&(optlist[noptlist++]),"NETCMD");
  10533. #endif /* NETCMD */
  10534. #ifdef NONETCMD
  10535.     makestr(&(optlist[noptlist++]),"NONETCMD");
  10536. #endif /* NONETCMD */
  10537. #ifdef NETPTY
  10538.     makestr(&(optlist[noptlist++]),"NETPTY");
  10539. #endif /* NETPTY */
  10540. #ifdef CK_ENVIRONMENT
  10541.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  10542. #endif /* CK_ENVIRONMENT */
  10543. #endif /* TCPSOCKET */
  10544. #ifdef TNCODE
  10545.     makestr(&(optlist[noptlist++]),"TNCODE");
  10546. #endif /* TNCODE */
  10547. #ifdef CK_FORWARD_X
  10548.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  10549. #endif /* CK_FORWARD_X */
  10550. #ifdef TN_COMPORT
  10551.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  10552. #endif /* TN_COMPORT */
  10553. #ifdef MULTINET
  10554.     makestr(&(optlist[noptlist++]),"MULTINET");
  10555. #endif /* MULTINET */
  10556. #ifdef DEC_TCPIP
  10557.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  10558. #endif /* DEC_TCPIP */
  10559. #ifdef TCPWARE
  10560.     makestr(&(optlist[noptlist++]),"TCPWARE");
  10561. #endif /* TCPWARE */
  10562. #ifdef UCX50
  10563.     makestr(&(optlist[noptlist++]),"UCX50");
  10564. #endif /* UCX50 */
  10565. #ifdef CMU_TCPIP
  10566.     makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  10567. #endif /* CMU_TCPIP */
  10568. #ifdef TTLEBUF
  10569.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  10570. #endif /* TTLEBUF */
  10571. #ifdef NETLEBUF
  10572.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  10573. #endif /* NETLEBUF */
  10574. #ifdef IKS_OPTION
  10575.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10576. #endif /* IKS_OPTION */
  10577. #ifdef IKSDB
  10578.     makestr(&(optlist[noptlist++]),"IKSDB");
  10579. #endif /* IKSDB */
  10580. #ifdef IKSDCONF
  10581.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  10582. #endif /* IKSDCONF */
  10583. #ifdef CK_LOGIN
  10584.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10585. #endif /* CK_LOGIN */
  10586. #ifdef CK_PAM
  10587.     makestr(&(optlist[noptlist++]),"CK_PAM");
  10588. #endif /* CK_PAM */
  10589. #ifdef CK_SHADOW
  10590.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10591. #endif /* CK_SHADOW */
  10592. #ifdef CONGSPD
  10593.     makestr(&(optlist[noptlist++]),"CONGSPD");
  10594. #endif /* CONGSPD */
  10595. #ifdef SUNX25
  10596.     makestr(&(optlist[noptlist++]),"SUNX25");
  10597. #endif /* SUNX25 */
  10598. #ifdef IBMX25
  10599.     makestr(&(optlist[noptlist++]),"IBMX25");
  10600. #endif /* IBMX25 */
  10601. #ifdef HPX25
  10602.     makestr(&(optlist[noptlist++]),"HPX25");
  10603. #endif /* HPX25 */
  10604. #ifdef DECNET
  10605.     makestr(&(optlist[noptlist++]),"DECNET");
  10606. #endif /* DECNET */
  10607. #ifdef SUPERLAT
  10608.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  10609. #endif /* SUPERLAT */
  10610. #ifdef NPIPE
  10611.     makestr(&(optlist[noptlist++]),"NPIPE");
  10612. #endif /* NPIPE */
  10613. #ifdef CK_NETBIOS
  10614.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10615. #endif /* CK_NETBIOS */
  10616. #ifdef ATT7300
  10617.     makestr(&(optlist[noptlist++]),"ATT7300");
  10618. #endif /* ATT7300 */
  10619. #ifdef ATT6300
  10620.     makestr(&(optlist[noptlist++]),"ATT6300");
  10621. #endif /* ATT6300 */
  10622. #ifdef HDBUUCP
  10623.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10624. #endif /* HDBUUCP */
  10625. #ifdef USETTYLOCK
  10626.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10627. #endif /* USETTYLOCK */
  10628. #ifdef USE_UU_LOCK
  10629.     makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
  10630. #endif /* USE_UU_LOCK */
  10631. #ifdef HAVE_BAUDBOY
  10632.     makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
  10633. #endif /* HAVE_BAUDBOY */
  10634. #ifdef HAVE_OPENPTY
  10635.     makestr(&(optlist[noptlist++]),"HAVE_OPENPTY");
  10636. #endif /* HAVE_OPENPTY */
  10637. #ifdef TTPTYCMD
  10638.     makestr(&(optlist[noptlist++]),"TTPTYCMD");
  10639. #endif /* TTPTYCMD */
  10640. #ifdef NOUUCP
  10641.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10642. #endif /* NOUUCP */
  10643. #ifdef LONGFN
  10644.     makestr(&(optlist[noptlist++]),"LONGFN");
  10645. #endif /* LONGFN */
  10646. #ifdef RDCHK
  10647.     makestr(&(optlist[noptlist++]),"RDCHK");
  10648. #endif /* RDCHK */
  10649. #ifdef SELECT
  10650.     makestr(&(optlist[noptlist++]),"SELECT");
  10651. #endif /* SELECT */
  10652. #ifdef USLEEP
  10653.     makestr(&(optlist[noptlist++]),"USLEEP");
  10654. #endif /* USLEEP */
  10655. #ifdef NAP
  10656.     makestr(&(optlist[noptlist++]),"NAP");
  10657. #endif /* NAP */
  10658. #ifdef NAPHACK
  10659.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10660. #endif /* NAPHACK */
  10661. #ifdef CK_POLL
  10662.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10663. #endif /* CK_POLL */
  10664. #ifdef NOIEXTEN
  10665.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10666. #endif /* NOIEXTEN */
  10667. #ifdef EXCELAN
  10668.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10669. #endif /* EXCELAN */
  10670. #ifdef INTERLAN
  10671.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10672. #endif /* INTERLAN */
  10673. #ifdef NOFILEH
  10674.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10675. #endif /* NOFILEH */
  10676. #ifdef NOSYSIOCTLH
  10677.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10678. #endif /* NOSYSIOCTLH */
  10679. #ifdef DCLPOPEN
  10680.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10681. #endif /* DCLPOPEN */
  10682. #ifdef NOSETBUF
  10683.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10684. #endif /* NOSETBUF */
  10685. #ifdef NOXFER
  10686.     makestr(&(optlist[noptlist++]),"NOXFER");
  10687. #endif /* NOXFER */
  10688. #ifdef NOCURSES
  10689.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10690. #endif /* NOCURSES */
  10691. #ifdef NOSERVER
  10692.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10693. #endif /* NOSERVER */
  10694. #ifdef NOPATTERNS
  10695.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10696. #else
  10697. #ifdef PATTERNS
  10698.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10699. #endif /* PATTERNS */
  10700. #endif /* NOPATTERNS */
  10701. #ifdef NOCKEXEC
  10702.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10703. #else
  10704. #ifdef CKEXEC
  10705.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10706. #endif /* CKEXEC */
  10707. #endif /* NOCKEXEC */
  10708. #ifdef NOAUTODL
  10709.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10710. #endif /* NOAUTODL */
  10711. #ifdef NOMSEND
  10712.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10713. #endif /* NOMSEND */
  10714. #ifdef NOFDZERO
  10715.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10716. #endif /* NOFDZERO */
  10717. #ifdef NOPOPEN
  10718.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10719. #endif /* NOPOPEN */
  10720. #ifdef NOPARTIAL
  10721.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10722. #endif /* NOPARTIAL */
  10723. #ifdef NOKVERBS
  10724.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10725. #endif /* NOKVERBS */
  10726. #ifdef NOSETREU
  10727.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10728. #endif /* NOSETREU */
  10729. #ifdef LCKDIR
  10730.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10731. #endif /* LCKDIR */
  10732. #ifdef ACUCNTRL
  10733.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10734. #endif /* ACUCNTRL */
  10735. #ifdef BSD4
  10736.     makestr(&(optlist[noptlist++]),"BSD4");
  10737. #endif /* BSD4 */
  10738. #ifdef BSD44
  10739.     makestr(&(optlist[noptlist++]),"BSD44");
  10740. #endif /* BSD44 */
  10741. #ifdef BSD41
  10742.     makestr(&(optlist[noptlist++]),"BSD41");
  10743. #endif /* BSD41 */
  10744. #ifdef BSD43
  10745.     makestr(&(optlist[noptlist++]),"BSD43");
  10746. #endif /* BSD43 */
  10747. #ifdef BSD29
  10748.     makestr(&(optlist[noptlist++]),"BSD29");
  10749. #endif /* BSD29 */
  10750. #ifdef BSDI
  10751.     makestr(&(optlist[noptlist++]),"BSDI");
  10752. #endif /* BSDI */
  10753. #ifdef __bsdi__
  10754.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10755. #endif /* __bsdi__ */
  10756. #ifdef __NetBSD__
  10757.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10758. #endif /* __NetBSD__ */
  10759. #ifdef __OpenBSD__
  10760.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10761. #endif /* __OpenBSD__ */
  10762. #ifdef __FreeBSD__
  10763.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10764. #endif /* __FreeBSD__ */
  10765. #ifdef __linux__
  10766.     makestr(&(optlist[noptlist++]),"__linux__");
  10767. #endif /* __linux__ */
  10768. #ifdef LINUX_HI_SPD
  10769.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10770. #endif /* LINUX_HI_SPD */
  10771. #ifdef LYNXOS
  10772.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10773. #endif /* LYNXOS */
  10774. #ifdef V7
  10775.     makestr(&(optlist[noptlist++]),"V7");
  10776. #endif /* V7 */
  10777. #ifdef AIX370
  10778.     makestr(&(optlist[noptlist++]),"AIX370");
  10779. #endif /* AIX370 */
  10780. #ifdef RTAIX
  10781.     makestr(&(optlist[noptlist++]),"RTAIX");
  10782. #endif /* RTAIX */
  10783. #ifdef HPUX
  10784.     makestr(&(optlist[noptlist++]),"HPUX");
  10785. #endif /* HPUX */
  10786. #ifdef HPUX9
  10787.     makestr(&(optlist[noptlist++]),"HPUX9");
  10788. #endif /* HPUX9 */
  10789. #ifdef HPUX10
  10790.     makestr(&(optlist[noptlist++]),"HPUX10");
  10791. #endif /* HPUX10 */
  10792. #ifdef HPUX1000
  10793.     makestr(&(optlist[noptlist++]),"HPUX1000");
  10794. #endif /* HPUX1000 */
  10795. #ifdef HPUX1100
  10796.     makestr(&(optlist[noptlist++]),"HPUX1100");
  10797. #endif /* HPUX1100 */
  10798. #ifdef HPUXPRE65
  10799.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10800. #endif /* HPUXPRE65 */
  10801. #ifdef DGUX
  10802.     makestr(&(optlist[noptlist++]),"DGUX");
  10803. #endif /* DGUX */
  10804. #ifdef DGUX430
  10805.     makestr(&(optlist[noptlist++]),"DGUX430");
  10806. #endif /* DGUX430 */
  10807. #ifdef DGUX540
  10808.     makestr(&(optlist[noptlist++]),"DGUX540");
  10809. #endif /* DGUX540 */
  10810. #ifdef DGUX543
  10811.     makestr(&(optlist[noptlist++]),"DGUX543");
  10812. #endif /* DGUX543 */
  10813. #ifdef DGUX54410
  10814.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10815. #endif /* DGUX54410 */
  10816. #ifdef DGUX54411
  10817.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10818. #endif /* DGUX54411 */
  10819. #ifdef sony_news
  10820.     makestr(&(optlist[noptlist++]),"sony_news");
  10821. #endif /* sony_news */
  10822. #ifdef CIE
  10823.     makestr(&(optlist[noptlist++]),"CIE");
  10824. #endif /* CIE */
  10825. #ifdef XENIX
  10826.     makestr(&(optlist[noptlist++]),"XENIX");
  10827. #endif /* XENIX */
  10828. #ifdef SCO_XENIX
  10829.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10830. #endif /* SCO_XENIX */
  10831. #ifdef ISIII
  10832.     makestr(&(optlist[noptlist++]),"ISIII");
  10833. #endif /* ISIII */
  10834. #ifdef I386IX
  10835.     makestr(&(optlist[noptlist++]),"I386IX");
  10836. #endif /* I386IX */
  10837. #ifdef RTU
  10838.     makestr(&(optlist[noptlist++]),"RTU");
  10839. #endif /* RTU */
  10840. #ifdef PROVX1
  10841.     makestr(&(optlist[noptlist++]),"PROVX1");
  10842. #endif /* PROVX1 */
  10843. #ifdef PYRAMID
  10844.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10845. #endif /* PYRAMID */
  10846. #ifdef TOWER1
  10847.     makestr(&(optlist[noptlist++]),"TOWER1");
  10848. #endif /* TOWER1 */
  10849. #ifdef UTEK
  10850.     makestr(&(optlist[noptlist++]),"UTEK");
  10851. #endif /* UTEK */
  10852. #ifdef ZILOG
  10853.     makestr(&(optlist[noptlist++]),"ZILOG");
  10854. #endif /* ZILOG */
  10855. #ifdef TRS16
  10856.     makestr(&(optlist[noptlist++]),"TRS16");
  10857. #endif /* TRS16 */
  10858. #ifdef MINIX
  10859.     makestr(&(optlist[noptlist++]),"MINIX");
  10860. #endif /* MINIX */
  10861. #ifdef MINIX2
  10862.     makestr(&(optlist[noptlist++]),"MINIX2");
  10863. #endif /* MINIX2 */
  10864. #ifdef MINIX3
  10865.     makestr(&(optlist[noptlist++]),"MINIX3");
  10866. #endif /* MINIX3 */
  10867. #ifdef MINIX315
  10868.     makestr(&(optlist[noptlist++]),"MINIX315");
  10869. #endif /* MINIX315 */
  10870. #ifdef C70
  10871.     makestr(&(optlist[noptlist++]),"C70");
  10872. #endif /* C70 */
  10873. #ifdef AIXPS2
  10874.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10875. #endif /* AIXPS2 */
  10876. #ifdef AIXRS
  10877.     makestr(&(optlist[noptlist++]),"AIXRS");
  10878. #endif /* AIXRS */
  10879. #ifdef UTSV
  10880.     makestr(&(optlist[noptlist++]),"UTSV");
  10881. #endif /* UTSV */
  10882. #ifdef ATTSV
  10883.     makestr(&(optlist[noptlist++]),"ATTSV");
  10884. #endif /* ATTSV */
  10885. #ifdef SVR3
  10886.     makestr(&(optlist[noptlist++]),"SVR3");
  10887. #endif /* SVR3 */
  10888. #ifdef SVR4
  10889.     makestr(&(optlist[noptlist++]),"SVR4");
  10890. #endif /* SVR4 */
  10891. #ifdef DELL_SVR4
  10892.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10893. #endif /* DELL_SVR4 */
  10894. #ifdef ICL_SVR4
  10895.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10896. #endif /* ICL_SVR4 */
  10897. #ifdef OSF
  10898.     makestr(&(optlist[noptlist++]),"OSF");
  10899. #endif /* OSF */
  10900. #ifdef OSF1
  10901.     makestr(&(optlist[noptlist++]),"OSF1");
  10902. #endif /* OSF1 */
  10903. #ifdef __OSF
  10904.     makestr(&(optlist[noptlist++]),"__OSF");
  10905. #endif /* __OSF */
  10906. #ifdef __OSF__
  10907.     makestr(&(optlist[noptlist++]),"__OSF__");
  10908. #endif /* __OSF__ */
  10909. #ifdef __osf__
  10910.     makestr(&(optlist[noptlist++]),"__osf__");
  10911. #endif /* __osf__ */
  10912. #ifdef __OSF1
  10913.     makestr(&(optlist[noptlist++]),"__OSF1");
  10914. #endif /* __OSF1 */
  10915. #ifdef __OSF1__
  10916.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10917. #endif /* __OSF1__ */
  10918. #ifdef PTX
  10919.     makestr(&(optlist[noptlist++]),"PTX");
  10920. #endif /* PTX */
  10921. #ifdef POSIX
  10922.     makestr(&(optlist[noptlist++]),"POSIX");
  10923. #endif /* POSIX */
  10924. #ifdef BSD44ORPOSIX
  10925.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10926. #endif /* BSD44ORPOSIX */
  10927. #ifdef SVORPOSIX
  10928.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10929. #endif /* SVORPOSIX */
  10930. #ifdef SVR4ORPOSIX
  10931.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10932. #endif /* SVR4ORPOSIX */
  10933. #ifdef OS2ORVMS
  10934.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10935. #endif /* OS2ORVMS */
  10936. #ifdef OS2ORUNIX
  10937.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10938. #endif /* OS2ORUNIX */
  10939. #ifdef VMSORUNIX
  10940.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10941. #endif /* VMSORUNIX */
  10942. #ifdef VMS64BIT
  10943.     makestr(&(optlist[noptlist++]),"VMS64BIT");    /* VMS on Alpha or IA64 */
  10944. #endif /* VMS64BIT */
  10945. #ifdef VMSI64
  10946.     makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
  10947. #endif /* VMSI64 */
  10948. #ifdef _POSIX_SOURCE
  10949.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10950. #endif /* _POSIX_SOURCE */
  10951. #ifdef _XOPEN_SOURCE
  10952.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10953. #endif
  10954. #ifdef _ALL_SOURCE
  10955.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10956. #endif
  10957. #ifdef _SVID3
  10958.     makestr(&(optlist[noptlist++]),"_SVID3");
  10959. #endif /* _SVID3 */
  10960. #ifdef Plan9
  10961.     makestr(&(optlist[noptlist++]),"Plan9");
  10962. #endif /* Plan9 */
  10963. #ifdef SOLARIS
  10964.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10965. #ifdef SOLARIS24
  10966.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10967. #endif /* SOLARIS24 */
  10968. #ifdef SOLARIS25
  10969.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10970. #endif /* SOLARIS25 */
  10971. #ifdef SOLARIS26
  10972.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10973. #endif /* SOLARIS26 */
  10974. #ifdef SOLARIS7
  10975.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10976. #endif /* SOLARIS7 */
  10977. #ifdef SOLARIS8
  10978.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10979. #endif /* SOLARIS8 */
  10980. #ifdef SOLARIS9
  10981.     makestr(&(optlist[noptlist++]),"SOLARIS9");
  10982. #endif /* SOLARIS9 */
  10983. #ifdef SOLARIS10
  10984.     makestr(&(optlist[noptlist++]),"SOLARIS10");
  10985. #endif /* SOLARIS10 */
  10986. #endif /* SOLARIS */
  10987.  
  10988. #ifdef SUNOS4
  10989.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10990. #endif /* SUNOS4 */
  10991. #ifdef SUN4S5
  10992.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10993. #endif /* SUN4S5 */
  10994. #ifdef IRIX
  10995.     makestr(&(optlist[noptlist++]),"IRIX");
  10996. #endif /* IRIX */
  10997. #ifdef ENCORE
  10998.     makestr(&(optlist[noptlist++]),"ENCORE");
  10999. #endif /* ENCORE */
  11000. #ifdef ultrix
  11001.     makestr(&(optlist[noptlist++]),"ultrix");
  11002. #endif
  11003. #ifdef sxaE50
  11004.     makestr(&(optlist[noptlist++]),"sxaE50");
  11005. #endif
  11006. #ifdef mips
  11007.     makestr(&(optlist[noptlist++]),"mips");
  11008. #endif
  11009. #ifdef MIPS
  11010.     makestr(&(optlist[noptlist++]),"MIPS");
  11011. #endif
  11012. #ifdef vax
  11013.     makestr(&(optlist[noptlist++]),"vax");
  11014. #endif
  11015. #ifdef VAX
  11016.     makestr(&(optlist[noptlist++]),"VAX");
  11017. #endif
  11018. #ifdef alpha
  11019.     makestr(&(optlist[noptlist++]),"alpha");
  11020. #endif
  11021. #ifdef ALPHA
  11022.     makestr(&(optlist[noptlist++]),"ALPHA");
  11023. #endif
  11024. #ifdef __ALPHA
  11025.     makestr(&(optlist[noptlist++]),"__ALPHA");
  11026. #endif
  11027. #ifdef __alpha
  11028.     makestr(&(optlist[noptlist++]),"__alpha");
  11029. #endif
  11030. #ifdef __AXP
  11031.     makestr(&(optlist[noptlist++]),"__AXP");
  11032. #endif
  11033. #ifdef AXP
  11034.     makestr(&(optlist[noptlist++]),"AXP");
  11035. #endif
  11036. #ifdef axp
  11037.     makestr(&(optlist[noptlist++]),"axp");
  11038. #endif
  11039. #ifdef __ALPHA__
  11040.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  11041. #endif
  11042. #ifdef __alpha__
  11043.     makestr(&(optlist[noptlist++]),"__alpha__");
  11044. #endif
  11045. #ifdef sun
  11046.     makestr(&(optlist[noptlist++]),"sun");
  11047. #endif
  11048. #ifdef sun3
  11049.     makestr(&(optlist[noptlist++]),"sun3");
  11050. #endif
  11051. #ifdef sun386
  11052.     makestr(&(optlist[noptlist++]),"sun386");
  11053. #endif
  11054. #ifdef _SUN
  11055.     makestr(&(optlist[noptlist++]),"_SUN");
  11056. #endif
  11057. #ifdef sun4
  11058.     makestr(&(optlist[noptlist++]),"sun4");
  11059. #endif
  11060. #ifdef sparc
  11061.     makestr(&(optlist[noptlist++]),"sparc");
  11062. #endif
  11063. #ifdef _CRAY
  11064.     makestr(&(optlist[noptlist++]),"_CRAY");
  11065. #endif /* _CRAY */
  11066. #ifdef NEXT33
  11067.     makestr(&(optlist[noptlist++]),"NEXT33");
  11068. #endif
  11069. #ifdef NEXT
  11070.     makestr(&(optlist[noptlist++]),"NEXT");
  11071. #endif
  11072. #ifdef NeXT
  11073.     makestr(&(optlist[noptlist++]),"NeXT");
  11074. #endif
  11075. #ifdef MACH
  11076.     makestr(&(optlist[noptlist++]),"MACH");
  11077. #endif
  11078.  
  11079. #ifdef MACOSX
  11080.     makestr(&(optlist[noptlist++]),"MACOSX");
  11081. #endif
  11082. #ifdef MACOSX10
  11083.     makestr(&(optlist[noptlist++]),"MACOSX10");
  11084. #endif
  11085. #ifdef MACOSX103
  11086.     makestr(&(optlist[noptlist++]),"MACOSX10e");
  11087. #endif
  11088. #ifdef COMMENT
  11089. /* not used */
  11090. #ifdef MACOSX103
  11091.     makestr(&(optlist[noptlist++]),"MACOSX103");
  11092. #endif
  11093. #endif    /* COMMENT */
  11094.  
  11095. #ifdef sgi
  11096.     makestr(&(optlist[noptlist++]),"sgi");
  11097. #endif
  11098. #ifdef M_SYS5
  11099.     makestr(&(optlist[noptlist++]),"M_SYS5");
  11100. #endif
  11101. #ifdef __SYSTEM_FIVE
  11102.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  11103. #endif
  11104. #ifdef sysV
  11105.     makestr(&(optlist[noptlist++]),"sysV");
  11106. #endif
  11107. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  11108.     makestr(&(optlist[noptlist++]),"M_XENIX");
  11109. #endif
  11110. #ifdef M_UNIX                           /* SCO UNIX */
  11111.     makestr(&(optlist[noptlist++]),"M_UNIX");
  11112. #endif
  11113. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  11114.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  11115. #endif
  11116. #ifdef CK_SCOV5
  11117.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  11118. #endif
  11119. #ifdef SCO_OSR504
  11120.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  11121. #endif
  11122. #ifdef M_IA64
  11123.     makestr(&(optlist[noptlist++]),"M_IA64");
  11124. #endif
  11125. #ifdef _M_IA64
  11126.     makestr(&(optlist[noptlist++]),"_M_IA64");
  11127. #endif
  11128. #ifdef ia64
  11129.     makestr(&(optlist[noptlist++]),"ia64");
  11130. #endif
  11131. #ifdef _ia64
  11132.     makestr(&(optlist[noptlist++]),"_ia64");
  11133. #endif
  11134. #ifdef _ia64_
  11135.     makestr(&(optlist[noptlist++]),"_ia64_");
  11136. #endif
  11137. #ifdef __ia64
  11138.     makestr(&(optlist[noptlist++]),"__ia64");
  11139. #endif
  11140. #ifdef M_I686
  11141.     makestr(&(optlist[noptlist++]),"M_I686");
  11142. #endif
  11143. #ifdef _M_I686
  11144.     makestr(&(optlist[noptlist++]),"_M_I686");
  11145. #endif
  11146. #ifdef i686
  11147.     makestr(&(optlist[noptlist++]),"i686");
  11148. #endif
  11149. #ifdef M_I586
  11150.     makestr(&(optlist[noptlist++]),"M_I586");
  11151. #endif
  11152. #ifdef _M_I586
  11153.     makestr(&(optlist[noptlist++]),"_M_I586");
  11154. #endif
  11155. #ifdef i586
  11156.     makestr(&(optlist[noptlist++]),"i586");
  11157. #endif
  11158. #ifdef M_I486
  11159.     makestr(&(optlist[noptlist++]),"M_I486");
  11160. #endif
  11161. #ifdef _M_I486
  11162.     makestr(&(optlist[noptlist++]),"_M_I486");
  11163. #endif
  11164. #ifdef i486
  11165.     makestr(&(optlist[noptlist++]),"i486");
  11166. #endif
  11167. #ifdef M_I386
  11168.     makestr(&(optlist[noptlist++]),"M_I386");
  11169. #endif
  11170. #ifdef _M_I386
  11171.     makestr(&(optlist[noptlist++]),"_M_I386");
  11172. #endif
  11173. #ifdef i386
  11174.     makestr(&(optlist[noptlist++]),"i386");
  11175. #endif
  11176. #ifdef __i386
  11177.     makestr(&(optlist[noptlist++]),"__i386");
  11178. #endif
  11179. #ifdef __x86
  11180.     makestr(&(optlist[noptlist++]),"__x86");
  11181. #endif
  11182. #ifdef __amd64
  11183.     makestr(&(optlist[noptlist++]),"__amd64");
  11184. #endif
  11185. #ifdef _ILP32
  11186.     makestr(&(optlist[noptlist++]),"_ILP32");
  11187. #endif
  11188. #ifdef _ILP64
  11189.     makestr(&(optlist[noptlist++]),"_ILP64");
  11190. #endif
  11191. #ifdef _LP32
  11192.     makestr(&(optlist[noptlist++]),"_LP32");
  11193. #endif
  11194. #ifdef _LP64
  11195.     makestr(&(optlist[noptlist++]),"_LP64");
  11196. #endif
  11197. #ifdef __LP32__
  11198.     makestr(&(optlist[noptlist++]),"__LP32__");
  11199. #endif
  11200. #ifdef __LP64__
  11201.     makestr(&(optlist[noptlist++]),"__LP64__");
  11202. #endif
  11203. #ifdef _XGP4_2
  11204.     makestr(&(optlist[noptlist++]),"_XGP4_2");
  11205. #endif
  11206. #ifdef __ppc__
  11207.     makestr(&(optlist[noptlist++]),"__ppc__");
  11208. #endif
  11209. #ifdef __ppc32__
  11210.     makestr(&(optlist[noptlist++]),"__ppc32__");
  11211. #endif
  11212. #ifdef __ppc64__
  11213.     makestr(&(optlist[noptlist++]),"__ppc64__");
  11214. #endif
  11215. #ifdef CK_64BIT
  11216.     makestr(&(optlist[noptlist++]),"CK_64BIT");
  11217. #endif
  11218. #ifdef i286
  11219.     makestr(&(optlist[noptlist++]),"i286");
  11220. #endif
  11221. #ifdef M_I286
  11222.     makestr(&(optlist[noptlist++]),"M_I286");
  11223. #endif
  11224. #ifdef __sparc
  11225.     makestr(&(optlist[noptlist++]),"__sparc");
  11226. #endif
  11227. #ifdef __sparcv8
  11228.     makestr(&(optlist[noptlist++]),"__sparcv8");
  11229. #endif
  11230. #ifdef __sparcv9
  11231.     makestr(&(optlist[noptlist++]),"__sparcv9");
  11232. #endif
  11233. #ifdef mc68000
  11234.     makestr(&(optlist[noptlist++]),"mc68000");
  11235. #endif
  11236. #ifdef mc68010
  11237.     makestr(&(optlist[noptlist++]),"mc68010");
  11238. #endif
  11239. #ifdef mc68020
  11240.     makestr(&(optlist[noptlist++]),"mc68020");
  11241. #endif
  11242. #ifdef mc68030
  11243.     makestr(&(optlist[noptlist++]),"mc68030");
  11244. #endif
  11245. #ifdef mc68040
  11246.     makestr(&(optlist[noptlist++]),"mc68040");
  11247. #endif
  11248. #ifdef M_68000
  11249.     makestr(&(optlist[noptlist++]),"M_68000");
  11250. #endif
  11251. #ifdef M_68010
  11252.     makestr(&(optlist[noptlist++]),"M_68010");
  11253. #endif
  11254. #ifdef M_68020
  11255.     makestr(&(optlist[noptlist++]),"M_68020");
  11256. #endif
  11257. #ifdef M_68030
  11258.     makestr(&(optlist[noptlist++]),"M_68030");
  11259. #endif
  11260. #ifdef M_68040
  11261.     makestr(&(optlist[noptlist++]),"M_68040");
  11262. #endif
  11263. #ifdef m68k
  11264.     makestr(&(optlist[noptlist++]),"m68k");
  11265. #endif
  11266. #ifdef m88k
  11267.     makestr(&(optlist[noptlist++]),"m88k");
  11268. #endif
  11269. #ifdef pdp11
  11270.     makestr(&(optlist[noptlist++]),"pdp11");
  11271. #endif
  11272. #ifdef iAPX
  11273.     makestr(&(optlist[noptlist++]),"iAPX");
  11274. #endif
  11275. #ifdef hpux
  11276.     makestr(&(optlist[noptlist++]),"hpux");
  11277. #endif
  11278. #ifdef __hpux
  11279.     makestr(&(optlist[noptlist++]),"__hpux");
  11280. #endif
  11281. #ifdef __hp9000s800
  11282.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  11283. #endif
  11284. #ifdef __hp9000s700
  11285.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  11286. #endif
  11287. #ifdef __hp9000s500
  11288.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  11289. #endif
  11290. #ifdef __hp9000s300
  11291.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  11292. #endif
  11293. #ifdef __hp9000s200
  11294.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  11295. #endif
  11296. #ifdef AIX
  11297.     makestr(&(optlist[noptlist++]),"AIX");
  11298. #endif
  11299. #ifdef _AIXFS
  11300.     makestr(&(optlist[noptlist++]),"_AIXFS");
  11301. #endif
  11302. #ifdef u370
  11303.     makestr(&(optlist[noptlist++]),"u370");
  11304. #endif
  11305. #ifdef u3b
  11306.     makestr(&(optlist[noptlist++]),"u3b");
  11307. #endif
  11308. #ifdef u3b2
  11309.     makestr(&(optlist[noptlist++]),"u3b2");
  11310. #endif
  11311. #ifdef multimax
  11312.     makestr(&(optlist[noptlist++]),"multimax");
  11313. #endif
  11314. #ifdef balance
  11315.     makestr(&(optlist[noptlist++]),"balance");
  11316. #endif
  11317. #ifdef ibmrt
  11318.     makestr(&(optlist[noptlist++]),"ibmrt");
  11319. #endif
  11320. #ifdef _IBMRT
  11321.     makestr(&(optlist[noptlist++]),"_IBMRT");
  11322. #endif
  11323. #ifdef ibmrs6000
  11324.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  11325. #endif
  11326. #ifdef _AIX
  11327.     makestr(&(optlist[noptlist++]),"_AIX");
  11328. #endif /* _AIX */
  11329. #ifdef _IBMR2
  11330.     makestr(&(optlist[noptlist++]),"_IBMR2");
  11331. #endif
  11332. #ifdef UNIXWARE
  11333.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  11334. #endif
  11335. #ifdef QNX
  11336.     makestr(&(optlist[noptlist++]),"QNX");
  11337. #ifdef __QNX__
  11338.     makestr(&(optlist[noptlist++]),"__QNX__");
  11339. #ifdef __16BIT__
  11340.     makestr(&(optlist[noptlist++]),"__16BIT__");
  11341. #endif
  11342. #ifdef CK_QNX16
  11343.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  11344. #endif
  11345. #ifdef __32BIT__
  11346.     makestr(&(optlist[noptlist++]),"__32BIT__");
  11347. #endif
  11348. #ifdef CK_QNX32
  11349.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  11350. #endif
  11351. #endif /* __QNX__ */
  11352. #endif /* QNX */
  11353.  
  11354. #ifdef QNX6
  11355.     makestr(&(optlist[noptlist++]),"QNX6");
  11356. #endif /* QNX6 */
  11357.  
  11358. #ifdef NEUTRINO
  11359.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  11360. #endif /* NEUTRINO */
  11361.  
  11362. #ifdef __STRICT_BSD__
  11363.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  11364. #endif
  11365. #ifdef __STRICT_ANSI__
  11366.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  11367. #endif
  11368. #ifdef _ANSI_C_SOURCE
  11369.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  11370. #endif
  11371. #ifdef __STDC__
  11372.     makestr(&(optlist[noptlist++]),"__STDC__");
  11373. #endif
  11374. #ifdef cplusplus
  11375.     makestr(&(optlist[noptlist++]),"cplusplus");
  11376. #endif
  11377. #ifdef __DECC
  11378.     makestr(&(optlist[noptlist++]),"__DECC");
  11379. #ifdef __DECC_VER
  11380.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  11381.     makestr(&(optlist[noptlist++]),line);
  11382. #endif /* __DECC_VER */
  11383. #endif /* __DECC */
  11384. #ifdef __CRTL_VER
  11385.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  11386.     makestr(&(optlist[noptlist++]),line);
  11387. #endif /* __CRTL_VER */
  11388. #ifdef __GNUC__                         /* gcc in ansi mode */
  11389.     makestr(&(optlist[noptlist++]),"__GNUC__");
  11390. #endif
  11391. #ifdef GNUC                             /* gcc in traditional mode */
  11392.     makestr(&(optlist[noptlist++]),"GNUC");
  11393. #endif
  11394. #ifdef __EGCS__                         /* egcs in ansi mode */
  11395.     makestr(&(optlist[noptlist++]),"__EGCS__");
  11396. #endif
  11397. #ifdef __egcs__                         /* egcs in ansi mode */
  11398.     makestr(&(optlist[noptlist++]),"__egcs__");
  11399. #endif
  11400. #ifdef __WATCOMC__
  11401.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  11402. #endif
  11403. #ifdef CK_ANSIC
  11404.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  11405. #endif
  11406. #ifdef CK_ANSILIBS
  11407.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  11408. #endif
  11409. #ifdef CKCONINTB4CB
  11410.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  11411. #endif /* CKCONINTB4CB */
  11412. #ifdef NOTERMCAP
  11413.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  11414. #endif /* NOTERMCAP */
  11415. #ifdef __GLIBC__
  11416.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  11417. #endif
  11418. #ifdef _SC_JOB_CONTROL
  11419.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  11420. #endif
  11421. #ifdef _POSIX_JOB_CONTROL
  11422.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  11423. #endif
  11424. #ifdef SIG_I
  11425.     makestr(&(optlist[noptlist++]),"SIG_I");
  11426. #endif /* SIG_I */
  11427. #ifdef SIG_V
  11428.     makestr(&(optlist[noptlist++]),"SIG_V");
  11429. #endif /* SIG_V */
  11430. #ifdef CK_POSIX_SIG
  11431.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  11432. #endif
  11433. #ifdef SVR3JC
  11434.     makestr(&(optlist[noptlist++]),"SVR3JC");
  11435. #endif
  11436. #ifdef _386BSD
  11437.     makestr(&(optlist[noptlist++]),"_386BSD");
  11438. #endif
  11439. #ifdef _BSD
  11440.     makestr(&(optlist[noptlist++]),"_BSD");
  11441. #endif
  11442. #ifdef USE_MEMCPY
  11443.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  11444. #endif /* USE_MEMCPY */
  11445. #ifdef USE_LSTAT
  11446.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  11447. #endif /* USE_LSTAT */
  11448. #ifdef TERMIOX
  11449.     makestr(&(optlist[noptlist++]),"TERMIOX");
  11450. #endif /* TERMIOX */
  11451. #ifdef STERMIOX
  11452.     makestr(&(optlist[noptlist++]),"STERMIOX");
  11453. #endif /* STERMIOX */
  11454. #ifdef CK_CURSES
  11455.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  11456. #endif /* CK_CURSES */
  11457. #ifdef CK_NEWTERM
  11458.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  11459. #endif /* CK_NEWTERM */
  11460. #ifdef CK_WREFRESH
  11461.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  11462. #endif /* CK_WREFRESH */
  11463. #ifdef CK_PCT_BAR
  11464.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  11465. #endif /* CK_PCT_BAR */
  11466. #ifdef CK_DTRCD
  11467.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  11468. #endif /* CK_DTRCD */
  11469. #ifdef CK_DTRCTS
  11470.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  11471. #endif /* CK_DTRCTS */
  11472. #ifdef CK_RTSCTS
  11473.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  11474. #endif /* CK_RTSCTS */
  11475. #ifdef POSIX_CRTSCTS
  11476.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  11477. #endif /* POSIX_CRTSCTS */
  11478. #ifdef FIXCRTSCTS
  11479.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  11480. #endif /* FIXCRTSCTS */
  11481. #ifdef HWPARITY
  11482.     makestr(&(optlist[noptlist++]),"HWPARITY");
  11483. #endif /* HWPARITY */
  11484. #ifdef CK_SYSINI
  11485. #ifdef CK_INI_A
  11486.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  11487.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11488.     makestr(&(optlist[noptlist++]),line);
  11489. #else
  11490. #ifdef CK_INI_B
  11491.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  11492.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11493.     makestr(&(optlist[noptlist++]),line);
  11494. #else
  11495.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  11496. #endif /* CK_INI_B */
  11497. #endif /* CK_INI_A */
  11498. #endif /* CK_DSYSINI */
  11499. #ifdef CK_DSYSINI
  11500.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  11501. #endif /* CK_DSYSINI */
  11502. #ifdef CK_TTGWSIZ
  11503.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  11504. #endif /* CK_TTGWSIZ */
  11505. #ifdef CK_NAWS
  11506.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  11507. #endif /* CK_NAWS */
  11508. #ifdef MDMHUP
  11509.     makestr(&(optlist[noptlist++]),"MDMHUP");
  11510. #endif /* MDMHUP */
  11511. #ifdef HUP_CLOSE_POSIX
  11512.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  11513. #endif /* HUP_CLOSE_POSIX */
  11514. #ifdef NO_HUP_CLOSE_POSIX
  11515.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  11516. #endif /* NO_HUP_CLOSE_POSIX */
  11517. #ifdef DCMDBUF
  11518.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  11519. #endif /* DCMDBUF */
  11520. #ifdef CK_RECALL
  11521.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  11522. #endif /* CK_RECALL */
  11523. #ifdef BROWSER
  11524.     makestr(&(optlist[noptlist++]),"BROWSER");
  11525. #endif /* BROWSER */
  11526. #ifdef CLSOPN
  11527.     makestr(&(optlist[noptlist++]),"CLSOPN");
  11528. #endif /* CLSOPN */
  11529. #ifdef STRATUS
  11530.     makestr(&(optlist[noptlist++]),"STRATUS");
  11531. #endif /* STRATUS */
  11532. #ifdef __VOS__
  11533.     makestr(&(optlist[noptlist++]),"__VOS__");
  11534. #endif /* __VOS__ */
  11535. #ifdef STRATUSX25
  11536.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  11537. #endif /* STRATUSX25 */
  11538. #ifdef OS2MOUSE
  11539.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  11540. #endif /* OS2MOUSE */
  11541. #ifdef CK_REXX
  11542.     makestr(&(optlist[noptlist++]),"CK_REXX");
  11543. #endif /* CK_REXX */
  11544. #ifdef CK_TIMERS
  11545.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  11546. #endif /* CK_TIMERS */
  11547. #ifdef TTSPDLIST
  11548.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  11549. #endif /* TTSPDLIST */
  11550. #ifdef CK_PERMS
  11551.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  11552. #endif /* CK_PERMS */
  11553. #ifdef CKTUNING
  11554.     makestr(&(optlist[noptlist++]),"CKTUNING");
  11555. #endif /* CKTUNING */
  11556. #ifdef NEWFTP
  11557.     makestr(&(optlist[noptlist++]),"NEWFTP");
  11558. #endif /* NEWFTP */
  11559. #ifdef SYSFTP
  11560.     makestr(&(optlist[noptlist++]),"SYSFTP");
  11561. #endif /* SYSFTP */
  11562. #ifdef NOFTP
  11563.     makestr(&(optlist[noptlist++]),"NOFTP");
  11564. #endif /* NOFTP */
  11565. #ifdef CKHTTP
  11566.     makestr(&(optlist[noptlist++]),"CKHTTP");
  11567. #endif /* CKHTTP */
  11568. #ifdef NOHTTP
  11569.     makestr(&(optlist[noptlist++]),"NOHTTP");
  11570. #endif /* NOHTTP */
  11571. #ifdef CKROOT
  11572.     makestr(&(optlist[noptlist++]),"CKROOT");
  11573. #endif /* CKROOT */
  11574. #ifdef CKREALPATH
  11575.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  11576. #endif /* CKREALPATH */
  11577. #ifdef STREAMING
  11578.     makestr(&(optlist[noptlist++]),"STREAMING");
  11579. #endif /* STREAMING */
  11580. #ifdef UNPREFIXZERO
  11581.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11582. #endif /* UNPREFIXZERO */
  11583. #ifdef CKREGEX
  11584.     makestr(&(optlist[noptlist++]),"CKREGEX");
  11585. #endif /* CKREGEX */
  11586. #ifdef ZXREWIND
  11587.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  11588. #endif /* ZXREWIND */
  11589. #ifdef CKSYSLOG
  11590.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11591. #endif /* CKSYSLOG */
  11592. #ifdef SYSLOGLEVEL
  11593.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11594.     makestr(&(optlist[noptlist++]),line);
  11595. #endif /* SYSLOGLEVEL */
  11596. #ifdef NOSEXP
  11597.     makestr(&(optlist[noptlist++]),"NOSEXP");
  11598. #endif /* NOSEXP */
  11599. #ifdef CKLEARN
  11600.     makestr(&(optlist[noptlist++]),"CKLEARN");
  11601. #else
  11602. #ifdef NOLOEARN
  11603.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  11604. #endif /* NOLOEARN */
  11605. #endif /* CKLEARN */
  11606.  
  11607. #ifdef NOFLOAT
  11608.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  11609. #else
  11610. #ifdef FNFLOAT
  11611.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  11612. #endif /* FNFLOAT */
  11613. #ifdef CKFLOAT
  11614. #ifdef GFTIMER
  11615.     makestr(&(optlist[noptlist++]),"GFTIMER");
  11616. #endif /* GFTIMER */
  11617. #ifdef CKFLOAT_S
  11618.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11619.     makestr(&(optlist[noptlist++]),line);
  11620. #else
  11621.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  11622. #endif /* CKFLOAT_S */
  11623. #endif /* CKFLOAT */
  11624. #endif /* NOFLOAT */
  11625.  
  11626. #ifdef SSH
  11627.     makestr(&(optlist[noptlist++]),"SSH");
  11628. #endif /* SSH */
  11629. #ifdef NETDLL
  11630.     makestr(&(optlist[noptlist++]),"NETDLL");
  11631. #endif /* NETDLL */
  11632. #ifdef NETFILE
  11633.     makestr(&(optlist[noptlist++]),"NETFILE");
  11634. #endif /* NETFILE */
  11635. #ifdef CK_TAPI
  11636.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  11637. #endif /* CK_TAPI */
  11638. #ifdef CK_SSL
  11639.     makestr(&(optlist[noptlist++]),"CK_SSL");
  11640. #ifdef OPENSSL_VERSION_TEXT
  11641.     ckmakmsg(line,LINBUFSIZ,
  11642.          "OPENSSL_VERSION_TEXT=","\"",OPENSSL_VERSION_TEXT,"\"");
  11643.     makestr(&(optlist[noptlist++]),line);
  11644. #endif    /* OPENSSL_VERSION_TEXT */
  11645. #endif /* CK_SSL */
  11646.     debug(F101,"initoptlist noptlist","",noptlist);
  11647.     sh_sort(optlist,NULL,noptlist,0,0,0);
  11648. }
  11649.  
  11650. int
  11651. shofea() {
  11652.     int i;
  11653.     int flag = 0;
  11654.     int lines = 1;
  11655. #ifdef FNFLOAT
  11656.     extern int fp_digits, fp_rounding;
  11657. #endif /* FNFLOAT */
  11658.     extern int byteorder;
  11659.     printf("%s\n",versio);
  11660.     if (inserver)
  11661.       return(1);
  11662.  
  11663.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11664.     initoptlist();
  11665.     debug(F101,"shofea noptlist","",noptlist);
  11666. #ifdef OS2
  11667. #ifdef NT
  11668. #ifdef _M_ALPHA
  11669.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11670. #else /* _M_ALPHA */
  11671. #ifdef _M_PPC
  11672.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11673. #else /* _M_PPC */
  11674. #ifdef _M_MRX000
  11675.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11676. #else /* _M_MRX000 */
  11677. #ifdef _M_IX86
  11678.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11679. #else /* _M_IX86 */
  11680.     UNKNOWN WINDOWS PLATFORM
  11681. #endif /* _M_IX86 */
  11682. #endif /* _M_MRX000 */
  11683. #endif /* _M_PPC */
  11684. #endif /* _M_ALPHA */
  11685. #else /* NT */
  11686. #ifdef M_I286
  11687.     printf("IBM OS/2 16-bit.\n");
  11688. #else
  11689.     printf("IBM OS/2 32-bit.\n");
  11690. #endif /* M_I286 */
  11691. #endif /* NT */
  11692.     lines++;
  11693. #endif /* OS2 */
  11694.     printf("\n");
  11695.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11696.     printf("Major optional features included:\n");
  11697.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11698.  
  11699.     if (sizeof(CK_OFF_T) == 8) {
  11700.     printf(" Large files and large integers (64 bits)\n");
  11701.         if (++lines > cmd_rows - 3) {
  11702.         if (!askmore()) return(1); else lines = 0;
  11703.     }
  11704.     }
  11705. #ifdef NETCONN
  11706.     printf(" Network support (type SHOW NET for further info)\n");
  11707.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11708. #ifdef IKS_OPTION
  11709.     printf(" Telnet Kermit Option\n");
  11710.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11711. #endif /* IKS_OPTION */
  11712. #ifdef CK_AUTHENTICATION
  11713.     printf(" Telnet Authentication Option\n");
  11714.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11715. #ifdef CK_KERBEROS
  11716. #ifdef KRB4
  11717. #ifdef KRB5
  11718.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11719.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11720. #else /* KRB5 */
  11721.     printf(" Kerberos(TM) IV authentication\n");
  11722.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11723. #endif /* KRB5 */
  11724. #else /* KRB4 */
  11725. #ifdef KRB5
  11726.     printf(" Kerberos(TM) V authentication\n");
  11727.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11728. #endif /* KRB5 */
  11729. #endif /* KRB4 */
  11730. #endif /* CK_KERBEROS */
  11731. #ifdef CK_SRP
  11732.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11733.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11734. #endif /* CK_SRP */
  11735. #ifdef CK_SSL
  11736.     printf(" Secure Sockets Layer (SSL)\n");
  11737.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11738.     printf(" Transport Layer Security (TLS)\n");
  11739.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11740. #endif /* CK_SSL */
  11741. #ifdef SSHBUILTIN
  11742.     printf(" Secure Shell (SSH) [internal]\n");
  11743.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11744. #endif /* SSHBUILTIN */
  11745. #ifdef SSHCMD
  11746.     printf(" Secure Shell (SSH) [external]\n");
  11747.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11748. #endif /* SSHCMD */
  11749. #ifdef CK_ENCRYPTION
  11750.     printf(" Telnet Encryption Option\n");
  11751.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11752. #ifdef CK_DES
  11753.     printf(" Telnet DES Encryption\n");
  11754.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11755. #endif /* CK_DES */
  11756. #ifdef CK_CAST
  11757.     printf(" Telnet CAST Encryption\n");
  11758.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11759. #endif /* CK_CAST */
  11760.  
  11761. #ifdef CK_KERBEROS
  11762. #ifdef KRB5
  11763. #ifdef ALLOW_KRB_3DES_ENCRYPT
  11764.     printf(" Kerberos 3DES/AES Telnet Encryption\n");
  11765.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11766. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11767. #endif /* KRB5 */
  11768. #endif /* CK_KERBEROS */
  11769.  
  11770. #endif /* CK_ENCRYPTION */
  11771. #endif /* CK_AUTHENTICATION */
  11772. #ifdef CK_FORWARD_X
  11773.     printf(" X Windows forwarding\n");
  11774.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11775. #endif /* CK_FORWARD_X */
  11776. #ifdef TN_COMPORT
  11777.     printf(" Telnet Remote Com Port Control Option\n");
  11778.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11779. #endif /* TN_COMPORT */
  11780. #ifdef CK_SOCKS
  11781. #ifdef CK_SOCKS5
  11782.     printf(" SOCKS 5\n");
  11783.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11784. #else /* CK_SOCKS5 */
  11785.     printf(" SOCKS 4\n");
  11786.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11787. #endif /* CK_SOCKS5 */
  11788. #endif /* CK_SOCKS */
  11789. #ifdef NEWFTP
  11790.     printf(" Built-in FTP client\n");
  11791.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11792. #endif /* NEWFTP */
  11793. #ifdef CKHTTP
  11794.     printf(" Built-in HTTP client\n");
  11795.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11796. #endif /* CKHTTP */
  11797. #endif /* NETCONN */
  11798.  
  11799. #ifdef CK_RTSCTS
  11800.     printf(" Hardware flow control\n");
  11801.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11802. #endif /* CK_RTSCTS */
  11803.  
  11804. #ifdef CK_XYZ
  11805. #ifdef XYZ_INTERNAL
  11806.     printf(" Built-in XYZMODEM protocols\n");
  11807. #else
  11808.     printf(" External XYZMODEM protocol support\n");
  11809. #endif /* XYZ_INTERNAL */
  11810.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11811. #endif /* CK_XYZ */
  11812.  
  11813. #ifndef NOCSETS
  11814.     printf(" Latin-1 (West European) character-set translation\n");
  11815.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11816. #ifdef LATIN2
  11817.     printf(" Latin-2 (East European) character-set translation\n");
  11818.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11819. #endif /* LATIN2 */
  11820. #ifdef CYRILLIC
  11821.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11822.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11823. #endif /* CYRILLIC */
  11824. #ifdef GREEK
  11825.     printf(" Greek character-set translation\n");
  11826.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11827. #endif /* GREEK */
  11828. #ifdef HEBREW
  11829.     printf(" Hebrew character-set translation\n");
  11830.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11831. #endif /* HEBREW */
  11832. #ifdef KANJI
  11833.     printf(" Japanese character-set translation\n");
  11834.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11835. #endif /* KANJI */
  11836. #ifdef UNICODE
  11837.     printf(" Unicode character-set translation\n");
  11838.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11839. #endif /* UNICODE */
  11840. #ifdef CKOUNI
  11841.     if (isunicode())
  11842.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11843.     else
  11844.       printf(" Unicode translation for Terminal Character-Sets\n");
  11845.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11846. #endif /* CKOUNI */
  11847. #endif /* NOCSETS */
  11848.  
  11849. #ifdef NETPTY
  11850.     printf(" Pseudoterminal control\n");
  11851.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11852. #endif /* NETPTY */
  11853.  
  11854. #ifdef CK_REDIR
  11855.     printf(" REDIRECT command\n");
  11856.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11857. #endif /* CK_REDIR */
  11858.  
  11859. #ifdef CK_RESEND
  11860.     printf(" RESEND command\n");
  11861.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11862. #endif /* CK_RESEND */
  11863.  
  11864. #ifndef NOXFER
  11865. #ifdef CK_CURSES
  11866.     printf(" Fullscreen file transfer display\n");
  11867.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11868. #endif /* CK_CURSES */
  11869. #endif /* NOXFER */
  11870.  
  11871. #ifdef CK_SPEED
  11872.     printf(" Control-character unprefixing\n");
  11873.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11874. #endif /* CK_SPEED */
  11875.  
  11876. #ifdef STREAMING
  11877.     printf(" Streaming\n");
  11878.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11879. #endif /* STREAMING */
  11880.  
  11881. #ifdef CK_AUTODL
  11882.     printf(" Autodownload\n");
  11883.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11884. #endif /* CK_AUTODL */
  11885.  
  11886. #ifdef OS2MOUSE
  11887.     printf(" Mouse support\n");
  11888.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11889. #endif /* OS2MOUSE */
  11890.  
  11891. #ifdef CK_REXX
  11892.     printf(" REXX script language interface\n");
  11893.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11894. #endif /* CK_REXX */
  11895.  
  11896. #ifdef IKSD
  11897. #ifdef CK_LOGIN
  11898.     printf(" Internet Kermit Service with user login support\n");
  11899. #else /* CK_LOGIN */
  11900.     printf(" Internet Kermit Service without user login support\n");
  11901. #endif /* CK_LOGIN */
  11902.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11903. #endif /* IKSD */
  11904.  
  11905.     printf("\n");
  11906.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11907.     printf("Major optional features not included:\n");
  11908.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11909.  
  11910.     if (sizeof(CK_OFF_T) <= 4) {
  11911.     printf(" No large files or large integers\n");
  11912.         if (++lines > cmd_rows - 3) {
  11913.         if (!askmore()) return(1); else lines = 0;
  11914.     }
  11915.     }
  11916.  
  11917. #ifdef NOXFER
  11918.     printf(" No file-transfer protocols\n");
  11919.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11920.     flag = 1;
  11921. #else
  11922. #ifndef CK_CURSES
  11923. #ifndef MAC
  11924.     printf(" No fullscreen file transfer display\n");
  11925.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11926.     flag = 1;
  11927. #endif /* MAC */
  11928. #endif /* CK_CURSES */
  11929.  
  11930. #ifdef NOSERVER
  11931.     printf(" No server mode\n");
  11932.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11933.     flag = 1;
  11934. #endif /* NOSERVER */
  11935.  
  11936. #ifndef CK_SPEED
  11937.     printf(" No control-character unprefixing\n");
  11938.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11939.     flag = 1;
  11940. #endif /* CK_SPEED */
  11941.  
  11942. #ifndef STREAMING
  11943.     printf(" No streaming\n");
  11944.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11945.     flag = 1;
  11946. #endif /* STREAMING */
  11947.  
  11948. #ifndef CK_AUTODL
  11949.     printf(" No autodownload\n");
  11950.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11951.     flag = 1;
  11952. #endif /* CK_AUTODL */
  11953.  
  11954. #ifndef CK_XYZ
  11955.     printf(" No built-in XYZMODEM protocols\n");
  11956.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11957.     flag = 1;
  11958. #endif /* CK_XYZ */
  11959.  
  11960. #ifdef NOTLOG
  11961.     printf(" No transaction log\n");
  11962.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11963.     flag = 1;
  11964. #endif /* NOTLOG */
  11965. #endif /* NOXFER */
  11966.  
  11967. #ifdef NODEBUG
  11968.     printf(" No debugging\n");
  11969.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11970.     flag = 1;
  11971. #endif /* NODEBUG */
  11972.  
  11973. #ifdef NOHELP
  11974.     printf(" No built-in help\n");
  11975.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11976.     flag = 1;
  11977. #endif /* NOHELP */
  11978.  
  11979. #ifdef NOLOCAL
  11980.     printf(" No making connections\n");
  11981.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11982.     flag = 1;
  11983. #else
  11984. #ifndef NETCONN
  11985.     printf(" No network support\n");
  11986.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11987.     flag = 1;
  11988. #else /* NETCONN */
  11989. #ifndef IKS_OPTION
  11990.     printf(" No Telnet Kermit Option\n");
  11991.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11992.     flag = 1;
  11993. #endif /* IKS_OPTION */
  11994. #endif /* NETCONN */
  11995.  
  11996. #ifdef NOSSH
  11997.     printf(" No Secure Shell (SSH)\n");
  11998.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11999. #endif /* NOSSH */
  12000. #ifndef CK_AUTHENTICATION
  12001.     printf(" No Kerberos(TM) authentication\n");
  12002.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12003.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  12004.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12005.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  12006.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12007.     printf(" No Transport Layer Security (TLS) protocol\n");
  12008.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12009.     printf(" No encryption\n");
  12010.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12011.     flag = 1;
  12012. #else /* CK_AUTHENTICATION */
  12013. #ifndef CK_KERBEROS
  12014.     printf(" No Kerberos(TM) authentication\n");
  12015.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12016.     flag = 1;
  12017. #else /* CK_KERBEROS */
  12018. #ifndef KRB4
  12019.     printf(" No Kerberos(TM) IV authentication\n");
  12020.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12021.     flag = 1;
  12022. #endif /* KRB4 */
  12023. #ifndef KRB5
  12024.     printf(" No Kerberos(TM) V authentication\n");
  12025.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12026.     flag = 1;
  12027. #endif /* KRB5 */
  12028. #endif /* CK_KERBEROS */
  12029. #ifndef CK_SRP
  12030.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  12031.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12032.     flag = 1;
  12033. #endif /* CK_SRP */
  12034. #ifndef CK_SSL
  12035.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  12036.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12037.     printf(" No Transport Layer Security (TLS) protocol\n");
  12038.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12039.     flag = 1;
  12040. #endif /* CK_SSL */
  12041. #ifndef CK_ENCRYPTION
  12042.     printf(" No Telnet Encryption Option\n");
  12043.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12044.     flag = 1;
  12045. #else /* CK_ENCRYPTION */
  12046. #ifndef OS2
  12047. #ifndef CK_DES
  12048.     printf(" No Telnet DES encryption\n");
  12049.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12050.     flag = 1;
  12051. #endif /* CK_DES */
  12052. #ifndef CK_CAST
  12053.     printf(" No Telnet CAST encryption\n");
  12054.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12055.     flag = 1;
  12056. #endif /* CK_CAST */
  12057.  
  12058. #ifdef COMMENT
  12059. #ifdef CK_KERBEROS
  12060. #ifdef KRB5
  12061. #ifndef ALLOW_KRB_3DES_ENCRYPT
  12062.     printf(" No Kerberos 3DES/AES Telnet Encryption\n");
  12063.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12064. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  12065. #endif /* KRB5 */
  12066. #endif /* CK_KERBEROS */
  12067. #endif /* COMMENT */
  12068.  
  12069. #endif /* OS2 */
  12070. #endif /* CK_ENCRYPTION */
  12071. #endif /* CK_AUTHENTICATION */
  12072. #ifndef CK_FORWARD_X
  12073.     printf(" No X Windows forwarding\n");
  12074.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12075. #endif /* CK_FORWARD_X */
  12076. #ifndef TN_COMPORT
  12077.     printf(" No Telnet Remote Com Port Control Option\n");
  12078.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12079. #endif /* TN_COMPORT */
  12080. #ifndef CK_SOCKS
  12081.     printf(" No SOCKS\n");
  12082.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12083. #endif /* CK_SOCKS */
  12084. #ifndef NEWFTP
  12085.     printf(" No built-in FTP client\n");
  12086.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12087. #endif /* NEWFTP */
  12088. #ifdef NOHTTP
  12089.     printf(" No built-in HTTP client\n");
  12090.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12091. #endif /* NOHTTP */
  12092.  
  12093. #ifdef NODIAL
  12094.     printf(" No DIAL command\n");
  12095.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12096.     flag = 1;
  12097. #else
  12098. #ifdef MINIDIAL
  12099.     printf(" Support for most modem types excluded\n");
  12100.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12101.     flag = 1;
  12102. #endif /* MINIDIAL */
  12103. #endif /* NODIAL */
  12104. #endif /* NOLOCAL */
  12105.  
  12106. #ifndef CK_RTSCTS
  12107. #ifndef MAC
  12108.     printf(" No hardware flow control\n");
  12109.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12110.     flag = 1;
  12111. #endif /* MAC */
  12112. #endif /* CK_RTSCTS */
  12113.  
  12114. #ifdef NOXMIT
  12115.     printf(" No TRANSMIT command\n");
  12116.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12117.     flag = 1;
  12118. #endif /* NOXMIT */
  12119.  
  12120. #ifdef NOSCRIPT
  12121.     printf(" No SCRIPT command\n");
  12122.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12123.     flag = 1;
  12124. #endif /* NOSCRIPT */
  12125.  
  12126. #ifdef NOSPL
  12127.     printf(" No script programming features\n");
  12128.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12129.     flag = 1;
  12130. #endif /* NOSPL */
  12131.  
  12132. #ifdef NOCSETS
  12133.     printf(" No character-set translation\n");
  12134.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12135.     flag = 1;
  12136. #else
  12137.  
  12138. #ifndef LATIN2
  12139.     printf(" No Latin-2 character-set translation\n");
  12140.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12141.     flag = 1;
  12142. #endif /* LATIN2 */
  12143.  
  12144. #ifdef NOGREEK
  12145.     printf(" No Greek character-set translation\n");
  12146.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12147.     flag = 1;
  12148. #endif /* NOGREEK */
  12149.  
  12150. #ifdef NOHEBREW
  12151.     printf(" No Hebrew character-set translation\n");
  12152.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12153.     flag = 1;
  12154. #endif /* NOHEBREW */
  12155.  
  12156. #ifdef NOUNICODE
  12157.     printf(" No Unicode character-set translation\n");
  12158.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12159.     flag = 1;
  12160. #endif /* NOUNICODE */
  12161.  
  12162. #ifdef NOCYRIL
  12163.     printf(" No Cyrillic character-set translation\n");
  12164.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12165.     flag = 1;
  12166. #endif /* NOCYRIL */
  12167.  
  12168. #ifndef KANJI
  12169.     printf(" No Kanji character-set translation\n");
  12170.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12171.     flag = 1;
  12172. #endif /* KANJI */
  12173. #endif /* NOCSETS */
  12174.  
  12175. #ifdef NOCMDL
  12176.     printf(" No command-line arguments\n");
  12177.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12178.     flag = 1;
  12179. #endif /* NOCMDL */
  12180.  
  12181. #ifdef NOPUSH
  12182.     printf(" No escape to system\n");
  12183.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12184.     flag = 1;
  12185. #endif /* NOPUSH */
  12186.  
  12187. #ifdef NOJC
  12188. #ifdef UNIX
  12189.     printf(" No UNIX job control\n");
  12190.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12191.     flag = 1;
  12192. #endif /* UNIX */
  12193. #endif /* NOJC */
  12194.  
  12195. #ifdef NOSETKEY
  12196.     printf(" No SET KEY command\n");
  12197.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12198.     flag = 1;
  12199. #endif /* NOSETKEY */
  12200.  
  12201. #ifndef CK_REDIR
  12202.     printf(" No REDIRECT or PIPE command\n");
  12203.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12204.     flag = 1;
  12205. #endif /* CK_REDIR */
  12206.  
  12207. #ifdef UNIX
  12208. #ifndef NETPTY
  12209.     printf(" No pseudoterminal control\n");
  12210.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12211.     flag = 1;
  12212. #endif /* NETPTY */
  12213. #endif /* UNIX */
  12214.  
  12215. #ifndef CK_RESEND
  12216.     printf(" No RESEND command\n");
  12217.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12218.     flag = 1;
  12219. #endif /* CK_RESEND */
  12220.  
  12221. #ifdef OS2
  12222. #ifdef __32BIT__
  12223. #ifndef OS2MOUSE
  12224.     printf(" No Mouse support\n");
  12225.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12226.     flag = 1;
  12227. #endif /* __32BIT__ */
  12228. #endif /* OS2 */
  12229. #endif /* OS2MOUSE */
  12230.  
  12231. #ifdef OS2
  12232. #ifndef NT
  12233. #ifndef CK_REXX
  12234.     printf(" No REXX script language interface\n");
  12235.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12236.     flag = 1;
  12237. #endif /* CK_REXX */
  12238. #endif /* NT */
  12239. #endif /* OS2 */
  12240.  
  12241. #ifndef IKSD
  12242.     printf(" No Internet Kermit Service\n");
  12243.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12244.     flag = 1;
  12245. #endif /* IKSD */
  12246.  
  12247.     if (flag == 0) {
  12248.         printf(" None\n");
  12249.         if (++lines > cmd_rows - 3)
  12250.           { if (!askmore()) return(1); else lines = 0; }
  12251.     }
  12252.     printf("\n");
  12253.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12254.  
  12255. #ifdef CK_UTSNAME
  12256.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12257.     printf("Host info:\n");
  12258.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12259.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  12260.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12261.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  12262.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12263.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  12264.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12265.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  12266.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12267.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  12268.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12269.     printf("\n");
  12270.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12271. #endif /* CK_UTSNAME */
  12272.  
  12273. /*
  12274.   Print compile-time (-D) options, as well as C preprocessor
  12275.   predefined symbols that might affect us...
  12276. */
  12277. #ifdef KTARGET
  12278.     {
  12279.         char * s;                       /* Makefile target */
  12280.         s = KTARGET;
  12281.         if (!s) s = "";
  12282.         if (!*s) s = "(unknown)";
  12283.         printf("\n");
  12284.         if (++lines > cmd_rows - 3) {
  12285.             if (!askmore()) return(1); else lines = 0;
  12286.         }
  12287.         printf("Target: %s\n", s);
  12288.         if (++lines > cmd_rows - 3) {
  12289.             if (!askmore()) return(1); else lines = 0;
  12290.         }
  12291.     }
  12292. #endif /* KTARGET */
  12293.  
  12294. #ifdef __VERSION__
  12295. #ifdef __GNUC__
  12296.     printf("GCC version: %s\n", __VERSION__);
  12297. #else
  12298.     printf("Compiler version: %s\n", __VERSION__);
  12299. #endif /* __GNUC__ */
  12300.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12301. #endif /* __VERSION__ */
  12302.  
  12303. #ifdef __DATE__                         /* GNU and other ANSI */
  12304. #ifdef __TIME__
  12305.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  12306. #else
  12307.     printf("Compiled %s, options:\n", __DATE__);
  12308. #endif /* __TIME__ */
  12309. #else /* !__DATE__ */
  12310.     printf("Compiler options:\n");
  12311. #endif /* __DATE__ */
  12312.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12313.  
  12314.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  12315.       if (!prtopt(&lines,optlist[i]))
  12316.         return(0);
  12317.  
  12318.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12319.  
  12320. /* Sizes of data types */
  12321.  
  12322.     ckmakmsg(line,
  12323.              LINBUFSIZ,
  12324.              "byte order: ",
  12325.              byteorder ? "little" : "big",
  12326.              " endian",
  12327.              NULL
  12328.              );
  12329.     if (!prtopt(&lines,line)) return(0);
  12330.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12331.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  12332.     if (!prtopt(&lines,line)) return(0);
  12333.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  12334.     if (!prtopt(&lines,line)) return(0);
  12335.  
  12336. #ifdef COMMENT
  12337. #ifdef CK_LONGLONG
  12338.     sprintf(line,"long long=%ld",sizeof(long long)); /* SAFE */
  12339.     if (!prtopt(&lines,line)) return(0);
  12340. #endif /* CK_LONGLONG */
  12341. #endif    /* COMMENT */
  12342.  
  12343. #ifndef OS2
  12344.     /* Windows doesn't have off_t */
  12345.     sprintf(line,"off_t=%ld",sizeof(off_t)); /* SAFE */
  12346.     if (!prtopt(&lines,line)) return(0);
  12347. #endif /* OS2 */
  12348.  
  12349.     sprintf(line,"CK_OFF_T=%ld",sizeof(CK_OFF_T)); /* SAFE */
  12350.     if (!prtopt(&lines,line)) return(0);
  12351.  
  12352. #ifdef BIGBUFOK
  12353.     sprintf(line,"size_t=%ld",sizeof(size_t)); /* SAFE */
  12354.     if (!prtopt(&lines,line)) return(0);
  12355. #endif /* BIGBUFOK */
  12356.  
  12357.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  12358.     if (!prtopt(&lines,line)) return(0);
  12359.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  12360.     if (!prtopt(&lines,line)) return(0);
  12361.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  12362.     if (!prtopt(&lines,line)) return(0);
  12363.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  12364.     if (!prtopt(&lines,line)) return(0);
  12365.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  12366.     if (!prtopt(&lines,line)) return(0);
  12367. #ifdef FNFLOAT
  12368.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12369.     if (!prtopt(&lines,"floating-point:")) return(0);
  12370.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  12371.     if (!prtopt(&lines,line)) return(0);
  12372.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  12373.     if (!prtopt(&lines,line)) return(0);
  12374. #endif /* FNFLOAT */
  12375.  
  12376.     prtopt(&lines,"");
  12377.     return(0);
  12378. }
  12379. #endif /* NOSHOW */
  12380. #endif /* NOICP */
  12381.