home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / tmp4 / ckuus5.c < prev    next >
C/C++ Source or Header  |  2009-11-27  |  399KB  |  12,330 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, 2009,
  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. /* For formatted screens, "more?" prompting, etc. */
  83.  
  84. #ifdef FT18
  85. #define isxdigit(c) isdigit(c)
  86. #endif /* FT18 */
  87.  
  88. #ifdef STRATUS                          /* Stratus Computer, Inc.  VOS */
  89. #ifdef putchar
  90. #undef putchar
  91. #endif /* putchar */
  92. #define putchar(x) conoc(x)
  93. #ifdef getchar
  94. #undef getchar
  95. #endif /* getchar */
  96. #define getchar(x) coninc(0)
  97. #endif /* STRATUS */
  98.  
  99. /* External variables */
  100.  
  101. extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
  102.   binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  103.   inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  104.   zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  105.   debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
  106.   rcdactive, keepallchars, cmd_err;
  107.  
  108. #ifdef LOCUS
  109. extern int locus, autolocus;
  110. #endif /* LOCUS */
  111.  
  112. #ifndef NOMSEND
  113. extern int addlist;
  114. #endif /* NOMSEND */
  115.  
  116. #ifdef CK_SPEED
  117. extern int prefixing;
  118. #endif /* CK_SPEED */
  119.  
  120. extern int g_matchdot;
  121.  
  122. #ifdef RECURSIVE
  123. extern int recursive;
  124. #endif /* RECURSIVE */
  125. extern int xfiletype;
  126.  
  127. #ifdef IKSDCONF
  128. extern char * iksdconf;
  129. extern int iksdcf;
  130. #endif /* IKSDCONF */
  131.  
  132. #ifdef CK_RECALL
  133. extern int on_recall;
  134. #endif /* CK_RECALL */
  135.  
  136. extern int ngetpath, exitonclose;
  137. extern char * getpath[];
  138. extern CHAR * epktmsg;
  139.  
  140. extern char * snd_move;
  141. extern char * snd_rename;
  142. extern char * rcv_move;
  143. extern char * rcv_rename;
  144. extern char * g_snd_move;
  145. extern char * g_snd_rename;
  146. extern char * g_rcv_move;
  147. extern char * g_rcv_rename;
  148.  
  149. extern char * nm[];
  150.  
  151. #ifdef CK_UTSNAME
  152. extern char unm_mch[];
  153. extern char unm_mod[];
  154. extern char unm_nam[];
  155. extern char unm_rel[];
  156. extern char unm_ver[];
  157. #endif /* CK_UTSNAME */
  158.  
  159. #ifndef NOPUSH
  160. #ifndef NOFRILLS
  161. extern char editor[];
  162. extern char editfile[];
  163. extern char editopts[];
  164. #ifdef BROWSER
  165. extern char browser[];
  166. extern char browsopts[];
  167. extern char browsurl[];
  168. #endif /* BROWSER */
  169. #endif /*  NOFRILLS */
  170. #endif /* NOPUSH */
  171.  
  172. #ifndef NOFRILLS
  173. #ifndef NORENAME
  174. _PROTOTYP(VOID shorename, (void));
  175. #endif    /* NORENAME */
  176. #endif    /* NOFRILLS */
  177.  
  178. #ifndef NOSERVER
  179. extern char * x_user, * x_passwd, * x_acct;
  180. #endif /* NOSERVER */
  181.  
  182. #ifdef CKLOGDIAL
  183. extern int dialog;
  184. extern char diafil[];
  185. #endif /* CKLOGDIAL */
  186.  
  187. #ifdef CKROOT
  188. extern int ckrooterr;
  189. #endif /* CKROOT */
  190.  
  191. #ifndef NOSPL
  192. extern int cfilef, xxdot, vareval;
  193. extern char cmdfil[];
  194.  
  195. struct localvar * localhead[CMDSTKL];
  196. struct localvar * localtail = NULL;
  197. struct localvar * localnext = NULL;
  198.  
  199. _PROTOTYP( VOID shosexp, (void) );
  200. _PROTOTYP( static VOID shoinput, (void) );
  201. _PROTOTYP( static char gettok,   (void) );
  202. _PROTOTYP( static VOID factor,   (void) );
  203. _PROTOTYP( static VOID term,     (void) );
  204. _PROTOTYP( static VOID termp,    (void) );
  205. _PROTOTYP( static VOID exprp,    (void) );
  206. _PROTOTYP( static VOID expr,     (void) );
  207. _PROTOTYP( static VOID simple,   (void) );
  208. _PROTOTYP( static VOID simpler,  (void) );
  209. _PROTOTYP( static VOID simplest, (void) );
  210. _PROTOTYP( static CK_OFF_T xparse,   (void) );
  211. #endif /* NOSPL */
  212. #ifndef NOSHOW
  213. _PROTOTYP( int sho_iks, (void) );
  214. #endif /* NOSHOW */
  215.  
  216. #ifdef MAC
  217. char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
  218. char * ikprompt = "IKSD>";
  219. #else  /* Not MAC */
  220. #ifdef NOSPL
  221. #ifdef OS2
  222. char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
  223. char * ikprompt = "IKSD> ";
  224. #else
  225. char * ckprompt = "C-Kermit>";
  226. char * ikprompt = "IKSD>";
  227. #endif /* NT */
  228. #else  /* NOSPL */
  229. #ifdef OS2
  230. /* Default prompt for OS/2 and Win32 */
  231. #ifdef NT
  232. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
  233. char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
  234. #else  /* NT */
  235. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  236. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  237. #endif /* NT */
  238. #else  /* OS2 */
  239. #ifdef VMS
  240. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  241. char * ikprompt = "\\v(dir) IKSD>";
  242. #else
  243. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  244. char * ikprompt = "(\\v(dir)) IKSD>";
  245. #endif /* VMS */
  246. #endif /* NT */
  247. #endif /* NOSPL */
  248. #endif /* MAC */
  249.  
  250. #ifndef CCHMAXPATH
  251. #define CCHMAXPATH 257
  252. #endif /* CCHMAXPATH */
  253. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  254.  
  255. #ifdef TNCODE
  256. extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
  257. #endif /* TNCODE */
  258.  
  259. #ifndef NOKVERBS
  260. extern struct keytab kverbs[];          /* Table of \Kverbs */
  261. extern int nkverbs;                     /* Number of \Kverbs */
  262. #endif /* NOKVERBS */
  263.  
  264. #ifndef NOPUSH
  265. extern int nopush;
  266. #endif /* NOPUSH */
  267.  
  268. #ifdef CK_RECALL
  269. extern int cm_recall;
  270. #endif /* CK_RECALL */
  271.  
  272. extern char *ccntab[];
  273.  
  274. /* Printer stuff */
  275.  
  276. extern char *printername;
  277. extern int printpipe;
  278. #ifdef BPRINT
  279. extern int printbidi, pportparity, pportflow;
  280. extern long pportspeed;
  281. #endif /* BPRINT */
  282.  
  283. #ifdef OS2
  284. _PROTOTYP (int os2getcp, (void) );
  285. _PROTOTYP (int os2getcplist, (int *, int) );
  286. #ifdef OS2MOUSE
  287. extern int tt_mouse;
  288. #endif /* OS2MOUSE */
  289. extern int tt_update, tt_updmode, updmode, tt_utf8;
  290. #ifndef IKSDONLY
  291. extern int tt_status[];
  292. #endif /* IKSDONLY */
  293. #ifdef PCFONTS
  294. extern struct keytab term_font[];
  295. #else
  296. #ifdef KUI
  297. extern struct keytab * term_font;
  298. #endif /* KUI */
  299. #endif /* PCFONTS */
  300. extern int ntermfont, tt_font, tt_font_size;
  301. extern unsigned char colornormal, colorunderline, colorstatus,
  302.     colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  303.     colorreverse, colorcmd, coloritalic;
  304. extern int priority;
  305. extern struct keytab prtytab[];
  306. extern int nprty;
  307. char * cmdmac = NULL;
  308. #endif /* OS2 */
  309.  
  310. #ifdef VMS
  311. _PROTOTYP (int zkermini, (char *, int, char *) );
  312. #endif /* VMS */
  313.  
  314. extern long vernum;
  315. extern int inecho, insilence, inbufsize, nvars, inintr;
  316. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  317.  *cknetv, *clcmds;
  318. #ifdef OS2
  319. extern char *ckyv;
  320. #endif /* OS2 */
  321. #ifdef CK_AUTHENTICATION
  322. extern char * ckathv;
  323. #endif /* CK_AUTHENTICATION */
  324. #ifdef CK_SSL
  325. extern char * cksslv;
  326. #endif /* CK_SSL */
  327. #ifdef CK_ENCRYPTION
  328. #ifndef CRYPT_DLL
  329. extern char * ckcrpv;
  330. #endif /* CRYPT_DLL */
  331. #endif /* CK_ENCRYPTION */
  332.  
  333. #ifdef SSHBUILTIN
  334. extern char *cksshv;
  335. #ifdef SFTP_BUILTIN
  336. extern char *cksftpv;
  337. #endif /* SFTP_BUILTIN */
  338. #endif /* SSHBUILTIN */
  339.  
  340. #ifdef TNCODE
  341. extern char *cktelv;
  342. #endif /* TNCODE */
  343. #ifndef NOFTP
  344. #ifndef SYSFTP
  345. extern char * ckftpv;
  346. #endif /* SYSFTP */
  347. #endif /* NOFTP */
  348.  
  349. extern int srvidl;
  350.  
  351. #ifdef OS2
  352. extern char *ckonetv;
  353. extern int interm;
  354. #ifdef CK_NETBIOS
  355. extern char *ckonbiv;
  356. #endif /* CK_NETBIOS */
  357. #ifdef OS2MOUSE
  358. extern char *ckomouv;
  359. #endif /* OS2MOUSE */
  360. #endif /* OS2 */
  361.  
  362. #ifndef NOLOCAL
  363. extern char *connv;
  364. #endif /* NOLOCAL */
  365. #ifndef NODIAL
  366. extern char *dialv;
  367. #endif /* NODIAL */
  368. #ifndef NOSCRIPT
  369. extern char *loginv;
  370. extern int secho;
  371. #endif /* NOSCRIPT */
  372.  
  373. #ifndef NODIAL
  374. extern int nmdm, dirline;
  375. extern struct keytab mdmtab[];
  376. #endif /* NODIAL */
  377.  
  378. extern int network, nettype, ttnproto;
  379.  
  380. #ifdef OS2
  381. #ifndef NOTERM
  382. /* SET TERMINAL items... */
  383. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  384. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  385. extern char answerback[];
  386. extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
  387. extern int max_tt;
  388. #endif /* NOTERM */
  389. #endif /* OS2 */
  390.  
  391. _PROTOTYP( VOID shotrm, (void) );
  392. _PROTOTYP( int shofea, (void) );
  393.  
  394. #ifdef OS2
  395. extern int tt_rows[], tt_cols[];
  396. #else /* OS2 */
  397. extern int tt_rows, tt_cols;
  398. #endif /* OS2 */
  399. extern int cmd_rows, cmd_cols;
  400.  
  401. #ifdef CK_TMPDIR
  402. extern int f_tmpdir;                    /* Directory changed temporarily */
  403. extern char savdir[];                   /* Temporary directory */
  404. #endif /* CK_TMPDIR */
  405.  
  406. #ifndef NOLOCAL
  407. extern int tt_crd, tt_lfd, tt_escape;
  408. #endif /* NOLOCAL */
  409.  
  410. #ifndef NOCSETS
  411. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  412. extern struct keytab fcstab[];
  413. extern struct csinfo fcsinfo[];
  414. #ifndef MAC
  415. extern struct keytab ttcstab[];
  416. #endif /* MAC */
  417. #endif /* NOCSETS */
  418.  
  419. extern long speed;
  420.  
  421. #ifndef NOXMIT
  422. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  423. extern char xmitbuf[];
  424. #endif /* NOXMIT */
  425.  
  426. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  427.  
  428. #ifdef DCMDBUF
  429. extern char *cmdbuf, *atmbuf;           /* Command buffers */
  430. #ifndef NOSPL
  431. extern char *savbuf;                    /* Command buffers */
  432. #endif /* NOSPL */
  433. #else
  434. extern char cmdbuf[], atmbuf[];         /* Command buffers */
  435. #ifndef NOSPL
  436. extern char savbuf[];                   /* Command buffers */
  437. #endif /* NOSPL */
  438. #endif /* DCMDBUF */
  439.  
  440. extern char toktab[], ttname[], psave[];
  441. extern CHAR sstate, feol;
  442. extern int cmflgs, techo, repars, ncmd;
  443. extern struct keytab cmdtab[];
  444.  
  445. #ifndef NOSETKEY
  446. KEY *keymap;
  447. #ifndef OS2
  448. #define mapkey(x) keymap[x]
  449. #endif /* OS2 */
  450. MACRO *macrotab;
  451. _PROTOTYP( VOID shostrdef, (CHAR *) );
  452. #endif /* NOSETKEY */
  453.  
  454. extern int cmdlvl;
  455.  
  456. #ifndef NOSPL
  457. extern struct mtab *mactab;
  458. extern struct keytab mackey[];
  459. extern struct keytab vartab[], fnctab[], iftab[];
  460. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  461. #endif /* NOSPL */
  462.  
  463. FILE *tfile[MAXTAKE];                   /* TAKE file stack */
  464. char *tfnam[MAXTAKE];
  465. int tfline[MAXTAKE];
  466.  
  467. int topcmd = -1;                        /* cmdtab index of current command */
  468. int havetoken = 0;
  469. extern int dblquo;                      /* Doublequoting enabled */
  470.  
  471. #ifdef DCMDBUF                          /* Initialization filespec */
  472. char *kermrc = NULL;
  473. #else
  474. char kermrcb[KERMRCL];
  475. char *kermrc = kermrcb;
  476. #endif /* DCMDBUF */
  477.  
  478. int noherald = 0;
  479. int cm_retry = 1;                       /* Command retry enabled */
  480. xx_strp xxstring = zzstring;
  481.  
  482. #ifndef NOXFER
  483. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  484.   keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  485.   srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  486.   fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  487.  
  488. #ifdef CK_AUTODL
  489. extern int inautodl, cmdadl;
  490. #endif /* CK_AUTODL */
  491.  
  492. #ifndef NOSERVER
  493. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  494.   en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  495.   en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  496. #endif /* NOSERVER */
  497.  
  498. extern int atcapr,
  499.   atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  500.   attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  501.  
  502. #ifdef STRATUS
  503. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  504. #endif /* STRATUS */
  505.  
  506. #ifdef CK_PERMS
  507. extern int atlpri, atlpro, atgpri, atgpro;
  508. #endif /* CK_PERMS */
  509.  
  510. #ifdef CK_LOGIN
  511. extern char * anonfile;                 /* Anonymous login init file */
  512. extern char * anonroot;                 /* Anonymous file-system root */
  513. extern char * userfile;                 /* Forbidden user file */
  514. extern int isguest;                     /* Flag for anonymous user */
  515. #endif /* CK_LOGIN */
  516. #endif /* NOXFER */
  517.  
  518. #ifdef DCMDBUF
  519. int *xquiet = NULL;
  520. int *xvarev = NULL;
  521. #else
  522. int xquiet[CMDSTKL];
  523. int xvarev[CMDSTKL];
  524. #endif /* DCMDBUF */
  525.  
  526. char * prstring[CMDSTKL];
  527.  
  528. #ifndef NOSPL
  529.  
  530. extern long ck_alarm;
  531. extern char alrm_date[], alrm_time[];
  532.  
  533. /* Local declarations */
  534.  
  535. static int nulcmd = 0;                  /* Flag for next cmd to be ignored */
  536.  
  537. /* Definitions for predefined macros */
  538.  
  539. /* First, the single-line macros, installed with addmac()... */
  540.  
  541. /* IBM-LINEMODE macro */
  542. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  543.  
  544. /* FATAL macro */
  545. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  546.  
  547. #ifdef CK_SPEED
  548. #ifdef IRIX65
  549. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  550. #else
  551. #ifdef IRIX
  552. /* Because of bug in telnet server */
  553. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  554.  set pref cautious";
  555. #else
  556. #ifdef pdp11
  557. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  558. #else
  559. #ifdef BIGBUFOK
  560. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  561. #else
  562. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  563. #endif /* BIGBUFOK */
  564. #endif /* IRIX */
  565. #endif /* IRIX65 */
  566. #endif /* pdp11 */
  567. #ifdef pdp11
  568. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  569. #else
  570. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  571. #endif /* pdp11 */
  572. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  573. set reliable off, set clearchannel off";
  574. #else
  575. #ifdef BIGBUFOK
  576. #ifdef IRIX65
  577. char *m_fast = "set win 30, set rec pack 4000";
  578. #else
  579. #ifdef IRIX
  580. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  581. #else
  582. char *m_fast = "set win 30, set rec pack 4000";
  583. #endif /* IRIX */
  584. #endif /* IRIX65 */
  585. #else /* Not BIGBUFOK */
  586. char *m_fast = "set win 4, set rec pack 2200";
  587. #endif /* BIGBUFOK */
  588. char *m_cautious = "set win 4, set rec pack 1000";
  589. char *m_robust = "set win 1, set rec pack 90, set reliable off";
  590. #endif /* CK_SPEED */
  591.  
  592. #ifdef VMS
  593. char *m_purge = "run purge \\%*";
  594. #endif /* VMS */
  595.  
  596. #ifdef OS2
  597. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  598. #endif /* OS2 */
  599.  
  600. /* Now the multiline macros, defined with addmmac()... */
  601.  
  602. /* FOR macro for \%i-style loop variables (see dofor()...) */
  603.  
  604. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  605. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  606. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  607. "def break goto _..bot, def continue goto _..inc,",
  608. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  609. ""};
  610.  
  611. /* This is the FOR macro when the loop variable is itself a macro */
  612.  
  613. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  614. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  615. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  616. "def break goto _..bot, def continue goto _..inc,",
  617. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  618. ""};
  619.  
  620. /* WHILE macro */
  621. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  622. ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
  623. "_def break goto _..bot, _def continue goto _..inc,",
  624. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  625. ""};
  626.  
  627. /* SWITCH macro */
  628. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  629. "_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  630. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  631. ""};
  632.  
  633. /* XIF macro */
  634. char *xif_def[] = {
  635. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  636. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  637. ""};
  638.  
  639. /*
  640.   Variables declared here for use by other ckuus*.c modules.
  641.   Space is allocated here to save room in ckuusr.c.
  642. */
  643. #ifdef DCMDBUF
  644. struct cmdptr *cmdstk;
  645. int
  646.   *ifcmd  = NULL,
  647.   *count  = NULL,
  648.   *iftest = NULL,
  649.   *intime = NULL,
  650.   *inpcas = NULL,
  651.   *takerr = NULL,
  652.   *merror = NULL;
  653. #else
  654. struct cmdptr cmdstk[CMDSTKL];
  655. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  656.   inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  657. #endif /* DCMDBUF */
  658.  
  659. /* Macro stack */
  660.  
  661. #ifdef COMMENT
  662. char *topline = NULL;                   /* Program invocation arg line */
  663. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  664. #endif /* COMMENT */
  665.  
  666. char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
  667. int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
  668. char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
  669. int macargc[MACLEVEL];                  /* Argc of each level */
  670. char *macp[MACLEVEL];                   /* Current position in each macro */
  671. char *macx[MACLEVEL];                   /* Beginning of each macro def */
  672. char *mrval[MACLEVEL];                  /* RETURN value at each level */
  673. int lastcmd[MACLEVEL];                  /* Last command at each level */
  674. int topargc = 0;                        /* Argc at top level */
  675. char **topxarg = NULL;                  /* Argv at top level */
  676. char *toparg[MAXARGLIST+2];
  677.  
  678. /* Global Variables */
  679.  
  680. char *g_var[GVARS+1];                   /* Global \%a..z pointers */
  681. extern char varnam[];                   /* \%x variable name buffer */
  682.  
  683. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  684. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  685.  
  686. char **a_ptr[32];                       /* Array pointers, for arrays a-z */
  687. int a_dim[32];                          /* Dimensions for each array */
  688. int a_link[32];                         /* Link (index of linked-to-array) */
  689.  
  690. char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
  691. int aa_dim[CMDSTKL][32];                /* Dimensions for each array */
  692.  
  693. /* INPUT command buffers and variables */
  694.  
  695. char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
  696. extern char * inpbp;                    /* Global/static pointer to it  */
  697. char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
  698. int  incount = 0;                       /* INPUT character count */
  699. extern int instatus;                    /* INPUT status */
  700. static char * i_text[] = {              /* INPUT status text */
  701.     "success", "timeout", "interrupted", "internal error", "i/o error"
  702. };
  703.  
  704. char lblbuf[LBLSIZ];                    /* Buffer for labels */
  705.  
  706. #else  /* NOSPL */
  707.  
  708. int takerr[MAXTAKE];
  709. #endif /* NOSPL */
  710.  
  711. static char *prevdir = NULL;
  712.  
  713. int pacing = 0;                         /* OUTPUT pacing */
  714.  
  715. char *tp;                               /* Temporary buffer pointer */
  716.  
  717. int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */
  718.  
  719. #ifdef CK_APC                           /* Application Program Command (APC) */
  720. int apcactive = APC_INACTIVE;
  721. int apcstatus = APC_OFF;                /* OFF by default everywhere */
  722. #ifdef DCMDBUF
  723. char *apcbuf;
  724. #else
  725. char apcbuf[APCBUFLEN];
  726. #endif /* DCMDBUF */
  727. #endif /* CK_APC */
  728.  
  729. extern char pktfil[],
  730. #ifdef DEBUG
  731.   debfil[],
  732. #endif /* DEBUG */
  733. #ifdef TLOG
  734.   trafil[],
  735. #endif /* TLOG */
  736.   sesfil[];
  737.  
  738. #ifndef NOFRILLS
  739. extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
  740. extern char optbuf[];
  741. #endif /* NOFRILLS */
  742.  
  743. extern int noinit;            /* Flat to skip init file */
  744.  
  745. #ifndef NOSPL
  746. static struct keytab kcdtab[] = {    /* Symbolic directory names */
  747. #ifdef NT
  748.     { "appdata",  VN_APPDATA,   0 },
  749.     { "common",   VN_COMMON,    0 },
  750.     { "desktop",  VN_DESKTOP,   0 },
  751. #endif /* NT */
  752.     { "download", VN_DLDIR,     0 },
  753. #ifdef OS2ORUNIX
  754.     { "exedir",   VN_EXEDIR,    0 },
  755. #endif /* OS2ORUNIX */
  756.     { "home",     VN_HOME,      0 },
  757.     { "inidir",   VN_INI,       0 },
  758. #ifdef UNIX
  759.     { "lockdir",  VN_LCKDIR,    0 },
  760. #endif /* UNIX */
  761. #ifdef NT
  762.     { "my_documents",VN_PERSONAL,  0 },
  763.     { "personal", VN_PERSONAL,  CM_INV },
  764. #endif /* NT */
  765.     { "startup",  VN_STAR,      0 },
  766.     { "textdir",  VN_TXTDIR,    0 },
  767.     { "tmpdir",   VN_TEMP,      0 }
  768. };
  769. static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
  770. #endif /* NOSPL */
  771.  
  772. #ifndef NOSPL
  773. _PROTOTYP( VOID freelocal, (int) );
  774. _PROTOTYP( static CK_OFF_T expon, (CK_OFF_T, CK_OFF_T) );
  775. _PROTOTYP( static CK_OFF_T gcd, (CK_OFF_T, CK_OFF_T) );
  776. _PROTOTYP( static CK_OFF_T fact, (CK_OFF_T) );
  777.  
  778. int                     /* Initialize macro data structures. */
  779. macini() {              /* Allocate mactab and preset the first element. */
  780.     int i;
  781.     if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  782.       return(-1);
  783.     mactab[0].kwd = NULL;
  784.     mactab[0].mval = NULL;
  785.     mactab[0].flgs = 0;
  786.     for (i = 0; i < MACLEVEL; i++)
  787.       localhead[i] = NULL;
  788.     return(0);
  789. }
  790. #endif /* NOSPL */
  791.  
  792. /*  C M D S R C  --  Returns current command source  */
  793.  
  794. /*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  795.  
  796. /*
  797.   As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  798.   xcmdsrc can be checked instead to save the overhead of a function call.
  799. */
  800. int
  801. cmdsrc() {
  802. #ifdef COMMENT
  803.     return(xcmdsrc);
  804. #else
  805. #ifndef NOSPL
  806.     if (cmdlvl == 0)
  807.       return(0);
  808.     else if (cmdstk[cmdlvl].src == CMD_MD)
  809.       return(2);
  810.     else if (cmdstk[cmdlvl].src == CMD_TF)
  811.       return(1);
  812.     else
  813.       return(-1);
  814. #else
  815.     if (tlevel < 0)
  816.       return(0);
  817.     else
  818.       return(1);
  819. #endif /* NOSPL */
  820. #endif /* COMMENT */
  821. }
  822.  
  823. /*  C M D I N I  --  Initialize the interactive command parser  */
  824.  
  825. static int cmdinited = 0;               /* Command parser initialized */
  826. extern int cmdint;                      /* Interrupts are allowed */
  827. #ifdef CK_AUTODL
  828. int cmdadl = 1;                         /* Autodownload */
  829. #else
  830. int cmdadl = 0;
  831. #endif /* CK_AUTODL */
  832.  
  833. char * k_info_dir = NULL;               /* Where to find text files */
  834. #ifdef UNIX
  835. static char * txtdir[] = {
  836.     "/usr/local/doc/",                  /* Linux, SunOS, ... */
  837.     "/usr/share/lib/",                  /* HP-UX 10.xx... */
  838.     "/usr/share/doc/",                  /* Other possibilities... */
  839.     "/usr/local/lib/",                  /* NOTE: Each of these is tried */
  840.     "/usr/local/share/",                /* as is, and also with a kermit */
  841.     "/usr/local/share/doc/",            /* subdirectory. */
  842.     "/usr/local/share/lib/",
  843.     "/opt/kermit/",                     /* Solaris */
  844.     "/opt/kermit/doc/",
  845.     "/opt/",
  846.     "/usr/doc/",
  847.     "/doc/",
  848.     ""
  849. };
  850. #endif /* UNIX */
  851.  
  852. /*
  853.   lookup() cache to speed up script execution.
  854.  
  855.   This is a static cache.  Items are stored in decreasing frequency of
  856.   reference based on statistics from a range of scripts.  This gives
  857.   better performance than a dynamic cache, which would require a lot more
  858.   code and also would require system-dependent elements including system
  859.   calls (e.g. to get subsecond times for entry aging).
  860. */
  861. #ifdef USE_LUCACHE                      /* Set in ckuusr.h */
  862. #define LUCACHE 32                      /* Change this to reduce cache size */
  863. int lusize = 0;
  864. char * lucmd[LUCACHE];
  865. int luval[LUCACHE];
  866. int luidx[LUCACHE];
  867. struct keytab * lutab[LUCACHE];
  868. #endif /* USE_LUCACHE */
  869.  
  870. static VOID
  871. luinit() {                              /* Initialize lookup() cache */
  872.     int x, y;
  873.  
  874. #ifdef USE_LUCACHE
  875.     x = lookup(cmdtab,"if",ncmd,&y);
  876.     lucmd[lusize] = "if";
  877.     luval[lusize] = x;
  878.     luidx[lusize] = y;
  879.     lutab[lusize] = cmdtab;
  880.     if (++lusize > LUCACHE) return;
  881.  
  882.     x = lookup(iftab,"not",nif,&y);
  883.     lucmd[lusize] = "not";
  884.     luval[lusize] = x;
  885.     luidx[lusize] = y;
  886.     lutab[lusize] = iftab;
  887.     if (++lusize > LUCACHE) return;
  888.  
  889.     x = lookup(vartab,"cmdlevel",nvars,&y);
  890.     lucmd[lusize] = "cmdlevel";
  891.     luval[lusize] = x;
  892.     luidx[lusize] = y;
  893.     lutab[lusize] = vartab;
  894.     if (++lusize > LUCACHE) return;
  895.  
  896.     x = lookup(cmdtab,"goto",ncmd,&y);
  897.     lucmd[lusize] = "goto";
  898.     luval[lusize] = x;
  899.     luidx[lusize] = y;
  900.     lutab[lusize] = cmdtab;
  901.     if (++lusize > LUCACHE) return;
  902.  
  903.     x = lookup(iftab,">",nif,&y);
  904.     lucmd[lusize] = ">";
  905.     luval[lusize] = x;
  906.     luidx[lusize] = y;
  907.     lutab[lusize] = iftab;
  908.     if (++lusize > LUCACHE) return;
  909.  
  910.     x = lookup(cmdtab,"incr",ncmd,&y);
  911.     lucmd[lusize] = "incr";
  912.     luval[lusize] = x;
  913.     luidx[lusize] = y;
  914.     lutab[lusize] = cmdtab;
  915.     if (++lusize > LUCACHE) return;
  916.  
  917.     x = lookup(cmdtab,"def",ncmd,&y);
  918.     lucmd[lusize] = "def";
  919.     luval[lusize] = x;
  920.     luidx[lusize] = y;
  921.     lutab[lusize] = cmdtab;
  922.     if (++lusize > LUCACHE) return;
  923.  
  924.     x = lookup(cmdtab,"_assign",ncmd,&y);
  925.     lucmd[lusize] = "_assign";
  926.     luval[lusize] = x;
  927.     luidx[lusize] = y;
  928.     lutab[lusize] = cmdtab;
  929.     if (++lusize > LUCACHE) return;
  930.  
  931.     x = lookup(cmdtab,"echo",ncmd,&y);
  932.     lucmd[lusize] = "echo";
  933.     luval[lusize] = x;
  934.     luidx[lusize] = y;
  935.     lutab[lusize] = cmdtab;
  936.     if (++lusize > LUCACHE) return;
  937.  
  938.     x = lookup(fnctab,"eval",nfuncs,&y);
  939.     lucmd[lusize] = "eval";
  940.     luval[lusize] = x;
  941.     luidx[lusize] = y;
  942.     lutab[lusize] = fnctab;
  943.     if (++lusize > LUCACHE) return;
  944.  
  945.     x = lookup(fnctab,"lit",nfuncs,&y);
  946.     lucmd[lusize] = "lit";
  947.     luval[lusize] = x;
  948.     luidx[lusize] = y;
  949.     lutab[lusize] = fnctab;
  950.     if (++lusize > LUCACHE) return;
  951.  
  952.     x = lookup(cmdtab,"do",ncmd,&y);
  953.     lucmd[lusize] = "do";
  954.     luval[lusize] = x;
  955.     luidx[lusize] = y;
  956.     lutab[lusize] = cmdtab;
  957.     if (++lusize > LUCACHE) return;
  958.  
  959.     x = lookup(cmdtab,"_getargs",ncmd,&y);
  960.     lucmd[lusize] = "_getargs";
  961.     luval[lusize] = x;
  962.     luidx[lusize] = y;
  963.     lutab[lusize] = cmdtab;
  964.     if (++lusize > LUCACHE) return;
  965.  
  966.     x = lookup(iftab,"<",nif,&y);
  967.     lucmd[lusize] = "<";
  968.     luval[lusize] = x;
  969.     luidx[lusize] = y;
  970.     lutab[lusize] = iftab;
  971.     if (++lusize > LUCACHE) return;
  972.  
  973.     x = lookup(cmdtab,"_putargs",ncmd,&y);
  974.     lucmd[lusize] = "_putargs";
  975.     luval[lusize] = x;
  976.     luidx[lusize] = y;
  977.     lutab[lusize] = cmdtab;
  978.     if (++lusize > LUCACHE) return;
  979.  
  980.     x = lookup(cmdtab,"asg",ncmd,&y);
  981.     lucmd[lusize] = "asg";
  982.     luval[lusize] = x;
  983.     luidx[lusize] = y;
  984.     lutab[lusize] = cmdtab;
  985.     if (++lusize > LUCACHE) return;
  986.  
  987.     x = lookup(cmdtab,"else",ncmd,&y);
  988.     lucmd[lusize] = "else";
  989.     luval[lusize] = x;
  990.     luidx[lusize] = y;
  991.     lutab[lusize] = cmdtab;
  992. #endif /* USE_LUCACHE */
  993. }
  994.  
  995. VOID
  996. cmdini() {
  997.     int i = 0, x = 0, y = 0, z = 0, skip = 0;
  998.     char * p;
  999. #ifdef TTSPDLIST
  1000.     long * ss = NULL;
  1001.     extern int nspd;
  1002.     extern struct keytab * spdtab;
  1003. #endif /* TTSPDLIST */
  1004.  
  1005. #ifndef NOSPL
  1006. /*
  1007.   On stack to allow recursion!
  1008. */
  1009.     char vnambuf[VNAML];                /* Buffer for variable names */
  1010. #endif /* NOSPL */
  1011.  
  1012.     if (cmdinited)                      /* Already initialized */
  1013.       return;                           /* Don't do it again */
  1014.  
  1015.     for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
  1016.       prstring[i] = NULL;               /* command level */
  1017.  
  1018. #ifndef NOCSETS
  1019.     p = getenv("K_CHARSET");            /* Set default file character set */
  1020.     if (p) {                            /* from environment */
  1021.         x = lookup(fcstab,p,nfilc,&y);
  1022.         if (x > -1)
  1023.           fcharset = x;
  1024.     }
  1025. #endif /* NOCSETS */
  1026.  
  1027.     p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
  1028.     if (p && *p && strlen(p) <= CKMAXPATH)
  1029.       makestr(&k_info_dir,p);
  1030.     if (!k_info_dir) {
  1031.         p = getenv("K_INFO_DIR");
  1032.         if (p && *p && strlen(p) <= CKMAXPATH)
  1033.           makestr(&k_info_dir,p);
  1034.     }
  1035. #ifdef UNIX
  1036.     if (k_info_dir) {                   /* Look for Kermit docs directory */
  1037.         if (zchki(k_info_dir) == -2) {
  1038.             char xbuf[CKMAXPATH+32], *s = "";
  1039.             if (ckrchar(k_info_dir) != '/')
  1040.               s = "/";
  1041.             ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  1042.             if (zchki(xbuf) < 0)
  1043.               makestr(&k_info_dir,NULL);
  1044.         }
  1045.     }
  1046.     if (!k_info_dir) {
  1047.         char xbuf[CKMAXPATH+32];
  1048.         int i;
  1049.         for (i = 0; *(txtdir[i]); i++) {
  1050.             ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  1051.             if (zchki(xbuf) > 0) {
  1052.                 makestr(&k_info_dir,txtdir[i]);
  1053.                 debug(F110,"k_info_dir 1",k_info_dir,0);
  1054.                 break;
  1055.             }
  1056.             ckmakmsg(xbuf,CKMAXPATH+32,
  1057.                      txtdir[i],"kermit/","ckubwr.txt",NULL);
  1058.             if (zchki(xbuf) > 0) {
  1059.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  1060.                 makestr(&k_info_dir,xbuf);
  1061.                 debug(F110,"k_info_dir 2",k_info_dir,0);
  1062.                 break;
  1063.             }
  1064.             ckmakmsg(xbuf,CKMAXPATH+32,
  1065.                      txtdir[i],"ckermit/","ckubwr.txt",NULL);
  1066.             if (zchki(xbuf) > 0) {
  1067.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
  1068.                 makestr(&k_info_dir,xbuf);
  1069.                 debug(F110,"k_info_dir 3",k_info_dir,0);
  1070.                 break;
  1071.             }
  1072.         }
  1073.         if (k_info_dir) {               /* Make sure it ends with "/" */
  1074.             if (ckrchar(k_info_dir) != '/') {
  1075.                 char xbuf[CKMAXPATH+32];
  1076.                 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1077.                 makestr(&k_info_dir,xbuf);
  1078.             }
  1079.         }
  1080.     }
  1081. #else
  1082. #ifdef OS2
  1083.     {
  1084.         char xdir[CKMAXPATH+8], *s = "";
  1085.         extern char startupdir[];
  1086.         xdir[0] = NUL;
  1087.         if (ckrchar(startupdir) != '/')
  1088.           s = "/";
  1089.         if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1090.           ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1091.         makestr(&k_info_dir,xdir);
  1092.     }
  1093. #endif /* OS2 */
  1094. #endif /* UNIX */
  1095.  
  1096. #ifdef TTSPDLIST
  1097.     if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1098.         int j, k, m = 0, n;             /* Create sorted keyword table */
  1099.         char buf[16];
  1100.         char * p;
  1101.         if ((spdtab =
  1102.              (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1103.             for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1104.                 if (ss[i] < 1L) break;     /* Shouldn't happen */
  1105.                 buf[0] = NUL;              /* Make string */
  1106.                 sprintf(buf,"%ld",ss[i]);  /* SAFE */
  1107.                 if (ss[i] == 8880L)
  1108.                   ckstrncpy(buf,"75/1200",sizeof(buf));
  1109.                 if (ss[i] == 134L)
  1110.                   ckstrncat(buf,".5",16);
  1111.                 n = strlen(buf);
  1112.                 if ((n > 0) && (p = (char *)malloc(n+1))) {
  1113.                     if (m > 0) {        /* Have at least one in list */
  1114.                         for (j = 0;     /* Find slot */
  1115.                              j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1116.                              j++
  1117.                              )
  1118.                           ;
  1119.                         if (j < m) {    /* Must insert */
  1120.                             for (k = m-1; k >= j; k--) { /* Move others down */
  1121.                                 spdtab[k+1].kwd = spdtab[k].kwd;
  1122.                                 spdtab[k+1].flgs = spdtab[k].flgs;
  1123.                                 spdtab[k+1].kwval = spdtab[k].kwval;
  1124.                             }
  1125.                         }
  1126.                     } else              /* First one */
  1127.                       j = 0;
  1128.                     ckstrncpy(p,buf,n+1); /* Add new speed */
  1129.                     spdtab[j].kwd = p;
  1130.                     spdtab[j].flgs = 0;
  1131.                     spdtab[j].kwval = (int) ss[i] / 10;
  1132.                     m++;                /* Count this one */
  1133.                 }
  1134.             }
  1135.         }
  1136.         nspd = m;
  1137.     }
  1138. #endif /* TTSPDLIST */
  1139.  
  1140. #ifndef NOSPL
  1141.     /* Allocate INPUT command buffer */
  1142.     if (!inpbuf) {
  1143.         if (!(inpbuf = (char *) malloc(INPBUFSIZ+8)))
  1144.           fatal("cmdini: no memory for INPUT buffer");
  1145.     }
  1146.     for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
  1147.       inpbuf[x] = NUL;
  1148.     inpbp = inpbuf;                     /* Initialize pointer */
  1149.     inbufsize = INPBUFSIZ;              /* and size. */
  1150. #endif /* NOSPL */
  1151.  
  1152. #ifdef DCMDBUF
  1153.     if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1154.  
  1155. #ifndef NOSPL
  1156.     /* Allocate command stack allowing command parser to call itself */
  1157.  
  1158.     if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1159.       fatal("cmdini: no memory for cmdstk");
  1160.     if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1161.       fatal("cmdini: no memory for ifcmd");
  1162.     if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1163.       fatal("cmdini: no memory for count");
  1164.     if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1165.       fatal("cmdini: no memory for iftest");
  1166.     if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1167.       fatal("cmdini: no memory for intime");
  1168.     if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1169.       fatal("cmdini: no memory for inpcas");
  1170.     if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1171.       fatal("cmdini: no memory for takerr");
  1172.     if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1173.       fatal("cmdini: no memory for merror");
  1174.     if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1175.       fatal("cmdini: no memory for xquiet");
  1176.     if (!(xvarev = (int *) malloc(sizeof(int)*CMDSTKL)))
  1177.       fatal("cmdini: no memory for xvarev");
  1178.     if (!kermrc)
  1179.       if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1180.         fatal("cmdini: no memory for kermrc");
  1181. #ifdef CK_APC
  1182. /* Application Program Command buffer */
  1183.     if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1184.         fatal("cmdini: no memory for apcbuf");
  1185. #endif /* CK_APC */
  1186. #endif /* NOSPL */
  1187.  
  1188. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1189.  
  1190.     if (!(line = malloc(LINBUFSIZ + 1)))
  1191.         fatal("cmdini: no memory for line");
  1192.     if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1193.         fatal("cmdini: no memory for tmpbuf");
  1194. #endif /* DCMDBUF */
  1195.  
  1196. #ifndef NOSPL
  1197. #ifdef CK_MINPUT
  1198.     {                                   /* Initialize MINPUT pointers */
  1199.         int i;
  1200.         extern char *ms[];
  1201.         for (i = 0; i < MINPMAX; i++)
  1202.           ms[i] = NULL;
  1203.     }
  1204. #endif /* CK_MINPUT */
  1205.  
  1206.     if (macini() < 0)                   /* Allocate macro buffers */
  1207.       fatal("Can't allocate macro buffers!");
  1208.  
  1209.     ifcmd[0] = 0;                       /* Command-level related variables. */
  1210.     iftest[0] = 0;                      /* Initialize variables at top level */
  1211.     count[0] = 0;                       /* of stack... */
  1212.     intime[0] = 0;
  1213.     inpcas[0] = 0;
  1214.     takerr[0] = 0;
  1215.     merror[0] = 0;
  1216.     xquiet[0] = quiet;
  1217.     xvarev[0] = vareval;
  1218. #endif /* NOSPL */
  1219.  
  1220. #ifndef NOSPL
  1221.     cmdlvl = 0;                         /* Initialize the command stack */
  1222.     xcmdsrc = CMD_KB;
  1223.     cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
  1224.     cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
  1225.     cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
  1226. #endif /* NOSPL */
  1227.  
  1228.     tlevel = -1;                        /* Take file level = keyboard */
  1229.     for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
  1230.       tfnam[i] = NULL;
  1231.  
  1232.     cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
  1233.                                         /* Can't set IKSD prompt here since */
  1234.                                         /* we do not yet know if we are IKSD */
  1235. #ifndef NOSPL
  1236.  
  1237.     initmac();                          /* Initialize macro table */
  1238.  
  1239. /* Predefine built-in one-line macros */
  1240.  
  1241.     addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
  1242.     addmac("fatal",m_fat);              /* FATAL macro */
  1243.     y = addmac("fast",m_fast);          /* FAST macro */
  1244.     addmac("cautious",m_cautious);      /* CAUTIOUS macro */
  1245.     addmac("robust",m_robust);          /* ROBUST macro */
  1246. #ifdef OS2
  1247.     addmac("manual",m_manual);          /* MANUAL macro */
  1248. #endif /* OS2 */
  1249. #ifdef VMS
  1250.     addmac("purge",m_purge);            /* PURGE macro */
  1251. #endif /* VMS */
  1252.  
  1253. /*
  1254.   Predefine built-in multiline macros; these are top-level commands
  1255.   that are implemented internally as macros.  NOTE: When adding a new
  1256.   one of these, remember to update the END and RETURN commands to
  1257.   account for it, or else END and RETURN from within it won't work right.
  1258. */
  1259.     x = addmmac("_forx",for_def);       /* FOR macro */
  1260.     if (x > -1) mactab[x].flgs = CM_INV;
  1261.     x = addmmac("_forz",foz_def);       /* Other FOR macro */
  1262.     if (x > -1) mactab[x].flgs = CM_INV;
  1263.     x = addmmac("_xif",xif_def);        /* XIF macro */
  1264.     if (x > -1) mactab[x].flgs = CM_INV;
  1265.     x = addmmac("_while",whil_def);     /* WHILE macro */
  1266.     if (x > -1) mactab[x].flgs = CM_INV;
  1267.     x = addmmac("_switx",sw_def);       /* SWITCH macro */
  1268.     if (x > -1) mactab[x].flgs = CM_INV;
  1269.  
  1270. /* Fill in command-line argument vector */
  1271.  
  1272.     sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
  1273.     if (inserver) {                     /* But hidden in IKSD */
  1274.         y = -1;
  1275.         xargs = 0;
  1276.     } else
  1277.       y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */
  1278.  
  1279.     tmpbuf[0] = NUL;
  1280.     if (y > -1) {
  1281.         int j = -1;
  1282.         int yy = 0;
  1283.         dclarray((char)x,z);            /* Declare the array */
  1284. #ifndef NOTAKEARGS
  1285.         /* Macro argument vector */
  1286.         sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
  1287.         yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
  1288.         if (yy > -1)                    /* Name is OK */
  1289.           dclarray((char)x,z);          /* Declare the array */
  1290. #endif /* NOTAKEARGS */
  1291.         skip = 0;
  1292.         for (i = 0; i < xargs; i++) {   /* Fill the arrays */
  1293.             sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1294.             addmac(vnambuf,xargv[i]);
  1295.             if (cfilef && i == 0)
  1296.               continue;
  1297. #ifdef KERBANG
  1298.             if (skip) {
  1299.                 j = 0;
  1300.                 skip = 0;
  1301.                 continue;
  1302.             }
  1303. #endif /* KERBANG */
  1304.             if (j < 0 &&                /* Assign items after "=" or "--"*/
  1305.                 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1306.                 ) {
  1307.                 j = 0;                  /* to \%1..\%9 */
  1308. #ifdef KERBANG
  1309.             } else if (j < 0 &&
  1310.                        (!strcmp(xargv[i],"+") ||
  1311.                         !strncmp(xargv[i],"+ ",2) ||
  1312.                         !strncmp(xargv[i],"+\t",2))
  1313.                         ) {
  1314.                 skip = 1;
  1315.                 continue;
  1316. #endif /* KERBANG */
  1317.             } else if (j > -1) {
  1318.                 j++;
  1319.                 if (j <= 9) {
  1320.                     vnambuf[0] = '\\';
  1321.                     vnambuf[1] = '%';
  1322.                     vnambuf[2] = (char)(j+'0');
  1323.                     vnambuf[3] = NUL;
  1324.                     addmac(vnambuf,xargv[i]);
  1325.                 }
  1326.                 if (yy > -1) {
  1327.                     char c, * p;
  1328.                     int flag = 0;
  1329.                     p = xargv[i];
  1330.                     makestr(&(toparg[j]),p);
  1331.                     while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1332.                     if (flag)
  1333.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1334.                     ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1335.                     if (flag)
  1336.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1337.                     ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1338.                 }
  1339.             }
  1340.         }
  1341.         if (cfilef) {
  1342.             addmac("\\%0",cmdfil);
  1343.             if (yy > -1)
  1344.               makestr(&(toparg[0]),cmdfil);
  1345.         } else {
  1346.             addmac("\\%0",xargv[0]);
  1347.             if (yy > -1)
  1348.               makestr(&(toparg[0]),xargv[0]);
  1349.         }
  1350.         if (yy > -1) {
  1351.             topargc = (j < 0) ? 1 : j + 1;
  1352.             topxarg = toparg;
  1353. #ifdef COMMENT
  1354.             /* This needs work */
  1355.             if (!cfilef)
  1356.               makestr(&topline,tmpbuf);
  1357. #endif /* COMMENT */
  1358.         } else {
  1359.             topargc = 0;
  1360.             topxarg = NULL;
  1361.         }
  1362.         a_dim[0] = topargc - 1;
  1363.         a_ptr[0] = topxarg;
  1364.     debug(F111,"a_dim[0]","A",a_dim[0]);
  1365.     }
  1366.     *vnambuf = NUL;
  1367. #endif /* NOSPL */
  1368.  
  1369.     luinit();                           /* Initialize lookup() cache */
  1370.  
  1371. /* Get our home directory now.  This needed in lots of places. */
  1372.  
  1373.     cmdinited = 1;
  1374. }
  1375.  
  1376. #ifdef NT
  1377. _PROTOTYP(char * GetAppData,(int));
  1378. #endif /* NT */
  1379.  
  1380. VOID
  1381. doinit() {
  1382. #ifdef CKROOT
  1383. extern int ckrooterr;
  1384. #endif /* CKROOT */
  1385.     int x = 0, ok = 0;
  1386. #ifdef OS2
  1387.     char * ptr = 0;
  1388. #endif /* OS2 */
  1389.  
  1390.     if (!cmdinited)
  1391.       cmdini();
  1392.  
  1393. #ifdef MAC
  1394.     return;                             /* Mac Kermit has no init file */
  1395.  
  1396. #else /* !MAC */
  1397.  
  1398. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1399.  
  1400.     if (noinit) {
  1401.         kermrc[0] = '\0';
  1402.         inidir[0] = '\0';
  1403. /*
  1404.   But returning from here results in inidir[] never being set to anything.
  1405.   Instead it should be set to wherever the init file *would* have been
  1406.   executed from.  So this bit of code should be removed, and then we should
  1407.   sprinkle "if (noinit)" tests throughout the following code until we have
  1408.   set inidir[], and then return without actually taking the init file.
  1409. */
  1410.         return;
  1411.     }
  1412.  
  1413. #ifdef OS2
  1414. /*
  1415.   The -y init file must be fully specified or in the current directory.
  1416.   KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  1417.   own executable file path is taken and the .EXE suffix is replaced by .INI
  1418.   and this is tried as the initialization file.
  1419. */
  1420. #ifdef CK_LOGIN
  1421.     debug(F101,"doinit inserver","",inserver);
  1422.     debug(F101,"doinit isguest","",isguest);
  1423.     debug(F110,"doinit anonfile",anonfile,0);
  1424.  
  1425.     if (isguest && anonfile) {
  1426.       ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1427.     } else
  1428. #endif /* CK_LOGIN */
  1429.       if (rcflag) {
  1430.           ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1431. #ifdef CK_LOGIN
  1432.       } else if (inserver) {
  1433.           char * appdata = NULL;
  1434. #ifdef NT
  1435.           appdata = GetAppData(1);
  1436.           if ( appdata ) {
  1437.               ckmakmsg(line,LINBUFSIZ+1,appdata,
  1438.                         "Kermit 95/k95.ini",NULL,NULL);
  1439.               if ( zchki(line) < 0 )
  1440.                   line[0] = '\0';
  1441.           }
  1442.           if (line[0] == 0) {
  1443.               appdata = GetAppData(0);
  1444.               if ( appdata ) {
  1445.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1446.                             "Kermit 95/k95.ini",NULL,NULL);
  1447.                   if ( zchki(line) < 0 )
  1448.                       line[0] = '\0';
  1449.               }
  1450.           }
  1451. #endif /* NT */
  1452.           if (line[0] == 0) {
  1453.               appdata = zhome();
  1454.               if ( appdata ) {
  1455.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1456. #ifdef NT
  1457.                           "k95.ini",
  1458. #else /* NT */
  1459.                           "k2.ini",
  1460. #endif /* NT */
  1461.                            NULL,NULL);
  1462.                   if ( zchki(line) < 0 )
  1463.                       line[0] = '\0';
  1464.               }
  1465.           }
  1466.           debug(F110,"doinit inserver inifile",line,0);
  1467. #endif /* CK_LOGIN */
  1468.     } else {
  1469.         char * env = 0;
  1470. #ifdef NT
  1471.         env = getenv("K95.KSC");
  1472. #else
  1473.         env = getenv("K2.KSC");
  1474. #endif /* NT */
  1475.         if (!env) {
  1476. #ifdef NT
  1477.             env = getenv("K95.INI");
  1478. #else
  1479.             env = getenv("K2.INI");
  1480. #endif /* NT */
  1481.         }
  1482.         if (!env)
  1483.           env = getenv("CKERMIT.INI");
  1484.         if (!env)
  1485.           env = getenv("CKERMIT_INI");
  1486.         line[0] = '\0';
  1487.  
  1488.         debug(F110,"doinit env",env,0);
  1489.         if (env)
  1490.           ckstrncpy(line,env,LINBUFSIZ+1);
  1491.  
  1492. #ifdef NT
  1493.         if (line[0] == 0) {
  1494.             env = GetAppData(1);
  1495.             if ( env ) {
  1496.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1497.                 if ( zchki(line) < 0 )
  1498.                     line[0] = '\0';
  1499.             }
  1500.         }
  1501.         if (line[0] == 0) {
  1502.             env = GetAppData(0);
  1503.             if ( env ) {
  1504.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1505.                 if ( zchki(line) < 0 )
  1506.                     line[0] = '\0';
  1507.             }
  1508.         }
  1509. #endif /* NT */
  1510.  
  1511.         if (line[0] == 0) {
  1512.             env = zhome();
  1513.             if ( env ) {
  1514.                 ckmakmsg(line,LINBUFSIZ+1,env,
  1515. #ifdef NT
  1516.                           "k95.ini",
  1517. #else /* NT */
  1518.                           "k2.ini",
  1519. #endif /* NT */
  1520.                           NULL,NULL);
  1521.                 if ( zchki(line) < 0 )
  1522.                     line[0] = '\0';
  1523.             }
  1524.         }
  1525.  
  1526.         if (line[0] == 0)
  1527.           _searchenv(kermrc,"INIT",line);
  1528.         if (line[0] == 0)
  1529.           _searchenv(kermrc,"DPATH",line);
  1530.         if (line[0] == 0)
  1531.           _searchenv(kermrc,"PATH",line);
  1532.         if (line[0] == 0) {
  1533.             char *pgmptr = GetLoadPath();
  1534.             if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1535.                 lp = strrchr(pgmptr, '\\');
  1536.                 if (lp) {
  1537.                     strncpy(line, pgmptr, lp - pgmptr);
  1538. #ifdef NT
  1539.                     strcpy(line + (lp - pgmptr), "/k95.ini");
  1540. #else /* NT */
  1541.                     strcpy(line + (lp - pgmptr), "/k2.ini");
  1542. #endif /* NT */
  1543.                 } else {
  1544.                     lp = strrchr(pgmptr, '.');
  1545.                     if (lp) {
  1546.                         strncpy(line, pgmptr, lp - pgmptr);
  1547.                         strcpy(line + (lp - pgmptr), ".ini");
  1548.                     }
  1549.                 }
  1550.             }
  1551.         }
  1552.     }
  1553.  
  1554. #ifdef CKROOT
  1555.     if (!zinroot(line)) {
  1556.         debug(F110,"doinit setroot violation",line,0);
  1557.         return;
  1558.     }
  1559. #endif /* CKROOT */
  1560.  
  1561.     debug(F110,"doinit fopen()",line,0);
  1562.     if ((tfile[0] = fopen(line,"r")) != NULL) {
  1563.         ok = 1;
  1564.         tlevel = 0;
  1565.         tfline[tlevel] = 0;
  1566.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1567.           strcpy(tfnam[tlevel],line);   /* safe */
  1568. #ifndef NOSPL
  1569.         cmdlvl++;
  1570.         xcmdsrc = CMD_TF;
  1571.         cmdstk[cmdlvl].src = CMD_TF;
  1572.         cmdstk[cmdlvl].lvl = tlevel;
  1573.         cmdstk[cmdlvl].ccflgs = 0;
  1574.         ifcmd[cmdlvl] = 0;
  1575.         iftest[cmdlvl] = 0;
  1576.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1577.         intime[cmdlvl] = intime[cmdlvl-1];
  1578.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1579.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1580.         merror[cmdlvl] = merror[cmdlvl-1];
  1581.         xquiet[cmdlvl] = quiet;
  1582.         xvarev[cmdlvl] = vareval;
  1583. #endif /* NOSPL */
  1584.         debug(F110,"doinit init file",line,0);
  1585.     } else {
  1586.         debug(F100,"doinit no init file","",0);
  1587.     }
  1588.     ckstrncpy(kermrc,line,KERMRCL);
  1589.     for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
  1590.        if (*ptr == '\\')
  1591.          *ptr = '/';
  1592. #else /* not OS2 */
  1593.     lp = line;
  1594.     lp[0] = '\0';
  1595.     debug(F101,"doinit rcflag","",rcflag);
  1596. #ifdef GEMDOS
  1597.     zkermini(line, rcflag, kermrc);
  1598. #else
  1599. #ifdef VMS
  1600.     {
  1601.     int x;
  1602.     x = zkermini(line,LINBUFSIZ,kermrc);
  1603.     debug(F111,"CUSTOM zkermini",line,x);
  1604.     if (x == 0)
  1605.       line[0] = NUL;
  1606.     }
  1607. #else /* not VMS */
  1608. #ifdef CK_LOGIN
  1609.     debug(F101,"doinit isguest","",isguest);
  1610.     if (isguest)
  1611.       ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1612.     else
  1613. #endif /* CK_LOGIN */
  1614.       if (rcflag) {                     /* If init file name from cmd line */
  1615.           ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1616.       } else {                          /* otherwise... */
  1617. #ifdef CK_INI_A                         /* If we've a system-wide init file */
  1618.           /* And it takes precedence over the user's... */
  1619.           ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1620.           if (zchki(lp) < 0) {          /* (if it exists...) */
  1621. #endif /* CK_INI_A */
  1622.               char * homdir;
  1623.               char * env = 0;
  1624.               line[0] = NUL;
  1625.  
  1626.               /* Add support for environment variable */
  1627.               env = getenv("CKERMIT.INI");
  1628.               if (!env)
  1629.                 env = getenv("CKERMIT_INI");
  1630.               if (env)
  1631.                 ckstrncpy(lp,env,KERMRCL);
  1632.  
  1633.               if (lp[0] == 0) {
  1634.                   homdir = zhome();
  1635.                   if (homdir) {         /* Home directory for init file. */
  1636.                       ckstrncpy(lp,homdir,KERMRCL);
  1637. #ifdef STRATUS
  1638.                       ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1639. #else
  1640.                       if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1641. #endif /* STRATUS */
  1642.                   }
  1643.                   ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1644.               }
  1645. #ifdef CK_INI_A
  1646.           }
  1647. #endif /* CK_INI_A */
  1648. #ifdef CK_INI_B                         /* System-wide init defined? */
  1649.           /* But user's ini file takes precedence */
  1650.           if (zchki(lp) < 0)            /* If user doesn't have her own, */
  1651.             ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1652. #endif /* CK_INI_B */
  1653.       }
  1654. #endif /* VMS */
  1655. #endif /* GEMDOS */
  1656.  
  1657. #ifdef AMIGA
  1658.     reqoff();                           /* Disable requestors */
  1659. #endif /* AMIGA */
  1660.  
  1661. #ifdef USE_CUSTOM
  1662.     /* If no init file was found, execute the customization file */
  1663.     debug(F111,"CUSTOM 1",line,rcflag);
  1664.     if ((!line[0] || zchki(line) < 0) && !rcflag) {
  1665.     int x;
  1666. #ifdef OS2
  1667.     x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1668.     debug(F111,"CUSTOM 2",line,x);
  1669.     if (zchki(line) < 0) {
  1670.         x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1671.         debug(F111,"CUSTOM 3",line,x);
  1672.     }
  1673. #else  /* OS2 */
  1674.     x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1675. #ifndef VMS
  1676.     /* VMS zhome() returns "SYS$LOGIN:" */
  1677.     if (line[x-1] != DIRSEP) {
  1678.         line[x++] = DIRSEP;
  1679.         line[x] = NUL;
  1680.     }
  1681. #endif /* VMS */
  1682.     x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1683.     debug(F111,"CUSTOM 4",line,x);
  1684. #endif /* OS2 */
  1685.     }
  1686.     debug(F110,"CUSTOM 5",line,0);
  1687. #endif /* USE_CUSTOM */
  1688.  
  1689. #ifdef CKROOT
  1690.     if (!zinroot(line)) {
  1691.         debug(F110,"doinit setroot violation",line,0);
  1692.         return;
  1693.     }
  1694. #endif /* CKROOT */
  1695.  
  1696.     debug(F110,"doinit ini file is",line,0);
  1697.     if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1698.         ok = 1;
  1699.         tlevel = 0;
  1700.         tfline[tlevel] = 0;
  1701.         if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1702.           strcpy(tfnam[tlevel],line);   /* safe */
  1703.  
  1704.         ckstrncpy(kermrc,line,KERMRCL);
  1705.  
  1706. #ifndef NOSPL
  1707.         cmdlvl++;
  1708.         ifcmd[cmdlvl] = 0;
  1709.         iftest[cmdlvl] = 0;
  1710.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1711.         intime[cmdlvl] = intime[cmdlvl-1];
  1712.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1713.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1714.         merror[cmdlvl] = merror[cmdlvl-1];
  1715.         xquiet[cmdlvl] = quiet;
  1716.         xvarev[cmdlvl] = vareval;
  1717.         debug(F101,"doinit open ok","",cmdlvl);
  1718.         xcmdsrc = CMD_TF;
  1719.         cmdstk[cmdlvl].src = CMD_TF;
  1720.         cmdstk[cmdlvl].lvl = tlevel;
  1721.         cmdstk[cmdlvl].ccflgs = 0;
  1722. #endif /* NOSPL */
  1723.     } else if (rcflag) {
  1724.         /* Print an error message only if a specific file was asked for. */
  1725.         printf("?%s - %s\n", ck_errstr(), line);
  1726.     }
  1727.  
  1728. #ifdef datageneral
  1729. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1730.     if (/* homdir && */ (tlevel < 0)) {
  1731.         ckstrncpy(lp,kermrc,LINBUFSIZ);
  1732.         if ((tfile[0] = fopen(line,"r")) != NULL) {
  1733.             ok = 1;
  1734.             tlevel = 0;
  1735.             tfline[tlevel] = 0;
  1736.             if (tfnam[tlevel] = malloc(strlen(line)+1))
  1737.               strcpy(tfnam[tlevel],line); /* safe */
  1738. #ifndef NOSPL
  1739.             cmdlvl++;
  1740.             xcmdsrc = CMD_TF;
  1741.             cmdstk[cmdlvl].src = CMD_TF;
  1742.             cmdstk[cmdlvl].lvl = tlevel;
  1743.             cmdstk[cmdlvl].ccflgs = 0;
  1744.             ifcmd[cmdlvl] = 0;
  1745.             iftest[cmdlvl] = 0;
  1746.             count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1747.             intime[cmdlvl] = intime[cmdlvl-1];
  1748.             inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1749.             takerr[cmdlvl] = takerr[cmdlvl-1];
  1750.             merror[cmdlvl] = merror[cmdlvl-1];
  1751.             xquiet[cmdlvl] = quiet;
  1752.         xvarev[cmdlvl] = vareval;
  1753. #endif /* NOSPL */
  1754.         }
  1755.     }
  1756. #endif /* datageneral */
  1757.  
  1758. #ifdef AMIGA                            /* Amiga... */
  1759.     reqpop();                           /* Restore requestors */
  1760. #endif /* AMIGA */
  1761. #endif /* OS2 */
  1762. #endif /* MAC */
  1763.  
  1764.     /* Assign value to inidir */
  1765.  
  1766.     if (!ok) {
  1767.         inidir[0] = NUL;
  1768.     } else {
  1769.         ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1770.         x = strlen(inidir);
  1771.         if (x > 0) {
  1772.             int i;
  1773.             for (i = x - 1; i > 0; i-- ) {
  1774.                 if (ISDIRSEP(inidir[i])) {
  1775.                     inidir[i+1] = NUL;
  1776.                     break;
  1777.                 }
  1778.             }
  1779.         }
  1780. #ifdef NT
  1781.         GetShortPathName(inidir,inidir,CCHMAXPATH);
  1782. #endif /* NT */
  1783.     }
  1784. }
  1785.  
  1786. VOID
  1787. doiksdinit() {
  1788. #ifdef CK_SSL
  1789.     /* IKSD doesn't request client certs */
  1790.     ssl_verify_flag = SSL_VERIFY_NONE;
  1791. #endif /* CK_SSL */
  1792.  
  1793.     if (!cmdinited)
  1794.       cmdini();
  1795.  
  1796. #ifdef IKSDCONF
  1797. #ifdef OS2
  1798.     line[0] = '\0';
  1799.     _searchenv(iksdconf,"INIT",line);
  1800.     if (line[0] == 0)
  1801.       _searchenv(iksdconf,"DPATH",line);
  1802.     if (line[0] == 0)
  1803.       _searchenv(iksdconf,"PATH",line);
  1804.     if (line[0] == 0) {
  1805.         char *pgmptr = GetLoadPath();
  1806.         if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1807.             lp = strrchr(pgmptr, '\\');
  1808.             if (lp) {
  1809.                 strncpy(line, pgmptr, lp - pgmptr);
  1810.                 strcpy(line + (lp - pgmptr), "\\");
  1811.                 strcpy(line + (lp - pgmptr + 1), iksdconf);
  1812.             } else {
  1813.                 lp = strrchr(pgmptr, '.');
  1814.                 if (lp) {
  1815.                     strncpy(line, pgmptr, lp - pgmptr);
  1816.                     strcpy(line + (lp - pgmptr), ".ksc");
  1817.                 }
  1818.             }
  1819.         }
  1820.     }
  1821.     debug(F110,"doiksdinit() line",line,0);
  1822.     tfile[0] = fopen(line,"r");
  1823. #else /* OS2 */
  1824.     tfile[0] = fopen(iksdconf,"r");
  1825. #endif /* OS2 */
  1826.     if (tfile[0] != NULL) {
  1827.         tlevel = 0;
  1828.         tfline[tlevel] = 0;
  1829. #ifdef OS2
  1830.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1831.           strcpy(tfnam[tlevel],line);
  1832. #else /* OS2 */
  1833.         if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1834.           strcpy(tfnam[tlevel],iksdconf);
  1835. #endif /* OS2 */
  1836. #ifndef NOSPL
  1837.         cmdlvl++;
  1838.         xcmdsrc = CMD_TF;
  1839.         cmdstk[cmdlvl].src = CMD_TF;
  1840.         cmdstk[cmdlvl].lvl = tlevel;
  1841.         cmdstk[cmdlvl].ccflgs = 0;
  1842.         ifcmd[cmdlvl]  = 0;
  1843.         iftest[cmdlvl] = 0;
  1844.         count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
  1845.         intime[cmdlvl] = intime[cmdlvl-1];
  1846.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1847.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1848.         merror[cmdlvl] = merror[cmdlvl-1];
  1849.         xquiet[cmdlvl] = quiet;
  1850.     xvarev[cmdlvl] = vareval;
  1851. #endif /* NOSPL */
  1852.         debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1853.     } else {
  1854.         debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1855.     }
  1856. #endif /* IKSDCONF */
  1857. }
  1858.  
  1859. #ifndef NOSPL
  1860. /*
  1861.   G E T N C M
  1862.  
  1863.   Get next command from current macro definition.  Command is copied
  1864.   into string pointed to by argument s, max length n.   Returns:
  1865.    0 if a string was copied;
  1866.   -1 if there was no string to copy.
  1867. */
  1868. int
  1869. getncm(s,n) char *s; int n; {
  1870.     int y = 0;                /* Character counter */
  1871.     int quote = 0;
  1872.     int kp = 0;                /* Brace up-down counter */
  1873.     int pp = 0;                /* Parenthesis up-down counter */
  1874. #ifndef NODQMACRO
  1875.     int dq = 0;                /* Doublequote counter */
  1876. #endif /* NODQMACRO */
  1877.     char *s2;                           /* Copy of destination pointer */
  1878.  
  1879.     s2 = s;                             /* Initialize string pointers */
  1880.     *s = NUL;                           /* and destination buffer */
  1881.  
  1882.     /* debug(F010,"getncm entry",macp[maclvl],0); */
  1883.  
  1884.     for (y = 0;                         /* Loop for n bytes max */
  1885.          macp[maclvl] && *macp[maclvl] && y < n;
  1886.          y++, s++, macp[maclvl]++) {
  1887.  
  1888.         *s = *macp[maclvl];             /* Get next char from macro def */
  1889.  
  1890. #ifndef COMMENT
  1891. /*
  1892.   This is to allow quoting of parentheses, commas, etc, in function
  1893.   arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  1894.   COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  1895.   everything again.)  <-- The preceding warning should be obsolete since the
  1896.   statements below have been fixed, but in case of fire, remove the "n" from
  1897.   the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the
  1898.   opening brace in \{nnn} from being treated as a quoted brace.
  1899. */
  1900.         if (!quote && *s == CMDQ) {
  1901.             quote = 1;
  1902.             continue;
  1903.         }
  1904.         if (quote) {
  1905.         int notquote = 0;
  1906.             quote = 0;
  1907.         if (*s == '{') {        /* Check for \{nnn} (8.0.203) */
  1908.         char c, * p;
  1909.         p = macp[maclvl] + 1;
  1910.         while ((c = *p++)) {
  1911.             if (isdigit(c))
  1912.               continue;
  1913.             else if (c == '}') {
  1914.             notquote++;
  1915.             break;
  1916.             } else {
  1917.             break;
  1918.             }
  1919.         }
  1920.         }
  1921.         if (notquote == 0)
  1922.           continue;
  1923.         }
  1924. #endif /* COMMENT */
  1925.  
  1926. /*
  1927.   Allow braces around macro definition to prevent commas from being turned to
  1928.   end-of-lines and also treat any commas within parens as text so that
  1929.   multiple-argument functions won't cause the command to break prematurely.
  1930.   19 Oct 2001: Similar treatment was added for doublequotes, so
  1931.  
  1932.      define foo { echo "one, two, three" }
  1933.  
  1934.   would work as expected.  This doesn't seem to have broken anything but
  1935.   if something comes up later, rebuild with NODQMACRO defined.
  1936. */
  1937.         if (*s == '{') kp++;            /* Count braces */
  1938.         if (*s == '}' && kp > 0) kp--;
  1939.         if (*s == '(') pp++;            /* Count parentheses. */
  1940.         if (*s == ')' && pp > 0) pp--;
  1941. #ifndef NODQMACRO
  1942. #ifndef COMMENT
  1943.     /* Too many false positives */
  1944.     /* No, not really -- this is indeed the best we can do */
  1945.     /* Reverted to this method Sun May 11 18:43:45 2003 */
  1946.     if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1947. #else  /* Fri Apr  4 13:21:29 2003 */
  1948.     /* The code below breaks the SWITCH statement */
  1949.     /* There is no way to make this work -- it would require */
  1950.     /* building in all the knowledge of command parser. */
  1951.         if (dblquo && (*s == '"')) {    /* Have doublequote */
  1952.             if (dq == 1) {        /* Close quote only if... */
  1953.                 if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
  1954.             (!*(macp[maclvl]+1)) ||      /* at end or ... */
  1955.             /* Next char is command separator... */
  1956.             /* Sun May 11 17:24:12 2003 */
  1957.             (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
  1958.             )             
  1959.                   dq = 0;        /* Close the quote */
  1960.             } else if (dq == 0) {
  1961.                 /* Open quote only if at beginning or preceded by space */
  1962.                 if (s > s2) {
  1963.                     if (*(s-1) == SP)
  1964.                       dq = 1;
  1965.                 } else if (s == s2) {
  1966.                       dq = 1;
  1967.                 }
  1968.             }
  1969.         }
  1970. #endif /* COMMENT */
  1971. #endif /* NODQMACRO */
  1972.         if (*s == ',' && pp <= 0 && kp <= 0
  1973. #ifndef NODQMACRO
  1974.             && dq == 0
  1975. #endif /* NODQMACRO */
  1976.             ) {
  1977.             macp[maclvl]++;             /* Comma not in {} or () */
  1978.             /* debug(F110,"next cmd",s,0); */
  1979.             kp = pp = 0;                /* so we have the next command */
  1980.             break;
  1981.         }
  1982.     }                                   /* Reached end. */
  1983. #ifdef COMMENT
  1984.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1985.     *s = NUL;
  1986. #endif /* COMMENT */
  1987.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1988.         /* debug(F100,"XXX getncm eom","",0); */
  1989.         popclvl();                      /* pop command level. */
  1990.         return(-1);
  1991.     } else {                            /* otherwise, tack CR onto end */
  1992.         *s++ = CR;
  1993.         *s = '\0';
  1994.         /* debug(F110,"XXX getncm OK",s,0); */
  1995.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  1996.           printf("%s\n",s2);
  1997.     }
  1998.     return(0);
  1999. }
  2000.  
  2001. /*  D O M A C  --  Define and then execute a macro */
  2002.  
  2003. int
  2004. domac(name, def, flags) char *name, *def; int flags; {
  2005.     int x, m;
  2006. #ifndef NOLOCAL
  2007. #ifdef OS2
  2008.     extern int term_io;
  2009.     int term_io_sav = term_io;
  2010.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  2011. #endif /* OS2 */
  2012. #endif /* NOLOCAL */
  2013.     m = maclvl;                         /* Current macro stack level */
  2014.     x = addmac(name, def);              /* Define a new macro */
  2015.     if (x > -1) {                       /* If successful, */
  2016.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  2017.         while (maclvl > m) {            /* Keep going till done with it, */
  2018.             debug(F101,"domac loop maclvl 1","",maclvl);
  2019.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  2020.             debug(F101,"domac loop maclvl 2","",maclvl);
  2021.             if (sstate) proto();        /* including protocol commands. */
  2022.         }
  2023.         debug(F101,"domac loop exit maclvl","",maclvl);
  2024.     }
  2025. #ifndef NOLOCAL
  2026. #ifdef OS2
  2027.     term_io = term_io_sav;
  2028. #endif /* OS2 */
  2029. #endif /* NOLOCAL */
  2030.     return(success);
  2031. }
  2032. #endif /* NOSPL */
  2033.  
  2034. /*
  2035.   G E T N C T
  2036.  
  2037.   Get next command from TAKE (command) file.
  2038.  
  2039.   Call with:
  2040.    s     Pointer to buffer to read into
  2041.    n     Length of buffer
  2042.    f     File descriptor of file to read from
  2043.    flag  0 == keep line terminator on and allow continuation
  2044.          1 == discard line terminator and don't allow continuation
  2045.  
  2046.   Call with flag == 0 to read a command from a TAKE file;
  2047.   Call with flag != 0 to read a line from a dialing or network directory.
  2048.  
  2049.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  2050.   If flag == 0, continued lines are combined into one line.  A continued line
  2051.   is one that ends in hypen, or any line in a "block", which starts with "{"
  2052.   at the end of a line and ends with a matching "}" at the beginning of a
  2053.   subsequent line; blocks may be nested.
  2054.  
  2055.   Returns:
  2056.    0 if a string was copied,
  2057.   -1 on EOF,
  2058.   -2 on malloc failure
  2059.   -3 if line is not properly terminated
  2060.   -4 if (possibly continued) line is too long.
  2061. */
  2062. static int lpxlen = 0;
  2063.  
  2064. int
  2065. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  2066.     int i = 0, len = 0, buflen = 0;
  2067.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  2068.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  2069.     char * prev = NULL;
  2070.     int bc = 0;                         /* Block counter */
  2071.  
  2072.     s2 = s;                             /* Remember original pointer */
  2073.     prev = s2;                /* Here too */
  2074.     buflen = n;                         /* Remember original buffer length */
  2075.  
  2076.     if (n < 0)
  2077.       return(-2);
  2078.  
  2079.     /* Allocate a line buffer only if we don't have one that's big enough */
  2080.  
  2081.     debug(F111,"getnct",ckitoa(lpxlen),n);
  2082.  
  2083.     if (lpx && (n > lpxlen)) {          /* Have one already */
  2084.         debug(F101,"getnct new buffer","",lpxlen);
  2085.         free(lpx);                      /* But it's not big enough */
  2086.         lpx = NULL;                     /* Free current one */
  2087.         lpxlen = 0;
  2088.     }
  2089.     if (!lpx) {                         /* Get new one */
  2090.         if (!(lpx = (char *) malloc(n))) {
  2091.             debug(F101,"getnct malloc failure","",0);
  2092.             printf("?Memory allocation failure [getnct:%d]\n",n);
  2093.             return(-2);
  2094.         }
  2095.         lpxlen = n;
  2096.     }
  2097.     lp2 = lpx;
  2098. #ifdef KLUDGE
  2099.     /* NOTE: No longer used as of 14 Aug 2000 */
  2100.     lp2++;
  2101. #endif /* KLUDGE */
  2102.  
  2103.     while (1) {                         /* Loop to read lines from file */
  2104.         debug(F101,"getnct while (1)","",n);
  2105.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  2106.             debug(F110,"getnct EOF",s2,0); /* EOF */
  2107.             free(lpx);                  /* Free temporary storage */
  2108.             lpx = NULL;
  2109.             *s = NUL;                   /* Make destination be empty */
  2110.             return(-1);                 /* Return failure code */
  2111.         }
  2112.  
  2113. #ifndef NODIAL
  2114.         if (flag)                       /* Count this line */
  2115.           dirline++;
  2116.         else
  2117. #endif /* NODIAL */
  2118.           tfline[tlevel]++;
  2119.         len = strlen(lp2) - 1;          /* Position of line terminator */
  2120.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  2121.             lp2[++len] = '\n';          /* that is not a newline */
  2122.             lp2[len] = NUL;
  2123.         }
  2124.         debug(F010,"getnct",lp2,0);
  2125.         if (len < 0)
  2126.           len = 0;
  2127.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2128.           printf("%3d. %s",             /* echo it this line. */
  2129. #ifndef NODIAL
  2130.                  flag ? dirline :
  2131. #endif /* NODIAL */
  2132.                  tfline[tlevel],
  2133.                  lp2
  2134.                  );
  2135.         lp3 = lp2;                      /* Working pointer */
  2136.         i = len;                        /* Get first nonwhitespace character */
  2137.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2138.             i--;
  2139.             lp3++;
  2140.         }
  2141.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2142.           continue;
  2143.  
  2144.         /* Isolate, remove, and check terminator */
  2145.  
  2146.         c = lp2[len];                   /* Value of line terminator */
  2147.         /* debug(F101,"getnct terminator","",c); */
  2148.         if (c < LF || c > CR) {         /* It's not a terminator */
  2149.             /* debug(F111,"getnct bad line",lp2,c); */
  2150.             if (feof(f) && len > 0 && len < n) {
  2151.                 /* Kludge Alert... */
  2152.                 if (!quiet)
  2153.                   printf("WARNING: Last line of %s lacks terminator\n",
  2154.                          s2 == cmdbuf ? "command file" : "directory file");
  2155.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2156.             } else {                    /* Something's wrong, fail. */
  2157.                 free(lpx);
  2158.                 lpx = NULL;
  2159.                 return(-3);
  2160.             }
  2161.         }
  2162.         /* Trim trailing whitespace */
  2163.  
  2164.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2165.           ;
  2166.         /* debug(F101,"getnct i","",i); */
  2167.         lp2[i+1] = NUL;                 /* Terminate the string */
  2168.         /* debug(F110,"getnct lp2",lp2,0); */
  2169.         lp = lp2;                       /* Make a working pointer */
  2170.  
  2171.         /* Remove trailing or full-line comment */
  2172.  
  2173.         while ((cc = *lp)) {
  2174.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2175.                 if (lp == lp2) {        /* First char on line */
  2176.                     *lp = NUL;
  2177.                     break;
  2178.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2179.                     lp--;
  2180.                     *lp = NUL;  /* Or preceded by whitespace */
  2181.                     break;
  2182.                 }
  2183.             }
  2184.             lp++;
  2185.         }
  2186.         if (lp > lp2)
  2187.           lp--;                         /* Back up over the NUL */
  2188.  
  2189.         /* Now trim any space that preceded the comment */
  2190.  
  2191.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2192.             *lp = NUL;
  2193.             if (lp <= lp2)
  2194.               break;
  2195.             lp--;
  2196.         }
  2197.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2198.  
  2199.         len = strlen(lp2);              /* Length after trimming */
  2200.  
  2201.         if (n - len < 2) {              /* Check remaining space */
  2202.             debug(F111,"getnct command too long",s2,buflen);
  2203.             printf("?Line too long, maximum length: %d.\n",buflen);
  2204.             free(lpx);
  2205.             return(-4);
  2206.         }
  2207.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2208.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2209.  
  2210. #ifdef COMMENT
  2211.         /* Line containing only whitespace and ,- */
  2212.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2213.           continue;
  2214. #endif /* COMMENT */
  2215.  
  2216. #ifdef KLUDGE
  2217. /*
  2218.   If it is a command and it begins with a token (like ! or .) that is not
  2219.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2220.   confused.
  2221. */
  2222.         if (s == s2 && !flag) {
  2223.             char *p = toktab;
  2224.             while (*p) {
  2225.                 if (*p == *lp3 && *(p+1) != SP) {
  2226.                     debug(F110,"getnct token",p,0);
  2227.                     *lp3-- = SP;
  2228.                     *lp3 = *p;
  2229.                     if (lp3 < lp2) {
  2230.                         lp2--;
  2231.                         len++;
  2232.                     }
  2233.                     break;
  2234.                 } else
  2235.                   p++;
  2236.             }
  2237.         }
  2238. #endif /* KLUDGE */
  2239.         lp = lp2;
  2240.  
  2241.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2242.           n--;                          /* accounting for length */
  2243.         s--;                            /* Back up over the NUL */
  2244.  
  2245.         /* Check whether this line is continued */
  2246.  
  2247.         if (flag)                       /* No line continuation when flag=1 */
  2248.           break;                        /* So break out of read-lines loop */
  2249.  
  2250. #ifdef COMMENT
  2251.         debug(F000,"getnct first char","",*lp3);
  2252.         debug(F000,"getnct last char","",ccl);
  2253.         debug(F000,"getnct next-to-last char","",ccx);
  2254. #endif /* COMMENT */
  2255.  
  2256.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2257.             bc--;            /* Decrement block counter */
  2258.         }
  2259.  
  2260.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2261. #ifdef COMMENT
  2262.             /* Not supported as of C-Kermit 6.0 */
  2263.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2264. #endif /* COMMENT */
  2265.             ccl != '-'  &&              /* or line ends with dash */
  2266.             ccl != '{')                 /* or line ends with opening brace */
  2267.           break;                        /* None of those, we're done. */
  2268.  
  2269.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2270.           if (ccx == CMDQ)              /* But it's quoted */
  2271.             break;                      /* so ignore it */
  2272.  
  2273.         if (ccl == '{') {               /* Last char on line is '{'? */
  2274.             bc++;                       /* Count the block opener. */
  2275.         } else if (ccl == '-') {        /* Explicit continue? */
  2276.             char c, * ss;
  2277.             int state = 0, nn;
  2278.             s--;                        /* Yes, back up over terminators */
  2279.             n++;                        /* and over continuation character */
  2280.             nn = n;                     /* Save current count */
  2281.             ss = s;                     /* and pointer */
  2282.             s--;                        /* Back up over dash */
  2283.             n++;
  2284.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2285.                 n++;
  2286.                 c = *s--;
  2287.                 if (c <= SP)
  2288.                   continue;
  2289.                 if (c != ',' && c != '{')
  2290.                   break;
  2291.                 switch (state) {
  2292.                   case 0:               /* Looking for comma */
  2293.                     if (c == ',')
  2294.                       state = 1;
  2295.                     break;
  2296.                   case 1:               /* Looking for left brace */
  2297.                     if (c == '{') {
  2298.                         state = 2;
  2299.                         s += 2;
  2300.                         *s = NUL;
  2301.                         bc++;
  2302.                     }
  2303.                     break;
  2304.                 }
  2305.             }
  2306.             if (state != 2) { s = ss; n = nn; }
  2307.             *s = NUL;
  2308.         } else {                        /* None of those but (bc > 0) */
  2309.             lastcomma = s;
  2310.             *s++ = ',';                 /* and insert a comma */
  2311.             n--;
  2312.         }
  2313. #ifdef COMMENT
  2314.         debug(F101,"getnct bc","",bc);
  2315.         debug(F100,"getnct continued","",0);
  2316. #endif /* COMMENT */
  2317.  
  2318.         *s = NUL;
  2319.         prev = s;
  2320.  
  2321.     } /* read-lines while loop */
  2322.  
  2323.     if (lastcomma)
  2324.       *lastcomma = SP;
  2325.     if (!flag)                          /* Tack line terminator back on */
  2326.       *s++ = c;
  2327.     *s++ = NUL;                         /* Terminate the string */
  2328.     untab(s2);                          /* Done, convert tabs to spaces */
  2329. #ifdef DEBUG
  2330.     if (!flag) {
  2331.         debug(F010,"CMD(F)",s2,0);
  2332.     }
  2333. #endif /* DEBUG */
  2334.     free(lpx);                          /* Free temporary storage */
  2335.     return(0);                          /* Return success */
  2336. }
  2337.  
  2338. VOID
  2339. shostack() {                            /* Dump the command stack */
  2340.     int i;
  2341.     char *p;
  2342. #ifndef NOSPL
  2343.     for (i = cmdlvl; i > 0; i--) {
  2344.         if (cmdstk[i].src == CMD_TF) {
  2345.             p = tfnam[cmdstk[i].lvl];
  2346.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2347.               p = tmpbuf;
  2348.             printf(" %2d. File  : %s (line %d)\n",
  2349.                    i,
  2350.                    p,
  2351.                    tfline[cmdstk[i].lvl]
  2352.                    );
  2353.         } else if (cmdstk[i].src == CMD_MD) {
  2354.             char * m;
  2355.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2356.             if (i > 0) {                 /* Special handling for 2-level */
  2357.                 char *s;                 /* built-in macros... */
  2358.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2359.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2360.                     if (!strcmp(s,"_forx"))
  2361.                       m = "FOR";
  2362.                     else if (!strcmp(s,"_xif"))
  2363.                       m = "XIF";
  2364.                     else if (!strcmp(s,"_while"))
  2365.                       m = "WHILE";
  2366.                     else if (!strcmp(s,"_switx"))
  2367.                       m = "SWITCH";
  2368.                 }
  2369.             }
  2370.             printf(" %2d. Macro : %s\n",i,m);
  2371.         } else if (cmdstk[i].src == CMD_KB) {
  2372.             printf(" %2d. Prompt:\n",i);
  2373.         } else {
  2374.             printf(" %2d. ERROR : Command source unknown\n",i);
  2375.         }
  2376.     }
  2377. #else
  2378.     for (i = tlevel; i > -1; i--) {
  2379.         p = tfnam[i];
  2380.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2381.           p = tmpbuf;
  2382.         printf(" %2d. File  : %s (line %d)\n",
  2383.                i,
  2384.                p,
  2385.                tfline[i]
  2386.                );
  2387.     }
  2388. #endif /* NOSPL */
  2389.     if (i == 0)
  2390.       printf(" %2d. Prompt: (top level)\n",0);
  2391. }
  2392.  
  2393. /* For command error messages - avoid dumping out the contents of some */
  2394. /* some huge FOR loop if it contains a syntax error. */
  2395.  
  2396. static char *
  2397. cmddisplay(s, cx) char * s; int cx; {
  2398.     static char buf[80];
  2399.     if ((int)strlen(s) > 70) {
  2400.     sprintf(buf,"%.64s...",s);    /* SAFE */
  2401.     s = buf;
  2402.     }
  2403.     return(s);
  2404. }
  2405.  
  2406. static VOID
  2407. cmderr() {
  2408.     if (xcmdsrc > 0) {
  2409.     switch (cmd_err) {        /* SET COMMAND ERROR-DISPLAY */
  2410.       case 0:
  2411.         break;
  2412.       case 1:
  2413.       case 2:
  2414.         if (tlevel > -1) {
  2415. #ifndef NOSPL
  2416.         if (xcmdsrc == 2)
  2417.           printf(
  2418. "In macro or block defined in file: %s starting about line %d\n",
  2419.              tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2420.              );
  2421.         else
  2422. #endif /* NOSPL */
  2423.           printf("File: %s, Line: %d\n",
  2424.              tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2425.              );
  2426.         }
  2427. #ifndef NOSPL
  2428.         if (cmd_err == 2) {
  2429.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2430.             int m;
  2431.             m = cmdstk[cmdlvl].lvl;
  2432.             if (mlook(mactab,m_arg[m][0],nmac) >= 0)
  2433.               printf("Macro name: %s\n", m_arg[m][0]);
  2434.         }
  2435.         }
  2436. #endif /* NOSPL */
  2437.         break;
  2438.  
  2439.       case 3:
  2440.         printf("Command stack:\n");
  2441.         shostack();                
  2442.     }
  2443.     }
  2444. }
  2445.  
  2446. /*  P A R S E R  --  Top-level interactive command parser.  */
  2447.  
  2448. /*
  2449.   Call with:
  2450.     m = 0 for normal behavior: keep parsing and executing commands
  2451.           until an action command is parsed, then return with a
  2452.           Kermit start-state as the value of this function.
  2453.     m = 1 to parse only one command, can also be used to call parser()
  2454.           recursively.
  2455.     m = 2 to read but do not execute one command.
  2456.   In all cases, parser() returns:
  2457.     0     if no Kermit protocol action required
  2458.     > 0   with a Kermit protocol start-state.
  2459.     < 0   upon error.
  2460. */
  2461. int
  2462. parser(m) int m; {
  2463.     int tfcode, xx, yy, zz;             /* Workers */
  2464.     int is_tn = 0;
  2465.     int cdlost = 0;
  2466.  
  2467. #ifndef NOSPL
  2468.     int inlevel;                        /* Level we were called at */
  2469.     extern int askflag, echostars;
  2470. #endif /* NOSPL */
  2471.     char *cbp;                          /* Command buffer pointer */
  2472. #ifdef MAC
  2473.     extern char *lfiles;                /* Fake extern cast */
  2474. #endif /* MAC */
  2475.     extern int interrupted;
  2476. #ifndef NOXFER
  2477.     extern int sndcmd, getcmd, fatalio, clearrq;
  2478. #endif /* NOXFER */
  2479.  
  2480. #ifdef AMIGA
  2481.     reqres();                           /* Restore AmigaDOS requestors */
  2482. #endif /* AMIGA */
  2483.  
  2484. #ifdef OS2
  2485.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2486.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2487.         cursor_save = -1;
  2488.     }
  2489. #endif /* OS2 */
  2490.  
  2491. #ifdef IKSDB
  2492.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2493. #endif /* IKSDB */
  2494.  
  2495.     is_tn = (local && network && IS_TELNET()) ||
  2496.       (!local && sstelnet);
  2497.  
  2498.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2499.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2500.  
  2501. #ifdef CK_TMPDIR
  2502. /* If we were cd'd temporarily to another device or directory ... */
  2503.     if (f_tmpdir) {
  2504.         int x;
  2505.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2506.         f_tmpdir = 0;                   /* and remember we did it. */
  2507.         debug(F111,"parser tmpdir restoring",savdir,x);
  2508.     }
  2509. #endif /* CK_TMPDIR */
  2510.  
  2511. #ifndef NOSPL
  2512.     inlevel = cmdlvl;           /* Current macro level */
  2513. #ifdef DEBUG
  2514.     if (deblog) {
  2515.         debug(F101,"&parser entry maclvl","",maclvl);
  2516.         debug(F101,"&parser entry inlevel","",inlevel);
  2517.         debug(F101,"&parser entry tlevel","",tlevel);
  2518.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2519.         debug(F101,"&parser entry m","",m);
  2520.     }
  2521. #endif /* DEBUG */
  2522. #endif /* NOSPL */
  2523.  
  2524. #ifndef NOXFER
  2525.     ftreset();                          /* Reset global file settings */
  2526. #endif /* NOXFER */
  2527. /*
  2528.   sstate becomes nonzero when a command has been parsed that requires some
  2529.   action from the protocol module.  Any non-protocol actions, such as local
  2530.   directory listing or terminal emulation, are invoked directly from below.
  2531. */
  2532.     sstate = 0;                         /* Start with no start state. */
  2533.  
  2534. #ifndef NOXFER
  2535. #ifndef NOSPL
  2536.     query = 0;                          /* QUERY not active */
  2537. #endif /* NOSPL */
  2538. #ifndef NOHINTS
  2539.     if (!success) {
  2540.         if (local && !network && carrier != CAR_OFF) {
  2541.             int x;                      /* Serial connection */
  2542.             x = ttgmdm();               /* with carrier checking */
  2543.             if (x > -1) {
  2544.                 if (!(x & BM_DCD)) {
  2545.                     cdlost = 1;
  2546.                     fatalio = 1;
  2547.                 }
  2548.             }
  2549.         }
  2550.     }
  2551. #ifdef DEBUG
  2552.     if (deblog) {
  2553.         debug(F101,"parser top what","",what);
  2554.         debug(F101,"parser top interrupted","",interrupted);
  2555.         debug(F101,"parser top cdlost","",cdlost);
  2556.         debug(F101,"parser top sndcmd","",sndcmd);
  2557.         debug(F101,"parser top getcmd","",getcmd);
  2558.     }
  2559. #endif /* DEBUG */
  2560.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2561.         printf("?Connection broken (carrier signal lost)\n");
  2562.     }
  2563.     if (sndcmd && protocol == PROTO_K &&
  2564.     !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2565.         int x = 0, n = 0;
  2566.         printf("\n*************************\n");
  2567.         printf("SEND-class command failed.\n");
  2568.         printf(" Packets sent: %d\n", spackets);
  2569.         printf(" Retransmissions: %d\n",retrans);
  2570.         printf(" Timeouts: %d\n", timeouts);
  2571.         printf(" Damaged packets: %d\n", crunched);
  2572.         if (epktrcvd) {
  2573.             printf(" Transfer canceled by receiver.\n");
  2574.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2575.             n++;
  2576.         } else {
  2577.             if (epktmsg) if (*epktmsg) {
  2578.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2579.                 n++;
  2580.             }
  2581.         }
  2582.         if (local && !network && carrier != CAR_OFF) {
  2583.             int xx;                     /* Serial connection */
  2584.             xx = ttgmdm();              /* with carrier checking */
  2585.             if (xx > -1) {
  2586.                 if (!(xx & BM_DCD))
  2587.                   cdlost = 1;
  2588.             }
  2589.         }
  2590.  
  2591. #ifdef UNIX
  2592.         if (errno != 0)
  2593. #endif /* UNIX */
  2594.           {
  2595.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2596.               n++;
  2597.           }
  2598.         printf(
  2599.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2600.                (n > 1) ? "s do" : " does"
  2601.                );
  2602. #ifndef NOLOCAL
  2603.         if (local) {
  2604.             if (rpackets == 0) {
  2605.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2606.             } else {
  2607.                 printf(
  2608.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2609.                 if (!network && mdmtyp > 0)
  2610.                   if ((3 * crunched) > spackets)
  2611.                     printf(
  2612.                 " . Try placing a new call to get a cleaner connection.\n");
  2613.             }
  2614.         } else if (rpackets > 0) {
  2615.             if (flow == FLO_NONE)
  2616.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2617.             else
  2618.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2619.         }
  2620.         x++;
  2621. #endif /* NOLOCAL */
  2622.  
  2623.         if ((3 * timeouts) > spackets)
  2624.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2625.         if ((3 * retrans) > spackets)
  2626.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2627.  
  2628. #ifdef CK_SPEED
  2629.         if (prefixing != PX_ALL && rpackets > 2) {
  2630.             printf(" . Try it again with: SET PREFIXING ALL\n");
  2631.             x++;
  2632.         }
  2633. #endif /* CK_SPEED */
  2634. #ifdef STREAMING
  2635.         if (streamed) {
  2636.             printf(" . Try it again with: SET STREAMING OFF\n");
  2637.             x++;
  2638.         } else if (reliable) {
  2639.             printf(" . Try it again with: SET RELIABLE OFF\n");
  2640.             x++;
  2641.         }
  2642. #endif /* STREAMING */
  2643.  
  2644. #ifdef CK_SPEED
  2645.         if (clearrq > 0 && prefixing == PX_NON) {
  2646.             printf(" . Try it again with: SET CLEAR-CHANNEL OFF\n");
  2647.             x++;
  2648.         }
  2649. #endif /* CK_SPEED */
  2650.         if (!parity) {
  2651.             printf(" . Try it again with: SET PARITY SPACE\n");
  2652.             x++;
  2653.         }
  2654.         printf(" . %sive a ROBUST command and try again.\n",
  2655.                (x > 0) ? "As a last resort, g" : "G"
  2656.                );
  2657.         printf("Also:\n");
  2658.         printf(" . Be sure the source file has read permission.\n");
  2659.         printf(" . Be sure the target directory has write permission.\n");
  2660. /*
  2661.         if the file was 2G or larger make sure other Kermit supports LFs...
  2662. */
  2663.         printf(" . Be sure the target disk has sufficient space.\n");
  2664.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2665.         printf("*************************\n\n");
  2666.     }
  2667.     debug(F101,"topcmd","",topcmd);
  2668.     if (getcmd && protocol == PROTO_K &&
  2669.     !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2670.         int x = 0;
  2671.         extern int urpsiz, wslotr;
  2672.         printf("\n*************************\n");
  2673.         printf("RECEIVE- or GET-class command failed.\n");
  2674.         printf(" Packets received: %d\n", rpackets);
  2675.         printf(" Damaged packets: %d\n", crunched);
  2676.         printf(" Timeouts: %d\n", timeouts);
  2677.         if (rpackets > 0)
  2678.           printf(" Packet length: %d\n", urpsiz);
  2679.         if (epktrcvd) {
  2680.             printf(" Transfer canceled by sender.\n");
  2681.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2682.         }
  2683. #ifdef UNIX
  2684.         if (errno != 0)
  2685. #endif /* UNIX */
  2686.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2687.         printf(
  2688.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2689.                epktrcvd ? "s do" : " does"
  2690.                );
  2691. #ifndef NOLOCAL
  2692.         if (local) {
  2693.             if (topcmd == XXGET)
  2694.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2695.             if (rpackets == 0) {
  2696.                 if (topcmd != XXGET)
  2697.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2698.             } else {
  2699.                 printf(
  2700.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2701.             }
  2702.         } else if (topcmd == XXGET)
  2703.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2704.         if (rpackets > 0 && urpsiz > 90)
  2705.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2706.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2707.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2708.         if (!local && rpackets > 0) {
  2709.             if (flow == FLO_NONE)
  2710.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2711.             else
  2712.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2713.         }
  2714.         x++;
  2715. #endif /* NOLOCAL */
  2716. #ifdef STREAMING
  2717.         if (streamed) {
  2718.             printf(" . Try it again with: SET STREAMING OFF\n");
  2719.             x++;
  2720.         } else if (reliable && local) {
  2721.             printf(" . Try it again with: SET RELIABLE OFF\n");
  2722.             x++;
  2723.         } else
  2724. #endif /* STREAMING */
  2725.         if (!parity) {
  2726.             printf(" . Try it again with: SET PARITY SPACE\n");
  2727.             x++;
  2728.         }
  2729.         printf((x > 0) ?
  2730.                " . As a last resort, give a ROBUST command and try again.\n" :
  2731.                " . Give a ROBUST command and try again.\n"
  2732.                );
  2733.         printf("Also:\n");
  2734.         printf(" . Be sure the target directory has write permission.\n");
  2735.         printf(" . Be sure the target disk has sufficient space.\n");
  2736.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2737.                topcmd == XXGET ? "server" : "sender"
  2738.                );
  2739.         printf(" . Try giving a ROBUST command to the %s.\n",
  2740.                topcmd == XXGET ? "server" : "sender"
  2741.                );
  2742.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2743.         printf("*************************\n\n");
  2744.     }
  2745. #endif /* NOHINTS */
  2746.     getcmd = 0;
  2747.     sndcmd = 0;
  2748.     interrupted = 0;
  2749. #endif /* NOXFER */
  2750.  
  2751.     while (sstate == 0) {               /* Parse cmds until action requested */
  2752.         debug(F100,"parse top","",0);
  2753.     what = W_COMMAND;        /* Now we're parsing commands. */
  2754.     rcdactive = 0;            /* REMOTE CD not active */
  2755.     keepallchars = 0;        /* MINPUT not active */
  2756.  
  2757. #ifdef OS2
  2758.         if (apcactive == APC_INACTIVE)
  2759.           WaitCommandModeSem(-1);
  2760. #endif /* OS2 */
  2761. #ifdef IKS_OPTION
  2762.         if ((local &&
  2763.              !xcmdsrc &&
  2764.              is_tn &&
  2765.              TELOPT_ME(TELOPT_KERMIT) &&
  2766.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2767.             (!local &&
  2768.              !cmdadl &&
  2769.              TELOPT_ME(TELOPT_KERMIT) &&
  2770.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2771.             ) {
  2772.             tn_siks(KERMIT_STOP);
  2773.         }
  2774. #endif /* IKS_OPTION */
  2775.  
  2776. #ifndef NOXFER
  2777.         if (autopath) {
  2778.             fnrpath = PATH_AUTO;
  2779.             autopath = 0;
  2780.         }
  2781.         remfile = 0;                    /* Clear these in case REMOTE */
  2782.         remappd = 0;                    /* command was interrupted... */
  2783.         rempipe = 0;
  2784.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2785.         makestr(&rcv_move,g_rcv_move);
  2786.         makestr(&snd_rename,g_snd_rename);
  2787.         makestr(&rcv_rename,g_rcv_rename);
  2788. #endif /* NOXFER */
  2789.  
  2790.     /* Take requested action if there was an error in the previous command */
  2791.  
  2792.         setint();
  2793.         debug(F101,"parser tlevel","",tlevel);
  2794.         debug(F101,"parser cmd_rows","",cmd_rows);
  2795.  
  2796. #ifndef NOLOCAL
  2797.         debug(F101,"parser wasclosed","",wasclosed);
  2798.         if (wasclosed) {                /* If connection was just closed */
  2799. #ifndef NOSPL
  2800.             int k;
  2801.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2802.             if (k >= 0) {               /* If found, */
  2803.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2804.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2805.             }
  2806. #endif /* NOSPL */
  2807.             whyclosed = WC_REMO;
  2808.             wasclosed = 0;
  2809.         }
  2810. #endif /* NOLOCAL */
  2811.  
  2812. #ifndef NOSPL
  2813.         xxdot = 0;                      /* Clear this... */
  2814.  
  2815.         debug(F101,"parser success","",success);
  2816.         if (success == 0) {
  2817.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2818.                 printf("Command file terminated by error.\n");
  2819.                 popclvl();
  2820.                 if (cmdlvl == 0) return(0);
  2821.             }
  2822.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2823.                 printf("Command error: macro terminated.\n");
  2824.                 popclvl();
  2825.                 if (m && (cmdlvl < inlevel))
  2826.                   return((int) sstate);
  2827.             }
  2828.         }
  2829.         nulcmd = (m == 2);
  2830.         debug(F101,"parser nulcmd","",nulcmd);
  2831. #else
  2832.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2833.             printf("Command file terminated by error.\n");
  2834.             popclvl();
  2835.             cmini(ckxech);              /* Clear the cmd buffer. */
  2836.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2837.               return(0);                /* End of init file or whatever. */
  2838.         }
  2839. #endif /* NOSPL */
  2840.  
  2841. #ifdef MAC
  2842.         /* Check for TAKE initiated by menu. */
  2843.         if ((tlevel == -1) && lfiles)
  2844.             startlfile();
  2845. #endif /* MAC */
  2846.  
  2847.         /* If in TAKE file, check for EOF */
  2848. #ifndef NOSPL
  2849. #ifdef MAC
  2850.         if
  2851. #else
  2852.         while
  2853. #endif /* MAC */
  2854.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2855.                && (tlevel > -1)
  2856.                && feof(tfile[tlevel])) {
  2857.             popclvl();                  /* pop command level */
  2858.             cmini(ckxech);              /* and clear the cmd buffer. */
  2859.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2860.                 return(0);              /* End of init file or whatever. */
  2861.             }
  2862.         }
  2863. #ifdef MAC
  2864.         miniparser(1);
  2865.         if (sstate == 'a') {            /* if cmd-. cancel */
  2866.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2867.             sstate = '\0';
  2868.             dostop();
  2869.             return(0);                  /* End of init file or whatever. */
  2870.         }
  2871. #endif /*  MAC */
  2872.  
  2873. #else /* NOSPL */
  2874.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2875.             popclvl();                  /* Pop up one level. */
  2876.             cmini(ckxech);              /* and clear the cmd buffer. */
  2877.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2878.               return(0);                /* End of init file or whatever. */
  2879.         }
  2880. #endif /* NOSPL */
  2881.  
  2882.  
  2883. #ifndef NOSPL
  2884.         debug(F101,"parser cmdlvl","",cmdlvl);
  2885.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2886.  
  2887.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2888.             debug(F100,"parser macro","",0);
  2889.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2890.             debug(F101,"parser maclvl","",maclvl);
  2891.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2892.             *cbp = NUL;
  2893.             if (*savbuf) {              /* In case then-part of 'if' command */
  2894.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2895.                 *savbuf = '\0';
  2896.             } else {                    /* Else get next cmd from macro def */
  2897.                 if (getncm(cbp,CMDBL) < 0) {
  2898. #ifdef DEBUG
  2899.                     if (deblog) {
  2900.                         debug(F101,"parser end of macro m","",m);
  2901.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2902.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2903.                     }
  2904. #endif /* DEBUG */
  2905.                     if (m && (cmdlvl < inlevel))
  2906.                       return((int) sstate);
  2907.                     else /* if (!m) */ continue;
  2908.                 }
  2909.             }
  2910.             debug(F010,"CMD(M)",cmdbuf,0);
  2911.  
  2912.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2913. #else
  2914.           if (tlevel > -1)
  2915. #endif /* NOSPL */
  2916.           {
  2917. #ifndef NOSPL
  2918.             debug(F111,"parser savbuf",savbuf,tlevel);
  2919.             if (*savbuf) {              /* In case THEN-part of IF command */
  2920.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2921.                 *savbuf = '\0';
  2922.             } else
  2923. #endif /* NOSPL */
  2924.  
  2925.               /* Get next line from TAKE file */
  2926.  
  2927.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2928.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2929.                   if (tfcode < -1) {    /* Error */
  2930.                       printf("?Error in TAKE command file: %s\n",
  2931.                              (tfcode == -2) ? "Memory allocation failure" :
  2932.                              "Line too long or contains NUL characters"
  2933.                              );
  2934.                       dostop();
  2935.                   }
  2936.                   continue;             /* -1 means EOF */
  2937.               }
  2938.  
  2939.         /* If interactive, get next command from user. */
  2940.  
  2941.         } else {                        /* User types it in. */
  2942.             if (pflag) prompt(xxstring);
  2943.             cmini(ckxech);
  2944.         }
  2945.  
  2946.     /* Now we know where next command is coming from. Parse and execute it. */
  2947.  
  2948.         repars = 1;                     /* 1 = command needs parsing */
  2949. #ifndef NOXFER
  2950.         displa = 0;                     /* Assume no file transfer display */
  2951. #endif /* NOXFER */
  2952.  
  2953.         while (repars) {                /* Parse this cmd until entered. */
  2954.  
  2955.             debug(F101,"parser top of while loop","",0);
  2956.         xaskmore = saveask;        /* Restore global more-prompting */
  2957.         diractive = 0;        /* DIR command not active */
  2958.         cdactive = 0;        /* CD command not active */
  2959. #ifndef NOSPL
  2960.         askflag = 0;        /* ASK command not active */
  2961.         echostars = 0;        /* Nor ASKQ */
  2962.         debok = 1;            /* Undisable debugging */
  2963. #endif /* NOSPL */
  2964.  
  2965. #ifdef RECURSIVE
  2966.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2967.             recursive = 0;              /* This is never sticky */
  2968. #endif /* RECURSIVE */
  2969.             xfiletype = -1;             /* Reset this between each command */
  2970. #ifndef NOMSEND
  2971.             addlist = 0;
  2972. #endif /* NOMSEND */
  2973. #ifdef CK_RECALL
  2974.             on_recall = 1;
  2975. #endif /* CK_RECALL */
  2976.             /* This might have been changed by a switch */
  2977.             if (g_matchdot > -1) {
  2978.                 matchdot = g_matchdot;
  2979.                 g_matchdot = -1;
  2980.             }
  2981.             cmres();                    /* Reset buffer pointers. */
  2982.  
  2983. #ifdef OS2
  2984. #ifdef COMMENT
  2985.             /* we check to see if a macro is waiting to be executed */
  2986.             /* if so, we call domac on it */
  2987.             if (cmdmac) {
  2988.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2989.                 free(cmdmac);
  2990.                 cmdmac = NULL;
  2991.             }
  2992. #endif /* COMMENT */
  2993. #endif /* OS2 */
  2994. #ifndef NOXFER
  2995.             bye_active = 0;
  2996. #endif /* NOXFER */
  2997.             havetoken = 0;
  2998.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2999.             debug(F101,"top-level cmkey2","",xx);
  3000.             if (xx == -5) {
  3001.                 yy = chktok(toktab);
  3002.                 debug(F101,"top-level cmkey token","",yy);
  3003. #ifndef COMMENT
  3004.                 /* Either way makes absolutely no difference */
  3005.                 debug(F110,"NO UNGWORD",atmbuf,0);
  3006.                 /* ungword(); */
  3007. #else
  3008.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  3009.                 ungword();
  3010. #endif /* COMMENT */
  3011.                 switch (yy) {
  3012.                   case '#': xx = XXCOM; break; /* Comment */
  3013.                   case ';': xx = XXCOM; break; /* Comment */
  3014. #ifndef NOSPL
  3015.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  3016.                   case ':': xx = XXLBL; break; /* GOTO label */
  3017. #endif /* NOSPL */
  3018.  
  3019. #ifndef NOPUSH
  3020. #ifdef CK_REDIR
  3021.                   case '<':
  3022. #endif /* CK_REDIR */
  3023.                   case '@':
  3024.                   case '!':
  3025.                     if (nopush) {
  3026.                         char *s; int x;
  3027.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  3028.                           return(x);
  3029.                         success = 0;
  3030.                         xx = XXCOM;
  3031.                     } else {
  3032.                         switch(yy) {
  3033. #ifdef CK_REDIR
  3034.                           case '<': xx = XXFUN; break; /* REDIRECT */
  3035. #endif /* CK_REDIR */
  3036.                           case '@':
  3037.                           case '!': xx = XXSHE; break; /* Shell escape */
  3038.                         }
  3039.                     }
  3040.                     break;
  3041. #endif /* NOPUSH */
  3042. #ifdef CK_RECALL
  3043.                   case '^': xx = XXREDO;  break;
  3044. #endif /* CK_RECALL */
  3045. #ifndef NOSPL
  3046.                   case '{': xx = XXMACRO; break;
  3047.                   case '(': xx = XXSEXP;  break;
  3048. #endif /* NOSPL */
  3049.  
  3050.                   default:
  3051.                     if (!quiet && !cmd_err) {
  3052.                         printf("\n?Invalid - \"%s\"\n",
  3053.                    cmddisplay((char *)cmdbuf,xx)
  3054.                    );
  3055.             cmderr();
  3056.                     }
  3057.                     xx = -2;
  3058.                 }
  3059.                 havetoken = 1;
  3060.                 debug(F101,"HAVE TOKEN","",xx);
  3061.             }
  3062.             if (xx > -1) {
  3063.                 topcmd = xx;            /* Top-level command index */
  3064. #ifndef NOSPL
  3065.                 if (maclvl > -1)
  3066.                   lastcmd[maclvl] = xx;
  3067. #endif /* NOSPL */
  3068.                 debug(F101,"topcmd","",topcmd);
  3069.                 debug(F101,"cmflgs","",cmflgs);
  3070.             }
  3071.  
  3072. #ifndef NOSPL
  3073.             /* Special handling for IF..ELSE */
  3074.  
  3075.             debug(F101,"cmdlvl","",cmdlvl);
  3076.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  3077.  
  3078.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  3079.               ifcmd[cmdlvl]++;
  3080.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  3081.               ifcmd[cmdlvl] = 0;
  3082.  
  3083.             /* Execute the command and take action based on return code. */
  3084.  
  3085.             if (nulcmd) {               /* Ignoring this command? */
  3086.                 xx = XXCOM;             /* Make this command a comment. */
  3087.             }
  3088.             fnsuccess = 1;              /* For catching \function() errors */
  3089. #endif /* NOSPL */
  3090.  
  3091.             debug(F101,"calling docmd()","",xx);
  3092.             zz = docmd(xx);             /* Parse rest of command & execute. */
  3093.  
  3094. #ifndef NOSPL
  3095.             if (fnerror && !fnsuccess)
  3096.               success = 0;
  3097. #endif /* NOSPL */
  3098.             debug(F101,"docmd returns","",zz);
  3099.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  3100.             /* debug(F011,"atmbuf",atmbuf,30); */
  3101. #ifdef MAC
  3102.             if (tlevel > -1) {
  3103.                 if (sstate == 'a') {    /* if cmd-. cancel */
  3104.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  3105.                     sstate = '\0';
  3106.                     dostop();
  3107.                     return(0);          /* End of init file or whatever. */
  3108.                 }
  3109.             }
  3110. #endif /* MAC */
  3111.             switch (zz) {
  3112.               case -4:                  /* EOF (e.g. on redirected stdin) */
  3113.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  3114.               case -1:                  /* Reparse needed */
  3115.                 repars = 1;             /* Just set reparse flag and... */
  3116.                 continue;
  3117. #ifdef OS2
  3118.               case -7:                  /* They typed a disk letter */
  3119.                 if (!zchdir((char *)cmdbuf)) {
  3120.                     perror((char *)cmdbuf);
  3121.                     success = 0;
  3122.                 } else success = 1;
  3123.                 repars = 0;
  3124.                 continue;
  3125.  
  3126. #endif /* OS2 */
  3127.               case -6:                  /* Invalid command given w/no args */
  3128.               case -2: {        /* Invalid command given w/args */
  3129.           int x = 0;
  3130.           char * eol = "";
  3131.           x = strlen(cmdbuf);    /* Avoid blank line */
  3132.           if (x > 0) {
  3133.               if (cmdbuf[x-1] != LF)
  3134.             eol = "\n";
  3135.               printf("?Invalid: %s%s",
  3136.                  cmddisplay(cmdbuf,xx),eol
  3137.                  );
  3138.           } else
  3139.             printf("?Invalid\n");
  3140.           }
  3141.           case -9:            /* Bad, error message already done */
  3142.         success = 0;
  3143.         debug(F110,"top-level cmkey failed",cmdbuf,0);
  3144.         /* If in background w/ commands coming stdin, terminate */
  3145.         if (pflag == 0 && tlevel < 0)
  3146.           fatal("Kermit command error in background execution");
  3147. /*
  3148.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3149.   reprompt the user with as much of the command as didn't fail.
  3150. */
  3151. #ifdef CK_RECALL
  3152.         if (cm_retry && !xcmdsrc) { /* If at top level */
  3153.             int len;
  3154.             char *p, *s;
  3155.             len = strlen(cmdbuf); /* Length of command buffer */
  3156.             p = malloc(len + 1);  /* Allocate space for copy */
  3157.             if (p) {              /* If we got the space copy */
  3158.             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3159.             /* Chop off final field, the one that failed. */
  3160.             s = p + len - 1;          /* Point to end */
  3161.             while (*s == SP && s > p) /* Trim blanks */
  3162.               s--;
  3163.             while (*s != SP && s > p) /* Trim last field */
  3164.               s--;
  3165.             if (s > p)        /* Keep the space */
  3166.               s++;            /* after last good field */
  3167.             if (s >= p)       /* Cut off remainder */
  3168.               *s = NUL;
  3169.             cmini(ckxech);    /* Reinitialize the parser */
  3170.             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3171.             free(p);          /* Free temporary storage */
  3172.             p = NULL;
  3173.             prompt(xxstring); /* Reprint the prompt */
  3174.             printf("%s",cmdbuf); /* Reprint partial command */
  3175.             repars = 1;          /* Force reparse */
  3176.             continue;
  3177.             }
  3178.         } else
  3179. #endif /* CK_RECALL */
  3180.           cmderr();
  3181.  
  3182.         cmini(ckxech);        /* (fall thru) */
  3183.  
  3184.           case -3:            /* Empty command OK at top level */
  3185.         repars = 0;        /* Don't need to reparse. */
  3186.         continue;        /* Go back and get another command. */
  3187.  
  3188.           default:            /* Command was successful. */
  3189. #ifndef NOSPL
  3190.         debug(F101,"parser preparing to continue","",maclvl);
  3191. #endif /* NOSPL */
  3192.         debug(F101,"parser success","",success);
  3193.         repars = 0;        /* Don't need to reparse. */
  3194.         continue;        /* Go back and get another command. */
  3195.         }
  3196.         }
  3197. #ifndef NOSPL
  3198.         debug(F101,"parser breaks out of while loop","",maclvl);
  3199.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3200. #endif /* NOSPL */
  3201.     }
  3202.  
  3203. /* Got an action command, return start state. */
  3204.  
  3205.     return((int) sstate);
  3206. }
  3207.  
  3208. #ifndef NOSPL
  3209. /*
  3210.   OUTPUT command.
  3211.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3212. */
  3213. #define OBSIZE 80                       /* Size of local character buffer */
  3214.  
  3215. static int obn;                         /* Buffer offset (high water mark) */
  3216. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3217. static char *obp;                       /* Pointer to output buffer. */
  3218. _PROTOTYP( static int oboc, (char) );
  3219. _PROTOTYP( static int xxout, (char *, int) );
  3220.  
  3221. static int
  3222. #ifdef CK_ANSIC
  3223. xxout(char *obuf, int obsize)
  3224. #else
  3225. xxout(obuf, obsize) char *obuf; int obsize;
  3226. #endif /* CK_ANSIC */
  3227. /* xxout */ {                           /* OUTPUT command's output function */
  3228.     int i, rc;
  3229.  
  3230.     debug(F101,"xxout obsize","",obsize);
  3231.     debug(F101,"xxout pacing","",pacing);
  3232.     debug(F111,"xxout string",obuf,strlen(obuf));
  3233.  
  3234.     rc = 0;                             /* Initial return code. */
  3235.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3236.       goto xxout_x;                     /* Return successfully */
  3237.  
  3238.     rc = -1;                              /* Now assume failure */
  3239.     if (pacing == 0) {                    /* Is pacing enabled? */
  3240.         if ((local ?                      /* No, write entire string at once */
  3241.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3242.              conxo(obsize, obuf))         /* or to console */
  3243.             != obsize)
  3244.           goto xxout_x;
  3245.     } else {
  3246.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3247.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3248.               goto xxout_x;
  3249.             msleep(pacing);
  3250.         }
  3251.     }
  3252.     if (duplex) {
  3253. #ifdef OS2
  3254.         if (inecho && local) {
  3255. #ifndef NOLOCAL
  3256.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3257.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3258.             }
  3259. #endif /* NOLOCAL */
  3260.             conxo(obsize,obuf);
  3261.         } else if (seslog) {            /* or log session here */
  3262.             logstr((char *) obuf, obsize);
  3263.         }
  3264. #else /* OS2 */
  3265.         if (seslog) {
  3266.             logstr((char *) obuf, obsize);
  3267.         }
  3268.         if (inecho && local) {
  3269.             conxo(obsize,obuf);
  3270.         }
  3271. #endif /* OS2 */
  3272.     }
  3273.     rc = 0;                             /* Success */
  3274.   xxout_x:
  3275.     obn = 0;                            /* Reset count */
  3276.     obp = obuf;                         /* and pointers */
  3277.     return(rc);                         /* return our return code */
  3278. }
  3279.  
  3280. #ifdef COMMENT
  3281. /*
  3282.   Macros for OUTPUT command execution, to make it go faster.
  3283. */
  3284. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3285. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3286.  
  3287. #else /* The macros cause some compilers to generate bad code. */
  3288.  
  3289. static int
  3290. #ifdef CK_ANSIC
  3291. oboc(char c)
  3292. #else
  3293. oboc(c) char c;
  3294. #endif /* CK_ANSIC */
  3295. /* oboc */ {                            /* OUTPUT command's output function */
  3296.  
  3297.     *obp++ = c;                         /* Deposit character */
  3298.     *obp = NUL;                         /* Flush buffer if it's now full */
  3299.  
  3300.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3301. }
  3302. #endif /* COMMENT */
  3303.  
  3304. /*  Routines for handling local variables -- also see popclvl().  */
  3305.  
  3306. VOID
  3307. freelocal(m) int m; {                   /* Free local variables */
  3308.     struct localvar * v, * tv;          /* at macro level m... */
  3309.     debug(F101,"freelocal level","",m);
  3310.     if (m < 0) return;
  3311.     v = localhead[m];                   /* List head for level m */
  3312.     while (v) {
  3313.         if (v->lv_name)                 /* Variable name */
  3314.           free(v->lv_name);
  3315.         if (v->lv_value)                /* Value */
  3316.           free(v->lv_value);
  3317.         tv = v;                         /* Save pointer to this node */
  3318.         v = v->lv_next;                 /* Get next one */
  3319.         if (tv)                         /* Free this one */
  3320.           free((char *)tv);
  3321.     }
  3322.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3323. }
  3324.  
  3325. #define MAXLOCALVAR 64
  3326.  
  3327. /* Return a pointer to the definition of a user-defined variable */
  3328.  
  3329. static char *
  3330. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3331.     char * p;
  3332.     char c;
  3333.     *isarray = 0;
  3334.     if (!s) return(NULL);
  3335.     if (!*s) return(NULL);
  3336.     p = s;
  3337.     if (*s == CMDQ) {
  3338.         p++;
  3339.         if (!*p)
  3340.           return(NULL);
  3341.         if ((c = *p) == '%') {          /* Scalar variable. */
  3342.             c = *++p;                   /* Get ID character. */
  3343.             p = "";                     /* Assume definition is empty */
  3344.             if (!c)
  3345.               return(NULL);
  3346.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3347.                 if (maclvl < 0)         /* Digit variables are global */
  3348.                   return(g_var[c]);     /* if no macro is active */
  3349.                 else                    /* otherwise */
  3350.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3351.             } else if (isalpha(c)) {
  3352.                 if (isupper(c)) c -= ('a'-'A');
  3353.                 return(g_var[c]);           /* Letter for global variable */
  3354.             } else
  3355.               return(NULL);
  3356.         } else if (c == '&') {          /* Array reference. */
  3357.             int x, vbi, d;
  3358.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3359.             if (x > -1 || d == -17) {
  3360.                 *isarray = 1;
  3361.                 *x1 = vbi;
  3362.                 *x2 = (d == -17) ? 0 : d;
  3363.             }
  3364.             if (x < 0)
  3365.               return(NULL);
  3366.             if (chkarray(vbi,d) >= 0) {    /* Array is declared? */
  3367.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3368.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3369.                     char **ap;
  3370.                     ap = a_ptr[vbi];
  3371.                     return((ap) ? ap[d] : NULL);
  3372.                 }
  3373.             }
  3374.         }
  3375.         return(NULL);
  3376.     } else {
  3377.         int k;
  3378.         k = mxlook(mactab,s,nmac);
  3379.         return((k > -1) ? mactab[k].mval : NULL);
  3380.     }
  3381. }
  3382.  
  3383.  
  3384. int
  3385. addlocal(p) char * p; {
  3386.     int x, z, isarray = 0;
  3387.     char * s;
  3388.     struct localvar * v, *prev = (struct localvar *)NULL;
  3389.     extern int tra_asg; int tra_tmp;
  3390.  
  3391.     tra_tmp = tra_asg;
  3392.  
  3393.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3394.     if (isarray) {                      /* Arrays are handled specially */
  3395.         pusharray(x,z);
  3396.         return(0);
  3397.     }
  3398.     if (!s) s = "";
  3399.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3400.         while (v) {                     /* Find end of list */
  3401.             prev = v;
  3402.             v = v->lv_next;
  3403.         }
  3404.     }
  3405.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3406.     if (!v) {
  3407.         printf("?Failure to allocate storage for local variables");
  3408.         return(-9);
  3409.     }
  3410.     if (!localhead[cmdlvl])             /* If first, set list head */
  3411.       localhead[cmdlvl] = v;
  3412.     else                                /* Otherwise link previous to this */
  3413.       prev->lv_next = v;
  3414.     prev = v;                           /* And make this previous */
  3415.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3416.  
  3417.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3418.       return(-1);
  3419.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3420.  
  3421.     if (*s) {
  3422.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3423.           return(-1);
  3424.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3425.     } else
  3426.       v->lv_value = NULL;
  3427.  
  3428.     tra_asg = 0;
  3429.     delmac(p,1);                        /* Delete the original macro */
  3430.     tra_asg = tra_tmp;
  3431.     return(0);
  3432. }
  3433.  
  3434. int
  3435. dolocal() {                             /* Do the LOCAL command */
  3436.     int i, x;
  3437.     char * s;
  3438.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3439.  
  3440.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3441.       return(x);
  3442.  
  3443.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3444.  
  3445.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3446.  
  3447.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3448.         if (addlocal(list[i]) < 0)
  3449.           goto localbad;
  3450.     }
  3451.     return(success = 1);
  3452.  
  3453.   localbad:
  3454.     printf("?Failure to allocate storage for local variables");
  3455.     freelocal(cmdlvl);
  3456.     return(-9);
  3457. }
  3458.  
  3459. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3460.  
  3461. #ifndef NOKVERBS
  3462. #define K_BUFLEN 30
  3463. #define SEND_BUFLEN 255
  3464. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3465.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3466. #endif /* NOKVERBS */
  3467.  
  3468. int outesc = 1;                         /* Process special OUTPUT escapes */
  3469.  
  3470. int
  3471. dooutput(s, cx) char *s; int cx; {
  3472. #ifdef SSHBUILTIN
  3473.     extern int ssh_cas;
  3474.     extern char * ssh_cmd;
  3475. #endif /* SSHBUILTIN */
  3476.     int x, xx, y, quote;                /* Workers */
  3477.     int is_tn = 0;
  3478.  
  3479.     is_tn = (local && network && IS_TELNET()) ||
  3480.       (!local && sstelnet);
  3481.  
  3482.     debug(F111,"dooutput s",s,(int)strlen(s));
  3483.  
  3484.     if (local) {                        /* Condition external line */
  3485. #ifdef NOLOCAL
  3486.         goto outerr;
  3487. #else
  3488.     if (ttchk() < 0) {
  3489.         if (!network) {
  3490.         if (carrier != CAR_OFF) {
  3491.             int x;
  3492.             x = ttgmdm();
  3493.             if ((x > -1) && ((x & BM_DCD) == 0)) {
  3494.             printf(
  3495. "?Carrier signal required but not present - Try SET CARRIER-WATCH OFF.\n"
  3496.                               );
  3497.             return(0);
  3498.             }
  3499.         } else {
  3500.             printf(
  3501. "?Problem with serial port or modem or cable - Try SHOW COMMUNICATIONS.\n"
  3502.                           );
  3503.             return(0);
  3504.         }
  3505.         }
  3506.         printf("?Connection %s %s is not open or not functioning.\n",
  3507.            network ? "to" : "on",
  3508.            ttname
  3509.            );
  3510.         return(0);
  3511.     }
  3512.         if (ttvt(speed,flow) < 0) {
  3513.             printf("?OUTPUT initialization error\n");
  3514.             return(0);
  3515.         }
  3516. #endif /* NOLOCAL */
  3517.     }
  3518. #ifdef SSHBUILTIN
  3519.     if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd && 
  3520.          !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
  3521.         if (!quiet)
  3522.             printf("?SSH Subsystem active: %s\n", ssh_cmd);
  3523.         return(0);
  3524.     }
  3525. #endif /* SSHBUILTIN */
  3526.  
  3527.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3528.         x = strlen(s);                  /* Just send the string literally */
  3529.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3530.         return(success = (xx == x) ? 1 : 0);
  3531.     }
  3532.     quote = 0;                          /* Initialize backslash (\) quote */
  3533.     obn = 0;                            /* Reset count */
  3534.     obp = obuf;                         /* and pointers */
  3535.  
  3536.   outagain:
  3537.     while ((x = *s++)) {                /* Loop through the string */
  3538.         y = 0;                          /* Error code, 0 = no error. */
  3539.         debug(F000,"dooutput","",x);
  3540.         if (quote) {                    /* This character is quoted */
  3541. #ifndef NOKVERBS
  3542.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3543.                extern struct keytab kverbs[];
  3544.                extern int nkverbs;
  3545.                extern char * keydefptr;
  3546.                extern int keymac;
  3547.                extern int keymacx;
  3548.                int x, y, brace = 0;
  3549.                int pause;
  3550.                char * p, * b;
  3551.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3552.                char osendbuf[SEND_BUFLEN +1];
  3553.                int  sendndx = 0;
  3554.  
  3555.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3556.                  goto outerr;
  3557.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3558.                {                        /* Have K verb? */
  3559.                    if (!*s) {
  3560.                        break;
  3561.                    }
  3562. /*
  3563.   We assume that the verb name is {braced}, or it extends to the end of the
  3564.   string, s, or it ends with a space, control character, or backslash.
  3565. */
  3566.                    p = kbuf;            /* Copy verb name into local buffer */
  3567.                    x = 0;
  3568.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3569.                        if (brace && *s == '}') {
  3570.                            break;
  3571.                        }
  3572.                        *p++ = *s++;
  3573.                    }
  3574.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3575.                      s--;               /*  back up so we get another look. */
  3576.                    brace = 0;
  3577.                    *p = NUL;            /* Terminate. */
  3578.                    p = kbuf;            /* Point back to beginning */
  3579.                    debug(F110,"dooutput kverb",p,0);
  3580.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3581.                    debug(F101,"dooutput lookup",0,y);
  3582.                    if (y > -1) {
  3583.                        if (sendndx) {
  3584.                            dooutput(osendbuf,cx);
  3585.                            sendndx = 0;
  3586.                        }
  3587.                        dokverb(VCMD,y);
  3588. #ifndef NOSPL
  3589.                    } else {             /* Is it a macro? */
  3590.                        y = mxlook(mactab,p,nmac);
  3591.                        if (y > -1) {
  3592.                            cmpush();
  3593.                            keymac = 1;  /* Flag for key macro active */
  3594.                            keymacx = y; /* Key macro index */
  3595.                            keydefptr = s; /* Where to resume next time */
  3596.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3597.                            parser(1);
  3598.                            cmpop();
  3599.                        }
  3600. #endif /* NOSPL */
  3601.                    }
  3602.                }
  3603.                quote = 0;
  3604.                continue;
  3605.            } else
  3606. #endif /* NOKVERBS */
  3607.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3608.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3609.                    goto outerr;
  3610.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3611.                  if (local)
  3612.                    ttoc(NUL);
  3613.                  else
  3614.                    conoc(NUL);
  3615.                  quote = 0;
  3616.                  continue;
  3617.  
  3618.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3619.  
  3620.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3621.                   goto outerr;
  3622.                 debug(F100,"OUTPUT BREAK","",0);
  3623. #ifndef NOLOCAL
  3624.                 ttsndb();               /* Send BREAK signal */
  3625. #else
  3626.                  if (local)
  3627.                    ttoc(NUL);
  3628.                  else
  3629.                    conoc(NUL);
  3630. #endif /* NOLOCAL */
  3631.                 quote = 0;              /* Turn off quote flag */
  3632.                 continue;               /* and not the b or B */
  3633. #ifdef CK_LBRK
  3634.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3635.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3636.                    goto outerr;
  3637.                  debug(F100,"OUTPUT Long BREAK","",0);
  3638. #ifndef NOLOCAL
  3639.                  ttsndlb();             /* Send Long BREAK signal */
  3640. #else
  3641.                  if (local)
  3642.                    ttoc(NUL);
  3643.                  else
  3644.                    conoc(NUL);
  3645. #endif /* NOLOCAL */
  3646.                  quote = 0;             /* Turn off quote flag */
  3647.                  continue;              /* and not the l or L */
  3648. #endif /* CK_LBRK */
  3649.  
  3650.              } else if (x == CMDQ) {    /* Backslash itself */
  3651.                  debug(F100,"OUTPUT CMDQ","",0);
  3652.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3653.                  if (xx < 0)
  3654.                    goto outerr;
  3655.                  quote = 0;
  3656.                  continue;
  3657.  
  3658.              } else {                   /* if \ not followed by special esc */
  3659.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3660.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3661.                  if (xx < 0)
  3662.                    goto outerr;
  3663.                  quote = 0;             /* Turn off quote flag */
  3664.              }
  3665.         } else if (x == CMDQ) {         /* This is the quote character */
  3666.             quote = 1;                  /* Go back and get next character */
  3667.             continue;                   /* which is quoted */
  3668.         }
  3669.         xx = oboc(dopar((char)x));      /* Output this character */
  3670.         debug(F111,"dooutput",obuf,obn);
  3671.         if (xx < 0)
  3672.           goto outerr;
  3673. #ifdef COMMENT
  3674.         if (seslog && duplex) {         /* Log the character if log is on */
  3675.             logchar((char)x);
  3676.         }
  3677. #endif /* COMMENT */
  3678.         if (x == '\015') {              /* String contains carriage return */
  3679.             int stuff = -1, stuff2 = -1;
  3680.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3681.                 stuff = LF;             /* Stuff LF */
  3682.             }
  3683. #ifdef TNCODE
  3684.             /* TELNET NEWLINE ON/OFF/RAW */
  3685.             if (is_tn) {
  3686.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3687.                         tn_b_nlm :
  3688.                         tn_nlm
  3689.                         ) {
  3690.                   case TNL_CR:
  3691.                     break;
  3692.                   case TNL_CRNUL:
  3693.                     stuff2 = stuff;
  3694.                     stuff  = NUL;
  3695.                     break;
  3696.                   case TNL_CRLF:
  3697.                     stuff2 = stuff;
  3698.                     stuff = LF;
  3699.                     break;
  3700.                 }
  3701.             }
  3702. #endif /* TNCODE */
  3703.             if (stuff > -1) {           /* Stuffing another character... */
  3704.                 xx = oboc(dopar((CHAR)stuff));
  3705.                 if (xx < 0)
  3706.                   goto outerr;
  3707. #ifdef COMMENT
  3708.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3709.                     logchar((char)stuff);
  3710.                 }
  3711. #endif /* COMMENT */
  3712.             }
  3713.             if (stuff2 > -1) {          /* Stuffing another character... */
  3714.                 xx = oboc(dopar((CHAR)stuff2));
  3715.                 if (xx < 0)
  3716.                   goto outerr;
  3717. #ifdef COMMENT
  3718.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3719.                     logchar((char)stuff2);
  3720.                 }
  3721. #endif /* COMMENT */
  3722.             }
  3723.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3724.               goto outerr;
  3725.         }
  3726.     }
  3727.     if (cx == XXLNOUT) {
  3728.         s = "\015";
  3729.         cx = 0;
  3730.         goto outagain;
  3731.     }
  3732.     if (quote == 1)                     /* String ended with backslash */
  3733.       xx = oboc(dopar(CMDQ));
  3734.  
  3735.     if (obn > 0)                        /* OUTPUT done */
  3736.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3737.         goto outerr;
  3738.     return(1);
  3739.  
  3740. outerr:                                 /* OUTPUT command error handler */
  3741.     if (msgflg) printf("?OUTPUT execution error\n");
  3742.     return(0);
  3743.  
  3744. /* Remove "local" OUTPUT macro defininitions */
  3745.  
  3746. #ifdef COMMENT
  3747. /* No more macros ... */
  3748. #undef oboc
  3749. #undef obfls
  3750. #endif /* COMMENT */
  3751. }
  3752. #endif /* NOSPL */
  3753.  
  3754. /* Display version herald and initial prompt */
  3755.  
  3756. VOID
  3757. herald() {
  3758.     int x = 0, i;
  3759.     extern int srvcdmsg;
  3760.     extern char * cdmsgfile[];
  3761. #ifndef NOCMDL
  3762.     extern char * bannerfile;
  3763.     debug(F110,"herald bannerfile",bannerfile,0);
  3764.     if (bannerfile) {
  3765.         concb((char)escape);
  3766.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3767.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3768.             if (srvcdmsg) {
  3769.                 for (i = 0; i < 8; i++) {
  3770.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3771.                     if (zchki(cdmsgfile[i]) > -1) {
  3772.                         printf("\n");
  3773.                         dotype(cdmsgfile[i],
  3774.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3775.                         break;
  3776.                     }
  3777.                 }
  3778.             }
  3779.             return;
  3780.         }
  3781.     }
  3782. #endif /* NOCMDL */
  3783.  
  3784. #ifdef COMMENT
  3785.     /* The following generates bad code in SCO compilers. */
  3786.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3787.     /* statement when all conditions are false, x has a value of -32. */
  3788.     if (noherald || quiet || bgset > 0 || (bgset != 0 && backgrd != 0))
  3789.       x = 1;
  3790. #else
  3791.     x = 0;
  3792.     if (noherald || quiet)
  3793.       x = 1;
  3794.     else if (bgset > 0)
  3795.       x = 1;
  3796.     else if (bgset < 0 && backgrd > 0)
  3797.       x = 1;
  3798. #endif /* COMMENT */
  3799.  
  3800.     if (x == 0) {
  3801. #ifdef datageneral
  3802.         printf("%s, for%s\n",versio,ckxsys);
  3803. #else
  3804. #ifdef OSK
  3805.         printf("%s, for%s\n",versio,ckxsys);
  3806. #else
  3807. #ifdef CK_64BIT
  3808.         printf("%s, for%s (64-bit)\n\r",versio,ckxsys);
  3809. #else
  3810.         printf("%s, for%s\n\r",versio,ckxsys);
  3811. #endif/* CK_64BIT */
  3812. #endif /* OSK */
  3813. #endif /* datageneral */
  3814.         printf(" Copyright (C) 1985, 2009,\n");
  3815.         printf("  Trustees of Columbia University in the City of New York.\n");
  3816. #ifdef OS2
  3817.        shoreg();
  3818. #endif /* OS2 */
  3819.  
  3820.         if (!quiet && !backgrd) {
  3821. #ifdef COMMENT
  3822. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3823.             char * s;
  3824.             extern int xfermode;
  3825. #ifdef VMS
  3826.             s = "AUTOMATIC";
  3827. #else
  3828.             if (xfermode == XMODE_A) {
  3829.                 s = "AUTOMATIC";
  3830.             } else {
  3831.                 s = gfmode(binary,1);
  3832.             }
  3833.             if (!s) s = "";
  3834. #endif /* VMS */
  3835.             if (*s)
  3836.               printf("Default file-transfer mode is %s\n", s);
  3837. #endif /* COMMENT */
  3838.  
  3839.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3840.             if (srvcdmsg) {
  3841.                 for (i = 0; i < 8; i++) {
  3842.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3843.                     if (zchki(cdmsgfile[i]) > -1) {
  3844.                         printf("\n");
  3845.                         dotype(cdmsgfile[i],
  3846.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3847.                         break;
  3848.                     }
  3849.                 }
  3850.             }
  3851.             printf("Type ? or HELP for help.\n");
  3852.         }
  3853.     }
  3854. }
  3855.  
  3856. /*  G F M O D E  --  Get File (transfer) Mode  */
  3857.  
  3858. char *
  3859. gfmode(binary,upcase) int binary, upcase; {
  3860.     char * s;
  3861.     switch (binary) {
  3862.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3863. #ifdef VMS
  3864.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3865.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3866.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3867.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3868. #else
  3869. #ifdef MAC
  3870.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3871.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3872. #else
  3873.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3874. #ifdef CK_LABELED
  3875.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3876. #endif /* CK_LABELED */
  3877. #endif /* MAC */
  3878. #endif /* VMS */
  3879.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3880.       default: s = "";
  3881.     }
  3882.     return(s);
  3883. }
  3884.  
  3885. #ifndef NOSPL
  3886. static int
  3887. isaa(s) char * s; {                     /* Is associative array */
  3888.     char c;
  3889.     int x;
  3890.     if (!s) s = "";
  3891.     if (!*s) return(0);
  3892.     s++;
  3893.     while ((c = *s++)) {
  3894.         if (c == '<') {
  3895.             x = strlen(s);
  3896.             return ((*(s+x-1) == '>') ? 1 : 0);
  3897.         }
  3898.     }
  3899.     return(0);
  3900. }
  3901.  
  3902. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3903.  
  3904. /*
  3905.   Call this way:  v = mlook(table,word,n);
  3906.  
  3907.     table - a 'struct mtab' table.
  3908.     word  - the target string to look up in the table.
  3909.     n     - the number of elements in the table.
  3910.  
  3911.   The keyword table must be arranged in ascending alphabetical order, and
  3912.   all letters must be lowercase.
  3913.  
  3914.   Returns the table index, 0 or greater, if the name was found, or:
  3915.  
  3916.    -3 if nothing to look up (target was null),
  3917.    -2 if ambiguous,
  3918.    -1 if not found.
  3919.  
  3920.   A match is successful if the target matches a keyword exactly, or if
  3921.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3922.   target matches two or more keywords from the table.
  3923. */
  3924. int
  3925. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3926.     register int i;
  3927.     int v, w, cmdlen = 0;
  3928.     char c = 0, c1, * s;
  3929.     if (!cmd) cmd = "";
  3930.  
  3931.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3932.     debug(F111,"MLOOK",cmd,cmdlen);
  3933.  
  3934.     c1 = *cmd;
  3935.     if (isupper(c1))
  3936.       c1 = tolower(c1);
  3937.     if (cmdlen < 1)
  3938.       return(-3);
  3939.  
  3940. /* Not null, look it up */
  3941.  
  3942.     if (n < 12) {                       /* Not worth it for small tables */
  3943.         i = 0;
  3944.     } else {                            /* Binary search for where to start */
  3945.         int lo = 0;
  3946.         int hi = n;
  3947.         int count = 0;
  3948.         while (lo+2 < hi && ++count < 12) {
  3949.             i = lo + ((hi - lo) / 2);
  3950.             c = *(table[i].kwd);
  3951.             if (isupper(c)) c = tolower(c);
  3952.             if (c < c1) {
  3953.                 lo = i;
  3954.             } else {
  3955.                 hi = i;
  3956.             }
  3957.         }
  3958.         i = (c < c1) ? lo+1 : lo;
  3959.     }
  3960.     for ( ; i < n-1; i++) {
  3961.         s = table[i].kwd;
  3962.         if (!s) s = "";
  3963.         if (!*s) continue;              /* Empty table entry */
  3964.         c = *s;
  3965.         if (isupper(c)) c = tolower(c);
  3966.         if (c1 != c) continue;          /* First char doesn't match */
  3967.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  3968.           return(i);
  3969.         v = !ckstrcmp(s,cmd,cmdlen,0);
  3970.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3971.         if (v && w)                     /* Have abbreviated match? */
  3972.           return(i);
  3973.         if (v)                          /* Ambiguous? */
  3974.           return(-2);
  3975.         if (w > 0)                      /* Past our alphabetic area? */
  3976.           return(-1);
  3977.     }
  3978.  
  3979. /* Last (or only) element */
  3980.  
  3981.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3982.       return(n-1);
  3983.  
  3984.     return(-1);
  3985. }
  3986.  
  3987. /* mxlook is like mlook, but an exact full-length match is required */
  3988.  
  3989. int
  3990. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3991.     register int i;
  3992.     int w, cmdlen = 0, one = 0;
  3993.     register char c = 0, c1, * s;
  3994.  
  3995.     if (!cmd) cmd = "";                 /* Check args */
  3996.  
  3997.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3998.     debug(F111,"MXLOOK",cmd,cmdlen);
  3999.  
  4000.     c1 = *cmd;                          /* First char of string to look up */
  4001.     if (isupper(c1))
  4002.       c1 = tolower(c1);
  4003.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  4004.       one = 1;
  4005.  
  4006.     if (cmdlen < 1)                     /* Nothing to look up */
  4007.       return(-3);
  4008.  
  4009.     if (n < 12) {                       /* Not worth it for small tables */
  4010.         i = 0;
  4011.     } else {                            /* Binary search for where to start */
  4012.         int lo = 0;
  4013.         int hi = n;
  4014.         int count = 0;
  4015.         while (lo+2 < hi && ++count < 12) {
  4016.             i = lo + ((hi - lo) / 2);
  4017.             c = *(table[i].kwd);
  4018.             if (isupper(c)) c = tolower(c);
  4019.             if (c < c1) {
  4020.                 lo = i;
  4021.             } else {
  4022.                 hi = i;
  4023.             }
  4024.         }
  4025.         i = (c < c1) ? lo+1 : lo;
  4026.     }
  4027.     for ( ; i < n; i++) {               /* Look thru table */
  4028.         s = table[i].kwd;               /* This entry */
  4029.         if (!s) s = "";
  4030.         if (!*s) continue;              /* Empty table entry */
  4031.         c = *s;
  4032.         if (isupper(c)) c = tolower(c);
  4033.         if (c1 != c) continue;          /* First char doesn't match */
  4034.         if (one) {                      /* Name is one char long */
  4035.             if (!*(s+1))
  4036.               return(i);                /* So is table entry */
  4037.         }
  4038. #ifdef COMMENT
  4039.         if (((int)strlen(s) == cmdlen) &&
  4040.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  4041. #else
  4042.         w = ckstrcmp(s,cmd,-1,0);
  4043.         if (!w) return(i);
  4044.         if (w > 0) return(-1);
  4045. #endif /* COMMENT */
  4046.     }
  4047.     return(-1);
  4048. }
  4049.  
  4050. /* mxxlook is like mxlook, but case-sensitive */
  4051.  
  4052. int
  4053. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  4054.     int i, cmdlen;
  4055.     if (!cmd) cmd = "";
  4056.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  4057.     /* debug(F111,"mxxlook target",cmd,n); */
  4058.     for (i = 0; i < n; i++) {
  4059.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  4060.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  4061.           return(i);
  4062.     }
  4063.     return(-1);
  4064. }
  4065.  
  4066. static int
  4067. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  4068.     if (val)
  4069.       printf(">>> %s: \"%s\"\n", nam, val);
  4070.     else
  4071.       printf(">>> %s: (undef)\n", nam);
  4072.     return(0);
  4073. }
  4074.  
  4075. #ifdef USE_VARLEN                       /* Not used */
  4076.  
  4077. /*  V A R L E N  --  Get length of variable's value.
  4078.  
  4079.   Given a variable name, return the length of its definition or 0 if the
  4080.   variable is not defined.  If it is defined, set argument s to point to its
  4081.   definition.  Otherwise set s to NULL.
  4082. */
  4083. int
  4084. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  4085.     int x, z;
  4086.     char *p = NULL, c;
  4087.  
  4088.     *s = NULL;
  4089.     if (!nam) return(0);                /* Watch out for null pointer */
  4090.     if (*nam == CMDQ) {
  4091.         nam++;
  4092.         if (*nam == '%') {              /* If it's a variable name */
  4093.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  4094.             p = (char *)0;              /* Initialize value pointer */
  4095.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4096.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  4097.             } else {                    /* It's a global variable */
  4098.                 if (c < 33 || c > GVARS) return(0);
  4099.                 p = g_var[c];           /* Get pointer from global-var table */
  4100.             }
  4101.         } else if (*nam == '&') {               /* An array reference? */
  4102.             char **q;
  4103.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4104.               return(-1);               /* return -1. */
  4105.             x -= ARRAYBASE;             /* Convert name to number. */
  4106.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4107.               return(0);                /* return -2. */
  4108.             if (z > a_dim[x])           /* If subscript out of range, */
  4109.               return(0);                /* return -3. */
  4110.             p = q[z];
  4111.         }
  4112.     } else {                            /* Macro */
  4113.         z = isaa(nam);
  4114.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  4115.         if (x < 0)
  4116.           return(0);
  4117.         p = mactab[x].mval;
  4118.     }
  4119.     if (p)
  4120.       *s = p;
  4121.     else
  4122.       p = "";
  4123.     return((int)strlen(p));
  4124. }
  4125. #endif /* USE_VARLEN */
  4126.  
  4127. /*
  4128.   This routine is for the benefit of those compilers that can't handle
  4129.   long string constants or continued lines within them.  Long predefined
  4130.   macros like FOR, WHILE, and XIF have their contents broken up into
  4131.   arrays of string pointers.  This routine concatenates them back into a
  4132.   single string again, and then calls the real addmac() routine to enter
  4133.   the definition into the macro table.
  4134. */
  4135. int
  4136. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  4137.     int i, x, y; char *p;
  4138.     x = 0;                              /* Length counter */
  4139.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  4140.         debug(F111,"addmmac line",s[i],y);
  4141.         x += y;
  4142.     }
  4143.     debug(F101,"addmmac lines","",i);
  4144.     debug(F101,"addmmac loop exit","",y);
  4145.     debug(F111,"addmmac length",nam,x);
  4146.     if (x < 0) return(-1);
  4147.  
  4148.     p = malloc(x+1);                    /* Allocate space for all of it. */
  4149.     if (!p) {
  4150.         printf("?addmmac malloc error: %s\n",nam);
  4151.         debug(F110,"addmmac malloc error",nam,0);
  4152.         return(-1);
  4153.     }
  4154.     *p = '\0';                          /* Start off with null string. */
  4155.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4156.       ckstrncat(p,s[i],x+1);
  4157.     y = (int)strlen(p);                 /* Final precaution. */
  4158.     debug(F111,"addmmac constructed string",p,y);
  4159.     if (y == x) {
  4160.         y = addmac(nam,p);              /* Add result to the macro table. */
  4161.     } else {
  4162.         debug(F100,"addmmac length mismatch","",0);
  4163.         printf("\n!addmmac internal error!\n");
  4164.         y = -1;
  4165.     }
  4166.     free(p);                            /* Free the temporary copy. */
  4167.     return(y);
  4168. }
  4169.  
  4170. /* Here is the real addmac routine. */
  4171.  
  4172. /* Returns -1 on failure, macro table index >= 0 on success. */
  4173.  
  4174. int mtchanged = 0;
  4175.  
  4176. int
  4177. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4178.     int i, x, y, z, namlen, deflen, flag = 0;
  4179.     int replacing = 0, deleting = 0;
  4180.     char * p = NULL, c, *s;
  4181.     extern int tra_asg; int tra_tmp;
  4182.  
  4183.     if (!nam) return(-1);
  4184.     if (!*nam) return(-1);
  4185.  
  4186. #ifdef IKSD
  4187.     if (inserver &&
  4188. #ifdef IKSDCONF
  4189.         iksdcf
  4190. #else /* IKSDCONF */
  4191.         1
  4192. #endif /* IKSDCONF */
  4193.         ) {
  4194.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4195.             !ckstrcmp("on_logout",nam,-1,0))
  4196.           return(-1);
  4197.     }
  4198. #endif /* IKSD */
  4199.  
  4200.     namlen = 0;
  4201.     p = nam;
  4202.     while (*p++) namlen++;              /* (instead of strlen) */
  4203.  
  4204.     tra_tmp = tra_asg;                  /* trace... */
  4205.     debug(F111,"addmac nam",nam,namlen);
  4206.     if (!def) {                         /* Watch out for null pointer */
  4207.         deflen = 0;
  4208.         debug(F111,"addmac def","(null pointer)",deflen);
  4209.     } else {
  4210.         deflen = 0;
  4211.         p = def;
  4212.         while (*p++) deflen++;          /* (instead of strlen) */
  4213.         debug(F010,"addmac def",def,0);
  4214.     }
  4215. #ifdef USE_VARLEN                       /* NOT USED */
  4216.     /* This does not boost performance much because varlen() does a lot */
  4217.     x = varlen(nam,&s);
  4218.     if (x > 0 && x >= deflen) {
  4219.         strcpy(s,def);                  /* NOT USED */
  4220.         flag = 1;
  4221.         p = s;
  4222.     }
  4223. #endif /* USE_VARLEN */
  4224.  
  4225.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4226.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4227.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4228.         if (!flag) {
  4229.             tra_asg = 0;
  4230.             delmac(nam,0);              /* Delete any old value. */
  4231.             tra_asg = tra_tmp;
  4232.         }
  4233.         if (deflen < 1) {               /* Null definition */
  4234.             p = NULL;                   /* Better not malloc or strcpy! */
  4235.         } else if (!flag) {             /* A substantial definition */
  4236.             p = malloc(deflen + 1);     /* Allocate space for it */
  4237.             if (!p) {
  4238.                 printf("?addmac malloc error 2\n");
  4239.                 return(-1);
  4240.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4241.         }
  4242.  
  4243.         /* Now p points to the definition, or is a null pointer */
  4244.  
  4245.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4246.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4247.                 g_var[c] = p;           /* No, it's top level one */
  4248.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4249.             } else {                    /* Yes, it's a macro argument */
  4250.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4251.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4252.             }
  4253.         } else {                        /* It's a \%a-z variable */
  4254.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4255.             if (isupper(c)) c = (char) tolower(c);
  4256.             g_var[c] = p;               /* Put pointer in global-var table */
  4257.         }
  4258.         if (tra_asg) traceval(nam,p);
  4259.         return(0);
  4260.     } else if (*nam == '&') {           /* An array reference? */
  4261.         char **q = NULL;
  4262.         int rc = 0;
  4263.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4264.           return(-1);                   /* return -1. */
  4265.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4266.           rc = -2;                      /* subscript out of range, ret -2 */
  4267.         if (!flag) {
  4268.             tra_asg = 0;
  4269.             delmac(nam,0);              /* Delete any old value. */
  4270.             tra_asg = tra_tmp;
  4271.         }
  4272.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4273.         if (x > 'z' - ARRAYBASE + 1)
  4274.           rc = -1;
  4275.         if (rc != -1) {
  4276.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4277.               return(-3);               /* return -3. */
  4278.         }
  4279.         if (rc < 0)
  4280.           return(rc);
  4281.         if (!flag) {
  4282.             if (deflen > 0) {
  4283.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4284.                     printf("addmac macro error 7: %s\n",nam);
  4285.                     return(-4);         /* for new def, return -4 on fail. */
  4286.                 }
  4287.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4288.             } else p = NULL;
  4289.         }
  4290.         q[z] = p;                       /* Store pointer to it. */
  4291.         if (x == 0) {                   /* Arg vector array */
  4292.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4293.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4294.                     makestr(&(toparg[z]),p);
  4295.                 } else {
  4296.                     makestr(&(m_arg[maclvl][z]),p);
  4297.                 }
  4298.             }
  4299.         }
  4300.         if (tra_asg) traceval(nam,p);
  4301.         return(0);                      /* Done. */
  4302.     }
  4303.  
  4304. /* Not a macro argument or a variable, so it's a macro definition */
  4305.  
  4306. #ifdef USE_VARLEN
  4307.     if (flag) {
  4308.         if (tra_asg) traceval(nam,p);
  4309.         return(0);
  4310.     }
  4311. #endif /* USE_VARLEN */
  4312.     x = isaa(nam) ?                     /* If it's an associative array */
  4313.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4314.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4315.     if (x > -1) {                       /* If found... */
  4316.         if (deflen > 0)                 /* and a new definition was given */
  4317.           replacing = 1;                /* we're replacing */
  4318.         else                            /* otherwise */
  4319.           deleting = 1;                 /* we're deleting */
  4320.     }
  4321.     if (deleting) {                     /* Deleting... */
  4322.         if (delmac(nam,0) < 0)
  4323.           return(-1);
  4324.         mtchanged++;
  4325.         if (tra_asg) traceval(nam,p);
  4326.         return(0);
  4327.     } else if (deflen < 1)              /* New macro with no definition */
  4328.       return(0);                        /* Nothing to do. */
  4329.  
  4330.     if (replacing) {                    /* Replacing an existing macro */
  4331.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4332.             free(mactab[x].mval);       /* free it. */
  4333.             mactab[x].mval = NULL;
  4334.         }
  4335.         mtchanged++;
  4336.         y = x;                          /* Replacement index. */
  4337.  
  4338.     } else {                            /* Adding a new macro... */
  4339.         char c1, c2;                    /* Use fast lookup to find the */
  4340.         c1 = *nam;                      /* alphabetical slot. */
  4341.         if (isupper(c1)) c1 = (char) tolower(c1);
  4342.  
  4343.         if (nmac < 5) {                 /* Not worth it for small tables */
  4344.             y = 0;
  4345.         } else {                        /* First binary search to find */
  4346.             int lo = 0;                 /* where to start */
  4347.             int hi = nmac;
  4348.             int count = 0;
  4349.             char c = 0;
  4350.             while (lo+2 < hi && ++count < 12) {
  4351.                 y = lo + ((hi - lo) / 2);
  4352.                 c = *(mactab[y].kwd);
  4353.                 if (isupper(c)) c = (char) tolower(c);
  4354.                 if (c < c1) {
  4355.                     lo = y;
  4356.                 } else {
  4357.                     hi = y;
  4358.                 }
  4359.             }
  4360.             y = (c < c1) ? lo+1 : lo;
  4361.         }
  4362.         /* Now search linearly from starting location */
  4363.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4364.             c2 = *(mactab[y].kwd);
  4365.             if (isupper(c2)) c2 = (char) tolower(c2);
  4366.             if (c1 > c2)
  4367.               continue;
  4368.             if (c1 < c2)
  4369.               break;
  4370.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4371.               break;
  4372.         }
  4373.         if (y == MAC_MAX) {             /* Macro table is full. */
  4374.             debug(F101,"addmac table overflow","",y);
  4375.             printf("?Macro table overflow\n");
  4376.             return(-1);
  4377.         }
  4378.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4379.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4380.                 mactab[i].kwd = mactab[i-1].kwd;
  4381.                 mactab[i].mval = mactab[i-1].mval;
  4382.                 mactab[i].flgs = mactab[i-1].flgs;
  4383.             }
  4384.         }
  4385.         mtchanged++;
  4386.         p = malloc(namlen + 1);         /* Allocate space for name */
  4387.         if (!p) {
  4388.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4389.             return(-1);
  4390.         }
  4391.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4392.         mactab[y].kwd = p;              /* Add pointer to table */
  4393.     }
  4394.     if (deflen > 0) {                   /* If we have a definition */
  4395.         p = malloc(deflen + 1);         /* Get space */
  4396.         if (p == NULL) {
  4397.             printf("?Space exhausted - \"%s\"\n", nam);
  4398.             if (mactab[y].kwd) {
  4399.                 free(mactab[y].kwd);
  4400.                 mactab[y].kwd = NULL;
  4401.             }
  4402.             return(-1);
  4403.         } else {
  4404.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4405.         }
  4406.     } else {                            /* definition is empty */
  4407.         p = NULL;
  4408.     }
  4409.     mactab[y].mval = p;                 /* Macro points to definition */
  4410.     mactab[y].flgs = 0;                 /* No flags */
  4411.     if (!replacing)                     /* If new macro */
  4412.       nmac++;                           /* count it */
  4413.     if (tra_asg) traceval(nam,p);
  4414.     return(y);
  4415. }
  4416.  
  4417. int
  4418. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4419.     int i;
  4420.     extern int tra_asg;
  4421.     if (x < 0) return(x);
  4422.     if (tra_asg)
  4423.       traceval(mactab[x].kwd,NULL);
  4424.  
  4425.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4426.         free(mactab[x].kwd);
  4427.         mactab[x].kwd = NULL;
  4428.     }
  4429.     if (mactab[x].mval) {               /* and for the definition */
  4430.         free(mactab[x].mval);
  4431.         mactab[x].mval = NULL;
  4432.     }
  4433.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4434.         mactab[i].kwd = mactab[i+1].kwd;
  4435.         mactab[i].mval = mactab[i+1].mval;
  4436.         mactab[i].flgs = mactab[i+1].flgs;
  4437.     }
  4438.     nmac--;                             /* One less macro */
  4439.  
  4440.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4441.     mactab[nmac].mval = NULL;
  4442.     mactab[nmac].flgs = 0;
  4443.     mtchanged++;
  4444.     return(0);
  4445. }
  4446.  
  4447. int
  4448. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4449.     int x, z;
  4450.     char *p, c;
  4451.     extern int tra_asg;
  4452.  
  4453.     if (!nam) return(0);                /* Watch out for null pointer */
  4454.     debug(F110,"delmac nam",nam,0);
  4455. #ifdef IKSD
  4456.     if ( inserver &&
  4457. #ifdef IKSDCONF
  4458.         iksdcf
  4459. #else /* IKSDCONF */
  4460.         1
  4461. #endif /* IKSDCONF */
  4462.         ) {
  4463.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4464.             !ckstrcmp("on_logout",nam,-1,0))
  4465.           return(-1);
  4466.     }
  4467. #endif /* IKSD */
  4468.  
  4469.     if (*nam == CMDQ) nam++;
  4470.     if (*nam == '%') {                  /* If it's a variable name */
  4471.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4472.         p = (char *)0;                  /* Initialize value pointer */
  4473.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4474.             p = toparg[c - '0'];
  4475.             if (p) if (p != g_var[c]) {
  4476.                 free(p);
  4477.                 toparg[c - '0'] = NULL;
  4478.             }
  4479.             p = g_var[c];
  4480.             g_var[c] = NULL;            /* Zero the table entry */
  4481.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4482.             p = m_xarg[maclvl][c - '0'];
  4483.             if (p) if (p != g_var[c]) {
  4484.                 free(p);
  4485.                 m_xarg[maclvl][c - '0'] = NULL;
  4486.             }
  4487.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4488.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4489.         } else {                        /* It's a global variable */
  4490.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4491.             p = g_var[c];               /* Get pointer from global-var table */
  4492.             g_var[c] = NULL;            /* Zero the table entry */
  4493.         }
  4494.         if (p) {
  4495.             debug(F010,"delmac def",p,0);
  4496.             free(p);                    /* Free the storage */
  4497.             p = NULL;
  4498.         } else debug(F110,"delmac def","(null pointer)",0);
  4499.         if (tra_asg) traceval(nam,NULL);
  4500.         return(0);
  4501.     }
  4502.     if (*nam == '&') {                  /* An array reference? */
  4503.         char **q;
  4504.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4505.           return(-1);                   /* return -1. */
  4506.         x -= ARRAYBASE;                 /* Convert name to number. */
  4507.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4508.           return(-2);                   /* return -2. */
  4509.         if (z > a_dim[x])               /* If subscript out of range, */
  4510.           return(-3);                   /* return -3. */
  4511.         if (q[z]) {                     /* If there is an old value, */
  4512.             debug(F010,"delmac def",q[z],0);
  4513.             if (x != 0)                 /* Macro arg vector is just a copy */
  4514.               free(q[z]);               /* Others are real so free them */
  4515.             q[z] = NULL;
  4516.             if (x == 0) {               /* Arg vector array */
  4517.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4518.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4519.                         makestr(&(toparg[z]),NULL);
  4520.                     } else {
  4521.                         makestr(&(m_arg[maclvl][z]),NULL);
  4522.                     }
  4523.                 }
  4524.             }
  4525.             if (tra_asg) traceval(nam,NULL);
  4526.         } else debug(F010,"delmac def","(null pointer)",0);
  4527.     }
  4528.  
  4529.    /* Not a variable or an array, so it must be a macro. */
  4530.  
  4531.     z = isaa(nam);
  4532.     debug(F111,"delmac isaa",nam,z);
  4533.     debug(F111,"delmac exact",nam,exact);
  4534.     x = z ? mxxlook(mactab,nam,nmac) :
  4535.       exact ? mxlook(mactab,nam,nmac) :
  4536.         mlook(mactab,nam,nmac);
  4537.     if (x < 0) {
  4538.         debug(F111,"delmac mlook",nam,x);
  4539.         return(x);
  4540.     }
  4541.     return(xdelmac(x));
  4542. }
  4543.  
  4544. VOID
  4545. initmac() {                             /* Init macro & variable tables */
  4546.     int i, j, x;
  4547.  
  4548.     nmac = 0;                           /* No macros */
  4549.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4550.         mactab[i].kwd = NULL;
  4551.         mactab[i].mval = NULL;
  4552.         mactab[i].flgs = 0;
  4553.     }
  4554.     mtchanged++;
  4555.     x = (MAXARGLIST + 1) * sizeof(char **);
  4556.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4557.         m_xarg[i] = (char **) malloc(x);
  4558.         mrval[i] = NULL;                /* Macro return value */
  4559.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4560.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4561.             if (j < 10)                 /* For the \%0..\%9 variables */
  4562.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4563.             if (m_xarg[i])              /* For \&_[] - all args. */
  4564.               m_xarg[i][j] = NULL;
  4565.         }
  4566.     }
  4567.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4568.         g_var[i] = NULL;
  4569.     }
  4570.     /* And the table of arrays */
  4571.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4572.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4573.         a_dim[i] = 0;                   /* and a dimension of zero */
  4574.         a_link[i] = -1;
  4575.         for (j = 0; j < CMDSTKL; j++) {
  4576.             aa_ptr[j][i] = (char **) NULL;
  4577.             aa_dim[j][i] = 0;
  4578.         }
  4579.     }
  4580. }
  4581.  
  4582. int
  4583. popclvl() {                             /* Pop command level, return cmdlvl */
  4584.     extern int tra_cmd;
  4585.     struct localvar * v;
  4586.     int i, topcmd;
  4587.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4588.     if (cmdlvl > 0) {
  4589.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4590.             while (v) {                 /* Yes */
  4591.                 if (v->lv_value)        /* Copy old ones back */
  4592.                   addmac(v->lv_name,v->lv_value);
  4593.                 else
  4594.                   delmac(v->lv_name,1);
  4595.                 v = v->lv_next;
  4596.             }
  4597.             freelocal(cmdlvl);          /* Free local storage */
  4598.         }
  4599.         /* Automatic arrays do not use the localhead list */
  4600.  
  4601.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4602.             if (aa_ptr[cmdlvl][i]) {    /* Does this one exist? */
  4603.                 dclarray((char)(i+ARRAYBASE),-1); /* Destroy global one */
  4604.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4605.                 a_dim[i] = aa_dim[cmdlvl][i];
  4606.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4607.                 aa_dim[cmdlvl][i] = 0;
  4608.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4609.                 dclarray((char)(i+ARRAYBASE),-1); /* (see pusharray()) */
  4610.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4611.                 aa_dim[cmdlvl][i] = 0;
  4612.             }
  4613.  
  4614.             /* Otherwise do nothing - it is a local array that was declared */
  4615.             /* at a level above this one so leave it alone. */
  4616.         }
  4617.     }
  4618.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4619.         cmdlvl = 0;                     /* just make sure all the */
  4620.         tlevel = -1;                    /* stack pointers are set right */
  4621.         maclvl = -1;                    /* and return */
  4622.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4623.         debug(F101,"popclvl tlevel","",tlevel);
  4624.         if (tlevel > -1) {              /* Yes, */
  4625.             fclose(tfile[tlevel]);      /* close it */
  4626.  
  4627.             if (tra_cmd)
  4628.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4629.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4630.             if (tfnam[tlevel]) {        /* free storage for name */
  4631.                 free(tfnam[tlevel]);
  4632.                 tfnam[tlevel] = NULL;
  4633.             }
  4634.             tlevel--;                   /* and pop take level */
  4635.             cmdlvl--;                   /* and command level */
  4636.             quiet = xquiet[cmdlvl];
  4637.             vareval = xvarev[cmdlvl];
  4638.         } else
  4639.           tlevel = -1;
  4640.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4641.         topcmd = lastcmd[maclvl];
  4642.         debug(F101,"popclvl maclvl","",maclvl);
  4643.         if (maclvl > -1) {              /* Yes, */
  4644. #ifdef COMMENT
  4645.             int i;
  4646.             char **q;
  4647. #endif /* COMMENT */
  4648.             macp[maclvl] = "";          /* set macro pointer to null string */
  4649.             *cmdbuf = '\0';             /* clear the command buffer */
  4650.  
  4651.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4652.                 (m_arg[maclvl-1][0]) &&
  4653.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4654.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4655.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4656.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4657.                 mrval[maclvl+1]) {
  4658.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4659.             }
  4660.             if (maclvl+1 < MACLEVEL) {
  4661.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4662.                     free(mrval[maclvl+1]);
  4663.                     mrval[maclvl+1] = NULL;
  4664.                 }
  4665.             }
  4666.             if (tra_cmd)
  4667.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4668.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4669.  
  4670.             maclvl--;                   /* Pop macro level */
  4671.             cmdlvl--;                   /* and command level */
  4672.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4673.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4674.  
  4675.             quiet = xquiet[cmdlvl];
  4676.         vareval = xvarev[cmdlvl];
  4677.             if (maclvl > -1) {
  4678.                 a_ptr[0] = m_xarg[maclvl];
  4679.                 a_dim[0] = n_xarg[maclvl] - 1;
  4680.         debug(F111,"a_dim[0]","B",a_dim[0]);
  4681.             } else {
  4682.                 a_ptr[0] = topxarg;
  4683.                 a_dim[0] = topargc - 1;
  4684.         debug(F111,"a_dim[0]","C",a_dim[0]);
  4685.             }
  4686.         } else {
  4687.             maclvl = -1;
  4688.         }
  4689. #ifndef NOSEXP
  4690.         debug(F101,"popclvl topcmd","",topcmd);
  4691.         if (topcmd == XXSEXP) {
  4692.             extern char * sexpval;
  4693.             makestr(&(mrval[maclvl+1]),sexpval);
  4694.         }
  4695. #endif /* NOSEXP */
  4696.     } else {
  4697.         cmdlvl--;
  4698.     }
  4699.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4700.     if (prstring[cmdlvl]) {
  4701.         cmsetp(prstring[cmdlvl]);
  4702.         makestr(&(prstring[cmdlvl]),NULL);
  4703.     }
  4704. #ifndef MAC
  4705.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4706.         setint();
  4707.         concb((char)escape);            /* Go into cbreak mode */
  4708.     }
  4709. #endif /* MAC */
  4710.     xcmdsrc = cmdstk[cmdlvl].src;
  4711.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4712.     debug(F101,"popclvl tlevel","",tlevel);
  4713.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4714. }
  4715. #else /* No script programming language */
  4716. int popclvl() {                         /* Just close current take file. */
  4717.     if (tlevel > -1) {                  /* if any... */
  4718.         if (tfnam[tlevel]) {
  4719.             free(tfnam[tlevel]);
  4720.             tfnam[tlevel] = NULL;
  4721.         }
  4722.         fclose(tfile[tlevel--]);
  4723.     }
  4724.     if (tlevel == -1) {                 /* And if back at top level */
  4725.         setint();
  4726.         concb((char)escape);            /* and go back into cbreak mode. */
  4727.     }
  4728.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4729.     return(tlevel + 1);
  4730. }
  4731. #endif /* NOSPL */
  4732.  
  4733.  
  4734. #ifndef NOSPL
  4735. static int
  4736. iseom(m) char * m; {                    /* Test if at end of macro def */
  4737.     if (!m)
  4738.       m = "";
  4739.     debug(F111,"iseom",m,maclvl);
  4740.     while (*m) {
  4741.         /* Anything but Space and Comma means more macro is left */
  4742.         if ((*m > SP) && (*m != ',')) {
  4743.             debug(F111,"iseom return",m,0);
  4744.             return(0);
  4745.         }
  4746.         m++;
  4747.     }
  4748.     debug(F111,"iseom return",m,1);
  4749.     return(1);                          /* Nothing left */
  4750. }
  4751. #endif /* NOSPL */
  4752.  
  4753. /* Pop all command levels that can be popped */
  4754.  
  4755. int
  4756. prepop() {
  4757.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4758.         while (
  4759. #ifndef NOSPL
  4760.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4761. #endif /* NOSPL */
  4762.             (tlevel > -1) &&
  4763.             feof(tfile[tlevel]))        /* And at end of file... */
  4764. #ifndef NOSPL
  4765.                /* Or command source is macro... */
  4766.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4767.                 (maclvl > -1) &&
  4768.                 iseom(macp[maclvl])))  /* and at end of macro, then... */
  4769. #endif /* NOSPL */
  4770.         {
  4771.               popclvl();                /* pop command level. */
  4772.         }
  4773.     }
  4774.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4775. }
  4776.  
  4777. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4778.  
  4779. int
  4780. dostop() {
  4781.     extern int cmddep;
  4782.     while (popclvl()) ;         /* Pop all macros & take files */
  4783. #ifndef NOSPL
  4784.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4785.       while (cmpop() > -1) ;
  4786. #endif /* NOSPL */
  4787.     cmini(ckxech);              /* Clear the command buffer. */
  4788.     return(0);
  4789. }
  4790.  
  4791. /* Close the given log */
  4792.  
  4793. int
  4794. doclslog(x) int x; {
  4795.     int y;
  4796.     switch (x) {
  4797. #ifdef DEBUG
  4798.       case LOGD:
  4799.         if (deblog <= 0) {
  4800.             printf("?Debugging log wasn't open\n");
  4801.             return(0);
  4802.         }
  4803.         debug(F100,"Debug Log Closed","",0L);
  4804.         *debfil = '\0';
  4805.         deblog = 0;
  4806.         return(zclose(ZDFILE));
  4807. #endif /* DEBUG */
  4808.  
  4809. #ifndef NOXFER
  4810.       case LOGP:
  4811.         if (pktlog <= 0) {
  4812.             printf("?Packet log wasn't open\n");
  4813.             return(0);
  4814.         }
  4815.         *pktfil = '\0';
  4816.         pktlog = 0;
  4817.         return(zclose(ZPFILE));
  4818. #endif /* NOXFER */
  4819.  
  4820. #ifndef NOLOCAL
  4821.       case LOGS:
  4822.         if (seslog <= 0) {
  4823.             printf("?Session log wasn't open\n");
  4824.             return(0);
  4825.         }
  4826.         *sesfil = '\0';
  4827.         setseslog(0);
  4828.         return(zclose(ZSFILE));
  4829. #endif /* NOLOCAL */
  4830.  
  4831. #ifdef TLOG
  4832.       case LOGT: {
  4833. #ifdef IKSD
  4834.           extern int iklogopen, xferlog;
  4835. #endif /* IKSD */
  4836.           if (tralog <= 0
  4837. #ifdef IKSD
  4838.               && !iklogopen
  4839. #endif /* IKSD */
  4840.               ) {
  4841.               if (msgflg)
  4842.                 printf("?Transaction log wasn't open\n");
  4843.               return(0);
  4844.           }
  4845. #ifdef IKSD
  4846.           if (iklogopen && !inserver) {
  4847.               close(xferlog);
  4848.               iklogopen = 0;
  4849.           }
  4850. #endif /* IKSD */
  4851.           if (tralog) {
  4852.               tlog(F100,"Transaction Log Closed","",0L);
  4853.               zclose(ZTFILE);
  4854.           }
  4855.           *trafil = '\0';
  4856.           tralog = 0;
  4857.           return(1);
  4858.       }
  4859. #endif /* TLOG */
  4860.  
  4861. #ifdef CKLOGDIAL
  4862.       case LOGM:
  4863.         if (dialog <= 0) {
  4864.             if (msgflg) printf("?Connection log wasn't open\n");
  4865.             return(0);
  4866.         }
  4867.         *diafil = '\0';
  4868.         dialog = 0;
  4869.         return(zclose(ZDIFIL));
  4870. #endif /* CKLOGDIAL */
  4871.  
  4872. #ifndef NOSPL
  4873.       case LOGW:                        /* WRITE file */
  4874.       case LOGR:                        /* READ file */
  4875.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4876.         if (chkfn(y) < 1)               /* If no file to close */
  4877.           return(1);                    /* succeed silently. */
  4878.         return(zclose(y));              /* Otherwise, close the file. */
  4879. #endif /* NOSPL */
  4880.  
  4881.       default:
  4882.         printf("\n?Unexpected log designator - %d\n", x);
  4883.         return(0);
  4884.     }
  4885. }
  4886.  
  4887. static int slc = 0;                     /* Screen line count */
  4888.  
  4889. char *
  4890. showstring(s) char * s; {
  4891.     return(s ? s : "(null)");
  4892. }
  4893.  
  4894. char *
  4895. showoff(x) int x; {
  4896.     return(x ? "on" : "off");
  4897. }
  4898.  
  4899. char *
  4900. showooa(x) int x; {
  4901.     switch (x) {
  4902.       case SET_OFF:  return("off");
  4903.       case SET_ON:   return("on");
  4904.       case SET_AUTO: return("automatic");
  4905.       default:       return("(unknown)");
  4906.     }
  4907. }
  4908.  
  4909. #ifdef GEMDOS
  4910. isxdigit(c) int c; {
  4911.     return(isdigit(c) ||
  4912.            (c >= 'a' && c <= 'f') ||
  4913.            (c >= 'A' && c <= 'F'));
  4914. }
  4915. #endif /* GEMDOS */
  4916.  
  4917. #ifndef NOSETKEY
  4918. #ifdef OS2
  4919. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4920.     "all",    1, 0,
  4921.     "one",    0, 0
  4922. };
  4923. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4924.  
  4925. #define SHKEYDEF TT_MAX+5
  4926. struct keytab shokeymtab[] = {
  4927.     "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
  4928.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4929.     "adm5",      TT_ADM5,    0,         /* LSI ADM-5 */
  4930.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4931.     "annarbor",  TT_AAA,     0,         /* AnnArbor */
  4932.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4933.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4934.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4935.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4936.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4937.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4938.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4939.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4940.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4941.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4942.     "default",   SHKEYDEF,   0,
  4943.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4944.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4945.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4946.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4947.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4948.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4949.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4950.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4951.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4952.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4953.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4954.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4955.     "linux",     TT_LINUX,   0,         /* Linux */
  4956.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4957.     "qnx",       TT_QNX,     0,         /* QNX */
  4958.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4959.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4960.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4961.     "sun",       TT_SUN,     0,         /* Sun Console */
  4962. #ifdef OS2PM
  4963. #ifdef COMMENT
  4964.     "tek4014", TT_TEK40, 0,
  4965. #endif /* COMMENT */
  4966. #endif /* OS2PM */
  4967.     "tty",     TT_NONE,  0,
  4968.     "tvi910+", TT_TVI910, 0,
  4969.     "tvi925",  TT_TVI925, 0,
  4970.     "tvi950",  TT_TVI950, 0,
  4971.     "vc404",   TT_VC4404, 0,
  4972.     "vc4404",  TT_VC4404, CM_INV,
  4973.     "vip7809", TT_VIP7809, 0,
  4974.     "vt100",   TT_VT100, 0,
  4975.     "vt102",   TT_VT102, 0,
  4976.     "vt220",   TT_VT220, 0,
  4977.     "vt220pc", TT_VT220PC, 0,
  4978.     "vt320",   TT_VT320, 0,
  4979.     "vt320pc", TT_VT320PC, 0,
  4980.     "vt52",    TT_VT52,  0,
  4981.     "wp",      TT_KBM_WP, 0,
  4982.     "wy160",   TT_WY160,  0,
  4983.     "wy30",    TT_WY30,  0,
  4984.     "wy370",   TT_WY370, 0,
  4985.     "wy50",    TT_WY50,  0,
  4986.     "wy60",    TT_WY60,  0,
  4987.     "wyse30",  TT_WY30,  CM_INV,
  4988.     "wyse370", TT_WY370, CM_INV,
  4989.     "wyse50",  TT_WY50,  CM_INV,
  4990.     "wyse60",  TT_WY60,  CM_INV
  4991. };
  4992. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4993. #endif /* OS2 */
  4994.  
  4995. VOID
  4996. #ifdef OS2
  4997. shokeycode(c,m) int c, m;
  4998. #else
  4999. shokeycode(c) int c;
  5000. #endif
  5001. /* shokeycode */ {
  5002.     KEY ch;
  5003.     CHAR *s;
  5004. #ifdef OS2
  5005.     int i;
  5006.     con_event km;
  5007. #else /* OS2 */
  5008.     int km;
  5009. #endif /* OS2 */
  5010.  
  5011. #ifdef OS2
  5012.     extern int mskkeys;
  5013.     char * mstr = "";
  5014.  
  5015.     if (c >= KMSIZE) {
  5016.         bleep(BP_FAIL);
  5017.         return;
  5018.     }
  5019. #else /* OS2 */
  5020.     printf(" Key code \\%d => ", c);
  5021. #endif /* OS2 */
  5022.  
  5023. #ifndef OS2
  5024.     km = mapkey(c);
  5025.  
  5026. #ifndef NOKVERBS
  5027.     if (IS_KVERB(km)) {                 /* \Kverb? */
  5028.         int i, kv;
  5029.         kv = km & ~(F_KVERB);
  5030.         printf("Verb: ");
  5031.         for (i = 0; i < nkverbs; i++)
  5032.           if (kverbs[i].kwval == kv) {
  5033.               printf("\\K%s",kverbs[i].kwd);
  5034.               break;
  5035.           }
  5036.         printf("\n");
  5037.     } else
  5038. #endif /* NOKVERBS */
  5039.       if (IS_CSI(km)) {
  5040.           int xkm = km & 0xFF;
  5041.           if (xkm <= 32 || xkm >= 127)
  5042.             printf("String: \\{27}[\\{%d}\n",xkm);
  5043.           else
  5044.             printf("String: \\{27}[%c\n",xkm);
  5045.       } else if (IS_ESC(km)) {
  5046.           int xkm = km & 0xFF;
  5047.           if (xkm <= 32 || xkm >= 127)
  5048.             printf("String: \\{27}\\{%d}\n",xkm);
  5049.           else
  5050.             printf("String: \\{27}%c\n",xkm);
  5051.       } else if (macrotab[c]) {         /* See if there's a macro */
  5052.           printf("String: ");           /* If so, display its definition */
  5053.           s = macrotab[c];
  5054.           shostrdef(s);
  5055.           printf("\n");
  5056. #ifndef NOKVERBS
  5057.     } else if (km >= 0x100) {           /* This means "undefined" */
  5058.         printf("Undefined\n");
  5059. #endif /* NOKVERBS */
  5060.     } else {                            /* No macro, show single character */
  5061.         printf("Character: ");
  5062.         ch = km;
  5063.         if (ch < 32 || ch == 127
  5064. #ifdef OS2
  5065.             || ch > 255
  5066. #endif /* OS2 */
  5067. #ifndef NEXT
  5068. #ifndef AUX
  5069. #ifndef XENIX
  5070. #ifndef OS2
  5071.             || (ch > 127 && ch < 160)
  5072. #endif /* OS2 */
  5073. #endif /* XENIX */
  5074. #endif /* AUX */
  5075. #endif /* NEXT */
  5076.             )
  5077. /*
  5078.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5079.   %u is supposed to be totally portable.
  5080. */
  5081.           printf("\\%u",(unsigned int) ch);
  5082.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5083.         if (ch == (KEY) c)
  5084.           printf(" (self, no translation)\n");
  5085.         else
  5086.           printf("\n");
  5087.     }
  5088. #else /* OS2 */
  5089.     if (m < 0) {
  5090.         km = mapkey(c);
  5091.         mstr = "default";
  5092.     } else {
  5093.         km = maptermkey(c,m);
  5094.         for (i = 0; i < nshokeym; i++) {
  5095.             if (m == shokeymtab[i].kwval) {
  5096.                 mstr = shokeymtab[i].kwd;
  5097.                 break;
  5098.             }
  5099.         }
  5100.     }
  5101.     s = keyname(c);
  5102.     debug(F111,"shokeycode mstr",mstr,m);
  5103.     debug(F111,"shokeycode keyname",s,c);
  5104.     printf(" %sKey code \\%d %s (%s) => ",
  5105.             mskkeys ? "mskermit " : "",
  5106.             mskkeys ? cktomsk(c) : c,
  5107.             s == NULL ? "" : s, mstr);
  5108.  
  5109.     switch (km.type) {
  5110. #ifndef NOKVERBS
  5111.       case kverb: {
  5112.           int i, kv;
  5113.           kv = km.kverb.id & ~(F_KVERB);
  5114.           printf("Verb: ");
  5115.           for (i = 0; i < nkverbs; i++) {
  5116.               if (kverbs[i].kwval == kv) {
  5117.                   printf("\\K%s",kverbs[i].kwd);
  5118.                   break;
  5119.               }
  5120.           }
  5121.           printf("\n");
  5122.           break;
  5123.       }
  5124. #endif /* NOKVERBS */
  5125.       case csi: {
  5126.           int xkm = km.csi.key & 0xFF;
  5127.           if (xkm <= 32 || xkm >= 127)
  5128.             printf("String: \\{27}[\\{%d}\n",xkm);
  5129.           else
  5130.             printf("String: \\{27}[%c\n",xkm);
  5131.           break;
  5132.       }
  5133.       case esc: {
  5134.           int xkm = km.esc.key & 0xFF;
  5135.           if (xkm <= 32 || xkm >= 127)
  5136.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  5137.           else
  5138.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  5139.           break;
  5140.       }
  5141.       case macro: {
  5142.           printf("String: ");           /* Macro, display its definition */
  5143.           shostrdef(km.macro.string);
  5144.           printf("\n");
  5145.           break;
  5146.       }
  5147.       case literal: {
  5148.           printf("Literal string: ");   /* Literal, display its definition */
  5149.           shostrdef(km.literal.string);
  5150.           printf("\n");
  5151.           break;
  5152.       }
  5153.       case error: {
  5154.           if (c >= 0x100) {
  5155.               printf("Undefined\n");
  5156.           } else {
  5157.               printf("Character: ");
  5158.               ch = c;
  5159.               if (ch < 32 || ch == 127 || ch > 255
  5160. #ifndef NEXT
  5161. #ifndef AUX
  5162. #ifndef XENIX
  5163. #ifndef OS2
  5164.                    || (ch > 127 && ch < 160)
  5165. #endif /* OS2 */
  5166. #endif /* XENIX */
  5167. #endif /* AUX */
  5168. #endif /* NEXT */
  5169.                    )
  5170. /*
  5171.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5172.   %u is supposed to be totally portable.
  5173. */
  5174.                   printf("\\%u",(unsigned int) ch);
  5175.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5176.               printf(" (self, no translation)\n");
  5177.           }
  5178.           break;
  5179.       }
  5180.       case key: {
  5181.           printf("Character: ");
  5182.           ch = km.key.scancode;
  5183.           if (ch < 32 || ch == 127 || ch > 255
  5184. #ifndef NEXT
  5185. #ifndef AUX
  5186. #ifndef XENIX
  5187. #ifndef OS2
  5188.               || (ch > 127 && ch < 160)
  5189. #else
  5190.                || (ch > 127)
  5191. #endif /* OS2 */
  5192. #endif /* XENIX */
  5193. #endif /* AUX */
  5194. #endif /* NEXT */
  5195.               )
  5196. /*
  5197.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5198.   %u is supposed to be totally portable.
  5199. */
  5200.             printf("\\%u",(unsigned int) ch);
  5201.           else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5202.           if (ch == (KEY) c)
  5203.             printf(" (self, no translation)\n");
  5204.           else
  5205.             printf("\n");
  5206.           break;
  5207.       }
  5208.     }
  5209. #endif /* OS2 */
  5210. }
  5211. #endif /* NOSETKEY */
  5212.  
  5213. VOID
  5214. shostrdef(s) CHAR * s; {
  5215.     CHAR ch;
  5216.     if (!s) s = (CHAR *)"";
  5217.     while ((ch = *s++)) {
  5218.         if (ch < 32 || ch == 127 || ch == 255
  5219. /*
  5220.   Systems whose native character sets have graphic characters in C1...
  5221. */
  5222. #ifndef NEXT                            /* NeXT */
  5223. #ifndef AUX                             /* Macintosh */
  5224. #ifndef XENIX                           /* IBM PC */
  5225. #ifdef OS2
  5226. /*
  5227.   It doesn't matter whether the local host can display 8-bit characters;
  5228.   they are not portable among character-sets and fonts.  Who knows what
  5229.   would be displayed...
  5230. */
  5231.             || (ch > 127)
  5232. #else /* OS2 */
  5233.             || (ch > 127 && ch < 160)
  5234. #endif /* OS2 */
  5235. #endif /* XENIX */
  5236. #endif /* AUX */
  5237. #endif /* NEXT */
  5238.             )
  5239.           printf("\\{%d}",ch);          /* Display control characters */
  5240.         else putchar((char) ch);        /* in backslash notation */
  5241.     }
  5242. }
  5243.  
  5244. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5245.  
  5246. #ifndef NOSHOW
  5247. VOID
  5248. shover() {
  5249. #ifdef OS2
  5250.     extern char ckxsystem[];
  5251. #endif /* OS2 */
  5252.     extern char *ck_patch, * cklibv;
  5253.     printf("\nVersions:\n %s\n",versio);
  5254.     printf(" Numeric: %ld\n",vernum);
  5255. #ifdef OS2
  5256.     printf(" Operating System: %s\n", ckxsystem);
  5257. #else /* OS2 */
  5258.     printf(" Built for: %s\n", ckxsys);
  5259. #ifdef CK_UTSNAME
  5260.     if (unm_nam[0])
  5261.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5262. #endif /* CK_UTSNAME */
  5263.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5264. #endif /* OS2 */
  5265.     if (xxdiff(ckxv,ckxsys))
  5266.       printf(" %s for%s\n",ckxv,ckxsys);
  5267.     else
  5268.       printf(" %s\n",ckxv);
  5269.     if (xxdiff(ckzv,ckzsys))
  5270.       printf(" %s for%s\n",ckzv,ckzsys);
  5271.     else
  5272.       printf(" %s\n",ckzv);
  5273.     printf(" %s\n",cklibv);
  5274.     printf(" %s\n",protv);
  5275.     printf(" %s\n",fnsv);
  5276.     printf(" %s\n %s\n",cmdv,userv);
  5277. #ifndef NOCSETS
  5278.     printf(" %s\n",xlav);
  5279. #endif /* NOCSETS */
  5280. #ifndef MAC
  5281. #ifndef NOLOCAL
  5282.     printf(" %s\n",connv);
  5283. #ifdef OS2
  5284.     printf(" %s\n",ckyv);
  5285. #endif /* OS2 */
  5286. #endif /* NOLOCAL */
  5287. #endif /* MAC */
  5288. #ifndef NODIAL
  5289.     printf(" %s\n",dialv);
  5290. #endif /* NODIAL */
  5291. #ifndef NOSCRIPT
  5292.     printf(" %s\n",loginv);
  5293. #endif /* NOSCRIPT */
  5294. #ifdef NETCONN
  5295.     printf(" %s\n",cknetv);
  5296. #ifdef OS2
  5297.     printf(" %s\n",ckonetv);
  5298. #ifdef CK_NETBIOS
  5299.     printf(" %s\n",ckonbiv);
  5300. #endif /* CK_NETBIOS */
  5301. #endif /* OS2 */
  5302. #endif /* NETCONN */
  5303. #ifdef TNCODE
  5304.     printf(" %s\n",cktelv);
  5305. #endif /* TNCODE */
  5306. #ifdef SSHBUILTIN
  5307.     printf(" %s\n",cksshv);
  5308. #ifdef SFTP_BUILTIN
  5309.     printf(" %s\n",cksftpv);
  5310. #endif /* SFTP_BUILTIN */
  5311. #endif /* SSHBUILTIN */
  5312. #ifdef OS2
  5313. #ifdef OS2MOUSE
  5314.     printf(" %s\n",ckomouv);
  5315. #endif /* OS2MOUSE */
  5316. #endif /* OS2 */
  5317. #ifdef NEWFTP
  5318.     printf(" %s\n",ckftpv);
  5319. #endif /* NEWFTP */
  5320. #ifdef CK_AUTHENTICATION
  5321.     printf(" %s\n",ckathv);
  5322. #endif /* CK_AUTHENTICATION */
  5323. #ifdef CK_ENCRYPTION
  5324. #ifdef CRYPT_DLL
  5325.     printf(" %s\n",ck_crypt_dll_version());
  5326. #else /* CRYPT_DLL */
  5327.     printf(" %s\n",ckcrpv);
  5328. #endif /* CRYPT_DLL */
  5329. #endif /* CK_ENCRYPTION */
  5330. #ifdef CK_SSL
  5331.     printf(" %s\n",cksslv);
  5332. #endif /* CK_SSL */
  5333.     printf("\n");
  5334. }
  5335.  
  5336. #ifdef CK_LABELED
  5337. VOID
  5338. sholbl() {
  5339. #ifdef VMS
  5340.     printf("VMS Labeled File Features:\n");
  5341.     printf(" acl %s (ACL info %s)\n",
  5342.            showoff(lf_opts & LBL_ACL),
  5343.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5344.     printf(" backup-date %s (backup date/time %s)\n",
  5345.            showoff(lf_opts & LBL_BCK),
  5346.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5347.     printf(" name %s (original filename %s)\n",
  5348.            showoff(lf_opts & LBL_NAM),
  5349.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5350.     printf(" owner %s (original file owner id %s)\n",
  5351.            showoff(lf_opts & LBL_OWN),
  5352.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5353.     printf(" path %s (original file's disk:[directory] %s)\n",
  5354.            showoff(lf_opts & LBL_PTH),
  5355.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5356. #else
  5357. #ifdef OS2
  5358.     printf("OS/2 Labeled File features (attributes):\n");
  5359.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5360.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5361.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5362.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5363.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5364. #endif /* OS2 */
  5365. #endif /* VMS */
  5366. }
  5367. #endif /* CK_LABELED */
  5368.  
  5369. VOID
  5370. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5371. #ifndef NOCSETS
  5372. #ifdef OS2
  5373. #ifndef NOTERM
  5374.     extern struct _vtG G[4], *GL, *GR;
  5375.     extern int decnrcm, sni_chcode;
  5376.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5377.     extern prncs;
  5378.  
  5379.     printf(" Terminal character-sets:\n");
  5380.     if (IS97801(tt_type_mode)) {
  5381.         if (cmask == 0377)
  5382.           printf("     Mode: 8-bit Mode\n");
  5383.         else
  5384.           printf("     Mode: 7-bit Mode\n");
  5385.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5386.     } else if (ISVT100(tt_type_mode)) {
  5387.         if (decnrcm)
  5388.           printf("     Mode: 7-bit National Mode\n");
  5389.         else
  5390.           printf("     Mode: 8-bit Multinational Mode\n");
  5391.     }
  5392.     if ( isunicode() )
  5393.         printf("    Local: Unicode display / %s input\n",
  5394.                 csl == TX_TRANSP ? "transparent" :
  5395.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5396.     else
  5397.         printf("    Local: %s\n",
  5398.                 csl == TX_TRANSP ? "transparent" :
  5399.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5400.  
  5401.     if ( tt_utf8 ) {
  5402.         printf("   Remote: UTF-8\n");
  5403.     } else {
  5404.         printf("   Remote: %sG0: %s (%s)\n",
  5405.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5406.            txrinfo[G[0].designation]->keywd,
  5407.            G[0].designation == TX_TRANSP ? "" :
  5408.            G[0].size == cs94 ? "94 chars" :
  5409.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5410.         printf("           %sG1: %s (%s)\n",
  5411.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5412.            txrinfo[G[1].designation]->keywd,
  5413.            G[1].designation == TX_TRANSP ? "" :
  5414.            G[1].size == cs94 ? "94 chars" :
  5415.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5416.         printf("           %sG2: %s (%s)\n",
  5417.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5418.            txrinfo[G[2].designation]->keywd,
  5419.            G[2].designation == TX_TRANSP ? "" :
  5420.            G[2].size == cs94 ? "94 chars" :
  5421.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5422.         printf("           %sG3: %s (%s)\n",
  5423.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5424.            txrinfo[G[3].designation]->keywd,
  5425.            G[3].designation == TX_TRANSP ? "" :
  5426.            G[3].size == cs94 ? "94 chars" :
  5427.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5428.     }
  5429.     printf("\n");
  5430.     printf(" Keyboard character-sets:\n");
  5431.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5432.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5433.     printf("\n");
  5434.     printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5435. #endif /* NOTERM */
  5436. #else /* OS2 */
  5437. #ifndef MAC
  5438.     char *s;
  5439.  
  5440.     debug(F101,"TERM LOCAL CSET","",csl);
  5441.     debug(F101,"TERM REMOTE CSET","",csr);
  5442.     printf(" Terminal character-set: ");
  5443.     if (tcs_transp) {                   /* No translation */
  5444.         printf("transparent\n");
  5445.     } else {                            /* Translation */
  5446.         printf("%s (remote) %s (local)\n",
  5447.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5448.         if (csr != csl) {
  5449.             switch(gettcs(csr,csl)) {
  5450.               case TC_USASCII:  s = "ascii";        break;
  5451.               case TC_1LATIN:   s = "latin1-iso";   break;
  5452.               case TC_2LATIN:   s = "latin2-iso";   break;
  5453.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5454.               case TC_JEUC:     s = "japanese-euc"; break;
  5455.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5456.               case TC_GREEK:    s = "greek-iso";    break;
  5457.               case TC_9LATIN:   s = "latin9-iso";   break;
  5458.               default:          s = "transparent";  break;
  5459.             }
  5460.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5461.                 strcmp(s,fcsinfo[csr].keyword))
  5462.               printf("                         (via %s)\n",s);
  5463.         }
  5464.     }
  5465. #endif /* MAC */
  5466. #endif /* OS2 */
  5467. #endif /* NOCSETS */
  5468. }
  5469.  
  5470. #ifndef NOLOCAL
  5471. #ifdef OS2
  5472. extern char htab[];
  5473. VOID
  5474. shotabs() {
  5475.     int i,j,k,n;
  5476.  
  5477.     printf("Tab Stops:\n\n");
  5478.     for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5479.         do {
  5480.             printf("%c",htab[++i]=='T'?'T':'-');
  5481.         } while (i % k && i < MAXTERMCOL);
  5482.         printf("\n");
  5483.         for ( ; j <= i; j++) {
  5484.             switch ( j%10 ) {
  5485.           case 1:
  5486.                 printf("%c",j == 1 ? '1' : '.');
  5487.                 break;
  5488.           case 2:
  5489.           case 3:
  5490.           case 4:
  5491.           case 5:
  5492.           case 6:
  5493.           case 7:
  5494.                 printf("%c",'.');
  5495.                 break;
  5496.           case 8:
  5497.                 n = (j+2)/100;
  5498.                 if (n)
  5499.           printf("%d",n);
  5500.                 else 
  5501.           printf("%c",'.');
  5502.                 break;
  5503.           case 9:
  5504.                 n = (j+1)%100/10;
  5505.                 if (n)
  5506.           printf("%d",n);
  5507.                 else if (j>90)
  5508.           printf("0");
  5509.                 else 
  5510.           printf("%c",'.');
  5511.                 break;
  5512.           case 0:
  5513.                 printf("0");
  5514.                 break;
  5515.             }
  5516.         }
  5517.         printf("\n");
  5518.     }
  5519. #ifdef COMMENT
  5520.     for (i = 1; i <= 70; i++)
  5521.       printf("%c",htab[i]=='T'?'T':'-');
  5522.     printf("\n1.......10........20........30........40........50........60\
  5523. ........70\n\n");
  5524.     for (; i <= 140; i++)
  5525.       printf("%c",htab[i]=='T'?'T':'-');
  5526.     printf("\n........80........90.......100.......110.......120.......130\
  5527. .......140\n\n");
  5528.     for (; i <= 210; i++)
  5529.       printf("%c",htab[i]=='T'?'T':'-');
  5530.     printf("\n.......150.......160.......170.......180.......190.......200\
  5531. .......210\n\n");
  5532.     for (; i <= 255; i++)
  5533.       printf("%c",htab[i]=='T'?'T':'-');
  5534.     printf("\n.......220.......230.......240.......250..255\n");
  5535. #endif
  5536.  
  5537. }
  5538. #endif /* OS2 */
  5539. #endif /* NOLOCAL */
  5540.  
  5541. #ifdef OS2MOUSE
  5542. VOID
  5543. shomou() {
  5544.     int button, event, id, i;
  5545.     char * name = "";
  5546.  
  5547.     printf("Mouse settings:\n");
  5548.     printf("   Button Count:   %d\n",mousebuttoncount());
  5549.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5550.  
  5551.     for (button = 0; button < MMBUTTONMAX; button++)
  5552.       for (event = 0; event < MMEVENTSIZE; event++)
  5553.         if (mousemap[button][event].type != error)
  5554.           switch (mousemap[button][event].type) {
  5555.             case key:
  5556.               printf("   %s = Character: %c \\%d\n",
  5557.                      mousename(button,event),
  5558.                      mousemap[button][event].key.scancode,
  5559.                      mousemap[button][event].key.scancode );
  5560.               break;
  5561.             case kverb:
  5562.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5563.               if (id != K_IGNORE) {
  5564.                   for (i = 0; i< nkverbs; i++)
  5565.                     if (id == kverbs[i].kwval) {
  5566.                         name = kverbs[i].kwd;
  5567.                         break;
  5568.                     }
  5569.                   printf("   %s = Kverb: \\K%s\n",
  5570.                          mousename(button,event),
  5571.                          name
  5572.                          );
  5573.               }
  5574.               break;
  5575.             case macro:
  5576.               printf("   %s = Macro: ",
  5577.                      mousename(button,event) );
  5578.               shostrdef(mousemap[button][event].macro.string);
  5579.               printf("\n");
  5580.               break;
  5581.           }
  5582. }
  5583. #endif /* OS2MOUSE */
  5584.  
  5585. #ifndef NOLOCAL
  5586. VOID
  5587. shotrm() {
  5588.     char *s;
  5589.     extern char * getiact();
  5590.     extern int tt_print, adl_err;
  5591. #ifndef NOTRIGGER
  5592.     extern char * tt_trigger[];
  5593. #endif /* NOTRIGGER */
  5594. #ifdef CKTIDLE
  5595.     extern char * tt_idlesnd_str;
  5596.     extern int tt_idlesnd_tmo;
  5597.     extern int tt_idlelimit, tt_idleact;
  5598. #endif /* CKTIDLE */
  5599. #ifdef OS2
  5600.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5601.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5602.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5603.     int lines = 0;
  5604. #ifdef KUI
  5605.     extern CKFLOAT tt_linespacing[];
  5606.     extern tt_cursor_blink;
  5607. #endif /* KUI */
  5608. #ifdef PCFONTS
  5609.     int i;
  5610.     char *font;
  5611.  
  5612.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5613.         if (!os2LoadPCFonts()) {
  5614.             for (i = 0; i < ntermfont; i++) {
  5615.                 if (tt_font == term_font[i].kwval) {
  5616.                     font = term_font[i].kwd;
  5617.                     break;
  5618.                 }
  5619.             }
  5620.         } else {
  5621.             font = "(DLL not available)";
  5622.         }
  5623.     } else {
  5624.         font =     "(full screen only)";
  5625.     }
  5626. #endif /* PCFONTS */
  5627. #ifdef KUI
  5628.     char font[64] = "(unknown)";
  5629.     if ( ntermfont > 0 ) {
  5630.         int i;
  5631.         for (i = 0; i < ntermfont; i++) {
  5632.             if (tt_font == term_font[i].kwval) {
  5633.                 ckstrncpy(font,term_font[i].kwd,59);
  5634.                 ckstrncat(font," ",64);
  5635.                 ckstrncat(font,ckitoa(tt_font_size/2),64);
  5636.                 if ( tt_font_size % 2 )
  5637.                     ckstrncat(font,".5",64);
  5638.                 break;
  5639.             }
  5640.         }
  5641.     }
  5642. #endif /* KUI */
  5643.  
  5644.     printf("Terminal parameters:\n");
  5645.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5646.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5647.            "Bytesize: Command",
  5648.            (cmdmsk == 0377) ? 8 : 7,
  5649.            " bits","Terminal",
  5650.            (cmask == 0377) ? 8 : 7," bits");
  5651.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5652.     printf(" %19s: %-13s","Type",
  5653.            (tt_type >= 0 && tt_type <= max_tt) ?
  5654.            tt_info[tt_type].x_name :
  5655.            "unknown" );
  5656.     if (tt_type >= 0 && tt_type <= max_tt)
  5657.       if (strlen(tt_info[tt_type].x_id))
  5658.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5659.     printf("\n");
  5660.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5661.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5662.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5663.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5664.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode", showoff(tnlm),
  5665.        "Cr-display",tt_crd ? "crlf" : "normal");
  5666.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5667.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5668. #ifdef KUI
  5669.         (tt_cursor == 2) ? (tt_cursor_blink ? 
  5670.                  "full (*)" : "full (.)") :
  5671.         (tt_cursor == 1) ? (tt_cursor_blink ? 
  5672.                  "half (*)" : "half (.)") :
  5673.         (tt_cursor_blink ? "underline (*)" : "underline (.)"),
  5674. #else /* KUI */
  5675.            (tt_cursor == 2) ? "full" :
  5676.            (tt_cursor == 1) ? "half" : "underline",
  5677. #endif /* KUI */
  5678. #ifdef CK_AUTODL
  5679.            "autodownload",autodl == TAD_ON ?
  5680.            (adl_err ? "on, error stop" : "on, error continue") : 
  5681.            autodl == TAD_ASK ? 
  5682.            (adl_err ? "ask, error stop" : "ask, error continue") :
  5683.            "off"
  5684. #else /* CK_AUTODL */
  5685.            "", ""
  5686. #endif /* CK_AUTODL */
  5687.            );
  5688.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5689.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5690.            tt_arrow ? "application" : "cursor",
  5691.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5692.            );
  5693.  
  5694.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5695.  
  5696.     /* Just to make sure we are using current info */
  5697.     updanswerbk();
  5698.  
  5699.     /*
  5700.        This line doesn't end with '\n' because the answerback string
  5701.        is terminated with a newline
  5702.     */
  5703.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5704.            showoff(tt_answer),"response",answerback);
  5705.     switch (tt_bell) {
  5706.       case XYB_NONE:
  5707.         s = "none";
  5708.         break;
  5709.       case XYB_VIS:
  5710.         s= "visible";
  5711.         break;
  5712.       case XYB_AUD | XYB_BEEP:
  5713.         s="beep";
  5714.         break;
  5715.       case XYB_AUD | XYB_SYS:
  5716.         s="system sounds";
  5717.         break;
  5718.       default:
  5719.         s="(unknown)";
  5720.     }
  5721.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5722.            "Wrap",showoff(tt_wrap));
  5723.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5724.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5725.            "Autoscroll",showoff(autoscroll));
  5726.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5727.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5728.            "ESC[0m color",colorreset?"default-color":"current-color");
  5729.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5730.     printf(" %19s: %-13s  %13s: %-15s\n",
  5731.             "Erase color",user_erasemode?"default-color":"current-color",
  5732.            "Screen mode",decscnm?"reverse":"normal");
  5733.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5734.  
  5735.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5736.            "Output-pacing",tt_pacing);
  5737.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5738.  
  5739.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5740.            "Idle-action", getiact());
  5741.  
  5742.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5743.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5744.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5745.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5746. #ifndef NOTRIGGER
  5747.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5748.            tt_trigger[0],"Output pacing",tt_pacing );
  5749.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5750. #endif /* NOTRIGGER */
  5751.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5752.            showoff(marginbell),"at column", marginbellcol);
  5753.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5754.     switch (tt_modechg) {
  5755.       case TVC_DIS: s = "disabled"; break;
  5756.       case TVC_ENA: s = "enabled";  break;
  5757.       case TVC_W95: s = "win95-restricted"; break;
  5758.       default: s = "(unknown)";
  5759.     }
  5760.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5761.            showoff(dgunix),"Video change", s);
  5762.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5763.  
  5764. #ifdef CK_APC
  5765.     if (apcstatus == APC_ON) s = "on";
  5766.     else if (apcstatus == APC_OFF) s = "off";
  5767.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5768.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5769.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5770.     printf(" %19s: %-13s  %13s: %-15s\n",
  5771.            "APC", s,
  5772. #ifdef PCFONTS
  5773.            "Font (VGA)",font
  5774. #else /* PCFONTS */
  5775. #ifdef KUI
  5776.            "Font",font
  5777. #else
  5778.            "Font","(not supported)"
  5779. #endif /* KUI */
  5780. #endif /* PCFONTS */
  5781.  
  5782.            );
  5783. #endif /* CK_APC */
  5784.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5785.  
  5786. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5787.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5788.       ttgwsiz();                        /* Try to get latest size */
  5789. #endif /* CK_TTGWSIZ */
  5790.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5791.            "Width",tt_cols[VTERM]);
  5792.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5793. #ifdef KUI
  5794.     printf(" %19s: %-12f  %14s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5795.            "Display Height",VscrnGetDisplayHeight(VTERM));
  5796.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5797. #endif /* KUI */
  5798.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5799.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5800.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5801.  
  5802.     if (updmode == tt_updmode)
  5803.       if (updmode == TTU_FAST)
  5804.         s = "fast (fast)";
  5805.       else
  5806.         s = "smooth (smooth)";
  5807.     else
  5808.       if (updmode == TTU_FAST)
  5809.         s = "fast (smooth)";
  5810.       else
  5811.         s = "smooth (fast)";
  5812.  
  5813.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5814.            "interval",tt_update);
  5815.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5816.     printf(" %19s: %-13s  %13s: %-15s\n",
  5817.            "Screen-optimization",showoff(tt_diff_upd),
  5818.            "Status line",showoff(tt_status[VTERM]));
  5819.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5820.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5821.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5822.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5823.  
  5824.     /* Display colors (should become SHOW COLORS) */
  5825.     {
  5826.         USHORT row, col;
  5827.         char * colors[16] = {
  5828.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5829.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5830.         };
  5831.         printf("\n");
  5832.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5833.  
  5834.         printf(" Color:");
  5835. #ifndef ONETERMUPD
  5836.         GetCurPos(&row, &col);
  5837.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5838.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5839.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5840.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5841.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5842.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5843.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5844.         WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5845. #endif /* ONETERMUPD */
  5846.         row = VscrnGetCurPos(VCMD)->y+1;
  5847.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5848.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5849.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5850.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5851.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5852.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5853.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5854.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5855.         printf("\n");
  5856.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5857.  
  5858.         /* Foreground color names */
  5859.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5860.                 "",
  5861.                 colors[colordebug&0x0F],
  5862.                 colors[colorhelp&0x0F],
  5863.                 colors[colorreverse&0x0F],
  5864.                 colors[colorselect&0x0F],
  5865.                 colors[colorstatus&0x0F],
  5866.                 colors[colornormal&0x0F],
  5867.                 colors[colorunderline&0x0F]);
  5868.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5869.  
  5870.         /* Background color names */
  5871.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5872.                 colors[colorborder],
  5873.                 colors[colordebug>>4],
  5874.                 colors[colorhelp>>4],
  5875.                 colors[colorreverse>>4],
  5876.                 colors[colorselect>>4],
  5877.                 colors[colorstatus>>4],
  5878.                 colors[colornormal>>4],
  5879.                 colors[colorunderline>>4] );
  5880.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5881.         printf("\n");
  5882.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5883.         printf(" Color:");
  5884. #ifndef ONETERMUPD
  5885.         GetCurPos(&row, &col);
  5886.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5887.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5888.         WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
  5889. #endif /* ONETERMUPD */
  5890.         row = VscrnGetCurPos(VCMD)->y+1;
  5891.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5892.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5893.         VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
  5894.         printf("\n");
  5895.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5896.  
  5897.         /* Foreground color names */
  5898.         printf("%6s: %-8s%-8s%-8s\n","fore",
  5899.                 colors[colorgraphic&0x0F],
  5900.                 colors[colorcmd&0x0F],
  5901.                 colors[coloritalic&0x0F]);
  5902.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5903.  
  5904.         /* Background color names */
  5905.         printf("%6s: %-8s%-8s%-8s\n","back",
  5906.                 colors[colorgraphic>>4],
  5907.                 colors[colorcmd>>4],
  5908.                 colors[coloritalic>>4]);
  5909.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5910.     }
  5911.     printf("\n");
  5912.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5913.     {
  5914.         extern int trueblink, truedim, truereverse, trueunderline, trueitalic;
  5915.         printf(
  5916.         " Attribute:  \
  5917. blink: %-3s  dim: %-3s  italic: %-3s  reverse: %-3s  underline: %-3s\n",
  5918.         trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", 
  5919.         truereverse?"on":"off", trueunderline?"on":"off");
  5920.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5921.     }
  5922.     {
  5923.         extern vtattrib WPattrib;
  5924.         printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5925.                 WPattrib.blinking?"blink ":"",
  5926.                 WPattrib.italic?"italic ":"",
  5927.                 WPattrib.reversed?"reverse ":"",
  5928.                 WPattrib.underlined?"underline ":"",
  5929.                 WPattrib.bold?"bold ":"",
  5930.                 WPattrib.dim?"dim ":"",
  5931.                 WPattrib.invisible?"invisible ":"");
  5932.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5933.     }
  5934.  
  5935.     printf("\n");
  5936.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5937.     (VOID) shoesc(escape);
  5938.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5939.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5940.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5941.  
  5942. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5943.  
  5944.     printf("\n");
  5945.     printf("Terminal parameters:\n");
  5946.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5947.            "Bytesize: Command",
  5948.            (cmdmsk == 0377) ? 8 : 7,
  5949.            " bits","Terminal",
  5950.            (cmask == 0377) ? 8 : 7," bits");
  5951.     s = getenv("TERM");
  5952. #ifdef XPRINT
  5953.     printf(" %19s: %-13s  %13s: %-15s\n",
  5954.            "Type",
  5955.            s ? s : "(unknown)",
  5956.            "Print",
  5957.            showoff(tt_print)
  5958.            );
  5959. #else
  5960.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5961. #endif /* XPRINT */
  5962.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5963.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5964.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5965.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5966.  
  5967. #ifdef CK_APC
  5968.     if (apcstatus == APC_ON) s = "on";
  5969.     else if (apcstatus == APC_OFF) s = "off";
  5970.     else if (apcstatus == (APC_ON|APC_UNCH)) s = "unchecked";
  5971.     else if (apcstatus == (APC_ON|APC_NOINP)) s = "no-input";
  5972.     else if (apcstatus == (APC_ON|APC_UNCH|APC_NOINP))
  5973.       s = "unchecked-no-input";
  5974.     printf(" %19s: %-13s  %13s: %-15s\n",
  5975.            "APC", s,
  5976. #ifdef CK_AUTODL
  5977.            "Autodownload", autodl ?
  5978.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5979. #else
  5980.            "",""
  5981. #endif /* CK_AUTODL */
  5982.            );
  5983. #endif /* CK_APC */
  5984.  
  5985. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5986.     ttgwsiz();                          /* Try to get latest size */
  5987.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5988. #endif /* CK_TTGWSIZ */
  5989.  
  5990.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5991.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5992.  
  5993. #ifdef CKTIDLE
  5994.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5995.            "Idle-action", getiact());
  5996. #endif /* CKTIDLE */
  5997.  
  5998.     printf(" %19s: %-13s  ","Lf-display", tt_lfd ? "crlf" : "normal");
  5999. #ifdef UNIX
  6000. #ifndef NOJC
  6001.     printf("%13s: %-15s","Suspend", showoff(xsuspend));
  6002. #endif /* NOJC */
  6003. #endif /* UNIX */
  6004.     printf("\n");
  6005.  
  6006. #ifndef NOTRIGGER
  6007.     printf(" %19s: %-13s\n","Trigger",
  6008.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  6009. #endif /* NOTRIGGER */
  6010.     printf("\n");
  6011.  
  6012.     (VOID) shoesc(escape);
  6013. #ifndef NOCSETS
  6014.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  6015. #endif /* NOCSETS */
  6016.  
  6017. #endif /* OS2 */
  6018. }
  6019.  
  6020. VOID
  6021. shmdmlin() {                            /* Briefly show modem & line */
  6022. #ifndef NODIAL
  6023. #ifndef MINIDIAL
  6024. #ifdef OLDTBCODE
  6025.     extern int tbmodel;
  6026.     _PROTOTYP( char * gtbmodel, (void) );
  6027. #endif /* OLDTBCODE */
  6028. #endif /* MINIDIAL */
  6029. #endif /* NODIAL */
  6030.     if (local)
  6031. #ifdef OS2
  6032.       printf(" Port: %s, Modem type: ",ttname);
  6033. #else
  6034.       printf(" Line: %s, Modem type: ",ttname);
  6035. #endif /* OS2 */
  6036.     else
  6037.       printf(
  6038. #ifdef OS2
  6039. " Communication device not yet selected with SET PORT\n Modem type: "
  6040. #else
  6041. " Communication device not yet selected with SET LINE\n Modem type: "
  6042. #endif /* OS2 */
  6043.              );
  6044. #ifndef NODIAL
  6045.     printf("%s",gmdmtyp());
  6046. #ifndef MINIDIAL
  6047. #ifdef OLDTBCODE
  6048.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  6049. #endif /* OLDTBCODE */
  6050. #endif /* MINIDIAL */
  6051. #else
  6052.     printf("(disabled)");
  6053. #endif /* NODIAL */
  6054. }
  6055.  
  6056. #ifdef CK_TAPI
  6057. void
  6058. shotapi(int option) {
  6059.     int rc=0,k ;
  6060.     char *s=NULL;
  6061.     LPDEVCFG        lpDevCfg = NULL;
  6062.     LPCOMMCONFIG    lpCommConfig = NULL;
  6063.     LPMODEMSETTINGS lpModemSettings = NULL;
  6064.     DCB *           lpDCB = NULL;
  6065.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  6066.     extern int ntapiloc;
  6067.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  6068.     extern int ntapiline;
  6069.     extern int tttapi;                  /* TAPI in use */
  6070.     extern int tapipass;                /* TAPI Passthrough mode */
  6071.     extern int tapiconv;                /* TAPI Conversion mode */
  6072.     extern int tapilights;
  6073.     extern int tapipreterm;
  6074.     extern int tapipostterm;
  6075.     extern int tapimanual;
  6076.     extern int tapiinactivity;
  6077.     extern int tapibong;
  6078.     extern int tapiusecfg;
  6079.     extern char tapiloc[];
  6080.     extern int tapilocid;
  6081.     extern int TAPIAvail;
  6082.  
  6083.     if (!TAPIAvail) {
  6084.         printf("TAPI Support not enabled\r\n");
  6085.         return;
  6086.     }
  6087.     switch (option) {
  6088.       case 0:
  6089.         printf("TAPI Settings:\n");
  6090.         printf("  Line:                      %s\n",
  6091.                tttapi ? ttname : "(none in use)");
  6092.  
  6093.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  6094.         if (tapilocid == -1)
  6095.           tapilocid = cktapiGetCurrentLocationID();
  6096.  
  6097.         /* Find the current tapiloc entry */
  6098.         /* and use it as the default. */
  6099.         for (k = 0; k < ntapiloc; k++) {
  6100.             if (tapiloctab[k].kwval == tapilocid)
  6101.               break;
  6102.         }
  6103.         if (k >= 0 && k < ntapiloc)
  6104.           s = tapiloctab[k].kwd;
  6105.         else
  6106.           s = "(unknown)";
  6107.         printf("  Location:                  %s\n",s);
  6108.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  6109.         printf("  Phone-number-conversions:  %s\n",
  6110.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  6111.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  6112.                 tapipass?"(n/a)":"");
  6113.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  6114.                 tapipass?"(n/a)":"");
  6115.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  6116.                 tapipass?"(n/a)":"");
  6117.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  6118.                 tapipass?"(n/a)":"");
  6119.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  6120.                 tapipass?"(n/a)":"");
  6121.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  6122.                 tapipass?"(n/a)":"");
  6123.         printf("  Use-windows-configuration: %s %s\n",
  6124.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  6125.         printf("\n");
  6126.  
  6127. #ifdef BETATEST
  6128.         if (tapipass) {
  6129. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  6130. printf("may open the device but may not place calls nor answer calls.\n");
  6131. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  6132. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  6133. printf("definition associated with the active TAPI LINE device.\n\n");
  6134.  
  6135.         } else {
  6136.  
  6137. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  6138. printf("may open the device, place and answer calls.  Dialing is performed\n");
  6139. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  6140.         }
  6141.  
  6142.         if (tapiconv == CK_ON ||
  6143.             tapiconv == CK_AUTO && !tapipass) {
  6144. printf(
  6145. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  6146. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  6147. printf("dialog.\n\n");
  6148.  
  6149.         } else {
  6150.  
  6151. printf(
  6152. "Phone numbers are converted from canonical to dialable form by K-95\n");
  6153. printf(
  6154. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  6155. printf(
  6156. "Dialing Properties are imported automaticly upon startup and whenever\n");
  6157. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  6158. printf("is changed.\n\n");
  6159.         }
  6160. #endif /* BETATEST */
  6161.  
  6162.         if (tapipass) {
  6163.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  6164.             if (tapiconv == CK_ON)
  6165.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6166.         } else {
  6167.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  6168.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6169.         }
  6170.         break;
  6171.       case 1:
  6172.         cktapiDisplayTapiLocationInfo();
  6173.         break;
  6174.       case 2:
  6175.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  6176.                                      &lpCommConfig,&lpDCB);
  6177.         if (rc) {
  6178.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  6179.                                          lpCommConfig,lpDCB);
  6180.         } else {
  6181.             printf("?Unable to retrieve Modem Settings\n");
  6182.         }
  6183.         break;
  6184.       case 3: {
  6185.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  6186.           if (hModem)
  6187.             DisplayCommProperties(hModem);
  6188.           else
  6189.             printf("?Unable to retrieve a valid Modem Handle\n");
  6190.           CloseHandle(hModem);
  6191.           break;
  6192.       }
  6193.     }
  6194.     printf("\n");
  6195. }
  6196. #endif /* CK_TAPI */
  6197. #endif /* NOLOCAL */
  6198.  
  6199. #ifdef PATTERNS
  6200. static VOID
  6201. shopat() {
  6202.     extern char * binpatterns[], * txtpatterns[];
  6203.     extern int patterns, filepeek;
  6204.     char **p, *s;
  6205.     int i, j, k, n, flag, width;
  6206. #ifdef CK_TTGWSIZ
  6207.     ttgwsiz();                          /* Try to get latest size */
  6208. #ifdef OS2
  6209.     width = tt_cols[VCMD];
  6210. #else /* OS2 */
  6211.     width = tt_cols;
  6212. #endif /* OS2 */
  6213.     if (width < 1)
  6214. #endif /* CK_TTGWSIZ */
  6215.       width = 80;
  6216.     printf("\n");
  6217.     printf(" Set file type:            %s\n",gfmode(binary,1));
  6218.     printf(" Set file patterns:        %s", showooa(patterns));
  6219. #ifdef CK_LABELED
  6220.     if (binary == XYFT_L)
  6221.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  6222.     else
  6223. #endif /* CK_LABELED */
  6224. #ifdef VMS
  6225.     if (binary == XYFT_I)
  6226.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  6227.     else
  6228. #endif /* VMS */
  6229.     if (filepeek)
  6230.       printf(" (but SET FILE SCAN ON overrides)\n");
  6231.     else
  6232.       printf("\n");
  6233.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  6234.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  6235.         printf("\n");
  6236.         if (k == 0) {                   /* binary... */
  6237.             printf(" File binary-patterns: ");
  6238.             p = binpatterns;
  6239.         } else {                        /* text... */
  6240.             printf(" File text-patterns:   ");
  6241.             p = txtpatterns;
  6242.         }
  6243.         if (!p[0]) {
  6244.             printf("(none)\n");
  6245.         } else {
  6246.             printf("\n ");
  6247.             n = 2;
  6248.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  6249.                 if (!p[i])              /* Done */
  6250.                   break;
  6251.                 s = p[i];               /* Look for embedded space */
  6252.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  6253.                   if (*s == SP)
  6254.                     flag = 3;
  6255.                 n += j + flag;          /* Length of this line */
  6256.                 if (n >= width - 1) {
  6257.                     printf("\n ");
  6258.                     n = j+2;
  6259.                 }
  6260.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6261.             }
  6262.             if (n > 2)
  6263.               printf("\n");
  6264.         }
  6265.     }
  6266.     printf("\n");
  6267. }
  6268. #endif /* PATTERNS */
  6269.  
  6270. #ifndef NOSPL
  6271. static VOID
  6272. shooutput() {
  6273.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6274.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6275. }
  6276.  
  6277. static VOID
  6278. shoinput() {
  6279. #ifdef CKFLOAT
  6280.     extern char * inpscale;
  6281. #endif    /* CKFLOAT */
  6282.  
  6283. #ifdef CK_AUTODL
  6284.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6285. #endif /* CK_AUTODL */
  6286.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6287.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6288.            "observe" : "ignore");
  6289.     printf(" Input buffer-length:    %d\n", inbufsize);
  6290.     printf(" Input echo:             %s\n", showoff(inecho));
  6291.     printf(" Input silence:          %d (seconds)\n", insilence);
  6292. #ifdef OS2
  6293.     printf(" Input terminal:         %s\n", showoff(interm));
  6294. #endif /* OS2 */
  6295.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6296.            "quit" : "proceed");
  6297. #ifdef CKFLOAT
  6298.     printf(" Input scale-factor:     %s\n", inpscale ? inpscale : "1.0");
  6299. #endif    /* CKFLOAT */
  6300.  
  6301.     if (instatus < 0)
  6302.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6303.     else
  6304.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6305. }
  6306. #endif /* NOSPL */
  6307.  
  6308. #ifndef NOSPL
  6309. int
  6310. showarray() {
  6311. #ifdef COMMENT
  6312.     char * p, * q, ** ap;
  6313.     int i;
  6314. #endif /* COMMENT */
  6315.     char *s; int x = 0, y;
  6316.     int range[2];
  6317.  
  6318.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6319.       if (y != -3)
  6320.         return(y);
  6321.     ckstrncpy(line,s,LINBUFSIZ);
  6322.     s = line;
  6323.     if ((y = cmcfm()) < 0)
  6324.       return(y);
  6325.     if (*s) {
  6326.         char ** ap;
  6327.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6328.             printf("?Bad array: %s\n",s);
  6329.             return(-9);
  6330.         }
  6331.         ap = a_ptr[x];
  6332.         if (!ap) {
  6333.             printf("Array not declared: %s\n", s);
  6334.             return(success = 1);
  6335.         } else {
  6336.             int i, n, max;
  6337.             max = (range[1] > 0) ?
  6338.               range[1] :
  6339.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6340.             if (range[0] < 0)
  6341.               range[0] = 0;
  6342.             if (max > a_dim[x])
  6343.               max = a_dim[x];
  6344.             n = 1;
  6345.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6346.             if (a_link[x] > -1)
  6347.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6348.             printf("\n");
  6349.             for (i = range[0]; i <= max; i++) {
  6350.                 if (ap[i]) {
  6351.                     printf("%3d. %s\n",i,ap[i]);
  6352.                     if (xaskmore) {
  6353.                         if (cmd_cols > 0) {
  6354.                             x = strlen(ap[i]) + 5;
  6355.                             y = (x % cmd_cols) ? 1 : 0;
  6356.                             n += (x / cmd_cols) + y;
  6357.                         } else {
  6358.                             n++;
  6359.                         }
  6360.                         if (n > (cmd_rows - 3)) {
  6361.                             if (!askmore())
  6362.                               break;
  6363.                             else
  6364.                               n = 0;
  6365.                         }
  6366.                     }
  6367.                 }
  6368.             }
  6369.         }
  6370.         return(1);
  6371.     }
  6372.  
  6373.     /* All arrays - just show name and dimension */
  6374.  
  6375.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6376.         if (a_ptr[y]) {
  6377.             if (x == 0) printf("Declared arrays:\n");
  6378.             x = 1;
  6379.             printf(" \\&%c[%d]",
  6380.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6381.             if (a_link[y] > -1)
  6382.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6383.             printf("\n");
  6384.         }
  6385.         if (!x) printf(" No arrays declared\n");
  6386.     }
  6387.     return(1);
  6388. }
  6389. #endif /* NOSPL */
  6390.  
  6391. int
  6392. doshow(x) int x; {
  6393.     int y, z, i; long zz;
  6394.     extern int optlines;
  6395.     char *s;
  6396. #ifdef OS2
  6397.     extern int os2gks;
  6398.     extern int tt_kb_mode;
  6399. #endif /* OS2 */
  6400.     extern int srvcdmsg;
  6401.     extern char * cdmsgstr, * ckcdpath;
  6402.  
  6403. #ifndef NOSETKEY
  6404.     if (x == SHKEY) {                   /* SHOW KEY */
  6405.         int c;
  6406. #ifdef OS2
  6407.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6408.                         "one",xxstring)) < 0) return(x);
  6409.         switch (tt_kb_mode) {
  6410.           case KBM_EM:
  6411.             s = "emacs";
  6412.             break;
  6413.           case KBM_HE:
  6414.             s = "hebrew";
  6415.             break;
  6416.           case KBM_RU:
  6417.             s = "russian";
  6418.             break;
  6419.           case KBM_EN:
  6420.           default:
  6421.             s = "default";
  6422.             break;
  6423.         }
  6424.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6425.                         s,xxstring)) < 0) return(z);
  6426.         if (z == SHKEYDEF)
  6427.           z = -1;
  6428. #endif /* OS2 */
  6429.         if ((y = cmcfm()) < 0) return(y);
  6430. #ifdef IKSD
  6431.         if (inserver) {
  6432.             printf("Sorry, command disabled.\r\n");
  6433.             return(success = 0);
  6434.         }
  6435. #endif /* IKSD */
  6436.  
  6437. #ifdef MAC
  6438.         printf("Not implemented\n");
  6439.         return(0);
  6440. #else /* Not MAC */
  6441. #ifdef OS2
  6442.         if (x) {
  6443.             con_event evt;
  6444.             for (c = 0; c < KMSIZE; c++) {
  6445.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6446.                 if (evt.type != error) {
  6447.                     shokeycode(c,z);
  6448.                 }
  6449.             }
  6450.         } else {
  6451. #endif /* OS2 */
  6452.             printf(" Press key: ");
  6453. #ifdef UNIX
  6454. #ifdef NOSETBUF
  6455.             fflush(stdout);
  6456. #endif /* NOSETBUF */
  6457. #endif /* UNIX */
  6458.             conbin((char)escape);       /* Put terminal in binary mode */
  6459. #ifdef OS2
  6460.             os2gks = 0;                 /* Raw scancode processing */
  6461. #endif /* OS2 */
  6462.             c = congks(0);              /* Get character or scan code */
  6463. #ifdef OS2
  6464.             os2gks = 1;                 /* Cooked scancode processing */
  6465. #endif /* OS2 */
  6466.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6467.             if (c < 0) {                /* Check for error */
  6468.                 printf("?Error reading key\n");
  6469.                 return(0);
  6470.             }
  6471. #ifndef OS2
  6472. /*
  6473.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6474. */
  6475.             c &= cmdmsk;                /* Apply command mask */
  6476. #endif /* OS2 */
  6477.             printf("\n");
  6478. #ifdef OS2
  6479.             shokeycode(c,z);
  6480. #else /* OS2 */
  6481.             shokeycode(c);
  6482. #endif /* OS2 */
  6483. #ifdef OS2
  6484.         }
  6485. #endif /* OS2 */
  6486.         return(1);
  6487. #endif /* MAC */
  6488.     }
  6489. #ifndef NOKVERBS
  6490.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6491.         if ((y = cmcfm()) < 0) return(y);
  6492. #ifdef IKSD
  6493.         if (inserver) {
  6494.             printf("Sorry, command disabled.\r\n");
  6495.             return(success = 0);
  6496.         }
  6497. #endif /* IKSD */
  6498.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6499.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6500.         printf("\n");
  6501.         return(1);
  6502.     }
  6503. #ifdef OS2
  6504.     if (x == SHUDK) {                   /* SHOW UDKs */
  6505.         extern void showudk(void);
  6506.         if ((y = cmcfm()) < 0) return(y);
  6507. #ifdef IKSD
  6508.         if (inserver) {
  6509.             printf("Sorry, command disabled.\r\n");
  6510.             return(success = 0);
  6511.         }
  6512. #endif /* IKSD */
  6513.         showudk();
  6514.         return(1);
  6515.     }
  6516. #endif /* OS2 */
  6517. #endif /* NOKVERBS */
  6518. #endif /* NOSETKEY */
  6519.  
  6520. #ifndef NOSPL
  6521.     if (x == SHMAC) {                   /* SHOW MACRO */
  6522.         struct FDB kw, fl, cm;
  6523.         int i, k, n = 0, left, flag, confirmed = 0;
  6524.         char * p, *q[64];
  6525.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6526.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6527.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6528.             mackey[i].flgs = mactab[i].flgs;
  6529.         }
  6530.         p = line;
  6531.         left = LINBUFSIZ;
  6532.         while (!confirmed && n < 64) {
  6533.             cmfdbi(&kw,                 /* First FDB - macro table */
  6534.                    _CMKEY,              /* fcode */
  6535.                    "Macro name",        /* hlpmsg */
  6536.                    "",                  /* default */
  6537.                    "",                  /* addtl string data */
  6538.                    nmac,                /* addtl numeric data 1: tbl size */
  6539.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6540.                    xxstring,            /* Processing function */
  6541.                    mackey,              /* Keyword table */
  6542.                    &fl                  /* Pointer to next FDB */
  6543.                    );
  6544.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6545.                    _CMFLD,              /* fcode */
  6546.                    "",                  /* hlpmsg */
  6547.                    "",                  /* default */
  6548.                    "",                  /* addtl string data */
  6549.                    0,                   /* addtl numeric data 1 */
  6550.                    0,                   /* addtl numeric data 2 */
  6551.                    xxstring,
  6552.                    NULL,
  6553.                    &cm
  6554.                    );
  6555.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6556.                    _CMCFM,              /* fcode */
  6557.                    "",                  /* hlpmsg */
  6558.                    "",                  /* default */
  6559.                    "",                  /* addtl string data */
  6560.                    0,                   /* addtl numeric data 1 */
  6561.                    0,                   /* addtl numeric data 2 */
  6562.                    NULL,
  6563.                    NULL,
  6564.                    NULL
  6565.                    );
  6566.             x = cmfdb(&kw);             /* Parse something */
  6567.             if (x < 0)
  6568.               return(x);
  6569.             s = atmbuf;                 /* What the user typed */
  6570.             switch (cmresult.fcode) {
  6571.               case _CMKEY:              /* If it was a keyword */
  6572.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6573.                 if (y > -1)
  6574.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6575.               case _CMFLD:
  6576.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6577.                 left -= k;
  6578.                 if (left <= 0) {
  6579.                     *p = NUL;
  6580.                     break;
  6581.                 }
  6582.                 q[n++] = p;             /* Point to this item */
  6583.                 p += k;                 /* Move buffer pointer past it */
  6584.                 break;
  6585.               case _CMCFM:              /* End of command */
  6586.                 confirmed++;
  6587.               default:
  6588.                 break;
  6589.             }
  6590.         }
  6591.         if (n == 0) {
  6592.             printf("Macros:\n");
  6593.             slc = 1;
  6594.             for (y = 0; y < nmac; y++)
  6595.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6596.             return(1);
  6597.         }
  6598.         slc = 0;
  6599.         for (i = 0; i < n; i++) {
  6600.             flag = 0;
  6601.             s = q[i];
  6602.             if (!s) s = "";
  6603.             if (!*s) continue;
  6604.             if (iswild(s)) {            /* Pattern match */
  6605.                 for (k = 0, x = 0; x < nmac; x++) {
  6606.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6607.                         shomac(mactab[x].kwd,mactab[x].mval);
  6608.                         k++;
  6609.                     }
  6610.                 }
  6611.                 if (!k)
  6612.                   x = -1;
  6613.                 else
  6614.                   continue;
  6615.             } else {                    /* Exact match */
  6616.                 x = mxlook(mactab,s,nmac);
  6617.                 flag = 1;
  6618.             }
  6619.             if (flag && x == -1)
  6620.               x = mlook(mactab,s,nmac);
  6621.             switch (x) {
  6622.               case -3:                  /* Nothing to look up */
  6623.               case -1:                  /* Not found */
  6624.                 printf("%s - (not defined)\n",s);
  6625.                 break;
  6626.               case -2:                  /* Ambiguous, matches more than one */
  6627.                 printf("%s - ambiguous\n",s);
  6628.                 break;
  6629.               default:                  /* Matches one exactly */
  6630.                 shomac(mactab[x].kwd,mactab[x].mval);
  6631.                 break;
  6632.             }
  6633.         }
  6634.         return(1);
  6635.     }
  6636. #endif /* NOSPL */
  6637.  
  6638. /*
  6639.   Other SHOW commands only have two fields.  Get command confirmation here,
  6640.   then handle with big switch() statement.
  6641. */
  6642. #ifndef NOSPL
  6643.     if (x != SHBUI && x != SHARR)
  6644. #endif /* NOSPL */
  6645.       if ((y = cmcfm()) < 0)
  6646.         return(y);
  6647.  
  6648. #ifdef COMMENT
  6649.     /* This restriction is too general. */
  6650. #ifdef IKSD
  6651.     if (inserver &&
  6652. #ifdef CK_LOGIN
  6653.         isguest
  6654. #else
  6655.         0
  6656. #endif /* CK_LOGIN */
  6657.         ) {
  6658.         printf("Sorry, command disabled.\r\n");
  6659.         return(success = 0);
  6660.     }
  6661. #endif /* IKSD */
  6662. #endif /* COMMENT */
  6663.  
  6664.     switch (x) {
  6665.  
  6666. #ifdef ANYX25
  6667. #ifndef IBMX25
  6668.       case SHPAD:
  6669.         shopad(0);
  6670.         break;
  6671. #endif /* IBMX25 */
  6672. #endif /* ANYX25 */
  6673.  
  6674.       case SHNET:
  6675. #ifdef NOLOCAL
  6676.         printf(" No network support in this version of C-Kermit.\n");
  6677. #else
  6678. #ifndef NETCONN
  6679.         printf(" No network support in this version of C-Kermit.\n");
  6680. #else
  6681.         shonet();
  6682. #endif /* NETCONN */
  6683. #endif /* NOLOCAL */
  6684.         break;
  6685.  
  6686.       case SHPAR:
  6687.         shopar();
  6688.         break;
  6689.  
  6690. #ifndef NOXFER
  6691.       case SHATT:
  6692.         shoatt();
  6693.         break;
  6694. #endif /* NOXFER */
  6695.  
  6696. #ifndef NOSPL
  6697.       case SHCOU:
  6698.         printf(" %d\n",count[cmdlvl]);
  6699.         break;
  6700. #endif /* NOSPL */
  6701.  
  6702. #ifndef NOSERVER
  6703.       case SHSER:                       /* Show Server */
  6704.         i = 0;
  6705. #ifndef NOFRILLS
  6706.         printf("Function:          Status:\n");
  6707.         i++;
  6708.         printf(" GET                %s\n",nm[en_get]);
  6709.         i++;
  6710.         printf(" SEND               %s\n",nm[en_sen]);
  6711.         i++;
  6712.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6713.         i++;
  6714.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6715.         i++;
  6716. #ifndef NOSPL
  6717.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6718.         i++;
  6719. #endif /* NOSPL */
  6720.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6721.         i++;
  6722. #ifdef ZCOPY
  6723.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6724.         i++;
  6725. #endif /* ZCOPY */
  6726.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6727.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6728.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6729.         i += 3;
  6730. #ifndef NOSPL
  6731.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6732.         i++;
  6733. #endif /* NOSPL */
  6734.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6735.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6736.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6737.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6738.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6739.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6740.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6741.         printf(" BYE                %s\n",nm[en_bye]);
  6742.         printf(" FINISH             %s\n",nm[en_fin]);
  6743.         printf(" EXIT               %s\n",nm[en_xit]);
  6744.         printf(" ENABLE             %s\n",nm[en_ena]);
  6745.         i += 11;
  6746. #endif /* NOFRILLS */
  6747.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6748.         printf("Server timeout:      %d\n",srvtim);
  6749.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6750.         printf("Server idle-timeout: %d\n",srvidl);
  6751.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6752.         printf("Server keepalive     %s\n", showoff(srvping));
  6753.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6754.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6755.         if (srvcdmsg && cdmsgstr)
  6756.           printf("Server cd-message    %s\n", cdmsgstr);
  6757.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6758.         printf("Server display:      %s\n", showoff(srvdis));
  6759.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6760.         printf("Server login:        ");
  6761.         if (!x_user) {
  6762.             printf("(none)\n");
  6763.         } else {
  6764.             printf("\"%s\", \"%s\", \"%s\"\n",
  6765.                    x_user,
  6766.                    x_passwd ? x_passwd : "",
  6767.                    x_acct ? x_acct : ""
  6768.                    );
  6769.         }
  6770.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6771.         printf("Server get-path: ");
  6772.         if (ngetpath == 0) {
  6773.             printf("    (none)\n");
  6774.         } else {
  6775.             printf("\n");
  6776.             i += 3;
  6777.             for (x = 0; x < ngetpath; x++) {
  6778.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6779.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6780.                     if (!askmore())
  6781.                       break;
  6782.                     else
  6783.                       i = 0;
  6784.                 }
  6785.             }
  6786.         }
  6787.         break;
  6788. #endif /* NOSERVER */
  6789.  
  6790.       case SHSTA:                       /* Status of last command */
  6791.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6792.         return(0);                      /* Don't change it */
  6793.  
  6794.       case SHSTK: {                     /* Stack for MAC debugging */
  6795. #ifdef MAC
  6796.           long sp;
  6797.           sp = -1;
  6798.           loadA0 ((char *)&sp);         /* set destination address */
  6799.           SPtoaA0();                    /* move SP to destination */
  6800.           printf("Stack at 0x%x\n", sp);
  6801.           show_queue();                 /* more debugging */
  6802.           break;
  6803. #else
  6804.           shostack();
  6805. #endif /* MAC */
  6806.           break;
  6807.       }
  6808.  
  6809.  
  6810. #ifndef NOLOCAL
  6811. #ifdef OS2
  6812.       case SHTAB:                       /* SHOW TABS */
  6813. #ifdef IKSD
  6814.         if (inserver) {
  6815.             printf("Sorry, command disabled.\r\n");
  6816.             return(success = 0);
  6817.         }
  6818. #endif /* IKSD */
  6819.         shotabs();
  6820.         break;
  6821. #endif /* OS2 */
  6822.  
  6823.       case SHTER:                       /* SHOW TERMINAL */
  6824. #ifdef IKSD
  6825.         if (inserver) {
  6826.             printf("Sorry, command disabled.\r\n");
  6827.             return(success = 0);
  6828.         }
  6829. #endif /* IKSD */
  6830.         shotrm();
  6831.         break;
  6832.  
  6833. #ifdef OS2
  6834.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6835.         shovscrn();
  6836.         break;
  6837. #endif /* OS2 */
  6838. #endif /* NOLOCAL */
  6839.  
  6840. #ifdef OS2MOUSE
  6841.       case SHMOU:                       /* SHOW MOUSE */
  6842. #ifdef IKSD
  6843.         if (inserver) {
  6844.             printf("Sorry, command disabled.\r\n");
  6845.             return(success = 0);
  6846.         }
  6847. #endif /* IKSD */
  6848.         shomou();
  6849.         break;
  6850. #endif /* OS2MOUSE */
  6851.  
  6852. #ifndef NOFRILLS
  6853.       case SHVER:
  6854.         shover();
  6855.         break;
  6856. #endif /* NOFRILLS */
  6857.  
  6858. #ifndef NOSPL
  6859.       case SHBUI:                       /* Built-in variables */
  6860.     line[0] = NUL;
  6861.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6862.           return(y);
  6863.         ckstrncpy(line,s,LINBUFSIZ);
  6864.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6865.  
  6866.       case SHFUN:                       /* or built-in functions */
  6867. #ifdef CK_TTGWSIZ
  6868. #ifdef OS2
  6869.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6870.           ttgwsiz();
  6871. #else /* OS2 */
  6872.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6873.             if (tt_rows > 0 && tt_cols > 0) {
  6874.                 cmd_rows = tt_rows;
  6875.                 cmd_cols = tt_cols;
  6876.             }
  6877.         }
  6878. #endif /* OS2 */
  6879. #endif /* CK_TTGWSIZ */
  6880.  
  6881.         if (x == SHFUN) {               /* Functions */
  6882.             printf("\nThe following functions are available:\n\n");
  6883.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6884.             printf("\n");
  6885. #ifndef NOHELP
  6886.             printf(
  6887. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6888.                    );
  6889. #endif /* NOHELP */
  6890.             break;
  6891.         } else {                        /* Variables */
  6892.         int j, flag = 0, havearg = 0;
  6893.         struct stringarray * q = NULL;
  6894.         char ** pp;
  6895.         if (line[0]) {        /* Have something to search for */
  6896.         havearg = 1;        /* Maybe a list of things */
  6897.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6898.         if (!q) break;
  6899.         pp = q->a_head;
  6900.         }
  6901.         i = 0;
  6902.         for (y = 0; y < nvars; y++) {
  6903.         if ((vartab[y].flgs & CM_INV))
  6904.           continue;
  6905.         if (havearg) {        /* If I have something to match */
  6906.             char * s2;
  6907.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6908.             s2 = pp[j] ? pp[j] : "";
  6909. #ifdef COMMENT
  6910. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6911.             len = strlen(s2);
  6912.             if (len > 0) {
  6913.                 if (s2[len-1] != '$') {/* To allow anchors */
  6914.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6915.                 s2 = line;
  6916.                 }
  6917.             }
  6918. #endif /* COMMENT */
  6919.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6920.                 flag = 1;    /* Matches */
  6921.                 break;
  6922.             }
  6923.             }
  6924.             if (!flag)        /* Doesn't match */
  6925.               continue;
  6926.         }
  6927.         s = nvlook(vartab[y].kwd);
  6928.         printf(" \\v(%s) = ",vartab[y].kwd);
  6929.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6930.             while (*s)        /* Show control chars symbolically */
  6931.               printf("\\{%d}",*s++);
  6932.             printf("\n");
  6933.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6934.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6935. #ifdef OS2
  6936.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6937. #endif /* OS2 */
  6938.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6939.                 vartab[y].kwval <= VN_M_ZZZ)
  6940.                ) {
  6941.             int r = 12;        /* This one can wrap around */
  6942.             char buf[10];
  6943.             while (*s) {
  6944.             if (isprint(*s)) {
  6945.                 buf[0] = *s;
  6946.                 buf[1] = NUL;
  6947.                 r++;
  6948.             } else {
  6949.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6950.                 r += (int) strlen(buf);
  6951.             }
  6952.             if (r >= cmd_cols - 1) {
  6953.                 printf("\n");
  6954.                 r = 0;
  6955.                 i++;
  6956.             }
  6957.             printf("%s",buf);
  6958.             s++;
  6959.             }
  6960.             printf("\n");
  6961.         } else
  6962.           printf("%s\n",s);
  6963.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6964.             if ((y >= nvars - 1) || !askmore())
  6965.               break;
  6966.             else
  6967.               i = 0;
  6968.         }
  6969.         }
  6970.         }
  6971.         break;
  6972.  
  6973.       case SHVAR:                       /* Global variables */
  6974.         x = 0;                          /* Variable count */
  6975.         slc = 1;                        /* Screen line count for "more?" */
  6976.         for (y = 33; y < GVARS; y++)
  6977.           if (g_var[y]) {
  6978.               if (x++ == 0) printf("Global variables:\n");
  6979.               sprintf(line," \\%%%c",y); /* SAFE */
  6980.               if (shomac(line,g_var[y]) < 0) break;
  6981.           }
  6982.         if (!x) printf(" No variables defined\n");
  6983.         break;
  6984.  
  6985.       case SHARG: {                     /* Args */
  6986.           char * s1, * s2;
  6987.           if (maclvl > -1) {
  6988.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6989.                      maclvl,
  6990.                      macargc[maclvl]
  6991.                      );
  6992.               for (y = 0; y < macargc[maclvl]; y++) {
  6993.                   s1 = m_arg[maclvl][y];
  6994.                   if (!s1) s1 = "(NULL)";
  6995.                   s2 = m_xarg[maclvl][y];
  6996.                   if (!s2) s2 = "(NULL)";
  6997.                   if (y < 10)
  6998.                     printf(" \\%%%d = %s\n",y,s1);
  6999.                   else
  7000.                     printf(" \\&_[%d] = %s\n",y,s2);
  7001.               }
  7002.           } else {
  7003.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  7004.               for (y = 0; y < topargc; y++) {
  7005.                   s1 = g_var[y + '0'];
  7006.                   if (!s1) s1 = "(NULL)";
  7007.                   s2 = toparg[y];
  7008.                   if (!s2) s2 = "(NULL)";
  7009.                   if (y < 10 && g_var[y])
  7010.                     printf(" \\%%%d = %s\n",y,s1);
  7011.                   if (toparg[y])
  7012.                     printf(" \\&_[%d] = %s\n",y,s2);
  7013.               }
  7014.           }
  7015.         }
  7016.         break;
  7017.  
  7018.       case SHARR:                       /* Arrays */
  7019.         return(showarray());
  7020. #endif /* NOSPL */
  7021.  
  7022. #ifndef NOXFER
  7023.       case SHPRO:                       /* Protocol parameters */
  7024.         shoparp();
  7025.         printf("\n");
  7026.         break;
  7027. #endif /* NOXFER */
  7028.  
  7029. #ifndef NOLOCAL
  7030.       case SHCOM:                       /* Communication parameters */
  7031.         printf("\n");
  7032.         shoparc();
  7033. #ifdef OS2
  7034.         {
  7035.             int i;
  7036.             char *s = "(unknown)";
  7037.             for (i = 0; i < nprty; i++)
  7038.               if (prtytab[i].kwval == priority) {
  7039.                   s = prtytab[i].kwd;
  7040.                   break;
  7041.               }
  7042.             printf(" Priority: %s\n", s );
  7043.         }
  7044. #endif /* OS2 */
  7045.  
  7046.         printf("\n");
  7047. #ifdef NETCONN
  7048.         if (!network
  7049. #ifdef IKSD
  7050.              && !inserver
  7051. #endif /* IKSD */
  7052.              ) {
  7053. #endif /* NETCONN */
  7054.             shomdm();
  7055.             printf("\n");
  7056. #ifdef NETCONN
  7057.         }
  7058. #endif /* NETCONN */
  7059.  
  7060. #ifndef NODIAL
  7061. #ifdef IKSD
  7062.         if ( !inserver )
  7063. #endif /* IKSD */
  7064.         {
  7065.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  7066.             printf("Type SHOW MODEM to see modem-related items.\n");
  7067. #ifdef CK_TAPI
  7068.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  7069. #endif /* CK_TAPI */
  7070.             printf("\n");
  7071.         }
  7072. #endif /* NODIAL */
  7073.         break;
  7074. #endif /* NOLOCAL */
  7075.  
  7076.       case SHFIL:                       /* File parameters */
  7077.         shofil();
  7078.         /* printf("\n"); */             /* (out o' space) */
  7079.         break;
  7080.  
  7081. #ifndef NOCSETS
  7082.       case SHLNG:                       /* Languages */
  7083.         shoparl();
  7084.         break;
  7085. #endif /* NOCSETS */
  7086.  
  7087. #ifndef NOSPL
  7088.       case SHSCR:                       /* Scripts */
  7089.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  7090.         printf(" Take  echo:             %s\n", showoff(techo));
  7091.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  7092.         printf(" Macro echo:             %s\n", showoff(mecho));
  7093.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  7094.         printf(" Quiet:                  %s\n", showoff(quiet));
  7095.         printf(" Variable evaluation:    %s [\\%%x and \\&x[] variables]\n",
  7096.            vareval ? "recursive" : "simple");
  7097.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  7098.         printf(" Function error:         %s\n", showoff(fnerror));
  7099. #ifdef CKLEARN
  7100.         {
  7101.             extern char * learnfile;
  7102.             extern int learning;
  7103.             if (learnfile) {
  7104.                 printf(" LEARN file:             %s (%s)\n",
  7105.                        learnfile,
  7106.                        learning ? "ON" : "OFF"
  7107.                        );
  7108.             } else
  7109.               printf(" LEARN file:             (none)\n");
  7110.         }
  7111. #endif /* CKLEARN */
  7112.         shoinput();
  7113.         shooutput();
  7114. #ifndef NOSCRIPT
  7115.         printf(" Script echo:            %s\n", showoff(secho));
  7116. #endif /* NOSCRIPT */
  7117.         printf(" Command buffer length:  %d\n", CMDBL);
  7118.         printf(" Atom buffer length:     %d\n", ATMBL);
  7119.         break;
  7120. #endif /* NOSPL */
  7121.  
  7122. #ifndef NOXMIT
  7123.       case SHXMI:
  7124.         printf("\n");
  7125.         printf(" File type:                       %s\n",
  7126.                binary ? "binary" : "text");
  7127. #ifndef NOCSETS
  7128.         printf(" File character-set:              %s\n",
  7129.                fcsinfo[fcharset].keyword);
  7130. #ifdef OS2
  7131.         if ( isunicode() ) {
  7132.         printf(" Terminal Character (remote):     %s\n",
  7133.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7134.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7135.         printf(" Terminal Character (local):      %s\n",
  7136.               tcsl == TX_TRANSP ? "transparent" :
  7137.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7138.         } else {
  7139.         printf(" Terminal Character (remote):     %s\n",
  7140.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7141.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7142.         printf(" Terminal Character (local):      %s\n",
  7143.               tcsl == TX_TRANSP ? "transparent" :
  7144.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7145.         }
  7146. #else /* OS2 */
  7147.         printf(" Terminal character-set (remote): %s\n",
  7148.                fcsinfo[tcsr].keyword);
  7149.         printf(" Terminal character-set (local):  %s\n",
  7150.                fcsinfo[tcsl].keyword);
  7151. #endif /* OS2 */
  7152. #endif /* NOCSETS */
  7153.         printf(" Terminal bytesize:               %d\n",
  7154.                (cmask == 0xff) ? 8 : 7);
  7155.         printf(" Terminal echo:                   %s\n",
  7156.                duplex ? "local" : "remote");
  7157.         printf(" Transmit EOF:                    ");
  7158.         if (*xmitbuf == NUL) {
  7159.             printf("(none)\n");
  7160.         } else {
  7161.             char *p;
  7162.             p = xmitbuf;
  7163.             while (*p) {
  7164.                 if (*p < SP)
  7165.                   printf("^%c",ctl(*p));
  7166.                 else
  7167.                   printf("%c",*p);
  7168.                 p++;
  7169.             }
  7170.             printf("\n");
  7171.         }
  7172.         if (xmitf)
  7173.           printf(" Transmit Fill:                   %d\n", xmitf);
  7174.         else
  7175.           printf(" Transmit Fill:                   (none)\n");
  7176.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  7177.         if (xmitp)
  7178.           printf(" Transmit Prompt:                 %d (%s)\n",
  7179.                  xmitp,
  7180.                  chartostr(xmitp)
  7181.                  );
  7182.         else
  7183.           printf(" Transmit Prompt:                 (none)\n");
  7184.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  7185.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  7186.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  7187.                xmitw,
  7188.                (xmitw == 1) ? "" : "s"
  7189.                );
  7190.         printf(" Transmit Timeout:                %d (second%s)\n",
  7191.                xmitt,
  7192.                (xmitt == 1) ? "" : "s"
  7193.                );
  7194.         printf("\n");
  7195.         break;
  7196. #endif /* NOXMIT */
  7197.  
  7198. #ifndef NODIAL
  7199.       case SHMOD:                       /* SHOW MODEM */
  7200. #ifdef IKSD
  7201.         if (inserver) {
  7202.             printf("Sorry, command disabled.\r\n");
  7203.             return(success = 0);
  7204.         }
  7205. #endif /* IKSD */
  7206.         shomodem();                     /* Show SET MODEM items */
  7207.         break;
  7208. #endif /* NODIAL */
  7209.  
  7210. #ifndef MAC
  7211.       case SHDFLT:
  7212.         printf("%s\n",zgtdir());
  7213.         break;
  7214. #endif /* MAC */
  7215.  
  7216. #ifndef NOLOCAL
  7217.       case SHESC:
  7218. #ifdef IKSD
  7219.         if (inserver) {
  7220.             printf("Sorry, command disabled.\r\n");
  7221.             return(success = 0);
  7222.         }
  7223. #endif /* IKSD */
  7224.         return(shoesc(escape));
  7225.  
  7226. #ifndef NODIAL
  7227.       case SHDIA:                       /* SHOW DIAL */
  7228. #ifdef IKSD
  7229.         if (inserver) {
  7230.             printf("Sorry, command disabled.\r\n");
  7231.             return(success = 0);
  7232.         }
  7233. #endif /* IKSD */
  7234.         shmdmlin();
  7235.         printf(", speed: ");
  7236.         if ((zz = ttgspd()) < 0) {
  7237.             printf("unknown");
  7238.         } else {
  7239.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  7240.         }
  7241.         if (carrier == CAR_OFF) s = "off";
  7242.         else if (carrier == CAR_ON) s = "on";
  7243.         else if (carrier == CAR_AUT) s = "auto";
  7244.         else s = "unknown";
  7245.         printf(", carrier: %s", s);
  7246.         if (carrier == CAR_ON) {
  7247.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  7248.             else printf(", timeout: none");
  7249.         }
  7250.         printf("\n");
  7251.         doshodial();
  7252.         if (local
  7253. #ifdef NETCONN
  7254.             && !network
  7255. #endif /* NETCONN */
  7256.             ) {
  7257.             printf("Type SHOW MODEM to see modem settings.\n");
  7258. #ifdef CK_TAPI
  7259.             printf("Type SHOW TAPI to see TAPI-related items\n");
  7260. #endif /* CK_TAPI */
  7261.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  7262.         }
  7263.         break;
  7264. #endif /* NODIAL */
  7265. #endif /* NOLOCAL */
  7266.  
  7267. #ifndef NOXFER
  7268. #ifdef CK_LABELED
  7269.       case SHLBL:                       /* Labeled file info */
  7270.         sholbl();
  7271.         break;
  7272. #endif /* CK_LABELED */
  7273. #endif /* NOXFER */
  7274.  
  7275.       case SHCSE:                       /* Character sets */
  7276. #ifdef NOCSETS
  7277.         printf(
  7278. " Character set translation is not supported in this version of C-Kermit\n");
  7279. #else
  7280.         shocharset();
  7281. #ifndef NOXFER
  7282.         printf("\n Unknown-Char-Set: %s\n",
  7283.                unkcs ? "Keep" : "Discard");
  7284. #endif /* NOXFER */
  7285. #ifdef OS2
  7286.         printf("\n");
  7287. #endif /* OS2 */
  7288.         shotcs(tcsl,tcsr);
  7289.         printf("\n");
  7290. #ifdef OS2
  7291.         /* PC Code Page information */
  7292.         {
  7293.             char cpbuf[128];
  7294.             int cplist[16], cps;
  7295.             int activecp;
  7296.             cps = os2getcplist(cplist, sizeof(cplist));
  7297.  
  7298.             sprintf(cpbuf,              /* SAFE */
  7299.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7300.                      cps > 1 ? cplist[1] : 0,
  7301.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7302.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7303.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7304.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7305.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7306.                      cps > 12 ? cplist[12] : 0
  7307.                      );
  7308.             printf(" Code Pages:\n");
  7309.             activecp = os2getcp();
  7310.             if ( activecp ) {
  7311.               printf("     Active: %d\n",activecp);
  7312.               if (!isWin95())
  7313.                 printf("  Available: %s\n",cpbuf);
  7314.             } else
  7315.               printf("     Active: n/a\n");
  7316.             printf("\n");
  7317.         }
  7318. #endif /* OS2 */
  7319. #endif /* NOCSETS */
  7320.         break;
  7321.  
  7322.       case SHFEA:                       /* Features */
  7323.         shofea();
  7324.         break;
  7325.  
  7326. #ifdef CK_SPEED
  7327.       case SHCTL:                       /* Control-Prefix table */
  7328.         shoctl();
  7329.         break;
  7330. #endif /* CK_SPEED */
  7331.  
  7332.       case SHEXI: {
  7333.           extern int exithangup;
  7334.           printf("\n Exit warning %s\n", xitwarn ?
  7335.                  (xitwarn == 1 ? "on" : "always") : "off");
  7336.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7337.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7338.           printf(" Current exit status: %d\n\n", xitsta);
  7339.           break;
  7340.       }
  7341.       case SHPRT: {
  7342. #ifdef PRINTSWI
  7343.           extern int printtimo, printertype, noprinter;
  7344.           extern char * printterm, * printsep;
  7345.           extern int prncs;
  7346. #ifdef BPRINT
  7347.           extern int printbidi;
  7348. #endif /* BPRINT */
  7349. #endif /* PRINTSWI */
  7350.  
  7351. #ifdef IKSD
  7352.         if (inserver &&
  7353. #ifdef CK_LOGIN
  7354.             isguest
  7355. #else /* CK_LOGIN */
  7356.             0
  7357. #endif /* CK_LOGIN */
  7358.              ) {
  7359.             printf("Sorry, command disabled.\r\n");
  7360.             return(success = 0);
  7361.         }
  7362. #endif /* IKSD */
  7363. #ifdef PRINTSWI
  7364.           if (noprinter) {
  7365.               printf("Printer: (none)\n\n");
  7366.               break;
  7367.           }
  7368. #endif /* PRINTSWI */
  7369.  
  7370.           printf("Printer: %s%s\n",
  7371.  
  7372.                  printpipe ? "| " : "",
  7373.                  printername ? printername :
  7374. #ifdef OS2
  7375.                  "PRN"
  7376. #else
  7377.                  "(default)"
  7378. #endif /* OS2 */
  7379.                  );
  7380. #ifdef PRINTSWI
  7381. #ifdef BPRINT
  7382.           if (printbidi) {
  7383.               printf(" /BIDIRECTIONAL\n");
  7384.               if (pportspeed > 0)
  7385.                 printf(" /SPEED:%ld\n",pportspeed);
  7386.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7387.               printf(" /FLOW:%s\n",
  7388.                      pportflow == FLO_NONE ? "NONE" :
  7389.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7390.                      );
  7391.           } else
  7392.             printf(" /OUTPUT-ONLY\n");
  7393. #endif /* BPRINT */
  7394.           switch (printertype) {
  7395.             case PRT_NON: printf(" /NONE\n"); break;
  7396.             case PRT_FIL: printf(" /FILE\n"); break;
  7397.             case PRT_PIP: printf(" /PIPE\n"); break;
  7398.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7399.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7400.           }
  7401.           printf(" /TIMEOUT:%d\n",printtimo);
  7402.           if (printterm) {
  7403.               printf(" /END-OF-JOB-STRING:");
  7404.               shostrdef(printterm);
  7405.               printf("\n");
  7406.           } else
  7407.             printf(" /END-OF-JOB-STRING:(none)\n");
  7408.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7409.           printf(" /CHARACTER-SET: %s\n",txrinfo[prncs]->keywd);
  7410. #endif /* PRINTSWI */
  7411.           printf("\n");
  7412.           break;
  7413.       }
  7414.  
  7415.       case SHCMD: {
  7416. #ifdef DOUBLEQUOTING
  7417.           extern int dblquo;
  7418. #endif /* DOUBLEQUOTING */
  7419. #ifdef CK_AUTODL
  7420.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7421. #else
  7422.           printf(" Command autodownload: (not available)\n");
  7423. #endif /* CK_AUTODL */
  7424.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7425.           printf(" Command error-display: %d\n", cmd_err);
  7426. #ifdef CK_RECALL
  7427.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7428. #else
  7429.           printf(" Command recall-buffer not available in this version\n");
  7430. #endif /* CK_RECALL */
  7431. #ifdef CK_RECALL
  7432.           printf(" Command retry: %s\n",showoff(cm_retry));
  7433. #else
  7434.           printf(" Command retry not available in this version\n");
  7435. #endif /* CK_RECALL */
  7436.           printf(" Command interruption: %s\n", showoff(cmdint));
  7437.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7438. #ifdef DOUBLEQUOTING
  7439.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7440. #endif /* DOUBLEQUOTING */
  7441.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7442.           printf(" Command height: %d\n", cmd_rows);
  7443.           printf(" Command width:  %d\n", cmd_cols);
  7444. #ifndef IKSDONLY
  7445. #ifdef OS2
  7446.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7447. #endif /* OS2 */
  7448. #endif /* IKSDONLY */
  7449. #ifdef LOCUS
  7450.           printf(" Locus:          %s",
  7451.                  autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7452.          (locus ? "local" : "remote"));
  7453.           if (autolocus)
  7454.             printf(" (%s)", locus ? "local" : "remote");
  7455.           printf("\n");
  7456. #endif /* LOCUS */
  7457.           printf(" Hints:          %s\n", showoff(hints));
  7458.           printf(" Quiet:          %s\n", showoff(quiet));
  7459.           printf(" Maximum command length: %d\n", CMDBL);
  7460. #ifndef NOSPL
  7461.           {
  7462.               char * s;
  7463.               int k;
  7464.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7465.               printf(" Macros defined: %d\n", nmac);
  7466.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7467.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7468.               s = "(not defined)";
  7469.               k = mlook(mactab,"on_unknown_command",nmac);
  7470.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7471.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7472.           }
  7473. #endif /* NOSPL */
  7474. #ifdef UNIX
  7475. #ifndef NOJC
  7476.           printf(" Suspend: %s\n", showoff(xsuspend));
  7477. #endif /* NOJC */
  7478. #endif /* UNIX */
  7479.           printf(" Access to external commands and programs%s allowed\n",
  7480. #ifndef NOPUSH
  7481.                  !nopush ? "" :
  7482. #endif /* NOPUSH */
  7483.                   " not");
  7484.           break;
  7485.       }
  7486.  
  7487. #ifndef NOSPL
  7488.       case SHALRM:
  7489.         if (ck_alarm)
  7490.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7491.         else
  7492.           printf("(no alarm set)\n");
  7493.         break;
  7494. #endif /* NOSPL */
  7495.  
  7496. #ifndef NOMSEND
  7497.       case SHSFL: {
  7498.           extern struct filelist * filehead;
  7499.           if (!filehead) {
  7500.               printf("send-list is empty\n");
  7501.           } else {
  7502.               struct filelist * flp;
  7503.               char * s;
  7504.               flp = filehead;
  7505.               while (flp) {
  7506.                   s = flp->fl_alias;
  7507.                   if (!s) s = "(none)";
  7508.                   printf("%s, mode: %s, alias: %s\n",
  7509.                          flp->fl_name,
  7510.                          gfmode(flp->fl_mode,0),
  7511.                          s
  7512.                          );
  7513.                   flp = flp->fl_next;
  7514.               }
  7515.           }
  7516.       }
  7517.       break;
  7518. #endif /* NOMSEND */
  7519.  
  7520. #ifdef CKXXCHAR
  7521.       case SHDBL:
  7522.         shodbl();
  7523.         break;
  7524. #endif /* CKXXCHAR */
  7525.  
  7526. #ifndef NOPUSH
  7527. #ifndef NOFRILLS
  7528.       case SHEDIT:
  7529.         if (!editor[0]) {
  7530.             s = getenv("EDITOR");
  7531.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7532.         }
  7533.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7534.         if (editor[0]) {
  7535.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7536.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7537.         }
  7538.         printf("\n");
  7539.         break;
  7540.  
  7541. #ifdef BROWSER
  7542.       case SHBROWSE:
  7543.         if (!browser[0]) {
  7544.             s = getenv("BROWSER");
  7545.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7546.         }
  7547.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7548.         if (browser[0]) {
  7549.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7550.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7551.         }
  7552.         printf("\n");
  7553.         break;
  7554. #endif /* BROWSER */
  7555. #endif /*  NOFRILLS */
  7556. #endif /* NOPUSH */
  7557.  
  7558. #ifndef NOLOCAL
  7559. #ifdef CK_TAPI
  7560.       case SHTAPI:                      /* TAPI options */
  7561. #ifdef IKSD
  7562.         if (inserver) {
  7563.             printf("Sorry, command disabled.\r\n");
  7564.             return(success = 0);
  7565.         }
  7566. #endif /* IKSD */
  7567.         shotapi(0);
  7568.         break;
  7569.       case SHTAPI_L:                    /* TAPI Locations */
  7570. #ifdef IKSD
  7571.         if (inserver) {
  7572.             printf("Sorry, command disabled.\r\n");
  7573.             return(success = 0);
  7574.         }
  7575. #endif /* IKSD */
  7576.         shotapi(1);
  7577.         break;
  7578.       case SHTAPI_M:                    /* TAPI Modem */
  7579. #ifdef IKSD
  7580.         if (inserver) {
  7581.             printf("Sorry, command disabled.\r\n");
  7582.             return(success = 0);
  7583.         }
  7584. #endif /* IKSD */
  7585.         shotapi(2);
  7586.         break;
  7587.       case SHTAPI_C:                    /* TAPI Comm */
  7588. #ifdef IKSD
  7589.         if (inserver) {
  7590.             printf("Sorry, command disabled.\r\n");
  7591.             return(success = 0);
  7592.         }
  7593. #endif /* IKSD */
  7594.         shotapi(3);
  7595.         break;
  7596. #endif /* CK_TAPI */
  7597.  
  7598.       case SHTCP:                       /* SHOTCP */
  7599.         printf("\n");
  7600.         shotcp(0);
  7601.         printf("\n");
  7602.         break;
  7603.  
  7604. #ifdef TNCODE
  7605.       case SHTEL:                       /* TELNET */
  7606.         printf("\n");
  7607.         shotel(0);
  7608.         printf("\n");
  7609.         break;
  7610.  
  7611.       case SHTOPT:                      /* TELNET OPTIONS */
  7612.         printf("\n");
  7613.         shotopt(0);
  7614.         printf("\n");
  7615.         break;
  7616. #endif /* TNCODE */
  7617.  
  7618. #ifdef CK_TRIGGER
  7619.       case SHTRIG: {
  7620.           extern char * tt_trigger[], * triggerval;
  7621.           int i;
  7622.           if (!tt_trigger[0]) {
  7623.               printf(" Triggers: (none)\n");
  7624.           } else {
  7625.               printf(" Triggers:\n");
  7626.               for (i = 0; i < TRIGGERS; i++) {
  7627.                   if (!tt_trigger[i])
  7628.                     break;
  7629.                   printf("  \"%s\"\n",tt_trigger[i]);
  7630.               }
  7631.               printf(" Most recent trigger encountered: ");
  7632.               if (triggerval)
  7633.                 printf("\"%s\"\n",triggerval);
  7634.               else
  7635.                 printf("(none)\n");
  7636.           }
  7637.           break;
  7638.       }
  7639. #endif /* CK_TRIGGER */
  7640. #endif /* NOLOCAL */
  7641.  
  7642. #ifndef NOSPL
  7643.       case SHINP:
  7644.         shoinput();
  7645.         break;
  7646. #endif /* NOSPL */
  7647.  
  7648.       case SHLOG: {
  7649. #ifndef MAC
  7650. #ifdef IKSD
  7651.           if (inserver &&
  7652. #ifdef CK_LOGIN
  7653.               isguest
  7654. #else /* CK_LOGIN */
  7655.               0
  7656. #endif /* CK_LOGIN */
  7657.              ) {
  7658.             printf("Sorry, command disabled.\r\n");
  7659.             return(success = 0);
  7660.         }
  7661. #endif /* IKSD */
  7662. #ifdef DEBUG
  7663.           printf("\n Debug log:       %s", deblog ? debfil : "(none)");
  7664.       {
  7665.           extern int debtim;
  7666.           if (debtim) printf(" (timestamps)");
  7667.           printf("\n");
  7668.       }
  7669. #endif /* DEBUG */
  7670. #ifndef NOXFER
  7671.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7672. #endif /* NOXFER */
  7673. #ifndef NOLOCAL
  7674.           printf(" Session log:     %s",   seslog ? sesfil : "(none)");
  7675.       {
  7676.           extern int sessft, slogts, slognul;
  7677.           switch (sessft) {
  7678.         case XYFT_T: printf(" (text)"); break;
  7679.         case XYFT_B: printf(" (binary)"); break;
  7680.         case XYFT_D: printf(" (debug)"); break;
  7681.           }
  7682.           if (slogts) printf("(timestamped)");
  7683.           if (slognul) printf("(null-padded)");
  7684.           printf("\n");
  7685.       }
  7686.  
  7687. #endif /* NOLOCAL */
  7688. #ifdef TLOG
  7689.           printf(" Transaction log: %s (%s)\n",
  7690.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7691.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7692.                  );
  7693. #endif /* TLOG */
  7694. #ifdef CKLOGDIAL
  7695.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7696. #endif /* CKLOGDIAL */
  7697.           printf("\n");
  7698. #endif /* MAC */
  7699.           break;
  7700.       }
  7701.  
  7702. #ifndef NOSPL
  7703.       case SHOUTP:                      /* OUTPUT */
  7704.         shooutput();
  7705.         break;
  7706. #endif /* NOSPL */
  7707.  
  7708. #ifdef PATTERNS
  7709.       case SHOPAT:                      /* PATTERNS */
  7710.         shopat();
  7711.         break;
  7712. #endif /* PATTERNS */
  7713.  
  7714. #ifdef STREAMING
  7715.       case SHOSTR: {                    /* STREAMING */
  7716.           extern int streamrq, clearrq, cleared;
  7717.           extern long tfcps;
  7718.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7719.           printf("\n Reliable:     %s\n",showooa(reliable));
  7720.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7721.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7722.           if ((!local && (streamrq == SET_ON)) ||
  7723.               (streamrq == SET_AUTO && reliable))
  7724.             printf(" Streaming will be done if requested.\n");
  7725.           else if ((streamrq == SET_OFF) ||
  7726.                    ((streamrq == SET_AUTO) && !reliable))
  7727.             printf(" Streaming will not be requested and will not be done.\n");
  7728.           else if ((streamrq == SET_ON) ||
  7729.                    ((streamrq == SET_AUTO) && reliable))
  7730.             printf(
  7731. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7732.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7733.                  streamed > 0 ? "" : "no ",
  7734.                  cleared ? ", clearchannel" : "",
  7735.                  tfcps
  7736.                  );
  7737.           printf("\n");
  7738.           break;
  7739.       }
  7740. #endif /* STREAMING */
  7741.  
  7742.       case SHOIKS:
  7743.         return(sho_iks());
  7744.         break;
  7745.  
  7746. #ifdef CK_AUTHENTICATION
  7747.       case SHOAUTH:
  7748.         return(sho_auth(0));
  7749. #endif /* CK_AUTHENTICATION */
  7750.  
  7751. #ifndef NOFTP
  7752.       case SHOFTP: {
  7753. #ifdef IKSD
  7754.         if (inserver) {
  7755.             printf("Sorry, command disabled.\r\n");
  7756.             return(success = 0);
  7757.         }
  7758. #endif /* IKSD */
  7759. #ifdef SYSFTP
  7760.         {
  7761.             extern char ftpapp[], ftpopts[];
  7762.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7763.             if (ftpapp[0])
  7764.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7765.         }
  7766. #else
  7767. #ifdef NEWFTP
  7768.         shoftp(0);
  7769. #else
  7770.         printf("(No FTP client included in this version of Kermit.)\n");
  7771. #endif /* NEWFTP */
  7772. #endif /* SYSFTP */
  7773.         break;
  7774.       }
  7775. #endif /* NOFTP */
  7776.  
  7777. #ifndef NOCMDL
  7778.       case SHXOPT: {
  7779. #ifdef IKSDB
  7780.           extern int dbenabled;
  7781.           extern char * dbfile, * dbdir;
  7782. #endif /* IKSDB */
  7783. #ifdef CKWTMP
  7784.           extern int ckxwtmp;
  7785.           extern char * wtmpfile;
  7786. #endif /* CKWTMP */
  7787. #ifdef CK_LOGIN
  7788.           extern int ckxanon, xferlog, logintimo;
  7789.           extern char * xferfile;
  7790. #ifdef UNIX
  7791.           extern int ckxpriv;
  7792. #endif /* UNIX */
  7793. #ifdef CK_PERMS
  7794.           extern int ckxperms;
  7795. #endif /* CK_PERMS */
  7796. #endif /* CK_LOGIN */
  7797.           extern char * bannerfile, * helpfile;
  7798.  
  7799. #ifdef IKSD
  7800.           if (inserver &&
  7801. #ifdef CK_LOGIN
  7802.               isguest
  7803. #else /* CK_LOGIN */
  7804.               0
  7805. #endif /* CK_LOGIN */
  7806.               ) {
  7807.               printf("Sorry, command disabled.\r\n");
  7808.               return(success = 0);
  7809.           }
  7810. #endif /* IKSD */
  7811.           printf("\n");
  7812.           if (!cmdint)
  7813.             printf(" --nointerrupts\n");
  7814.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7815.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7816.           printf(" --cdmessage:%d\n",srvcdmsg);
  7817.           printf(" --helpfile:%d\n",helpfile);
  7818.           if (inserver) {
  7819.               printf("\n");
  7820.               break;
  7821.           }
  7822. #ifdef CKSYSLOG
  7823. #ifdef SYSLOGLEVEL
  7824.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7825. #else
  7826.           printf(" --syslog:%d\n",ckxsyslog);
  7827. #endif /* SYSLOGLEVEL */
  7828. #endif /* CKSYSLOG */
  7829. #ifdef CKWTMP
  7830.           printf(" --wtmplog:%d\n",ckxwtmp);
  7831.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7832. #endif /* CKWTMP */
  7833. #ifdef IKSD
  7834. #ifdef CK_LOGIN
  7835.           printf(" --anonymous:%d\n",ckxanon);
  7836. #ifdef UNIX
  7837.           printf(" --privid:%d\n",ckxpriv);
  7838. #endif /* UNIX */
  7839. #ifdef CK_PERMS
  7840.           printf(" --permission:%04o\n",ckxperms);
  7841. #endif /* CK_PERMS */
  7842.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7843.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7844.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7845.           printf(" --xferlog=%d\n",xferlog);
  7846.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7847.           printf(" --timeout=%d\n",logintimo);
  7848. #endif /* CK_LOGIN */
  7849. #ifdef IKSDB
  7850.           printf(" --database=%d\n",dbenabled);
  7851.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7852.           if (dbdir)
  7853.             printf("   (db directory=[%s])\n",dbdir);
  7854. #endif /* IKSDB */
  7855. #ifdef IKSDCONF
  7856.           printf(" IKSD conf=%s\n",iksdconf);
  7857. #endif /* IKSDCONF */
  7858. #endif /* IKSD */
  7859.           printf("\n");
  7860.           break;
  7861.       }
  7862. #endif /* NOCMDL */
  7863.  
  7864.       case SHCD: {
  7865.       extern char * myhome;
  7866.       s = getenv("CDPATH");
  7867.       if (!s) s = "(none)";
  7868.       printf("\n current directory:  %s\n", zgtdir());
  7869.       printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7870.       printf(" cd home:            %s\n", homepath());
  7871.       printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7872.       printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7873.       printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7874.       printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7875.       break;
  7876.       }
  7877. #ifndef NOCSETS
  7878.       case SHASSOC:
  7879.         (VOID) showassoc();
  7880.         break;
  7881. #endif /* NOCSETS */
  7882.  
  7883. #ifdef CKLOGDIAL
  7884.       case SHCONNX:
  7885. #ifdef NEWFTP
  7886.         if (ftpisconnected()) {
  7887.             extern char cxlogbuf[];
  7888.             dologshow(W_FTP | 1);
  7889.             if (cxlogbuf[0])
  7890.               dologshow(1);
  7891.         } else {
  7892. #endif /* NEWFTP */
  7893.             dologshow(1);
  7894. #ifdef NEWFTP
  7895.         }
  7896. #endif /* NEWFTP */
  7897.         break;
  7898. #endif /* CKLOGDIAL */
  7899.  
  7900.       case SHOPTS:
  7901.         optlines = 0;
  7902. #ifndef NOFRILLS
  7903.         (VOID) showdelopts();
  7904. #endif /* NOFRILLS */
  7905. #ifdef DOMYDIR
  7906.         (VOID) showdiropts();
  7907. #endif /* DOMYDIR */
  7908. #ifdef CKPURGE
  7909.         (VOID) showpurgopts();
  7910. #endif /* CKPURGE */
  7911.         (VOID) showtypopts();
  7912.         break;
  7913.  
  7914. #ifndef NOLOCAL
  7915.       case SHOFLO:
  7916.         (VOID) shoflow();
  7917.         break;
  7918. #endif /* NOLOCAL */
  7919.  
  7920. #ifndef NOXFER
  7921.       case SHOXFER:
  7922.         (VOID) shoxfer();
  7923.         break;
  7924. #endif /* NOXFER */
  7925.  
  7926. #ifdef CK_RECALL
  7927.       case SHHISTORY:
  7928.         (VOID) cmhistory();
  7929.         break;
  7930. #endif /* CK_RECALL */
  7931.  
  7932. #ifndef NOSEXP
  7933. #ifndef NOSPL
  7934.       case SHSEXP:
  7935.         (VOID) shosexp();
  7936.         break;
  7937. #endif /* NOSPL */
  7938. #endif /* NOSEXP */
  7939.  
  7940. #ifdef ANYSSH
  7941.       case SHOSSH:
  7942.         (VOID) shossh();
  7943.         break;
  7944. #endif /* ANYSSH */
  7945.  
  7946. #ifdef KUI
  7947.       case SHOGUI:
  7948.         (VOID) shogui();
  7949.         break;
  7950. #endif /* KUI */
  7951.  
  7952. #ifndef NOFRILLS
  7953. #ifndef NORENAME
  7954.       case SHOREN:
  7955.         (VOID) shorename();
  7956.         break;
  7957. #endif    /* NORENAME */
  7958. #endif    /* NOFRILLS */
  7959.  
  7960.       default:
  7961.         printf("\nNothing to show...\n");
  7962.         return(-2);
  7963.     }
  7964.     return(success = 1);
  7965. }
  7966.  
  7967. #ifndef NOXFER
  7968. int
  7969. shoatt() {
  7970.     printf("Attributes: %s\n", showoff(atcapr));
  7971.     if (!atcapr) return(0);
  7972.     printf(" Blocksize: %s\n", showoff(atblki));
  7973.     printf(" Date: %s\n", showoff(atdati));
  7974.     printf(" Disposition: %s\n", showoff(atdisi));
  7975.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7976.     printf(" Length: %s\n", showoff(atleni));
  7977.     printf(" Type (text/binary): %s\n", showoff(attypi));
  7978.     printf(" System ID: %s\n", showoff(atsidi));
  7979.     printf(" System Info: %s\n", showoff(atsysi));
  7980. #ifdef CK_PERMS
  7981.     printf(" Permissions In:  %s\n", showoff(atlpri));
  7982.     printf(" Permissions Out: %s\n", showoff(atlpro));
  7983. #endif /* CK_PERMS */
  7984. #ifdef STRATUS
  7985.     printf(" Format: %s\n", showoff(atfrmi));
  7986.     printf(" Creator: %s\n", showoff(atcrei));
  7987.     printf(" Account: %s\n", showoff(atacti));
  7988. #endif /* STRATUS */
  7989.     return(0);
  7990. }
  7991. #endif /* NOXFER */
  7992.  
  7993. #ifndef NOSPL
  7994. int                                     /* SHOW MACROS */
  7995. shomac(s1, s2) char *s1, *s2; {
  7996.     int x, n, pp;
  7997.     pp = 0;                             /* Parenthesis counter */
  7998.  
  7999.     debug(F110,"shomac s1",s1,0);
  8000.     debug(F110,"shomac s2",s2,0);
  8001.  
  8002. #ifdef IKSD
  8003.     if ( inserver &&
  8004. #ifdef IKSDCONF
  8005.         iksdcf
  8006. #else /* IKSDCONF */
  8007.         1
  8008. #endif /* IKSDCONF */
  8009.         ) {
  8010.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  8011.             !ckstrcmp("on_logout",s1,-1,0))
  8012.           return(0);
  8013.     }
  8014. #endif /* IKSD */
  8015.  
  8016.     if (!s1)
  8017.       return(0);
  8018.     else
  8019.       printf("%s = ",s1);               /* Print blank line and macro name */
  8020.     n = (int)strlen(s1) + 4;            /* Width of current line */
  8021.     if (!s2) s2 = "(not defined)";
  8022.  
  8023.     while ((x = *s2++)) {               /* Loop thru definition */
  8024.         if (x == '(') pp++;             /* Treat commas within parens */
  8025.         if (x == ')') pp--;             /* as ordinary text */
  8026.         if (pp < 0) pp = 0;             /* Outside parens, */
  8027.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  8028.             putchar(',');
  8029.             putchar('-');
  8030.             x = '\n';
  8031.         }
  8032.         if (inserver && (x == '\n'))    /* Send CR before LF */
  8033.           putchar(CR);
  8034.         putchar((CHAR)x);               /* Output the character */
  8035.         if (x == '\n') {                /* If it was a newline */
  8036. #ifdef UNIX
  8037. #ifdef NOSETBUF
  8038.             fflush(stdout);
  8039. #endif /* NOSETBUF */
  8040. #endif /* UNIX */
  8041.             putchar(' ');               /* Indent the next line 1 space */
  8042.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  8043.             n = 2;                      /* restart the character counter */
  8044.             slc++;                      /* and increment the line counter. */
  8045.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  8046.             putchar('-');               /* output a dash */
  8047.             if (inserver)
  8048.               putchar(CR);              /* and a carriage return */
  8049.             putchar(NL);                /* and a newline */
  8050. #ifdef UNIX
  8051. #ifdef NOSETBUF
  8052.             fflush(stdout);
  8053. #endif /* NOSETBUF */
  8054. #endif /* UNIX */
  8055.             n = 1;                      /* and restart the char counter */
  8056.             slc++;                      /* and increment the line counter */
  8057.         }
  8058.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  8059.             if (!askmore()) return(-1); /* ask if they want more. */
  8060.             n = 1;                      /* They do, start a new line */
  8061.             slc = 0;                    /* and restart line counter */
  8062.         }
  8063.     }
  8064.     if (inserver)
  8065.       putchar(CR);
  8066.     putchar(NL);                        /* End of definition */
  8067.     if (++slc > (cmd_rows - 3)) {
  8068.         if (!askmore()) return(-1);
  8069.         slc = 0;
  8070.     }
  8071.     return(0);
  8072. }
  8073. #endif /* NOSPL */
  8074. #endif /* NOSHOW */
  8075.  
  8076. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  8077.  
  8078. #ifndef NOSPL
  8079. /* Evaluate an arithmetic expression. */
  8080. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  8081.  
  8082. static int xerror = 0;
  8083. int divbyzero = 0;
  8084. static char *cp;
  8085. static CK_OFF_T tokval;
  8086. static char curtok;
  8087. static CK_OFF_T expval;
  8088.  
  8089. #define LONGBITS (8*sizeof (CK_OFF_T))
  8090. #define NUMBER 'N'
  8091. #define N_EOT 'E'
  8092.  
  8093. /*
  8094.  Replacement for strchr() and index(), neither of which seem to be universal.
  8095. */
  8096.  
  8097. static char *
  8098. #ifdef CK_ANSIC
  8099. windex(char * s, char c)
  8100. #else
  8101. windex(s,c) char *s, c;
  8102. #endif /* CK_ANSIC */
  8103. /* windex */ {
  8104.     while (*s != NUL && *s != c) s++;
  8105.     if (*s == c) return(s); else return(NULL);
  8106. }
  8107.  
  8108.  
  8109. /*
  8110.  g e t t o k
  8111.  
  8112.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  8113. */
  8114. static char
  8115. gettok() {
  8116.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  8117.  
  8118.     while (isspace(*cp))                /* Skip past leading spaces */
  8119.       cp++;
  8120.  
  8121.     debug(F110,"GETTOK",cp,0);
  8122.  
  8123.     switch (*cp) {
  8124.       case '$':                         /* ??? */
  8125.       case '+':                         /* Add */
  8126.       case '-':                         /* Subtract or Negate */
  8127.       case '@':                         /* Greatest Common Divisor */
  8128.       case '*':                         /* Multiply */
  8129.       case '/':                         /* Divide */
  8130.       case '%':                         /* Modulus */
  8131.       case '<':                         /* Left shift */
  8132.       case '>':                         /* Right shift */
  8133.       case '&':                         /* And */
  8134.       case '|':                         /* Or */
  8135.       case '#':                         /* Exclusive Or */
  8136.       case '~':                         /* Not */
  8137.       case '^':                         /* Exponent */
  8138.       case '!':                         /* Factorial */
  8139.       case '(':                         /* Parens for grouping */
  8140.       case ')': return(*cp++);          /* operator, just return it */
  8141.       case '\n':
  8142.       case '\0': return(N_EOT);         /* End of line, return that */
  8143.     }
  8144. #ifdef COMMENT
  8145. /* This is the original code, which allows only integer numbers. */
  8146.  
  8147.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  8148.         int radix = 10;                 /* Default radix */
  8149.         for (tp = tbuf; isxdigit(*cp); cp++)
  8150.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  8151.         *tp = '\0';                     /* End number */
  8152.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  8153.           case 'h':
  8154.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  8155.           case 'o':
  8156.           case 'q': radix = 8; cp++; break;
  8157.           case 't': radix = 2; cp++; break;
  8158.         }
  8159.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  8160.             int dig;
  8161.             dig = *tp - '0';            /* Convert number */
  8162.             if (dig > 10) dig -= 'a'-'0'-10;
  8163.             if (dig >= radix) {
  8164.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8165.                   printf("?Invalid digit '%c' in number\n",*tp);
  8166.                 xerror = 1;
  8167.                 return(NUMBER);
  8168.             }
  8169.             tokval = radix*tokval + dig;
  8170.         }
  8171.         return(NUMBER);
  8172.     }
  8173.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  8174.       printf("Invalid character '%c' in input\n",*cp);
  8175.     xerror = 1;
  8176.     cp++;
  8177.     return(gettok());
  8178. #else
  8179. /* This code allows non-numbers to be treated as macro names */
  8180.     {
  8181.         int i, x;
  8182.         char * s, * cp1;
  8183.         cp1 = cp;
  8184.         tp = tbuf;
  8185.         for (i = 0; i < 80; i++) {
  8186.             /* Look ahead to next break character */
  8187.             /* pretty much anything that is not in the switch() above. */
  8188.             if (isalpha(*cp) || isdigit(*cp) ||
  8189.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  8190.                 *cp == '[' || *cp == ']' ||
  8191.                 *cp == '{' || *cp == '}'
  8192.                 )
  8193.               tbuf[i] = *cp++;
  8194.             else
  8195.               break;
  8196.         }
  8197.         if (i >= 80) {
  8198.             printf("Too long - \"%s\"\n", cp1);
  8199.             xerror = 1;
  8200.             cp++;
  8201.             return(gettok());
  8202.         }
  8203.         if (xerror) return(NUMBER);
  8204.  
  8205.         tbuf[i] = NUL;
  8206.         s = tbuf;
  8207.         if (!isdigit(tbuf[0])) {
  8208.             char * s2 = NULL;
  8209.             x = mxlook(mactab,tbuf,nmac);
  8210.             debug(F111,"gettok mxlook",tbuf,x);
  8211.             if (x < 0) {
  8212.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8213.                   printf("Bad number - \"%s\"\n",tbuf);
  8214.                 xerror = 1;
  8215.                 cp++;
  8216.                 return(gettok());
  8217.             }
  8218.             s2 = mactab[x].mval;
  8219.             if (!s2) s2 = "";
  8220.             if (*s2) s = s2;
  8221.         }
  8222. #ifdef CKFLOAT
  8223.         x = isfloat(s,0);
  8224. #else
  8225.         x = chknum(s);
  8226. #endif /* CKFLOAT */
  8227.         if (x > 0) {
  8228.             tokval = ckatofs(s);
  8229.         } else {
  8230.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8231.               printf("Bad number - \"%s\"\n",tbuf);
  8232.             xerror = 1;
  8233.             cp++;
  8234.             return(gettok());
  8235.         }
  8236.         return(NUMBER);
  8237.     }
  8238. #endif /* COMMENT */
  8239. }
  8240.  
  8241. static CK_OFF_T
  8242. #ifdef CK_ANSIC
  8243. expon(CK_OFF_T x, CK_OFF_T y)
  8244. #else
  8245. expon(x,y) CK_OFF_T x,y;
  8246. #endif /* CK_ANSIC */
  8247. /* expon */ {
  8248.     CK_OFF_T result = 1;
  8249.     int sign = 1;
  8250.     if (y < 0) return(0);
  8251.     if (x < 0) {
  8252.         x = -x;
  8253.         if (y & 1) sign = -1;
  8254.     }
  8255.     while (y != 0) {
  8256.         if (y & 1) result *= x;
  8257.         y >>= 1;
  8258.         if (y != 0) x *= x;
  8259.   }
  8260.   return(result * sign);
  8261. }
  8262.  
  8263. /*
  8264.  * factor ::= simple | simple ^ factor
  8265.  *
  8266.  */
  8267. static VOID
  8268. factor() {
  8269.     CK_OFF_T oldval;
  8270.     simple();
  8271.     if (curtok == '^') {
  8272.         oldval = expval;
  8273.         curtok = gettok();
  8274.         factor();
  8275.         expval = expon(oldval,expval);
  8276.     }
  8277. }
  8278.  
  8279. /*
  8280.  * termp ::= NULL | {*,/,%,&} factor termp
  8281.  *
  8282.  */
  8283. static VOID
  8284. termp() {
  8285.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  8286.         CK_OFF_T oldval;
  8287.         char op;
  8288.         op = curtok;
  8289.         curtok = gettok();              /* skip past operator */
  8290.         oldval = expval;
  8291.         factor();
  8292.         switch(op) {
  8293.           case '*': expval = oldval * expval; break;
  8294.           case '/':
  8295.           case '%':
  8296.             if (expval == 0) {
  8297.                 if (!x_ifnum)
  8298.                   printf("?Divide by zero\n");
  8299.                 xerror = 1;
  8300.                 divbyzero = 1;
  8301.                 expval = -1;
  8302.             } else
  8303.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  8304.             break;
  8305.           case '&':
  8306.             expval = oldval & expval; break;
  8307.         }
  8308.     }
  8309. }
  8310.  
  8311. static CK_OFF_T
  8312. #ifdef CK_ANSIC
  8313. fact(CK_OFF_T x)
  8314. #else
  8315. fact(x) CK_OFF_T x;
  8316. #endif /* CK_ANSIC */
  8317. /* fact */ {                            /* factorial */
  8318.     CK_OFF_T result = 1;
  8319.     while (x > 1)
  8320.       result *= x--;
  8321.     return(result);
  8322. }
  8323.  
  8324. /*
  8325.  * term ::= factor termp
  8326.  *
  8327.  */
  8328. static VOID
  8329. term() {
  8330.     factor();
  8331.     termp();
  8332. }
  8333.  
  8334. static CK_OFF_T
  8335. #ifdef CK_ANSIC
  8336. gcd(CK_OFF_T x, CK_OFF_T y)
  8337. #else
  8338. gcd(x,y) CK_OFF_T x,y;
  8339. #endif /* CK_ANSIC */
  8340. /* gcd */ {                             /* Greatest Common Divisor */
  8341.     int nshift = 0;
  8342.     if (x < 0) x = -x;
  8343.     if (y < 0) y = -y;                  /* validate arguments */
  8344.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8345.  
  8346.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8347.         nshift++;
  8348.         x >>= 1;
  8349.         y >>= 1;
  8350.     }
  8351.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8352.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8353.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8354.         if (x < y) {                    /* force x to be larger */
  8355.             CK_OFF_T t;
  8356.             t = x;
  8357.             x = y;
  8358.             y = t;
  8359.         }
  8360.         x -= y;
  8361.     }
  8362.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8363.     else return((CK_OFF_T) 1 << nshift);    /* else gcd is 1 */
  8364. }
  8365.  
  8366. /*
  8367.  * exprp ::= NULL | {+,-,|,...} term exprp
  8368.  *
  8369.  */
  8370. static VOID
  8371. exprp() {
  8372.     while (windex("+-|<>#@",curtok) != NULL) {
  8373.         CK_OFF_T oldval;
  8374.         char op;
  8375.         op = curtok;
  8376.         curtok = gettok();              /* skip past operator */
  8377.         oldval = expval;
  8378.         term();
  8379.         switch(op) {
  8380.           case '+' : expval = oldval + expval; break;
  8381.           case '-' : expval = oldval - expval; break;
  8382.           case '|' : expval = oldval | expval; break;
  8383.           case '#' : expval = oldval ^ expval; break;
  8384.           case '@' : expval = gcd(oldval,expval); break;
  8385.           case '<' : expval = oldval << expval; break;
  8386.           case '>' : expval = oldval >> expval; break;
  8387.         }
  8388.     }
  8389. }
  8390.  
  8391. /*
  8392.  * expr ::= term exprp
  8393.  *
  8394.  */
  8395. static VOID
  8396. expr() {
  8397.     term();
  8398.     exprp();
  8399. }
  8400.  
  8401. static CK_OFF_T
  8402. xparse() {
  8403.     curtok = gettok();
  8404.     expr();
  8405. #ifdef COMMENT
  8406.     if (curtok == '$') {
  8407.         curtok = gettok();
  8408.         if (curtok != NUMBER) {
  8409.             if (cmdlvl == 0 && !x_ifnum)
  8410.               printf("?Illegal radix\n");
  8411.             xerror = 1;
  8412.             return(0);
  8413.         }
  8414.         curtok = gettok();
  8415.     }
  8416. #endif /* COMMENT */
  8417.     if (curtok != N_EOT) {
  8418.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8419.           printf("?Extra characters after expression\n");
  8420.         xerror = 1;
  8421.     }
  8422.     return(expval);
  8423. }
  8424.  
  8425. char *                                  /* Silent front end for evala() */
  8426. evalx(s) char *s; {
  8427.     char * p;
  8428.     int t;
  8429.     t = x_ifnum;
  8430.     x_ifnum = 1;
  8431.     p = evala(s);
  8432.     x_ifnum = t;
  8433.     return(p);
  8434. }
  8435.  
  8436. char *
  8437. evala(s) char *s; {
  8438.     CK_OFF_T v;                /* Numeric value */
  8439.     if (!s) return("");
  8440.     xerror = 0;                         /* Start out with no error */
  8441.     divbyzero = 0;
  8442.     cp = s;                             /* Make the argument global */
  8443.     v = xparse();                       /* Parse the string */
  8444.     return(xerror ? "" : ckfstoa(v));    /* Return empty string on error */
  8445. }
  8446.  
  8447. /*
  8448.  * simplest ::= NUMBER | ( expr )
  8449.  *
  8450.  */
  8451. static VOID
  8452. simplest() {
  8453.     char * p;
  8454.     p = cp;
  8455.     if (curtok == NUMBER)
  8456.       expval = tokval;
  8457.     else if (curtok == '(') {
  8458.         curtok = gettok();              /* skip over paren */
  8459.         expr();
  8460.         if (curtok != ')') {
  8461.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8462.               printf("?Missing right parenthesis\n");
  8463.             xerror = 1;
  8464.         }
  8465.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8466.  
  8467.     } else {
  8468.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8469.           printf("?Operator unexpected\n");
  8470.         xerror = 1;
  8471.     }
  8472.     curtok = gettok();
  8473. }
  8474.  
  8475. /*
  8476.  * simpler ::= simplest | simplest !
  8477.  *
  8478.  */
  8479. static VOID
  8480. simpler() {
  8481.     simplest();
  8482.     if (curtok == '!') {
  8483.         curtok = gettok();
  8484.         expval = fact(expval);
  8485.     }
  8486. }
  8487.  
  8488. /*
  8489.  * simple ::= {-,~,!} simpler | simpler
  8490.  *
  8491.  */
  8492.  
  8493. static VOID
  8494. simple() {
  8495.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8496.         int op = curtok;
  8497.         curtok = gettok();              /* skip over - sign */
  8498.         simpler();                      /* parse the factor again */
  8499.         if (op != '+')
  8500.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8501.     } else simpler();
  8502. }
  8503.  
  8504. /*  D C L A R R A Y  --  Declare an array  */
  8505. /*
  8506.   Call with:
  8507.    char a = single character designator for the array, e.g. "a".
  8508.    int  n = size of array.  -1 means to undeclare the array.
  8509.   Returns:
  8510.    0 or greater on success, having created the requested array with
  8511.      with n+1 elements, 0..n.  If an array of the same name existed
  8512.      previously, it is destroyed.  The new array has all its elements
  8513.      initialized to NULL pointers.  When an array is successfully created,
  8514.      the return value is its index (0 = 'a', 1 = 'b', and so on.)
  8515.   -1 on failure (because 'a' out of range or malloc failure).
  8516. */
  8517. int
  8518. #ifdef CK_ANSIC
  8519. dclarray(char a, int n)
  8520. #else
  8521. dclarray(a,n) char a; int n;
  8522. #endif /* CK_ANSIC */
  8523. /* dclarray */ {
  8524.     char c, **p; int i, n2, rc;
  8525.  
  8526.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8527.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8528.       return(-1);
  8529.  
  8530.     if (n < 0)                          /* Check arg */
  8531.       return(-1);
  8532.     if (n+1 < 0)                        /* MAXINT+1 wraps around */
  8533.       return(-1);
  8534.  
  8535.     c = a;
  8536.     a -= ARRAYBASE;                     /* Convert name to number */
  8537.     rc = a;                /* Array index will be return code */
  8538.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8539.         if (a_link[a] > -1) {           /* Is it a link? */
  8540.             if (n == 0) {               /* If we're just deleting it */
  8541.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8542.                 a_dim[a] = 0;
  8543.                 a_link[a] = -1;
  8544.                 return(0);
  8545.             }                           /* Not deleting */
  8546.             a = a_link[a];              /* Switch to linked-to array */
  8547.         }
  8548.         n2 = a_dim[a];                  /* Real array */
  8549.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8550.             if (p[i]) {
  8551.                 free(p[i]);
  8552.                 p[i] = NULL;
  8553.             }
  8554.         }
  8555.         free((char *)a_ptr[a]);         /* Then the element list */
  8556.         if (n == 0) {                   /* If undeclaring this array... */
  8557.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8558.                 if (i != a && a_link[i] == a) {     /* Find them */
  8559.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8560.                     a_dim[i] = 0;
  8561.                     a_link[i] = -1;
  8562.                 }
  8563.             }
  8564.         }
  8565.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8566.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8567.         a_link[a] = -1;                 /* Unset link word */
  8568.     }
  8569.     if (n < 0)                /* If only undeclaring, */
  8570.       return(0);            /*  we're done. */
  8571.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8572.     if (p == NULL) return(-1);          /* Check */
  8573.     a_ptr[a] = p;                       /* Save pointer to member list */
  8574.     a_dim[a] = n;                       /* Save dimension */
  8575.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8576.       p[i] = NULL;
  8577.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8578.         if (i != a && a_link[i] == a) { /* Find and update them */
  8579.             a_ptr[i] = p;
  8580.             a_dim[i] = n;
  8581.         }
  8582.     }
  8583.     return(rc);
  8584. }
  8585.  
  8586. /*  X A R R A Y  -- Convert array name to array index  */
  8587.  
  8588. int
  8589. xarray(s) char * s; {
  8590.     char buf[8];
  8591.     int x;
  8592.     char c;
  8593.  
  8594.     if (!s) s = "";
  8595.     debug(F110,"xarray",s,0);
  8596.     if (!*s)
  8597.       return(-1);
  8598.     x = strlen(s);
  8599.  
  8600.     buf[0] = NUL;
  8601.     buf[1] = NUL;
  8602.     buf[2] = s[0];
  8603.     buf[3] = (x > 0) ? s[1] : NUL;
  8604.     buf[4] = (x > 1) ? s[2] : NUL;
  8605.     buf[5] = (x > 2) ? s[3] : NUL;
  8606.     buf[6] = NUL;
  8607.     debug(F110,"xarray buf[3]",&buf[3],0);
  8608.     s = buf+2;
  8609.     if (*s == '&') {
  8610.         buf[1] = CMDQ;
  8611.         s--;
  8612.     } else if (*s != CMDQ) {
  8613.         buf[0] = CMDQ;
  8614.         buf[1] = '&';
  8615.         s = buf;
  8616.     }
  8617.     debug(F110,"xarray s",s,0);
  8618.     c = *(s+2);
  8619.     if (isupper(c))
  8620.       c = tolower(c);
  8621.     if (c == '@')
  8622.       c = 96;
  8623.     x = (int)c - ARRAYBASE;
  8624.     if (*(s+3) == '[')
  8625.       *(s+3) = NUL;
  8626.     if (x < 0) {
  8627.     return(-1);
  8628.     }
  8629.     if (x > ('z' - ARRAYBASE)) {
  8630.     debug(F101,"xarray x out of range","",x);
  8631.     return(-1);
  8632.     }
  8633.     if (*(s+3)) {
  8634.     debug(F110,"xarray syntax",s,0);
  8635.     return(-1);
  8636.     }
  8637.     return(x);
  8638. }
  8639.  
  8640. /*
  8641.   boundspair() -- parses blah[n:m]
  8642.  
  8643.   For use with array segment specifiers and compact substring notation.
  8644.   Ignores the "blah" part, gets the values of n and m, which can be
  8645.   numbers, variables, or arithmetic expressions; anything that resolves
  8646.   to a number.
  8647.  
  8648.   Call with:
  8649.    s    - string to parse
  8650.    sep  - array of permissible bounds separator chars
  8651.    lo   - pointer to low-bound result (or -1)
  8652.    hi   - pointer to hi-bound result (or -1)
  8653.    zz   - pointer to separator char that was encountered (or NUL)
  8654.   Returns:
  8655.    -1 on failure
  8656.     0 on success
  8657. */      
  8658.  
  8659. int
  8660. #ifdef CK_ANSIC
  8661. boundspair(char *s, char *sep, int *lo, int *hi, char *zz)
  8662. #else
  8663. boundspair(s,sep,lo,hi,zz) char *s, *sep, *zz; int *lo, *hi;
  8664. #endif /* CK_ANSIC */
  8665. {
  8666.     int i, x, y, range[2], bc = 0;
  8667.     char c = NUL, *s2 = NULL, buf[256], *p, *q, *r, *e[2], *tmp = NULL;
  8668.  
  8669.     debug(F110,"boundspair s",s,0);
  8670.     debug(F110,"boundspair sep",sep,0);
  8671.  
  8672.     *lo = -1;                           /* Default bounds */
  8673.     *hi = -1;
  8674.     *zz = 0;                /* Default bounds separator */
  8675.  
  8676.     range[0] = -1;                      /* It's OK -- get contents */
  8677.     range[1] = -1;                      /* of subscript brackets */
  8678.     if (!s) s = "";
  8679.     if (!*s)
  8680.       return(-1);
  8681.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8682.     p = tmp;
  8683.     q = NULL;
  8684.     r = NULL;
  8685.     for (p = s; *p; p++) {        /* Get the two elements */
  8686.     if (*p == '[') {
  8687.         bc++;
  8688.         if (bc == 1 && !q) q = p+1;
  8689.     } else if (*p == ']') {
  8690.         bc--;
  8691.         if (bc == 0 && q) *p = NUL;
  8692.     } else if (bc == 1) {        /* Check for separator */
  8693.         s2 = ckstrchr(sep,*p);
  8694.         if (s2) {
  8695.         debug(F000,"boundspair *s2","",*s2);
  8696.         if (c) {        
  8697.             debug(F000,"boundspair","Too many separators",*s2);
  8698.             makestr(&tmp,NULL);
  8699.             return(-1);
  8700.         }
  8701.         c = *s2;
  8702.         *p = NUL;
  8703.         r = p+1;
  8704.         }
  8705.     }
  8706.     }
  8707.     if (bc == 0 && !q) {
  8708.     /* This allows such constructions as "show array a" */
  8709.     debug(F110,"boundspair","no brackets",0);
  8710.     makestr(&tmp,NULL);
  8711.     return(0);
  8712.     }
  8713.     if (bc != 0 || !q) {
  8714.     debug(F110,"boundspair","unbalanced or missing brackets",0);
  8715.     makestr(&tmp,NULL);
  8716.     return(-1);
  8717.     }
  8718.     if (!*q) q = "-1";
  8719.     if (!r) r = "-1";
  8720.  
  8721.     e[0] = q;
  8722.     e[1] = r;
  8723.  
  8724.     debug(F000,"boundspair c","",c);
  8725.     debug(F110,"boundspair q",q,0);
  8726.     debug(F110,"boundspair r",r,0);
  8727.  
  8728.     for (i = 0; i < 2 && e[i]; i++) {
  8729.     y = 255;            /* Expand variables, etc. */
  8730.     s = buf;
  8731.     zzstring(e[i],&s,&y);
  8732.     s = evalx(buf);            /* Evaluate it arithmetically */
  8733.     if (s) if (*s)
  8734.       ckstrncpy(buf,s,256);
  8735.     if (!chknum(buf)) {        /* Did we get a number? */
  8736.         debug(F110,"boundspair element not numeric",buf,0);
  8737.         makestr(&tmp,NULL);        /* No, fail. */
  8738.         return(-1);
  8739.     }
  8740.     range[i] = atoi(buf);
  8741.     }
  8742.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8743.     *lo = range[0];                     /* Return what we got */
  8744.     *hi = range[1];
  8745.     *zz = c;
  8746.     debug(F101,"boundspair lo","",*lo);
  8747.     debug(F101,"boundspair hi","",*hi);
  8748.     return(0);
  8749. }
  8750.  
  8751. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8752.  
  8753. /*
  8754.   Call with s = array reference, plus two pointers to ints.
  8755.   Returns -1 on error, or array index, with the two ints set as follows:
  8756.    \&a[]     -1, -1
  8757.    \&a[3]     3, -1
  8758.    \&a[3:17]  3, 17
  8759.   The array need not be declared -- this routine is just for parsing.
  8760. */
  8761. int
  8762. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8763.     int i, x, y, range[2];
  8764.     char zz, buf[256], * p, * q;
  8765.     char * tmp = NULL;
  8766.  
  8767.     *lo = -1;                           /* Default bounds */
  8768.     *hi = -1;
  8769.  
  8770.     if (!s) s = "";                     /* Defense de null args */
  8771.     if (!*s)
  8772.       return(-1);
  8773.  
  8774.     x = xarray(s);                      /* Check basic structure */
  8775.     debug(F111,"arraybounds xarray",s,x);
  8776.     if (x < 0)                          /* Not OK, fail. */
  8777.       return(-1);
  8778.     y = boundspair(s,":",lo,hi,&zz);
  8779.     debug(F111,"arraybounds boundspair",s,y);
  8780.     debug(F101,"arraybounds lo","",*lo);
  8781.     debug(F101,"arraybounds hi","",*hi);
  8782.     if (y < 0)                /* Get bounds */
  8783.       return(-1);
  8784.     return(x);
  8785. }
  8786.  
  8787. /*  A R R A Y N A M  --  Parse an array name  */
  8788.  
  8789. /*
  8790.   Call with pointer to string that starts with the array reference.
  8791.   String may begin with either \& or just &.
  8792.   On success,
  8793.     Returns letter ID (always lowercase) in argument c,
  8794.       which can also be accent grave (` = 96; '@' is converted to grave);
  8795.     Dimension or subscript in argument n;
  8796.     IMPORTANT: These arguments must be provided by the caller as addresses
  8797.     of ints (not chars), for example:
  8798.       char *s; int x, y;
  8799.       arraynam(s,&x,&y);
  8800.   On failure, returns a negative number, with args n and c set to zero.
  8801. */
  8802. int
  8803. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8804.     int i, y, pp, len;
  8805.     char x;
  8806.     char *s, *p, *sx, *vnp;
  8807.     /* On stack to allow for recursive calls... */
  8808.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8809.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8810.     char sxbuf[16];                     /* Evaluated subscript */
  8811.  
  8812.     *c = *n = 0;                        /* Initialize return values */
  8813.     len = strlen(ss);
  8814.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8815.         if (ss[i] == '[') {
  8816.             pp++;
  8817.         } else if (ss[i] == ']') {
  8818.             if (--pp == 0)
  8819.               break;
  8820.         }
  8821.     }
  8822.     if (i > ARRAYREFLEN) {
  8823.         printf("?Array reference too long - %s\n",ss);
  8824.         return(-9);
  8825.     }
  8826.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8827.     vnp = vnbuf;
  8828.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8829.     if (*vnp != '&') {
  8830.         printf("?Not an array - %s\n",vnbuf);
  8831.         return(-9);
  8832.     }
  8833.     x = *(vnp + 1);                     /* Fold case of array name */
  8834.  
  8835.     /* We don't use isupper & tolower here on purpose because these */
  8836.     /* would produce undesired effects with accented letters. */
  8837.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8838.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8839.         if (msgflg) {
  8840.             printf("?Invalid format for array name - %s\n",vnbuf);
  8841.             return(-9);
  8842.         } else
  8843.           return(-2);
  8844.     }
  8845.     *c = x;                             /* Return the array name */
  8846.     s = vnp+3;                          /* Get dimension */
  8847.     p = ssbuf;
  8848.     pp = 1;                             /* Bracket counter */
  8849.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8850.         if (*s == '[') pp++;
  8851.         if (*s == ']' && --pp == 0) break;
  8852.         *p++ = *s++;
  8853.     }
  8854.     if (*s != ']') {
  8855.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8856.         return(-9);
  8857.     }
  8858.     p--;                                /* Trim whitespace from end */
  8859.     while (*p == SP || *p == HT)
  8860.       p--;
  8861.     p++;
  8862.     *p = NUL;                           /* Terminate subscript with null */
  8863.     p = ssbuf;                          /* Point to beginning of subscript */
  8864.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8865.       p++;
  8866.     sx = sxbuf;                         /* Where to put expanded subscript */
  8867.     y = 16;
  8868.     {
  8869.     /* Even if VARIABLE-EVALUATION SIMPLE use RECURSIVE for subscripts */
  8870.     /* NOTE: This is vulnerable to SIGINT and whatnot... */
  8871.     int tmp = vareval;        /* Save VARIABLE-EVALUATION setting */
  8872.     vareval = 1;            /* Force it to RECURSIVE */
  8873.     zzstring(p,&sx,&y);        /* Convert variables, etc. */
  8874.     vareval = tmp;            /* Restore VARIABLE-EVALUATION */
  8875.     }
  8876.     sx = sxbuf;
  8877.     while (*sx == SP) sx++;
  8878.     /* debug(F110,"arraynam sx","",sx); */
  8879.     if (!*sx) {                         /* Empty brackets... */
  8880.         *n = -17;                       /* (Secret code :-) */
  8881.         return(-2);
  8882.     }
  8883.     p = evala(sx);                      /* Run it thru \fneval()... */
  8884.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8885.  
  8886.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8887.         if (msgflg) {
  8888.             printf("?Array dimension or subscript missing or not numeric\n");
  8889.             return(-9);
  8890.         } else
  8891.           return(-2);
  8892.     }
  8893.     if ((y = atoi(sxbuf)) < 0) {
  8894.         if (cmflgs == 0) printf("\n");
  8895.         if (msgflg) {
  8896.             printf("?Array dimension or subscript not positive or zero\n");
  8897.             return(-9);
  8898.         } else
  8899.           return(-2);
  8900.     }
  8901.     *n = y;                             /* Return the subscript or dimension */
  8902.     return(0);
  8903. }
  8904.  
  8905. /* chkarray returns 0 or greater if array exists, negative otherwise */
  8906.  
  8907. int
  8908. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8909.     int x;                              /* and if subscript is in range */
  8910.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8911.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8912. #ifdef COMMENT
  8913.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8914.       return(0);
  8915. #endif /* COMMENT */
  8916.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8917.       return(-2);
  8918.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8919.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8920.     return(a_dim[x]);                   /* All ok, return dimension */
  8921. }
  8922.  
  8923. #ifdef COMMENT                          /* This isn't used. */
  8924. char *
  8925. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8926.     int x; char **p;                    /* (possibly NULL) */
  8927.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8928.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8929.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8930.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8931.       return(NULL);
  8932.     if (i > a_dim[x])                   /* Subscript out of range. */
  8933.       return(NULL);
  8934.     return(p[i]);                       /* All ok, return pointer to value. */
  8935. }
  8936. #endif /* COMMENT */
  8937.  
  8938. /*
  8939.   pusharray() is called when an array name is included in a LOCAL statement.
  8940.   It moves the pointers from the global definition to the stack, and removes
  8941.   the global definition.  Later, if the same array is declared in the local
  8942.   context, it occupies the global definition in the normal way.  But when
  8943.   popclvl() is called, it replaces the global definition with the one saved
  8944.   here.  The "secret code" is used to indicate to popclv() that it should
  8945.   remove the global array when popping through this level -- otherwise if a
  8946.   local array were declared that had no counterpart at any higher level, it
  8947.   would never be deleted.  This allows Algol-like inheritance to work both
  8948.   on the way down and on the way back up.
  8949. */
  8950. int
  8951. pusharray(x,z) int x, z; {
  8952.     int y;
  8953.     debug(F000,"pusharray x","",x);
  8954.     debug(F101,"pusharray z","",z);
  8955.     y = chkarray(x,z);
  8956.     debug(F101,"pusharray y","",y);
  8957.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8958.     if (x < 0 || x > 27)
  8959.       return(-1);
  8960.     if (y < 0) {
  8961.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8962.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8963.     } else {
  8964.         aa_ptr[cmdlvl][x] = a_ptr[x];
  8965.         aa_dim[cmdlvl][x] = y;
  8966.     }
  8967.     a_ptr[x] = (char **) NULL;
  8968.     a_dim[x] = 0;
  8969.     return(0);
  8970. }
  8971.  
  8972. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  8973. /*
  8974.  Call with:
  8975.    s  = pointer to candidate variable name or array reference.
  8976.    *c = address of integer in which to return variable ID.
  8977.    *i = address of integer in which to return array subscript.
  8978.  Returns:
  8979.    -2:  syntax error in variable name or array reference.
  8980.     1:  successful parse of a simple variable, with ID in c.
  8981.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  8982. */
  8983. int
  8984. parsevar(s,c,i) char *s; int *c, *i; {
  8985.     char *p;
  8986.     int x,y,z;
  8987.  
  8988.     p = s;
  8989.     if (*s == CMDQ) s++;                /* Point after backslash */
  8990.  
  8991.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  8992.         printf("?Not a variable name - %s\n",p);
  8993.         return(-9);
  8994.     }
  8995.     if ((int)strlen(s) < 2) {
  8996.         printf("?Incomplete variable name - %s\n",p);
  8997.         return(-9);
  8998.     }
  8999.     if (*s == '%' && *(s+2) != '\0') {
  9000.         printf("?Only one character after '%%' in variable name, please\n");
  9001.         return(-9);
  9002.     }
  9003.     if (*s == '&' && *(s+2) != '[') {
  9004.         printf("?Array subscript expected - %s\n",p);
  9005.         return(-9);
  9006.     }
  9007.     if (*s == '%') {                    /* Simple variable. */
  9008.         y = *(s+1);                     /* Get variable ID letter/char */
  9009.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  9010.         *c = y;                         /* Set the return values. */
  9011.         *i = -1;                        /* No array subscript. */
  9012.         return(1);                      /* Return 1 = simple variable */
  9013.     }
  9014.     if (*s == '&') {                    /* Array reference. */
  9015.         y = arraynam(s,&x,&z);          /* Go parse it. */
  9016.         debug(F101,"parsevar arraynam","",y);
  9017.         if ((y) < 0) {
  9018.             if (y == -2)
  9019.               return(pusharray(x,z));
  9020.             if (y != -9)
  9021.               printf("?Invalid array reference - %s\n",p);
  9022.             return(-9);
  9023.         }
  9024.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  9025.             printf("?Array not declared or subscript out of range\n");
  9026.             return(-9);
  9027.         }
  9028.         *c = x;                         /* Return array letter */
  9029.         *i = z;                         /* and subscript. */
  9030.         return(2);
  9031.     }
  9032.     return(-2);                         /* None of the above. */
  9033. }
  9034.  
  9035.  
  9036. #define VALN 32
  9037.  
  9038. /* Get the numeric value of a variable */
  9039. /*
  9040.   Call with pointer to variable name, pointer to int for return value.
  9041.   Returns:
  9042.     0 on success with second arg containing the value.
  9043.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  9044. */
  9045. int
  9046. varval(s,v) char *s; CK_OFF_T *v; {
  9047.     char valbuf[VALN+1];                /* s is pointer to variable name */
  9048.     char name[256];
  9049.     char *p;
  9050.     int y;
  9051.  
  9052.     if (*s != CMDQ) {                   /* Handle macro names too */
  9053.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  9054.         s = name;
  9055.     }
  9056.     p = valbuf;                         /* Expand variable into valbuf. */
  9057.     y = VALN;
  9058.     if (zzstring(s,&p,&y) < 0) return(-1);
  9059.     p = valbuf;                         /* Make sure value is numeric  */
  9060.     if (!*p) {                          /* Be nice -- let an undefined */
  9061.         valbuf[0] = '0';                /* variable be treated as 0.   */
  9062.         valbuf[1] = NUL;
  9063.     }
  9064.     if (chknum(p)) {                    /* Convert numeric string to int */
  9065.         *v = ckatofs(p);        /* OK */
  9066.     } else {                            /* Not OK */
  9067.         p = evala(p);                   /* Maybe it's an expression */
  9068.         if (!chknum(p))                 /* Did it evaluate? */
  9069.           return(-1);                   /* No, failure. */
  9070.         else                            /* Yes, */
  9071.           *v = ckatofs(p);        /* success */
  9072.     }
  9073.     return(0);
  9074. }
  9075.  
  9076. /* Increment or decrement a variable */
  9077. /* Returns -1 on failure, 0 on success */
  9078.  
  9079. int
  9080. incvar(s,x,z) char *s; CK_OFF_T x; int z; {  /* Increment a numeric variable */
  9081.     CK_OFF_T n;                /* s is pointer to variable name */
  9082.                                         /* x is amount to increment by */
  9083.                                         /* z != 0 means add */
  9084.                                         /* z = 0 means subtract */
  9085.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  9086.       return(-1);
  9087.     if (z)                              /* Increment it by the given amount */
  9088.       n += x;
  9089.     else                                /* or decrement as requested. */
  9090.       n -= x;
  9091.     addmac(s,ckfstoa(n));        /* Replace old variable */
  9092.     return(0);
  9093. }
  9094.  
  9095. /* D O D O  --  Do a macro */
  9096.  
  9097. /*
  9098.   Call with x = macro table index, s = pointer to arguments.
  9099.   Returns 0 on failure, 1 on success.
  9100. */
  9101.  
  9102. int
  9103. dodo(x,s,flags) int x; char *s; int flags; {
  9104.     int y;
  9105.     extern int tra_asg, tra_cmd; int tra_tmp;
  9106. #ifndef NOLOCAL
  9107. #ifdef OS2
  9108.     extern int term_io;
  9109.     int term_io_sav = term_io;
  9110. #endif /* OS2 */
  9111. #endif /* NOLOCAL */
  9112.  
  9113.     if (x < 0)                          /* It can happen! */
  9114.       return(-1);
  9115.  
  9116.     tra_tmp = tra_asg;
  9117.  
  9118.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  9119.         debug(F101,"dodo maclvl too deep","",maclvl);
  9120.         --maclvl;
  9121.         printf("Macros nested too deeply\n");
  9122.         return(0);
  9123.     }
  9124.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  9125.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  9126.  
  9127. #ifdef COMMENT
  9128.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  9129. #endif /* COMMENT */
  9130.  
  9131.     cmdlvl++;                           /* Entering a new command level */
  9132.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  9133.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  9134.         cmdlvl--;
  9135.         printf("?TAKE files and DO commands nested too deeply\n");
  9136.         return(0);
  9137.     }
  9138. #ifdef DEBUG
  9139.     if (deblog) {
  9140.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  9141.         debug(F010,"CMD ->",s,0);
  9142.     }
  9143. #endif /* DEBUG */
  9144.  
  9145. #ifdef VMS
  9146.     conres();                           /* So Ctrl-C, etc, will work. */
  9147. #endif /* VMS */
  9148. #ifndef NOLOCAL
  9149. #ifdef OS2
  9150.     term_io = 0;                        /* Disable terminal emulator I/O */
  9151. #endif /* OS2 */
  9152. #endif /* NOLOCAL */
  9153.     ifcmd[cmdlvl] = 0;
  9154.     iftest[cmdlvl] = 0;
  9155.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  9156.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  9157.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  9158.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  9159.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  9160.     xquiet[cmdlvl] = quiet;
  9161.     xvarev[cmdlvl] = vareval;
  9162.     xcmdsrc = CMD_MD;
  9163.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  9164.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  9165.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  9166.  
  9167.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  9168.  
  9169.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  9170.         free(mrval[maclvl]);
  9171.         mrval[maclvl] = NULL;
  9172.     }
  9173.  
  9174.     /* Clear old %0..%9 arguments */
  9175.  
  9176.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  9177.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  9178.     varnam[0] = '%';
  9179.     varnam[2] = '\0';
  9180.     tra_asg = 0;
  9181.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  9182.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  9183.             varnam[1] = (char) (y + '0'); /* we have to... */
  9184.             delmac(varnam,0);
  9185.         }
  9186.     }
  9187.     tra_asg = tra_tmp;
  9188.  
  9189. /* Assign the new args one word per arg, allowing braces to group words */
  9190.  
  9191.     xwords(s,MAXARGLIST,NULL,0);
  9192.  
  9193. #ifndef NOLOCAL
  9194. #ifdef OS2
  9195.     term_io = term_io_sav;
  9196. #endif /* OS2 */
  9197. #endif /* NOLOCAL */
  9198.     if (tra_cmd)
  9199.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  9200.     return(1);
  9201. }
  9202.  
  9203. /* Insert "literal" quote around each comma-separated command to prevent */
  9204. /* its premature expansion.  Only do this if object command is surrounded */
  9205. /* by braces. */
  9206.  
  9207. static char* flit = "\\flit(";
  9208.  
  9209. int
  9210. litcmd(src,dest,n) char **src, **dest; int n; {
  9211.     int bc = 0, pp = 0;
  9212.     char c, *s, *lp, *ss;
  9213.  
  9214.     s = *src;
  9215.     lp = *dest;
  9216.  
  9217.     debug(F010,"litcmd",s,0);
  9218.  
  9219.     while (*s == SP) s++;               /* Strip extra leading spaces */
  9220.  
  9221.     if (*s == '{') {                    /* Starts with brace */
  9222.         pp = 0;                         /* Paren counter */
  9223.         bc = 1;                         /* Count leading brace */
  9224.         *lp++ = *s++;                   /* Copy it */
  9225.         if (--n < 1) return(-1);        /* Check space */
  9226.         while (*s == SP) s++;           /* Strip interior leading spaces */
  9227.         ss = flit;                      /* Point to "\flit(" */
  9228.         while ((*lp++ = *ss++))         /* Copy it */
  9229.           if (--n < 1)                  /* and check space */
  9230.             return(-1);
  9231.         lp--;                           /* Back up over null */
  9232.  
  9233.         while (*s) {                    /* Go thru rest of text */
  9234.             c = *s;
  9235.             if (c == '{') bc++;         /* Count brackets */
  9236.             if (c == '(') pp++;         /* and parens */
  9237.             if (c == ')') {             /* Right parenthesis. */
  9238.                 pp--;                   /* Count it. */
  9239.                 if (pp < 0) {           /* An unbalanced right paren... */
  9240. #ifdef COMMENT
  9241. /*
  9242.   The problem here is that "\{" appears to be a quoted brace and therefore
  9243.   isn't counted; then the "}" matches an earlier opening brace, causing
  9244.   (e.g.) truncation of macros by getncm().
  9245. */
  9246.                     if (n < 5)          /* Out of space in dest buffer? */
  9247.                       return(-1);       /* If so, give up. */
  9248.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9249.                     *lp++ = '}';        /* premature termination of */
  9250.                     *lp++ = '4';        /* \flit(...) */
  9251.                     *lp++ = '1';
  9252.                     *lp++ = '}';
  9253.                     n -= 5;
  9254. #else
  9255. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  9256.                     if (n < 4)          /* Out of space in dest buffer? */
  9257.                       return(-1);       /* If so, give up. */
  9258.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9259.                     *lp++ = '0';        /* premature termination of */
  9260.                     *lp++ = '4';        /* \flit(...) */
  9261.                     *lp++ = '1';
  9262.                     n -= 4;
  9263. #endif /* COMMENT */
  9264.                     pp++;               /* Uncount it. */
  9265.                     s++;
  9266.                     continue;
  9267.                 }
  9268.             }
  9269.             if (c == '}') {             /* Closing brace. */
  9270.                 if (--bc == 0) {        /* Final one? */
  9271.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  9272.                     if (--n < 1) return(-1);
  9273.                     *lp++ = c;
  9274.                     if (--n < 1) return(-1);
  9275.                     s++;
  9276.                     break;
  9277.                 }
  9278.             }
  9279.             *lp++ = c;                  /* General case */
  9280.             if (--n < 1) return(-1);
  9281.             s++;
  9282.         }
  9283.         *lp = NUL;
  9284.     } else {                            /* No brackets around, */
  9285.         while ((*lp++ = *s++))          /* just copy. */
  9286.           if (--n < 1)
  9287.             return(-1);
  9288.         lp--;
  9289.     }
  9290.     *src = s;                           /* Return updated source */
  9291.     *dest = lp;                         /* and destination pointers */
  9292.     if (bc)                             /* Fail if braces unbalanced */
  9293.       return(-1);
  9294.     else                                /* Otherwise succeed. */
  9295.       return(0);
  9296. }
  9297. #endif /* NOSPL */
  9298.  
  9299. /* Functions moved here from ckuusr.c to even out the module sizes... */
  9300.  
  9301. /*
  9302.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  9303.   Pointers to each word go into the array list[].
  9304.   max is the maximum number of words (pointers).
  9305.   If list is NULL, then they are added to the macro table.
  9306.   flag = 0 means the last field is to be one word, like all the other fields,
  9307.          so anything after it is discarded.
  9308.   flag = 1 means the last field extends to the end of the string, even if
  9309.          there are lots of words left, so the last field contains the
  9310.          remainder of the string.
  9311. */
  9312. VOID
  9313. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  9314.     char *p;
  9315.     int b, i, k, q, y, z;
  9316. #ifndef NOSPL
  9317.     int macro;
  9318.     macro = (list == NULL);
  9319.     debug(F010,"xwords",s,0);
  9320. #endif /* NOSPL */
  9321.  
  9322. #ifdef XWORDSDEBUG
  9323.     printf("XWORDS string=%s\n",s);
  9324.     printf("XWORDS max=%d\n",max);
  9325. #endif /* XWORDSDEBUG */
  9326.     p = s;                              /* Pointer to beginning of string */
  9327.     q = 0;                              /* Flag for doublequote removal */
  9328.     b = 0;                              /* Flag for outer brace removal */
  9329.     k = 0;                              /* Flag for in-word */
  9330.     y = 0;                              /* Brace nesting level */
  9331.     z = 0;                              /* "Word" counter, 0 thru max */
  9332.  
  9333.     if (list)
  9334.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  9335.         list[i] = NULL;
  9336.  
  9337.     if (flag) max--;
  9338.  
  9339.     while (1) {                         /* Go thru word list */
  9340.         if (!s || (*s == '\0')) {       /* No more characters? */
  9341.             if (k != 0) {               /* Was I in a word? */
  9342.                 if (z == max) break;    /* Yes, only go up to max. */
  9343.                 z++;                    /* Count this word. */
  9344. #ifdef XWORDSDEBUG
  9345.                 printf("1 z++ = %d\n", z);
  9346. #endif /* XWORDSDEBUG */
  9347. #ifndef NOSPL
  9348.                 if (macro) {            /* Doing macro args */
  9349.                     if (z < 10) {
  9350.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  9351.                         addmac(varnam,p);
  9352.                     }
  9353.                     if (z <= max) {
  9354. #ifdef COMMENT
  9355.                         if (maclvl < 0)
  9356.                           addmac(varnam,p);
  9357.                         else
  9358. #endif /* COMMENT */
  9359.                           makestr(&(m_xarg[maclvl][z]),p);
  9360.                     }
  9361.                 } else {                /* Not doing macro args */
  9362. #endif /* NOSPL */
  9363.                     list[z] = p;        /* Assign pointer. */
  9364. #ifdef XWORDSDEBUG
  9365.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  9366. #endif /* XWORDSDEBUG */
  9367. #ifndef NOSPL
  9368.                 }
  9369. #endif /* NOSPL */
  9370.                 break;                  /* And get out. */
  9371.             } else break;               /* Was not in a word */
  9372.         }
  9373.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  9374.             s++;
  9375.             continue;
  9376.         } else if (q == 0 && *s == '{') { /* An opening brace */
  9377.             if (k == 0 && y == 0) {     /* If leading brace */
  9378.                 p = s+1;                /* point past it */
  9379.                 b = 1;                  /* and flag that we did this */
  9380.             }
  9381.             k = 1;                      /* Flag that we're in a word */
  9382.             y++;                        /* Count the brace. */
  9383.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  9384.             y--;                        /* Count it. */
  9385.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  9386.                 char c;
  9387.                 c = *(s+1);
  9388.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9389.                     *s = SP;            /* change it to a space */
  9390.                     b = 0;              /* and we're not in braces any more */
  9391.                 }
  9392.             }
  9393. #ifdef DOUBLEQUOTING
  9394.         /* Opening doublequote */
  9395.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9396.             y++;
  9397.             p = s+1;                    /* point past it */
  9398.             q = 1;                      /* and flag that we did this */
  9399.             k = 1;                      /* Flag that we're in a word */
  9400.         /* Closing double quote */
  9401.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9402.             char c;
  9403.             c = *(s+1);
  9404.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9405.                 y--;
  9406.                 *s = SP;                /* change it to a space */
  9407.                 q = 0;                  /* and we're not in quotes any more */
  9408.             }
  9409. #endif /* DOUBLEQUOTING */
  9410.  
  9411.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9412.             if (k == 0) {               /* If we weren't in a word before, */
  9413.                 p = s;                  /* Mark the beginning */
  9414.                 if (flag && z == max) { /* Want last word to be remainder? */
  9415.                     z++;
  9416. #ifdef XWORDSDEBUG
  9417.                     printf("1 z++ = %d\n", z);
  9418. #endif /* XWORDSDEBUG */
  9419.                     list[z] = p;        /* Yes, point to it */
  9420. #ifdef XWORDSDEBUG
  9421.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9422. #endif /* XWORDSDEBUG */
  9423.                     break;              /* and quit */
  9424.                 }
  9425.                 k = 1;                  /* Set in-word flag */
  9426.             }
  9427.         }
  9428.         /* If we're not inside a braced quantity, and we are in a word, and */
  9429.         /* we have hit whitespace, then we have a word. */
  9430.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9431.             if (!flag || z < max)       /* if we don't want to keep rest */
  9432.               *s = '\0';                /* terminate the arg with null */
  9433.             k = 0;                      /* say we're not in a word any more */
  9434.             y = 0;                      /* start braces off clean again */
  9435.             if (z == max) break;        /* Only go up to max. */
  9436.             z++;                        /* count this arg */
  9437. #ifdef XWORDSDEBUG
  9438.             printf("1 z++ = %d\n", z);
  9439. #endif /* XWORDSDEBUG */
  9440.  
  9441. #ifndef NOSPL
  9442.             if (macro) {
  9443.                 if (z < 10) {
  9444.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9445.                     addmac(varnam,p);   /* add it to the macro table */
  9446.                 }
  9447.                 if (z <= max) {
  9448. #ifdef COMMENT
  9449.                     if (maclvl < 0)
  9450.                       addmac(varnam,p);
  9451.                     else
  9452. #endif /* COMMENT */
  9453.                       makestr(&(m_xarg[maclvl][z]),p);
  9454.                 }
  9455.             } else {
  9456. #endif /* NOSPL */
  9457.                 list[z] = p;
  9458. #ifdef XWORDSDEBUG
  9459.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9460. #endif /* XWORDSDEBUG */
  9461. #ifndef NOSPL
  9462.             }
  9463. #endif /* NOSPL */
  9464.             p = s+1;
  9465.         }
  9466.         s++;                            /* Point past this character */
  9467.     }
  9468.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9469.         z++;
  9470. #ifndef NOSPL
  9471.         if (macro) {
  9472.             if (z < 10) {
  9473.                 varnam[1] = z + '0';    /* compute its name */
  9474.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9475.             }
  9476.             if (z <= max) {
  9477. #ifdef COMMENT
  9478.                 if (maclvl < 0)
  9479.                   addmac(varnam,p);
  9480.                 else
  9481. #endif /* COMMENT */
  9482.                   makestr(&(m_xarg[maclvl][z]),p);
  9483.             }
  9484.         } else {
  9485. #endif /* NOSPL */
  9486.             list[z] = p;
  9487. #ifdef XWORDSDEBUG
  9488.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9489. #endif /* XWORDSDEBUG */
  9490. #ifndef NOSPL
  9491.         }
  9492. #endif /* NOSPL */
  9493.     }
  9494. #ifndef NOSPL
  9495.     if (macro) {                        /* Macro */
  9496.         if (maclvl < 0) {
  9497.             a_dim[0] = z;               /* Array dimension is one less */
  9498.             topargc = z + 1;            /* than \v(argc) */
  9499.         debug(F111,"a_dim[0]","D",a_dim[0]);
  9500.         } else {
  9501.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9502.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9503.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9504.             a_dim[0] = z;               /* And give it this dimension */
  9505.         debug(F111,"a_dim[0]","E",a_dim[0]);
  9506.         }
  9507.     }
  9508. #endif /* NOSPL */
  9509.     return;
  9510. }
  9511.  
  9512. #ifndef NOSPL
  9513.  
  9514. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9515.  
  9516. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9517.  
  9518. int
  9519. doshift(n) int n; {                     /* n = shift count */
  9520.     int i, top, level;
  9521.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9522.     char * sx = tmpbuf;
  9523.     int nx = TMPBUFSIZ;
  9524.  
  9525.     debug(F101,"SHIFT count","",n);
  9526.     debug(F101,"SHIFT topargc","",topargc);
  9527.  
  9528.     if (n < 1)                          /* Stay in range */
  9529.       return(n == 0 ? 1 : 0);
  9530.  
  9531.     level = maclvl;
  9532.     top = (level < 0) ? topargc : macargc[level];
  9533.  
  9534.     if (n >= top)
  9535.       n = top - 1;
  9536.  
  9537. #ifdef DEBUG
  9538.     if (deblog) {
  9539.         debug(F101,"SHIFT count 2","",n);
  9540.         debug(F101,"SHIFT level","",level);
  9541.         if (level > -1)
  9542.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9543.     }
  9544. #endif /* DEBUG */
  9545.  
  9546.     buf[0] = '\\';                      /* Initialize name template */
  9547.     buf[1] = '%';
  9548.     buf[2] = NUL;
  9549.     buf[3] = NUL;
  9550.  
  9551.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9552.         if (level < 0) {
  9553.             makestr(&(toparg[i]),NULL);
  9554.         } else {
  9555.             makestr(&(m_xarg[level][i]),NULL);
  9556.         }
  9557.         if (i < 10) {                   /* Is this necessary? */
  9558.             buf[2] = (char)(i+'0');
  9559.             delmac(buf,0);
  9560.         }
  9561.     }
  9562.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9563.         if (level < 0) {
  9564. #ifdef COMMENT
  9565.             toparg[i] = toparg[i+n];    /* Full vector */
  9566. #else
  9567.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9568. #endif /* COMMENT */
  9569.             if (i < 10)                 /* Scalars... */
  9570.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9571.         } else {
  9572. #ifdef COMMENT
  9573.             m_xarg[level][i] = m_xarg[level][i+n];
  9574. #else
  9575.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9576. #endif /* COMMENT */
  9577.             if (i < 10) {
  9578.                 buf[2] = (char)(i+'0');
  9579.                 debug(F010,"SHIFT buf",buf,0);
  9580.                 addmac(buf,m_xarg[level][i+n]);
  9581.             }
  9582.         }
  9583.     }
  9584.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9585.         if (level < 0) {
  9586. #ifdef COMMENT
  9587.             toparg[i] = NULL;
  9588. #else
  9589.             makestr(&(toparg[i]),NULL);
  9590. #endif /* COMMENt */
  9591.             if (i < 10)
  9592.               makestr(&(g_var[i+'0']),NULL);
  9593.         } else {
  9594. #ifdef COMMENT
  9595.             m_xarg[level][i] = NULL;
  9596. #else
  9597.             makestr(&(m_xarg[level][i]),NULL);
  9598. #endif /* COMMENt */
  9599.             if (i < 10) {
  9600.                 buf[2] = (char)(i+'0');
  9601.                 delmac(buf,0);
  9602.             }
  9603.         }
  9604.     }
  9605.     if (level > -1) {                   /* Macro args */
  9606.         macargc[level] -= n;            /* Adjust count */
  9607.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9608.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9609.     debug(F111,"a_dim[0]","F",a_dim[0]);
  9610.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9611. #ifdef COMMENT
  9612.         makestr(&(m_line[level]),tmpbuf);
  9613. #endif /* COMMENT */
  9614.     } else {                            /* Ditto for top level */
  9615.         topargc -= n;
  9616.         a_dim[0] = topargc - 1;
  9617.     debug(F111,"a_dim[0]","G",a_dim[0]);
  9618.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9619. #ifdef COMMENT
  9620.         makestr(&topline,tmpbuf);
  9621. #endif /* COMMENT */
  9622.     }
  9623.     return(1);
  9624. }
  9625. #endif /* NOSPL */
  9626.  
  9627. int
  9628. docd(cx) int cx; {                      /* Do the CD command */
  9629.     int x;
  9630.     extern int server, srvcdmsg, cdactive;
  9631.     extern char * cdmsgfile[], * ckcdpath;
  9632.     char *s, *p;
  9633. #ifdef MAC
  9634.     char temp[34];
  9635. #endif /* MAC */
  9636. #ifdef IKSDCONF
  9637. extern int iksdcf;
  9638. #endif /* IKSDCONF */
  9639.  
  9640. #ifndef NOFRILLS
  9641.     if (cx == XXBACK) {
  9642.         if ((x = cmcfm()) < 0)
  9643.         cwdf = 1;
  9644.         if (prevdir) {
  9645.             s = zgtdir();
  9646.             if (!zchdir(prevdir)) {
  9647.                 cwdf = 0;
  9648.                 perror(s);
  9649.             } else {
  9650.                 makestr(&prevdir,s);
  9651.             }
  9652.         }
  9653.         return(cwdf);
  9654.     }
  9655. #endif /* NOFRILLS */
  9656.  
  9657.     if (cx == XXCDUP) {
  9658. #ifdef VMS
  9659.         s = "[-]";
  9660. #else
  9661. #ifdef datageneral
  9662.         s = "^";
  9663. #else
  9664.         s = "..";
  9665. #endif /* datageneral */
  9666. #endif /* VMS */
  9667.         ckstrncpy(line,s,LINBUFSIZ);
  9668.         goto gocd;
  9669.     }
  9670. #ifndef NOSPL
  9671.     if (cx == XXKCD) {            /* Symbolic (Kermit) CD */
  9672.     char * p;
  9673.     int n, k;
  9674.     x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9675.     if (x < 0)
  9676.       return(x);
  9677.     x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9678.     if (x < 0) {
  9679.         printf("?Lookup error\n");    /* shouldn't happen */
  9680.         return(-9);
  9681.     }
  9682.         if ((x = cmcfm()) < 0)
  9683.       return(x);
  9684.     if (k == VN_HOME) {        /* HOME: allow SET HOME to override */
  9685.         ckstrncpy(line,homepath(),LINBUFSIZ);
  9686.     } else {            /* Other symbolic name */
  9687.         /* Convert to variable syntax */
  9688.         ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9689.         p = line;            /* Expand the variable */
  9690.         n = LINBUFSIZ;
  9691.         zzstring(tmpbuf,&p,&n);
  9692.         if (!line[0]) {        /* Fail if variable not defined */
  9693.         printf("?%s - not defined\n",tmpbuf);
  9694.         return(success = 0);
  9695.         }
  9696.     }
  9697.     s = line;            /* All OK, go try to CD... */
  9698.     goto gocd;
  9699.     }
  9700. #endif /* NOSPL */
  9701.  
  9702.     cdactive = 1;
  9703. #ifdef GEMDOS
  9704.     if ((x = cmdir("Name of local directory, or carriage return",
  9705.                    homepath(),
  9706.                    &s,
  9707.                    NULL
  9708.                    )
  9709.          ) < 0 )
  9710.       return(x);
  9711. #else
  9712. #ifdef OS2
  9713.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9714.        or press the Enter key for the default",
  9715.                     homepath(),
  9716.                     &s,
  9717.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9718.                     xxstring
  9719.                     )
  9720.          ) < 0 )
  9721.       return(x);
  9722. #else
  9723. #ifdef MAC
  9724.     x = ckstrncpy(temp,homepath(),32);
  9725.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9726.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9727.  or press the Return key for the desktop on the boot disk",
  9728.                    temp,&s, xxstring)) < 0 )
  9729.       return(x);
  9730. #else
  9731.     if ((x = cmdirp("Carriage return for home directory,\n\
  9732. or name of directory on this computer",
  9733. #ifdef VMS
  9734.                     "SYS$LOGIN",        /* With no colon */
  9735. #else
  9736.                     homepath(),        /* In VMS this is "SYS$LOGIN:" */
  9737. #endif /* VMS */
  9738.                     &s,
  9739.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9740.                     xxstring
  9741.                     )) < 0)
  9742.       return(x);
  9743. #endif /* MAC */
  9744. #endif /* OS2 */
  9745. #endif /* GEMDOS */
  9746.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9747.     s = line;
  9748. #ifdef VMS
  9749.     if (ckmatch("*.DIR;1$",s,0,0))
  9750.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9751.         s = tmpbuf;
  9752. #endif /* VMS */
  9753.     debug(F110,"docd",s,0);
  9754. #ifndef MAC
  9755.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9756.       return(x);
  9757. #endif /* MAC */
  9758.  
  9759.   gocd:
  9760.  
  9761. #ifdef datageneral
  9762.     x = strlen(line);                   /* homdir ends in colon, */
  9763.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9764.       line[x-1] = NUL;
  9765. #endif /* datageneral */
  9766.  
  9767. #ifdef MAC
  9768.     cwdf = 1;
  9769.     if (!zchdir(s)) {
  9770.         cwdf = 0;
  9771.         if (*s != ':') {                /* If it failed, */
  9772.             char *p;                    /* supply leading colon */
  9773.             int len = (int)strlen(s) + 2;
  9774.             p = malloc(len);            /* and try again... */
  9775.             if (p) {
  9776.                 strcpy(p,":");          /* safe */
  9777.                 strcat(p,s);            /* safe */
  9778.                 if (zchdir(p))
  9779.                   cwdf = 1;
  9780.                 free(p);
  9781.                 p = NULL;
  9782.             }
  9783.         }
  9784.     }
  9785.     if (!cwdf)
  9786.       perror(s);
  9787. #else
  9788.     p = zgtdir();
  9789.     if (!zchdir(s)) {
  9790.         cwdf = 0;
  9791. #ifdef CKROOT
  9792.         if (ckrooterr)
  9793.           printf("?Off limits: \"%s\"\n",s);
  9794.         else
  9795. #endif /* CKROOT */
  9796.           perror(s);
  9797.     } else cwdf = 1;
  9798. #endif /* MAC */
  9799.  
  9800.     x = 0;
  9801.     if (cwdf) {
  9802.         makestr(&prevdir,p);
  9803.         debug(F111,"docd","srvcdmsg",srvcdmsg);
  9804.         if (srvcdmsg
  9805. #ifdef IKSDCONF
  9806.             && !(inserver && !iksdcf)
  9807. #endif /* IKSDCONF */
  9808.             ) {
  9809.             int i;
  9810.             for (i = 0; i < 8; i++) {
  9811.                 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9812.                 if (zchki(cdmsgfile[i]) > -1) {
  9813.                     x = 1;
  9814.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9815.                     break;
  9816.                 }
  9817.             }
  9818.         }
  9819.     }
  9820. /* xdocd: */
  9821.     if (!x && srvcdmsg && !server
  9822. #ifdef IKSDCONF
  9823.         && !(inserver && !iksdcf)
  9824. #endif /* IKSDCONF */
  9825.         && !quiet && !xcmdsrc)
  9826.       printf("%s\n", zgtdir());
  9827.  
  9828.     return(cwdf);
  9829. }
  9830.  
  9831. static int on_ctrlc = 0;
  9832.  
  9833. VOID
  9834. fixcmd() {                      /* Fix command parser after interruption */
  9835. #ifndef NOSPL
  9836. #ifndef NOONCTRLC
  9837.     if (nmac) {                         /* Any macros defined? */
  9838.         int k;                          /* Yes */
  9839.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9840.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9841.         if (k >= 0) {                   /* If found, */
  9842.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9843.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9844.                   parser(1);            /* execute it, */
  9845.             }
  9846.             delmac(s,1);                /* and undefine it. */
  9847.         }
  9848.     }
  9849.     on_ctrlc = 0;
  9850. #endif /* NOONCTRLC */
  9851. #endif /* NOSPL */
  9852.     dostop();                   /* Back to top level (also calls conint()). */
  9853.     bgchk();                    /* Check background status */
  9854.     if (*psave) {               /* If old prompt saved, */
  9855.         cmsetp(psave);          /* restore it. */
  9856.         *psave = NUL;
  9857.     }
  9858.     success = 0;                /* Tell parser last command failed */
  9859. }
  9860.  
  9861. #ifndef NOSHOW                          /* SHOW FEATURES */
  9862. /*
  9863.   Note, presently optlist[] index overflow is not checked.
  9864.   There is plenty of room (less than 360 entries for 1000 slots).
  9865.   When space starts to get tight, check for noptlist >= NOPTLIST
  9866.   every time noptlist is incremented.
  9867. */
  9868. #define NOPTLIST 1024
  9869. static int noptlist = 0;
  9870. static char * optlist[NOPTLIST+1];
  9871. static int hpos = 0;
  9872.  
  9873. int
  9874. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9875.     int y, i;                           /* Does word wrap. */
  9876.     if (!s) s = "";
  9877.     i = *lines;
  9878.     if (!*s) {                          /* Empty argument */
  9879.         if (hpos > 0) {                 /* means to end this line. */
  9880.             printf("\n");               /* Not needed if already at */
  9881.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9882.                 if (!askmore())
  9883.                   return(0);
  9884.                 else
  9885.                   i = 0;
  9886.             }
  9887.         }
  9888.         printf("\n");                   /* And then make a blank line */
  9889.         if (++i > (cmd_rows - 3)) {
  9890.             if (!askmore())
  9891.               return(0);
  9892.             else
  9893.               i = 0;
  9894.         }
  9895.         hpos = 0;
  9896.         *lines = i;
  9897.         return(1);
  9898.     }
  9899.     y = (int)strlen(s) + 1;
  9900.     hpos += y;
  9901.     debug(F101,"prtopt hpos","",hpos);
  9902.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9903.  
  9904.     if (
  9905. #ifdef OS2
  9906.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9907. #else /* OS2 */
  9908.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9909. #endif /* OS2 */
  9910.         ) {
  9911.         printf("\n");
  9912.         if (++i > (cmd_rows - 3)) {
  9913.             if (!askmore())
  9914.               return(0);
  9915.             else
  9916.               i = 0;
  9917.         }
  9918.         printf(" %s",s);
  9919.         hpos = y;
  9920.     } else
  9921.       printf(" %s",s);
  9922.     *lines = i;
  9923.     return(1);
  9924. }
  9925.  
  9926. static VOID
  9927. initoptlist() {
  9928.     int i;
  9929.     if (noptlist > 0)
  9930.       return;
  9931.     for (i = 0; i < NOPTLIST; i++)
  9932.       optlist[i] = NULL;
  9933.  
  9934. #ifdef MAC
  9935. #ifdef MPW
  9936.     makestr(&(optlist[noptlist++]),"MPW");
  9937. #endif /* MPW */
  9938. #endif /* MAC */
  9939.  
  9940. #ifdef MAC
  9941. #ifdef THINK_C
  9942.     makestr(&(optlist[noptlist++]),"THINK_C");
  9943. #endif /* THINK_C */
  9944. #endif /* MAC */
  9945.  
  9946. #ifdef __386__
  9947.     makestr(&(optlist[noptlist++]),"__386__");
  9948. #endif /* __386__ */
  9949.  
  9950. /* Memory models... */
  9951.  
  9952. #ifdef __FLAT__
  9953.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9954. #endif /* __FLAT__ */
  9955. #ifdef __SMALL__
  9956.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9957. #endif /* __SMALL__ */
  9958. #ifdef __MEDIUM__
  9959.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9960. #endif /* __MEDIUM__ */
  9961. #ifdef __COMPACT__
  9962.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9963. #endif /* __COMPACT__ */
  9964. #ifdef __LARGE__
  9965.     makestr(&(optlist[noptlist++]),"__LARGE__");
  9966. #endif /* __LARGE__ */
  9967.  
  9968. #ifdef DEBUG
  9969. #ifdef IFDEBUG
  9970.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  9971. #else
  9972.     makestr(&(optlist[noptlist++]),"DEBUG");
  9973. #endif /* IFDEBUG */
  9974. #endif /* DEBUG */
  9975. #ifdef TLOG
  9976.     makestr(&(optlist[noptlist++]),"TLOG");
  9977. #endif /* TLOG */
  9978. #ifdef BIGBUFOK
  9979.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9980. #endif /* BIGBUFOK */
  9981. #ifdef INPBUFSIZ
  9982.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9983.     makestr(&(optlist[noptlist++]),line);
  9984. #endif /* INPBUFSIZE */
  9985. #ifdef LINBUFSIZ
  9986.     sprintf(line,"LINBUFSIZ=%d",LINBUFSIZ); /* SAFE */
  9987.     makestr(&(optlist[noptlist++]),line);
  9988. #endif /* LINBUFSIZE */
  9989. #ifdef INBUFSIZE
  9990.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9991.     makestr(&(optlist[noptlist++]),line);
  9992. #endif /* INBUFSIZE */
  9993. #ifdef OBUFSIZE
  9994.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9995.     makestr(&(optlist[noptlist++]),line);
  9996. #endif /* OBUFSIZE */
  9997. #ifdef FD_SETSIZE
  9998.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9999.     makestr(&(optlist[noptlist++]),line);
  10000. #endif /* FD_SETSIZE */
  10001. #ifdef XFRCAN
  10002.     makestr(&(optlist[noptlist++]),"XFRCAN");
  10003. #endif /* XFRCAN */
  10004. #ifdef XPRINT
  10005.     makestr(&(optlist[noptlist++]),"XPRINT");
  10006. #endif /* XPRINT */
  10007. #ifdef PIPESEND
  10008.     makestr(&(optlist[noptlist++]),"PIPESEND");
  10009. #endif /* PIPESEND */
  10010. #ifdef CK_SPEED
  10011.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  10012. #endif /* CK_SPEED */
  10013. #ifdef CK_FAST
  10014.     makestr(&(optlist[noptlist++]),"CK_FAST");
  10015. #endif /* CK_FAST */
  10016. #ifdef CK_APC
  10017.     makestr(&(optlist[noptlist++]),"CK_APC");
  10018. #endif /* CK_APC */
  10019. #ifdef CK_AUTODL
  10020.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  10021. #endif /* CK_AUTODL */
  10022. #ifdef CK_MKDIR
  10023.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  10024. #endif /* CK_MKDIR */
  10025. #ifdef NOMKDIR
  10026.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  10027. #endif /* NOMKDIR */
  10028. #ifdef CK_LABELED
  10029.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  10030. #endif /* CK_LABELED */
  10031. #ifdef NODIAL
  10032.     makestr(&(optlist[noptlist++]),"NODIAL");
  10033. #endif /* NODIAL */
  10034. #ifdef MINIDIAL
  10035.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  10036. #endif /* MINIDIAL */
  10037. #ifdef WHATAMI
  10038.     makestr(&(optlist[noptlist++]),"WHATAMI");
  10039. #endif /* WHATAMI */
  10040. #ifdef DYNAMIC
  10041.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  10042. #endif /* DYNAMIC */
  10043. #ifndef NOSPL
  10044.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  10045.     makestr(&(optlist[noptlist++]),line);
  10046. #endif /* NOSPL */
  10047.  
  10048. #ifdef MAXPATHLEN
  10049.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  10050.     makestr(&(optlist[noptlist++]),line);
  10051. #endif /* MAXPATHLEN */
  10052.  
  10053. #ifdef DEVNAMLEN
  10054.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  10055.     makestr(&(optlist[noptlist++]),line);
  10056. #endif /* DEVNAMLEN */
  10057.  
  10058. #ifdef NO_PARAM_H
  10059.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  10060. #endif /* NO_PARAM_H */
  10061.  
  10062. #ifdef INCL_PARAM_H
  10063.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  10064. #endif /* INCL_PARAM_H */
  10065.  
  10066.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  10067.     makestr(&(optlist[noptlist++]),line);
  10068.  
  10069.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  10070.     makestr(&(optlist[noptlist++]),line);
  10071.  
  10072.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  10073.     makestr(&(optlist[noptlist++]),line);
  10074.  
  10075. #ifdef OPEN_MAX
  10076.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  10077.     makestr(&(optlist[noptlist++]),line);
  10078. #endif /* OPEN_MAX */
  10079.  
  10080. #ifdef _POSIX_OPEN_MAX
  10081.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  10082.     makestr(&(optlist[noptlist++]),line);
  10083. #endif /* _POSIX_OPEN_MAX */
  10084.  
  10085. #ifdef CKCHANNELIO
  10086.     {
  10087.         extern int z_maxchan;
  10088. #ifdef UNIX
  10089.         extern int ckmaxfiles;
  10090.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  10091.         makestr(&(optlist[noptlist++]),line);
  10092. #endif /* UNIX */
  10093.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  10094.         makestr(&(optlist[noptlist++]),line);
  10095.     }
  10096. #endif /* CKCHANNELIO */
  10097.  
  10098. #ifdef FOPEN_MAX
  10099.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  10100.     makestr(&(optlist[noptlist++]),line);
  10101. #endif /* FOPEN_MAX */
  10102.  
  10103. #ifdef MAXGETPATH
  10104.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  10105.     makestr(&(optlist[noptlist++]),line);
  10106. #endif /* MAXGETPATH */
  10107.  
  10108. #ifdef CMDBL
  10109.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  10110.     makestr(&(optlist[noptlist++]),line);
  10111. #endif /* CMDBL */
  10112.  
  10113. #ifdef VNAML
  10114.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  10115.     makestr(&(optlist[noptlist++]),line);
  10116. #endif /* VNAML */
  10117.  
  10118. #ifdef ARRAYREFLEN
  10119.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  10120.     makestr(&(optlist[noptlist++]),line);
  10121. #endif /* ARRAYREFLEN */
  10122.  
  10123. #ifdef UIDBUFLEN
  10124.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  10125.     makestr(&(optlist[noptlist++]),line);
  10126. #endif /* UIDBUFLEN */
  10127.  
  10128. #ifdef FORDEPTH
  10129.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  10130.     makestr(&(optlist[noptlist++]),line);
  10131. #endif /* FORDEPTH */
  10132.  
  10133. #ifdef MAXTAKE
  10134.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  10135.     makestr(&(optlist[noptlist++]),line);
  10136. #endif /* MAXTAKE */
  10137.  
  10138. #ifdef MACLEVEL
  10139.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  10140.     makestr(&(optlist[noptlist++]),line);
  10141. #endif /* MACLEVEL */
  10142.  
  10143. #ifdef MAC_MAX
  10144.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  10145.     makestr(&(optlist[noptlist++]),line);
  10146. #endif /* MAC_MAX */
  10147.  
  10148. #ifdef _LARGEFILE_SOURCE
  10149.     makestr(&(optlist[noptlist++]),"_LARGEFILE_SOURCE");
  10150. #endif    /* _LARGEFILE_SOURCE */
  10151.  
  10152. #ifdef _FILE_OFFSET_BITS
  10153.     sprintf(line,"_FILE_OFFSET_BITS=%d",_FILE_OFFSET_BITS); /* SAFE */
  10154.     makestr(&(optlist[noptlist++]),line);
  10155. #endif    /* _FILE_OFFSET_BITS */
  10156.  
  10157. #ifdef __USE_FILE_OFFSET64
  10158.     makestr(&(optlist[noptlist++]),"__USE_FILE_OFFSET64");
  10159. #endif    /* __USE_FILE_OFFSET64 */
  10160.  
  10161. #ifdef __USE_LARGEFILE64
  10162.     makestr(&(optlist[noptlist++]),"__USE_LARGEFILE64");
  10163. #endif    /* __USE_LARGEFILE64 */
  10164.  
  10165. #ifdef COMMENT
  10166. #ifdef CHAR_MAX
  10167.     sprintf(line,"CHAR_MAX=%llx",CHAR_MAX); /* SAFE */
  10168.     makestr(&(optlist[noptlist++]),line);
  10169. #endif /* CHAR_MAX */
  10170. #ifdef UCHAR_MAX
  10171.     sprintf(line,"UCHAR_MAX=%llx",UCHAR_MAX); /* SAFE */
  10172.     makestr(&(optlist[noptlist++]),line);
  10173. #endif /* UCHAR_MAX */
  10174. #ifdef SHRT_MAX
  10175.     sprintf(line,"SHRT_MAX=%llx",SHRT_MAX); /* SAFE */
  10176.     makestr(&(optlist[noptlist++]),line);
  10177. #endif /* SHRT_MAX */
  10178. #ifdef USHRT_MAX
  10179.     sprintf(line,"USHRT_MAX=%llx",USHRT_MAX); /* SAFE */
  10180.     makestr(&(optlist[noptlist++]),line);
  10181. #endif /* USHRT_MAX */
  10182. #ifdef INT_MAX
  10183.     sprintf(line,"INT_MAX=%llx",INT_MAX); /* SAFE */
  10184.     makestr(&(optlist[noptlist++]),line);
  10185. #endif /* INT_MAX */
  10186. #ifdef UINT_MAX
  10187.     sprintf(line,"UINT_MAX=%llx",UINT_MAX); /* SAFE */
  10188.     makestr(&(optlist[noptlist++]),line);
  10189. #endif /* UINT_MAX */
  10190. #ifdef MAX_LONG
  10191.     sprintf(line,"MAX_LONG=%llx",MAX_LONG); /* SAFE */
  10192.     makestr(&(optlist[noptlist++]),line);
  10193. #endif /* MAX_LONG */
  10194. #ifdef LONG_MAX
  10195.     sprintf(line,"LONG_MAX=%llx",LONG_MAX); /* SAFE */
  10196.     makestr(&(optlist[noptlist++]),line);
  10197. #endif /* LONG_MAX */
  10198. #ifdef ULONG_MAX
  10199.     sprintf(line,"ULONG_MAX=%llx",ULONG_MAX); /* SAFE */
  10200.     makestr(&(optlist[noptlist++]),line);
  10201. #endif /* ULONG_MAX */
  10202. #ifdef MAXINT
  10203.     sprintf(line,"MAXINT=%llx",MAXINT); /* SAFE */
  10204.     makestr(&(optlist[noptlist++]),line);
  10205. #endif /* MAXINT */
  10206. #ifdef MAXLONG
  10207.     sprintf(line,"MAXLONG=%llx",MAXLONG); /* SAFE */
  10208.     makestr(&(optlist[noptlist++]),line);
  10209. #endif /* MAXLONG */
  10210. #ifdef NT
  10211. #ifdef LLONG_MAX
  10212.     sprintf(line,"LLONG_MAX=%I64x",LLONG_MAX); /* SAFE */
  10213.     makestr(&(optlist[noptlist++]),line);
  10214. #endif /* LLONG_MAX */
  10215. #ifdef ULLONG_MAX
  10216.     sprintf(line,"ULLONG_MAX=%I64x",ULLONG_MAX); /* SAFE */
  10217.     makestr(&(optlist[noptlist++]),line);
  10218. #endif /* ULLONG_MAX */
  10219. #ifdef MAXLONGLONG
  10220.     sprintf(line,"MAXLONGLONG=%I64x",MAXLONGLONG);  /* SAFE */
  10221.     makestr(&(optlist[noptlist++]),line);
  10222. #endif /* MAXLONGLONG */
  10223. #else
  10224. #ifdef LLONG_MAX
  10225.     sprintf(line,"LLONG_MAX=%llx",LLONG_MAX); /* SAFE */
  10226.     makestr(&(optlist[noptlist++]),line);
  10227. #endif /* LLONG_MAX */
  10228. #ifdef ULLONG_MAX
  10229.     sprintf(line,"ULLONG_MAX=%llx",ULLONG_MAX); /* SAFE */
  10230.     makestr(&(optlist[noptlist++]),line);
  10231. #endif /* ULLONG_MAX */
  10232. #ifdef MAXLONGLONG
  10233.     sprintf(line,"MAXLONGLONG=%llx",MAXLONGLONG);  /* SAFE */
  10234.     makestr(&(optlist[noptlist++]),line);
  10235. #endif /* MAXLONGLONG */
  10236. #endif
  10237. #ifdef _INTEGRAL_MAX_BITS
  10238.     sprintf(line,"_INTEGRAL_MAX_BITS=%d",_INTEGRAL_MAX_BITS);  /* SAFE */
  10239.     makestr(&(optlist[noptlist++]),line);
  10240. #endif /* _INTEGRAL_MAX_BITS */
  10241. #endif    /* COMMENT */
  10242.  
  10243. #ifdef MINPUTMAX
  10244.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  10245.     makestr(&(optlist[noptlist++]),line);
  10246. #endif /* MINPUTMAX */
  10247.  
  10248. #ifdef MAXWLD
  10249.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  10250.     makestr(&(optlist[noptlist++]),line);
  10251. #else
  10252. #ifdef OS2
  10253.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  10254. #endif /* OS2 */
  10255. #endif /* MAXWLD */
  10256.  
  10257. #ifdef MSENDMAX
  10258.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  10259.     makestr(&(optlist[noptlist++]),line);
  10260. #endif /* MSENDMAX */
  10261.  
  10262. #ifdef MAXDDIR
  10263.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  10264.     makestr(&(optlist[noptlist++]),line);
  10265. #endif /* MAXDDIR */
  10266.  
  10267. #ifdef MAXDNUMS
  10268.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  10269.     makestr(&(optlist[noptlist++]),line);
  10270. #endif /* MAXDNUMS */
  10271.  
  10272. #ifdef UNIX
  10273.     makestr(&(optlist[noptlist++]),"UNIX");
  10274. #endif /* UNIX */
  10275.  
  10276. #ifdef VMS
  10277.     makestr(&(optlist[noptlist++]),"VMS");
  10278. #ifdef __VMS_VER
  10279.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  10280.     makestr(&(optlist[noptlist++]),line);
  10281. #endif /* __VMS_VER */
  10282. #ifdef VMSV70
  10283.     makestr(&(optlist[noptlist++]),"VMSV70");
  10284. #endif /* VMSV70 */
  10285. #ifdef OLD_VMS
  10286.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  10287. #endif /* OLD_VMS */
  10288. #ifdef vms
  10289.     makestr(&(optlist[noptlist++]),"vms");
  10290. #endif /* vms */
  10291. #ifdef VMSV60
  10292.     makestr(&(optlist[noptlist++]),"VMSV60");
  10293. #endif /* VMSV60 */
  10294. #ifdef VMSV80
  10295.     makestr(&(optlist[noptlist++]),"VMSV80");
  10296. #endif /* VMSV80 */
  10297. #ifdef VMSSHARE
  10298.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  10299. #endif /* VMSSHARE */
  10300. #ifdef NOVMSSHARE
  10301.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  10302. #endif /* NOVMSSHARE */
  10303. #endif /* VMS */
  10304.  
  10305. #ifdef datageneral
  10306.     makestr(&(optlist[noptlist++]),"datageneral");
  10307. #endif /* datageneral */
  10308. #ifdef apollo
  10309.     makestr(&(optlist[noptlist++]),"apollo");
  10310. #endif /* apollo */
  10311. #ifdef aegis
  10312.     makestr(&(optlist[noptlist++]),"aegis");
  10313. #endif /* aegis */
  10314. #ifdef A986
  10315.     makestr(&(optlist[noptlist++]),"A986");
  10316. #endif /* A986 */
  10317. #ifdef AMIGA
  10318.     makestr(&(optlist[noptlist++]),"AMIGA");
  10319. #endif /* AMIGA */
  10320. #ifdef CONVEX9
  10321.     makestr(&(optlist[noptlist++]),"CONVEX9");
  10322. #endif /* CONVEX9 */
  10323. #ifdef CONVEX10
  10324.     makestr(&(optlist[noptlist++]),"CONVEX10");
  10325. #endif /* CONVEX9 */
  10326. #ifdef MAC
  10327.     makestr(&(optlist[noptlist++]),"MAC");
  10328. #endif /* MAC */
  10329. #ifdef AUX
  10330.     makestr(&(optlist[noptlist++]),"AUX");
  10331. #endif /* AUX */
  10332.  
  10333. #ifdef OS2
  10334.     makestr(&(optlist[noptlist++]),"OS2");
  10335. #ifdef NT
  10336.     makestr(&(optlist[noptlist++]),"NT");
  10337. #endif /* NT */
  10338. #endif /* OS2 */
  10339.  
  10340. #ifdef OSK
  10341.     makestr(&(optlist[noptlist++]),"OS9");
  10342. #endif /* OSK */
  10343.  
  10344. #ifdef MSDOS
  10345.     makestr(&(optlist[noptlist++]),"MSDOS");
  10346. #endif /* MSDOS */
  10347.  
  10348. #ifdef DIRENT
  10349.     makestr(&(optlist[noptlist++]),"DIRENT");
  10350. #endif /* DIRENT */
  10351.  
  10352. #ifdef SDIRENT
  10353.     makestr(&(optlist[noptlist++]),"SDIRENT");
  10354. #endif /* SDIRENT */
  10355.  
  10356. #ifdef NDIR
  10357.     makestr(&(optlist[noptlist++]),"NDIR");
  10358. #endif /* NDIR */
  10359.  
  10360. #ifdef XNDIR
  10361.     makestr(&(optlist[noptlist++]),"XNDIR");
  10362. #endif /* XNDIR */
  10363.  
  10364. #ifdef SAVEDUID
  10365.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  10366. #endif /* SAVEDUID */
  10367.  
  10368. #ifdef RENAME
  10369.     makestr(&(optlist[noptlist++]),"RENAME");
  10370. #endif /* RENAME */
  10371.  
  10372. #ifdef CK_TMPDIR
  10373.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  10374. #endif /* CK_TMPDIR */
  10375.  
  10376. #ifdef NOCCTRAP
  10377.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  10378. #endif /* NOCCTRAP */
  10379.  
  10380. #ifdef NOCOTFMC
  10381.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  10382. #endif /* NOCOTFMC */
  10383.  
  10384. #ifdef NOFRILLS
  10385.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  10386. #endif /* NOFRILLS */
  10387.  
  10388. #ifdef PARSENSE
  10389.     makestr(&(optlist[noptlist++]),"PARSENSE");
  10390. #endif /* PARSENSE */
  10391.  
  10392. #ifdef TIMEH
  10393.     makestr(&(optlist[noptlist++]),"TIMEH");
  10394. #endif /* TIMEH */
  10395.  
  10396. #ifdef NOTIMEH
  10397.     makestr(&(optlist[noptlist++]),"TIMEH");
  10398. #endif /* NOTIMEH */
  10399.  
  10400. #ifdef SYSTIMEH
  10401.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10402. #endif /* SYSTIMEH */
  10403.  
  10404. #ifdef NOSYSTIMEH
  10405.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10406. #endif /* NOSYSTIMEH */
  10407.  
  10408. #ifdef SYSTIMEBH
  10409.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10410. #endif /* SYSTIMEBH */
  10411.  
  10412. #ifdef NOSYSTIMEBH
  10413.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10414. #endif /* NOSYSTIMEBH */
  10415.  
  10416. #ifdef UTIMEH
  10417.     makestr(&(optlist[noptlist++]),"UTIMEH");
  10418. #endif /* UTIMEH */
  10419.  
  10420. #ifdef SYSUTIMEH
  10421.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  10422. #endif /* SYSUTIMEH */
  10423.  
  10424. #ifdef CK_NEED_SIG
  10425.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  10426. #endif /* CK_NEED_SIG */
  10427.  
  10428. #ifdef CK_TTYFD
  10429.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  10430. #endif /* CK_TTYFD */
  10431.  
  10432. #ifdef NETCONN
  10433.     makestr(&(optlist[noptlist++]),"NETCONN");
  10434. #endif /* NETCONN */
  10435.  
  10436. #ifdef TCPSOCKET
  10437.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  10438. #ifdef NOTCPOPTS
  10439.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  10440. #endif /* NOTCPOPTS */
  10441. #ifdef CK_DNS_SRV
  10442.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  10443. #endif /* CK_DNS_SRV */
  10444. #ifdef NO_DNS_SRV
  10445.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  10446. #endif /* NO_DNS_SRV */
  10447. #ifdef CKGHNLHOST
  10448.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  10449. #endif /* CKGHNLHOST */
  10450. #ifdef NOLISTEN
  10451.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  10452. #endif /* NOLISTEN */
  10453. #ifdef SOL_SOCKET
  10454.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  10455. #endif /* SOL_SOCKET */
  10456. #ifdef SO_OOBINLINE
  10457.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  10458. #endif /* SO_OOBINLNE */
  10459. #ifdef SO_DONTROUTE
  10460.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  10461. #endif /* SO_DONTROUTE */
  10462. #ifdef SO_KEEPALIVE
  10463.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  10464. #endif /* SO_KEEPALIVE */
  10465. #ifdef SO_LINGER
  10466.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  10467. #endif /* SO_LINGER */
  10468. #ifdef TCP_NODELAY
  10469.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  10470. #endif /* TCP_NODELAY */
  10471. #ifdef SO_SNDBUF
  10472.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  10473. #endif /* SO_SNDBUF */
  10474. #ifdef SO_RCVBUF
  10475.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  10476. #endif /* SO_RCVBUF */
  10477. #ifdef h_addr
  10478.     makestr(&(optlist[noptlist++]),"h_addr");
  10479. #endif /* h_addr */
  10480. #ifdef HADDRLIST
  10481.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  10482. #endif /* HADDRLIST */
  10483. #ifdef CK_SOCKS
  10484.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  10485. #ifdef CK_SOCKS5
  10486.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  10487. #endif /* CK_SOCKS5 */
  10488. #ifdef CK_SOCKS_NS
  10489.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  10490. #endif /* CK_SOCKS_NS */
  10491. #endif /* CK_SOCKS */
  10492. #ifdef RLOGCODE
  10493.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  10494. #endif /* RLOGCODE */
  10495. #ifdef NETCMD
  10496.     makestr(&(optlist[noptlist++]),"NETCMD");
  10497. #endif /* NETCMD */
  10498. #ifdef NONETCMD
  10499.     makestr(&(optlist[noptlist++]),"NONETCMD");
  10500. #endif /* NONETCMD */
  10501. #ifdef NETPTY
  10502.     makestr(&(optlist[noptlist++]),"NETPTY");
  10503. #endif /* NETPTY */
  10504. #ifdef CK_ENVIRONMENT
  10505.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  10506. #endif /* CK_ENVIRONMENT */
  10507. #endif /* TCPSOCKET */
  10508. #ifdef TNCODE
  10509.     makestr(&(optlist[noptlist++]),"TNCODE");
  10510. #endif /* TNCODE */
  10511. #ifdef CK_FORWARD_X
  10512.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  10513. #endif /* CK_FORWARD_X */
  10514. #ifdef TN_COMPORT
  10515.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  10516. #endif /* TN_COMPORT */
  10517. #ifdef MULTINET
  10518.     makestr(&(optlist[noptlist++]),"MULTINET");
  10519. #endif /* MULTINET */
  10520. #ifdef DEC_TCPIP
  10521.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  10522. #endif /* DEC_TCPIP */
  10523. #ifdef TCPWARE
  10524.     makestr(&(optlist[noptlist++]),"TCPWARE");
  10525. #endif /* TCPWARE */
  10526. #ifdef UCX50
  10527.     makestr(&(optlist[noptlist++]),"UCX50");
  10528. #endif /* UCX50 */
  10529. #ifdef CMU_TCPIP
  10530.     makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  10531. #endif /* CMU_TCPIP */
  10532. #ifdef TTLEBUF
  10533.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  10534. #endif /* TTLEBUF */
  10535. #ifdef NETLEBUF
  10536.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  10537. #endif /* NETLEBUF */
  10538. #ifdef IKS_OPTION
  10539.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10540. #endif /* IKS_OPTION */
  10541. #ifdef IKSDB
  10542.     makestr(&(optlist[noptlist++]),"IKSDB");
  10543. #endif /* IKSDB */
  10544. #ifdef IKSDCONF
  10545.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  10546. #endif /* IKSDCONF */
  10547. #ifdef CK_LOGIN
  10548.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10549. #endif /* CK_LOGIN */
  10550. #ifdef CK_PAM
  10551.     makestr(&(optlist[noptlist++]),"CK_PAM");
  10552. #endif /* CK_PAM */
  10553. #ifdef CK_SHADOW
  10554.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10555. #endif /* CK_SHADOW */
  10556. #ifdef CONGSPD
  10557.     makestr(&(optlist[noptlist++]),"CONGSPD");
  10558. #endif /* CONGSPD */
  10559. #ifdef SUNX25
  10560.     makestr(&(optlist[noptlist++]),"SUNX25");
  10561. #endif /* SUNX25 */
  10562. #ifdef IBMX25
  10563.     makestr(&(optlist[noptlist++]),"IBMX25");
  10564. #endif /* IBMX25 */
  10565. #ifdef HPX25
  10566.     makestr(&(optlist[noptlist++]),"HPX25");
  10567. #endif /* HPX25 */
  10568. #ifdef DECNET
  10569.     makestr(&(optlist[noptlist++]),"DECNET");
  10570. #endif /* DECNET */
  10571. #ifdef SUPERLAT
  10572.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  10573. #endif /* SUPERLAT */
  10574. #ifdef NPIPE
  10575.     makestr(&(optlist[noptlist++]),"NPIPE");
  10576. #endif /* NPIPE */
  10577. #ifdef CK_NETBIOS
  10578.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10579. #endif /* CK_NETBIOS */
  10580. #ifdef ATT7300
  10581.     makestr(&(optlist[noptlist++]),"ATT7300");
  10582. #endif /* ATT7300 */
  10583. #ifdef ATT6300
  10584.     makestr(&(optlist[noptlist++]),"ATT6300");
  10585. #endif /* ATT6300 */
  10586. #ifdef HDBUUCP
  10587.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10588. #endif /* HDBUUCP */
  10589. #ifdef USETTYLOCK
  10590.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10591. #endif /* USETTYLOCK */
  10592. #ifdef USE_UU_LOCK
  10593.     makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
  10594. #endif /* USE_UU_LOCK */
  10595. #ifdef HAVE_BAUDBOY
  10596.     makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
  10597. #endif /* HAVE_BAUDBOY */
  10598. #ifdef HAVE_OPENPTY
  10599.     makestr(&(optlist[noptlist++]),"HAVE_OPENPTY");
  10600. #endif /* HAVE_OPENPTY */
  10601. #ifdef TTPTYCMD
  10602.     makestr(&(optlist[noptlist++]),"TTPTYCMD");
  10603. #endif /* TTPTYCMD */
  10604. #ifdef NOUUCP
  10605.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10606. #endif /* NOUUCP */
  10607. #ifdef LONGFN
  10608.     makestr(&(optlist[noptlist++]),"LONGFN");
  10609. #endif /* LONGFN */
  10610. #ifdef RDCHK
  10611.     makestr(&(optlist[noptlist++]),"RDCHK");
  10612. #endif /* RDCHK */
  10613. #ifdef SELECT
  10614.     makestr(&(optlist[noptlist++]),"SELECT");
  10615. #endif /* SELECT */
  10616. #ifdef USLEEP
  10617.     makestr(&(optlist[noptlist++]),"USLEEP");
  10618. #endif /* USLEEP */
  10619. #ifdef NAP
  10620.     makestr(&(optlist[noptlist++]),"NAP");
  10621. #endif /* NAP */
  10622. #ifdef NAPHACK
  10623.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10624. #endif /* NAPHACK */
  10625. #ifdef CK_POLL
  10626.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10627. #endif /* CK_POLL */
  10628. #ifdef NOIEXTEN
  10629.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10630. #endif /* NOIEXTEN */
  10631. #ifdef EXCELAN
  10632.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10633. #endif /* EXCELAN */
  10634. #ifdef INTERLAN
  10635.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10636. #endif /* INTERLAN */
  10637. #ifdef NOFILEH
  10638.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10639. #endif /* NOFILEH */
  10640. #ifdef NOSYSIOCTLH
  10641.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10642. #endif /* NOSYSIOCTLH */
  10643. #ifdef DCLPOPEN
  10644.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10645. #endif /* DCLPOPEN */
  10646. #ifdef NOSETBUF
  10647.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10648. #endif /* NOSETBUF */
  10649. #ifdef NOXFER
  10650.     makestr(&(optlist[noptlist++]),"NOXFER");
  10651. #endif /* NOXFER */
  10652. #ifdef NOCURSES
  10653.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10654. #endif /* NOCURSES */
  10655. #ifdef NOSERVER
  10656.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10657. #endif /* NOSERVER */
  10658. #ifdef NOPATTERNS
  10659.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10660. #else
  10661. #ifdef PATTERNS
  10662.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10663. #endif /* PATTERNS */
  10664. #endif /* NOPATTERNS */
  10665. #ifdef NOCKEXEC
  10666.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10667. #else
  10668. #ifdef CKEXEC
  10669.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10670. #endif /* CKEXEC */
  10671. #endif /* NOCKEXEC */
  10672. #ifdef NOAUTODL
  10673.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10674. #endif /* NOAUTODL */
  10675. #ifdef NOMSEND
  10676.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10677. #endif /* NOMSEND */
  10678. #ifdef NOFDZERO
  10679.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10680. #endif /* NOFDZERO */
  10681. #ifdef NOPOPEN
  10682.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10683. #endif /* NOPOPEN */
  10684. #ifdef NOPARTIAL
  10685.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10686. #endif /* NOPARTIAL */
  10687. #ifdef NOKVERBS
  10688.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10689. #endif /* NOKVERBS */
  10690. #ifdef NOSETREU
  10691.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10692. #endif /* NOSETREU */
  10693. #ifdef LCKDIR
  10694.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10695. #endif /* LCKDIR */
  10696. #ifdef ACUCNTRL
  10697.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10698. #endif /* ACUCNTRL */
  10699. #ifdef BSD4
  10700.     makestr(&(optlist[noptlist++]),"BSD4");
  10701. #endif /* BSD4 */
  10702. #ifdef BSD44
  10703.     makestr(&(optlist[noptlist++]),"BSD44");
  10704. #endif /* BSD44 */
  10705. #ifdef BSD41
  10706.     makestr(&(optlist[noptlist++]),"BSD41");
  10707. #endif /* BSD41 */
  10708. #ifdef BSD43
  10709.     makestr(&(optlist[noptlist++]),"BSD43");
  10710. #endif /* BSD43 */
  10711. #ifdef BSD29
  10712.     makestr(&(optlist[noptlist++]),"BSD29");
  10713. #endif /* BSD29 */
  10714. #ifdef BSDI
  10715.     makestr(&(optlist[noptlist++]),"BSDI");
  10716. #endif /* BSDI */
  10717. #ifdef __bsdi__
  10718.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10719. #endif /* __bsdi__ */
  10720. #ifdef __NetBSD__
  10721.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10722. #endif /* __NetBSD__ */
  10723. #ifdef __OpenBSD__
  10724.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10725. #endif /* __OpenBSD__ */
  10726. #ifdef __FreeBSD__
  10727.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10728. #endif /* __FreeBSD__ */
  10729. #ifdef __linux__
  10730.     makestr(&(optlist[noptlist++]),"__linux__");
  10731. #endif /* __linux__ */
  10732. #ifdef LINUX_HI_SPD
  10733.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10734. #endif /* LINUX_HI_SPD */
  10735. #ifdef LYNXOS
  10736.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10737. #endif /* LYNXOS */
  10738. #ifdef V7
  10739.     makestr(&(optlist[noptlist++]),"V7");
  10740. #endif /* V7 */
  10741. #ifdef AIX370
  10742.     makestr(&(optlist[noptlist++]),"AIX370");
  10743. #endif /* AIX370 */
  10744. #ifdef RTAIX
  10745.     makestr(&(optlist[noptlist++]),"RTAIX");
  10746. #endif /* RTAIX */
  10747. #ifdef HPUX
  10748.     makestr(&(optlist[noptlist++]),"HPUX");
  10749. #endif /* HPUX */
  10750. #ifdef HPUXPRE65
  10751.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10752. #endif /* HPUXPRE65 */
  10753. #ifdef DGUX
  10754.     makestr(&(optlist[noptlist++]),"DGUX");
  10755. #endif /* DGUX */
  10756. #ifdef DGUX430
  10757.     makestr(&(optlist[noptlist++]),"DGUX430");
  10758. #endif /* DGUX430 */
  10759. #ifdef DGUX540
  10760.     makestr(&(optlist[noptlist++]),"DGUX540");
  10761. #endif /* DGUX540 */
  10762. #ifdef DGUX543
  10763.     makestr(&(optlist[noptlist++]),"DGUX543");
  10764. #endif /* DGUX543 */
  10765. #ifdef DGUX54410
  10766.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10767. #endif /* DGUX54410 */
  10768. #ifdef DGUX54411
  10769.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10770. #endif /* DGUX54411 */
  10771. #ifdef sony_news
  10772.     makestr(&(optlist[noptlist++]),"sony_news");
  10773. #endif /* sony_news */
  10774. #ifdef CIE
  10775.     makestr(&(optlist[noptlist++]),"CIE");
  10776. #endif /* CIE */
  10777. #ifdef XENIX
  10778.     makestr(&(optlist[noptlist++]),"XENIX");
  10779. #endif /* XENIX */
  10780. #ifdef SCO_XENIX
  10781.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10782. #endif /* SCO_XENIX */
  10783. #ifdef ISIII
  10784.     makestr(&(optlist[noptlist++]),"ISIII");
  10785. #endif /* ISIII */
  10786. #ifdef I386IX
  10787.     makestr(&(optlist[noptlist++]),"I386IX");
  10788. #endif /* I386IX */
  10789. #ifdef RTU
  10790.     makestr(&(optlist[noptlist++]),"RTU");
  10791. #endif /* RTU */
  10792. #ifdef PROVX1
  10793.     makestr(&(optlist[noptlist++]),"PROVX1");
  10794. #endif /* PROVX1 */
  10795. #ifdef PYRAMID
  10796.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10797. #endif /* PYRAMID */
  10798. #ifdef TOWER1
  10799.     makestr(&(optlist[noptlist++]),"TOWER1");
  10800. #endif /* TOWER1 */
  10801. #ifdef UTEK
  10802.     makestr(&(optlist[noptlist++]),"UTEK");
  10803. #endif /* UTEK */
  10804. #ifdef ZILOG
  10805.     makestr(&(optlist[noptlist++]),"ZILOG");
  10806. #endif /* ZILOG */
  10807. #ifdef TRS16
  10808.     makestr(&(optlist[noptlist++]),"TRS16");
  10809. #endif /* TRS16 */
  10810. #ifdef MINIX
  10811.     makestr(&(optlist[noptlist++]),"MINIX");
  10812. #endif /* MINIX */
  10813. #ifdef MINIX2
  10814.     makestr(&(optlist[noptlist++]),"MINIX2");
  10815. #endif /* MINIX2 */
  10816. #ifdef MINIX3
  10817.     makestr(&(optlist[noptlist++]),"MINIX3");
  10818. #endif /* MINIX3 */
  10819. #ifdef C70
  10820.     makestr(&(optlist[noptlist++]),"C70");
  10821. #endif /* C70 */
  10822. #ifdef AIXPS2
  10823.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10824. #endif /* AIXPS2 */
  10825. #ifdef AIXRS
  10826.     makestr(&(optlist[noptlist++]),"AIXRS");
  10827. #endif /* AIXRS */
  10828. #ifdef UTSV
  10829.     makestr(&(optlist[noptlist++]),"UTSV");
  10830. #endif /* UTSV */
  10831. #ifdef ATTSV
  10832.     makestr(&(optlist[noptlist++]),"ATTSV");
  10833. #endif /* ATTSV */
  10834. #ifdef SVR3
  10835.     makestr(&(optlist[noptlist++]),"SVR3");
  10836. #endif /* SVR3 */
  10837. #ifdef SVR4
  10838.     makestr(&(optlist[noptlist++]),"SVR4");
  10839. #endif /* SVR4 */
  10840. #ifdef DELL_SVR4
  10841.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10842. #endif /* DELL_SVR4 */
  10843. #ifdef ICL_SVR4
  10844.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10845. #endif /* ICL_SVR4 */
  10846. #ifdef OSF
  10847.     makestr(&(optlist[noptlist++]),"OSF");
  10848. #endif /* OSF */
  10849. #ifdef OSF1
  10850.     makestr(&(optlist[noptlist++]),"OSF1");
  10851. #endif /* OSF1 */
  10852. #ifdef __OSF
  10853.     makestr(&(optlist[noptlist++]),"__OSF");
  10854. #endif /* __OSF */
  10855. #ifdef __OSF__
  10856.     makestr(&(optlist[noptlist++]),"__OSF__");
  10857. #endif /* __OSF__ */
  10858. #ifdef __osf__
  10859.     makestr(&(optlist[noptlist++]),"__osf__");
  10860. #endif /* __osf__ */
  10861. #ifdef __OSF1
  10862.     makestr(&(optlist[noptlist++]),"__OSF1");
  10863. #endif /* __OSF1 */
  10864. #ifdef __OSF1__
  10865.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10866. #endif /* __OSF1__ */
  10867. #ifdef PTX
  10868.     makestr(&(optlist[noptlist++]),"PTX");
  10869. #endif /* PTX */
  10870. #ifdef POSIX
  10871.     makestr(&(optlist[noptlist++]),"POSIX");
  10872. #endif /* POSIX */
  10873. #ifdef BSD44ORPOSIX
  10874.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10875. #endif /* BSD44ORPOSIX */
  10876. #ifdef SVORPOSIX
  10877.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10878. #endif /* SVORPOSIX */
  10879. #ifdef SVR4ORPOSIX
  10880.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10881. #endif /* SVR4ORPOSIX */
  10882. #ifdef OS2ORVMS
  10883.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10884. #endif /* OS2ORVMS */
  10885. #ifdef OS2ORUNIX
  10886.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10887. #endif /* OS2ORUNIX */
  10888. #ifdef VMSORUNIX
  10889.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10890. #endif /* VMSORUNIX */
  10891. #ifdef VMS64BIT
  10892.     makestr(&(optlist[noptlist++]),"VMS64BIT");    /* VMS on Alpha or IA64 */
  10893. #endif /* VMS64BIT */
  10894. #ifdef VMSI64
  10895.     makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
  10896. #endif /* VMSI64 */
  10897. #ifdef _POSIX_SOURCE
  10898.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10899. #endif /* _POSIX_SOURCE */
  10900. #ifdef _XOPEN_SOURCE
  10901.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10902. #endif
  10903. #ifdef _ALL_SOURCE
  10904.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10905. #endif
  10906. #ifdef _SVID3
  10907.     makestr(&(optlist[noptlist++]),"_SVID3");
  10908. #endif /* _SVID3 */
  10909. #ifdef Plan9
  10910.     makestr(&(optlist[noptlist++]),"Plan9");
  10911. #endif /* Plan9 */
  10912. #ifdef SOLARIS
  10913.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10914. #ifdef SOLARIS24
  10915.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10916. #endif /* SOLARIS24 */
  10917. #ifdef SOLARIS25
  10918.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10919. #endif /* SOLARIS25 */
  10920. #ifdef SOLARIS26
  10921.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10922. #endif /* SOLARIS26 */
  10923. #ifdef SOLARIS7
  10924.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10925. #endif /* SOLARIS7 */
  10926. #ifdef SOLARIS8
  10927.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10928. #endif /* SOLARIS8 */
  10929. #ifdef SOLARIS9
  10930.     makestr(&(optlist[noptlist++]),"SOLARIS9");
  10931. #endif /* SOLARIS9 */
  10932. #ifdef SOLARIS10
  10933.     makestr(&(optlist[noptlist++]),"SOLARIS10");
  10934. #endif /* SOLARIS10 */
  10935. #endif /* SOLARIS */
  10936.  
  10937. #ifdef SUNOS4
  10938.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10939. #endif /* SUNOS4 */
  10940. #ifdef SUN4S5
  10941.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10942. #endif /* SUN4S5 */
  10943. #ifdef IRIX
  10944.     makestr(&(optlist[noptlist++]),"IRIX");
  10945. #endif /* IRIX */
  10946. #ifdef ENCORE
  10947.     makestr(&(optlist[noptlist++]),"ENCORE");
  10948. #endif /* ENCORE */
  10949. #ifdef ultrix
  10950.     makestr(&(optlist[noptlist++]),"ultrix");
  10951. #endif
  10952. #ifdef sxaE50
  10953.     makestr(&(optlist[noptlist++]),"sxaE50");
  10954. #endif
  10955. #ifdef mips
  10956.     makestr(&(optlist[noptlist++]),"mips");
  10957. #endif
  10958. #ifdef MIPS
  10959.     makestr(&(optlist[noptlist++]),"MIPS");
  10960. #endif
  10961. #ifdef vax
  10962.     makestr(&(optlist[noptlist++]),"vax");
  10963. #endif
  10964. #ifdef VAX
  10965.     makestr(&(optlist[noptlist++]),"VAX");
  10966. #endif
  10967. #ifdef alpha
  10968.     makestr(&(optlist[noptlist++]),"alpha");
  10969. #endif
  10970. #ifdef ALPHA
  10971.     makestr(&(optlist[noptlist++]),"ALPHA");
  10972. #endif
  10973. #ifdef __ALPHA
  10974.     makestr(&(optlist[noptlist++]),"__ALPHA");
  10975. #endif
  10976. #ifdef __alpha
  10977.     makestr(&(optlist[noptlist++]),"__alpha");
  10978. #endif
  10979. #ifdef __AXP
  10980.     makestr(&(optlist[noptlist++]),"__AXP");
  10981. #endif
  10982. #ifdef AXP
  10983.     makestr(&(optlist[noptlist++]),"AXP");
  10984. #endif
  10985. #ifdef axp
  10986.     makestr(&(optlist[noptlist++]),"axp");
  10987. #endif
  10988. #ifdef __ALPHA__
  10989.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  10990. #endif
  10991. #ifdef __alpha__
  10992.     makestr(&(optlist[noptlist++]),"__alpha__");
  10993. #endif
  10994. #ifdef sun
  10995.     makestr(&(optlist[noptlist++]),"sun");
  10996. #endif
  10997. #ifdef sun3
  10998.     makestr(&(optlist[noptlist++]),"sun3");
  10999. #endif
  11000. #ifdef sun386
  11001.     makestr(&(optlist[noptlist++]),"sun386");
  11002. #endif
  11003. #ifdef _SUN
  11004.     makestr(&(optlist[noptlist++]),"_SUN");
  11005. #endif
  11006. #ifdef sun4
  11007.     makestr(&(optlist[noptlist++]),"sun4");
  11008. #endif
  11009. #ifdef sparc
  11010.     makestr(&(optlist[noptlist++]),"sparc");
  11011. #endif
  11012. #ifdef _CRAY
  11013.     makestr(&(optlist[noptlist++]),"_CRAY");
  11014. #endif /* _CRAY */
  11015. #ifdef NEXT33
  11016.     makestr(&(optlist[noptlist++]),"NEXT33");
  11017. #endif
  11018. #ifdef NEXT
  11019.     makestr(&(optlist[noptlist++]),"NEXT");
  11020. #endif
  11021. #ifdef NeXT
  11022.     makestr(&(optlist[noptlist++]),"NeXT");
  11023. #endif
  11024. #ifdef MACH
  11025.     makestr(&(optlist[noptlist++]),"MACH");
  11026. #endif
  11027.  
  11028. #ifdef MACOSX
  11029.     makestr(&(optlist[noptlist++]),"MACOSX");
  11030. #endif
  11031. #ifdef MACOSX10
  11032.     makestr(&(optlist[noptlist++]),"MACOSX10");
  11033. #endif
  11034. #ifdef MACOSX103
  11035.     makestr(&(optlist[noptlist++]),"MACOSX10e");
  11036. #endif
  11037. #ifdef COMMENT
  11038. /* not used */
  11039. #ifdef MACOSX103
  11040.     makestr(&(optlist[noptlist++]),"MACOSX103");
  11041. #endif
  11042. #endif    /* COMMENT */
  11043.  
  11044. #ifdef sgi
  11045.     makestr(&(optlist[noptlist++]),"sgi");
  11046. #endif
  11047. #ifdef M_SYS5
  11048.     makestr(&(optlist[noptlist++]),"M_SYS5");
  11049. #endif
  11050. #ifdef __SYSTEM_FIVE
  11051.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  11052. #endif
  11053. #ifdef sysV
  11054.     makestr(&(optlist[noptlist++]),"sysV");
  11055. #endif
  11056. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  11057.     makestr(&(optlist[noptlist++]),"M_XENIX");
  11058. #endif
  11059. #ifdef M_UNIX                           /* SCO UNIX */
  11060.     makestr(&(optlist[noptlist++]),"M_UNIX");
  11061. #endif
  11062. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  11063.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  11064. #endif
  11065. #ifdef CK_SCOV5
  11066.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  11067. #endif
  11068. #ifdef SCO_OSR504
  11069.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  11070. #endif
  11071. #ifdef M_IA64
  11072.     makestr(&(optlist[noptlist++]),"M_IA64");
  11073. #endif
  11074. #ifdef _M_IA64
  11075.     makestr(&(optlist[noptlist++]),"_M_IA64");
  11076. #endif
  11077. #ifdef ia64
  11078.     makestr(&(optlist[noptlist++]),"ia64");
  11079. #endif
  11080. #ifdef _ia64
  11081.     makestr(&(optlist[noptlist++]),"_ia64");
  11082. #endif
  11083. #ifdef _ia64_
  11084.     makestr(&(optlist[noptlist++]),"_ia64_");
  11085. #endif
  11086. #ifdef __ia64
  11087.     makestr(&(optlist[noptlist++]),"__ia64");
  11088. #endif
  11089. #ifdef M_I686
  11090.     makestr(&(optlist[noptlist++]),"M_I686");
  11091. #endif
  11092. #ifdef _M_I686
  11093.     makestr(&(optlist[noptlist++]),"_M_I686");
  11094. #endif
  11095. #ifdef i686
  11096.     makestr(&(optlist[noptlist++]),"i686");
  11097. #endif
  11098. #ifdef M_I586
  11099.     makestr(&(optlist[noptlist++]),"M_I586");
  11100. #endif
  11101. #ifdef _M_I586
  11102.     makestr(&(optlist[noptlist++]),"_M_I586");
  11103. #endif
  11104. #ifdef i586
  11105.     makestr(&(optlist[noptlist++]),"i586");
  11106. #endif
  11107. #ifdef M_I486
  11108.     makestr(&(optlist[noptlist++]),"M_I486");
  11109. #endif
  11110. #ifdef _M_I486
  11111.     makestr(&(optlist[noptlist++]),"_M_I486");
  11112. #endif
  11113. #ifdef i486
  11114.     makestr(&(optlist[noptlist++]),"i486");
  11115. #endif
  11116. #ifdef M_I386
  11117.     makestr(&(optlist[noptlist++]),"M_I386");
  11118. #endif
  11119. #ifdef _M_I386
  11120.     makestr(&(optlist[noptlist++]),"_M_I386");
  11121. #endif
  11122. #ifdef i386
  11123.     makestr(&(optlist[noptlist++]),"i386");
  11124. #endif
  11125. #ifdef __i386
  11126.     makestr(&(optlist[noptlist++]),"__i386");
  11127. #endif
  11128. #ifdef __x86
  11129.     makestr(&(optlist[noptlist++]),"__x86");
  11130. #endif
  11131. #ifdef __amd64
  11132.     makestr(&(optlist[noptlist++]),"__amd64");
  11133. #endif
  11134. #ifdef _ILP32
  11135.     makestr(&(optlist[noptlist++]),"_ILP32");
  11136. #endif
  11137. #ifdef _ILP64
  11138.     makestr(&(optlist[noptlist++]),"_ILP64");
  11139. #endif
  11140. #ifdef _LP32
  11141.     makestr(&(optlist[noptlist++]),"_LP32");
  11142. #endif
  11143. #ifdef _LP64
  11144.     makestr(&(optlist[noptlist++]),"_LP64");
  11145. #endif
  11146. #ifdef __LP32__
  11147.     makestr(&(optlist[noptlist++]),"__LP32__");
  11148. #endif
  11149. #ifdef __LP64__
  11150.     makestr(&(optlist[noptlist++]),"__LP64__");
  11151. #endif
  11152. #ifdef _XGP4_2
  11153.     makestr(&(optlist[noptlist++]),"_XGP4_2");
  11154. #endif
  11155. #ifdef __ppc__
  11156.     makestr(&(optlist[noptlist++]),"__ppc__");
  11157. #endif
  11158. #ifdef __ppc32__
  11159.     makestr(&(optlist[noptlist++]),"__ppc32__");
  11160. #endif
  11161. #ifdef __ppc64__
  11162.     makestr(&(optlist[noptlist++]),"__ppc64__");
  11163. #endif
  11164. #ifdef CK_64BIT
  11165.     makestr(&(optlist[noptlist++]),"CK_64BIT");
  11166. #endif
  11167. #ifdef i286
  11168.     makestr(&(optlist[noptlist++]),"i286");
  11169. #endif
  11170. #ifdef M_I286
  11171.     makestr(&(optlist[noptlist++]),"M_I286");
  11172. #endif
  11173. #ifdef __sparc
  11174.     makestr(&(optlist[noptlist++]),"__sparc");
  11175. #endif
  11176. #ifdef __sparcv8
  11177.     makestr(&(optlist[noptlist++]),"__sparcv8");
  11178. #endif
  11179. #ifdef __sparcv9
  11180.     makestr(&(optlist[noptlist++]),"__sparcv9");
  11181. #endif
  11182. #ifdef mc68000
  11183.     makestr(&(optlist[noptlist++]),"mc68000");
  11184. #endif
  11185. #ifdef mc68010
  11186.     makestr(&(optlist[noptlist++]),"mc68010");
  11187. #endif
  11188. #ifdef mc68020
  11189.     makestr(&(optlist[noptlist++]),"mc68020");
  11190. #endif
  11191. #ifdef mc68030
  11192.     makestr(&(optlist[noptlist++]),"mc68030");
  11193. #endif
  11194. #ifdef mc68040
  11195.     makestr(&(optlist[noptlist++]),"mc68040");
  11196. #endif
  11197. #ifdef M_68000
  11198.     makestr(&(optlist[noptlist++]),"M_68000");
  11199. #endif
  11200. #ifdef M_68010
  11201.     makestr(&(optlist[noptlist++]),"M_68010");
  11202. #endif
  11203. #ifdef M_68020
  11204.     makestr(&(optlist[noptlist++]),"M_68020");
  11205. #endif
  11206. #ifdef M_68030
  11207.     makestr(&(optlist[noptlist++]),"M_68030");
  11208. #endif
  11209. #ifdef M_68040
  11210.     makestr(&(optlist[noptlist++]),"M_68040");
  11211. #endif
  11212. #ifdef m68k
  11213.     makestr(&(optlist[noptlist++]),"m68k");
  11214. #endif
  11215. #ifdef m88k
  11216.     makestr(&(optlist[noptlist++]),"m88k");
  11217. #endif
  11218. #ifdef pdp11
  11219.     makestr(&(optlist[noptlist++]),"pdp11");
  11220. #endif
  11221. #ifdef iAPX
  11222.     makestr(&(optlist[noptlist++]),"iAPX");
  11223. #endif
  11224. #ifdef hpux
  11225.     makestr(&(optlist[noptlist++]),"hpux");
  11226. #endif
  11227. #ifdef __hpux
  11228.     makestr(&(optlist[noptlist++]),"__hpux");
  11229. #endif
  11230. #ifdef __hp9000s800
  11231.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  11232. #endif
  11233. #ifdef __hp9000s700
  11234.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  11235. #endif
  11236. #ifdef __hp9000s500
  11237.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  11238. #endif
  11239. #ifdef __hp9000s300
  11240.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  11241. #endif
  11242. #ifdef __hp9000s200
  11243.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  11244. #endif
  11245. #ifdef AIX
  11246.     makestr(&(optlist[noptlist++]),"AIX");
  11247. #endif
  11248. #ifdef _AIXFS
  11249.     makestr(&(optlist[noptlist++]),"_AIXFS");
  11250. #endif
  11251. #ifdef u370
  11252.     makestr(&(optlist[noptlist++]),"u370");
  11253. #endif
  11254. #ifdef u3b
  11255.     makestr(&(optlist[noptlist++]),"u3b");
  11256. #endif
  11257. #ifdef u3b2
  11258.     makestr(&(optlist[noptlist++]),"u3b2");
  11259. #endif
  11260. #ifdef multimax
  11261.     makestr(&(optlist[noptlist++]),"multimax");
  11262. #endif
  11263. #ifdef balance
  11264.     makestr(&(optlist[noptlist++]),"balance");
  11265. #endif
  11266. #ifdef ibmrt
  11267.     makestr(&(optlist[noptlist++]),"ibmrt");
  11268. #endif
  11269. #ifdef _IBMRT
  11270.     makestr(&(optlist[noptlist++]),"_IBMRT");
  11271. #endif
  11272. #ifdef ibmrs6000
  11273.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  11274. #endif
  11275. #ifdef _AIX
  11276.     makestr(&(optlist[noptlist++]),"_AIX");
  11277. #endif /* _AIX */
  11278. #ifdef _IBMR2
  11279.     makestr(&(optlist[noptlist++]),"_IBMR2");
  11280. #endif
  11281. #ifdef UNIXWARE
  11282.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  11283. #endif
  11284. #ifdef QNX
  11285.     makestr(&(optlist[noptlist++]),"QNX");
  11286. #ifdef __QNX__
  11287.     makestr(&(optlist[noptlist++]),"__QNX__");
  11288. #ifdef __16BIT__
  11289.     makestr(&(optlist[noptlist++]),"__16BIT__");
  11290. #endif
  11291. #ifdef CK_QNX16
  11292.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  11293. #endif
  11294. #ifdef __32BIT__
  11295.     makestr(&(optlist[noptlist++]),"__32BIT__");
  11296. #endif
  11297. #ifdef CK_QNX32
  11298.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  11299. #endif
  11300. #endif /* __QNX__ */
  11301. #endif /* QNX */
  11302.  
  11303. #ifdef QNX6
  11304.     makestr(&(optlist[noptlist++]),"QNX6");
  11305. #endif /* QNX6 */
  11306.  
  11307. #ifdef NEUTRINO
  11308.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  11309. #endif /* NEUTRINO */
  11310.  
  11311. #ifdef __STRICT_BSD__
  11312.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  11313. #endif
  11314. #ifdef __STRICT_ANSI__
  11315.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  11316. #endif
  11317. #ifdef _ANSI_C_SOURCE
  11318.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  11319. #endif
  11320. #ifdef __STDC__
  11321.     makestr(&(optlist[noptlist++]),"__STDC__");
  11322. #endif
  11323. #ifdef cplusplus
  11324.     makestr(&(optlist[noptlist++]),"cplusplus");
  11325. #endif
  11326. #ifdef __DECC
  11327.     makestr(&(optlist[noptlist++]),"__DECC");
  11328. #ifdef __DECC_VER
  11329.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  11330.     makestr(&(optlist[noptlist++]),line);
  11331. #endif /* __DECC_VER */
  11332. #endif /* __DECC */
  11333. #ifdef __CRTL_VER
  11334.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  11335.     makestr(&(optlist[noptlist++]),line);
  11336. #endif /* __CRTL_VER */
  11337. #ifdef __GNUC__                         /* gcc in ansi mode */
  11338.     makestr(&(optlist[noptlist++]),"__GNUC__");
  11339. #endif
  11340. #ifdef GNUC                             /* gcc in traditional mode */
  11341.     makestr(&(optlist[noptlist++]),"GNUC");
  11342. #endif
  11343. #ifdef __EGCS__                         /* egcs in ansi mode */
  11344.     makestr(&(optlist[noptlist++]),"__EGCS__");
  11345. #endif
  11346. #ifdef __egcs__                         /* egcs in ansi mode */
  11347.     makestr(&(optlist[noptlist++]),"__egcs__");
  11348. #endif
  11349. #ifdef __WATCOMC__
  11350.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  11351. #endif
  11352. #ifdef CK_ANSIC
  11353.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  11354. #endif
  11355. #ifdef CK_ANSILIBS
  11356.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  11357. #endif
  11358. #ifdef CKCONINTB4CB
  11359.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  11360. #endif /* CKCONINTB4CB */
  11361. #ifdef NOTERMCAP
  11362.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  11363. #endif /* NOTERMCAP */
  11364. #ifdef __GLIBC__
  11365.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  11366. #endif
  11367. #ifdef _SC_JOB_CONTROL
  11368.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  11369. #endif
  11370. #ifdef _POSIX_JOB_CONTROL
  11371.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  11372. #endif
  11373. #ifdef SIG_I
  11374.     makestr(&(optlist[noptlist++]),"SIG_I");
  11375. #endif /* SIG_I */
  11376. #ifdef SIG_V
  11377.     makestr(&(optlist[noptlist++]),"SIG_V");
  11378. #endif /* SIG_V */
  11379. #ifdef CK_POSIX_SIG
  11380.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  11381. #endif
  11382. #ifdef SVR3JC
  11383.     makestr(&(optlist[noptlist++]),"SVR3JC");
  11384. #endif
  11385. #ifdef _386BSD
  11386.     makestr(&(optlist[noptlist++]),"_386BSD");
  11387. #endif
  11388. #ifdef _BSD
  11389.     makestr(&(optlist[noptlist++]),"_BSD");
  11390. #endif
  11391. #ifdef USE_MEMCPY
  11392.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  11393. #endif /* USE_MEMCPY */
  11394. #ifdef USE_LSTAT
  11395.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  11396. #endif /* USE_LSTAT */
  11397. #ifdef TERMIOX
  11398.     makestr(&(optlist[noptlist++]),"TERMIOX");
  11399. #endif /* TERMIOX */
  11400. #ifdef STERMIOX
  11401.     makestr(&(optlist[noptlist++]),"STERMIOX");
  11402. #endif /* STERMIOX */
  11403. #ifdef CK_CURSES
  11404.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  11405. #endif /* CK_CURSES */
  11406. #ifdef CK_NEWTERM
  11407.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  11408. #endif /* CK_NEWTERM */
  11409. #ifdef CK_WREFRESH
  11410.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  11411. #endif /* CK_WREFRESH */
  11412. #ifdef CK_PCT_BAR
  11413.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  11414. #endif /* CK_PCT_BAR */
  11415. #ifdef CK_DTRCD
  11416.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  11417. #endif /* CK_DTRCD */
  11418. #ifdef CK_DTRCTS
  11419.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  11420. #endif /* CK_DTRCTS */
  11421. #ifdef CK_RTSCTS
  11422.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  11423. #endif /* CK_RTSCTS */
  11424. #ifdef POSIX_CRTSCTS
  11425.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  11426. #endif /* POSIX_CRTSCTS */
  11427. #ifdef FIXCRTSCTS
  11428.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  11429. #endif /* FIXCRTSCTS */
  11430. #ifdef HWPARITY
  11431.     makestr(&(optlist[noptlist++]),"HWPARITY");
  11432. #endif /* HWPARITY */
  11433. #ifdef CK_SYSINI
  11434. #ifdef CK_INI_A
  11435.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  11436.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11437.     makestr(&(optlist[noptlist++]),line);
  11438. #else
  11439. #ifdef CK_INI_B
  11440.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  11441.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11442.     makestr(&(optlist[noptlist++]),line);
  11443. #else
  11444.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  11445. #endif /* CK_INI_B */
  11446. #endif /* CK_INI_A */
  11447. #endif /* CK_DSYSINI */
  11448. #ifdef CK_DSYSINI
  11449.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  11450. #endif /* CK_DSYSINI */
  11451. #ifdef CK_TTGWSIZ
  11452.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  11453. #endif /* CK_TTGWSIZ */
  11454. #ifdef CK_NAWS
  11455.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  11456. #endif /* CK_NAWS */
  11457. #ifdef MDMHUP
  11458.     makestr(&(optlist[noptlist++]),"MDMHUP");
  11459. #endif /* MDMHUP */
  11460. #ifdef HUP_CLOSE_POSIX
  11461.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  11462. #endif /* HUP_CLOSE_POSIX */
  11463. #ifdef NO_HUP_CLOSE_POSIX
  11464.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  11465. #endif /* NO_HUP_CLOSE_POSIX */
  11466. #ifdef DCMDBUF
  11467.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  11468. #endif /* DCMDBUF */
  11469. #ifdef CK_RECALL
  11470.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  11471. #endif /* CK_RECALL */
  11472. #ifdef BROWSER
  11473.     makestr(&(optlist[noptlist++]),"BROWSER");
  11474. #endif /* BROWSER */
  11475. #ifdef CLSOPN
  11476.     makestr(&(optlist[noptlist++]),"CLSOPN");
  11477. #endif /* CLSOPN */
  11478. #ifdef STRATUS
  11479.     makestr(&(optlist[noptlist++]),"STRATUS");
  11480. #endif /* STRATUS */
  11481. #ifdef __VOS__
  11482.     makestr(&(optlist[noptlist++]),"__VOS__");
  11483. #endif /* __VOS__ */
  11484. #ifdef STRATUSX25
  11485.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  11486. #endif /* STRATUSX25 */
  11487. #ifdef OS2MOUSE
  11488.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  11489. #endif /* OS2MOUSE */
  11490. #ifdef CK_REXX
  11491.     makestr(&(optlist[noptlist++]),"CK_REXX");
  11492. #endif /* CK_REXX */
  11493. #ifdef CK_TIMERS
  11494.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  11495. #endif /* CK_TIMERS */
  11496. #ifdef TTSPDLIST
  11497.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  11498. #endif /* TTSPDLIST */
  11499. #ifdef CK_PERMS
  11500.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  11501. #endif /* CK_PERMS */
  11502. #ifdef CKTUNING
  11503.     makestr(&(optlist[noptlist++]),"CKTUNING");
  11504. #endif /* CKTUNING */
  11505. #ifdef NEWFTP
  11506.     makestr(&(optlist[noptlist++]),"NEWFTP");
  11507. #endif /* NEWFTP */
  11508. #ifdef SYSFTP
  11509.     makestr(&(optlist[noptlist++]),"SYSFTP");
  11510. #endif /* SYSFTP */
  11511. #ifdef NOFTP
  11512.     makestr(&(optlist[noptlist++]),"NOFTP");
  11513. #endif /* NOFTP */
  11514. #ifdef CKHTTP
  11515.     makestr(&(optlist[noptlist++]),"CKHTTP");
  11516. #endif /* CKHTTP */
  11517. #ifdef NOHTTP
  11518.     makestr(&(optlist[noptlist++]),"NOHTTP");
  11519. #endif /* NOHTTP */
  11520. #ifdef CKROOT
  11521.     makestr(&(optlist[noptlist++]),"CKROOT");
  11522. #endif /* CKROOT */
  11523. #ifdef CKREALPATH
  11524.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  11525. #endif /* CKREALPATH */
  11526. #ifdef STREAMING
  11527.     makestr(&(optlist[noptlist++]),"STREAMING");
  11528. #endif /* STREAMING */
  11529. #ifdef UNPREFIXZERO
  11530.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11531. #endif /* UNPREFIXZERO */
  11532. #ifdef CKREGEX
  11533.     makestr(&(optlist[noptlist++]),"CKREGEX");
  11534. #endif /* CKREGEX */
  11535. #ifdef ZXREWIND
  11536.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  11537. #endif /* ZXREWIND */
  11538. #ifdef CKSYSLOG
  11539.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11540. #endif /* CKSYSLOG */
  11541. #ifdef SYSLOGLEVEL
  11542.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11543.     makestr(&(optlist[noptlist++]),line);
  11544. #endif /* SYSLOGLEVEL */
  11545. #ifdef NOSEXP
  11546.     makestr(&(optlist[noptlist++]),"NOSEXP");
  11547. #endif /* NOSEXP */
  11548. #ifdef CKLEARN
  11549.     makestr(&(optlist[noptlist++]),"CKLEARN");
  11550. #else
  11551. #ifdef NOLOEARN
  11552.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  11553. #endif /* NOLOEARN */
  11554. #endif /* CKLEARN */
  11555.  
  11556. #ifdef NOFLOAT
  11557.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  11558. #else
  11559. #ifdef FNFLOAT
  11560.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  11561. #endif /* FNFLOAT */
  11562. #ifdef CKFLOAT
  11563. #ifdef GFTIMER
  11564.     makestr(&(optlist[noptlist++]),"GFTIMER");
  11565. #endif /* GFTIMER */
  11566. #ifdef CKFLOAT_S
  11567.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11568.     makestr(&(optlist[noptlist++]),line);
  11569. #else
  11570.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  11571. #endif /* CKFLOAT_S */
  11572. #endif /* CKFLOAT */
  11573. #endif /* NOFLOAT */
  11574.  
  11575. #ifdef SSH
  11576.     makestr(&(optlist[noptlist++]),"SSH");
  11577. #endif /* SSH */
  11578. #ifdef NETDLL
  11579.     makestr(&(optlist[noptlist++]),"NETDLL");
  11580. #endif /* NETDLL */
  11581. #ifdef NETFILE
  11582.     makestr(&(optlist[noptlist++]),"NETFILE");
  11583. #endif /* NETFILE */
  11584. #ifdef CK_TAPI
  11585.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  11586. #endif /* CK_TAPI */
  11587. #ifdef CK_SSL
  11588.     makestr(&(optlist[noptlist++]),"CK_SSL");
  11589. #ifdef OPENSSL_VERSION_TEXT
  11590.     ckmakmsg(line,LINBUFSIZ,
  11591.          "OPENSSL_VERSION_TEXT=","\"",OPENSSL_VERSION_TEXT,"\"");
  11592.     makestr(&(optlist[noptlist++]),line);
  11593. #endif    /* OPENSSL_VERSION_TEXT */
  11594. #endif /* CK_SSL */
  11595.     debug(F101,"initoptlist noptlist","",noptlist);
  11596.     sh_sort(optlist,NULL,noptlist,0,0,0);
  11597. }
  11598.  
  11599. int
  11600. shofea() {
  11601.     int i;
  11602.     int flag = 0;
  11603.     int lines = 1;
  11604. #ifdef FNFLOAT
  11605.     extern int fp_digits, fp_rounding;
  11606. #endif /* FNFLOAT */
  11607.     extern int byteorder;
  11608.     printf("%s\n",versio);
  11609.     if (inserver)
  11610.       return(1);
  11611.  
  11612.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11613.     initoptlist();
  11614.     debug(F101,"shofea noptlist","",noptlist);
  11615. #ifdef OS2
  11616. #ifdef NT
  11617. #ifdef _M_ALPHA
  11618.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11619. #else /* _M_ALPHA */
  11620. #ifdef _M_PPC
  11621.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11622. #else /* _M_PPC */
  11623. #ifdef _M_MRX000
  11624.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11625. #else /* _M_MRX000 */
  11626. #ifdef _M_IX86
  11627.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11628. #else /* _M_IX86 */
  11629.     UNKNOWN WINDOWS PLATFORM
  11630. #endif /* _M_IX86 */
  11631. #endif /* _M_MRX000 */
  11632. #endif /* _M_PPC */
  11633. #endif /* _M_ALPHA */
  11634. #else /* NT */
  11635. #ifdef M_I286
  11636.     printf("IBM OS/2 16-bit.\n");
  11637. #else
  11638.     printf("IBM OS/2 32-bit.\n");
  11639. #endif /* M_I286 */
  11640. #endif /* NT */
  11641.     lines++;
  11642. #endif /* OS2 */
  11643.     printf("\n");
  11644.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11645.     printf("Major optional features included:\n");
  11646.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11647.  
  11648.     if (sizeof(CK_OFF_T) == 8) {
  11649.     printf(" Large files and large integers (64 bits)\n");
  11650.         if (++lines > cmd_rows - 3) {
  11651.         if (!askmore()) return(1); else lines = 0;
  11652.     }
  11653.     }
  11654. #ifdef NETCONN
  11655.     printf(" Network support (type SHOW NET for further info)\n");
  11656.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11657. #ifdef IKS_OPTION
  11658.     printf(" Telnet Kermit Option\n");
  11659.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11660. #endif /* IKS_OPTION */
  11661. #ifdef CK_AUTHENTICATION
  11662.     printf(" Telnet Authentication Option\n");
  11663.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11664. #ifdef CK_KERBEROS
  11665. #ifdef KRB4
  11666. #ifdef KRB5
  11667.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11668.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11669. #else /* KRB5 */
  11670.     printf(" Kerberos(TM) IV authentication\n");
  11671.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11672. #endif /* KRB5 */
  11673. #else /* KRB4 */
  11674. #ifdef KRB5
  11675.     printf(" Kerberos(TM) V authentication\n");
  11676.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11677. #endif /* KRB5 */
  11678. #endif /* KRB4 */
  11679. #endif /* CK_KERBEROS */
  11680. #ifdef CK_SRP
  11681.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11682.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11683. #endif /* CK_SRP */
  11684. #ifdef CK_SSL
  11685.     printf(" Secure Sockets Layer (SSL)\n");
  11686.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11687.     printf(" Transport Layer Security (TLS)\n");
  11688.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11689. #endif /* CK_SSL */
  11690. #ifdef SSHBUILTIN
  11691.     printf(" Secure Shell (SSH) [internal]\n");
  11692.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11693. #endif /* SSHBUILTIN */
  11694. #ifdef SSHCMD
  11695.     printf(" Secure Shell (SSH) [external]\n");
  11696.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11697. #endif /* SSHCMD */
  11698. #ifdef CK_ENCRYPTION
  11699.     printf(" Telnet Encryption Option\n");
  11700.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11701. #ifdef CK_DES
  11702.     printf(" Telnet DES Encryption\n");
  11703.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11704. #endif /* CK_DES */
  11705. #ifdef CK_CAST
  11706.     printf(" Telnet CAST Encryption\n");
  11707.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11708. #endif /* CK_CAST */
  11709.  
  11710. #ifdef CK_KERBEROS
  11711. #ifdef KRB5
  11712. #ifdef ALLOW_KRB_3DES_ENCRYPT
  11713.     printf(" Kerberos 3DES/AES Telnet Encryption\n");
  11714.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11715. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11716. #endif /* KRB5 */
  11717. #endif /* CK_KERBEROS */
  11718.  
  11719. #endif /* CK_ENCRYPTION */
  11720. #endif /* CK_AUTHENTICATION */
  11721. #ifdef CK_FORWARD_X
  11722.     printf(" X Windows forwarding\n");
  11723.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11724. #endif /* CK_FORWARD_X */
  11725. #ifdef TN_COMPORT
  11726.     printf(" Telnet Remote Com Port Control Option\n");
  11727.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11728. #endif /* TN_COMPORT */
  11729. #ifdef CK_SOCKS
  11730. #ifdef CK_SOCKS5
  11731.     printf(" SOCKS 5\n");
  11732.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11733. #else /* CK_SOCKS5 */
  11734.     printf(" SOCKS 4\n");
  11735.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11736. #endif /* CK_SOCKS5 */
  11737. #endif /* CK_SOCKS */
  11738. #ifdef NEWFTP
  11739.     printf(" Built-in FTP client\n");
  11740.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11741. #endif /* NEWFTP */
  11742. #ifdef CKHTTP
  11743.     printf(" Built-in HTTP client\n");
  11744.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11745. #endif /* CKHTTP */
  11746. #endif /* NETCONN */
  11747.  
  11748. #ifdef CK_RTSCTS
  11749.     printf(" Hardware flow control\n");
  11750.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11751. #endif /* CK_RTSCTS */
  11752.  
  11753. #ifdef CK_XYZ
  11754. #ifdef XYZ_INTERNAL
  11755.     printf(" Built-in XYZMODEM protocols\n");
  11756. #else
  11757.     printf(" External XYZMODEM protocol support\n");
  11758. #endif /* XYZ_INTERNAL */
  11759.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11760. #endif /* CK_XYZ */
  11761.  
  11762. #ifndef NOCSETS
  11763.     printf(" Latin-1 (West European) character-set translation\n");
  11764.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11765. #ifdef LATIN2
  11766.     printf(" Latin-2 (East European) character-set translation\n");
  11767.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11768. #endif /* LATIN2 */
  11769. #ifdef CYRILLIC
  11770.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11771.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11772. #endif /* CYRILLIC */
  11773. #ifdef GREEK
  11774.     printf(" Greek character-set translation\n");
  11775.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11776. #endif /* GREEK */
  11777. #ifdef HEBREW
  11778.     printf(" Hebrew character-set translation\n");
  11779.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11780. #endif /* HEBREW */
  11781. #ifdef KANJI
  11782.     printf(" Japanese character-set translation\n");
  11783.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11784. #endif /* KANJI */
  11785. #ifdef UNICODE
  11786.     printf(" Unicode character-set translation\n");
  11787.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11788. #endif /* UNICODE */
  11789. #ifdef CKOUNI
  11790.     if (isunicode())
  11791.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11792.     else
  11793.       printf(" Unicode translation for Terminal Character-Sets\n");
  11794.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11795. #endif /* CKOUNI */
  11796. #endif /* NOCSETS */
  11797.  
  11798. #ifdef NETPTY
  11799.     printf(" Pseudoterminal control\n");
  11800.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11801. #endif /* NETPTY */
  11802.  
  11803. #ifdef CK_REDIR
  11804.     printf(" REDIRECT command\n");
  11805.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11806. #endif /* CK_REDIR */
  11807.  
  11808. #ifdef CK_RESEND
  11809.     printf(" RESEND command\n");
  11810.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11811. #endif /* CK_RESEND */
  11812.  
  11813. #ifndef NOXFER
  11814. #ifdef CK_CURSES
  11815.     printf(" Fullscreen file transfer display\n");
  11816.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11817. #endif /* CK_CURSES */
  11818. #endif /* NOXFER */
  11819.  
  11820. #ifdef CK_SPEED
  11821.     printf(" Control-character unprefixing\n");
  11822.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11823. #endif /* CK_SPEED */
  11824.  
  11825. #ifdef STREAMING
  11826.     printf(" Streaming\n");
  11827.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11828. #endif /* STREAMING */
  11829.  
  11830. #ifdef CK_AUTODL
  11831.     printf(" Autodownload\n");
  11832.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11833. #endif /* CK_AUTODL */
  11834.  
  11835. #ifdef OS2MOUSE
  11836.     printf(" Mouse support\n");
  11837.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11838. #endif /* OS2MOUSE */
  11839.  
  11840. #ifdef CK_REXX
  11841.     printf(" REXX script language interface\n");
  11842.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11843. #endif /* CK_REXX */
  11844.  
  11845. #ifdef IKSD
  11846. #ifdef CK_LOGIN
  11847.     printf(" Internet Kermit Service with user login support\n");
  11848. #else /* CK_LOGIN */
  11849.     printf(" Internet Kermit Service without user login support\n");
  11850. #endif /* CK_LOGIN */
  11851.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11852. #endif /* IKSD */
  11853.  
  11854.     printf("\n");
  11855.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11856.     printf("Major optional features not included:\n");
  11857.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11858.  
  11859.     if (sizeof(CK_OFF_T) <= 4) {
  11860.     printf(" No large files or large integers\n");
  11861.         if (++lines > cmd_rows - 3) {
  11862.         if (!askmore()) return(1); else lines = 0;
  11863.     }
  11864.     }
  11865.  
  11866. #ifdef NOXFER
  11867.     printf(" No file-transfer protocols\n");
  11868.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11869.     flag = 1;
  11870. #else
  11871. #ifndef CK_CURSES
  11872. #ifndef MAC
  11873.     printf(" No fullscreen file transfer display\n");
  11874.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11875.     flag = 1;
  11876. #endif /* MAC */
  11877. #endif /* CK_CURSES */
  11878.  
  11879. #ifdef NOSERVER
  11880.     printf(" No server mode\n");
  11881.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11882.     flag = 1;
  11883. #endif /* NOSERVER */
  11884.  
  11885. #ifndef CK_SPEED
  11886.     printf(" No control-character unprefixing\n");
  11887.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11888.     flag = 1;
  11889. #endif /* CK_SPEED */
  11890.  
  11891. #ifndef STREAMING
  11892.     printf(" No streaming\n");
  11893.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11894.     flag = 1;
  11895. #endif /* STREAMING */
  11896.  
  11897. #ifndef CK_AUTODL
  11898.     printf(" No autodownload\n");
  11899.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11900.     flag = 1;
  11901. #endif /* CK_AUTODL */
  11902.  
  11903. #ifndef CK_XYZ
  11904.     printf(" No built-in XYZMODEM protocols\n");
  11905.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11906.     flag = 1;
  11907. #endif /* CK_XYZ */
  11908.  
  11909. #ifdef NOTLOG
  11910.     printf(" No transaction log\n");
  11911.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11912.     flag = 1;
  11913. #endif /* NOTLOG */
  11914. #endif /* NOXFER */
  11915.  
  11916. #ifdef NODEBUG
  11917.     printf(" No debugging\n");
  11918.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11919.     flag = 1;
  11920. #endif /* NODEBUG */
  11921.  
  11922. #ifdef NOHELP
  11923.     printf(" No built-in help\n");
  11924.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11925.     flag = 1;
  11926. #endif /* NOHELP */
  11927.  
  11928. #ifdef NOLOCAL
  11929.     printf(" No making connections\n");
  11930.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11931.     flag = 1;
  11932. #else
  11933. #ifndef NETCONN
  11934.     printf(" No network support\n");
  11935.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11936.     flag = 1;
  11937. #else /* NETCONN */
  11938. #ifndef IKS_OPTION
  11939.     printf(" No Telnet Kermit Option\n");
  11940.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11941.     flag = 1;
  11942. #endif /* IKS_OPTION */
  11943. #endif /* NETCONN */
  11944.  
  11945. #ifdef NOSSH
  11946.     printf(" No Secure Shell (SSH)\n");
  11947.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11948. #endif /* NOSSH */
  11949. #ifndef CK_AUTHENTICATION
  11950.     printf(" No Kerberos(TM) authentication\n");
  11951.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11952.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11953.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11954.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11955.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11956.     printf(" No Transport Layer Security (TLS) protocol\n");
  11957.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11958.     printf(" No encryption\n");
  11959.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11960.     flag = 1;
  11961. #else /* CK_AUTHENTICATION */
  11962. #ifndef CK_KERBEROS
  11963.     printf(" No Kerberos(TM) authentication\n");
  11964.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11965.     flag = 1;
  11966. #else /* CK_KERBEROS */
  11967. #ifndef KRB4
  11968.     printf(" No Kerberos(TM) IV authentication\n");
  11969.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11970.     flag = 1;
  11971. #endif /* KRB4 */
  11972. #ifndef KRB5
  11973.     printf(" No Kerberos(TM) V authentication\n");
  11974.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11975.     flag = 1;
  11976. #endif /* KRB5 */
  11977. #endif /* CK_KERBEROS */
  11978. #ifndef CK_SRP
  11979.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11980.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11981.     flag = 1;
  11982. #endif /* CK_SRP */
  11983. #ifndef CK_SSL
  11984.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11985.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11986.     printf(" No Transport Layer Security (TLS) protocol\n");
  11987.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11988.     flag = 1;
  11989. #endif /* CK_SSL */
  11990. #ifndef CK_ENCRYPTION
  11991.     printf(" No Telnet Encryption Option\n");
  11992.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11993.     flag = 1;
  11994. #else /* CK_ENCRYPTION */
  11995. #ifndef OS2
  11996. #ifndef CK_DES
  11997.     printf(" No Telnet DES encryption\n");
  11998.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11999.     flag = 1;
  12000. #endif /* CK_DES */
  12001. #ifndef CK_CAST
  12002.     printf(" No Telnet CAST encryption\n");
  12003.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12004.     flag = 1;
  12005. #endif /* CK_CAST */
  12006.  
  12007. #ifdef COMMENT
  12008. #ifdef CK_KERBEROS
  12009. #ifdef KRB5
  12010. #ifndef ALLOW_KRB_3DES_ENCRYPT
  12011.     printf(" No Kerberos 3DES/AES Telnet Encryption\n");
  12012.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12013. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  12014. #endif /* KRB5 */
  12015. #endif /* CK_KERBEROS */
  12016. #endif /* COMMENT */
  12017.  
  12018. #endif /* OS2 */
  12019. #endif /* CK_ENCRYPTION */
  12020. #endif /* CK_AUTHENTICATION */
  12021. #ifndef CK_FORWARD_X
  12022.     printf(" No X Windows forwarding\n");
  12023.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12024. #endif /* CK_FORWARD_X */
  12025. #ifndef TN_COMPORT
  12026.     printf(" No Telnet Remote Com Port Control Option\n");
  12027.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12028. #endif /* TN_COMPORT */
  12029. #ifndef CK_SOCKS
  12030.     printf(" No SOCKS\n");
  12031.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12032. #endif /* CK_SOCKS */
  12033. #ifndef NEWFTP
  12034.     printf(" No built-in FTP client\n");
  12035.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12036. #endif /* NEWFTP */
  12037. #ifdef NOHTTP
  12038.     printf(" No built-in HTTP client\n");
  12039.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12040. #endif /* NOHTTP */
  12041.  
  12042. #ifdef NODIAL
  12043.     printf(" No DIAL command\n");
  12044.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12045.     flag = 1;
  12046. #else
  12047. #ifdef MINIDIAL
  12048.     printf(" Support for most modem types excluded\n");
  12049.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12050.     flag = 1;
  12051. #endif /* MINIDIAL */
  12052. #endif /* NODIAL */
  12053. #endif /* NOLOCAL */
  12054.  
  12055. #ifndef CK_RTSCTS
  12056. #ifndef MAC
  12057.     printf(" No hardware flow control\n");
  12058.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12059.     flag = 1;
  12060. #endif /* MAC */
  12061. #endif /* CK_RTSCTS */
  12062.  
  12063. #ifdef NOXMIT
  12064.     printf(" No TRANSMIT command\n");
  12065.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12066.     flag = 1;
  12067. #endif /* NOXMIT */
  12068.  
  12069. #ifdef NOSCRIPT
  12070.     printf(" No SCRIPT command\n");
  12071.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12072.     flag = 1;
  12073. #endif /* NOSCRIPT */
  12074.  
  12075. #ifdef NOSPL
  12076.     printf(" No script programming features\n");
  12077.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12078.     flag = 1;
  12079. #endif /* NOSPL */
  12080.  
  12081. #ifdef NOCSETS
  12082.     printf(" No character-set translation\n");
  12083.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12084.     flag = 1;
  12085. #else
  12086.  
  12087. #ifndef LATIN2
  12088.     printf(" No Latin-2 character-set translation\n");
  12089.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12090.     flag = 1;
  12091. #endif /* LATIN2 */
  12092.  
  12093. #ifdef NOGREEK
  12094.     printf(" No Greek character-set translation\n");
  12095.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12096.     flag = 1;
  12097. #endif /* NOGREEK */
  12098.  
  12099. #ifdef NOHEBREW
  12100.     printf(" No Hebrew character-set translation\n");
  12101.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12102.     flag = 1;
  12103. #endif /* NOHEBREW */
  12104.  
  12105. #ifdef NOUNICODE
  12106.     printf(" No Unicode character-set translation\n");
  12107.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12108.     flag = 1;
  12109. #endif /* NOUNICODE */
  12110.  
  12111. #ifdef NOCYRIL
  12112.     printf(" No Cyrillic character-set translation\n");
  12113.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12114.     flag = 1;
  12115. #endif /* NOCYRIL */
  12116.  
  12117. #ifndef KANJI
  12118.     printf(" No Kanji character-set translation\n");
  12119.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12120.     flag = 1;
  12121. #endif /* KANJI */
  12122. #endif /* NOCSETS */
  12123.  
  12124. #ifdef NOCMDL
  12125.     printf(" No command-line arguments\n");
  12126.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12127.     flag = 1;
  12128. #endif /* NOCMDL */
  12129.  
  12130. #ifdef NOPUSH
  12131.     printf(" No escape to system\n");
  12132.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12133.     flag = 1;
  12134. #endif /* NOPUSH */
  12135.  
  12136. #ifdef NOJC
  12137. #ifdef UNIX
  12138.     printf(" No UNIX job control\n");
  12139.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12140.     flag = 1;
  12141. #endif /* UNIX */
  12142. #endif /* NOJC */
  12143.  
  12144. #ifdef NOSETKEY
  12145.     printf(" No SET KEY command\n");
  12146.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12147.     flag = 1;
  12148. #endif /* NOSETKEY */
  12149.  
  12150. #ifndef CK_REDIR
  12151.     printf(" No REDIRECT or PIPE command\n");
  12152.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12153.     flag = 1;
  12154. #endif /* CK_REDIR */
  12155.  
  12156. #ifdef UNIX
  12157. #ifndef NETPTY
  12158.     printf(" No pseudoterminal control\n");
  12159.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12160.     flag = 1;
  12161. #endif /* NETPTY */
  12162. #endif /* UNIX */
  12163.  
  12164. #ifndef CK_RESEND
  12165.     printf(" No RESEND command\n");
  12166.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12167.     flag = 1;
  12168. #endif /* CK_RESEND */
  12169.  
  12170. #ifdef OS2
  12171. #ifdef __32BIT__
  12172. #ifndef OS2MOUSE
  12173.     printf(" No Mouse support\n");
  12174.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12175.     flag = 1;
  12176. #endif /* __32BIT__ */
  12177. #endif /* OS2 */
  12178. #endif /* OS2MOUSE */
  12179.  
  12180. #ifdef OS2
  12181. #ifndef NT
  12182. #ifndef CK_REXX
  12183.     printf(" No REXX script language interface\n");
  12184.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12185.     flag = 1;
  12186. #endif /* CK_REXX */
  12187. #endif /* NT */
  12188. #endif /* OS2 */
  12189.  
  12190. #ifndef IKSD
  12191.     printf(" No Internet Kermit Service\n");
  12192.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12193.     flag = 1;
  12194. #endif /* IKSD */
  12195.  
  12196.     if (flag == 0) {
  12197.         printf(" None\n");
  12198.         if (++lines > cmd_rows - 3)
  12199.           { if (!askmore()) return(1); else lines = 0; }
  12200.     }
  12201.     printf("\n");
  12202.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12203.  
  12204. #ifdef CK_UTSNAME
  12205.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12206.     printf("Host info:\n");
  12207.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12208.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  12209.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12210.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  12211.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12212.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  12213.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12214.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  12215.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12216.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  12217.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12218.     printf("\n");
  12219.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12220. #endif /* CK_UTSNAME */
  12221.  
  12222. /*
  12223.   Print compile-time (-D) options, as well as C preprocessor
  12224.   predefined symbols that might affect us...
  12225. */
  12226. #ifdef KTARGET
  12227.     {
  12228.         char * s;                       /* Makefile target */
  12229.         s = KTARGET;
  12230.         if (!s) s = "";
  12231.         if (!*s) s = "(unknown)";
  12232.         printf("\n");
  12233.         if (++lines > cmd_rows - 3) {
  12234.             if (!askmore()) return(1); else lines = 0;
  12235.         }
  12236.         printf("Target: %s\n", s);
  12237.         if (++lines > cmd_rows - 3) {
  12238.             if (!askmore()) return(1); else lines = 0;
  12239.         }
  12240.     }
  12241. #endif /* KTARGET */
  12242.  
  12243. #ifdef __VERSION__
  12244. #ifdef __GNUC__
  12245.     printf("GCC version: %s\n", __VERSION__);
  12246. #else
  12247.     printf("Compiler version: %s\n", __VERSION__);
  12248. #endif /* __GNUC__ */
  12249.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12250. #endif /* __VERSION__ */
  12251.  
  12252. #ifdef __DATE__                         /* GNU and other ANSI */
  12253. #ifdef __TIME__
  12254.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  12255. #else
  12256.     printf("Compiled %s, options:\n", __DATE__);
  12257. #endif /* __TIME__ */
  12258. #else /* !__DATE__ */
  12259.     printf("Compiler options:\n");
  12260. #endif /* __DATE__ */
  12261.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12262.  
  12263.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  12264.       if (!prtopt(&lines,optlist[i]))
  12265.         return(0);
  12266.  
  12267.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12268.  
  12269. /* Sizes of data types */
  12270.  
  12271.     ckmakmsg(line,
  12272.              LINBUFSIZ,
  12273.              "byte order: ",
  12274.              byteorder ? "little" : "big",
  12275.              " endian",
  12276.              NULL
  12277.              );
  12278.     if (!prtopt(&lines,line)) return(0);
  12279.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12280.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  12281.     if (!prtopt(&lines,line)) return(0);
  12282.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  12283.     if (!prtopt(&lines,line)) return(0);
  12284.  
  12285. #ifdef COMMENT
  12286. #ifdef CK_LONGLONG
  12287.     sprintf(line,"long long=%ld",sizeof(long long)); /* SAFE */
  12288.     if (!prtopt(&lines,line)) return(0);
  12289. #endif /* CK_LONGLONG */
  12290. #endif    /* COMMENT */
  12291.  
  12292. #ifndef OS2
  12293.     /* Windows doesn't have off_t */
  12294.     sprintf(line,"off_t=%ld",sizeof(off_t)); /* SAFE */
  12295.     if (!prtopt(&lines,line)) return(0);
  12296. #endif /* OS2 */
  12297.  
  12298.     sprintf(line,"CK_OFF_T=%ld",sizeof(CK_OFF_T)); /* SAFE */
  12299.     if (!prtopt(&lines,line)) return(0);
  12300.  
  12301. #ifdef BIGBUFOK
  12302.     sprintf(line,"size_t=%ld",sizeof(size_t)); /* SAFE */
  12303.     if (!prtopt(&lines,line)) return(0);
  12304. #endif /* BIGBUFOK */
  12305.  
  12306.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  12307.     if (!prtopt(&lines,line)) return(0);
  12308.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  12309.     if (!prtopt(&lines,line)) return(0);
  12310.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  12311.     if (!prtopt(&lines,line)) return(0);
  12312.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  12313.     if (!prtopt(&lines,line)) return(0);
  12314.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  12315.     if (!prtopt(&lines,line)) return(0);
  12316. #ifdef FNFLOAT
  12317.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12318.     if (!prtopt(&lines,"floating-point:")) return(0);
  12319.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  12320.     if (!prtopt(&lines,line)) return(0);
  12321.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  12322.     if (!prtopt(&lines,line)) return(0);
  12323. #endif /* FNFLOAT */
  12324.  
  12325.     prtopt(&lines,"");
  12326.     return(0);
  12327. }
  12328. #endif /* NOSHOW */
  12329. #endif /* NOICP */
  12330.