home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckuus5.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  384KB  |  12,131 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, 2005,
  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;
  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 NOSERVER
  173. extern char * x_user, * x_passwd, * x_acct;
  174. #endif /* NOSERVER */
  175.  
  176. #ifdef CKLOGDIAL
  177. extern int dialog;
  178. extern char diafil[];
  179. #endif /* CKLOGDIAL */
  180.  
  181. #ifdef CKROOT
  182. extern int ckrooterr;
  183. #endif /* CKROOT */
  184.  
  185. #ifndef NOSPL
  186. extern int cfilef, xxdot;
  187. extern char cmdfil[];
  188.  
  189. struct localvar * localhead[CMDSTKL];
  190. struct localvar * localtail = NULL;
  191. struct localvar * localnext = NULL;
  192.  
  193. _PROTOTYP( VOID shosexp, (void) );
  194. _PROTOTYP( static VOID shoinput, (void) );
  195. _PROTOTYP( static char gettok,   (void) );
  196. _PROTOTYP( static VOID factor,   (void) );
  197. _PROTOTYP( static VOID term,     (void) );
  198. _PROTOTYP( static VOID termp,    (void) );
  199. _PROTOTYP( static VOID exprp,    (void) );
  200. _PROTOTYP( static VOID expr,     (void) );
  201. _PROTOTYP( static VOID simple,   (void) );
  202. _PROTOTYP( static VOID simpler,  (void) );
  203. _PROTOTYP( static VOID simplest, (void) );
  204. _PROTOTYP( static CK_OFF_T xparse,   (void) );
  205. #endif /* NOSPL */
  206. #ifndef NOSHOW
  207. _PROTOTYP( int sho_iks, (void) );
  208. #endif /* NOSHOW */
  209.  
  210. #ifdef MAC
  211. char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
  212. char * ikprompt = "IKSD>";
  213. #else  /* Not MAC */
  214. #ifdef NOSPL
  215. #ifdef OS2
  216. char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
  217. char * ikprompt = "IKSD> ";
  218. #else
  219. char * ckprompt = "C-Kermit>";
  220. char * ikprompt = "IKSD>";
  221. #endif /* NT */
  222. #else  /* NOSPL */
  223. #ifdef OS2
  224. /* Default prompt for OS/2 and Win32 */
  225. #ifdef NT
  226. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
  227. char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
  228. #else  /* NT */
  229. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  230. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  231. #endif /* NT */
  232. #else  /* OS2 */
  233. #ifdef VMS
  234. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  235. char * ikprompt = "\\v(dir) IKSD>";
  236. #else
  237. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  238. char * ikprompt = "(\\v(dir)) IKSD>";
  239. #endif /* VMS */
  240. #endif /* NT */
  241. #endif /* NOSPL */
  242. #endif /* MAC */
  243.  
  244. #ifndef CCHMAXPATH
  245. #define CCHMAXPATH 257
  246. #endif /* CCHMAXPATH */
  247. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  248.  
  249. #ifdef TNCODE
  250. extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
  251. #endif /* TNCODE */
  252.  
  253. #ifndef NOKVERBS
  254. extern struct keytab kverbs[];          /* Table of \Kverbs */
  255. extern int nkverbs;                     /* Number of \Kverbs */
  256. #endif /* NOKVERBS */
  257.  
  258. #ifndef NOPUSH
  259. extern int nopush;
  260. #endif /* NOPUSH */
  261.  
  262. #ifdef CK_RECALL
  263. extern int cm_recall;
  264. #endif /* CK_RECALL */
  265.  
  266. extern char *ccntab[];
  267.  
  268. /* Printer stuff */
  269.  
  270. extern char *printername;
  271. extern int printpipe;
  272. #ifdef BPRINT
  273. extern int printbidi, pportparity, pportflow;
  274. extern long pportspeed;
  275. #endif /* BPRINT */
  276.  
  277. #ifdef OS2
  278. _PROTOTYP (int os2getcp, (void) );
  279. _PROTOTYP (int os2getcplist, (int *, int) );
  280. #ifdef OS2MOUSE
  281. extern int tt_mouse;
  282. #endif /* OS2MOUSE */
  283. extern int tt_update, tt_updmode, updmode, tt_utf8;
  284. #ifndef IKSDONLY
  285. extern int tt_status[];
  286. #endif /* IKSDONLY */
  287. #ifdef PCFONTS
  288. extern struct keytab term_font[];
  289. #else
  290. #ifdef KUI
  291. extern struct keytab * term_font;
  292. #endif /* KUI */
  293. #endif /* PCFONTS */
  294. extern int ntermfont, tt_font, tt_font_size;
  295. extern unsigned char colornormal, colorunderline, colorstatus,
  296.     colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  297.     colorreverse, colorcmd, coloritalic;
  298. extern int priority;
  299. extern struct keytab prtytab[];
  300. extern int nprty;
  301. char * cmdmac = NULL;
  302. #endif /* OS2 */
  303.  
  304. #ifdef VMS
  305. _PROTOTYP (int zkermini, (char *, int, char *) );
  306. #endif /* VMS */
  307.  
  308. extern long vernum;
  309. extern int inecho, insilence, inbufsize, nvars, inintr;
  310. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  311.  *cknetv, *clcmds;
  312. #ifdef OS2
  313. extern char *ckyv;
  314. #endif /* OS2 */
  315. #ifdef CK_AUTHENTICATION
  316. extern char * ckathv;
  317. #endif /* CK_AUTHENTICATION */
  318. #ifdef CK_SSL
  319. extern char * cksslv;
  320. #endif /* CK_SSL */
  321. #ifdef CK_ENCRYPTION
  322. #ifndef CRYPT_DLL
  323. extern char * ckcrpv;
  324. #endif /* CRYPT_DLL */
  325. #endif /* CK_ENCRYPTION */
  326.  
  327. #ifdef SSHBUILTIN
  328. extern char *cksshv;
  329. #ifdef SFTP_BUILTIN
  330. extern char *cksftpv;
  331. #endif /* SFTP_BUILTIN */
  332. #endif /* SSHBUILTIN */
  333.  
  334. #ifdef TNCODE
  335. extern char *cktelv;
  336. #endif /* TNCODE */
  337. #ifndef NOFTP
  338. #ifndef SYSFTP
  339. extern char * ckftpv;
  340. #endif /* SYSFTP */
  341. #endif /* NOFTP */
  342.  
  343. extern int srvidl;
  344.  
  345. #ifdef OS2
  346. extern char *ckonetv;
  347. extern int interm;
  348. #ifdef CK_NETBIOS
  349. extern char *ckonbiv;
  350. #endif /* CK_NETBIOS */
  351. #ifdef OS2MOUSE
  352. extern char *ckomouv;
  353. #endif /* OS2MOUSE */
  354. #endif /* OS2 */
  355.  
  356. #ifndef NOLOCAL
  357. extern char *connv;
  358. #endif /* NOLOCAL */
  359. #ifndef NODIAL
  360. extern char *dialv;
  361. #endif /* NODIAL */
  362. #ifndef NOSCRIPT
  363. extern char *loginv;
  364. extern int secho;
  365. #endif /* NOSCRIPT */
  366.  
  367. #ifndef NODIAL
  368. extern int nmdm, dirline;
  369. extern struct keytab mdmtab[];
  370. #endif /* NODIAL */
  371.  
  372. extern int network, nettype, ttnproto;
  373.  
  374. #ifdef OS2
  375. #ifndef NOTERM
  376. /* SET TERMINAL items... */
  377. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  378. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  379. extern char answerback[];
  380. extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
  381. extern int max_tt;
  382. #endif /* NOTERM */
  383. #endif /* OS2 */
  384.  
  385. _PROTOTYP( VOID shotrm, (void) );
  386. _PROTOTYP( int shofea, (void) );
  387.  
  388. #ifdef OS2
  389. extern int tt_rows[], tt_cols[];
  390. #else /* OS2 */
  391. extern int tt_rows, tt_cols;
  392. #endif /* OS2 */
  393. extern int cmd_rows, cmd_cols;
  394.  
  395. #ifdef CK_TMPDIR
  396. extern int f_tmpdir;                    /* Directory changed temporarily */
  397. extern char savdir[];                   /* Temporary directory */
  398. #endif /* CK_TMPDIR */
  399.  
  400. #ifndef NOLOCAL
  401. extern int tt_crd, tt_lfd, tt_escape;
  402. #endif /* NOLOCAL */
  403.  
  404. #ifndef NOCSETS
  405. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  406. extern struct keytab fcstab[];
  407. extern struct csinfo fcsinfo[];
  408. #ifndef MAC
  409. extern struct keytab ttcstab[];
  410. #endif /* MAC */
  411. #endif /* NOCSETS */
  412.  
  413. extern long speed;
  414.  
  415. #ifndef NOXMIT
  416. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  417. extern char xmitbuf[];
  418. #endif /* NOXMIT */
  419.  
  420. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  421.  
  422. #ifdef DCMDBUF
  423. extern char *cmdbuf, *atmbuf;           /* Command buffers */
  424. #ifndef NOSPL
  425. extern char *savbuf;                    /* Command buffers */
  426. #endif /* NOSPL */
  427. #else
  428. extern char cmdbuf[], atmbuf[];         /* Command buffers */
  429. #ifndef NOSPL
  430. extern char savbuf[];                   /* Command buffers */
  431. #endif /* NOSPL */
  432. #endif /* DCMDBUF */
  433.  
  434. extern char toktab[], ttname[], psave[];
  435. extern CHAR sstate, feol;
  436. extern int cmflgs, techo, repars, ncmd;
  437. extern struct keytab cmdtab[];
  438.  
  439. #ifndef NOSETKEY
  440. KEY *keymap;
  441. #ifndef OS2
  442. #define mapkey(x) keymap[x]
  443. #endif /* OS2 */
  444. MACRO *macrotab;
  445. _PROTOTYP( VOID shostrdef, (CHAR *) );
  446. #endif /* NOSETKEY */
  447.  
  448. extern int cmdlvl;
  449.  
  450. #ifndef NOSPL
  451. extern struct mtab *mactab;
  452. extern struct keytab mackey[];
  453. extern struct keytab vartab[], fnctab[], iftab[];
  454. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  455. #endif /* NOSPL */
  456.  
  457. FILE *tfile[MAXTAKE];                   /* TAKE file stack */
  458. char *tfnam[MAXTAKE];
  459. int tfline[MAXTAKE];
  460.  
  461. int topcmd = -1;                        /* cmdtab index of current command */
  462. int havetoken = 0;
  463. extern int dblquo;                      /* Doublequoting enabled */
  464.  
  465. #ifdef DCMDBUF                          /* Initialization filespec */
  466. char *kermrc = NULL;
  467. #else
  468. char kermrcb[KERMRCL];
  469. char *kermrc = kermrcb;
  470. #endif /* DCMDBUF */
  471.  
  472. int noherald = 0;
  473. int cm_retry = 1;                       /* Command retry enabled */
  474. xx_strp xxstring = zzstring;
  475.  
  476. #ifndef NOXFER
  477. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  478.   keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  479.   srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  480.   fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  481.  
  482. #ifdef CK_AUTODL
  483. extern int inautodl, cmdadl;
  484. #endif /* CK_AUTODL */
  485.  
  486. #ifndef NOSERVER
  487. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  488.   en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  489.   en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  490. #endif /* NOSERVER */
  491.  
  492. extern int atcapr,
  493.   atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  494.   attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  495.  
  496. #ifdef STRATUS
  497. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  498. #endif /* STRATUS */
  499.  
  500. #ifdef CK_PERMS
  501. extern int atlpri, atlpro, atgpri, atgpro;
  502. #endif /* CK_PERMS */
  503.  
  504. #ifdef CK_LOGIN
  505. extern char * anonfile;                 /* Anonymous login init file */
  506. extern char * anonroot;                 /* Anonymous file-system root */
  507. extern char * userfile;                 /* Forbidden user file */
  508. extern int isguest;                     /* Flag for anonymous user */
  509. #endif /* CK_LOGIN */
  510. #endif /* NOXFER */
  511.  
  512. #ifdef DCMDBUF
  513. int *xquiet = NULL;
  514. #else
  515. int xquiet[CMDSTKL];
  516. #endif /* DCMDBUF */
  517.  
  518. char * prstring[CMDSTKL];
  519.  
  520. #ifndef NOSPL
  521.  
  522. extern long ck_alarm;
  523. extern char alrm_date[], alrm_time[];
  524.  
  525. /* Local declarations */
  526.  
  527. static int nulcmd = 0;                  /* Flag for next cmd to be ignored */
  528.  
  529. /* Definitions for predefined macros */
  530.  
  531. /* First, the single-line macros, installed with addmac()... */
  532.  
  533. /* IBM-LINEMODE macro */
  534. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  535.  
  536. /* FATAL macro */
  537. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  538.  
  539. #ifdef CK_SPEED
  540. #ifdef IRIX65
  541. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  542. #else
  543. #ifdef IRIX
  544. /* Because of bug in telnet server */
  545. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  546.  set pref cautious";
  547. #else
  548. #ifdef pdp11
  549. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  550. #else
  551. #ifdef BIGBUFOK
  552. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  553. #else
  554. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  555. #endif /* BIGBUFOK */
  556. #endif /* IRIX */
  557. #endif /* IRIX65 */
  558. #endif /* pdp11 */
  559. #ifdef pdp11
  560. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  561. #else
  562. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  563. #endif /* pdp11 */
  564. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  565. set reliable off, set clearchannel off";
  566. #else
  567. #ifdef BIGBUFOK
  568. #ifdef IRIX65
  569. char *m_fast = "set win 30, set rec pack 4000";
  570. #else
  571. #ifdef IRIX
  572. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  573. #else
  574. char *m_fast = "set win 30, set rec pack 4000";
  575. #endif /* IRIX */
  576. #endif /* IRIX65 */
  577. #else /* Not BIGBUFOK */
  578. char *m_fast = "set win 4, set rec pack 2200";
  579. #endif /* BIGBUFOK */
  580. char *m_cautious = "set win 4, set rec pack 1000";
  581. char *m_robust = "set win 1, set rec pack 90, set reliable off";
  582. #endif /* CK_SPEED */
  583.  
  584. #ifdef VMS
  585. char *m_purge = "run purge \\%*";
  586. #endif /* VMS */
  587.  
  588. #ifdef OS2
  589. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  590. #endif /* OS2 */
  591.  
  592. /* Now the multiline macros, defined with addmmac()... */
  593.  
  594. /* FOR macro for \%i-style loop variables (see dofor()...) */
  595.  
  596. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  597. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  598. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  599. "def break goto _..bot, def continue goto _..inc,",
  600. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  601. ""};
  602.  
  603. /* This is the FOR macro when the loop variable is itself a macro */
  604.  
  605. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  606. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  607. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  608. "def break goto _..bot, def continue goto _..inc,",
  609. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  610. ""};
  611.  
  612. /* WHILE macro */
  613. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  614. ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
  615. "_def break goto _..bot, _def continue goto _..inc,",
  616. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  617. ""};
  618.  
  619. /* SWITCH macro */
  620. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  621. "_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  622. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  623. ""};
  624.  
  625. /* XIF macro */
  626. char *xif_def[] = {
  627. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  628. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  629. ""};
  630.  
  631. /*
  632.   Variables declared here for use by other ckuus*.c modules.
  633.   Space is allocated here to save room in ckuusr.c.
  634. */
  635. #ifdef DCMDBUF
  636. struct cmdptr *cmdstk;
  637. int
  638.   *ifcmd  = NULL,
  639.   *count  = NULL,
  640.   *iftest = NULL,
  641.   *intime = NULL,
  642.   *inpcas = NULL,
  643.   *takerr = NULL,
  644.   *merror = NULL;
  645. #else
  646. struct cmdptr cmdstk[CMDSTKL];
  647. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  648.   inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  649. #endif /* DCMDBUF */
  650.  
  651. /* Macro stack */
  652.  
  653. #ifdef COMMENT
  654. char *topline = NULL;                   /* Program invocation arg line */
  655. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  656. #endif /* COMMENT */
  657.  
  658. char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
  659. int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
  660. char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
  661. int macargc[MACLEVEL];                  /* Argc of each level */
  662. char *macp[MACLEVEL];                   /* Current position in each macro */
  663. char *macx[MACLEVEL];                   /* Beginning of each macro def */
  664. char *mrval[MACLEVEL];                  /* RETURN value at each level */
  665. int lastcmd[MACLEVEL];                  /* Last command at each level */
  666. int topargc = 0;                        /* Argc at top level */
  667. char **topxarg = NULL;                  /* Argv at top level */
  668. char *toparg[MAXARGLIST+2];
  669.  
  670. /* Global Variables */
  671.  
  672. char *g_var[GVARS+1];                   /* Global \%a..z pointers */
  673. extern char varnam[];                   /* \%x variable name buffer */
  674.  
  675. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  676. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  677.  
  678. char **a_ptr[32];                       /* Array pointers, for arrays a-z */
  679. int a_dim[32];                          /* Dimensions for each array */
  680. int a_link[32];                         /* Link (index of linked-to-array) */
  681.  
  682. char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
  683. int aa_dim[CMDSTKL][32];                /* Dimensions for each array */
  684.  
  685. /* INPUT command buffers and variables */
  686.  
  687. char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
  688. extern char * inpbp;                    /* Global/static pointer to it  */
  689. char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
  690. int  incount = 0;                       /* INPUT character count */
  691. extern int instatus;                    /* INPUT status */
  692. static char * i_text[] = {              /* INPUT status text */
  693.     "success", "timeout", "interrupted", "internal error", "i/o error"
  694. };
  695.  
  696. char lblbuf[LBLSIZ];                    /* Buffer for labels */
  697.  
  698. #else  /* NOSPL */
  699.  
  700. int takerr[MAXTAKE];
  701. #endif /* NOSPL */
  702.  
  703. static char *prevdir = NULL;
  704.  
  705. int pacing = 0;                         /* OUTPUT pacing */
  706.  
  707. char *tp;                               /* Temporary buffer pointer */
  708.  
  709. int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */
  710.  
  711. #ifdef CK_APC                           /* Application Program Command (APC) */
  712. int apcactive = APC_INACTIVE;
  713. int apcstatus = APC_OFF;                /* OFF by default everywhere */
  714. #ifdef DCMDBUF
  715. char *apcbuf;
  716. #else
  717. char apcbuf[APCBUFLEN];
  718. #endif /* DCMDBUF */
  719. #endif /* CK_APC */
  720.  
  721. extern char pktfil[],
  722. #ifdef DEBUG
  723.   debfil[],
  724. #endif /* DEBUG */
  725. #ifdef TLOG
  726.   trafil[],
  727. #endif /* TLOG */
  728.   sesfil[];
  729.  
  730. #ifndef NOFRILLS
  731. extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
  732. extern char optbuf[];
  733. #endif /* NOFRILLS */
  734.  
  735. extern int noinit;            /* Flat to skip init file */
  736.  
  737. #ifndef NOSPL
  738. static struct keytab kcdtab[] = {    /* Symbolic directory names */
  739. #ifdef NT
  740.     { "appdata",  VN_APPDATA,   0 },
  741.     { "common",   VN_COMMON,    0 },
  742.     { "desktop",  VN_DESKTOP,   0 },
  743. #endif /* NT */
  744.     { "download", VN_DLDIR,     0 },
  745. #ifdef OS2ORUNIX
  746.     { "exedir",   VN_EXEDIR,    0 },
  747. #endif /* OS2ORUNIX */
  748.     { "home",     VN_HOME,      0 },
  749.     { "inidir",   VN_INI,       0 },
  750. #ifdef UNIX
  751.     { "lockdir",  VN_LCKDIR,    0 },
  752. #endif /* UNIX */
  753. #ifdef NT
  754.     { "personal", VN_PERSONAL,  0 },
  755. #endif /* NT */
  756.     { "startup",  VN_STAR,      0 },
  757.     { "textdir",  VN_TXTDIR,    0 },
  758.     { "tmpdir",   VN_TEMP,      0 }
  759. };
  760. static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
  761. #endif /* NOSPL */
  762.  
  763. #ifndef NOSPL
  764. _PROTOTYP( VOID freelocal, (int) );
  765. _PROTOTYP( static CK_OFF_T expon, (CK_OFF_T, CK_OFF_T) );
  766. _PROTOTYP( static CK_OFF_T gcd, (CK_OFF_T, CK_OFF_T) );
  767. _PROTOTYP( static CK_OFF_T fact, (CK_OFF_T) );
  768.  
  769. int                     /* Initialize macro data structures. */
  770. macini() {              /* Allocate mactab and preset the first element. */
  771.     int i;
  772.     if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  773.       return(-1);
  774.     mactab[0].kwd = NULL;
  775.     mactab[0].mval = NULL;
  776.     mactab[0].flgs = 0;
  777.     for (i = 0; i < MACLEVEL; i++)
  778.       localhead[i] = NULL;
  779.     return(0);
  780. }
  781. #endif /* NOSPL */
  782.  
  783. /*  C M D S R C  --  Returns current command source  */
  784.  
  785. /*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  786.  
  787. /*
  788.   As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  789.   xcmdsrc can be checked instead to save the overhead of a function call.
  790. */
  791. int
  792. cmdsrc() {
  793. #ifdef COMMENT
  794.     return(xcmdsrc);
  795. #else
  796. #ifndef NOSPL
  797.     if (cmdlvl == 0)
  798.       return(0);
  799.     else if (cmdstk[cmdlvl].src == CMD_MD)
  800.       return(2);
  801.     else if (cmdstk[cmdlvl].src == CMD_TF)
  802.       return(1);
  803.     else
  804.       return(-1);
  805. #else
  806.     if (tlevel < 0)
  807.       return(0);
  808.     else
  809.       return(1);
  810. #endif /* NOSPL */
  811. #endif /* COMMENT */
  812. }
  813.  
  814. /*  C M D I N I  --  Initialize the interactive command parser  */
  815.  
  816. static int cmdinited = 0;               /* Command parser initialized */
  817. extern int cmdint;                      /* Interrupts are allowed */
  818. #ifdef CK_AUTODL
  819. int cmdadl = 1;                         /* Autodownload */
  820. #else
  821. int cmdadl = 0;
  822. #endif /* CK_AUTODL */
  823.  
  824. char * k_info_dir = NULL;               /* Where to find text files */
  825. #ifdef UNIX
  826. static char * txtdir[] = {
  827.     "/usr/local/doc/",                  /* Linux, SunOS, ... */
  828.     "/usr/share/lib/",                  /* HP-UX 10.xx... */
  829.     "/usr/share/doc/",                  /* Other possibilities... */
  830.     "/usr/local/lib/",                  /* NOTE: Each of these is tried */
  831.     "/usr/local/share/",                /* as is, and also with a kermit */
  832.     "/usr/local/share/doc/",            /* subdirectory. */
  833.     "/usr/local/share/lib/",
  834.     "/opt/kermit/",                     /* Solaris */
  835.     "/opt/kermit/doc/",
  836.     "/opt/",
  837.     "/usr/doc/",
  838.     "/doc/",
  839.     ""
  840. };
  841. #endif /* UNIX */
  842.  
  843. /*
  844.   lookup() cache to speed up script execution.
  845.  
  846.   This is a static cache.  Items are stored in decreasing frequency of
  847.   reference based on statistics from a range of scripts.  This gives
  848.   better performance than a dynamic cache, which would require a lot more
  849.   code and also would require system-dependent elements including system
  850.   calls (e.g. to get subsecond times for entry aging).
  851. */
  852. #ifdef USE_LUCACHE                      /* Set in ckuusr.h */
  853. #define LUCACHE 32                      /* Change this to reduce cache size */
  854. int lusize = 0;
  855. char * lucmd[LUCACHE];
  856. int luval[LUCACHE];
  857. int luidx[LUCACHE];
  858. struct keytab * lutab[LUCACHE];
  859. #endif /* USE_LUCACHE */
  860.  
  861. static VOID
  862. luinit() {                              /* Initialize lookup() cache */
  863.     int x, y;
  864.  
  865. #ifdef USE_LUCACHE
  866.     x = lookup(cmdtab,"if",ncmd,&y);
  867.     lucmd[lusize] = "if";
  868.     luval[lusize] = x;
  869.     luidx[lusize] = y;
  870.     lutab[lusize] = cmdtab;
  871.     if (++lusize > LUCACHE) return;
  872.  
  873.     x = lookup(iftab,"not",nif,&y);
  874.     lucmd[lusize] = "not";
  875.     luval[lusize] = x;
  876.     luidx[lusize] = y;
  877.     lutab[lusize] = iftab;
  878.     if (++lusize > LUCACHE) return;
  879.  
  880.     x = lookup(vartab,"cmdlevel",nvars,&y);
  881.     lucmd[lusize] = "cmdlevel";
  882.     luval[lusize] = x;
  883.     luidx[lusize] = y;
  884.     lutab[lusize] = vartab;
  885.     if (++lusize > LUCACHE) return;
  886.  
  887.     x = lookup(cmdtab,"goto",ncmd,&y);
  888.     lucmd[lusize] = "goto";
  889.     luval[lusize] = x;
  890.     luidx[lusize] = y;
  891.     lutab[lusize] = cmdtab;
  892.     if (++lusize > LUCACHE) return;
  893.  
  894.     x = lookup(iftab,">",nif,&y);
  895.     lucmd[lusize] = ">";
  896.     luval[lusize] = x;
  897.     luidx[lusize] = y;
  898.     lutab[lusize] = iftab;
  899.     if (++lusize > LUCACHE) return;
  900.  
  901.     x = lookup(cmdtab,"incr",ncmd,&y);
  902.     lucmd[lusize] = "incr";
  903.     luval[lusize] = x;
  904.     luidx[lusize] = y;
  905.     lutab[lusize] = cmdtab;
  906.     if (++lusize > LUCACHE) return;
  907.  
  908.     x = lookup(cmdtab,"def",ncmd,&y);
  909.     lucmd[lusize] = "def";
  910.     luval[lusize] = x;
  911.     luidx[lusize] = y;
  912.     lutab[lusize] = cmdtab;
  913.     if (++lusize > LUCACHE) return;
  914.  
  915.     x = lookup(cmdtab,"_assign",ncmd,&y);
  916.     lucmd[lusize] = "_assign";
  917.     luval[lusize] = x;
  918.     luidx[lusize] = y;
  919.     lutab[lusize] = cmdtab;
  920.     if (++lusize > LUCACHE) return;
  921.  
  922.     x = lookup(cmdtab,"echo",ncmd,&y);
  923.     lucmd[lusize] = "echo";
  924.     luval[lusize] = x;
  925.     luidx[lusize] = y;
  926.     lutab[lusize] = cmdtab;
  927.     if (++lusize > LUCACHE) return;
  928.  
  929.     x = lookup(fnctab,"eval",nfuncs,&y);
  930.     lucmd[lusize] = "eval";
  931.     luval[lusize] = x;
  932.     luidx[lusize] = y;
  933.     lutab[lusize] = fnctab;
  934.     if (++lusize > LUCACHE) return;
  935.  
  936.     x = lookup(fnctab,"lit",nfuncs,&y);
  937.     lucmd[lusize] = "lit";
  938.     luval[lusize] = x;
  939.     luidx[lusize] = y;
  940.     lutab[lusize] = fnctab;
  941.     if (++lusize > LUCACHE) return;
  942.  
  943.     x = lookup(cmdtab,"do",ncmd,&y);
  944.     lucmd[lusize] = "do";
  945.     luval[lusize] = x;
  946.     luidx[lusize] = y;
  947.     lutab[lusize] = cmdtab;
  948.     if (++lusize > LUCACHE) return;
  949.  
  950.     x = lookup(cmdtab,"_getargs",ncmd,&y);
  951.     lucmd[lusize] = "_getargs";
  952.     luval[lusize] = x;
  953.     luidx[lusize] = y;
  954.     lutab[lusize] = cmdtab;
  955.     if (++lusize > LUCACHE) return;
  956.  
  957.     x = lookup(iftab,"<",nif,&y);
  958.     lucmd[lusize] = "<";
  959.     luval[lusize] = x;
  960.     luidx[lusize] = y;
  961.     lutab[lusize] = iftab;
  962.     if (++lusize > LUCACHE) return;
  963.  
  964.     x = lookup(cmdtab,"_putargs",ncmd,&y);
  965.     lucmd[lusize] = "_putargs";
  966.     luval[lusize] = x;
  967.     luidx[lusize] = y;
  968.     lutab[lusize] = cmdtab;
  969.     if (++lusize > LUCACHE) return;
  970.  
  971.     x = lookup(cmdtab,"asg",ncmd,&y);
  972.     lucmd[lusize] = "asg";
  973.     luval[lusize] = x;
  974.     luidx[lusize] = y;
  975.     lutab[lusize] = cmdtab;
  976.     if (++lusize > LUCACHE) return;
  977.  
  978.     x = lookup(cmdtab,"else",ncmd,&y);
  979.     lucmd[lusize] = "else";
  980.     luval[lusize] = x;
  981.     luidx[lusize] = y;
  982.     lutab[lusize] = cmdtab;
  983. #endif /* USE_LUCACHE */
  984. }
  985.  
  986. VOID
  987. cmdini() {
  988.     int i = 0, x = 0, y = 0, z = 0, skip = 0;
  989.     char * p;
  990. #ifdef TTSPDLIST
  991.     long * ss = NULL;
  992.     extern int nspd;
  993.     extern struct keytab * spdtab;
  994. #endif /* TTSPDLIST */
  995.  
  996. #ifndef NOSPL
  997. /*
  998.   On stack to allow recursion!
  999. */
  1000.     char vnambuf[VNAML];                /* Buffer for variable names */
  1001. #endif /* NOSPL */
  1002.  
  1003.     if (cmdinited)                      /* Already initialized */
  1004.       return;                           /* Don't do it again */
  1005.  
  1006.     for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
  1007.       prstring[i] = NULL;               /* command level */
  1008.  
  1009. #ifndef NOCSETS
  1010.     p = getenv("K_CHARSET");            /* Set default file character set */
  1011.     if (p) {                            /* from environment */
  1012.         x = lookup(fcstab,p,nfilc,&y);
  1013.         if (x > -1)
  1014.           fcharset = x;
  1015.     }
  1016. #endif /* NOCSETS */
  1017.  
  1018.     p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
  1019.     if (p && *p && strlen(p) <= CKMAXPATH)
  1020.       makestr(&k_info_dir,p);
  1021.     if (!k_info_dir) {
  1022.         p = getenv("K_INFO_DIR");
  1023.         if (p && *p && strlen(p) <= CKMAXPATH)
  1024.           makestr(&k_info_dir,p);
  1025.     }
  1026. #ifdef UNIX
  1027.     if (k_info_dir) {                   /* Look for Kermit docs directory */
  1028.         if (zchki(k_info_dir) == -2) {
  1029.             char xbuf[CKMAXPATH+32], *s = "";
  1030.             if (ckrchar(k_info_dir) != '/')
  1031.               s = "/";
  1032.             ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  1033.             if (zchki(xbuf) < 0)
  1034.               makestr(&k_info_dir,NULL);
  1035.         }
  1036.     }
  1037.     if (!k_info_dir) {
  1038.         char xbuf[CKMAXPATH+32];
  1039.         int i;
  1040.         for (i = 0; *(txtdir[i]); i++) {
  1041.             ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  1042.             if (zchki(xbuf) > 0) {
  1043.                 makestr(&k_info_dir,txtdir[i]);
  1044.                 debug(F110,"k_info_dir 1",k_info_dir,0);
  1045.                 break;
  1046.             }
  1047.             ckmakmsg(xbuf,CKMAXPATH+32,
  1048.                      txtdir[i],"kermit/","ckubwr.txt",NULL);
  1049.             if (zchki(xbuf) > 0) {
  1050.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  1051.                 makestr(&k_info_dir,xbuf);
  1052.                 debug(F110,"k_info_dir 2",k_info_dir,0);
  1053.                 break;
  1054.             }
  1055.             ckmakmsg(xbuf,CKMAXPATH+32,
  1056.                      txtdir[i],"ckermit/","ckubwr.txt",NULL);
  1057.             if (zchki(xbuf) > 0) {
  1058.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
  1059.                 makestr(&k_info_dir,xbuf);
  1060.                 debug(F110,"k_info_dir 3",k_info_dir,0);
  1061.                 break;
  1062.             }
  1063.         }
  1064.         if (k_info_dir) {               /* Make sure it ends with "/" */
  1065.             if (ckrchar(k_info_dir) != '/') {
  1066.                 char xbuf[CKMAXPATH+32];
  1067.                 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1068.                 makestr(&k_info_dir,xbuf);
  1069.             }
  1070.         }
  1071.     }
  1072. #else
  1073. #ifdef OS2
  1074.     {
  1075.         char xdir[CKMAXPATH+8], *s = "";
  1076.         extern char startupdir[];
  1077.         xdir[0] = NUL;
  1078.         if (ckrchar(startupdir) != '/')
  1079.           s = "/";
  1080.         if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1081.           ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1082.         makestr(&k_info_dir,xdir);
  1083.     }
  1084. #endif /* OS2 */
  1085. #endif /* UNIX */
  1086.  
  1087. #ifdef TTSPDLIST
  1088.     if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1089.         int j, k, m = 0, n;             /* Create sorted keyword table */
  1090.         char buf[16];
  1091.         char * p;
  1092.         if ((spdtab =
  1093.              (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1094.             for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1095.                 if (ss[i] < 1L) break;     /* Shouldn't happen */
  1096.                 buf[0] = NUL;              /* Make string */
  1097.                 sprintf(buf,"%ld",ss[i]);  /* SAFE */
  1098.                 if (ss[i] == 8880L)
  1099.                   ckstrncpy(buf,"75/1200",sizeof(buf));
  1100.                 if (ss[i] == 134L)
  1101.                   ckstrncat(buf,".5",16);
  1102.                 n = strlen(buf);
  1103.                 if ((n > 0) && (p = (char *)malloc(n+1))) {
  1104.                     if (m > 0) {        /* Have at least one in list */
  1105.                         for (j = 0;     /* Find slot */
  1106.                              j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1107.                              j++
  1108.                              )
  1109.                           ;
  1110.                         if (j < m) {    /* Must insert */
  1111.                             for (k = m-1; k >= j; k--) { /* Move others down */
  1112.                                 spdtab[k+1].kwd = spdtab[k].kwd;
  1113.                                 spdtab[k+1].flgs = spdtab[k].flgs;
  1114.                                 spdtab[k+1].kwval = spdtab[k].kwval;
  1115.                             }
  1116.                         }
  1117.                     } else              /* First one */
  1118.                       j = 0;
  1119.                     ckstrncpy(p,buf,n+1); /* Add new speed */
  1120.                     spdtab[j].kwd = p;
  1121.                     spdtab[j].flgs = 0;
  1122.                     spdtab[j].kwval = (int) ss[i] / 10;
  1123.                     m++;                /* Count this one */
  1124.                 }
  1125.             }
  1126.         }
  1127.         nspd = m;
  1128.     }
  1129. #endif /* TTSPDLIST */
  1130.  
  1131. #ifndef NOSPL
  1132.     /* Allocate INPUT command buffer */
  1133.     if (!inpbuf) {
  1134.         if (!(inpbuf = (char *) malloc(INPBUFSIZ+8)))
  1135.           fatal("cmdini: no memory for INPUT buffer");
  1136.     }
  1137.     for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
  1138.       inpbuf[x] = NUL;
  1139.     inpbp = inpbuf;                     /* Initialize pointer */
  1140.     inbufsize = INPBUFSIZ;              /* and size. */
  1141. #endif /* NOSPL */
  1142.  
  1143. #ifdef DCMDBUF
  1144.     if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1145.  
  1146. #ifndef NOSPL
  1147.     /* Allocate command stack allowing command parser to call itself */
  1148.  
  1149.     if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1150.       fatal("cmdini: no memory for cmdstk");
  1151.     if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1152.       fatal("cmdini: no memory for ifcmd");
  1153.     if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1154.       fatal("cmdini: no memory for count");
  1155.     if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1156.       fatal("cmdini: no memory for iftest");
  1157.     if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1158.       fatal("cmdini: no memory for intime");
  1159.     if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1160.       fatal("cmdini: no memory for inpcas");
  1161.     if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1162.       fatal("cmdini: no memory for takerr");
  1163.     if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1164.       fatal("cmdini: no memory for merror");
  1165.     if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1166.       fatal("cmdini: no memory for xquiet");
  1167.     if (!kermrc)
  1168.       if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1169.         fatal("cmdini: no memory for kermrc");
  1170. #ifdef CK_APC
  1171. /* Application Program Command buffer */
  1172.     if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1173.         fatal("cmdini: no memory for apcbuf");
  1174. #endif /* CK_APC */
  1175. #endif /* NOSPL */
  1176.  
  1177. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1178.  
  1179.     if (!(line = malloc(LINBUFSIZ + 1)))
  1180.         fatal("cmdini: no memory for line");
  1181.     if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1182.         fatal("cmdini: no memory for tmpbuf");
  1183. #endif /* DCMDBUF */
  1184.  
  1185. #ifndef NOSPL
  1186. #ifdef CK_MINPUT
  1187.     {                                   /* Initialize MINPUT pointers */
  1188.         int i;
  1189.         extern char *ms[];
  1190.         for (i = 0; i < MINPMAX; i++)
  1191.           ms[i] = NULL;
  1192.     }
  1193. #endif /* CK_MINPUT */
  1194.  
  1195.     if (macini() < 0)                   /* Allocate macro buffers */
  1196.       fatal("Can't allocate macro buffers!");
  1197.  
  1198.     ifcmd[0] = 0;                       /* Command-level related variables. */
  1199.     iftest[0] = 0;                      /* Initialize variables at top level */
  1200.     count[0] = 0;                       /* of stack... */
  1201.     intime[0] = 0;
  1202.     inpcas[0] = 0;
  1203.     takerr[0] = 0;
  1204.     merror[0] = 0;
  1205.     xquiet[0] = quiet;
  1206. #endif /* NOSPL */
  1207.  
  1208. #ifndef NOSPL
  1209.     cmdlvl = 0;                         /* Initialize the command stack */
  1210.     xcmdsrc = CMD_KB;
  1211.     cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
  1212.     cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
  1213.     cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
  1214. #endif /* NOSPL */
  1215.  
  1216.     tlevel = -1;                        /* Take file level = keyboard */
  1217.     for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
  1218.       tfnam[i] = NULL;
  1219.  
  1220.     cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
  1221.                                         /* Can't set IKSD prompt here since */
  1222.                                         /* we do not yet know if we are IKSD */
  1223. #ifndef NOSPL
  1224.  
  1225.     initmac();                          /* Initialize macro table */
  1226.  
  1227. /* Predefine built-in one-line macros */
  1228.  
  1229.     addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
  1230.     addmac("fatal",m_fat);              /* FATAL macro */
  1231.     y = addmac("fast",m_fast);          /* FAST macro */
  1232.     addmac("cautious",m_cautious);      /* CAUTIOUS macro */
  1233.     addmac("robust",m_robust);          /* ROBUST macro */
  1234. #ifdef OS2
  1235.     addmac("manual",m_manual);          /* MANUAL macro */
  1236. #endif /* OS2 */
  1237. #ifdef VMS
  1238.     addmac("purge",m_purge);            /* PURGE macro */
  1239. #endif /* VMS */
  1240.  
  1241. /*
  1242.   Predefine built-in multiline macros; these are top-level commands
  1243.   that are implemented internally as macros.  NOTE: When adding a new
  1244.   one of these, remember to update the END and RETURN commands to
  1245.   account for it, or else END and RETURN from within it won't work right.
  1246. */
  1247.     x = addmmac("_forx",for_def);       /* FOR macro */
  1248.     if (x > -1) mactab[x].flgs = CM_INV;
  1249.     x = addmmac("_forz",foz_def);       /* Other FOR macro */
  1250.     if (x > -1) mactab[x].flgs = CM_INV;
  1251.     x = addmmac("_xif",xif_def);        /* XIF macro */
  1252.     if (x > -1) mactab[x].flgs = CM_INV;
  1253.     x = addmmac("_while",whil_def);     /* WHILE macro */
  1254.     if (x > -1) mactab[x].flgs = CM_INV;
  1255.     x = addmmac("_switx",sw_def);       /* SWITCH macro */
  1256.     if (x > -1) mactab[x].flgs = CM_INV;
  1257.  
  1258. /* Fill in command-line argument vector */
  1259.  
  1260.     sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
  1261.     if (inserver) {                     /* But hidden in IKSD */
  1262.         y = -1;
  1263.         xargs = 0;
  1264.     } else
  1265.       y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */
  1266.  
  1267.     tmpbuf[0] = NUL;
  1268.     if (y > -1) {
  1269.         int j = -1;
  1270.         int yy = 0;
  1271.         dclarray((char)x,z);            /* Declare the array */
  1272. #ifndef NOTAKEARGS
  1273.         /* Macro argument vector */
  1274.         sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
  1275.         yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
  1276.         if (yy > -1)                    /* Name is OK */
  1277.           dclarray((char)x,z);          /* Declare the array */
  1278. #endif /* NOTAKEARGS */
  1279.         skip = 0;
  1280.         for (i = 0; i < xargs; i++) {   /* Fill the arrays */
  1281.             sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1282.             addmac(vnambuf,xargv[i]);
  1283.             if (cfilef && i == 0)
  1284.               continue;
  1285. #ifdef KERBANG
  1286.             if (skip) {
  1287.                 j = 0;
  1288.                 skip = 0;
  1289.                 continue;
  1290.             }
  1291. #endif /* KERBANG */
  1292.             if (j < 0 &&                /* Assign items after "=" or "--"*/
  1293.                 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1294.                 ) {
  1295.                 j = 0;                  /* to \%1..\%9 */
  1296. #ifdef KERBANG
  1297.             } else if (j < 0 &&
  1298.                        (!strcmp(xargv[i],"+") ||
  1299.                         !strncmp(xargv[i],"+ ",2) ||
  1300.                         !strncmp(xargv[i],"+\t",2))
  1301.                         ) {
  1302.                 skip = 1;
  1303.                 continue;
  1304. #endif /* KERBANG */
  1305.             } else if (j > -1) {
  1306.                 j++;
  1307.                 if (j <= 9) {
  1308.                     vnambuf[0] = '\\';
  1309.                     vnambuf[1] = '%';
  1310.                     vnambuf[2] = (char)(j+'0');
  1311.                     vnambuf[3] = NUL;
  1312.                     addmac(vnambuf,xargv[i]);
  1313.                 }
  1314.                 if (yy > -1) {
  1315.                     char c, * p;
  1316.                     int flag = 0;
  1317.                     p = xargv[i];
  1318.                     makestr(&(toparg[j]),p);
  1319.                     while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1320.                     if (flag)
  1321.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1322.                     ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1323.                     if (flag)
  1324.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1325.                     ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1326.                 }
  1327.             }
  1328.         }
  1329.         if (cfilef) {
  1330.             addmac("\\%0",cmdfil);
  1331.             if (yy > -1)
  1332.               makestr(&(toparg[0]),cmdfil);
  1333.         } else {
  1334.             addmac("\\%0",xargv[0]);
  1335.             if (yy > -1)
  1336.               makestr(&(toparg[0]),xargv[0]);
  1337.         }
  1338.         if (yy > -1) {
  1339.             topargc = (j < 0) ? 1 : j + 1;
  1340.             topxarg = toparg;
  1341. #ifdef COMMENT
  1342.             /* This needs work */
  1343.             if (!cfilef)
  1344.               makestr(&topline,tmpbuf);
  1345. #endif /* COMMENT */
  1346.         } else {
  1347.             topargc = 0;
  1348.             topxarg = NULL;
  1349.         }
  1350.         a_dim[0] = topargc - 1;
  1351.         a_ptr[0] = topxarg;
  1352.     debug(F111,"a_dim[0]","A",a_dim[0]);
  1353.     }
  1354.     *vnambuf = NUL;
  1355. #endif /* NOSPL */
  1356.  
  1357.     luinit();                           /* Initialize lookup() cache */
  1358.  
  1359. /* Get our home directory now.  This needed in lots of places. */
  1360.  
  1361.     cmdinited = 1;
  1362. }
  1363.  
  1364. #ifdef NT
  1365. _PROTOTYP(char * GetAppData,(int));
  1366. #endif /* NT */
  1367.  
  1368. VOID
  1369. doinit() {
  1370. #ifdef CKROOT
  1371. extern int ckrooterr;
  1372. #endif /* CKROOT */
  1373.     int x = 0, ok = 0;
  1374. #ifdef OS2
  1375.     char * ptr = 0;
  1376. #endif /* OS2 */
  1377.  
  1378.     if (!cmdinited)
  1379.       cmdini();
  1380.  
  1381. #ifdef MAC
  1382.     return;                             /* Mac Kermit has no init file */
  1383.  
  1384. #else /* !MAC */
  1385.  
  1386. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1387.  
  1388.     if (noinit) {
  1389.         kermrc[0] = '\0';
  1390.         inidir[0] = '\0';
  1391. /*
  1392.   But returning from here results in inidir[] never being set to anything.
  1393.   Instead it should be set to wherever the init file *would* have been
  1394.   executed from.  So this bit of code should be removed, and then we should
  1395.   sprinkle "if (noinit)" tests throughout the following code until we have
  1396.   set inidir[], and then return without actually taking the init file.
  1397. */
  1398.         return;
  1399.     }
  1400.  
  1401. #ifdef OS2
  1402. /*
  1403.   The -y init file must be fully specified or in the current directory.
  1404.   KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  1405.   own executable file path is taken and the .EXE suffix is replaced by .INI
  1406.   and this is tried as the initialization file.
  1407. */
  1408. #ifdef CK_LOGIN
  1409.     debug(F101,"doinit inserver","",inserver);
  1410.     debug(F101,"doinit isguest","",isguest);
  1411.     debug(F110,"doinit anonfile",anonfile,0);
  1412.  
  1413.     if (isguest && anonfile) {
  1414.       ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1415.     } else
  1416. #endif /* CK_LOGIN */
  1417.       if (rcflag) {
  1418.           ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1419. #ifdef CK_LOGIN
  1420.       } else if (inserver) {
  1421.           char * appdata = NULL;
  1422. #ifdef NT
  1423.           appdata = GetAppData(1);
  1424.           if ( appdata ) {
  1425.               ckmakmsg(line,LINBUFSIZ+1,appdata,
  1426.                         "Kermit 95/k95.ini",NULL,NULL);
  1427.               if ( zchki(line) < 0 )
  1428.                   line[0] = '\0';
  1429.           }
  1430.           if (line[0] == 0) {
  1431.               appdata = GetAppData(0);
  1432.               if ( appdata ) {
  1433.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1434.                             "Kermit 95/k95.ini",NULL,NULL);
  1435.                   if ( zchki(line) < 0 )
  1436.                       line[0] = '\0';
  1437.               }
  1438.           }
  1439. #endif /* NT */
  1440.           if (line[0] == 0) {
  1441.               appdata = zhome();
  1442.               if ( appdata ) {
  1443.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1444. #ifdef NT
  1445.                           "k95.ini",
  1446. #else /* NT */
  1447.                           "k2.ini",
  1448. #endif /* NT */
  1449.                            NULL,NULL);
  1450.                   if ( zchki(line) < 0 )
  1451.                       line[0] = '\0';
  1452.               }
  1453.           }
  1454.           debug(F110,"doinit inserver inifile",line,0);
  1455. #endif /* CK_LOGIN */
  1456.     } else {
  1457.         char * env = 0;
  1458. #ifdef NT
  1459.         env = getenv("K95.KSC");
  1460. #else
  1461.         env = getenv("K2.KSC");
  1462. #endif /* NT */
  1463.         if (!env) {
  1464. #ifdef NT
  1465.             env = getenv("K95.INI");
  1466. #else
  1467.             env = getenv("K2.INI");
  1468. #endif /* NT */
  1469.         }
  1470.         if (!env)
  1471.           env = getenv("CKERMIT.INI");
  1472.         if (!env)
  1473.           env = getenv("CKERMIT_INI");
  1474.         line[0] = '\0';
  1475.  
  1476.         debug(F110,"doinit env",env,0);
  1477.         if (env)
  1478.           ckstrncpy(line,env,LINBUFSIZ+1);
  1479.  
  1480. #ifdef NT
  1481.         if (line[0] == 0) {
  1482.             env = GetAppData(1);
  1483.             if ( env ) {
  1484.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1485.                 if ( zchki(line) < 0 )
  1486.                     line[0] = '\0';
  1487.             }
  1488.         }
  1489.         if (line[0] == 0) {
  1490.             env = GetAppData(0);
  1491.             if ( env ) {
  1492.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1493.                 if ( zchki(line) < 0 )
  1494.                     line[0] = '\0';
  1495.             }
  1496.         }
  1497. #endif /* NT */
  1498.  
  1499.         if (line[0] == 0) {
  1500.             env = zhome();
  1501.             if ( env ) {
  1502.                 ckmakmsg(line,LINBUFSIZ+1,env,
  1503. #ifdef NT
  1504.                           "k95.ini",
  1505. #else /* NT */
  1506.                           "k2.ini",
  1507. #endif /* NT */
  1508.                           NULL,NULL);
  1509.                 if ( zchki(line) < 0 )
  1510.                     line[0] = '\0';
  1511.             }
  1512.         }
  1513.  
  1514.         if (line[0] == 0)
  1515.           _searchenv(kermrc,"INIT",line);
  1516.         if (line[0] == 0)
  1517.           _searchenv(kermrc,"DPATH",line);
  1518.         if (line[0] == 0)
  1519.           _searchenv(kermrc,"PATH",line);
  1520.         if (line[0] == 0) {
  1521.             char *pgmptr = GetLoadPath();
  1522.             if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1523.                 lp = strrchr(pgmptr, '\\');
  1524.                 if (lp) {
  1525.                     strncpy(line, pgmptr, lp - pgmptr);
  1526. #ifdef NT
  1527.                     strcpy(line + (lp - pgmptr), "/k95.ini");
  1528. #else /* NT */
  1529.                     strcpy(line + (lp - pgmptr), "/k2.ini");
  1530. #endif /* NT */
  1531.                 } else {
  1532.                     lp = strrchr(pgmptr, '.');
  1533.                     if (lp) {
  1534.                         strncpy(line, pgmptr, lp - pgmptr);
  1535.                         strcpy(line + (lp - pgmptr), ".ini");
  1536.                     }
  1537.                 }
  1538.             }
  1539.         }
  1540.     }
  1541.  
  1542. #ifdef CKROOT
  1543.     if (!zinroot(line)) {
  1544.         debug(F110,"doinit setroot violation",line,0);
  1545.         return;
  1546.     }
  1547. #endif /* CKROOT */
  1548.  
  1549.     debug(F110,"doinit fopen()",line,0);
  1550.     if ((tfile[0] = fopen(line,"r")) != NULL) {
  1551.         ok = 1;
  1552.         tlevel = 0;
  1553.         tfline[tlevel] = 0;
  1554.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1555.           strcpy(tfnam[tlevel],line);   /* safe */
  1556. #ifndef NOSPL
  1557.         cmdlvl++;
  1558.         xcmdsrc = CMD_TF;
  1559.         cmdstk[cmdlvl].src = CMD_TF;
  1560.         cmdstk[cmdlvl].lvl = tlevel;
  1561.         cmdstk[cmdlvl].ccflgs = 0;
  1562.         ifcmd[cmdlvl] = 0;
  1563.         iftest[cmdlvl] = 0;
  1564.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1565.         intime[cmdlvl] = intime[cmdlvl-1];
  1566.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1567.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1568.         merror[cmdlvl] = merror[cmdlvl-1];
  1569.         xquiet[cmdlvl] = quiet;
  1570. #endif /* NOSPL */
  1571.         debug(F110,"doinit init file",line,0);
  1572.     } else {
  1573.         debug(F100,"doinit no init file","",0);
  1574.     }
  1575.     ckstrncpy(kermrc,line,KERMRCL);
  1576.     for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
  1577.        if (*ptr == '\\')
  1578.          *ptr = '/';
  1579. #else /* not OS2 */
  1580.     lp = line;
  1581.     lp[0] = '\0';
  1582.     debug(F101,"doinit rcflag","",rcflag);
  1583. #ifdef GEMDOS
  1584.     zkermini(line, rcflag, kermrc);
  1585. #else
  1586. #ifdef VMS
  1587.     {
  1588.     int x;
  1589.     x = zkermini(line,LINBUFSIZ,kermrc);
  1590.     debug(F111,"CUSTOM zkermini",line,x);
  1591.     if (x == 0)
  1592.       line[0] = NUL;
  1593.     }
  1594. #else /* not VMS */
  1595. #ifdef CK_LOGIN
  1596.     debug(F101,"doinit isguest","",isguest);
  1597.     if (isguest)
  1598.       ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1599.     else
  1600. #endif /* CK_LOGIN */
  1601.       if (rcflag) {                     /* If init file name from cmd line */
  1602.           ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1603.       } else {                          /* otherwise... */
  1604. #ifdef CK_INI_A                         /* If we've a system-wide init file */
  1605.           /* And it takes precedence over the user's... */
  1606.           ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1607.           if (zchki(lp) < 0) {          /* (if it exists...) */
  1608. #endif /* CK_INI_A */
  1609.               char * homdir;
  1610.               char * env = 0;
  1611.               line[0] = NUL;
  1612.  
  1613.               /* Add support for environment variable */
  1614.               env = getenv("CKERMIT.INI");
  1615.               if (!env)
  1616.                 env = getenv("CKERMIT_INI");
  1617.               if (env)
  1618.                 ckstrncpy(lp,env,KERMRCL);
  1619.  
  1620.               if (lp[0] == 0) {
  1621.                   homdir = zhome();
  1622.                   if (homdir) {         /* Home directory for init file. */
  1623.                       ckstrncpy(lp,homdir,KERMRCL);
  1624. #ifdef STRATUS
  1625.                       ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1626. #else
  1627.                       if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1628. #endif /* STRATUS */
  1629.                   }
  1630.                   ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1631.               }
  1632. #ifdef CK_INI_A
  1633.           }
  1634. #endif /* CK_INI_A */
  1635. #ifdef CK_INI_B                         /* System-wide init defined? */
  1636.           /* But user's ini file takes precedence */
  1637.           if (zchki(lp) < 0)            /* If user doesn't have her own, */
  1638.             ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1639. #endif /* CK_INI_B */
  1640.       }
  1641. #endif /* VMS */
  1642. #endif /* GEMDOS */
  1643.  
  1644. #ifdef AMIGA
  1645.     reqoff();                           /* Disable requestors */
  1646. #endif /* AMIGA */
  1647.  
  1648. #ifdef USE_CUSTOM
  1649.     /* If no init file was found, execute the customization file */
  1650.     debug(F111,"CUSTOM 1",line,rcflag);
  1651.     if ((!line[0] || zchki(line) < 0) && !rcflag) {
  1652.     int x;
  1653. #ifdef OS2
  1654.     x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1655.     debug(F111,"CUSTOM 2",line,x);
  1656.     if (zchki(line) < 0) {
  1657.         x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1658.         debug(F111,"CUSTOM 3",line,x);
  1659.     }
  1660. #else  /* OS2 */
  1661.     x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1662. #ifndef VMS
  1663.     /* VMS zhome() returns "SYS$LOGIN:" */
  1664.     if (line[x-1] != DIRSEP) {
  1665.         line[x++] = DIRSEP;
  1666.         line[x] = NUL;
  1667.     }
  1668. #endif /* VMS */
  1669.     x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1670.     debug(F111,"CUSTOM 4",line,x);
  1671. #endif /* OS2 */
  1672.     }
  1673.     debug(F110,"CUSTOM 5",line,0);
  1674. #endif /* USE_CUSTOM */
  1675.  
  1676. #ifdef CKROOT
  1677.     if (!zinroot(line)) {
  1678.         debug(F110,"doinit setroot violation",line,0);
  1679.         return;
  1680.     }
  1681. #endif /* CKROOT */
  1682.  
  1683.     debug(F110,"doinit ini file is",line,0);
  1684.     if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1685.         ok = 1;
  1686.         tlevel = 0;
  1687.         tfline[tlevel] = 0;
  1688.         if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1689.           strcpy(tfnam[tlevel],line);   /* safe */
  1690.  
  1691.         ckstrncpy(kermrc,line,KERMRCL);
  1692.  
  1693. #ifndef NOSPL
  1694.         cmdlvl++;
  1695.         ifcmd[cmdlvl] = 0;
  1696.         iftest[cmdlvl] = 0;
  1697.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1698.         intime[cmdlvl] = intime[cmdlvl-1];
  1699.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1700.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1701.         merror[cmdlvl] = merror[cmdlvl-1];
  1702.         xquiet[cmdlvl] = quiet;
  1703.         debug(F101,"doinit open ok","",cmdlvl);
  1704.         xcmdsrc = CMD_TF;
  1705.         cmdstk[cmdlvl].src = CMD_TF;
  1706.         cmdstk[cmdlvl].lvl = tlevel;
  1707.         cmdstk[cmdlvl].ccflgs = 0;
  1708. #endif /* NOSPL */
  1709.     } else if (rcflag) {
  1710.         /* Print an error message only if a specific file was asked for. */
  1711.         printf("?%s - %s\n", ck_errstr(), line);
  1712.     }
  1713.  
  1714. #ifdef datageneral
  1715. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1716.     if (/* homdir && */ (tlevel < 0)) {
  1717.         ckstrncpy(lp,kermrc,LINBUFSIZ);
  1718.         if ((tfile[0] = fopen(line,"r")) != NULL) {
  1719.             ok = 1;
  1720.             tlevel = 0;
  1721.             tfline[tlevel] = 0;
  1722.             if (tfnam[tlevel] = malloc(strlen(line)+1))
  1723.               strcpy(tfnam[tlevel],line); /* safe */
  1724. #ifndef NOSPL
  1725.             cmdlvl++;
  1726.             xcmdsrc = CMD_TF;
  1727.             cmdstk[cmdlvl].src = CMD_TF;
  1728.             cmdstk[cmdlvl].lvl = tlevel;
  1729.             cmdstk[cmdlvl].ccflgs = 0;
  1730.             ifcmd[cmdlvl] = 0;
  1731.             iftest[cmdlvl] = 0;
  1732.             count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1733.             intime[cmdlvl] = intime[cmdlvl-1];
  1734.             inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1735.             takerr[cmdlvl] = takerr[cmdlvl-1];
  1736.             merror[cmdlvl] = merror[cmdlvl-1];
  1737.             xquiet[cmdlvl] = quiet;
  1738. #endif /* NOSPL */
  1739.         }
  1740.     }
  1741. #endif /* datageneral */
  1742.  
  1743. #ifdef AMIGA                            /* Amiga... */
  1744.     reqpop();                           /* Restore requestors */
  1745. #endif /* AMIGA */
  1746. #endif /* OS2 */
  1747. #endif /* MAC */
  1748.  
  1749.     /* Assign value to inidir */
  1750.  
  1751.     if (!ok) {
  1752.         inidir[0] = NUL;
  1753.     } else {
  1754.         ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1755.         x = strlen(inidir);
  1756.         if (x > 0) {
  1757.             int i;
  1758.             for (i = x - 1; i > 0; i-- ) {
  1759.                 if (ISDIRSEP(inidir[i])) {
  1760.                     inidir[i+1] = NUL;
  1761.                     break;
  1762.                 }
  1763.             }
  1764.         }
  1765. #ifdef NT
  1766.         GetShortPathName(inidir,inidir,CCHMAXPATH);
  1767. #endif /* NT */
  1768.     }
  1769. }
  1770.  
  1771. VOID
  1772. doiksdinit() {
  1773. #ifdef CK_SSL
  1774.     /* IKSD doesn't request client certs */
  1775.     ssl_verify_flag = SSL_VERIFY_NONE;
  1776. #endif /* CK_SSL */
  1777.  
  1778.     if (!cmdinited)
  1779.       cmdini();
  1780.  
  1781. #ifdef IKSDCONF
  1782. #ifdef OS2
  1783.     line[0] = '\0';
  1784.     _searchenv(iksdconf,"INIT",line);
  1785.     if (line[0] == 0)
  1786.       _searchenv(iksdconf,"DPATH",line);
  1787.     if (line[0] == 0)
  1788.       _searchenv(iksdconf,"PATH",line);
  1789.     if (line[0] == 0) {
  1790.         char *pgmptr = GetLoadPath();
  1791.         if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1792.             lp = strrchr(pgmptr, '\\');
  1793.             if (lp) {
  1794.                 strncpy(line, pgmptr, lp - pgmptr);
  1795.                 strcpy(line + (lp - pgmptr), "\\");
  1796.                 strcpy(line + (lp - pgmptr + 1), iksdconf);
  1797.             } else {
  1798.                 lp = strrchr(pgmptr, '.');
  1799.                 if (lp) {
  1800.                     strncpy(line, pgmptr, lp - pgmptr);
  1801.                     strcpy(line + (lp - pgmptr), ".ksc");
  1802.                 }
  1803.             }
  1804.         }
  1805.     }
  1806.     debug(F110,"doiksdinit() line",line,0);
  1807.     tfile[0] = fopen(line,"r");
  1808. #else /* OS2 */
  1809.     tfile[0] = fopen(iksdconf,"r");
  1810. #endif /* OS2 */
  1811.     if (tfile[0] != NULL) {
  1812.         tlevel = 0;
  1813.         tfline[tlevel] = 0;
  1814. #ifdef OS2
  1815.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1816.           strcpy(tfnam[tlevel],line);
  1817. #else /* OS2 */
  1818.         if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1819.           strcpy(tfnam[tlevel],iksdconf);
  1820. #endif /* OS2 */
  1821. #ifndef NOSPL
  1822.         cmdlvl++;
  1823.         xcmdsrc = CMD_TF;
  1824.         cmdstk[cmdlvl].src = CMD_TF;
  1825.         cmdstk[cmdlvl].lvl = tlevel;
  1826.         cmdstk[cmdlvl].ccflgs = 0;
  1827.         ifcmd[cmdlvl]  = 0;
  1828.         iftest[cmdlvl] = 0;
  1829.         count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
  1830.         intime[cmdlvl] = intime[cmdlvl-1];
  1831.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1832.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1833.         merror[cmdlvl] = merror[cmdlvl-1];
  1834.         xquiet[cmdlvl] = quiet;
  1835. #endif /* NOSPL */
  1836.         debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1837.     } else {
  1838.         debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1839.     }
  1840. #endif /* IKSDCONF */
  1841. }
  1842.  
  1843. #ifndef NOSPL
  1844. /*
  1845.   G E T N C M
  1846.  
  1847.   Get next command from current macro definition.  Command is copied
  1848.   into string pointed to by argument s, max length n.   Returns:
  1849.    0 if a string was copied;
  1850.   -1 if there was no string to copy.
  1851. */
  1852. int
  1853. getncm(s,n) char *s; int n; {
  1854.     int y = 0;                /* Character counter */
  1855.     int quote = 0;
  1856.     int kp = 0;                /* Brace up-down counter */
  1857.     int pp = 0;                /* Parenthesis up-down counter */
  1858. #ifndef NODQMACRO
  1859.     int dq = 0;                /* Doublequote counter */
  1860. #endif /* NODQMACRO */
  1861.     char *s2;                           /* Copy of destination pointer */
  1862.  
  1863.     s2 = s;                             /* Initialize string pointers */
  1864.     *s = NUL;                           /* and destination buffer */
  1865.  
  1866.     /* debug(F010,"getncm entry",macp[maclvl],0); */
  1867.  
  1868.     for (y = 0;                         /* Loop for n bytes max */
  1869.          macp[maclvl] && *macp[maclvl] && y < n;
  1870.          y++, s++, macp[maclvl]++) {
  1871.  
  1872.         *s = *macp[maclvl];             /* Get next char from macro def */
  1873.  
  1874. #ifndef COMMENT
  1875. /*
  1876.   This is to allow quoting of parentheses, commas, etc, in function
  1877.   arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  1878.   COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  1879.   everything again.)  <-- The preceding warning should be obsolete since the
  1880.   statements below have been fixed, but in case of fire, remove the "n" from
  1881.   the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the
  1882.   opening brace in \{nnn} from being treated as a quoted brace.
  1883. */
  1884.         if (!quote && *s == CMDQ) {
  1885.             quote = 1;
  1886.             continue;
  1887.         }
  1888.         if (quote) {
  1889.         int notquote = 0;
  1890.             quote = 0;
  1891.         if (*s == '{') {        /* Check for \{nnn} (8.0.203) */
  1892.         char c, * p;
  1893.         p = macp[maclvl] + 1;
  1894.         while ((c = *p++)) {
  1895.             if (isdigit(c))
  1896.               continue;
  1897.             else if (c == '}') {
  1898.             notquote++;
  1899.             break;
  1900.             } else {
  1901.             break;
  1902.             }
  1903.         }
  1904.         }
  1905.         if (notquote == 0)
  1906.           continue;
  1907.         }
  1908. #endif /* COMMENT */
  1909.  
  1910. /*
  1911.   Allow braces around macro definition to prevent commas from being turned to
  1912.   end-of-lines and also treat any commas within parens as text so that
  1913.   multiple-argument functions won't cause the command to break prematurely.
  1914.   19 Oct 2001: Similar treatment was added for doublequotes, so
  1915.  
  1916.      define foo { echo "one, two, three" }
  1917.  
  1918.   would work as expected.  This doesn't seem to have broken anything but
  1919.   if something comes up later, rebuild with NODQMACRO defined.
  1920. */
  1921.         if (*s == '{') kp++;            /* Count braces */
  1922.         if (*s == '}' && kp > 0) kp--;
  1923.         if (*s == '(') pp++;            /* Count parentheses. */
  1924.         if (*s == ')' && pp > 0) pp--;
  1925. #ifndef NODQMACRO
  1926. #ifndef COMMENT
  1927.     /* Too many false positives */
  1928.     /* No, not really -- this is indeed the best we can do */
  1929.     /* Reverted to this method Sun May 11 18:43:45 2003 */
  1930.     if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1931. #else  /* Fri Apr  4 13:21:29 2003 */
  1932.     /* The code below breaks the SWITCH statement */
  1933.     /* There is no way to make this work -- it would require */
  1934.     /* building in all the knowledge of command parser. */
  1935.         if (dblquo && (*s == '"')) {    /* Have doublequote */
  1936.             if (dq == 1) {        /* Close quote only if... */
  1937.                 if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
  1938.             (!*(macp[maclvl]+1)) ||      /* at end or ... */
  1939.             /* Next char is command separator... */
  1940.             /* Sun May 11 17:24:12 2003 */
  1941.             (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
  1942.             )             
  1943.                   dq = 0;        /* Close the quote */
  1944.             } else if (dq == 0) {
  1945.                 /* Open quote only if at beginning or preceded by space */
  1946.                 if (s > s2) {
  1947.                     if (*(s-1) == SP)
  1948.                       dq = 1;
  1949.                 } else if (s == s2) {
  1950.                       dq = 1;
  1951.                 }
  1952.             }
  1953.         }
  1954. #endif /* COMMENT */
  1955. #endif /* NODQMACRO */
  1956.         if (*s == ',' && pp <= 0 && kp <= 0
  1957. #ifndef NODQMACRO
  1958.             && dq == 0
  1959. #endif /* NODQMACRO */
  1960.             ) {
  1961.             macp[maclvl]++;             /* Comma not in {} or () */
  1962.             /* debug(F110,"next cmd",s,0); */
  1963.             kp = pp = 0;                /* so we have the next command */
  1964.             break;
  1965.         }
  1966.     }                                   /* Reached end. */
  1967. #ifdef COMMENT
  1968.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1969.     *s = NUL;
  1970. #endif /* COMMENT */
  1971.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1972.         /* debug(F100,"XXX getncm eom","",0); */
  1973.         popclvl();                      /* pop command level. */
  1974.         return(-1);
  1975.     } else {                            /* otherwise, tack CR onto end */
  1976.         *s++ = CR;
  1977.         *s = '\0';
  1978.         /* debug(F110,"XXX getncm OK",s,0); */
  1979.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  1980.           printf("%s\n",s2);
  1981.     }
  1982.     return(0);
  1983. }
  1984.  
  1985. /*  D O M A C  --  Define and then execute a macro */
  1986.  
  1987. int
  1988. domac(name, def, flags) char *name, *def; int flags; {
  1989.     int x, m;
  1990. #ifndef NOLOCAL
  1991. #ifdef OS2
  1992.     extern int term_io;
  1993.     int term_io_sav = term_io;
  1994.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  1995. #endif /* OS2 */
  1996. #endif /* NOLOCAL */
  1997.     m = maclvl;                         /* Current macro stack level */
  1998.     x = addmac(name, def);              /* Define a new macro */
  1999.     if (x > -1) {                       /* If successful, */
  2000.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  2001.         while (maclvl > m) {            /* Keep going till done with it, */
  2002.             debug(F101,"domac loop maclvl 1","",maclvl);
  2003.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  2004.             debug(F101,"domac loop maclvl 2","",maclvl);
  2005.             if (sstate) proto();        /* including protocol commands. */
  2006.         }
  2007.         debug(F101,"domac loop exit maclvl","",maclvl);
  2008.     }
  2009. #ifndef NOLOCAL
  2010. #ifdef OS2
  2011.     term_io = term_io_sav;
  2012. #endif /* OS2 */
  2013. #endif /* NOLOCAL */
  2014.     return(success);
  2015. }
  2016. #endif /* NOSPL */
  2017.  
  2018. /*
  2019.   G E T N C T
  2020.  
  2021.   Get next command from TAKE (command) file.
  2022.  
  2023.   Call with:
  2024.    s     Pointer to buffer to read into
  2025.    n     Length of buffer
  2026.    f     File descriptor of file to read from
  2027.    flag  0 == keep line terminator on and allow continuation
  2028.          1 == discard line terminator and don't allow continuation
  2029.  
  2030.   Call with flag == 0 to read a command from a TAKE file;
  2031.   Call with flag != 0 to read a line from a dialing or network directory.
  2032.  
  2033.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  2034.   If flag == 0, continued lines are combined into one line.  A continued line
  2035.   is one that ends in hypen, or any line in a "block", which starts with "{"
  2036.   at the end of a line and ends with a matching "}" at the beginning of a
  2037.   subsequent line; blocks may be nested.
  2038.  
  2039.   Returns:
  2040.    0 if a string was copied,
  2041.   -1 on EOF,
  2042.   -2 on malloc failure
  2043.   -3 if line is not properly terminated
  2044.   -4 if (possibly continued) line is too long.
  2045. */
  2046. static int lpxlen = 0;
  2047.  
  2048. int
  2049. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  2050.     int i = 0, len = 0, buflen = 0;
  2051.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  2052.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  2053.     char * prev = NULL;
  2054.     int bc = 0;                         /* Block counter */
  2055.  
  2056.     s2 = s;                             /* Remember original pointer */
  2057.     prev = s2;
  2058.     buflen = n;                         /* Remember original buffer length */
  2059.  
  2060.     if (n < 0)
  2061.       return(-2);
  2062.  
  2063.     /* Allocate a line buffer only if we don't have one that's big enough */
  2064.  
  2065.     debug(F111,"getnct",ckitoa(lpxlen),n);
  2066.  
  2067.     if (lpx && (n > lpxlen)) {          /* Have one already */
  2068.         debug(F101,"getnct new buffer","",lpxlen);
  2069.         free(lpx);                      /* But it's not big enough */
  2070.         lpx = NULL;                     /* Free current one */
  2071.         lpxlen = 0;
  2072.     }
  2073.     if (!lpx) {                         /* Get new one */
  2074.         if (!(lpx = (char *) malloc(n))) {
  2075.             debug(F101,"getnct malloc failure","",0);
  2076.             printf("?Memory allocation failure [getnct]\n");
  2077.             return(-2);
  2078.         }
  2079.         lpxlen = n;
  2080.     }
  2081.     lp2 = lpx;
  2082. #ifdef KLUDGE
  2083.     /* NOTE: No longer used as of 14 Aug 2000 */
  2084.     lp2++;
  2085. #endif /* KLUDGE */
  2086.  
  2087.     while (1) {                         /* Loop to read lines from file */
  2088.         debug(F101,"getnct while (1)","",n);
  2089.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  2090.             debug(F110,"getnct EOF",s2,0); /* EOF */
  2091.             free(lpx);                  /* Free temporary storage */
  2092.             lpx = NULL;
  2093.             *s = NUL;                   /* Make destination be empty */
  2094.             return(-1);                 /* Return failure code */
  2095.         }
  2096. #ifndef NODIAL
  2097.         if (flag)                       /* Count this line */
  2098.           dirline++;
  2099.         else
  2100. #endif /* NODIAL */
  2101.           tfline[tlevel]++;
  2102.         len = strlen(lp2) - 1;          /* Position of line terminator */
  2103.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  2104.             lp2[++len] = '\n';          /* that is not a newline */
  2105.             lp2[len] = NUL;
  2106.         }
  2107.         debug(F010,"getnct",lp2,0);
  2108.         if (len < 0)
  2109.           len = 0;
  2110.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2111.           printf("%3d. %s",             /* echo it this line. */
  2112. #ifndef NODIAL
  2113.                  flag ? dirline :
  2114. #endif /* NODIAL */
  2115.                  tfline[tlevel],
  2116.                  lp2
  2117.                  );
  2118.         lp3 = lp2;                      /* Working pointer */
  2119.         i = len;                        /* Get first nonwhitespace character */
  2120.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2121.             i--;
  2122.             lp3++;
  2123.         }
  2124.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2125.           continue;
  2126.  
  2127.         /* Isolate, remove, and check terminator */
  2128.  
  2129.         c = lp2[len];                   /* Value of line terminator */
  2130.         /* debug(F101,"getnct terminator","",c); */
  2131.         if (c < LF || c > CR) {         /* It's not a terminator */
  2132.             /* debug(F111,"getnct bad line",lp2,c); */
  2133.             if (feof(f) && len > 0 && len < n) {
  2134.                 /* Kludge Alert... */
  2135.                 if (!quiet)
  2136.                   printf("WARNING: Last line of %s lacks terminator\n",
  2137.                          s2 == cmdbuf ? "command file" : "directory file");
  2138.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2139.             } else {                    /* Something's wrong, fail. */
  2140.                 free(lpx);
  2141.                 lpx = NULL;
  2142.                 return(-3);
  2143.             }
  2144.         }
  2145.         /* Trim trailing whitespace */
  2146.  
  2147.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2148.           ;
  2149.         /* debug(F101,"getnct i","",i); */
  2150.         lp2[i+1] = NUL;                 /* Terminate the string */
  2151.         /* debug(F110,"getnct lp2",lp2,0); */
  2152.         lp = lp2;                       /* Make a working pointer */
  2153.  
  2154.         /* Remove trailing or full-line comment */
  2155.  
  2156.         while ((cc = *lp)) {
  2157.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2158.                 if (lp == lp2) {        /* First char on line */
  2159.                     *lp = NUL;
  2160.                     break;
  2161.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2162.                     lp--;
  2163.                     *lp = NUL;  /* Or preceded by whitespace */
  2164.                     break;
  2165.                 }
  2166.             }
  2167.             lp++;
  2168.         }
  2169.         if (lp > lp2)
  2170.           lp--;                         /* Back up over the NUL */
  2171.  
  2172.         /* Now trim any space that preceded the comment */
  2173.  
  2174.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2175.             *lp = NUL;
  2176.             if (lp <= lp2)
  2177.               break;
  2178.             lp--;
  2179.         }
  2180.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2181.  
  2182.         len = strlen(lp2);              /* Length after trimming */
  2183.  
  2184.         if (n - len < 2) {              /* Check remaining space */
  2185.             debug(F111,"getnct command too long",s2,buflen);
  2186.             printf("?Line too long, maximum length: %d.\n",buflen);
  2187.             free(lpx);
  2188.             return(-4);
  2189.         }
  2190.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2191.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2192.  
  2193. #ifdef COMMENT
  2194.         /* Line containing only whitespace and ,- */
  2195.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2196.           continue;
  2197. #endif /* COMMENT */
  2198.  
  2199. #ifdef KLUDGE
  2200. /*
  2201.   If it is a command and it begins with a token (like ! or .) that is not
  2202.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2203.   confused.
  2204. */
  2205.         if (s == s2 && !flag) {
  2206.             char *p = toktab;
  2207.             while (*p) {
  2208.                 if (*p == *lp3 && *(p+1) != SP) {
  2209.                     debug(F110,"getnct token",p,0);
  2210.                     *lp3-- = SP;
  2211.                     *lp3 = *p;
  2212.                     if (lp3 < lp2) {
  2213.                         lp2--;
  2214.                         len++;
  2215.                     }
  2216.                     break;
  2217.                 } else
  2218.                   p++;
  2219.             }
  2220.         }
  2221. #endif /* KLUDGE */
  2222.         lp = lp2;
  2223.  
  2224.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2225.           n--;                          /* accounting for length */
  2226.         s--;                            /* Back up over the NUL */
  2227.  
  2228.         /* Check whether this line is continued */
  2229.  
  2230.         if (flag)                       /* No line continuation when flag=1 */
  2231.           break;                        /* So break out of read-lines loop */
  2232.  
  2233. #ifdef COMMENT
  2234.         debug(F000,"getnct first char","",*lp3);
  2235.         debug(F000,"getnct last char","",ccl);
  2236.         debug(F000,"getnct next-to-last char","",ccx);
  2237. #endif /* COMMENT */
  2238.  
  2239.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2240.             bc--;                               /* Decrement block counter */
  2241.         }
  2242.  
  2243.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2244. #ifdef COMMENT
  2245.             /* Not supported as of C-Kermit 6.0 */
  2246.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2247. #endif /* COMMENT */
  2248.             ccl != '-'  &&              /* or line ends with dash */
  2249.             ccl != '{')                 /* or line ends with opening brace */
  2250.           break;                        /* None of those, we're done. */
  2251.  
  2252.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2253.           if (ccx == CMDQ)              /* But it's quoted */
  2254.             break;                      /* so ignore it */
  2255.  
  2256.         if (ccl == '{') {               /* Last char on line is '{'? */
  2257.             bc++;                       /* Count the block opener. */
  2258.         } else if (ccl == '-') {        /* Explicit continue? */
  2259.             char c, * ss;
  2260.             int state = 0, nn;
  2261.             s--;                        /* Yes, back up over terminators */
  2262.             n++;                        /* and over continuation character */
  2263.             nn = n;                     /* Save current count */
  2264.             ss = s;                     /* and pointer */
  2265.             s--;                        /* Back up over dash */
  2266.             n++;
  2267.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2268.                 n++;
  2269.                 c = *s--;
  2270.                 if (c <= SP)
  2271.                   continue;
  2272.                 if (c != ',' && c != '{')
  2273.                   break;
  2274.                 switch (state) {
  2275.                   case 0:               /* Looking for comma */
  2276.                     if (c == ',')
  2277.                       state = 1;
  2278.                     break;
  2279.                   case 1:               /* Looking for left brace */
  2280.                     if (c == '{') {
  2281.                         state = 2;
  2282.                         s += 2;
  2283.                         *s = NUL;
  2284.                         bc++;
  2285.                     }
  2286.                     break;
  2287.                 }
  2288.             }
  2289.             if (state != 2) { s = ss; n = nn; }
  2290.             *s = NUL;
  2291.         } else {                        /* None of those but (bc > 0) */
  2292.             lastcomma = s;
  2293.             *s++ = ',';                 /* and insert a comma */
  2294.             n--;
  2295.         }
  2296. #ifdef COMMENT
  2297.         debug(F101,"getnct bc","",bc);
  2298.         debug(F100,"getnct continued","",0);
  2299. #endif /* COMMENT */
  2300.  
  2301.         *s = NUL;
  2302.         prev = s;
  2303.  
  2304.     } /* read-lines while loop */
  2305.  
  2306.     if (lastcomma)
  2307.       *lastcomma = SP;
  2308.     if (!flag)                          /* Tack line terminator back on */
  2309.       *s++ = c;
  2310.     *s++ = NUL;                         /* Terminate the string */
  2311.     untab(s2);                          /* Done, convert tabs to spaces */
  2312. #ifdef DEBUG
  2313.     if (!flag) {
  2314.         debug(F010,"CMD(F)",s2,0);
  2315.     }
  2316. #endif /* DEBUG */
  2317.     free(lpx);                          /* Free temporary storage */
  2318.     return(0);                          /* Return success */
  2319. }
  2320.  
  2321. VOID
  2322. shostack() {                            /* Dump the command stack */
  2323.     int i;
  2324.     char *p;
  2325. #ifndef NOSPL
  2326.     for (i = cmdlvl; i > 0; i--) {
  2327.         if (cmdstk[i].src == CMD_TF) {
  2328.             p = tfnam[cmdstk[i].lvl];
  2329.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2330.               p = tmpbuf;
  2331.             printf(" %2d. File  : %s (line %d)\n",
  2332.                    i,
  2333.                    p,
  2334.                    tfline[cmdstk[i].lvl]
  2335.                    );
  2336.         } else if (cmdstk[i].src == CMD_MD) {
  2337.             char * m;
  2338.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2339.             if (i > 0) {                 /* Special handling for 2-level */
  2340.                 char *s;                 /* built-in macros... */
  2341.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2342.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2343.                     if (!strcmp(s,"_forx"))
  2344.                       m = "FOR";
  2345.                     else if (!strcmp(s,"_xif"))
  2346.                       m = "XIF";
  2347.                     else if (!strcmp(s,"_while"))
  2348.                       m = "WHILE";
  2349.                     else if (!strcmp(s,"_switx"))
  2350.                       m = "SWITCH";
  2351.                 }
  2352.             }
  2353.             printf(" %2d. Macro : %s\n",i,m);
  2354.         } else if (cmdstk[i].src == CMD_KB) {
  2355.             printf(" %2d. Prompt:\n",i);
  2356.         } else {
  2357.             printf(" %2d. ERROR : Command source unknown\n",i);
  2358.         }
  2359.     }
  2360. #else
  2361.     for (i = tlevel; i > -1; i--) {
  2362.         p = tfnam[i];
  2363.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2364.           p = tmpbuf;
  2365.         printf(" %2d. File  : %s (line %d)\n",
  2366.                i,
  2367.                p,
  2368.                tfline[i]
  2369.                );
  2370.     }
  2371. #endif /* NOSPL */
  2372.     if (i == 0)
  2373.       printf(" %2d. Prompt: (top level)\n",0);
  2374. }
  2375.  
  2376.  
  2377. /*  P A R S E R  --  Top-level interactive command parser.  */
  2378.  
  2379. /*
  2380.   Call with:
  2381.     m = 0 for normal behavior: keep parsing and executing commands
  2382.           until an action command is parsed, then return with a
  2383.           Kermit start-state as the value of this function.
  2384.     m = 1 to parse only one command, can also be used to call parser()
  2385.           recursively.
  2386.     m = 2 to read but do not execute one command.
  2387.   In all cases, parser() returns:
  2388.     0     if no Kermit protocol action required
  2389.     > 0   with a Kermit protocol start-state.
  2390.     < 0   upon error.
  2391. */
  2392. int
  2393. parser(m) int m; {
  2394.     int tfcode, xx, yy, zz;             /* Workers */
  2395.     int is_tn = 0;
  2396.     int cdlost = 0;
  2397.  
  2398. #ifndef NOSPL
  2399.     int inlevel;                        /* Level we were called at */
  2400.     extern int askflag, echostars;
  2401. #endif /* NOSPL */
  2402.     char *cbp;                          /* Command buffer pointer */
  2403. #ifdef MAC
  2404.     extern char *lfiles;                /* Fake extern cast */
  2405. #endif /* MAC */
  2406.     extern int interrupted;
  2407. #ifndef NOXFER
  2408.     extern int sndcmd, getcmd, fatalio, clearrq;
  2409. #endif /* NOXFER */
  2410.  
  2411. #ifdef AMIGA
  2412.     reqres();                           /* Restore AmigaDOS requestors */
  2413. #endif /* AMIGA */
  2414.  
  2415. #ifdef OS2
  2416.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2417.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2418.         cursor_save = -1;
  2419.     }
  2420. #endif /* OS2 */
  2421.  
  2422. #ifdef IKSDB
  2423.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2424. #endif /* IKSDB */
  2425.  
  2426.     is_tn = (local && network && IS_TELNET()) ||
  2427.       (!local && sstelnet);
  2428.  
  2429.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2430.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2431.  
  2432. #ifdef CK_TMPDIR
  2433. /* If we were cd'd temporarily to another device or directory ... */
  2434.     if (f_tmpdir) {
  2435.         int x;
  2436.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2437.         f_tmpdir = 0;                   /* and remember we did it. */
  2438.         debug(F111,"parser tmpdir restoring",savdir,x);
  2439.     }
  2440. #endif /* CK_TMPDIR */
  2441.  
  2442. #ifndef NOSPL
  2443.     inlevel = cmdlvl;           /* Current macro level */
  2444. #ifdef DEBUG
  2445.     if (deblog) {
  2446.         debug(F101,"&parser entry maclvl","",maclvl);
  2447.         debug(F101,"&parser entry inlevel","",inlevel);
  2448.         debug(F101,"&parser entry tlevel","",tlevel);
  2449.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2450.         debug(F101,"&parser entry m","",m);
  2451.     }
  2452. #endif /* DEBUG */
  2453. #endif /* NOSPL */
  2454.  
  2455. #ifndef NOXFER
  2456.     ftreset();                          /* Reset global file settings */
  2457. #endif /* NOXFER */
  2458. /*
  2459.   sstate becomes nonzero when a command has been parsed that requires some
  2460.   action from the protocol module.  Any non-protocol actions, such as local
  2461.   directory listing or terminal emulation, are invoked directly from below.
  2462. */
  2463.     sstate = 0;                         /* Start with no start state. */
  2464.  
  2465. #ifndef NOXFER
  2466. #ifndef NOSPL
  2467.     query = 0;                          /* QUERY not active */
  2468. #endif /* NOSPL */
  2469. #ifndef NOHINTS
  2470.     if (!success) {
  2471.         if (local && !network && carrier != CAR_OFF) {
  2472.             int x;                      /* Serial connection */
  2473.             x = ttgmdm();               /* with carrier checking */
  2474.             if (x > -1) {
  2475.                 if (!(x & BM_DCD)) {
  2476.                     cdlost = 1;
  2477.                     fatalio = 1;
  2478.                 }
  2479.             }
  2480.         }
  2481.     }
  2482. #ifdef DEBUG
  2483.     if (deblog) {
  2484.         debug(F101,"parser top what","",what);
  2485.         debug(F101,"parser top interrupted","",interrupted);
  2486.         debug(F101,"parser top cdlost","",cdlost);
  2487.         debug(F101,"parser top sndcmd","",sndcmd);
  2488.         debug(F101,"parser top getcmd","",getcmd);
  2489.     }
  2490. #endif /* DEBUG */
  2491.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2492.         printf("?Connection broken (carrier signal lost)\n");
  2493.     }
  2494.     if (sndcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2495.         int x = 0, n = 0;
  2496.         printf("\n*************************\n");
  2497.         printf("SEND-class command failed.\n");
  2498.         printf(" Packets sent: %d\n", spackets);
  2499.         printf(" Retransmissions: %d\n",retrans);
  2500.         printf(" Timeouts: %d\n", timeouts);
  2501.         printf(" Damaged packets: %d\n", crunched);
  2502.         if (epktrcvd) {
  2503.             printf(" Transfer canceled by receiver.\n");
  2504.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2505.             n++;
  2506.         } else {
  2507.             if (epktmsg) if (*epktmsg) {
  2508.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2509.                 n++;
  2510.             }
  2511.         }
  2512.         if (local && !network && carrier != CAR_OFF) {
  2513.             int xx;                     /* Serial connection */
  2514.             xx = ttgmdm();              /* with carrier checking */
  2515.             if (xx > -1) {
  2516.                 if (!(xx & BM_DCD))
  2517.                   cdlost = 1;
  2518.             }
  2519.         }
  2520.  
  2521. #ifdef UNIX
  2522.         if (errno != 0)
  2523. #endif /* UNIX */
  2524.           {
  2525.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2526.               n++;
  2527.           }
  2528.         printf(
  2529.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2530.                (n > 1) ? "s do" : " does"
  2531.                );
  2532. #ifndef NOLOCAL
  2533.         if (local) {
  2534.             if (rpackets == 0) {
  2535.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2536.             } else {
  2537.                 printf(
  2538.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2539.                 if (!network && mdmtyp > 0)
  2540.                   if ((3 * crunched) > spackets)
  2541.                     printf(
  2542.                 " . Try placing a new call to get a cleaner connection.\n");
  2543.             }
  2544.         } else if (rpackets > 0) {
  2545.             if (flow == FLO_NONE)
  2546.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2547.             else
  2548.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2549.         }
  2550.         x++;
  2551. #endif /* NOLOCAL */
  2552.  
  2553.         if ((3 * timeouts) > spackets)
  2554.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2555.         if ((3 * retrans) > spackets)
  2556.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2557.  
  2558. #ifdef CK_SPEED
  2559.         if (prefixing != PX_ALL && rpackets > 2) {
  2560.             printf(" . Try it again with SET PREFIXING ALL.\n");
  2561.             x++;
  2562.         }
  2563. #endif /* CK_SPEED */
  2564. #ifdef STREAMING
  2565.         if (streamed) {
  2566.             printf(" . Try it again with SET STREAMING OFF.\n");
  2567.             x++;
  2568.         } else if (reliable) {
  2569.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2570.             x++;
  2571.         }
  2572. #endif /* STREAMING */
  2573.  
  2574. #ifdef CK_SPEED
  2575.         if (clearrq > 0 && prefixing == PX_NON) {
  2576.             printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");
  2577.             x++;
  2578.         }
  2579. #endif /* CK_SPEED */
  2580.         if (!parity) {
  2581.             printf(" . Try it again with SET PARITY SPACE.\n");
  2582.             x++;
  2583.         }
  2584.         printf(" . %sive a ROBUST command and try again.\n",
  2585.                (x > 0) ? "As a last resort, g" : "G"
  2586.                );
  2587.         printf("Also:\n");
  2588.         printf(" . Be sure the source file has read permission.\n");
  2589.         printf(" . Be sure the target directory has write permission.\n");
  2590.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2591.         printf("*************************\n\n");
  2592.     }
  2593.     debug(F101,"topcmd","",topcmd);
  2594.     if (getcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2595.         int x = 0;
  2596.         extern int urpsiz, wslotr;
  2597.         printf("\n*************************\n");
  2598.         printf("RECEIVE- or GET-class command failed.\n");
  2599.         printf(" Packets received: %d\n", rpackets);
  2600.         printf(" Damaged packets: %d\n", crunched);
  2601.         printf(" Timeouts: %d\n", timeouts);
  2602.         if (rpackets > 0)
  2603.           printf(" Packet length: %d\n", urpsiz);
  2604.         if (epktrcvd) {
  2605.             printf(" Transfer canceled by sender.\n");
  2606.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2607.         }
  2608. #ifdef UNIX
  2609.         if (errno != 0)
  2610. #endif /* UNIX */
  2611.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2612.         printf(
  2613.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2614.                epktrcvd ? "s do" : " does"
  2615.                );
  2616. #ifndef NOLOCAL
  2617.         if (local) {
  2618.             if (topcmd == XXGET)
  2619.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2620.             if (rpackets == 0) {
  2621.                 if (topcmd != XXGET)
  2622.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2623.             } else {
  2624.                 printf(
  2625.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2626.             }
  2627.         } else if (topcmd == XXGET)
  2628.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2629.         if (rpackets > 0 && urpsiz > 90)
  2630.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2631.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2632.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2633.         if (!local && rpackets > 0) {
  2634.             if (flow == FLO_NONE)
  2635.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2636.             else
  2637.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2638.         }
  2639.         x++;
  2640. #endif /* NOLOCAL */
  2641. #ifdef STREAMING
  2642.         if (streamed) {
  2643.             printf(" . Try it again with SET STREAMING OFF.\n");
  2644.             x++;
  2645.         } else if (reliable && local) {
  2646.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2647.             x++;
  2648.         } else
  2649. #endif /* STREAMING */
  2650.         if (!parity) {
  2651.             printf(" . Try it again with SET PARITY SPACE.\n");
  2652.             x++;
  2653.         }
  2654.         printf((x > 0) ?
  2655.                " . As a last resort, give a ROBUST command and try again.\n" :
  2656.                " . Give a ROBUST command and try again.\n"
  2657.                );
  2658.         printf("Also:\n");
  2659.         printf(" . Be sure the target directory has write permission.\n");
  2660.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2661.                topcmd == XXGET ? "server" : "sender"
  2662.                );
  2663.         printf(" . Try giving a ROBUST command to the %s.\n",
  2664.                topcmd == XXGET ? "server" : "sender"
  2665.                );
  2666.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2667.         printf("*************************\n\n");
  2668.     }
  2669. #endif /* NOHINTS */
  2670.     getcmd = 0;
  2671.     sndcmd = 0;
  2672.     interrupted = 0;
  2673. #endif /* NOXFER */
  2674.  
  2675.     while (sstate == 0) {               /* Parse cmds until action requested */
  2676.         debug(F100,"parse top","",0);
  2677.     what = W_COMMAND;        /* Now we're parsing commands. */
  2678.     rcdactive = 0;            /* REMOTE CD not active */
  2679.     keepallchars = 0;        /* MINPUT not active */
  2680.  
  2681. #ifdef OS2
  2682.         if (apcactive == APC_INACTIVE)
  2683.           WaitCommandModeSem(-1);
  2684. #endif /* OS2 */
  2685. #ifdef IKS_OPTION
  2686.         if ((local &&
  2687.              !xcmdsrc &&
  2688.              is_tn &&
  2689.              TELOPT_ME(TELOPT_KERMIT) &&
  2690.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2691.             (!local &&
  2692.              !cmdadl &&
  2693.              TELOPT_ME(TELOPT_KERMIT) &&
  2694.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2695.             ) {
  2696.             tn_siks(KERMIT_STOP);
  2697.         }
  2698. #endif /* IKS_OPTION */
  2699.  
  2700. #ifndef NOXFER
  2701.         if (autopath) {
  2702.             fnrpath = PATH_AUTO;
  2703.             autopath = 0;
  2704.         }
  2705.         remfile = 0;                    /* Clear these in case REMOTE */
  2706.         remappd = 0;                    /* command was interrupted... */
  2707.         rempipe = 0;
  2708.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2709.         makestr(&rcv_move,g_rcv_move);
  2710.         makestr(&snd_rename,g_snd_rename);
  2711.         makestr(&rcv_rename,g_rcv_rename);
  2712. #endif /* NOXFER */
  2713.  
  2714.     /* Take requested action if there was an error in the previous command */
  2715.  
  2716.         setint();
  2717.         debug(F101,"parser tlevel","",tlevel);
  2718.         debug(F101,"parser cmd_rows","",cmd_rows);
  2719.  
  2720. #ifndef NOLOCAL
  2721.         debug(F101,"parser wasclosed","",wasclosed);
  2722.         if (wasclosed) {                /* If connection was just closed */
  2723. #ifndef NOSPL
  2724.             int k;
  2725.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2726.             if (k >= 0) {               /* If found, */
  2727.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2728.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2729.             }
  2730. #endif /* NOSPL */
  2731.             whyclosed = WC_REMO;
  2732.             wasclosed = 0;
  2733.         }
  2734. #endif /* NOLOCAL */
  2735.  
  2736. #ifndef NOSPL
  2737.         xxdot = 0;                      /* Clear this... */
  2738.  
  2739.         debug(F101,"parser success","",success);
  2740.         if (success == 0) {
  2741.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2742.                 printf("Command file terminated by error.\n");
  2743.                 popclvl();
  2744.                 if (cmdlvl == 0) return(0);
  2745.             }
  2746.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2747.                 printf("Command error: macro terminated.\n");
  2748.                 popclvl();
  2749.                 if (m && (cmdlvl < inlevel))
  2750.                   return((int) sstate);
  2751.             }
  2752.         }
  2753.         nulcmd = (m == 2);
  2754.         debug(F101,"parser nulcmd","",nulcmd);
  2755. #else
  2756.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2757.             printf("Command file terminated by error.\n");
  2758.             popclvl();
  2759.             cmini(ckxech);              /* Clear the cmd buffer. */
  2760.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2761.               return(0);                /* End of init file or whatever. */
  2762.         }
  2763. #endif /* NOSPL */
  2764.  
  2765. #ifdef MAC
  2766.         /* Check for TAKE initiated by menu. */
  2767.         if ((tlevel == -1) && lfiles)
  2768.             startlfile();
  2769. #endif /* MAC */
  2770.  
  2771.         /* If in TAKE file, check for EOF */
  2772. #ifndef NOSPL
  2773. #ifdef MAC
  2774.         if
  2775. #else
  2776.         while
  2777. #endif /* MAC */
  2778.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2779.                && (tlevel > -1)
  2780.                && feof(tfile[tlevel])) {
  2781.             popclvl();                  /* pop command level */
  2782.             cmini(ckxech);              /* and clear the cmd buffer. */
  2783.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2784.                 return(0);              /* End of init file or whatever. */
  2785.             }
  2786.         }
  2787. #ifdef MAC
  2788.         miniparser(1);
  2789.         if (sstate == 'a') {            /* if cmd-. cancel */
  2790.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2791.             sstate = '\0';
  2792.             dostop();
  2793.             return(0);                  /* End of init file or whatever. */
  2794.         }
  2795. #endif /*  MAC */
  2796.  
  2797. #else /* NOSPL */
  2798.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2799.             popclvl();                  /* Pop up one level. */
  2800.             cmini(ckxech);              /* and clear the cmd buffer. */
  2801.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2802.               return(0);                /* End of init file or whatever. */
  2803.         }
  2804. #endif /* NOSPL */
  2805.  
  2806.  
  2807. #ifndef NOSPL
  2808.         debug(F101,"parser cmdlvl","",cmdlvl);
  2809.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2810.  
  2811.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2812.             debug(F100,"parser macro","",0);
  2813.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2814.             debug(F101,"parser maclvl","",maclvl);
  2815.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2816.             *cbp = NUL;
  2817.             if (*savbuf) {              /* In case then-part of 'if' command */
  2818.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2819.                 *savbuf = '\0';
  2820.             } else {                    /* Else get next cmd from macro def */
  2821.                 if (getncm(cbp,CMDBL) < 0) {
  2822. #ifdef DEBUG
  2823.                     if (deblog) {
  2824.                         debug(F101,"parser end of macro m","",m);
  2825.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2826.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2827.                     }
  2828. #endif /* DEBUG */
  2829.                     if (m && (cmdlvl < inlevel))
  2830.                       return((int) sstate);
  2831.                     else /* if (!m) */ continue;
  2832.                 }
  2833.             }
  2834.             debug(F010,"CMD(M)",cmdbuf,0);
  2835.  
  2836.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2837. #else
  2838.           if (tlevel > -1)
  2839. #endif /* NOSPL */
  2840.           {
  2841. #ifndef NOSPL
  2842.             debug(F111,"parser savbuf",savbuf,tlevel);
  2843.             if (*savbuf) {              /* In case THEN-part of IF command */
  2844.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2845.                 *savbuf = '\0';
  2846.             } else
  2847. #endif /* NOSPL */
  2848.  
  2849.               /* Get next line from TAKE file */
  2850.  
  2851.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2852.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2853.                   if (tfcode < -1) {    /* Error */
  2854.                       printf("?Error in TAKE command file: %s\n",
  2855.                              (tfcode == -2) ? "Memory allocation failure" :
  2856.                              "Line too long or contains NUL characters"
  2857.                              );
  2858.                       dostop();
  2859.                   }
  2860.                   continue;             /* -1 means EOF */
  2861.               }
  2862.  
  2863.         /* If interactive, get next command from user. */
  2864.  
  2865.         } else {                        /* User types it in. */
  2866.             if (pflag) prompt(xxstring);
  2867.             cmini(ckxech);
  2868.         }
  2869.  
  2870.     /* Now we know where next command is coming from. Parse and execute it. */
  2871.  
  2872.         repars = 1;                     /* 1 = command needs parsing */
  2873. #ifndef NOXFER
  2874.         displa = 0;                     /* Assume no file transfer display */
  2875. #endif /* NOXFER */
  2876.  
  2877.         while (repars) {                /* Parse this cmd until entered. */
  2878.  
  2879.             debug(F101,"parser top of while loop","",0);
  2880.         xaskmore = saveask;        /* Restore global more-prompting */
  2881.         diractive = 0;        /* DIR command not active */
  2882.         cdactive = 0;        /* CD command not active */
  2883. #ifndef NOSPL
  2884.         askflag = 0;        /* ASK command not active */
  2885.         echostars = 0;        /* Nor ASKQ */
  2886.         debok = 1;            /* Undisable debugging */
  2887. #endif /* NOSPL */
  2888.  
  2889. #ifdef RECURSIVE
  2890.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2891.             recursive = 0;              /* This is never sticky */
  2892. #endif /* RECURSIVE */
  2893.             xfiletype = -1;             /* Reset this between each command */
  2894. #ifndef NOMSEND
  2895.             addlist = 0;
  2896. #endif /* NOMSEND */
  2897. #ifdef CK_RECALL
  2898.             on_recall = 1;
  2899. #endif /* CK_RECALL */
  2900.             /* This might have been changed by a switch */
  2901.             if (g_matchdot > -1) {
  2902.                 matchdot = g_matchdot;
  2903.                 g_matchdot = -1;
  2904.             }
  2905.             cmres();                    /* Reset buffer pointers. */
  2906.  
  2907. #ifdef OS2
  2908. #ifdef COMMENT
  2909.             /* we check to see if a macro is waiting to be executed */
  2910.             /* if so, we call domac on it */
  2911.             if (cmdmac) {
  2912.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2913.                 free(cmdmac);
  2914.                 cmdmac = NULL;
  2915.             }
  2916. #endif /* COMMENT */
  2917. #endif /* OS2 */
  2918. #ifndef NOXFER
  2919.             bye_active = 0;
  2920. #endif /* NOXFER */
  2921.             havetoken = 0;
  2922.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2923.             debug(F101,"top-level cmkey2","",xx);
  2924.             if (xx == -5) {
  2925.                 yy = chktok(toktab);
  2926.                 debug(F101,"top-level cmkey token","",yy);
  2927. #ifndef COMMENT
  2928.                 /* Either way makes absolutely no difference */
  2929.                 debug(F110,"NO UNGWORD",atmbuf,0);
  2930.                 /* ungword(); */
  2931. #else
  2932.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  2933.                 ungword();
  2934. #endif /* COMMENT */
  2935.                 switch (yy) {
  2936.                   case '#': xx = XXCOM; break; /* Comment */
  2937.                   case ';': xx = XXCOM; break; /* Comment */
  2938. #ifndef NOSPL
  2939.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  2940.                   case ':': xx = XXLBL; break; /* GOTO label */
  2941. #endif /* NOSPL */
  2942.  
  2943. #ifndef NOPUSH
  2944. #ifdef CK_REDIR
  2945.                   case '<':
  2946. #endif /* CK_REDIR */
  2947.                   case '@':
  2948.                   case '!':
  2949.                     if (nopush) {
  2950.                         char *s; int x;
  2951.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  2952.                           return(x);
  2953.                         success = 0;
  2954.                         xx = XXCOM;
  2955.                     } else {
  2956.                         switch(yy) {
  2957. #ifdef CK_REDIR
  2958.                           case '<': xx = XXFUN; break; /* REDIRECT */
  2959. #endif /* CK_REDIR */
  2960.                           case '@':
  2961.                           case '!': xx = XXSHE; break; /* Shell escape */
  2962.                         }
  2963.                     }
  2964.                     break;
  2965. #endif /* NOPUSH */
  2966. #ifdef CK_RECALL
  2967.                   case '^': xx = XXREDO;  break;
  2968. #endif /* CK_RECALL */
  2969. #ifndef NOSPL
  2970.                   case '{': xx = XXMACRO; break;
  2971.                   case '(': xx = XXSEXP;  break;
  2972. #endif /* NOSPL */
  2973.  
  2974.                   default:
  2975.                     if (!quiet) {
  2976.                         printf("\n?Invalid - \"%s\"\n",cmdbuf);
  2977. #ifdef COMMENT
  2978. #ifndef NOSPL
  2979.                         if (maclvl > -1 && xcmdsrc == 2)
  2980.                           printf("Macro: %s; ",
  2981.                                  m_arg[maclvl][0] ?
  2982.                                  m_arg[maclvl][0] : "");
  2983. #endif /* NOSPL */
  2984.                         if (tlevel > -1) {
  2985.                             printf("Command file: %s, line %d\n",
  2986.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  2987.                                    tfline[tlevel]
  2988.                                    );
  2989.                         }
  2990. #else
  2991.                         if (xcmdsrc > 0) {
  2992.                             printf("Command stack:\n");
  2993.                             shostack();
  2994.                         }
  2995. #endif /* COMMENT */
  2996.  
  2997.                     }
  2998.                     xx = -2;
  2999.                 }
  3000.                 havetoken = 1;
  3001.                 debug(F101,"HAVE TOKEN","",xx);
  3002.             }
  3003.             if (xx > -1) {
  3004.                 topcmd = xx;            /* Top-level command index */
  3005. #ifndef NOSPL
  3006.                 if (maclvl > -1)
  3007.                   lastcmd[maclvl] = xx;
  3008. #endif /* NOSPL */
  3009.                 debug(F101,"topcmd","",topcmd);
  3010.                 debug(F101,"cmflgs","",cmflgs);
  3011.             }
  3012.  
  3013. #ifndef NOSPL
  3014.             /* Special handling for IF..ELSE */
  3015.  
  3016.             debug(F101,"cmdlvl","",cmdlvl);
  3017.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  3018.  
  3019.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  3020.               ifcmd[cmdlvl]++;
  3021.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  3022.               ifcmd[cmdlvl] = 0;
  3023.  
  3024.             /* Execute the command and take action based on return code. */
  3025.  
  3026.             if (nulcmd) {               /* Ignoring this command? */
  3027.                 xx = XXCOM;             /* Make this command a comment. */
  3028.             }
  3029.             fnsuccess = 1;              /* For catching \function() errors */
  3030. #endif /* NOSPL */
  3031.  
  3032.             debug(F101,"calling docmd()","",xx);
  3033.             zz = docmd(xx);             /* Parse rest of command & execute. */
  3034.  
  3035. #ifndef NOSPL
  3036.             if (fnerror && !fnsuccess)
  3037.               success = 0;
  3038. #endif /* NOSPL */
  3039.             debug(F101,"docmd returns","",zz);
  3040.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  3041.             /* debug(F011,"atmbuf",atmbuf,30); */
  3042. #ifdef MAC
  3043.             if (tlevel > -1) {
  3044.                 if (sstate == 'a') {    /* if cmd-. cancel */
  3045.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  3046.                     sstate = '\0';
  3047.                     dostop();
  3048.                     return(0);          /* End of init file or whatever. */
  3049.                 }
  3050.             }
  3051. #endif /* MAC */
  3052.             switch (zz) {
  3053.               case -4:                  /* EOF (e.g. on redirected stdin) */
  3054.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  3055.               case -1:                  /* Reparse needed */
  3056.                 repars = 1;             /* Just set reparse flag and... */
  3057.                 continue;
  3058. #ifdef OS2
  3059.               case -7:                  /* They typed a disk letter */
  3060.                 if (!zchdir((char *)cmdbuf)) {
  3061.                     perror((char *)cmdbuf);
  3062.                     success = 0;
  3063.                 } else success = 1;
  3064.                 repars = 0;
  3065.                 continue;
  3066.  
  3067. #endif /* OS2 */
  3068.               case -6:                  /* Invalid command given w/no args */
  3069.               case -2:                  /* Invalid command given w/args */
  3070. #ifdef COMMENT
  3071. #ifndef NOSPL
  3072.                     /* This is going to be really ugly... */
  3073.                     yy = mlook(mactab,atmbuf,nmac); /* Look in macro table */
  3074.                     if (yy > -1) {                  /* If it's there */
  3075.                         if (zz == -2) {             /* insert "do" */
  3076.                             char *mp;
  3077.                             mp = malloc((int)strlen(cmdbuf) + 5);
  3078.                             if (!mp) {
  3079.                                 printf("?malloc error 1\n");
  3080.                                 return(-2);
  3081.                             }
  3082.                             sprintf(mp,"do %s ",cmdbuf); /* SAFE (checked) */
  3083.                             ckstrncpy(cmdbuf,mp,CMDBL);
  3084.                             free(mp);
  3085.                             mp = NULL;
  3086.                         } else {
  3087.                             if (((int)strlen(atmbuf) + 5) < CMDBL)
  3088.                               sprintf(cmdbuf,"do %s %c",atmbuf, CR); /* SAFE */
  3089.                             else
  3090.                               ckstrncpy(cmdbuf,"echo ?Too long\r",CMDBL);
  3091.                         }
  3092.                         if (ifcmd[cmdlvl] == 2) /* This one doesn't count! */
  3093.                           ifcmd[cmdlvl]--;
  3094.                         debug(F111,"stuff cmdbuf",cmdbuf,zz);
  3095.                         repars = 1;     /* Go for reparse */
  3096.                         continue;
  3097.                     } else {
  3098.                         char *p;
  3099.                         int n;
  3100.                         p = cmdbuf;
  3101.                         lp = line;
  3102.                         n = LINBUFSIZ;
  3103.                         if (cmflgs == 0) printf("\n");
  3104.                         if (zzstring(p,&lp,&n) > -1)
  3105.                           printf("?Invalid: %s\n",line);
  3106.                         else
  3107.                           printf("?Invalid: %s\n",cmdbuf);
  3108.                     } /* (fall thru...) */
  3109. #else
  3110.                     printf("?Invalid: %s\n",cmdbuf);
  3111. #endif /* NOSPL */
  3112. #else /* Not COMMENT */
  3113.                     printf("?Invalid: %s\n",cmdbuf);
  3114. #endif /* COMMENT */
  3115.  
  3116.                 case -9:                /* Bad, error message already done */
  3117.                     success = 0;
  3118.                     debug(F110,"top-level cmkey failed",cmdbuf,0);
  3119.                     /* If in background w/ commands coming stdin, terminate */
  3120.                     if (pflag == 0 && tlevel < 0)
  3121.                       fatal("Kermit command error in background execution");
  3122. /*
  3123.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3124.   reprompt the user with as much of the command as didn't fail.
  3125. */
  3126. #ifdef CK_RECALL
  3127.                     if (cm_retry && !xcmdsrc) { /* If at top level */
  3128.                         int len;
  3129.                         char *p, *s;
  3130.                         len = strlen(cmdbuf); /* Length of command buffer */
  3131.                         p = malloc(len + 1);  /* Allocate space for copy */
  3132.                         if (p) {              /* If we got the space copy */
  3133.                             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3134.                             /* Chop off final field, the one that failed. */
  3135.                             s = p + len - 1;          /* Point to end */
  3136.                             while (*s == SP && s > p) /* Trim blanks */
  3137.                               s--;
  3138.                             while (*s != SP && s > p) /* Trim last field */
  3139.                               s--;
  3140.                             if (s > p)        /* Keep the space */
  3141.                               s++;            /* after last good field */
  3142.                             if (s >= p)       /* Cut off remainder */
  3143.                               *s = NUL;
  3144.                             cmini(ckxech);    /* Reinitialize the parser */
  3145.                             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3146.                             free(p);          /* Free temporary storage */
  3147.                             p = NULL;
  3148.                             prompt(xxstring); /* Reprint the prompt */
  3149.                             printf("%s",cmdbuf); /* Reprint partial command */
  3150.                             repars = 1;          /* Force reparse */
  3151.                             continue;
  3152.                         }
  3153.                     } else
  3154. #endif /* CK_RECALL */
  3155.                       if (!quiet) {
  3156. #ifdef COMMENT
  3157. #ifndef NOSPL
  3158.                           if (maclvl > -1)
  3159.                             printf("Macro: %s; ",
  3160.                                    m_arg[maclvl][0] ?
  3161.                                    m_arg[maclvl][0] : "");
  3162. #endif /* NOSPL */
  3163.                           if (tlevel > -1)
  3164.                             printf("Command file: %s, line %d\n",
  3165.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  3166.                                    tfline[tlevel]
  3167.                                    );
  3168. #else
  3169.                           if (xcmdsrc > 0) {
  3170.                               printf("Command stack:\n");
  3171.                               shostack();
  3172.                           }
  3173. #endif /* COMMENT */
  3174.                       }
  3175.                       cmini(ckxech);    /* (fall thru) */
  3176.  
  3177.                 case -3:                /* Empty command OK at top level */
  3178.                     repars = 0;         /* Don't need to reparse. */
  3179.                     continue;           /* Go back and get another command. */
  3180.  
  3181.                 default:                /* Command was successful. */
  3182. #ifndef NOSPL
  3183.                     debug(F101,"parser preparing to continue","",maclvl);
  3184. #endif /* NOSPL */
  3185.                     debug(F101,"parser success","",success);
  3186.                     repars = 0;         /* Don't need to reparse. */
  3187.                     continue;           /* Go back and get another command. */
  3188.                 }
  3189.         }
  3190. #ifndef NOSPL
  3191.         debug(F101,"parser breaks out of while loop","",maclvl);
  3192.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3193. #endif /* NOSPL */
  3194.     }
  3195.  
  3196. /* Got an action command, return start state. */
  3197.  
  3198.     return((int) sstate);
  3199. }
  3200.  
  3201. #ifndef NOSPL
  3202. /*
  3203.   OUTPUT command.
  3204.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3205. */
  3206. #define OBSIZE 80                       /* Size of local character buffer */
  3207.  
  3208. static int obn;                         /* Buffer offset (high water mark) */
  3209. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3210. static char *obp;                       /* Pointer to output buffer. */
  3211. _PROTOTYP( static int oboc, (char) );
  3212. _PROTOTYP( static int xxout, (char *, int) );
  3213.  
  3214. static int
  3215. #ifdef CK_ANSIC
  3216. xxout(char *obuf, int obsize)
  3217. #else
  3218. xxout(obuf, obsize) char *obuf; int obsize;
  3219. #endif /* CK_ANSIC */
  3220. /* xxout */ {                           /* OUTPUT command's output function */
  3221.     int i, rc;
  3222.  
  3223.     debug(F101,"xxout obsize","",obsize);
  3224.     debug(F101,"xxout pacing","",pacing);
  3225.     debug(F111,"xxout string",obuf,strlen(obuf));
  3226.  
  3227.     rc = 0;                             /* Initial return code. */
  3228.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3229.       goto xxout_x;                     /* Return successfully */
  3230.  
  3231.     rc = -1;                              /* Now assume failure */
  3232.     if (pacing == 0) {                    /* Is pacing enabled? */
  3233.         if ((local ?                      /* No, write entire string at once */
  3234.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3235.              conxo(obsize, obuf))         /* or to console */
  3236.             != obsize)
  3237.           goto xxout_x;
  3238.     } else {
  3239.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3240.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3241.               goto xxout_x;
  3242.             msleep(pacing);
  3243.         }
  3244.     }
  3245.     if (duplex) {
  3246. #ifdef OS2
  3247.         if (inecho && local) {
  3248. #ifndef NOLOCAL
  3249.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3250.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3251.             }
  3252. #endif /* NOLOCAL */
  3253.             conxo(obsize,obuf);
  3254.         } else if (seslog) {            /* or log session here */
  3255.             logstr((char *) obuf, obsize);
  3256.         }
  3257. #else /* OS2 */
  3258.         if (seslog) {
  3259.             logstr((char *) obuf, obsize);
  3260.         }
  3261.         if (inecho && local) {
  3262.             conxo(obsize,obuf);
  3263.         }
  3264. #endif /* OS2 */
  3265.     }
  3266.     rc = 0;                             /* Success */
  3267.   xxout_x:
  3268.     obn = 0;                            /* Reset count */
  3269.     obp = obuf;                         /* and pointers */
  3270.     return(rc);                         /* return our return code */
  3271. }
  3272.  
  3273. #ifdef COMMENT
  3274. /*
  3275.   Macros for OUTPUT command execution, to make it go faster.
  3276. */
  3277. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3278. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3279.  
  3280. #else /* The macros cause some compilers to generate bad code. */
  3281.  
  3282. static int
  3283. #ifdef CK_ANSIC
  3284. oboc(char c)
  3285. #else
  3286. oboc(c) char c;
  3287. #endif /* CK_ANSIC */
  3288. /* oboc */ {                            /* OUTPUT command's output function */
  3289.  
  3290.     *obp++ = c;                         /* Deposit character */
  3291.     *obp = NUL;                         /* Flush buffer if it's now full */
  3292.  
  3293.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3294. }
  3295. #endif /* COMMENT */
  3296.  
  3297. /*  Routines for handling local variables -- also see popclvl().  */
  3298.  
  3299. VOID
  3300. freelocal(m) int m; {                   /* Free local variables */
  3301.     struct localvar * v, * tv;          /* at macro level m... */
  3302.     debug(F101,"freelocal level","",m);
  3303.     if (m < 0) return;
  3304.     v = localhead[m];                   /* List head for level m */
  3305.     while (v) {
  3306.         if (v->lv_name)                 /* Variable name */
  3307.           free(v->lv_name);
  3308.         if (v->lv_value)                /* Value */
  3309.           free(v->lv_value);
  3310.         tv = v;                         /* Save pointer to this node */
  3311.         v = v->lv_next;                 /* Get next one */
  3312.         if (tv)                         /* Free this one */
  3313.           free((char *)tv);
  3314.     }
  3315.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3316. }
  3317.  
  3318. #define MAXLOCALVAR 64
  3319.  
  3320. /* Return a pointer to the definition of a user-defined variable */
  3321.  
  3322. static char *
  3323. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3324.     char * p;
  3325.     char c;
  3326.     *isarray = 0;
  3327.     if (!s) return(NULL);
  3328.     if (!*s) return(NULL);
  3329.     p = s;
  3330.     if (*s == CMDQ) {
  3331.         p++;
  3332.         if (!*p)
  3333.           return(NULL);
  3334.         if ((c = *p) == '%') {          /* Scalar variable. */
  3335.             c = *++p;                   /* Get ID character. */
  3336.             p = "";                     /* Assume definition is empty */
  3337.             if (!c)
  3338.               return(NULL);
  3339.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3340.                 if (maclvl < 0)         /* Digit variables are global */
  3341.                   return(g_var[c]);     /* if no macro is active */
  3342.                 else                    /* otherwise */
  3343.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3344.             } else if (isalpha(c)) {
  3345.                 if (isupper(c)) c -= ('a'-'A');
  3346.                 return(g_var[c]);           /* Letter for global variable */
  3347.             } else
  3348.               return(NULL);
  3349.         } else if (c == '&') {          /* Array reference. */
  3350.             int x, vbi, d;
  3351.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3352.             if (x > -1 || d == -17) {
  3353.                 *isarray = 1;
  3354.                 *x1 = vbi;
  3355.                 *x2 = (d == -17) ? 0 : d;
  3356.             }
  3357.             if (x < 0)
  3358.               return(NULL);
  3359.             if (chkarray(vbi,d) > 0) {  /* Array is declared? */
  3360.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3361.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3362.                     char **ap;
  3363.                     ap = a_ptr[vbi];
  3364.                     return((ap) ? ap[d] : NULL);
  3365.                 }
  3366.             }
  3367.         }
  3368.         return(NULL);
  3369.     } else {
  3370.         int k;
  3371.         k = mxlook(mactab,s,nmac);
  3372.         return((k > -1) ? mactab[k].mval : NULL);
  3373.     }
  3374. }
  3375.  
  3376.  
  3377. int
  3378. addlocal(p) char * p; {
  3379.     int x, z, isarray = 0;
  3380.     char * s;
  3381.     struct localvar * v, *prev = (struct localvar *)NULL;
  3382.     extern int tra_asg; int tra_tmp;
  3383.  
  3384.     tra_tmp = tra_asg;
  3385.  
  3386.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3387.     if (isarray) {                      /* Arrays are handled specially */
  3388.         pusharray(x,z);
  3389.         return(0);
  3390.     }
  3391.     if (!s) s = "";
  3392.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3393.         while (v) {                     /* Find end of list */
  3394.             prev = v;
  3395.             v = v->lv_next;
  3396.         }
  3397.     }
  3398.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3399.     if (!v) {
  3400.         printf("?Failure to allocate storage for local variables");
  3401.         return(-9);
  3402.     }
  3403.     if (!localhead[cmdlvl])             /* If first, set list head */
  3404.       localhead[cmdlvl] = v;
  3405.     else                                /* Otherwise link previous to this */
  3406.       prev->lv_next = v;
  3407.     prev = v;                           /* And make this previous */
  3408.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3409.  
  3410.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3411.       return(-1);
  3412.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3413.  
  3414.     if (*s) {
  3415.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3416.           return(-1);
  3417.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3418.     } else
  3419.       v->lv_value = NULL;
  3420.  
  3421.     tra_asg = 0;
  3422.     delmac(p,1);                        /* Delete the original macro */
  3423.     tra_asg = tra_tmp;
  3424.     return(0);
  3425. }
  3426.  
  3427. int
  3428. dolocal() {                             /* Do the LOCAL command */
  3429.     int i, x;
  3430.     char * s;
  3431.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3432.  
  3433.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3434.       return(x);
  3435.  
  3436.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3437.  
  3438.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3439.  
  3440.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3441.         if (addlocal(list[i]) < 0)
  3442.           goto localbad;
  3443.     }
  3444.     return(success = 1);
  3445.  
  3446.   localbad:
  3447.     printf("?Failure to allocate storage for local variables");
  3448.     freelocal(cmdlvl);
  3449.     return(-9);
  3450. }
  3451.  
  3452. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3453.  
  3454. #ifndef NOKVERBS
  3455. #define K_BUFLEN 30
  3456. #define SEND_BUFLEN 255
  3457. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3458.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3459. #endif /* NOKVERBS */
  3460.  
  3461. int outesc = 1;                         /* Process special OUTPUT escapes */
  3462.  
  3463. int
  3464. dooutput(s, cx) char *s; int cx; {
  3465. #ifdef SSHBUILTIN
  3466.     extern int ssh_cas;
  3467.     extern char * ssh_cmd;
  3468. #endif /* SSHBUILTIN */
  3469.     int x, xx, y, quote;                /* Workers */
  3470.     int is_tn = 0;
  3471.  
  3472.     is_tn = (local && network && IS_TELNET()) ||
  3473.       (!local && sstelnet);
  3474.  
  3475.     debug(F111,"dooutput s",s,(int)strlen(s));
  3476.  
  3477.     if (local) {                        /* Condition external line */
  3478. #ifdef NOLOCAL
  3479.         goto outerr;
  3480. #else
  3481.         if (ttchk() < 0) {
  3482.             printf("?Connection %s %s is not open.\n",
  3483.                    network ? "to" : "on",
  3484.                    ttname
  3485.                    );
  3486.             return(0);
  3487.         }
  3488.         if (ttvt(speed,flow) < 0) {
  3489.             printf("?OUTPUT initialization error\n");
  3490.             return(0);
  3491.         }
  3492. #endif /* NOLOCAL */
  3493.     }
  3494. #ifdef SSHBUILTIN
  3495.     if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd && 
  3496.          !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
  3497.         if (!quiet)
  3498.             printf("?SSH Subsystem active: %s\n", ssh_cmd);
  3499.         return(0);
  3500.     }
  3501. #endif /* SSHBUILTIN */
  3502.  
  3503.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3504.         x = strlen(s);                  /* Just send the string literally */
  3505.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3506.         return(success = (xx == x) ? 1 : 0);
  3507.     }
  3508.     quote = 0;                          /* Initialize backslash (\) quote */
  3509.     obn = 0;                            /* Reset count */
  3510.     obp = obuf;                         /* and pointers */
  3511.  
  3512.   outagain:
  3513.     while ((x = *s++)) {                /* Loop through the string */
  3514.         y = 0;                          /* Error code, 0 = no error. */
  3515.         debug(F000,"dooutput","",x);
  3516.         if (quote) {                    /* This character is quoted */
  3517. #ifndef NOKVERBS
  3518.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3519.                extern struct keytab kverbs[];
  3520.                extern int nkverbs;
  3521.                extern char * keydefptr;
  3522.                extern int keymac;
  3523.                extern int keymacx;
  3524.                int x, y, brace = 0;
  3525.                int pause;
  3526.                char * p, * b;
  3527.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3528.                char osendbuf[SEND_BUFLEN +1];
  3529.                int  sendndx = 0;
  3530.  
  3531.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3532.                  goto outerr;
  3533.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3534.                {                        /* Have K verb? */
  3535.                    if (!*s) {
  3536.                        break;
  3537.                    }
  3538. /*
  3539.   We assume that the verb name is {braced}, or it extends to the end of the
  3540.   string, s, or it ends with a space, control character, or backslash.
  3541. */
  3542.                    p = kbuf;            /* Copy verb name into local buffer */
  3543.                    x = 0;
  3544.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3545.                        if (brace && *s == '}') {
  3546.                            break;
  3547.                        }
  3548.                        *p++ = *s++;
  3549.                    }
  3550.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3551.                      s--;               /*  back up so we get another look. */
  3552.                    brace = 0;
  3553.                    *p = NUL;            /* Terminate. */
  3554.                    p = kbuf;            /* Point back to beginning */
  3555.                    debug(F110,"dooutput kverb",p,0);
  3556.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3557.                    debug(F101,"dooutput lookup",0,y);
  3558.                    if (y > -1) {
  3559.                        if (sendndx) {
  3560.                            dooutput(osendbuf,cx);
  3561.                            sendndx = 0;
  3562.                        }
  3563.                        dokverb(VCMD,y);
  3564. #ifndef NOSPL
  3565.                    } else {             /* Is it a macro? */
  3566.                        y = mxlook(mactab,p,nmac);
  3567.                        if (y > -1) {
  3568.                            cmpush();
  3569.                            keymac = 1;  /* Flag for key macro active */
  3570.                            keymacx = y; /* Key macro index */
  3571.                            keydefptr = s; /* Where to resume next time */
  3572.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3573.                            parser(1);
  3574.                            cmpop();
  3575.                        }
  3576. #endif /* NOSPL */
  3577.                    }
  3578.                }
  3579.                quote = 0;
  3580.                continue;
  3581.            } else
  3582. #endif /* NOKVERBS */
  3583.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3584.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3585.                    goto outerr;
  3586.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3587.                  if (local)
  3588.                    ttoc(NUL);
  3589.                  else
  3590.                    conoc(NUL);
  3591.                  quote = 0;
  3592.                  continue;
  3593.  
  3594.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3595.  
  3596.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3597.                   goto outerr;
  3598.                 debug(F100,"OUTPUT BREAK","",0);
  3599. #ifndef NOLOCAL
  3600.                 ttsndb();               /* Send BREAK signal */
  3601. #else
  3602.                  if (local)
  3603.                    ttoc(NUL);
  3604.                  else
  3605.                    conoc(NUL);
  3606. #endif /* NOLOCAL */
  3607.                 quote = 0;              /* Turn off quote flag */
  3608.                 continue;               /* and not the b or B */
  3609. #ifdef CK_LBRK
  3610.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3611.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3612.                    goto outerr;
  3613.                  debug(F100,"OUTPUT Long BREAK","",0);
  3614. #ifndef NOLOCAL
  3615.                  ttsndlb();             /* Send Long BREAK signal */
  3616. #else
  3617.                  if (local)
  3618.                    ttoc(NUL);
  3619.                  else
  3620.                    conoc(NUL);
  3621. #endif /* NOLOCAL */
  3622.                  quote = 0;             /* Turn off quote flag */
  3623.                  continue;              /* and not the l or L */
  3624. #endif /* CK_LBRK */
  3625.  
  3626.              } else if (x == CMDQ) {    /* Backslash itself */
  3627.                  debug(F100,"OUTPUT CMDQ","",0);
  3628.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3629.                  if (xx < 0)
  3630.                    goto outerr;
  3631.                  quote = 0;
  3632.                  continue;
  3633.  
  3634.              } else {                   /* if \ not followed by special esc */
  3635.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3636.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3637.                  if (xx < 0)
  3638.                    goto outerr;
  3639.                  quote = 0;             /* Turn off quote flag */
  3640.              }
  3641.         } else if (x == CMDQ) {         /* This is the quote character */
  3642.             quote = 1;                  /* Go back and get next character */
  3643.             continue;                   /* which is quoted */
  3644.         }
  3645.         xx = oboc(dopar((char)x));      /* Output this character */
  3646.         debug(F111,"dooutput",obuf,obn);
  3647.         if (xx < 0)
  3648.           goto outerr;
  3649. #ifdef COMMENT
  3650.         if (seslog && duplex) {         /* Log the character if log is on */
  3651.             logchar((char)x);
  3652.         }
  3653. #endif /* COMMENT */
  3654.         if (x == '\015') {              /* String contains carriage return */
  3655.             int stuff = -1, stuff2 = -1;
  3656.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3657.                 stuff = LF;             /* Stuff LF */
  3658.             }
  3659. #ifdef TNCODE
  3660.             /* TELNET NEWLINE ON/OFF/RAW */
  3661.             if (is_tn) {
  3662.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3663.                         tn_b_nlm :
  3664.                         tn_nlm
  3665.                         ) {
  3666.                   case TNL_CR:
  3667.                     break;
  3668.                   case TNL_CRNUL:
  3669.                     stuff2 = stuff;
  3670.                     stuff  = NUL;
  3671.                     break;
  3672.                   case TNL_CRLF:
  3673.                     stuff2 = stuff;
  3674.                     stuff = LF;
  3675.                     break;
  3676.                 }
  3677.             }
  3678. #endif /* TNCODE */
  3679.             if (stuff > -1) {           /* Stuffing another character... */
  3680.                 xx = oboc(dopar((CHAR)stuff));
  3681.                 if (xx < 0)
  3682.                   goto outerr;
  3683. #ifdef COMMENT
  3684.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3685.                     logchar((char)stuff);
  3686.                 }
  3687. #endif /* COMMENT */
  3688.             }
  3689.             if (stuff2 > -1) {          /* Stuffing another character... */
  3690.                 xx = oboc(dopar((CHAR)stuff2));
  3691.                 if (xx < 0)
  3692.                   goto outerr;
  3693. #ifdef COMMENT
  3694.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3695.                     logchar((char)stuff2);
  3696.                 }
  3697. #endif /* COMMENT */
  3698.             }
  3699.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3700.               goto outerr;
  3701.         }
  3702.     }
  3703.     if (cx == XXLNOUT) {
  3704.         s = "\015";
  3705.         cx = 0;
  3706.         goto outagain;
  3707.     }
  3708.     if (quote == 1)                     /* String ended with backslash */
  3709.       xx = oboc(dopar(CMDQ));
  3710.  
  3711.     if (obn > 0)                        /* OUTPUT done */
  3712.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3713.         goto outerr;
  3714.     return(1);
  3715.  
  3716. outerr:                                 /* OUTPUT command error handler */
  3717.     if (msgflg) printf("?OUTPUT execution error\n");
  3718.     return(0);
  3719.  
  3720. /* Remove "local" OUTPUT macro defininitions */
  3721.  
  3722. #ifdef COMMENT
  3723. /* No more macros ... */
  3724. #undef oboc
  3725. #undef obfls
  3726. #endif /* COMMENT */
  3727. }
  3728. #endif /* NOSPL */
  3729.  
  3730. /* Display version herald and initial prompt */
  3731.  
  3732. VOID
  3733. herald() {
  3734.     int x = 0, i;
  3735.     extern int srvcdmsg;
  3736.     extern char * cdmsgfile[];
  3737. #ifndef NOCMDL
  3738.     extern char * bannerfile;
  3739.     debug(F110,"herald bannerfile",bannerfile,0);
  3740.     if (bannerfile) {
  3741.         concb((char)escape);
  3742.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3743.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3744.             if (srvcdmsg) {
  3745.                 for (i = 0; i < 8; i++) {
  3746.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3747.                     if (zchki(cdmsgfile[i]) > -1) {
  3748.                         printf("\n");
  3749.                         dotype(cdmsgfile[i],
  3750.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3751.                         break;
  3752.                     }
  3753.                 }
  3754.             }
  3755.             return;
  3756.         }
  3757.     }
  3758. #endif /* NOCMDL */
  3759.  
  3760. #ifdef COMMENT
  3761.     /* The following generates bad code in SCO compilers. */
  3762.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3763.     /* statement when all conditions are false, x has a value of -32. */
  3764.     if (noherald || quiet || bgset > 0 || (bgset != 0 && backgrd != 0))
  3765.       x = 1;
  3766. #else
  3767.     x = 0;
  3768.     if (noherald || quiet)
  3769.       x = 1;
  3770.     else if (bgset > 0)
  3771.       x = 1;
  3772.     else if (bgset < 0 && backgrd > 0)
  3773.       x = 1;
  3774. #endif /* COMMENT */
  3775.  
  3776.     if (x == 0) {
  3777. #ifdef datageneral
  3778.         printf("%s, for%s\n",versio,ckxsys);
  3779. #else
  3780. #ifdef OSK
  3781.         printf("%s, for%s\n",versio,ckxsys);
  3782. #else
  3783. #ifdef CK_64BIT
  3784.         printf("%s, for%s (64-bit)\n\r",versio,ckxsys);
  3785. #else
  3786.         printf("%s, for%s\n\r",versio,ckxsys);
  3787. #endif/* CK_64BIT */
  3788. #endif /* OSK */
  3789. #endif /* datageneral */
  3790.         printf(" Copyright (C) 1985, 2005,\n");
  3791.         printf("  Trustees of Columbia University in the City of New York.\n");
  3792. #ifdef OS2
  3793.        shoreg();
  3794. #endif /* OS2 */
  3795.  
  3796.         if (!quiet && !backgrd) {
  3797. #ifdef COMMENT
  3798. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3799.             char * s;
  3800.             extern int xfermode;
  3801. #ifdef VMS
  3802.             s = "AUTOMATIC";
  3803. #else
  3804.             if (xfermode == XMODE_A) {
  3805.                 s = "AUTOMATIC";
  3806.             } else {
  3807.                 s = gfmode(binary,1);
  3808.             }
  3809.             if (!s) s = "";
  3810. #endif /* VMS */
  3811.             if (*s)
  3812.               printf("Default file-transfer mode is %s\n", s);
  3813. #endif /* COMMENT */
  3814.  
  3815.             debug(F111,"herald","srvcdmsg",srvcdmsg);
  3816.             if (srvcdmsg) {
  3817.                 for (i = 0; i < 8; i++) {
  3818.                     debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3819.                     if (zchki(cdmsgfile[i]) > -1) {
  3820.                         printf("\n");
  3821.                         dotype(cdmsgfile[i],
  3822.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3823.                         break;
  3824.                     }
  3825.                 }
  3826.             }
  3827.             printf("Type ? or HELP for help.\n");
  3828.         }
  3829.     }
  3830. }
  3831.  
  3832. /*  G F M O D E  --  Get File (transfer) Mode  */
  3833.  
  3834. char *
  3835. gfmode(binary,upcase) int binary, upcase; {
  3836.     char * s;
  3837.     switch (binary) {
  3838.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3839. #ifdef VMS
  3840.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3841.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3842.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3843.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3844. #else
  3845. #ifdef MAC
  3846.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3847.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3848. #else
  3849.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3850. #ifdef CK_LABELED
  3851.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3852. #endif /* CK_LABELED */
  3853. #endif /* MAC */
  3854. #endif /* VMS */
  3855.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3856.       default: s = "";
  3857.     }
  3858.     return(s);
  3859. }
  3860.  
  3861. #ifndef NOSPL
  3862. static int
  3863. isaa(s) char * s; {                     /* Is associative array */
  3864.     char c;
  3865.     int x;
  3866.     if (!s) s = "";
  3867.     if (!*s) return(0);
  3868.     s++;
  3869.     while ((c = *s++)) {
  3870.         if (c == '<') {
  3871.             x = strlen(s);
  3872.             return ((*(s+x-1) == '>') ? 1 : 0);
  3873.         }
  3874.     }
  3875.     return(0);
  3876. }
  3877.  
  3878. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3879.  
  3880. /*
  3881.   Call this way:  v = mlook(table,word,n);
  3882.  
  3883.     table - a 'struct mtab' table.
  3884.     word  - the target string to look up in the table.
  3885.     n     - the number of elements in the table.
  3886.  
  3887.   The keyword table must be arranged in ascending alphabetical order, and
  3888.   all letters must be lowercase.
  3889.  
  3890.   Returns the table index, 0 or greater, if the name was found, or:
  3891.  
  3892.    -3 if nothing to look up (target was null),
  3893.    -2 if ambiguous,
  3894.    -1 if not found.
  3895.  
  3896.   A match is successful if the target matches a keyword exactly, or if
  3897.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3898.   target matches two or more keywords from the table.
  3899. */
  3900. int
  3901. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3902.     register int i;
  3903.     int v, w, cmdlen = 0;
  3904.     char c = 0, c1, * s;
  3905.     if (!cmd) cmd = "";
  3906.  
  3907.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3908.     debug(F111,"MLOOK",cmd,cmdlen);
  3909.  
  3910.     c1 = *cmd;
  3911.     if (isupper(c1))
  3912.       c1 = tolower(c1);
  3913.     if (cmdlen < 1)
  3914.       return(-3);
  3915.  
  3916. /* Not null, look it up */
  3917.  
  3918.     if (n < 12) {                       /* Not worth it for small tables */
  3919.         i = 0;
  3920.     } else {                            /* Binary search for where to start */
  3921.         int lo = 0;
  3922.         int hi = n;
  3923.         int count = 0;
  3924.         while (lo+2 < hi && ++count < 12) {
  3925.             i = lo + ((hi - lo) / 2);
  3926.             c = *(table[i].kwd);
  3927.             if (isupper(c)) c = tolower(c);
  3928.             if (c < c1) {
  3929.                 lo = i;
  3930.             } else {
  3931.                 hi = i;
  3932.             }
  3933.         }
  3934.         i = (c < c1) ? lo+1 : lo;
  3935.     }
  3936.     for ( ; i < n-1; i++) {
  3937.         s = table[i].kwd;
  3938.         if (!s) s = "";
  3939.         if (!*s) continue;              /* Empty table entry */
  3940.         c = *s;
  3941.         if (isupper(c)) c = tolower(c);
  3942.         if (c1 != c) continue;          /* First char doesn't match */
  3943.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  3944.           return(i);
  3945.         v = !ckstrcmp(s,cmd,cmdlen,0);
  3946.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3947.         if (v && w)                     /* Have abbreviated match? */
  3948.           return(i);
  3949.         if (v)                          /* Ambiguous? */
  3950.           return(-2);
  3951.         if (w > 0)                      /* Past our alphabetic area? */
  3952.           return(-1);
  3953.     }
  3954.  
  3955. /* Last (or only) element */
  3956.  
  3957.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3958.       return(n-1);
  3959.  
  3960.     return(-1);
  3961. }
  3962.  
  3963. /* mxlook is like mlook, but an exact full-length match is required */
  3964.  
  3965. int
  3966. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3967.     register int i;
  3968.     int w, cmdlen = 0, one = 0;
  3969.     register char c = 0, c1, * s;
  3970.  
  3971.     if (!cmd) cmd = "";                 /* Check args */
  3972.  
  3973.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3974.     debug(F111,"MXLOOK",cmd,cmdlen);
  3975.  
  3976.     c1 = *cmd;                          /* First char of string to look up */
  3977.     if (isupper(c1))
  3978.       c1 = tolower(c1);
  3979.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  3980.       one = 1;
  3981.  
  3982.     if (cmdlen < 1)                     /* Nothing to look up */
  3983.       return(-3);
  3984.  
  3985.     if (n < 12) {                       /* Not worth it for small tables */
  3986.         i = 0;
  3987.     } else {                            /* Binary search for where to start */
  3988.         int lo = 0;
  3989.         int hi = n;
  3990.         int count = 0;
  3991.         while (lo+2 < hi && ++count < 12) {
  3992.             i = lo + ((hi - lo) / 2);
  3993.             c = *(table[i].kwd);
  3994.             if (isupper(c)) c = tolower(c);
  3995.             if (c < c1) {
  3996.                 lo = i;
  3997.             } else {
  3998.                 hi = i;
  3999.             }
  4000.         }
  4001.         i = (c < c1) ? lo+1 : lo;
  4002.     }
  4003.     for ( ; i < n; i++) {               /* Look thru table */
  4004.         s = table[i].kwd;               /* This entry */
  4005.         if (!s) s = "";
  4006.         if (!*s) continue;              /* Empty table entry */
  4007.         c = *s;
  4008.         if (isupper(c)) c = tolower(c);
  4009.         if (c1 != c) continue;          /* First char doesn't match */
  4010.         if (one) {                      /* Name is one char long */
  4011.             if (!*(s+1))
  4012.               return(i);                /* So is table entry */
  4013.         }
  4014. #ifdef COMMENT
  4015.         if (((int)strlen(s) == cmdlen) &&
  4016.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  4017. #else
  4018.         w = ckstrcmp(s,cmd,-1,0);
  4019.         if (!w) return(i);
  4020.         if (w > 0) return(-1);
  4021. #endif /* COMMENT */
  4022.     }
  4023.     return(-1);
  4024. }
  4025.  
  4026. /* mxxlook is like mxlook, but case-sensitive */
  4027.  
  4028. int
  4029. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  4030.     int i, cmdlen;
  4031.     if (!cmd) cmd = "";
  4032.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  4033.     /* debug(F111,"mxxlook target",cmd,n); */
  4034.     for (i = 0; i < n; i++) {
  4035.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  4036.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  4037.           return(i);
  4038.     }
  4039.     return(-1);
  4040. }
  4041.  
  4042. static int
  4043. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  4044.     if (val)
  4045.       printf(">>> %s: \"%s\"\n", nam, val);
  4046.     else
  4047.       printf(">>> %s: (undef)\n", nam);
  4048.     return(0);
  4049. }
  4050.  
  4051. #ifdef USE_VARLEN                       /* Not used */
  4052.  
  4053. /*  V A R L E N  --  Get length of variable's value.
  4054.  
  4055.   Given a variable name, return the length of its definition or 0 if the
  4056.   variable is not defined.  If it is defined, set argument s to point to its
  4057.   definition.  Otherwise set s to NULL.
  4058. */
  4059. int
  4060. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  4061.     int x, z;
  4062.     char *p = NULL, c;
  4063.  
  4064.     *s = NULL;
  4065.     if (!nam) return(0);                /* Watch out for null pointer */
  4066.     if (*nam == CMDQ) {
  4067.         nam++;
  4068.         if (*nam == '%') {              /* If it's a variable name */
  4069.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  4070.             p = (char *)0;              /* Initialize value pointer */
  4071.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4072.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  4073.             } else {                    /* It's a global variable */
  4074.                 if (c < 33 || c > GVARS) return(0);
  4075.                 p = g_var[c];           /* Get pointer from global-var table */
  4076.             }
  4077.         } else if (*nam == '&') {               /* An array reference? */
  4078.             char **q;
  4079.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4080.               return(-1);               /* return -1. */
  4081.             x -= ARRAYBASE;             /* Convert name to number. */
  4082.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4083.               return(0);                /* return -2. */
  4084.             if (z > a_dim[x])           /* If subscript out of range, */
  4085.               return(0);                /* return -3. */
  4086.             p = q[z];
  4087.         }
  4088.     } else {                            /* Macro */
  4089.         z = isaa(nam);
  4090.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  4091.         if (x < 0)
  4092.           return(0);
  4093.         p = mactab[x].mval;
  4094.     }
  4095.     if (p)
  4096.       *s = p;
  4097.     else
  4098.       p = "";
  4099.     return((int)strlen(p));
  4100. }
  4101. #endif /* USE_VARLEN */
  4102.  
  4103. /*
  4104.   This routine is for the benefit of those compilers that can't handle
  4105.   long string constants or continued lines within them.  Long predefined
  4106.   macros like FOR, WHILE, and XIF have their contents broken up into
  4107.   arrays of string pointers.  This routine concatenates them back into a
  4108.   single string again, and then calls the real addmac() routine to enter
  4109.   the definition into the macro table.
  4110. */
  4111. int
  4112. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  4113.     int i, x, y; char *p;
  4114.     x = 0;                              /* Length counter */
  4115.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  4116.         debug(F111,"addmmac line",s[i],y);
  4117.         x += y;
  4118.     }
  4119.     debug(F101,"addmmac lines","",i);
  4120.     debug(F101,"addmmac loop exit","",y);
  4121.     debug(F111,"addmmac length",nam,x);
  4122.     if (x < 0) return(-1);
  4123.  
  4124.     p = malloc(x+1);                    /* Allocate space for all of it. */
  4125.     if (!p) {
  4126.         printf("?addmmac malloc error: %s\n",nam);
  4127.         debug(F110,"addmmac malloc error",nam,0);
  4128.         return(-1);
  4129.     }
  4130.     *p = '\0';                          /* Start off with null string. */
  4131.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4132.       ckstrncat(p,s[i],x+1);
  4133.     y = (int)strlen(p);                 /* Final precaution. */
  4134.     debug(F111,"addmmac constructed string",p,y);
  4135.     if (y == x) {
  4136.         y = addmac(nam,p);              /* Add result to the macro table. */
  4137.     } else {
  4138.         debug(F100,"addmmac length mismatch","",0);
  4139.         printf("\n!addmmac internal error!\n");
  4140.         y = -1;
  4141.     }
  4142.     free(p);                            /* Free the temporary copy. */
  4143.     return(y);
  4144. }
  4145.  
  4146. /* Here is the real addmac routine. */
  4147.  
  4148. /* Returns -1 on failure, macro table index >= 0 on success. */
  4149.  
  4150. int mtchanged = 0;
  4151.  
  4152. int
  4153. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4154.     int i, x, y, z, namlen, deflen, flag = 0;
  4155.     int replacing = 0, deleting = 0;
  4156.     char * p = NULL, c, *s;
  4157.     extern int tra_asg; int tra_tmp;
  4158.  
  4159.     if (!nam) return(-1);
  4160.     if (!*nam) return(-1);
  4161.  
  4162. #ifdef IKSD
  4163.     if (inserver &&
  4164. #ifdef IKSDCONF
  4165.         iksdcf
  4166. #else /* IKSDCONF */
  4167.         1
  4168. #endif /* IKSDCONF */
  4169.         ) {
  4170.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4171.             !ckstrcmp("on_logout",nam,-1,0))
  4172.           return(-1);
  4173.     }
  4174. #endif /* IKSD */
  4175.  
  4176.     namlen = 0;
  4177.     p = nam;
  4178.     while (*p++) namlen++;              /* (instead of strlen) */
  4179.  
  4180.     tra_tmp = tra_asg;                  /* trace... */
  4181.     debug(F111,"addmac nam",nam,namlen);
  4182.     if (!def) {                         /* Watch out for null pointer */
  4183.         deflen = 0;
  4184.         debug(F111,"addmac def","(null pointer)",deflen);
  4185.     } else {
  4186.         deflen = 0;
  4187.         p = def;
  4188.         while (*p++) deflen++;          /* (instead of strlen) */
  4189.         debug(F010,"addmac def",def,0);
  4190.     }
  4191. #ifdef USE_VARLEN                       /* NOT USED */
  4192.     /* This does not boost performance much because varlen() does a lot */
  4193.     x = varlen(nam,&s);
  4194.     if (x > 0 && x >= deflen) {
  4195.         strcpy(s,def);                  /* NOT USED */
  4196.         flag = 1;
  4197.         p = s;
  4198.     }
  4199. #endif /* USE_VARLEN */
  4200.  
  4201.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4202.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4203.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4204.         if (!flag) {
  4205.             tra_asg = 0;
  4206.             delmac(nam,0);              /* Delete any old value. */
  4207.             tra_asg = tra_tmp;
  4208.         }
  4209.         if (deflen < 1) {               /* Null definition */
  4210.             p = NULL;                   /* Better not malloc or strcpy! */
  4211.         } else if (!flag) {             /* A substantial definition */
  4212.             p = malloc(deflen + 1);     /* Allocate space for it */
  4213.             if (!p) {
  4214.                 printf("?addmac malloc error 2\n");
  4215.                 return(-1);
  4216.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4217.         }
  4218.  
  4219.         /* Now p points to the definition, or is a null pointer */
  4220.  
  4221.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4222.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4223.                 g_var[c] = p;           /* No, it's top level one */
  4224.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4225.             } else {                    /* Yes, it's a macro argument */
  4226.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4227.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4228.             }
  4229.         } else {                        /* It's a \%a-z variable */
  4230.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4231.             if (isupper(c)) c = (char) tolower(c);
  4232.             g_var[c] = p;               /* Put pointer in global-var table */
  4233.         }
  4234.         if (tra_asg) traceval(nam,p);
  4235.         return(0);
  4236.     } else if (*nam == '&') {           /* An array reference? */
  4237.         char **q = NULL;
  4238.         int rc = 0;
  4239.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4240.           return(-1);                   /* return -1. */
  4241.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4242.           rc = -2;                      /* subscript out of range, ret -2 */
  4243.         if (!flag) {
  4244.             tra_asg = 0;
  4245.             delmac(nam,0);              /* Delete any old value. */
  4246.             tra_asg = tra_tmp;
  4247.         }
  4248.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4249.         if (x > 'z' - ARRAYBASE + 1)
  4250.           rc = -1;
  4251.         if (rc != -1) {
  4252.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4253.               return(-3);               /* return -3. */
  4254.         }
  4255.         if (rc < 0)
  4256.           return(rc);
  4257.         if (!flag) {
  4258.             if (deflen > 0) {
  4259.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4260.                     printf("addmac macro error 7: %s\n",nam);
  4261.                     return(-4);         /* for new def, return -4 on fail. */
  4262.                 }
  4263.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4264.             } else p = NULL;
  4265.         }
  4266.         q[z] = p;                       /* Store pointer to it. */
  4267.         if (x == 0) {                   /* Arg vector array */
  4268.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4269.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4270.                     makestr(&(toparg[z]),p);
  4271.                 } else {
  4272.                     makestr(&(m_arg[maclvl][z]),p);
  4273.                 }
  4274.             }
  4275.         }
  4276.         if (tra_asg) traceval(nam,p);
  4277.         return(0);                      /* Done. */
  4278.     }
  4279.  
  4280. /* Not a macro argument or a variable, so it's a macro definition */
  4281.  
  4282. #ifdef USE_VARLEN
  4283.     if (flag) {
  4284.         if (tra_asg) traceval(nam,p);
  4285.         return(0);
  4286.     }
  4287. #endif /* USE_VARLEN */
  4288.     x = isaa(nam) ?                     /* If it's an associative array */
  4289.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4290.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4291.     if (x > -1) {                       /* If found... */
  4292.         if (deflen > 0)                 /* and a new definition was given */
  4293.           replacing = 1;                /* we're replacing */
  4294.         else                            /* otherwise */
  4295.           deleting = 1;                 /* we're deleting */
  4296.     }
  4297.     if (deleting) {                     /* Deleting... */
  4298.         if (delmac(nam,0) < 0)
  4299.           return(-1);
  4300.         mtchanged++;
  4301.         if (tra_asg) traceval(nam,p);
  4302.         return(0);
  4303.     } else if (deflen < 1)              /* New macro with no definition */
  4304.       return(0);                        /* Nothing to do. */
  4305.  
  4306.     if (replacing) {                    /* Replacing an existing macro */
  4307.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4308.             free(mactab[x].mval);       /* free it. */
  4309.             mactab[x].mval = NULL;
  4310.         }
  4311.         mtchanged++;
  4312.         y = x;                          /* Replacement index. */
  4313.  
  4314.     } else {                            /* Adding a new macro... */
  4315.         char c1, c2;                    /* Use fast lookup to find the */
  4316.         c1 = *nam;                      /* alphabetical slot. */
  4317.         if (isupper(c1)) c1 = (char) tolower(c1);
  4318.  
  4319.         if (nmac < 5) {                 /* Not worth it for small tables */
  4320.             y = 0;
  4321.         } else {                        /* First binary search to find */
  4322.             int lo = 0;                 /* where to start */
  4323.             int hi = nmac;
  4324.             int count = 0;
  4325.             char c = 0;
  4326.             while (lo+2 < hi && ++count < 12) {
  4327.                 y = lo + ((hi - lo) / 2);
  4328.                 c = *(mactab[y].kwd);
  4329.                 if (isupper(c)) c = (char) tolower(c);
  4330.                 if (c < c1) {
  4331.                     lo = y;
  4332.                 } else {
  4333.                     hi = y;
  4334.                 }
  4335.             }
  4336.             y = (c < c1) ? lo+1 : lo;
  4337.         }
  4338.         /* Now search linearly from starting location */
  4339.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4340.             c2 = *(mactab[y].kwd);
  4341.             if (isupper(c2)) c2 = (char) tolower(c2);
  4342.             if (c1 > c2)
  4343.               continue;
  4344.             if (c1 < c2)
  4345.               break;
  4346.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4347.               break;
  4348.         }
  4349.         if (y == MAC_MAX) {             /* Macro table is full. */
  4350.             debug(F101,"addmac table overflow","",y);
  4351.             printf("?Macro table overflow\n");
  4352.             return(-1);
  4353.         }
  4354.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4355.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4356.                 mactab[i].kwd = mactab[i-1].kwd;
  4357.                 mactab[i].mval = mactab[i-1].mval;
  4358.                 mactab[i].flgs = mactab[i-1].flgs;
  4359.             }
  4360.         }
  4361.         mtchanged++;
  4362.         p = malloc(namlen + 1);         /* Allocate space for name */
  4363.         if (!p) {
  4364.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4365.             return(-1);
  4366.         }
  4367.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4368.         mactab[y].kwd = p;              /* Add pointer to table */
  4369.     }
  4370.     if (deflen > 0) {                   /* If we have a definition */
  4371.         p = malloc(deflen + 1);         /* Get space */
  4372.         if (p == NULL) {
  4373.             printf("?Space exhausted - \"%s\"\n", nam);
  4374.             if (mactab[y].kwd) {
  4375.                 free(mactab[y].kwd);
  4376.                 mactab[y].kwd = NULL;
  4377.             }
  4378.             return(-1);
  4379.         } else {
  4380.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4381.         }
  4382.     } else {                            /* definition is empty */
  4383.         p = NULL;
  4384.     }
  4385.     mactab[y].mval = p;                 /* Macro points to definition */
  4386.     mactab[y].flgs = 0;                 /* No flags */
  4387.     if (!replacing)                     /* If new macro */
  4388.       nmac++;                           /* count it */
  4389.     if (tra_asg) traceval(nam,p);
  4390.     return(y);
  4391. }
  4392.  
  4393. int
  4394. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4395.     int i;
  4396.     extern int tra_asg;
  4397.     if (x < 0) return(x);
  4398.     if (tra_asg)
  4399.       traceval(mactab[x].kwd,NULL);
  4400.  
  4401.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4402.         free(mactab[x].kwd);
  4403.         mactab[x].kwd = NULL;
  4404.     }
  4405.     if (mactab[x].mval) {               /* and for the definition */
  4406.         free(mactab[x].mval);
  4407.         mactab[x].mval = NULL;
  4408.     }
  4409.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4410.         mactab[i].kwd = mactab[i+1].kwd;
  4411.         mactab[i].mval = mactab[i+1].mval;
  4412.         mactab[i].flgs = mactab[i+1].flgs;
  4413.     }
  4414.     nmac--;                             /* One less macro */
  4415.  
  4416.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4417.     mactab[nmac].mval = NULL;
  4418.     mactab[nmac].flgs = 0;
  4419.     mtchanged++;
  4420.     return(0);
  4421. }
  4422.  
  4423. int
  4424. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4425.     int x, z;
  4426.     char *p, c;
  4427.     extern int tra_asg;
  4428.  
  4429.     if (!nam) return(0);                /* Watch out for null pointer */
  4430.     debug(F110,"delmac nam",nam,0);
  4431. #ifdef IKSD
  4432.     if ( inserver &&
  4433. #ifdef IKSDCONF
  4434.         iksdcf
  4435. #else /* IKSDCONF */
  4436.         1
  4437. #endif /* IKSDCONF */
  4438.         ) {
  4439.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4440.             !ckstrcmp("on_logout",nam,-1,0))
  4441.           return(-1);
  4442.     }
  4443. #endif /* IKSD */
  4444.  
  4445.     if (*nam == CMDQ) nam++;
  4446.     if (*nam == '%') {                  /* If it's a variable name */
  4447.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4448.         p = (char *)0;                  /* Initialize value pointer */
  4449.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4450.             p = toparg[c - '0'];
  4451.             if (p) if (p != g_var[c]) {
  4452.                 free(p);
  4453.                 toparg[c - '0'] = NULL;
  4454.             }
  4455.             p = g_var[c];
  4456.             g_var[c] = NULL;            /* Zero the table entry */
  4457.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4458.             p = m_xarg[maclvl][c - '0'];
  4459.             if (p) if (p != g_var[c]) {
  4460.                 free(p);
  4461.                 m_xarg[maclvl][c - '0'] = NULL;
  4462.             }
  4463.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4464.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4465.         } else {                        /* It's a global variable */
  4466.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4467.             p = g_var[c];               /* Get pointer from global-var table */
  4468.             g_var[c] = NULL;            /* Zero the table entry */
  4469.         }
  4470.         if (p) {
  4471.             debug(F010,"delmac def",p,0);
  4472.             free(p);                    /* Free the storage */
  4473.             p = NULL;
  4474.         } else debug(F110,"delmac def","(null pointer)",0);
  4475.         if (tra_asg) traceval(nam,NULL);
  4476.         return(0);
  4477.     }
  4478.     if (*nam == '&') {                  /* An array reference? */
  4479.         char **q;
  4480.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4481.           return(-1);                   /* return -1. */
  4482.         x -= ARRAYBASE;                 /* Convert name to number. */
  4483.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4484.           return(-2);                   /* return -2. */
  4485.         if (z > a_dim[x])               /* If subscript out of range, */
  4486.           return(-3);                   /* return -3. */
  4487.         if (q[z]) {                     /* If there is an old value, */
  4488.             debug(F010,"delmac def",q[z],0);
  4489.             if (x != 0)                 /* Macro arg vector is just a copy */
  4490.               free(q[z]);               /* Others are real so free them */
  4491.             q[z] = NULL;
  4492.             if (x == 0) {               /* Arg vector array */
  4493.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4494.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4495.                         makestr(&(toparg[z]),NULL);
  4496.                     } else {
  4497.                         makestr(&(m_arg[maclvl][z]),NULL);
  4498.                     }
  4499.                 }
  4500.             }
  4501.             if (tra_asg) traceval(nam,NULL);
  4502.         } else debug(F010,"delmac def","(null pointer)",0);
  4503.     }
  4504.  
  4505.    /* Not a variable or an array, so it must be a macro. */
  4506.  
  4507.     z = isaa(nam);
  4508.     debug(F111,"delmac isaa",nam,z);
  4509.     debug(F111,"delmac exact",nam,exact);
  4510.     x = z ? mxxlook(mactab,nam,nmac) :
  4511.       exact ? mxlook(mactab,nam,nmac) :
  4512.         mlook(mactab,nam,nmac);
  4513.     if (x < 0) {
  4514.         debug(F111,"delmac mlook",nam,x);
  4515.         return(x);
  4516.     }
  4517.     return(xdelmac(x));
  4518. }
  4519.  
  4520. VOID
  4521. initmac() {                             /* Init macro & variable tables */
  4522.     int i, j, x;
  4523.  
  4524.     nmac = 0;                           /* No macros */
  4525.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4526.         mactab[i].kwd = NULL;
  4527.         mactab[i].mval = NULL;
  4528.         mactab[i].flgs = 0;
  4529.     }
  4530.     mtchanged++;
  4531.     x = (MAXARGLIST + 1) * sizeof(char **);
  4532.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4533.         m_xarg[i] = (char **) malloc(x);
  4534.         mrval[i] = NULL;                /* Macro return value */
  4535.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4536.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4537.             if (j < 10)                 /* For the \%0..\%9 variables */
  4538.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4539.             if (m_xarg[i])              /* For \&_[] - all args. */
  4540.               m_xarg[i][j] = NULL;
  4541.         }
  4542.     }
  4543.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4544.         g_var[i] = NULL;
  4545.     }
  4546.     /* And the table of arrays */
  4547.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4548.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4549.         a_dim[i] = 0;                   /* and a dimension of zero */
  4550.         a_link[i] = -1;
  4551.         for (j = 0; j < CMDSTKL; j++) {
  4552.             aa_ptr[j][i] = (char **) NULL;
  4553.             aa_dim[j][i] = 0;
  4554.         }
  4555.     }
  4556. }
  4557.  
  4558. int
  4559. popclvl() {                             /* Pop command level, return cmdlvl */
  4560.     extern int tra_cmd;
  4561.     struct localvar * v;
  4562.     int i, topcmd;
  4563.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4564.     if (cmdlvl > 0) {
  4565.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4566.             while (v) {                 /* Yes */
  4567.                 if (v->lv_value)        /* Copy old ones back */
  4568.                   addmac(v->lv_name,v->lv_value);
  4569.                 else
  4570.                   delmac(v->lv_name,1);
  4571.                 v = v->lv_next;
  4572.             }
  4573.             freelocal(cmdlvl);          /* Free local storage */
  4574.         }
  4575.         /* Automatic arrays do not use the localhead list */
  4576.  
  4577.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4578.             if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
  4579.                 dclarray((char)(i+ARRAYBASE),0); /* Destroy global one */
  4580.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4581.                 a_dim[i] = aa_dim[cmdlvl][i];
  4582.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4583.                 aa_dim[cmdlvl][i] = 0;
  4584.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4585.                 dclarray((char)(i+ARRAYBASE),0); /* (see pusharray()) */
  4586.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4587.                 aa_dim[cmdlvl][i] = 0;
  4588.             }
  4589.  
  4590.             /* Otherwise do nothing - it is a local array that was declared */
  4591.             /* at a level above this one so leave it alone. */
  4592.         }
  4593.     }
  4594.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4595.         cmdlvl = 0;                     /* just make sure all the */
  4596.         tlevel = -1;                    /* stack pointers are set right */
  4597.         maclvl = -1;                    /* and return */
  4598.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4599.         debug(F101,"popclvl tlevel","",tlevel);
  4600.         if (tlevel > -1) {              /* Yes, */
  4601.             fclose(tfile[tlevel]);      /* close it */
  4602.  
  4603.             if (tra_cmd)
  4604.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4605.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4606.             if (tfnam[tlevel]) {        /* free storage for name */
  4607.                 free(tfnam[tlevel]);
  4608.                 tfnam[tlevel] = NULL;
  4609.             }
  4610.             tlevel--;                   /* and pop take level */
  4611.             cmdlvl--;                   /* and command level */
  4612.             quiet = xquiet[cmdlvl];
  4613.         } else
  4614.           tlevel = -1;
  4615.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4616.         topcmd = lastcmd[maclvl];
  4617.         debug(F101,"popclvl maclvl","",maclvl);
  4618.         if (maclvl > -1) {              /* Yes, */
  4619. #ifdef COMMENT
  4620.             int i;
  4621.             char **q;
  4622. #endif /* COMMENT */
  4623.             macp[maclvl] = "";          /* set macro pointer to null string */
  4624.             *cmdbuf = '\0';             /* clear the command buffer */
  4625.  
  4626.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4627.                 (m_arg[maclvl-1][0]) &&
  4628.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4629.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4630.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4631.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4632.                 mrval[maclvl+1]) {
  4633.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4634.             }
  4635.             if (maclvl+1 < MACLEVEL) {
  4636.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4637.                     free(mrval[maclvl+1]);
  4638.                     mrval[maclvl+1] = NULL;
  4639.                 }
  4640.             }
  4641.             if (tra_cmd)
  4642.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4643.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4644.  
  4645.             maclvl--;                   /* Pop macro level */
  4646.             cmdlvl--;                   /* and command level */
  4647.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4648.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4649.  
  4650.             quiet = xquiet[cmdlvl];
  4651.             if (maclvl > -1) {
  4652.                 a_ptr[0] = m_xarg[maclvl];
  4653.                 a_dim[0] = n_xarg[maclvl] - 1;
  4654.         debug(F111,"a_dim[0]","B",a_dim[0]);
  4655.             } else {
  4656.                 a_ptr[0] = topxarg;
  4657.                 a_dim[0] = topargc - 1;
  4658.         debug(F111,"a_dim[0]","C",a_dim[0]);
  4659.             }
  4660.         } else {
  4661.             maclvl = -1;
  4662.         }
  4663. #ifndef NOSEXP
  4664.         debug(F101,"popclvl topcmd","",topcmd);
  4665.         if (topcmd == XXSEXP) {
  4666.             extern char * sexpval;
  4667.             makestr(&(mrval[maclvl+1]),sexpval);
  4668.         }
  4669. #endif /* NOSEXP */
  4670.     } else {
  4671.         cmdlvl--;
  4672.     }
  4673.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4674.     if (prstring[cmdlvl]) {
  4675.         cmsetp(prstring[cmdlvl]);
  4676.         makestr(&(prstring[cmdlvl]),NULL);
  4677.     }
  4678. #ifndef MAC
  4679.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4680.         setint();
  4681.         concb((char)escape);            /* Go into cbreak mode */
  4682.     }
  4683. #endif /* MAC */
  4684.     xcmdsrc = cmdstk[cmdlvl].src;
  4685.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4686.     debug(F101,"popclvl tlevel","",tlevel);
  4687.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4688. }
  4689. #else /* No script programming language */
  4690. int popclvl() {                         /* Just close current take file. */
  4691.     if (tlevel > -1) {                  /* if any... */
  4692.         if (tfnam[tlevel]) {
  4693.             free(tfnam[tlevel]);
  4694.             tfnam[tlevel] = NULL;
  4695.         }
  4696.         fclose(tfile[tlevel--]);
  4697.     }
  4698.     if (tlevel == -1) {                 /* And if back at top level */
  4699.         setint();
  4700.         concb((char)escape);            /* and go back into cbreak mode. */
  4701.     }
  4702.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4703.     return(tlevel + 1);
  4704. }
  4705. #endif /* NOSPL */
  4706.  
  4707.  
  4708. #ifndef NOSPL
  4709. static int
  4710. iseom(m) char * m; {                    /* Test if at end of macro def */
  4711.     if (!m)
  4712.       m = "";
  4713.     debug(F111,"iseom",m,maclvl);
  4714.     while (*m) {
  4715.         /* Anything but Space and Comma means more macro is left */
  4716.         if ((*m > SP) && (*m != ',')) {
  4717.             debug(F111,"iseom return",m,0);
  4718.             return(0);
  4719.         }
  4720.         m++;
  4721.     }
  4722.     debug(F111,"iseom return",m,1);
  4723.     return(1);                          /* Nothing left */
  4724. }
  4725. #endif /* NOSPL */
  4726.  
  4727. /* Pop all command levels that can be popped */
  4728.  
  4729. int
  4730. prepop() {
  4731.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4732.         while (
  4733. #ifndef NOSPL
  4734.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4735. #endif /* NOSPL */
  4736.             (tlevel > -1) &&
  4737.             feof(tfile[tlevel]))        /* And at end of file... */
  4738. #ifndef NOSPL
  4739.                /* Or command source is macro... */
  4740.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4741.                 (maclvl > -1) &&
  4742.                 iseom(macp[maclvl])))  /* and at end of macro, then... */
  4743. #endif /* NOSPL */
  4744.         {
  4745.               popclvl();                /* pop command level. */
  4746.         }
  4747.     }
  4748.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4749. }
  4750.  
  4751. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4752.  
  4753. int
  4754. dostop() {
  4755.     extern int cmddep;
  4756.     while (popclvl()) ;         /* Pop all macros & take files */
  4757. #ifndef NOSPL
  4758.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4759.       while (cmpop() > -1) ;
  4760. #endif /* NOSPL */
  4761.     cmini(ckxech);              /* Clear the command buffer. */
  4762.     return(0);
  4763. }
  4764.  
  4765. /* Close the given log */
  4766.  
  4767. int
  4768. doclslog(x) int x; {
  4769.     int y;
  4770.     switch (x) {
  4771. #ifdef DEBUG
  4772.       case LOGD:
  4773.         if (deblog <= 0) {
  4774.             printf("?Debugging log wasn't open\n");
  4775.             return(0);
  4776.         }
  4777.         debug(F100,"Debug Log Closed","",0L);
  4778.         *debfil = '\0';
  4779.         deblog = 0;
  4780.         return(zclose(ZDFILE));
  4781. #endif /* DEBUG */
  4782.  
  4783. #ifndef NOXFER
  4784.       case LOGP:
  4785.         if (pktlog <= 0) {
  4786.             printf("?Packet log wasn't open\n");
  4787.             return(0);
  4788.         }
  4789.         *pktfil = '\0';
  4790.         pktlog = 0;
  4791.         return(zclose(ZPFILE));
  4792. #endif /* NOXFER */
  4793.  
  4794. #ifndef NOLOCAL
  4795.       case LOGS:
  4796.         if (seslog <= 0) {
  4797.             printf("?Session log wasn't open\n");
  4798.             return(0);
  4799.         }
  4800.         *sesfil = '\0';
  4801.         setseslog(0);
  4802.         return(zclose(ZSFILE));
  4803. #endif /* NOLOCAL */
  4804.  
  4805. #ifdef TLOG
  4806.       case LOGT: {
  4807. #ifdef IKSD
  4808.           extern int iklogopen, xferlog;
  4809. #endif /* IKSD */
  4810.           if (tralog <= 0
  4811. #ifdef IKSD
  4812.               && !iklogopen
  4813. #endif /* IKSD */
  4814.               ) {
  4815.               if (msgflg)
  4816.                 printf("?Transaction log wasn't open\n");
  4817.               return(0);
  4818.           }
  4819. #ifdef IKSD
  4820.           if (iklogopen && !inserver) {
  4821.               close(xferlog);
  4822.               iklogopen = 0;
  4823.           }
  4824. #endif /* IKSD */
  4825.           if (tralog) {
  4826.               tlog(F100,"Transaction Log Closed","",0L);
  4827.               zclose(ZTFILE);
  4828.           }
  4829.           *trafil = '\0';
  4830.           tralog = 0;
  4831.           return(1);
  4832.       }
  4833. #endif /* TLOG */
  4834.  
  4835. #ifdef CKLOGDIAL
  4836.       case LOGM:
  4837.         if (dialog <= 0) {
  4838.             if (msgflg) printf("?Connection log wasn't open\n");
  4839.             return(0);
  4840.         }
  4841.         *diafil = '\0';
  4842.         dialog = 0;
  4843.         return(zclose(ZDIFIL));
  4844. #endif /* CKLOGDIAL */
  4845.  
  4846. #ifndef NOSPL
  4847.       case LOGW:                        /* WRITE file */
  4848.       case LOGR:                        /* READ file */
  4849.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4850.         if (chkfn(y) < 1)               /* If no file to close */
  4851.           return(1);                    /* succeed silently. */
  4852.         return(zclose(y));              /* Otherwise, close the file. */
  4853. #endif /* NOSPL */
  4854.  
  4855.       default:
  4856.         printf("\n?Unexpected log designator - %d\n", x);
  4857.         return(0);
  4858.     }
  4859. }
  4860.  
  4861. static int slc = 0;                     /* Screen line count */
  4862.  
  4863. char *
  4864. showstring(s) char * s; {
  4865.     return(s ? s : "(null)");
  4866. }
  4867.  
  4868. char *
  4869. showoff(x) int x; {
  4870.     return(x ? "on" : "off");
  4871. }
  4872.  
  4873. char *
  4874. showooa(x) int x; {
  4875.     switch (x) {
  4876.       case SET_OFF:  return("off");
  4877.       case SET_ON:   return("on");
  4878.       case SET_AUTO: return("automatic");
  4879.       default:       return("(unknown)");
  4880.     }
  4881. }
  4882.  
  4883. #ifdef GEMDOS
  4884. isxdigit(c) int c; {
  4885.     return(isdigit(c) ||
  4886.            (c >= 'a' && c <= 'f') ||
  4887.            (c >= 'A' && c <= 'F'));
  4888. }
  4889. #endif /* GEMDOS */
  4890.  
  4891. #ifndef NOSETKEY
  4892. #ifdef OS2
  4893. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4894.     "all",    1, 0,
  4895.     "one",    0, 0
  4896. };
  4897. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4898.  
  4899. #define SHKEYDEF TT_MAX+5
  4900. struct keytab shokeymtab[] = {
  4901.     "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
  4902.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4903.     "adm5",      TT_ADM5,    0,         /* LSI ADM-5 */
  4904.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4905.     "annarbor",  TT_AAA,     0,         /* AnnArbor */
  4906.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4907.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4908.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4909.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4910.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4911.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4912.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4913.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4914.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4915.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4916.     "default",   SHKEYDEF,   0,
  4917.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4918.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4919.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4920.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4921.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4922.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4923.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4924.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4925.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4926.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4927.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4928.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4929.     "linux",     TT_LINUX,   0,         /* Linux */
  4930.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4931.     "qnx",       TT_QNX,     0,         /* QNX */
  4932.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4933.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4934.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4935.     "sun",       TT_SUN,     0,         /* Sun Console */
  4936. #ifdef OS2PM
  4937. #ifdef COMMENT
  4938.     "tek4014", TT_TEK40, 0,
  4939. #endif /* COMMENT */
  4940. #endif /* OS2PM */
  4941.     "tty",     TT_NONE,  0,
  4942.     "tvi910+", TT_TVI910, 0,
  4943.     "tvi925",  TT_TVI925, 0,
  4944.     "tvi950",  TT_TVI950, 0,
  4945.     "vc404",   TT_VC4404, 0,
  4946.     "vc4404",  TT_VC4404, CM_INV,
  4947.     "vip7809", TT_VIP7809, 0,
  4948.     "vt100",   TT_VT100, 0,
  4949.     "vt102",   TT_VT102, 0,
  4950.     "vt220",   TT_VT220, 0,
  4951.     "vt220pc", TT_VT220PC, 0,
  4952.     "vt320",   TT_VT320, 0,
  4953.     "vt320pc", TT_VT320PC, 0,
  4954.     "vt52",    TT_VT52,  0,
  4955.     "wp",      TT_KBM_WP, 0,
  4956.     "wy160",   TT_WY160,  0,
  4957.     "wy30",    TT_WY30,  0,
  4958.     "wy370",   TT_WY370, 0,
  4959.     "wy50",    TT_WY50,  0,
  4960.     "wy60",    TT_WY60,  0,
  4961.     "wyse30",  TT_WY30,  CM_INV,
  4962.     "wyse370", TT_WY370, CM_INV,
  4963.     "wyse50",  TT_WY50,  CM_INV,
  4964.     "wyse60",  TT_WY60,  CM_INV
  4965. };
  4966. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4967. #endif /* OS2 */
  4968.  
  4969. VOID
  4970. #ifdef OS2
  4971. shokeycode(c,m) int c, m;
  4972. #else
  4973. shokeycode(c) int c;
  4974. #endif
  4975. /* shokeycode */ {
  4976.     KEY ch;
  4977.     CHAR *s;
  4978. #ifdef OS2
  4979.     int i;
  4980.     con_event km;
  4981. #else /* OS2 */
  4982.     int km;
  4983. #endif /* OS2 */
  4984.  
  4985. #ifdef OS2
  4986.     extern int mskkeys;
  4987.     char * mstr = "";
  4988.  
  4989.     if (c >= KMSIZE) {
  4990.         bleep(BP_FAIL);
  4991.         return;
  4992.     }
  4993. #else /* OS2 */
  4994.     printf(" Key code \\%d => ", c);
  4995. #endif /* OS2 */
  4996.  
  4997. #ifndef OS2
  4998.     km = mapkey(c);
  4999.  
  5000. #ifndef NOKVERBS
  5001.     if (IS_KVERB(km)) {                 /* \Kverb? */
  5002.         int i, kv;
  5003.         kv = km & ~(F_KVERB);
  5004.         printf("Verb: ");
  5005.         for (i = 0; i < nkverbs; i++)
  5006.           if (kverbs[i].kwval == kv) {
  5007.               printf("\\K%s",kverbs[i].kwd);
  5008.               break;
  5009.           }
  5010.         printf("\n");
  5011.     } else
  5012. #endif /* NOKVERBS */
  5013.       if (IS_CSI(km)) {
  5014.           int xkm = km & 0xFF;
  5015.           if (xkm <= 32 || xkm >= 127)
  5016.             printf("String: \\{27}[\\{%d}\n",xkm);
  5017.           else
  5018.             printf("String: \\{27}[%c\n",xkm);
  5019.       } else if (IS_ESC(km)) {
  5020.           int xkm = km & 0xFF;
  5021.           if (xkm <= 32 || xkm >= 127)
  5022.             printf("String: \\{27}\\{%d}\n",xkm);
  5023.           else
  5024.             printf("String: \\{27}%c\n",xkm);
  5025.       } else if (macrotab[c]) {         /* See if there's a macro */
  5026.           printf("String: ");           /* If so, display its definition */
  5027.           s = macrotab[c];
  5028.           shostrdef(s);
  5029.           printf("\n");
  5030. #ifndef NOKVERBS
  5031.     } else if (km >= 0x100) {           /* This means "undefined" */
  5032.         printf("Undefined\n");
  5033. #endif /* NOKVERBS */
  5034.     } else {                            /* No macro, show single character */
  5035.         printf("Character: ");
  5036.         ch = km;
  5037.         if (ch < 32 || ch == 127
  5038. #ifdef OS2
  5039.             || ch > 255
  5040. #endif /* OS2 */
  5041. #ifndef NEXT
  5042. #ifndef AUX
  5043. #ifndef XENIX
  5044. #ifndef OS2
  5045.             || (ch > 127 && ch < 160)
  5046. #endif /* OS2 */
  5047. #endif /* XENIX */
  5048. #endif /* AUX */
  5049. #endif /* NEXT */
  5050.             )
  5051. /*
  5052.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5053.   %u is supposed to be totally portable.
  5054. */
  5055.           printf("\\%u",(unsigned int) ch);
  5056.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5057.         if (ch == (KEY) c)
  5058.           printf(" (self, no translation)\n");
  5059.         else
  5060.           printf("\n");
  5061.     }
  5062. #else /* OS2 */
  5063.     if (m < 0) {
  5064.         km = mapkey(c);
  5065.         mstr = "default";
  5066.     } else {
  5067.         km = maptermkey(c,m);
  5068.         for (i = 0; i < nshokeym; i++) {
  5069.             if (m == shokeymtab[i].kwval) {
  5070.                 mstr = shokeymtab[i].kwd;
  5071.                 break;
  5072.             }
  5073.         }
  5074.     }
  5075.     s = keyname(c);
  5076.     debug(F111,"shokeycode mstr",mstr,m);
  5077.     debug(F111,"shokeycode keyname",s,c);
  5078.     printf(" %sKey code \\%d %s (%s) => ",
  5079.             mskkeys ? "mskermit " : "",
  5080.             mskkeys ? cktomsk(c) : c,
  5081.             s == NULL ? "" : s, mstr);
  5082.  
  5083.     switch (km.type) {
  5084. #ifndef NOKVERBS
  5085.       case kverb: {
  5086.           int i, kv;
  5087.           kv = km.kverb.id & ~(F_KVERB);
  5088.           printf("Verb: ");
  5089.           for (i = 0; i < nkverbs; i++) {
  5090.               if (kverbs[i].kwval == kv) {
  5091.                   printf("\\K%s",kverbs[i].kwd);
  5092.                   break;
  5093.               }
  5094.           }
  5095.           printf("\n");
  5096.           break;
  5097.       }
  5098. #endif /* NOKVERBS */
  5099.       case csi: {
  5100.           int xkm = km.csi.key & 0xFF;
  5101.           if (xkm <= 32 || xkm >= 127)
  5102.             printf("String: \\{27}[\\{%d}\n",xkm);
  5103.           else
  5104.             printf("String: \\{27}[%c\n",xkm);
  5105.           break;
  5106.       }
  5107.       case esc: {
  5108.           int xkm = km.esc.key & 0xFF;
  5109.           if (xkm <= 32 || xkm >= 127)
  5110.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  5111.           else
  5112.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  5113.           break;
  5114.       }
  5115.       case macro: {
  5116.           printf("String: ");           /* Macro, display its definition */
  5117.           shostrdef(km.macro.string);
  5118.           printf("\n");
  5119.           break;
  5120.       }
  5121.       case literal: {
  5122.           printf("Literal string: ");   /* Literal, display its definition */
  5123.           shostrdef(km.literal.string);
  5124.           printf("\n");
  5125.           break;
  5126.       }
  5127.       case error: {
  5128.           if (c >= 0x100) {
  5129.               printf("Undefined\n");
  5130.           } else {
  5131.               printf("Character: ");
  5132.               ch = c;
  5133.               if (ch < 32 || ch == 127 || ch > 255
  5134. #ifndef NEXT
  5135. #ifndef AUX
  5136. #ifndef XENIX
  5137. #ifndef OS2
  5138.                    || (ch > 127 && ch < 160)
  5139. #endif /* OS2 */
  5140. #endif /* XENIX */
  5141. #endif /* AUX */
  5142. #endif /* NEXT */
  5143.                    )
  5144. /*
  5145.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5146.   %u is supposed to be totally portable.
  5147. */
  5148.                   printf("\\%u",(unsigned int) ch);
  5149.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5150.               printf(" (self, no translation)\n");
  5151.           }
  5152.           break;
  5153.       }
  5154.       case key: {
  5155.           printf("Character: ");
  5156.           ch = km.key.scancode;
  5157.           if (ch < 32 || ch == 127 || ch > 255
  5158. #ifndef NEXT
  5159. #ifndef AUX
  5160. #ifndef XENIX
  5161. #ifndef OS2
  5162.               || (ch > 127 && ch < 160)
  5163. #else
  5164.                || (ch > 127)
  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.           if (ch == (KEY) c)
  5177.             printf(" (self, no translation)\n");
  5178.           else
  5179.             printf("\n");
  5180.           break;
  5181.       }
  5182.     }
  5183. #endif /* OS2 */
  5184. }
  5185. #endif /* NOSETKEY */
  5186.  
  5187. VOID
  5188. shostrdef(s) CHAR * s; {
  5189.     CHAR ch;
  5190.     if (!s) s = (CHAR *)"";
  5191.     while ((ch = *s++)) {
  5192.         if (ch < 32 || ch == 127 || ch == 255
  5193. /*
  5194.   Systems whose native character sets have graphic characters in C1...
  5195. */
  5196. #ifndef NEXT                            /* NeXT */
  5197. #ifndef AUX                             /* Macintosh */
  5198. #ifndef XENIX                           /* IBM PC */
  5199. #ifdef OS2
  5200. /*
  5201.   It doesn't matter whether the local host can display 8-bit characters;
  5202.   they are not portable among character-sets and fonts.  Who knows what
  5203.   would be displayed...
  5204. */
  5205.             || (ch > 127)
  5206. #else /* OS2 */
  5207.             || (ch > 127 && ch < 160)
  5208. #endif /* OS2 */
  5209. #endif /* XENIX */
  5210. #endif /* AUX */
  5211. #endif /* NEXT */
  5212.             )
  5213.           printf("\\{%d}",ch);          /* Display control characters */
  5214.         else putchar((char) ch);        /* in backslash notation */
  5215.     }
  5216. }
  5217.  
  5218. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5219.  
  5220. #ifndef NOSHOW
  5221. VOID
  5222. shover() {
  5223. #ifdef OS2
  5224.     extern char ckxsystem[];
  5225. #endif /* OS2 */
  5226.     extern char *ck_patch, * cklibv;
  5227.     printf("\nVersions:\n %s\n",versio);
  5228.     printf(" Numeric: %ld\n",vernum);
  5229. #ifdef OS2
  5230.     printf(" Operating System: %s\n", ckxsystem);
  5231. #else /* OS2 */
  5232.     printf(" Built for: %s\n", ckxsys);
  5233. #ifdef CK_UTSNAME
  5234.     if (unm_nam[0])
  5235.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5236. #endif /* CK_UTSNAME */
  5237.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5238. #endif /* OS2 */
  5239.     if (xxdiff(ckxv,ckxsys))
  5240.       printf(" %s for%s\n",ckxv,ckxsys);
  5241.     else
  5242.       printf(" %s\n",ckxv);
  5243.     if (xxdiff(ckzv,ckzsys))
  5244.       printf(" %s for%s\n",ckzv,ckzsys);
  5245.     else
  5246.       printf(" %s\n",ckzv);
  5247.     printf(" %s\n",cklibv);
  5248.     printf(" %s\n",protv);
  5249.     printf(" %s\n",fnsv);
  5250.     printf(" %s\n %s\n",cmdv,userv);
  5251. #ifndef NOCSETS
  5252.     printf(" %s\n",xlav);
  5253. #endif /* NOCSETS */
  5254. #ifndef MAC
  5255. #ifndef NOLOCAL
  5256.     printf(" %s\n",connv);
  5257. #ifdef OS2
  5258.     printf(" %s\n",ckyv);
  5259. #endif /* OS2 */
  5260. #endif /* NOLOCAL */
  5261. #endif /* MAC */
  5262. #ifndef NODIAL
  5263.     printf(" %s\n",dialv);
  5264. #endif /* NODIAL */
  5265. #ifndef NOSCRIPT
  5266.     printf(" %s\n",loginv);
  5267. #endif /* NOSCRIPT */
  5268. #ifdef NETCONN
  5269.     printf(" %s\n",cknetv);
  5270. #ifdef OS2
  5271.     printf(" %s\n",ckonetv);
  5272. #ifdef CK_NETBIOS
  5273.     printf(" %s\n",ckonbiv);
  5274. #endif /* CK_NETBIOS */
  5275. #endif /* OS2 */
  5276. #endif /* NETCONN */
  5277. #ifdef TNCODE
  5278.     printf(" %s\n",cktelv);
  5279. #endif /* TNCODE */
  5280. #ifdef SSHBUILTIN
  5281.     printf(" %s\n",cksshv);
  5282. #ifdef SFTP_BUILTIN
  5283.     printf(" %s\n",cksftpv);
  5284. #endif /* SFTP_BUILTIN */
  5285. #endif /* SSHBUILTIN */
  5286. #ifdef OS2
  5287. #ifdef OS2MOUSE
  5288.     printf(" %s\n",ckomouv);
  5289. #endif /* OS2MOUSE */
  5290. #endif /* OS2 */
  5291. #ifdef NEWFTP
  5292.     printf(" %s\n",ckftpv);
  5293. #endif /* NEWFTP */
  5294. #ifdef CK_AUTHENTICATION
  5295.     printf(" %s\n",ckathv);
  5296. #endif /* CK_AUTHENTICATION */
  5297. #ifdef CK_ENCRYPTION
  5298. #ifdef CRYPT_DLL
  5299.     printf(" %s\n",ck_crypt_dll_version());
  5300. #else /* CRYPT_DLL */
  5301.     printf(" %s\n",ckcrpv);
  5302. #endif /* CRYPT_DLL */
  5303. #endif /* CK_ENCRYPTION */
  5304. #ifdef CK_SSL
  5305.     printf(" %s\n",cksslv);
  5306. #endif /* CK_SSL */
  5307.     printf("\n");
  5308. }
  5309.  
  5310. #ifdef CK_LABELED
  5311. VOID
  5312. sholbl() {
  5313. #ifdef VMS
  5314.     printf("VMS Labeled File Features:\n");
  5315.     printf(" acl %s (ACL info %s)\n",
  5316.            showoff(lf_opts & LBL_ACL),
  5317.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5318.     printf(" backup-date %s (backup date/time %s)\n",
  5319.            showoff(lf_opts & LBL_BCK),
  5320.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5321.     printf(" name %s (original filename %s)\n",
  5322.            showoff(lf_opts & LBL_NAM),
  5323.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5324.     printf(" owner %s (original file owner id %s)\n",
  5325.            showoff(lf_opts & LBL_OWN),
  5326.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5327.     printf(" path %s (original file's disk:[directory] %s)\n",
  5328.            showoff(lf_opts & LBL_PTH),
  5329.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5330. #else
  5331. #ifdef OS2
  5332.     printf("OS/2 Labeled File features (attributes):\n");
  5333.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5334.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5335.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5336.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5337.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5338. #endif /* OS2 */
  5339. #endif /* VMS */
  5340. }
  5341. #endif /* CK_LABELED */
  5342.  
  5343. VOID
  5344. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5345. #ifndef NOCSETS
  5346. #ifdef OS2
  5347. #ifndef NOTERM
  5348.     extern struct _vtG G[4], *GL, *GR;
  5349.     extern int decnrcm, sni_chcode;
  5350.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5351.     extern prncs;
  5352.  
  5353.     printf(" Terminal character-sets:\n");
  5354.     if (IS97801(tt_type_mode)) {
  5355.         if (cmask == 0377)
  5356.           printf("     Mode: 8-bit Mode\n");
  5357.         else
  5358.           printf("     Mode: 7-bit Mode\n");
  5359.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5360.     } else if (ISVT100(tt_type_mode)) {
  5361.         if (decnrcm)
  5362.           printf("     Mode: 7-bit National Mode\n");
  5363.         else
  5364.           printf("     Mode: 8-bit Multinational Mode\n");
  5365.     }
  5366.     if ( isunicode() )
  5367.         printf("    Local: Unicode display / %s input\n",
  5368.                 csl == TX_TRANSP ? "transparent" :
  5369.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5370.     else
  5371.         printf("    Local: %s\n",
  5372.                 csl == TX_TRANSP ? "transparent" :
  5373.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5374.  
  5375.     if ( tt_utf8 ) {
  5376.         printf("   Remote: UTF-8\n");
  5377.     } else {
  5378.         printf("   Remote: %sG0: %s (%s)\n",
  5379.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5380.            txrinfo[G[0].designation]->keywd,
  5381.            G[0].designation == TX_TRANSP ? "" :
  5382.            G[0].size == cs94 ? "94 chars" :
  5383.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5384.         printf("           %sG1: %s (%s)\n",
  5385.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5386.            txrinfo[G[1].designation]->keywd,
  5387.            G[1].designation == TX_TRANSP ? "" :
  5388.            G[1].size == cs94 ? "94 chars" :
  5389.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5390.         printf("           %sG2: %s (%s)\n",
  5391.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5392.            txrinfo[G[2].designation]->keywd,
  5393.            G[2].designation == TX_TRANSP ? "" :
  5394.            G[2].size == cs94 ? "94 chars" :
  5395.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5396.         printf("           %sG3: %s (%s)\n",
  5397.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5398.            txrinfo[G[3].designation]->keywd,
  5399.            G[3].designation == TX_TRANSP ? "" :
  5400.            G[3].size == cs94 ? "94 chars" :
  5401.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5402.     }
  5403.     printf("\n");
  5404.     printf(" Keyboard character-sets:\n");
  5405.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5406.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5407.     printf("\n");
  5408.     printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5409. #endif /* NOTERM */
  5410. #else /* OS2 */
  5411. #ifndef MAC
  5412.     char *s;
  5413.  
  5414.     debug(F101,"TERM LOCAL CSET","",csl);
  5415.     debug(F101,"TERM REMOTE CSET","",csr);
  5416.     printf(" Terminal character-set: ");
  5417.     if (tcs_transp) {                   /* No translation */
  5418.         printf("transparent\n");
  5419.     } else {                            /* Translation */
  5420.         printf("%s (remote) %s (local)\n",
  5421.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5422.         if (csr != csl) {
  5423.             switch(gettcs(csr,csl)) {
  5424.               case TC_USASCII:  s = "ascii";        break;
  5425.               case TC_1LATIN:   s = "latin1-iso";   break;
  5426.               case TC_2LATIN:   s = "latin2-iso";   break;
  5427.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5428.               case TC_JEUC:     s = "japanese-euc"; break;
  5429.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5430.               case TC_GREEK:    s = "greek-iso";    break;
  5431.               case TC_9LATIN:   s = "latin9-iso";   break;
  5432.               default:          s = "transparent";  break;
  5433.             }
  5434.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5435.                 strcmp(s,fcsinfo[csr].keyword))
  5436.               printf("                         (via %s)\n",s);
  5437.         }
  5438.     }
  5439. #endif /* MAC */
  5440. #endif /* OS2 */
  5441. #endif /* NOCSETS */
  5442. }
  5443.  
  5444. #ifndef NOLOCAL
  5445. #ifdef OS2
  5446. extern char htab[];
  5447. VOID
  5448. shotabs() {
  5449.     int i,j,k,n;
  5450.  
  5451.     printf("Tab Stops:\n\n");
  5452.     for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5453.         do {
  5454.             printf("%c",htab[++i]=='T'?'T':'-');
  5455.         } while (i % k && i < MAXTERMCOL);
  5456.         printf("\n");
  5457.         for ( ; j <= i; j++) {
  5458.             switch ( j%10 ) {
  5459.           case 1:
  5460.                 printf("%c",j == 1 ? '1' : '.');
  5461.                 break;
  5462.           case 2:
  5463.           case 3:
  5464.           case 4:
  5465.           case 5:
  5466.           case 6:
  5467.           case 7:
  5468.                 printf("%c",'.');
  5469.                 break;
  5470.           case 8:
  5471.                 n = (j+2)/100;
  5472.                 if (n)
  5473.           printf("%d",n);
  5474.                 else 
  5475.           printf("%c",'.');
  5476.                 break;
  5477.           case 9:
  5478.                 n = (j+1)%100/10;
  5479.                 if (n)
  5480.           printf("%d",n);
  5481.                 else if (j>90)
  5482.           printf("0");
  5483.                 else 
  5484.           printf("%c",'.');
  5485.                 break;
  5486.           case 0:
  5487.                 printf("0");
  5488.                 break;
  5489.             }
  5490.         }
  5491.         printf("\n");
  5492.     }
  5493. #ifdef COMMENT
  5494.     for (i = 1; i <= 70; i++)
  5495.       printf("%c",htab[i]=='T'?'T':'-');
  5496.     printf("\n1.......10........20........30........40........50........60\
  5497. ........70\n\n");
  5498.     for (; i <= 140; i++)
  5499.       printf("%c",htab[i]=='T'?'T':'-');
  5500.     printf("\n........80........90.......100.......110.......120.......130\
  5501. .......140\n\n");
  5502.     for (; i <= 210; i++)
  5503.       printf("%c",htab[i]=='T'?'T':'-');
  5504.     printf("\n.......150.......160.......170.......180.......190.......200\
  5505. .......210\n\n");
  5506.     for (; i <= 255; i++)
  5507.       printf("%c",htab[i]=='T'?'T':'-');
  5508.     printf("\n.......220.......230.......240.......250..255\n");
  5509. #endif
  5510.  
  5511. }
  5512. #endif /* OS2 */
  5513. #endif /* NOLOCAL */
  5514.  
  5515. #ifdef OS2MOUSE
  5516. VOID
  5517. shomou() {
  5518.     int button, event, id, i;
  5519.     char * name = "";
  5520.  
  5521.     printf("Mouse settings:\n");
  5522.     printf("   Button Count:   %d\n",mousebuttoncount());
  5523.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5524.  
  5525.     for (button = 0; button < MMBUTTONMAX; button++)
  5526.       for (event = 0; event < MMEVENTSIZE; event++)
  5527.         if (mousemap[button][event].type != error)
  5528.           switch (mousemap[button][event].type) {
  5529.             case key:
  5530.               printf("   %s = Character: %c \\%d\n",
  5531.                      mousename(button,event),
  5532.                      mousemap[button][event].key.scancode,
  5533.                      mousemap[button][event].key.scancode );
  5534.               break;
  5535.             case kverb:
  5536.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5537.               if (id != K_IGNORE) {
  5538.                   for (i = 0; i< nkverbs; i++)
  5539.                     if (id == kverbs[i].kwval) {
  5540.                         name = kverbs[i].kwd;
  5541.                         break;
  5542.                     }
  5543.                   printf("   %s = Kverb: \\K%s\n",
  5544.                          mousename(button,event),
  5545.                          name
  5546.                          );
  5547.               }
  5548.               break;
  5549.             case macro:
  5550.               printf("   %s = Macro: ",
  5551.                      mousename(button,event) );
  5552.               shostrdef(mousemap[button][event].macro.string);
  5553.               printf("\n");
  5554.               break;
  5555.           }
  5556. }
  5557. #endif /* OS2MOUSE */
  5558.  
  5559. #ifndef NOLOCAL
  5560. VOID
  5561. shotrm() {
  5562.     char *s;
  5563.     extern char * getiact();
  5564.     extern int tt_print, adl_err;
  5565. #ifndef NOTRIGGER
  5566.     extern char * tt_trigger[];
  5567. #endif /* NOTRIGGER */
  5568. #ifdef CKTIDLE
  5569.     extern char * tt_idlesnd_str;
  5570.     extern int tt_idlesnd_tmo;
  5571.     extern int tt_idlelimit, tt_idleact;
  5572. #endif /* CKTIDLE */
  5573. #ifdef OS2
  5574.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5575.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5576.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5577.     int lines = 0;
  5578. #ifdef KUI
  5579.     extern CKFLOAT tt_linespacing[];
  5580.     extern tt_cursor_blink;
  5581. #endif /* KUI */
  5582. #ifdef PCFONTS
  5583.     int i;
  5584.     char *font;
  5585.  
  5586.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5587.         if (!os2LoadPCFonts()) {
  5588.             for (i = 0; i < ntermfont; i++) {
  5589.                 if (tt_font == term_font[i].kwval) {
  5590.                     font = term_font[i].kwd;
  5591.                     break;
  5592.                 }
  5593.             }
  5594.         } else {
  5595.             font = "(DLL not available)";
  5596.         }
  5597.     } else {
  5598.         font =     "(full screen only)";
  5599.     }
  5600. #endif /* PCFONTS */
  5601. #ifdef KUI
  5602.     char font[64] = "(unknown)";
  5603.     if ( ntermfont > 0 ) {
  5604.         int i;
  5605.         for (i = 0; i < ntermfont; i++) {
  5606.             if (tt_font == term_font[i].kwval) {
  5607.                 ckstrncpy(font,term_font[i].kwd,59);
  5608.                 ckstrncat(font," ",64);
  5609.                 ckstrncat(font,ckitoa(tt_font_size/2),64);
  5610.                 if ( tt_font_size % 2 )
  5611.                     ckstrncat(font,".5",64);
  5612.                 break;
  5613.             }
  5614.         }
  5615.     }
  5616. #endif /* KUI */
  5617.  
  5618.     printf("Terminal parameters:\n");
  5619.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5620.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5621.            "Bytesize: Command",
  5622.            (cmdmsk == 0377) ? 8 : 7,
  5623.            " bits","Terminal",
  5624.            (cmask == 0377) ? 8 : 7," bits");
  5625.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5626.     printf(" %19s: %-13s","Type",
  5627.            (tt_type >= 0 && tt_type <= max_tt) ?
  5628.            tt_info[tt_type].x_name :
  5629.            "unknown" );
  5630.     if (tt_type >= 0 && tt_type <= max_tt)
  5631.       if (strlen(tt_info[tt_type].x_id))
  5632.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5633.     printf("\n");
  5634.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5635.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5636.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5637.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5638.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode", showoff(tnlm),
  5639.        "Cr-display",tt_crd ? "crlf" : "normal");
  5640.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5641.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5642. #ifdef KUI
  5643.         (tt_cursor == 2) ? (tt_cursor_blink ? 
  5644.                  "full (*)" : "full (.)") :
  5645.         (tt_cursor == 1) ? (tt_cursor_blink ? 
  5646.                  "half (*)" : "half (.)") :
  5647.         (tt_cursor_blink ? "underline (*)" : "underline (.)"),
  5648. #else /* KUI */
  5649.            (tt_cursor == 2) ? "full" :
  5650.            (tt_cursor == 1) ? "half" : "underline",
  5651. #endif /* KUI */
  5652. #ifdef CK_AUTODL
  5653.            "autodownload",autodl == TAD_ON ?
  5654.            (adl_err ? "on, error stop" : "on, error continue") : 
  5655.            autodl == TAD_ASK ? 
  5656.            (adl_err ? "ask, error stop" : "ask, error continue") :
  5657.            "off"
  5658. #else /* CK_AUTODL */
  5659.            "", ""
  5660. #endif /* CK_AUTODL */
  5661.            );
  5662.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5663.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5664.            tt_arrow ? "application" : "cursor",
  5665.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5666.            );
  5667.  
  5668.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5669.  
  5670.     /* Just to make sure we are using current info */
  5671.     updanswerbk();
  5672.  
  5673.     /*
  5674.        This line doesn't end with '\n' because the answerback string
  5675.        is terminated with a newline
  5676.     */
  5677.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5678.            showoff(tt_answer),"response",answerback);
  5679.     switch (tt_bell) {
  5680.       case XYB_NONE:
  5681.         s = "none";
  5682.         break;
  5683.       case XYB_VIS:
  5684.         s= "visible";
  5685.         break;
  5686.       case XYB_AUD | XYB_BEEP:
  5687.         s="beep";
  5688.         break;
  5689.       case XYB_AUD | XYB_SYS:
  5690.         s="system sounds";
  5691.         break;
  5692.       default:
  5693.         s="(unknown)";
  5694.     }
  5695.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5696.            "Wrap",showoff(tt_wrap));
  5697.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5698.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5699.            "Autoscroll",showoff(autoscroll));
  5700.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5701.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5702.            "ESC[0m color",colorreset?"default-color":"current-color");
  5703.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5704.     printf(" %19s: %-13s  %13s: %-15s\n",
  5705.             "Erase color",user_erasemode?"default-color":"current-color",
  5706.            "Screen mode",decscnm?"reverse":"normal");
  5707.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5708.  
  5709.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5710.            "Output-pacing",tt_pacing);
  5711.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5712.  
  5713.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5714.            "Idle-action", getiact());
  5715.  
  5716.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5717.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5718.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5719.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5720. #ifndef NOTRIGGER
  5721.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5722.            tt_trigger[0],"Output pacing",tt_pacing );
  5723.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5724. #endif /* NOTRIGGER */
  5725.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5726.            showoff(marginbell),"at column", marginbellcol);
  5727.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5728.     switch (tt_modechg) {
  5729.       case TVC_DIS: s = "disabled"; break;
  5730.       case TVC_ENA: s = "enabled";  break;
  5731.       case TVC_W95: s = "win95-restricted"; break;
  5732.       default: s = "(unknown)";
  5733.     }
  5734.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5735.            showoff(dgunix),"Video change", s);
  5736.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5737.  
  5738. #ifdef CK_APC
  5739.     if (apcstatus == APC_ON) s = "on";
  5740.     else if (apcstatus == APC_OFF) s = "off";
  5741.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5742.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5743.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5744.     printf(" %19s: %-13s  %13s: %-15s\n",
  5745.            "APC", s,
  5746. #ifdef PCFONTS
  5747.            "Font (VGA)",font
  5748. #else /* PCFONTS */
  5749. #ifdef KUI
  5750.            "Font",font
  5751. #else
  5752.            "Font","(not supported)"
  5753. #endif /* KUI */
  5754. #endif /* PCFONTS */
  5755.  
  5756.            );
  5757. #endif /* CK_APC */
  5758.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5759.  
  5760. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5761.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5762.       ttgwsiz();                        /* Try to get latest size */
  5763. #endif /* CK_TTGWSIZ */
  5764.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5765.            "Width",tt_cols[VTERM]);
  5766.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5767. #ifdef KUI
  5768.     printf(" %19s: %-12f  %14s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5769.            "Display Height",VscrnGetDisplayHeight(VTERM));
  5770.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5771. #endif /* KUI */
  5772.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5773.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5774.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5775.  
  5776.     if (updmode == tt_updmode)
  5777.       if (updmode == TTU_FAST)
  5778.         s = "fast (fast)";
  5779.       else
  5780.         s = "smooth (smooth)";
  5781.     else
  5782.       if (updmode == TTU_FAST)
  5783.         s = "fast (smooth)";
  5784.       else
  5785.         s = "smooth (fast)";
  5786.  
  5787.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5788.            "interval",tt_update);
  5789.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5790.     printf(" %19s: %-13s  %13s: %-15s\n",
  5791.            "Screen-optimization",showoff(tt_diff_upd),
  5792.            "Status line",showoff(tt_status[VTERM]));
  5793.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5794.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5795.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5796.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5797.  
  5798.     /* Display colors (should become SHOW COLORS) */
  5799.     {
  5800.         USHORT row, col;
  5801.         char * colors[16] = {
  5802.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5803.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5804.         };
  5805.         printf("\n");
  5806.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5807.  
  5808.         printf(" Color:");
  5809. #ifndef ONETERMUPD
  5810.         GetCurPos(&row, &col);
  5811.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5812.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5813.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5814.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5815.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5816.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5817.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5818.         WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5819. #endif /* ONETERMUPD */
  5820.         row = VscrnGetCurPos(VCMD)->y+1;
  5821.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5822.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5823.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5824.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5825.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5826.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5827.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5828.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5829.         printf("\n");
  5830.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5831.  
  5832.         /* Foreground color names */
  5833.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5834.                 "",
  5835.                 colors[colordebug&0x0F],
  5836.                 colors[colorhelp&0x0F],
  5837.                 colors[colorreverse&0x0F],
  5838.                 colors[colorselect&0x0F],
  5839.                 colors[colorstatus&0x0F],
  5840.                 colors[colornormal&0x0F],
  5841.                 colors[colorunderline&0x0F]);
  5842.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5843.  
  5844.         /* Background color names */
  5845.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5846.                 colors[colorborder],
  5847.                 colors[colordebug>>4],
  5848.                 colors[colorhelp>>4],
  5849.                 colors[colorreverse>>4],
  5850.                 colors[colorselect>>4],
  5851.                 colors[colorstatus>>4],
  5852.                 colors[colornormal>>4],
  5853.                 colors[colorunderline>>4] );
  5854.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5855.         printf("\n");
  5856.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5857.         printf(" Color:");
  5858. #ifndef ONETERMUPD
  5859.         GetCurPos(&row, &col);
  5860.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5861.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5862.         WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
  5863. #endif /* ONETERMUPD */
  5864.         row = VscrnGetCurPos(VCMD)->y+1;
  5865.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5866.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5867.         VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
  5868.         printf("\n");
  5869.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5870.  
  5871.         /* Foreground color names */
  5872.         printf("%6s: %-8s%-8s%-8s\n","fore",
  5873.                 colors[colorgraphic&0x0F],
  5874.                 colors[colorcmd&0x0F],
  5875.                 colors[coloritalic&0x0F]);
  5876.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5877.  
  5878.         /* Background color names */
  5879.         printf("%6s: %-8s%-8s%-8s\n","back",
  5880.                 colors[colorgraphic>>4],
  5881.                 colors[colorcmd>>4],
  5882.                 colors[coloritalic>>4]);
  5883.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5884.     }
  5885.     printf("\n");
  5886.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5887.     {
  5888.         extern int trueblink, truedim, truereverse, trueunderline, trueitalic;
  5889.         printf(
  5890.         " Attribute:  \
  5891. blink: %-3s  dim: %-3s  italic: %-3s  reverse: %-3s  underline: %-3s\n",
  5892.         trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", 
  5893.         truereverse?"on":"off", trueunderline?"on":"off");
  5894.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5895.     }
  5896.     {
  5897.         extern vtattrib WPattrib;
  5898.         printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5899.                 WPattrib.blinking?"blink ":"",
  5900.                 WPattrib.italic?"italic ":"",
  5901.                 WPattrib.reversed?"reverse ":"",
  5902.                 WPattrib.underlined?"underline ":"",
  5903.                 WPattrib.bold?"bold ":"",
  5904.                 WPattrib.dim?"dim ":"",
  5905.                 WPattrib.invisible?"invisible ":"");
  5906.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5907.     }
  5908.  
  5909.     printf("\n");
  5910.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5911.     (VOID) shoesc(escape);
  5912.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5913.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5914.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5915.  
  5916. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5917.  
  5918.     printf("\n");
  5919.     printf("Terminal parameters:\n");
  5920.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5921.            "Bytesize: Command",
  5922.            (cmdmsk == 0377) ? 8 : 7,
  5923.            " bits","Terminal",
  5924.            (cmask == 0377) ? 8 : 7," bits");
  5925.     s = getenv("TERM");
  5926. #ifdef XPRINT
  5927.     printf(" %19s: %-13s  %13s: %-15s\n",
  5928.            "Type",
  5929.            s ? s : "(unknown)",
  5930.            "Print",
  5931.            showoff(tt_print)
  5932.            );
  5933. #else
  5934.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5935. #endif /* XPRINT */
  5936.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5937.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5938.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5939.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5940.  
  5941. #ifdef CK_APC
  5942.     if (apcstatus == APC_ON) s = "on";
  5943.     else if (apcstatus == APC_OFF) s = "off";
  5944.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5945.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5946.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5947.     printf(" %19s: %-13s  %13s: %-15s\n",
  5948.            "APC", s,
  5949. #ifdef CK_AUTODL
  5950.            "Autodownload", autodl ?
  5951.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5952. #else
  5953.            "",""
  5954. #endif /* CK_AUTODL */
  5955.            );
  5956. #endif /* CK_APC */
  5957.  
  5958. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5959.     ttgwsiz();                          /* Try to get latest size */
  5960.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5961. #endif /* CK_TTGWSIZ */
  5962.  
  5963.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5964.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5965.  
  5966. #ifdef CKTIDLE
  5967.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5968.            "Idle-action", getiact());
  5969. #endif /* CKTIDLE */
  5970.  
  5971.     printf(" %19s: %-13s  ","Lf-display", tt_lfd ? "crlf" : "normal");
  5972. #ifdef UNIX
  5973. #ifndef NOJC
  5974.     printf("%13s: %-15s","Suspend", showoff(xsuspend));
  5975. #endif /* NOJC */
  5976. #endif /* UNIX */
  5977.     printf("\n");
  5978.  
  5979. #ifndef NOTRIGGER
  5980.     printf(" %19s: %-13s\n","Trigger",
  5981.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  5982. #endif /* NOTRIGGER */
  5983.     printf("\n");
  5984.  
  5985.     (VOID) shoesc(escape);
  5986. #ifndef NOCSETS
  5987.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  5988. #endif /* NOCSETS */
  5989.  
  5990. #endif /* OS2 */
  5991. }
  5992.  
  5993. VOID
  5994. shmdmlin() {                            /* Briefly show modem & line */
  5995. #ifndef NODIAL
  5996. #ifndef MINIDIAL
  5997. #ifdef OLDTBCODE
  5998.     extern int tbmodel;
  5999.     _PROTOTYP( char * gtbmodel, (void) );
  6000. #endif /* OLDTBCODE */
  6001. #endif /* MINIDIAL */
  6002. #endif /* NODIAL */
  6003.     if (local)
  6004. #ifdef OS2
  6005.       printf(" Port: %s, Modem type: ",ttname);
  6006. #else
  6007.       printf(" Line: %s, Modem type: ",ttname);
  6008. #endif /* OS2 */
  6009.     else
  6010.       printf(
  6011. #ifdef OS2
  6012. " Communication device not yet selected with SET PORT\n Modem type: "
  6013. #else
  6014. " Communication device not yet selected with SET LINE\n Modem type: "
  6015. #endif /* OS2 */
  6016.              );
  6017. #ifndef NODIAL
  6018.     printf("%s",gmdmtyp());
  6019. #ifndef MINIDIAL
  6020. #ifdef OLDTBCODE
  6021.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  6022. #endif /* OLDTBCODE */
  6023. #endif /* MINIDIAL */
  6024. #else
  6025.     printf("(disabled)");
  6026. #endif /* NODIAL */
  6027. }
  6028.  
  6029. #ifdef CK_TAPI
  6030. void
  6031. shotapi(int option) {
  6032.     int rc=0,k ;
  6033.     char *s=NULL;
  6034.     LPDEVCFG        lpDevCfg = NULL;
  6035.     LPCOMMCONFIG    lpCommConfig = NULL;
  6036.     LPMODEMSETTINGS lpModemSettings = NULL;
  6037.     DCB *           lpDCB = NULL;
  6038.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  6039.     extern int ntapiloc;
  6040.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  6041.     extern int ntapiline;
  6042.     extern int tttapi;                  /* TAPI in use */
  6043.     extern int tapipass;                /* TAPI Passthrough mode */
  6044.     extern int tapiconv;                /* TAPI Conversion mode */
  6045.     extern int tapilights;
  6046.     extern int tapipreterm;
  6047.     extern int tapipostterm;
  6048.     extern int tapimanual;
  6049.     extern int tapiinactivity;
  6050.     extern int tapibong;
  6051.     extern int tapiusecfg;
  6052.     extern char tapiloc[];
  6053.     extern int tapilocid;
  6054.     extern int TAPIAvail;
  6055.  
  6056.     if (!TAPIAvail) {
  6057.         printf("TAPI Support not enabled\r\n");
  6058.         return;
  6059.     }
  6060.     switch (option) {
  6061.       case 0:
  6062.         printf("TAPI Settings:\n");
  6063.         printf("  Line:                      %s\n",
  6064.                tttapi ? ttname : "(none in use)");
  6065.  
  6066.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  6067.         if (tapilocid == -1)
  6068.           tapilocid = cktapiGetCurrentLocationID();
  6069.  
  6070.         /* Find the current tapiloc entry */
  6071.         /* and use it as the default. */
  6072.         for (k = 0; k < ntapiloc; k++) {
  6073.             if (tapiloctab[k].kwval == tapilocid)
  6074.               break;
  6075.         }
  6076.         if (k >= 0 && k < ntapiloc)
  6077.           s = tapiloctab[k].kwd;
  6078.         else
  6079.           s = "(unknown)";
  6080.         printf("  Location:                  %s\n",s);
  6081.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  6082.         printf("  Phone-number-conversions:  %s\n",
  6083.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  6084.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  6085.                 tapipass?"(n/a)":"");
  6086.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  6087.                 tapipass?"(n/a)":"");
  6088.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  6089.                 tapipass?"(n/a)":"");
  6090.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  6091.                 tapipass?"(n/a)":"");
  6092.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  6093.                 tapipass?"(n/a)":"");
  6094.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  6095.                 tapipass?"(n/a)":"");
  6096.         printf("  Use-windows-configuration: %s %s\n",
  6097.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  6098.         printf("\n");
  6099.  
  6100. #ifdef BETATEST
  6101.         if (tapipass) {
  6102. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  6103. printf("may open the device but may not place calls nor answer calls.\n");
  6104. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  6105. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  6106. printf("definition associated with the active TAPI LINE device.\n\n");
  6107.  
  6108.         } else {
  6109.  
  6110. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  6111. printf("may open the device, place and answer calls.  Dialing is performed\n");
  6112. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  6113.         }
  6114.  
  6115.         if (tapiconv == CK_ON ||
  6116.             tapiconv == CK_AUTO && !tapipass) {
  6117. printf(
  6118. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  6119. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  6120. printf("dialog.\n\n");
  6121.  
  6122.         } else {
  6123.  
  6124. printf(
  6125. "Phone numbers are converted from canonical to dialable form by K-95\n");
  6126. printf(
  6127. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  6128. printf(
  6129. "Dialing Properties are imported automaticly upon startup and whenever\n");
  6130. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  6131. printf("is changed.\n\n");
  6132.         }
  6133. #endif /* BETATEST */
  6134.  
  6135.         if (tapipass) {
  6136.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  6137.             if (tapiconv == CK_ON)
  6138.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6139.         } else {
  6140.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  6141.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  6142.         }
  6143.         break;
  6144.       case 1:
  6145.         cktapiDisplayTapiLocationInfo();
  6146.         break;
  6147.       case 2:
  6148.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  6149.                                      &lpCommConfig,&lpDCB);
  6150.         if (rc) {
  6151.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  6152.                                          lpCommConfig,lpDCB);
  6153.         } else {
  6154.             printf("?Unable to retrieve Modem Settings\n");
  6155.         }
  6156.         break;
  6157.       case 3: {
  6158.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  6159.           if (hModem)
  6160.             DisplayCommProperties(hModem);
  6161.           else
  6162.             printf("?Unable to retrieve a valid Modem Handle\n");
  6163.           CloseHandle(hModem);
  6164.           break;
  6165.       }
  6166.     }
  6167.     printf("\n");
  6168. }
  6169. #endif /* CK_TAPI */
  6170. #endif /* NOLOCAL */
  6171.  
  6172. #ifdef PATTERNS
  6173. static VOID
  6174. shopat() {
  6175.     extern char * binpatterns[], * txtpatterns[];
  6176.     extern int patterns, filepeek;
  6177.     char **p, *s;
  6178.     int i, j, k, n, flag, width;
  6179. #ifdef CK_TTGWSIZ
  6180.     ttgwsiz();                          /* Try to get latest size */
  6181. #ifdef OS2
  6182.     width = tt_cols[VCMD];
  6183. #else /* OS2 */
  6184.     width = tt_cols;
  6185. #endif /* OS2 */
  6186.     if (width < 1)
  6187. #endif /* CK_TTGWSIZ */
  6188.       width = 80;
  6189.     printf("\n");
  6190.     printf(" Set file type:            %s\n",gfmode(binary,1));
  6191.     printf(" Set file patterns:        %s", showooa(patterns));
  6192. #ifdef CK_LABELED
  6193.     if (binary == XYFT_L)
  6194.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  6195.     else
  6196. #endif /* CK_LABELED */
  6197. #ifdef VMS
  6198.     if (binary == XYFT_I)
  6199.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  6200.     else
  6201. #endif /* VMS */
  6202.     if (filepeek)
  6203.       printf(" (but SET FILE SCAN ON overrides)\n");
  6204.     else
  6205.       printf("\n");
  6206.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  6207.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  6208.         printf("\n");
  6209.         if (k == 0) {                   /* binary... */
  6210.             printf(" File binary-patterns: ");
  6211.             p = binpatterns;
  6212.         } else {                        /* text... */
  6213.             printf(" File text-patterns:   ");
  6214.             p = txtpatterns;
  6215.         }
  6216.         if (!p[0]) {
  6217.             printf("(none)\n");
  6218.         } else {
  6219.             printf("\n ");
  6220.             n = 2;
  6221.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  6222.                 if (!p[i])              /* Done */
  6223.                   break;
  6224.                 s = p[i];               /* Look for embedded space */
  6225.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  6226.                   if (*s == SP)
  6227.                     flag = 3;
  6228.                 n += j + flag;          /* Length of this line */
  6229.                 if (n >= width - 1) {
  6230.                     printf("\n ");
  6231.                     n = j+2;
  6232.                 }
  6233.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6234.             }
  6235.             if (n > 2)
  6236.               printf("\n");
  6237.         }
  6238.     }
  6239.     printf("\n");
  6240. }
  6241. #endif /* PATTERNS */
  6242.  
  6243. #ifndef NOSPL
  6244. static VOID
  6245. shooutput() {
  6246.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6247.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6248. }
  6249.  
  6250. static VOID
  6251. shoinput() {
  6252. #ifdef CKFLOAT
  6253.     extern char * inpscale;
  6254. #endif    /* CKFLOAT */
  6255.  
  6256. #ifdef CK_AUTODL
  6257.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6258. #endif /* CK_AUTODL */
  6259.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6260.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6261.            "observe" : "ignore");
  6262.     printf(" Input buffer-length:    %d\n", inbufsize);
  6263.     printf(" Input echo:             %s\n", showoff(inecho));
  6264.     printf(" Input silence:          %d (seconds)\n", insilence);
  6265. #ifdef OS2
  6266.     printf(" Input terminal:         %s\n", showoff(interm));
  6267. #endif /* OS2 */
  6268.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6269.            "quit" : "proceed");
  6270. #ifdef CKFLOAT
  6271.     printf(" Input scale-factor:     %s\n", inpscale ? inpscale : "1.0");
  6272. #endif    /* CKFLOAT */
  6273.  
  6274.     if (instatus < 0)
  6275.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6276.     else
  6277.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6278. }
  6279. #endif /* NOSPL */
  6280.  
  6281. #ifndef NOSPL
  6282. int
  6283. showarray() {
  6284. #ifdef COMMENT
  6285.     char * p, * q, ** ap;
  6286.     int i;
  6287. #endif /* COMMENT */
  6288.     char *s; int x = 0, y;
  6289.     int range[2];
  6290.  
  6291.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6292.       if (y != -3)
  6293.         return(y);
  6294.     ckstrncpy(line,s,LINBUFSIZ);
  6295.     s = line;
  6296.     if ((y = cmcfm()) < 0)
  6297.       return(y);
  6298.     if (*s) {
  6299.         char ** ap;
  6300.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6301.             printf("?Bad array: %s\n",s);
  6302.             return(-9);
  6303.         }
  6304.         ap = a_ptr[x];
  6305.         if (!ap) {
  6306.             printf("Array not declared: %s\n", s);
  6307.             return(success = 1);
  6308.         } else {
  6309.             int i, n, max;
  6310.             max = (range[1] > 0) ?
  6311.               range[1] :
  6312.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6313.             if (range[0] < 0)
  6314.               range[0] = 0;
  6315.             if (max > a_dim[x])
  6316.               max = a_dim[x];
  6317.             n = 1;
  6318.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6319.             if (a_link[x] > -1)
  6320.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6321.             printf("\n");
  6322.             for (i = range[0]; i <= max; i++) {
  6323.                 if (ap[i]) {
  6324.                     printf("%3d. %s\n",i,ap[i]);
  6325.                     if (xaskmore) {
  6326.                         if (cmd_cols > 0) {
  6327.                             x = strlen(ap[i]) + 5;
  6328.                             y = (x % cmd_cols) ? 1 : 0;
  6329.                             n += (x / cmd_cols) + y;
  6330.                         } else {
  6331.                             n++;
  6332.                         }
  6333.                         if (n > (cmd_rows - 3)) {
  6334.                             if (!askmore())
  6335.                               break;
  6336.                             else
  6337.                               n = 0;
  6338.                         }
  6339.                     }
  6340.                 }
  6341.             }
  6342.         }
  6343.         return(1);
  6344.     }
  6345.  
  6346.     /* All arrays - just show name and dimension */
  6347.  
  6348.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6349.         if (a_ptr[y]) {
  6350.             if (x == 0) printf("Declared arrays:\n");
  6351.             x = 1;
  6352.             printf(" \\&%c[%d]",
  6353.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6354.             if (a_link[y] > -1)
  6355.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6356.             printf("\n");
  6357.         }
  6358.         if (!x) printf(" No arrays declared\n");
  6359.     }
  6360.     return(1);
  6361. }
  6362. #endif /* NOSPL */
  6363.  
  6364. int
  6365. doshow(x) int x; {
  6366.     int y, z, i; long zz;
  6367.     extern int optlines;
  6368.     char *s;
  6369. #ifdef OS2
  6370.     extern int os2gks;
  6371.     extern int tt_kb_mode;
  6372. #endif /* OS2 */
  6373.     extern int srvcdmsg;
  6374.     extern char * cdmsgstr, * ckcdpath;
  6375.  
  6376. #ifndef NOSETKEY
  6377.     if (x == SHKEY) {                   /* SHOW KEY */
  6378.         int c;
  6379. #ifdef OS2
  6380.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6381.                         "one",xxstring)) < 0) return(x);
  6382.         switch (tt_kb_mode) {
  6383.           case KBM_EM:
  6384.             s = "emacs";
  6385.             break;
  6386.           case KBM_HE:
  6387.             s = "hebrew";
  6388.             break;
  6389.           case KBM_RU:
  6390.             s = "russian";
  6391.             break;
  6392.           case KBM_EN:
  6393.           default:
  6394.             s = "default";
  6395.             break;
  6396.         }
  6397.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6398.                         s,xxstring)) < 0) return(z);
  6399.         if (z == SHKEYDEF)
  6400.           z = -1;
  6401. #endif /* OS2 */
  6402.         if ((y = cmcfm()) < 0) return(y);
  6403. #ifdef IKSD
  6404.         if (inserver) {
  6405.             printf("Sorry, command disabled.\r\n");
  6406.             return(success = 0);
  6407.         }
  6408. #endif /* IKSD */
  6409.  
  6410. #ifdef MAC
  6411.         printf("Not implemented\n");
  6412.         return(0);
  6413. #else /* Not MAC */
  6414. #ifdef OS2
  6415.         if (x) {
  6416.             con_event evt;
  6417.             for (c = 0; c < KMSIZE; c++) {
  6418.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6419.                 if (evt.type != error) {
  6420.                     shokeycode(c,z);
  6421.                 }
  6422.             }
  6423.         } else {
  6424. #endif /* OS2 */
  6425.             printf(" Press key: ");
  6426. #ifdef UNIX
  6427. #ifdef NOSETBUF
  6428.             fflush(stdout);
  6429. #endif /* NOSETBUF */
  6430. #endif /* UNIX */
  6431.             conbin((char)escape);       /* Put terminal in binary mode */
  6432. #ifdef OS2
  6433.             os2gks = 0;                 /* Raw scancode processing */
  6434. #endif /* OS2 */
  6435.             c = congks(0);              /* Get character or scan code */
  6436. #ifdef OS2
  6437.             os2gks = 1;                 /* Cooked scancode processing */
  6438. #endif /* OS2 */
  6439.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6440.             if (c < 0) {                /* Check for error */
  6441.                 printf("?Error reading key\n");
  6442.                 return(0);
  6443.             }
  6444. #ifndef OS2
  6445. /*
  6446.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6447. */
  6448.             c &= cmdmsk;                /* Apply command mask */
  6449. #endif /* OS2 */
  6450.             printf("\n");
  6451. #ifdef OS2
  6452.             shokeycode(c,z);
  6453. #else /* OS2 */
  6454.             shokeycode(c);
  6455. #endif /* OS2 */
  6456. #ifdef OS2
  6457.         }
  6458. #endif /* OS2 */
  6459.         return(1);
  6460. #endif /* MAC */
  6461.     }
  6462. #ifndef NOKVERBS
  6463.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6464.         if ((y = cmcfm()) < 0) return(y);
  6465. #ifdef IKSD
  6466.         if (inserver) {
  6467.             printf("Sorry, command disabled.\r\n");
  6468.             return(success = 0);
  6469.         }
  6470. #endif /* IKSD */
  6471.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6472.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6473.         printf("\n");
  6474.         return(1);
  6475.     }
  6476. #ifdef OS2
  6477.     if (x == SHUDK) {                   /* SHOW UDKs */
  6478.         extern void showudk(void);
  6479.         if ((y = cmcfm()) < 0) return(y);
  6480. #ifdef IKSD
  6481.         if (inserver) {
  6482.             printf("Sorry, command disabled.\r\n");
  6483.             return(success = 0);
  6484.         }
  6485. #endif /* IKSD */
  6486.         showudk();
  6487.         return(1);
  6488.     }
  6489. #endif /* OS2 */
  6490. #endif /* NOKVERBS */
  6491. #endif /* NOSETKEY */
  6492.  
  6493. #ifndef NOSPL
  6494.     if (x == SHMAC) {                   /* SHOW MACRO */
  6495.         struct FDB kw, fl, cm;
  6496.         int i, k, n = 0, left, flag, confirmed = 0;
  6497.         char * p, *q[64];
  6498.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6499.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6500.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6501.             mackey[i].flgs = mactab[i].flgs;
  6502.         }
  6503.         p = line;
  6504.         left = LINBUFSIZ;
  6505.         while (!confirmed && n < 64) {
  6506.             cmfdbi(&kw,                 /* First FDB - macro table */
  6507.                    _CMKEY,              /* fcode */
  6508.                    "Macro name",        /* hlpmsg */
  6509.                    "",                  /* default */
  6510.                    "",                  /* addtl string data */
  6511.                    nmac,                /* addtl numeric data 1: tbl size */
  6512.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6513.                    xxstring,            /* Processing function */
  6514.                    mackey,              /* Keyword table */
  6515.                    &fl                  /* Pointer to next FDB */
  6516.                    );
  6517.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6518.                    _CMFLD,              /* fcode */
  6519.                    "",                  /* hlpmsg */
  6520.                    "",                  /* default */
  6521.                    "",                  /* addtl string data */
  6522.                    0,                   /* addtl numeric data 1 */
  6523.                    0,                   /* addtl numeric data 2 */
  6524.                    xxstring,
  6525.                    NULL,
  6526.                    &cm
  6527.                    );
  6528.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6529.                    _CMCFM,              /* fcode */
  6530.                    "",                  /* hlpmsg */
  6531.                    "",                  /* default */
  6532.                    "",                  /* addtl string data */
  6533.                    0,                   /* addtl numeric data 1 */
  6534.                    0,                   /* addtl numeric data 2 */
  6535.                    NULL,
  6536.                    NULL,
  6537.                    NULL
  6538.                    );
  6539.             x = cmfdb(&kw);             /* Parse something */
  6540.             if (x < 0)
  6541.               return(x);
  6542.             s = atmbuf;                 /* What the user typed */
  6543.             switch (cmresult.fcode) {
  6544.               case _CMKEY:              /* If it was a keyword */
  6545.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6546.                 if (y > -1)
  6547.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6548.               case _CMFLD:
  6549.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6550.                 left -= k;
  6551.                 if (left <= 0) {
  6552.                     *p = NUL;
  6553.                     break;
  6554.                 }
  6555.                 q[n++] = p;             /* Point to this item */
  6556.                 p += k;                 /* Move buffer pointer past it */
  6557.                 break;
  6558.               case _CMCFM:              /* End of command */
  6559.                 confirmed++;
  6560.               default:
  6561.                 break;
  6562.             }
  6563.         }
  6564.         if (n == 0) {
  6565.             printf("Macros:\n");
  6566.             slc = 1;
  6567.             for (y = 0; y < nmac; y++)
  6568.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6569.             return(1);
  6570.         }
  6571.         slc = 0;
  6572.         for (i = 0; i < n; i++) {
  6573.             flag = 0;
  6574.             s = q[i];
  6575.             if (!s) s = "";
  6576.             if (!*s) continue;
  6577.             if (iswild(s)) {            /* Pattern match */
  6578.                 for (k = 0, x = 0; x < nmac; x++) {
  6579.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6580.                         shomac(mactab[x].kwd,mactab[x].mval);
  6581.                         k++;
  6582.                     }
  6583.                 }
  6584.                 if (!k)
  6585.                   x = -1;
  6586.                 else
  6587.                   continue;
  6588.             } else {                    /* Exact match */
  6589.                 x = mxlook(mactab,s,nmac);
  6590.                 flag = 1;
  6591.             }
  6592.             if (flag && x == -1)
  6593.               x = mlook(mactab,s,nmac);
  6594.             switch (x) {
  6595.               case -3:                  /* Nothing to look up */
  6596.               case -1:                  /* Not found */
  6597.                 printf("%s - (not defined)\n",s);
  6598.                 break;
  6599.               case -2:                  /* Ambiguous, matches more than one */
  6600.                 printf("%s - ambiguous\n",s);
  6601.                 break;
  6602.               default:                  /* Matches one exactly */
  6603.                 shomac(mactab[x].kwd,mactab[x].mval);
  6604.                 break;
  6605.             }
  6606.         }
  6607.         return(1);
  6608.     }
  6609. #endif /* NOSPL */
  6610.  
  6611. /*
  6612.   Other SHOW commands only have two fields.  Get command confirmation here,
  6613.   then handle with big switch() statement.
  6614. */
  6615. #ifndef NOSPL
  6616.     if (x != SHBUI && x != SHARR)
  6617. #endif /* NOSPL */
  6618.       if ((y = cmcfm()) < 0)
  6619.         return(y);
  6620.  
  6621. #ifdef COMMENT
  6622.     /* This restriction is too general. */
  6623. #ifdef IKSD
  6624.     if (inserver &&
  6625. #ifdef CK_LOGIN
  6626.         isguest
  6627. #else
  6628.         0
  6629. #endif /* CK_LOGIN */
  6630.         ) {
  6631.         printf("Sorry, command disabled.\r\n");
  6632.         return(success = 0);
  6633.     }
  6634. #endif /* IKSD */
  6635. #endif /* COMMENT */
  6636.  
  6637.     switch (x) {
  6638.  
  6639. #ifdef ANYX25
  6640. #ifndef IBMX25
  6641.       case SHPAD:
  6642.         shopad(0);
  6643.         break;
  6644. #endif /* IBMX25 */
  6645. #endif /* ANYX25 */
  6646.  
  6647.       case SHNET:
  6648. #ifdef NOLOCAL
  6649.         printf(" No network support in this version of C-Kermit.\n");
  6650. #else
  6651. #ifndef NETCONN
  6652.         printf(" No network support in this version of C-Kermit.\n");
  6653. #else
  6654.         shonet();
  6655. #endif /* NETCONN */
  6656. #endif /* NOLOCAL */
  6657.         break;
  6658.  
  6659.       case SHPAR:
  6660.         shopar();
  6661.         break;
  6662.  
  6663. #ifndef NOXFER
  6664.       case SHATT:
  6665.         shoatt();
  6666.         break;
  6667. #endif /* NOXFER */
  6668.  
  6669. #ifndef NOSPL
  6670.       case SHCOU:
  6671.         printf(" %d\n",count[cmdlvl]);
  6672.         break;
  6673. #endif /* NOSPL */
  6674.  
  6675. #ifndef NOSERVER
  6676.       case SHSER:                       /* Show Server */
  6677.         i = 0;
  6678. #ifndef NOFRILLS
  6679.         printf("Function:          Status:\n");
  6680.         i++;
  6681.         printf(" GET                %s\n",nm[en_get]);
  6682.         i++;
  6683.         printf(" SEND               %s\n",nm[en_sen]);
  6684.         i++;
  6685.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6686.         i++;
  6687.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6688.         i++;
  6689. #ifndef NOSPL
  6690.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6691.         i++;
  6692. #endif /* NOSPL */
  6693.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6694.         i++;
  6695. #ifdef ZCOPY
  6696.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6697.         i++;
  6698. #endif /* ZCOPY */
  6699.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6700.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6701.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6702.         i += 3;
  6703. #ifndef NOSPL
  6704.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6705.         i++;
  6706. #endif /* NOSPL */
  6707.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6708.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6709.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6710.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6711.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6712.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6713.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6714.         printf(" BYE                %s\n",nm[en_bye]);
  6715.         printf(" FINISH             %s\n",nm[en_fin]);
  6716.         printf(" EXIT               %s\n",nm[en_xit]);
  6717.         printf(" ENABLE             %s\n",nm[en_ena]);
  6718.         i += 11;
  6719. #endif /* NOFRILLS */
  6720.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6721.         printf("Server timeout:      %d\n",srvtim);
  6722.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6723.         printf("Server idle-timeout: %d\n",srvidl);
  6724.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6725.         printf("Server keepalive     %s\n", showoff(srvping));
  6726.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6727.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6728.         if (srvcdmsg && cdmsgstr)
  6729.           printf("Server cd-message    %s\n", cdmsgstr);
  6730.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6731.         printf("Server display:      %s\n", showoff(srvdis));
  6732.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6733.         printf("Server login:        ");
  6734.         if (!x_user) {
  6735.             printf("(none)\n");
  6736.         } else {
  6737.             printf("\"%s\", \"%s\", \"%s\"\n",
  6738.                    x_user,
  6739.                    x_passwd ? x_passwd : "",
  6740.                    x_acct ? x_acct : ""
  6741.                    );
  6742.         }
  6743.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6744.         printf("Server get-path: ");
  6745.         if (ngetpath == 0) {
  6746.             printf("    (none)\n");
  6747.         } else {
  6748.             printf("\n");
  6749.             i += 3;
  6750.             for (x = 0; x < ngetpath; x++) {
  6751.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6752.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6753.                     if (!askmore())
  6754.                       break;
  6755.                     else
  6756.                       i = 0;
  6757.                 }
  6758.             }
  6759.         }
  6760.         break;
  6761. #endif /* NOSERVER */
  6762.  
  6763.       case SHSTA:                       /* Status of last command */
  6764.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6765.         return(0);                      /* Don't change it */
  6766.  
  6767.       case SHSTK: {                     /* Stack for MAC debugging */
  6768. #ifdef MAC
  6769.           long sp;
  6770.           sp = -1;
  6771.           loadA0 ((char *)&sp);         /* set destination address */
  6772.           SPtoaA0();                    /* move SP to destination */
  6773.           printf("Stack at 0x%x\n", sp);
  6774.           show_queue();                 /* more debugging */
  6775.           break;
  6776. #else
  6777.           shostack();
  6778. #endif /* MAC */
  6779.           break;
  6780.       }
  6781.  
  6782.  
  6783. #ifndef NOLOCAL
  6784. #ifdef OS2
  6785.       case SHTAB:                       /* SHOW TABS */
  6786. #ifdef IKSD
  6787.         if (inserver) {
  6788.             printf("Sorry, command disabled.\r\n");
  6789.             return(success = 0);
  6790.         }
  6791. #endif /* IKSD */
  6792.         shotabs();
  6793.         break;
  6794. #endif /* OS2 */
  6795.  
  6796.       case SHTER:                       /* SHOW TERMINAL */
  6797. #ifdef IKSD
  6798.         if (inserver) {
  6799.             printf("Sorry, command disabled.\r\n");
  6800.             return(success = 0);
  6801.         }
  6802. #endif /* IKSD */
  6803.         shotrm();
  6804.         break;
  6805.  
  6806. #ifdef OS2
  6807.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6808.         shovscrn();
  6809.         break;
  6810. #endif /* OS2 */
  6811. #endif /* NOLOCAL */
  6812.  
  6813. #ifdef OS2MOUSE
  6814.       case SHMOU:                       /* SHOW MOUSE */
  6815. #ifdef IKSD
  6816.         if (inserver) {
  6817.             printf("Sorry, command disabled.\r\n");
  6818.             return(success = 0);
  6819.         }
  6820. #endif /* IKSD */
  6821.         shomou();
  6822.         break;
  6823. #endif /* OS2MOUSE */
  6824.  
  6825. #ifndef NOFRILLS
  6826.       case SHVER:
  6827.         shover();
  6828.         break;
  6829. #endif /* NOFRILLS */
  6830.  
  6831. #ifndef NOSPL
  6832.       case SHBUI:                       /* Built-in variables */
  6833.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6834.           return(y);
  6835.         ckstrncpy(line,s,LINBUFSIZ);
  6836.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6837.  
  6838.       case SHFUN:                       /* or built-in functions */
  6839. #ifdef CK_TTGWSIZ
  6840. #ifdef OS2
  6841.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6842.           ttgwsiz();
  6843. #else /* OS2 */
  6844.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6845.             if (tt_rows > 0 && tt_cols > 0) {
  6846.                 cmd_rows = tt_rows;
  6847.                 cmd_cols = tt_cols;
  6848.             }
  6849.         }
  6850. #endif /* OS2 */
  6851. #endif /* CK_TTGWSIZ */
  6852.  
  6853.         if (x == SHFUN) {               /* Functions */
  6854.             printf("\nThe following functions are available:\n\n");
  6855.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6856.             printf("\n");
  6857. #ifndef NOHELP
  6858.             printf(
  6859. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6860.                    );
  6861. #endif /* NOHELP */
  6862.             break;
  6863.         } else {                        /* Variables */
  6864.         int j, flag = 0, havearg = 0;
  6865.         struct stringarray * q = NULL;
  6866.         char ** pp;
  6867.         if (line[0]) {        /* Have something to search for */
  6868.         havearg = 1;        /* Maybe a list of things */
  6869.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6870.         if (!q) break;
  6871.         pp = q->a_head;
  6872.         }
  6873.         i = 0;
  6874.         for (y = 0; y < nvars; y++) {
  6875.         if ((vartab[y].flgs & CM_INV))
  6876.           continue;
  6877.         if (havearg) {        /* If I have something to match */
  6878.             char * s2;
  6879.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6880.             s2 = pp[j] ? pp[j] : "";
  6881. #ifdef COMMENT
  6882. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6883.             len = strlen(s2);
  6884.             if (len > 0) {
  6885.                 if (s2[len-1] != '$') {/* To allow anchors */
  6886.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6887.                 s2 = line;
  6888.                 }
  6889.             }
  6890. #endif /* COMMENT */
  6891.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6892.                 flag = 1;    /* Matches */
  6893.                 break;
  6894.             }
  6895.             }
  6896.             if (!flag)        /* Doesn't match */
  6897.               continue;
  6898.         }
  6899.         s = nvlook(vartab[y].kwd);
  6900.         printf(" \\v(%s) = ",vartab[y].kwd);
  6901.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6902.             while (*s)        /* Show control chars symbolically */
  6903.               printf("\\{%d}",*s++);
  6904.             printf("\n");
  6905.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6906.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6907. #ifdef OS2
  6908.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6909. #endif /* OS2 */
  6910.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6911.                 vartab[y].kwval <= VN_M_ZZZ)
  6912.                ) {
  6913.             int r = 12;        /* This one can wrap around */
  6914.             char buf[10];
  6915.             while (*s) {
  6916.             if (isprint(*s)) {
  6917.                 buf[0] = *s;
  6918.                 buf[1] = NUL;
  6919.                 r++;
  6920.             } else {
  6921.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6922.                 r += (int) strlen(buf);
  6923.             }
  6924.             if (r >= cmd_cols - 1) {
  6925.                 printf("\n");
  6926.                 r = 0;
  6927.                 i++;
  6928.             }
  6929.             printf("%s",buf);
  6930.             s++;
  6931.             }
  6932.             printf("\n");
  6933.         } else
  6934.           printf("%s\n",s);
  6935.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6936.             if ((y >= nvars - 1) || !askmore())
  6937.               break;
  6938.             else
  6939.               i = 0;
  6940.         }
  6941.         }
  6942.         }
  6943.         break;
  6944.  
  6945.       case SHVAR:                       /* Global variables */
  6946.         x = 0;                          /* Variable count */
  6947.         slc = 1;                        /* Screen line count for "more?" */
  6948.         for (y = 33; y < GVARS; y++)
  6949.           if (g_var[y]) {
  6950.               if (x++ == 0) printf("Global variables:\n");
  6951.               sprintf(line," \\%%%c",y); /* SAFE */
  6952.               if (shomac(line,g_var[y]) < 0) break;
  6953.           }
  6954.         if (!x) printf(" No variables defined\n");
  6955.         break;
  6956.  
  6957.       case SHARG: {                     /* Args */
  6958.           char * s1, * s2;
  6959.           if (maclvl > -1) {
  6960.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6961.                      maclvl,
  6962.                      macargc[maclvl]
  6963.                      );
  6964.               for (y = 0; y < macargc[maclvl]; y++) {
  6965.                   s1 = m_arg[maclvl][y];
  6966.                   if (!s1) s1 = "(NULL)";
  6967.                   s2 = m_xarg[maclvl][y];
  6968.                   if (!s2) s2 = "(NULL)";
  6969.                   if (y < 10)
  6970.                     printf(" \\%%%d = %s\n",y,s1);
  6971.                   else
  6972.                     printf(" \\&_[%d] = %s\n",y,s2);
  6973.               }
  6974.           } else {
  6975.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  6976.               for (y = 0; y < topargc; y++) {
  6977.                   s1 = g_var[y + '0'];
  6978.                   if (!s1) s1 = "(NULL)";
  6979.                   s2 = toparg[y];
  6980.                   if (!s2) s2 = "(NULL)";
  6981.                   if (y < 10 && g_var[y])
  6982.                     printf(" \\%%%d = %s\n",y,s1);
  6983.                   if (toparg[y])
  6984.                     printf(" \\&_[%d] = %s\n",y,s2);
  6985.               }
  6986.           }
  6987.         }
  6988.         break;
  6989.  
  6990.       case SHARR:                       /* Arrays */
  6991.         return(showarray());
  6992. #endif /* NOSPL */
  6993.  
  6994. #ifndef NOXFER
  6995.       case SHPRO:                       /* Protocol parameters */
  6996.         shoparp();
  6997.         printf("\n");
  6998.         break;
  6999. #endif /* NOXFER */
  7000.  
  7001. #ifndef NOLOCAL
  7002.       case SHCOM:                       /* Communication parameters */
  7003.         printf("\n");
  7004.         shoparc();
  7005. #ifdef OS2
  7006.         {
  7007.             int i;
  7008.             char *s = "(unknown)";
  7009.             for (i = 0; i < nprty; i++)
  7010.               if (prtytab[i].kwval == priority) {
  7011.                   s = prtytab[i].kwd;
  7012.                   break;
  7013.               }
  7014.             printf(" Priority: %s\n", s );
  7015.         }
  7016. #endif /* OS2 */
  7017.  
  7018.         printf("\n");
  7019. #ifdef NETCONN
  7020.         if (!network
  7021. #ifdef IKSD
  7022.              && !inserver
  7023. #endif /* IKSD */
  7024.              ) {
  7025. #endif /* NETCONN */
  7026.             shomdm();
  7027.             printf("\n");
  7028. #ifdef NETCONN
  7029.         }
  7030. #endif /* NETCONN */
  7031.  
  7032. #ifndef NODIAL
  7033. #ifdef IKSD
  7034.         if ( !inserver )
  7035. #endif /* IKSD */
  7036.         {
  7037.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  7038.             printf("Type SHOW MODEM to see modem-related items.\n");
  7039. #ifdef CK_TAPI
  7040.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  7041. #endif /* CK_TAPI */
  7042.             printf("\n");
  7043.         }
  7044. #endif /* NODIAL */
  7045.         break;
  7046. #endif /* NOLOCAL */
  7047.  
  7048.       case SHFIL:                       /* File parameters */
  7049.         shofil();
  7050.         /* printf("\n"); */             /* (out o' space) */
  7051.         break;
  7052.  
  7053. #ifndef NOCSETS
  7054.       case SHLNG:                       /* Languages */
  7055.         shoparl();
  7056.         break;
  7057. #endif /* NOCSETS */
  7058.  
  7059. #ifndef NOSPL
  7060.       case SHSCR:                       /* Scripts */
  7061.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  7062.         printf(" Take  echo:             %s\n", showoff(techo));
  7063.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  7064.         printf(" Macro echo:             %s\n", showoff(mecho));
  7065.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  7066.         printf(" Quiet:                  %s\n", showoff(quiet));
  7067.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  7068.         printf(" Function error:         %s\n", showoff(fnerror));
  7069. #ifdef CKLEARN
  7070.         {
  7071.             extern char * learnfile;
  7072.             extern int learning;
  7073.             if (learnfile) {
  7074.                 printf(" LEARN file:             %s (%s)\n",
  7075.                        learnfile,
  7076.                        learning ? "ON" : "OFF"
  7077.                        );
  7078.             } else
  7079.               printf(" LEARN file:             (none)\n");
  7080.         }
  7081. #endif /* CKLEARN */
  7082.         shoinput();
  7083.         shooutput();
  7084. #ifndef NOSCRIPT
  7085.         printf(" Script echo:            %s\n", showoff(secho));
  7086. #endif /* NOSCRIPT */
  7087.         printf(" Command buffer length:  %d\n", CMDBL);
  7088.         printf(" Atom buffer length:     %d\n", ATMBL);
  7089.         break;
  7090. #endif /* NOSPL */
  7091.  
  7092. #ifndef NOXMIT
  7093.       case SHXMI:
  7094.         printf("\n");
  7095.         printf(" File type:                       %s\n",
  7096.                binary ? "binary" : "text");
  7097. #ifndef NOCSETS
  7098.         printf(" File character-set:              %s\n",
  7099.                fcsinfo[fcharset].keyword);
  7100. #ifdef OS2
  7101.         if ( isunicode() ) {
  7102.         printf(" Terminal Character (remote):     %s\n",
  7103.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7104.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7105.         printf(" Terminal Character (local):      %s\n",
  7106.               tcsl == TX_TRANSP ? "transparent" :
  7107.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7108.         } else {
  7109.         printf(" Terminal Character (remote):     %s\n",
  7110.               tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  7111.               tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  7112.         printf(" Terminal Character (local):      %s\n",
  7113.               tcsl == TX_TRANSP ? "transparent" :
  7114.               tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  7115.         }
  7116. #else /* OS2 */
  7117.         printf(" Terminal character-set (remote): %s\n",
  7118.                fcsinfo[tcsr].keyword);
  7119.         printf(" Terminal character-set (local):  %s\n",
  7120.                fcsinfo[tcsl].keyword);
  7121. #endif /* OS2 */
  7122. #endif /* NOCSETS */
  7123.         printf(" Terminal bytesize:               %d\n",
  7124.                (cmask == 0xff) ? 8 : 7);
  7125.         printf(" Terminal echo:                   %s\n",
  7126.                duplex ? "local" : "remote");
  7127.         printf(" Transmit EOF:                    ");
  7128.         if (*xmitbuf == NUL) {
  7129.             printf("(none)\n");
  7130.         } else {
  7131.             char *p;
  7132.             p = xmitbuf;
  7133.             while (*p) {
  7134.                 if (*p < SP)
  7135.                   printf("^%c",ctl(*p));
  7136.                 else
  7137.                   printf("%c",*p);
  7138.                 p++;
  7139.             }
  7140.             printf("\n");
  7141.         }
  7142.         if (xmitf)
  7143.           printf(" Transmit Fill:                   %d\n", xmitf);
  7144.         else
  7145.           printf(" Transmit Fill:                   (none)\n");
  7146.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  7147.         if (xmitp)
  7148.           printf(" Transmit Prompt:                 %d (%s)\n",
  7149.                  xmitp,
  7150.                  chartostr(xmitp)
  7151.                  );
  7152.         else
  7153.           printf(" Transmit Prompt:                 (none)\n");
  7154.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  7155.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  7156.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  7157.                xmitw,
  7158.                (xmitw == 1) ? "" : "s"
  7159.                );
  7160.         printf(" Transmit Timeout:                %d (second%s)\n",
  7161.                xmitt,
  7162.                (xmitt == 1) ? "" : "s"
  7163.                );
  7164.         printf("\n");
  7165.         break;
  7166. #endif /* NOXMIT */
  7167.  
  7168. #ifndef NODIAL
  7169.       case SHMOD:                       /* SHOW MODEM */
  7170. #ifdef IKSD
  7171.         if (inserver) {
  7172.             printf("Sorry, command disabled.\r\n");
  7173.             return(success = 0);
  7174.         }
  7175. #endif /* IKSD */
  7176.         shomodem();                     /* Show SET MODEM items */
  7177.         break;
  7178. #endif /* NODIAL */
  7179.  
  7180. #ifndef MAC
  7181.       case SHDFLT:
  7182.         printf("%s\n",zgtdir());
  7183.         break;
  7184. #endif /* MAC */
  7185.  
  7186. #ifndef NOLOCAL
  7187.       case SHESC:
  7188. #ifdef IKSD
  7189.         if (inserver) {
  7190.             printf("Sorry, command disabled.\r\n");
  7191.             return(success = 0);
  7192.         }
  7193. #endif /* IKSD */
  7194.         return(shoesc(escape));
  7195.  
  7196. #ifndef NODIAL
  7197.       case SHDIA:                       /* SHOW DIAL */
  7198. #ifdef IKSD
  7199.         if (inserver) {
  7200.             printf("Sorry, command disabled.\r\n");
  7201.             return(success = 0);
  7202.         }
  7203. #endif /* IKSD */
  7204.         shmdmlin();
  7205.         printf(", speed: ");
  7206.         if ((zz = ttgspd()) < 0) {
  7207.             printf("unknown");
  7208.         } else {
  7209.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  7210.         }
  7211.         if (carrier == CAR_OFF) s = "off";
  7212.         else if (carrier == CAR_ON) s = "on";
  7213.         else if (carrier == CAR_AUT) s = "auto";
  7214.         else s = "unknown";
  7215.         printf(", carrier: %s", s);
  7216.         if (carrier == CAR_ON) {
  7217.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  7218.             else printf(", timeout: none");
  7219.         }
  7220.         printf("\n");
  7221.         doshodial();
  7222.         if (local
  7223. #ifdef NETCONN
  7224.             && !network
  7225. #endif /* NETCONN */
  7226.             ) {
  7227.             printf("Type SHOW MODEM to see modem settings.\n");
  7228. #ifdef CK_TAPI
  7229.             printf("Type SHOW TAPI to see TAPI-related items\n");
  7230. #endif /* CK_TAPI */
  7231.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  7232.         }
  7233.         break;
  7234. #endif /* NODIAL */
  7235. #endif /* NOLOCAL */
  7236.  
  7237. #ifndef NOXFER
  7238. #ifdef CK_LABELED
  7239.       case SHLBL:                       /* Labeled file info */
  7240.         sholbl();
  7241.         break;
  7242. #endif /* CK_LABELED */
  7243. #endif /* NOXFER */
  7244.  
  7245.       case SHCSE:                       /* Character sets */
  7246. #ifdef NOCSETS
  7247.         printf(
  7248. " Character set translation is not supported in this version of C-Kermit\n");
  7249. #else
  7250.         shocharset();
  7251. #ifndef NOXFER
  7252.         printf("\n Unknown-Char-Set: %s\n",
  7253.                unkcs ? "Keep" : "Discard");
  7254. #endif /* NOXFER */
  7255. #ifdef OS2
  7256.         printf("\n");
  7257. #endif /* OS2 */
  7258.         shotcs(tcsl,tcsr);
  7259.         printf("\n");
  7260. #ifdef OS2
  7261.         /* PC Code Page information */
  7262.         {
  7263.             char cpbuf[128];
  7264.             int cplist[16], cps;
  7265.             int activecp;
  7266.             cps = os2getcplist(cplist, sizeof(cplist));
  7267.  
  7268.             sprintf(cpbuf,              /* SAFE */
  7269.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7270.                      cps > 1 ? cplist[1] : 0,
  7271.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7272.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7273.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7274.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7275.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7276.                      cps > 12 ? cplist[12] : 0
  7277.                      );
  7278.             printf(" Code Pages:\n");
  7279.             activecp = os2getcp();
  7280.             if ( activecp ) {
  7281.               printf("     Active: %d\n",activecp);
  7282.               if (!isWin95())
  7283.                 printf("  Available: %s\n",cpbuf);
  7284.             } else
  7285.               printf("     Active: n/a\n");
  7286.             printf("\n");
  7287.         }
  7288. #endif /* OS2 */
  7289. #endif /* NOCSETS */
  7290.         break;
  7291.  
  7292.       case SHFEA:                       /* Features */
  7293.         shofea();
  7294.         break;
  7295.  
  7296. #ifdef CK_SPEED
  7297.       case SHCTL:                       /* Control-Prefix table */
  7298.         shoctl();
  7299.         break;
  7300. #endif /* CK_SPEED */
  7301.  
  7302.       case SHEXI: {
  7303.           extern int exithangup;
  7304.           printf("\n Exit warning %s\n", xitwarn ?
  7305.                  (xitwarn == 1 ? "on" : "always") : "off");
  7306.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7307.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7308.           printf(" Current exit status: %d\n\n", xitsta);
  7309.           break;
  7310.       }
  7311.       case SHPRT: {
  7312. #ifdef PRINTSWI
  7313.           extern int printtimo, printertype, noprinter;
  7314.           extern char * printterm, * printsep;
  7315.           extern int prncs;
  7316. #ifdef BPRINT
  7317.           extern int printbidi;
  7318. #endif /* BPRINT */
  7319. #endif /* PRINTSWI */
  7320.  
  7321. #ifdef IKSD
  7322.         if (inserver &&
  7323. #ifdef CK_LOGIN
  7324.             isguest
  7325. #else /* CK_LOGIN */
  7326.             0
  7327. #endif /* CK_LOGIN */
  7328.              ) {
  7329.             printf("Sorry, command disabled.\r\n");
  7330.             return(success = 0);
  7331.         }
  7332. #endif /* IKSD */
  7333. #ifdef PRINTSWI
  7334.           if (noprinter) {
  7335.               printf("Printer: (none)\n\n");
  7336.               break;
  7337.           }
  7338. #endif /* PRINTSWI */
  7339.  
  7340.           printf("Printer: %s%s\n",
  7341.  
  7342.                  printpipe ? "| " : "",
  7343.                  printername ? printername :
  7344. #ifdef OS2
  7345.                  "PRN"
  7346. #else
  7347.                  "(default)"
  7348. #endif /* OS2 */
  7349.                  );
  7350. #ifdef PRINTSWI
  7351. #ifdef BPRINT
  7352.           if (printbidi) {
  7353.               printf(" /BIDIRECTIONAL\n");
  7354.               if (pportspeed > 0)
  7355.                 printf(" /SPEED:%ld\n",pportspeed);
  7356.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7357.               printf(" /FLOW:%s\n",
  7358.                      pportflow == FLO_NONE ? "NONE" :
  7359.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7360.                      );
  7361.           } else
  7362.             printf(" /OUTPUT-ONLY\n");
  7363. #endif /* BPRINT */
  7364.           switch (printertype) {
  7365.             case PRT_NON: printf(" /NONE\n"); break;
  7366.             case PRT_FIL: printf(" /FILE\n"); break;
  7367.             case PRT_PIP: printf(" /PIPE\n"); break;
  7368.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7369.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7370.           }
  7371.           printf(" /TIMEOUT:%d\n",printtimo);
  7372.           if (printterm) {
  7373.               printf(" /END-OF-JOB-STRING:");
  7374.               shostrdef(printterm);
  7375.               printf("\n");
  7376.           } else
  7377.             printf(" /END-OF-JOB-STRING:(none)\n");
  7378.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7379.           printf(" /CHARACTER-SET: %s\n",txrinfo[prncs]->keywd);
  7380. #endif /* PRINTSWI */
  7381.           printf("\n");
  7382.           break;
  7383.       }
  7384.  
  7385.       case SHCMD: {
  7386. #ifdef DOUBLEQUOTING
  7387.           extern int dblquo;
  7388. #endif /* DOUBLEQUOTING */
  7389. #ifdef CK_AUTODL
  7390.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7391. #else
  7392.           printf(" Command autodownload: (not available)\n");
  7393. #endif /* CK_AUTODL */
  7394.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7395. #ifdef CK_RECALL
  7396.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7397. #else
  7398.           printf(" Command recall-buffer not available in this version\n");
  7399. #endif /* CK_RECALL */
  7400. #ifdef CK_RECALL
  7401.           printf(" Command retry: %s\n",showoff(cm_retry));
  7402. #else
  7403.           printf(" Command retry not available in this version\n");
  7404. #endif /* CK_RECALL */
  7405.           printf(" Command interruption: %s\n", showoff(cmdint));
  7406.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7407. #ifdef DOUBLEQUOTING
  7408.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7409. #endif /* DOUBLEQUOTING */
  7410.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7411.           printf(" Command height: %d\n", cmd_rows);
  7412.           printf(" Command width:  %d\n", cmd_cols);
  7413. #ifndef IKSDONLY
  7414. #ifdef OS2
  7415.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7416. #endif /* OS2 */
  7417. #endif /* IKSDONLY */
  7418. #ifdef LOCUS
  7419.           printf(" Locus:          %s",
  7420.                  autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7421.          (locus ? "local" : "remote"));
  7422.           if (autolocus)
  7423.             printf(" (%s)", locus ? "local" : "remote");
  7424.           printf("\n");
  7425. #endif /* LOCUS */
  7426.           printf(" Hints:          %s\n", showoff(hints));
  7427.           printf(" Quiet:          %s\n", showoff(quiet));
  7428.           printf(" Maximum command length: %d\n", CMDBL);
  7429. #ifndef NOSPL
  7430.           {
  7431.               char * s;
  7432.               int k;
  7433.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7434.               printf(" Macros defined: %d\n", nmac);
  7435.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7436.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7437.               s = "(not defined)";
  7438.               k = mlook(mactab,"on_unknown_command",nmac);
  7439.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7440.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7441.           }
  7442. #endif /* NOSPL */
  7443. #ifdef UNIX
  7444. #ifndef NOJC
  7445.           printf(" Suspend: %s\n", showoff(xsuspend));
  7446. #endif /* NOJC */
  7447. #endif /* UNIX */
  7448.           printf(" Access to external commands and programs%s allowed\n",
  7449. #ifndef NOPUSH
  7450.                  !nopush ? "" :
  7451. #endif /* NOPUSH */
  7452.                   " not");
  7453.           break;
  7454.       }
  7455.  
  7456. #ifndef NOSPL
  7457.       case SHALRM:
  7458.         if (ck_alarm)
  7459.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7460.         else
  7461.           printf("(no alarm set)\n");
  7462.         break;
  7463. #endif /* NOSPL */
  7464.  
  7465. #ifndef NOMSEND
  7466.       case SHSFL: {
  7467.           extern struct filelist * filehead;
  7468.           if (!filehead) {
  7469.               printf("send-list is empty\n");
  7470.           } else {
  7471.               struct filelist * flp;
  7472.               char * s;
  7473.               flp = filehead;
  7474.               while (flp) {
  7475.                   s = flp->fl_alias;
  7476.                   if (!s) s = "(none)";
  7477.                   printf("%s, mode: %s, alias: %s\n",
  7478.                          flp->fl_name,
  7479.                          gfmode(flp->fl_mode,0),
  7480.                          s
  7481.                          );
  7482.                   flp = flp->fl_next;
  7483.               }
  7484.           }
  7485.       }
  7486.       break;
  7487. #endif /* NOMSEND */
  7488.  
  7489. #ifdef CKXXCHAR
  7490.       case SHDBL:
  7491.         shodbl();
  7492.         break;
  7493. #endif /* CKXXCHAR */
  7494.  
  7495. #ifndef NOPUSH
  7496. #ifndef NOFRILLS
  7497.       case SHEDIT:
  7498.         if (!editor[0]) {
  7499.             s = getenv("EDITOR");
  7500.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7501.         }
  7502.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7503.         if (editor[0]) {
  7504.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7505.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7506.         }
  7507.         printf("\n");
  7508.         break;
  7509.  
  7510. #ifdef BROWSER
  7511.       case SHBROWSE:
  7512.         if (!browser[0]) {
  7513.             s = getenv("BROWSER");
  7514.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7515.         }
  7516.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7517.         if (browser[0]) {
  7518.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7519.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7520.         }
  7521.         printf("\n");
  7522.         break;
  7523. #endif /* BROWSER */
  7524. #endif /*  NOFRILLS */
  7525. #endif /* NOPUSH */
  7526.  
  7527. #ifndef NOLOCAL
  7528. #ifdef CK_TAPI
  7529.       case SHTAPI:                      /* TAPI options */
  7530. #ifdef IKSD
  7531.         if (inserver) {
  7532.             printf("Sorry, command disabled.\r\n");
  7533.             return(success = 0);
  7534.         }
  7535. #endif /* IKSD */
  7536.         shotapi(0);
  7537.         break;
  7538.       case SHTAPI_L:                    /* TAPI Locations */
  7539. #ifdef IKSD
  7540.         if (inserver) {
  7541.             printf("Sorry, command disabled.\r\n");
  7542.             return(success = 0);
  7543.         }
  7544. #endif /* IKSD */
  7545.         shotapi(1);
  7546.         break;
  7547.       case SHTAPI_M:                    /* TAPI Modem */
  7548. #ifdef IKSD
  7549.         if (inserver) {
  7550.             printf("Sorry, command disabled.\r\n");
  7551.             return(success = 0);
  7552.         }
  7553. #endif /* IKSD */
  7554.         shotapi(2);
  7555.         break;
  7556.       case SHTAPI_C:                    /* TAPI Comm */
  7557. #ifdef IKSD
  7558.         if (inserver) {
  7559.             printf("Sorry, command disabled.\r\n");
  7560.             return(success = 0);
  7561.         }
  7562. #endif /* IKSD */
  7563.         shotapi(3);
  7564.         break;
  7565. #endif /* CK_TAPI */
  7566.  
  7567.       case SHTCP:                       /* SHOTCP */
  7568.         printf("\n");
  7569.         shotcp(0);
  7570.         printf("\n");
  7571.         break;
  7572.  
  7573. #ifdef TNCODE
  7574.       case SHTEL:                       /* TELNET */
  7575.         printf("\n");
  7576.         shotel(0);
  7577.         printf("\n");
  7578.         break;
  7579.  
  7580.       case SHTOPT:                      /* TELNET OPTIONS */
  7581.         printf("\n");
  7582.         shotopt(0);
  7583.         printf("\n");
  7584.         break;
  7585. #endif /* TNCODE */
  7586.  
  7587. #ifdef CK_TRIGGER
  7588.       case SHTRIG: {
  7589.           extern char * tt_trigger[], * triggerval;
  7590.           int i;
  7591.           if (!tt_trigger[0]) {
  7592.               printf(" Triggers: (none)\n");
  7593.           } else {
  7594.               printf(" Triggers:\n");
  7595.               for (i = 0; i < TRIGGERS; i++) {
  7596.                   if (!tt_trigger[i])
  7597.                     break;
  7598.                   printf("  \"%s\"\n",tt_trigger[i]);
  7599.               }
  7600.               printf(" Most recent trigger encountered: ");
  7601.               if (triggerval)
  7602.                 printf("\"%s\"\n",triggerval);
  7603.               else
  7604.                 printf("(none)\n");
  7605.           }
  7606.           break;
  7607.       }
  7608. #endif /* CK_TRIGGER */
  7609. #endif /* NOLOCAL */
  7610.  
  7611. #ifndef NOSPL
  7612.       case SHINP:
  7613.         shoinput();
  7614.         break;
  7615. #endif /* NOSPL */
  7616.  
  7617.       case SHLOG: {
  7618. #ifndef MAC
  7619. #ifdef IKSD
  7620.           if (inserver &&
  7621. #ifdef CK_LOGIN
  7622.               isguest
  7623. #else /* CK_LOGIN */
  7624.               0
  7625. #endif /* CK_LOGIN */
  7626.              ) {
  7627.             printf("Sorry, command disabled.\r\n");
  7628.             return(success = 0);
  7629.         }
  7630. #endif /* IKSD */
  7631. #ifdef DEBUG
  7632.           printf("\n Debug log:       %s\n", deblog ? debfil : "(none)");
  7633. #endif /* DEBUG */
  7634. #ifndef NOXFER
  7635.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7636. #endif /* NOXFER */
  7637. #ifndef NOLOCAL
  7638.           printf(" Session log:     %s\n",   seslog ? sesfil : "(none)");
  7639. #endif /* NOLOCAL */
  7640. #ifdef TLOG
  7641.           printf(" Transaction log: %s (%s)\n",
  7642.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7643.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7644.                  );
  7645. #endif /* TLOG */
  7646. #ifdef CKLOGDIAL
  7647.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7648. #endif /* CKLOGDIAL */
  7649.           printf("\n");
  7650. #endif /* MAC */
  7651.           break;
  7652.       }
  7653.  
  7654. #ifndef NOSPL
  7655.       case SHOUTP:                      /* OUTPUT */
  7656.         shooutput();
  7657.         break;
  7658. #endif /* NOSPL */
  7659.  
  7660. #ifdef PATTERNS
  7661.       case SHOPAT:                      /* PATTERNS */
  7662.         shopat();
  7663.         break;
  7664. #endif /* PATTERNS */
  7665.  
  7666. #ifdef STREAMING
  7667.       case SHOSTR: {                    /* STREAMING */
  7668.           extern int streamrq, clearrq, cleared;
  7669.           extern long tfcps;
  7670.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7671.           printf("\n Reliable:     %s\n",showooa(reliable));
  7672.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7673.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7674.           if ((!local && (streamrq == SET_ON)) ||
  7675.               (streamrq == SET_AUTO && reliable))
  7676.             printf(" Streaming will be done if requested.\n");
  7677.           else if ((streamrq == SET_OFF) ||
  7678.                    ((streamrq == SET_AUTO) && !reliable))
  7679.             printf(" Streaming will not be requested and will not be done.\n");
  7680.           else if ((streamrq == SET_ON) ||
  7681.                    ((streamrq == SET_AUTO) && reliable))
  7682.             printf(
  7683. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7684.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7685.                  streamed > 0 ? "" : "no ",
  7686.                  cleared ? ", clearchannel" : "",
  7687.                  tfcps
  7688.                  );
  7689.           printf("\n");
  7690.           break;
  7691.       }
  7692. #endif /* STREAMING */
  7693.  
  7694.       case SHOIKS:
  7695.         return(sho_iks());
  7696.         break;
  7697.  
  7698. #ifdef CK_AUTHENTICATION
  7699.       case SHOAUTH:
  7700.         return(sho_auth(0));
  7701. #endif /* CK_AUTHENTICATION */
  7702.  
  7703. #ifndef NOFTP
  7704.       case SHOFTP: {
  7705. #ifdef IKSD
  7706.         if (inserver) {
  7707.             printf("Sorry, command disabled.\r\n");
  7708.             return(success = 0);
  7709.         }
  7710. #endif /* IKSD */
  7711. #ifdef SYSFTP
  7712.         {
  7713.             extern char ftpapp[], ftpopts[];
  7714.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7715.             if (ftpapp[0])
  7716.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7717.         }
  7718. #else
  7719. #ifdef NEWFTP
  7720.         shoftp(0);
  7721. #else
  7722.         printf("(No FTP client included in this version of Kermit.)\n");
  7723. #endif /* NEWFTP */
  7724. #endif /* SYSFTP */
  7725.         break;
  7726.       }
  7727. #endif /* NOFTP */
  7728.  
  7729. #ifndef NOCMDL
  7730.       case SHXOPT: {
  7731. #ifdef IKSDB
  7732.           extern int dbenabled;
  7733.           extern char * dbfile, * dbdir;
  7734. #endif /* IKSDB */
  7735. #ifdef CKWTMP
  7736.           extern int ckxwtmp;
  7737.           extern char * wtmpfile;
  7738. #endif /* CKWTMP */
  7739. #ifdef CK_LOGIN
  7740.           extern int ckxanon, xferlog, logintimo;
  7741.           extern char * xferfile;
  7742. #ifdef UNIX
  7743.           extern int ckxpriv;
  7744. #endif /* UNIX */
  7745. #ifdef CK_PERMS
  7746.           extern int ckxperms;
  7747. #endif /* CK_PERMS */
  7748. #endif /* CK_LOGIN */
  7749.           extern char * bannerfile, * helpfile;
  7750.  
  7751. #ifdef IKSD
  7752.           if (inserver &&
  7753. #ifdef CK_LOGIN
  7754.               isguest
  7755. #else /* CK_LOGIN */
  7756.               0
  7757. #endif /* CK_LOGIN */
  7758.               ) {
  7759.               printf("Sorry, command disabled.\r\n");
  7760.               return(success = 0);
  7761.           }
  7762. #endif /* IKSD */
  7763.           printf("\n");
  7764.           if (!cmdint)
  7765.             printf(" --nointerrupts\n");
  7766.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7767.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7768.           printf(" --cdmessage:%d\n",srvcdmsg);
  7769.           printf(" --helpfile:%d\n",helpfile);
  7770.           if (inserver) {
  7771.               printf("\n");
  7772.               break;
  7773.           }
  7774. #ifdef CKSYSLOG
  7775. #ifdef SYSLOGLEVEL
  7776.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7777. #else
  7778.           printf(" --syslog:%d\n",ckxsyslog);
  7779. #endif /* SYSLOGLEVEL */
  7780. #endif /* CKSYSLOG */
  7781. #ifdef CKWTMP
  7782.           printf(" --wtmplog:%d\n",ckxwtmp);
  7783.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7784. #endif /* CKWTMP */
  7785. #ifdef IKSD
  7786. #ifdef CK_LOGIN
  7787.           printf(" --anonymous:%d\n",ckxanon);
  7788. #ifdef UNIX
  7789.           printf(" --privid:%d\n",ckxpriv);
  7790. #endif /* UNIX */
  7791. #ifdef CK_PERMS
  7792.           printf(" --permission:%04o\n",ckxperms);
  7793. #endif /* CK_PERMS */
  7794.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7795.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7796.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7797.           printf(" --xferlog=%d\n",xferlog);
  7798.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7799.           printf(" --timeout=%d\n",logintimo);
  7800. #endif /* CK_LOGIN */
  7801. #ifdef IKSDB
  7802.           printf(" --database=%d\n",dbenabled);
  7803.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7804.           if (dbdir)
  7805.             printf("   (db directory=[%s])\n",dbdir);
  7806. #endif /* IKSDB */
  7807. #ifdef IKSDCONF
  7808.           printf(" IKSD conf=%s\n",iksdconf);
  7809. #endif /* IKSDCONF */
  7810. #endif /* IKSD */
  7811.           printf("\n");
  7812.           break;
  7813.       }
  7814. #endif /* NOCMDL */
  7815.  
  7816.       case SHCD: {
  7817.       extern char * myhome;
  7818.       s = getenv("CDPATH");
  7819.       if (!s) s = "(none)";
  7820.       printf("\n current directory:  %s\n", zgtdir());
  7821.       printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7822.       printf(" cd home:            %s\n", homepath());
  7823.       printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7824.       printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7825.       printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7826.       printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7827.       break;
  7828.       }
  7829. #ifndef NOCSETS
  7830.       case SHASSOC:
  7831.         (VOID) showassoc();
  7832.         break;
  7833. #endif /* NOCSETS */
  7834.  
  7835. #ifdef CKLOGDIAL
  7836.       case SHCONNX:
  7837. #ifdef NEWFTP
  7838.         if (ftpisconnected()) {
  7839.             extern char cxlogbuf[];
  7840.             dologshow(W_FTP | 1);
  7841.             if (cxlogbuf[0])
  7842.               dologshow(1);
  7843.         } else {
  7844. #endif /* NEWFTP */
  7845.             dologshow(1);
  7846. #ifdef NEWFTP
  7847.         }
  7848. #endif /* NEWFTP */
  7849.         break;
  7850. #endif /* CKLOGDIAL */
  7851.  
  7852.       case SHOPTS:
  7853.         optlines = 0;
  7854. #ifndef NOFRILLS
  7855.         (VOID) showdelopts();
  7856. #endif /* NOFRILLS */
  7857. #ifdef DOMYDIR
  7858.         (VOID) showdiropts();
  7859. #endif /* DOMYDIR */
  7860. #ifdef CKPURGE
  7861.         (VOID) showpurgopts();
  7862. #endif /* CKPURGE */
  7863.         (VOID) showtypopts();
  7864.         break;
  7865.  
  7866. #ifndef NOLOCAL
  7867.       case SHOFLO:
  7868.         (VOID) shoflow();
  7869.         break;
  7870. #endif /* NOLOCAL */
  7871.  
  7872. #ifndef NOXFER
  7873.       case SHOXFER:
  7874.         (VOID) shoxfer();
  7875.         break;
  7876. #endif /* NOXFER */
  7877.  
  7878. #ifdef CK_RECALL
  7879.       case SHHISTORY:
  7880.         (VOID) cmhistory();
  7881.         break;
  7882. #endif /* CK_RECALL */
  7883.  
  7884. #ifndef NOSEXP
  7885. #ifndef NOSPL
  7886.       case SHSEXP:
  7887.         (VOID) shosexp();
  7888.         break;
  7889. #endif /* NOSPL */
  7890. #endif /* NOSEXP */
  7891.  
  7892. #ifdef ANYSSH
  7893.       case SHOSSH:
  7894.         (VOID) shossh();
  7895.         break;
  7896. #endif /* ANYSSH */
  7897.  
  7898. #ifdef KUI
  7899.       case SHOGUI:
  7900.         (VOID) shogui();
  7901.         break;
  7902. #endif /* KUI */
  7903.  
  7904.       default:
  7905.         printf("\nNothing to show...\n");
  7906.         return(-2);
  7907.     }
  7908.     return(success = 1);
  7909. }
  7910.  
  7911. #ifndef NOXFER
  7912. int
  7913. shoatt() {
  7914.     printf("Attributes: %s\n", showoff(atcapr));
  7915.     if (!atcapr) return(0);
  7916.     printf(" Blocksize: %s\n", showoff(atblki));
  7917.     printf(" Date: %s\n", showoff(atdati));
  7918.     printf(" Disposition: %s\n", showoff(atdisi));
  7919.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7920.     printf(" Length: %s\n", showoff(atleni));
  7921.     printf(" Type (text/binary): %s\n", showoff(attypi));
  7922.     printf(" System ID: %s\n", showoff(atsidi));
  7923.     printf(" System Info: %s\n", showoff(atsysi));
  7924. #ifdef CK_PERMS
  7925.     printf(" Permissions In:  %s\n", showoff(atlpri));
  7926.     printf(" Permissions Out: %s\n", showoff(atlpro));
  7927. #endif /* CK_PERMS */
  7928. #ifdef STRATUS
  7929.     printf(" Format: %s\n", showoff(atfrmi));
  7930.     printf(" Creator: %s\n", showoff(atcrei));
  7931.     printf(" Account: %s\n", showoff(atacti));
  7932. #endif /* STRATUS */
  7933.     return(0);
  7934. }
  7935. #endif /* NOXFER */
  7936.  
  7937. #ifndef NOSPL
  7938. int                                     /* SHOW MACROS */
  7939. shomac(s1, s2) char *s1, *s2; {
  7940.     int x, n, pp;
  7941.     pp = 0;                             /* Parenthesis counter */
  7942.  
  7943.     debug(F110,"shomac s1",s1,0);
  7944.     debug(F110,"shomac s2",s2,0);
  7945.  
  7946. #ifdef IKSD
  7947.     if ( inserver &&
  7948. #ifdef IKSDCONF
  7949.         iksdcf
  7950. #else /* IKSDCONF */
  7951.         1
  7952. #endif /* IKSDCONF */
  7953.         ) {
  7954.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  7955.             !ckstrcmp("on_logout",s1,-1,0))
  7956.           return(0);
  7957.     }
  7958. #endif /* IKSD */
  7959.  
  7960.     if (!s1)
  7961.       return(0);
  7962.     else
  7963.       printf("%s = ",s1);               /* Print blank line and macro name */
  7964.     n = (int)strlen(s1) + 4;            /* Width of current line */
  7965.     if (!s2) s2 = "(not defined)";
  7966.  
  7967.     while ((x = *s2++)) {               /* Loop thru definition */
  7968.         if (x == '(') pp++;             /* Treat commas within parens */
  7969.         if (x == ')') pp--;             /* as ordinary text */
  7970.         if (pp < 0) pp = 0;             /* Outside parens, */
  7971.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  7972.             putchar(',');
  7973.             putchar('-');
  7974.             x = '\n';
  7975.         }
  7976.         if (inserver && (x == '\n'))    /* Send CR before LF */
  7977.           putchar(CR);
  7978.         putchar((CHAR)x);               /* Output the character */
  7979.         if (x == '\n') {                /* If it was a newline */
  7980. #ifdef UNIX
  7981. #ifdef NOSETBUF
  7982.             fflush(stdout);
  7983. #endif /* NOSETBUF */
  7984. #endif /* UNIX */
  7985.             putchar(' ');               /* Indent the next line 1 space */
  7986.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  7987.             n = 2;                      /* restart the character counter */
  7988.             slc++;                      /* and increment the line counter. */
  7989.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  7990.             putchar('-');               /* output a dash */
  7991.             if (inserver)
  7992.               putchar(CR);              /* and a carriage return */
  7993.             putchar(NL);                /* and a newline */
  7994. #ifdef UNIX
  7995. #ifdef NOSETBUF
  7996.             fflush(stdout);
  7997. #endif /* NOSETBUF */
  7998. #endif /* UNIX */
  7999.             n = 1;                      /* and restart the char counter */
  8000.             slc++;                      /* and increment the line counter */
  8001.         }
  8002.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  8003.             if (!askmore()) return(-1); /* ask if they want more. */
  8004.             n = 1;                      /* They do, start a new line */
  8005.             slc = 0;                    /* and restart line counter */
  8006.         }
  8007.     }
  8008.     if (inserver)
  8009.       putchar(CR);
  8010.     putchar(NL);                        /* End of definition */
  8011.     if (++slc > (cmd_rows - 3)) {
  8012.         if (!askmore()) return(-1);
  8013.         slc = 0;
  8014.     }
  8015.     return(0);
  8016. }
  8017. #endif /* NOSPL */
  8018. #endif /* NOSHOW */
  8019.  
  8020. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  8021.  
  8022. #ifndef NOSPL
  8023. /* Evaluate an arithmetic expression. */
  8024. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  8025.  
  8026. static int xerror = 0;
  8027. int divbyzero = 0;
  8028. static char *cp;
  8029. static CK_OFF_T tokval;
  8030. static char curtok;
  8031. static CK_OFF_T expval;
  8032.  
  8033. #define LONGBITS (8*sizeof (CK_OFF_T))
  8034. #define NUMBER 'N'
  8035. #define N_EOT 'E'
  8036.  
  8037. /*
  8038.  Replacement for strchr() and index(), neither of which seem to be universal.
  8039. */
  8040.  
  8041. static char *
  8042. #ifdef CK_ANSIC
  8043. windex(char * s, char c)
  8044. #else
  8045. windex(s,c) char *s, c;
  8046. #endif /* CK_ANSIC */
  8047. /* windex */ {
  8048.     while (*s != NUL && *s != c) s++;
  8049.     if (*s == c) return(s); else return(NULL);
  8050. }
  8051.  
  8052.  
  8053. /*
  8054.  g e t t o k
  8055.  
  8056.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  8057. */
  8058. static char
  8059. gettok() {
  8060.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  8061.  
  8062.     while (isspace(*cp))                /* Skip past leading spaces */
  8063.       cp++;
  8064.  
  8065.     debug(F110,"GETTOK",cp,0);
  8066.  
  8067.     switch (*cp) {
  8068.       case '$':                         /* ??? */
  8069.       case '+':                         /* Add */
  8070.       case '-':                         /* Subtract or Negate */
  8071.       case '@':                         /* Greatest Common Divisor */
  8072.       case '*':                         /* Multiply */
  8073.       case '/':                         /* Divide */
  8074.       case '%':                         /* Modulus */
  8075.       case '<':                         /* Left shift */
  8076.       case '>':                         /* Right shift */
  8077.       case '&':                         /* And */
  8078.       case '|':                         /* Or */
  8079.       case '#':                         /* Exclusive Or */
  8080.       case '~':                         /* Not */
  8081.       case '^':                         /* Exponent */
  8082.       case '!':                         /* Factorial */
  8083.       case '(':                         /* Parens for grouping */
  8084.       case ')': return(*cp++);          /* operator, just return it */
  8085.       case '\n':
  8086.       case '\0': return(N_EOT);         /* End of line, return that */
  8087.     }
  8088. #ifdef COMMENT
  8089. /* This is the original code, which allows only integer numbers. */
  8090.  
  8091.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  8092.         int radix = 10;                 /* Default radix */
  8093.         for (tp = tbuf; isxdigit(*cp); cp++)
  8094.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  8095.         *tp = '\0';                     /* End number */
  8096.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  8097.           case 'h':
  8098.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  8099.           case 'o':
  8100.           case 'q': radix = 8; cp++; break;
  8101.           case 't': radix = 2; cp++; break;
  8102.         }
  8103.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  8104.             int dig;
  8105.             dig = *tp - '0';            /* Convert number */
  8106.             if (dig > 10) dig -= 'a'-'0'-10;
  8107.             if (dig >= radix) {
  8108.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8109.                   printf("?Invalid digit '%c' in number\n",*tp);
  8110.                 xerror = 1;
  8111.                 return(NUMBER);
  8112.             }
  8113.             tokval = radix*tokval + dig;
  8114.         }
  8115.         return(NUMBER);
  8116.     }
  8117.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  8118.       printf("Invalid character '%c' in input\n",*cp);
  8119.     xerror = 1;
  8120.     cp++;
  8121.     return(gettok());
  8122. #else
  8123. /* This code allows non-numbers to be treated as macro names */
  8124.     {
  8125.         int i, x;
  8126.         char * s, * cp1;
  8127.         cp1 = cp;
  8128.         tp = tbuf;
  8129.         for (i = 0; i < 80; i++) {
  8130.             /* Look ahead to next break character */
  8131.             /* pretty much anything that is not in the switch() above. */
  8132.             if (isalpha(*cp) || isdigit(*cp) ||
  8133.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  8134.                 *cp == '[' || *cp == ']' ||
  8135.                 *cp == '{' || *cp == '}'
  8136.                 )
  8137.               tbuf[i] = *cp++;
  8138.             else
  8139.               break;
  8140.         }
  8141.         if (i >= 80) {
  8142.             printf("Too long - \"%s\"\n", cp1);
  8143.             xerror = 1;
  8144.             cp++;
  8145.             return(gettok());
  8146.         }
  8147.         if (xerror) return(NUMBER);
  8148.  
  8149.         tbuf[i] = NUL;
  8150.         s = tbuf;
  8151.         if (!isdigit(tbuf[0])) {
  8152.             char * s2 = NULL;
  8153.             x = mxlook(mactab,tbuf,nmac);
  8154.             debug(F111,"gettok mxlook",tbuf,x);
  8155.             if (x < 0) {
  8156.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  8157.                   printf("Bad number - \"%s\"\n",tbuf);
  8158.                 xerror = 1;
  8159.                 cp++;
  8160.                 return(gettok());
  8161.             }
  8162.             s2 = mactab[x].mval;
  8163.             if (!s2) s2 = "";
  8164.             if (*s2) s = s2;
  8165.         }
  8166. #ifdef CKFLOAT
  8167.         x = isfloat(s,0);
  8168. #else
  8169.         x = chknum(s);
  8170. #endif /* CKFLOAT */
  8171.         if (x > 0) {
  8172.             tokval = ckatofs(s);
  8173.         } else {
  8174.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8175.               printf("Bad number - \"%s\"\n",tbuf);
  8176.             xerror = 1;
  8177.             cp++;
  8178.             return(gettok());
  8179.         }
  8180.         return(NUMBER);
  8181.     }
  8182. #endif /* COMMENT */
  8183. }
  8184.  
  8185. static CK_OFF_T
  8186. #ifdef CK_ANSIC
  8187. expon(CK_OFF_T x, CK_OFF_T y)
  8188. #else
  8189. expon(x,y) CK_OFF_T x,y;
  8190. #endif /* CK_ANSIC */
  8191. /* expon */ {
  8192.     CK_OFF_T result = 1;
  8193.     int sign = 1;
  8194.     if (y < 0) return(0);
  8195.     if (x < 0) {
  8196.         x = -x;
  8197.         if (y & 1) sign = -1;
  8198.     }
  8199.     while (y != 0) {
  8200.         if (y & 1) result *= x;
  8201.         y >>= 1;
  8202.         if (y != 0) x *= x;
  8203.   }
  8204.   return(result * sign);
  8205. }
  8206.  
  8207. /*
  8208.  * factor ::= simple | simple ^ factor
  8209.  *
  8210.  */
  8211. static VOID
  8212. factor() {
  8213.     CK_OFF_T oldval;
  8214.     simple();
  8215.     if (curtok == '^') {
  8216.         oldval = expval;
  8217.         curtok = gettok();
  8218.         factor();
  8219.         expval = expon(oldval,expval);
  8220.     }
  8221. }
  8222.  
  8223. /*
  8224.  * termp ::= NULL | {*,/,%,&} factor termp
  8225.  *
  8226.  */
  8227. static VOID
  8228. termp() {
  8229.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  8230.         CK_OFF_T oldval;
  8231.         char op;
  8232.         op = curtok;
  8233.         curtok = gettok();              /* skip past operator */
  8234.         oldval = expval;
  8235.         factor();
  8236.         switch(op) {
  8237.           case '*': expval = oldval * expval; break;
  8238.           case '/':
  8239.           case '%':
  8240.             if (expval == 0) {
  8241.                 if (!x_ifnum)
  8242.                   printf("?Divide by zero\n");
  8243.                 xerror = 1;
  8244.                 divbyzero = 1;
  8245.                 expval = -1;
  8246.             } else
  8247.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  8248.             break;
  8249.           case '&':
  8250.             expval = oldval & expval; break;
  8251.         }
  8252.     }
  8253. }
  8254.  
  8255. static CK_OFF_T
  8256. #ifdef CK_ANSIC
  8257. fact(CK_OFF_T x)
  8258. #else
  8259. fact(x) CK_OFF_T x;
  8260. #endif /* CK_ANSIC */
  8261. /* fact */ {                            /* factorial */
  8262.     CK_OFF_T result = 1;
  8263.     while (x > 1)
  8264.       result *= x--;
  8265.     return(result);
  8266. }
  8267.  
  8268. /*
  8269.  * term ::= factor termp
  8270.  *
  8271.  */
  8272. static VOID
  8273. term() {
  8274.     factor();
  8275.     termp();
  8276. }
  8277.  
  8278. static CK_OFF_T
  8279. #ifdef CK_ANSIC
  8280. gcd(CK_OFF_T x, CK_OFF_T y)
  8281. #else
  8282. gcd(x,y) CK_OFF_T x,y;
  8283. #endif /* CK_ANSIC */
  8284. /* gcd */ {                             /* Greatest Common Divisor */
  8285.     int nshift = 0;
  8286.     if (x < 0) x = -x;
  8287.     if (y < 0) y = -y;                  /* validate arguments */
  8288.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8289.  
  8290.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8291.         nshift++;
  8292.         x >>= 1;
  8293.         y >>= 1;
  8294.     }
  8295.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8296.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8297.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8298.         if (x < y) {                    /* force x to be larger */
  8299.             CK_OFF_T t;
  8300.             t = x;
  8301.             x = y;
  8302.             y = t;
  8303.         }
  8304.         x -= y;
  8305.     }
  8306.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8307.     else return((CK_OFF_T) 1 << nshift);    /* else gcd is 1 */
  8308. }
  8309.  
  8310. /*
  8311.  * exprp ::= NULL | {+,-,|,...} term exprp
  8312.  *
  8313.  */
  8314. static VOID
  8315. exprp() {
  8316.     while (windex("+-|<>#@",curtok) != NULL) {
  8317.         CK_OFF_T oldval;
  8318.         char op;
  8319.         op = curtok;
  8320.         curtok = gettok();              /* skip past operator */
  8321.         oldval = expval;
  8322.         term();
  8323.         switch(op) {
  8324.           case '+' : expval = oldval + expval; break;
  8325.           case '-' : expval = oldval - expval; break;
  8326.           case '|' : expval = oldval | expval; break;
  8327.           case '#' : expval = oldval ^ expval; break;
  8328.           case '@' : expval = gcd(oldval,expval); break;
  8329.           case '<' : expval = oldval << expval; break;
  8330.           case '>' : expval = oldval >> expval; break;
  8331.         }
  8332.     }
  8333. }
  8334.  
  8335. /*
  8336.  * expr ::= term exprp
  8337.  *
  8338.  */
  8339. static VOID
  8340. expr() {
  8341.     term();
  8342.     exprp();
  8343. }
  8344.  
  8345. static CK_OFF_T
  8346. xparse() {
  8347.     curtok = gettok();
  8348.     expr();
  8349. #ifdef COMMENT
  8350.     if (curtok == '$') {
  8351.         curtok = gettok();
  8352.         if (curtok != NUMBER) {
  8353.             if (cmdlvl == 0 && !x_ifnum)
  8354.               printf("?Illegal radix\n");
  8355.             xerror = 1;
  8356.             return(0);
  8357.         }
  8358.         curtok = gettok();
  8359.     }
  8360. #endif /* COMMENT */
  8361.     if (curtok != N_EOT) {
  8362.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8363.           printf("?Extra characters after expression\n");
  8364.         xerror = 1;
  8365.     }
  8366.     return(expval);
  8367. }
  8368.  
  8369. char *                                  /* Silent front end for evala() */
  8370. evalx(s) char *s; {
  8371.     char * p;
  8372.     int t;
  8373.     t = x_ifnum;
  8374.     x_ifnum = 1;
  8375.     p = evala(s);
  8376.     x_ifnum = t;
  8377.     return(p);
  8378. }
  8379.  
  8380. char *
  8381. evala(s) char *s; {
  8382.     CK_OFF_T v;                /* Numeric value */
  8383.     if (!s) return("");
  8384.     xerror = 0;                         /* Start out with no error */
  8385.     divbyzero = 0;
  8386.     cp = s;                             /* Make the argument global */
  8387.     v = xparse();                       /* Parse the string */
  8388.     return(xerror ? "" : ckfstoa(v));    /* Return empty string on error */
  8389. }
  8390.  
  8391. /*
  8392.  * simplest ::= NUMBER | ( expr )
  8393.  *
  8394.  */
  8395. static VOID
  8396. simplest() {
  8397.     char * p;
  8398.     p = cp;
  8399.     if (curtok == NUMBER)
  8400.       expval = tokval;
  8401.     else if (curtok == '(') {
  8402.         curtok = gettok();              /* skip over paren */
  8403.         expr();
  8404.         if (curtok != ')') {
  8405.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8406.               printf("?Missing right parenthesis\n");
  8407.             xerror = 1;
  8408.         }
  8409.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8410.  
  8411.     } else {
  8412.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8413.           printf("?Operator unexpected\n");
  8414.         xerror = 1;
  8415.     }
  8416.     curtok = gettok();
  8417. }
  8418.  
  8419. /*
  8420.  * simpler ::= simplest | simplest !
  8421.  *
  8422.  */
  8423. static VOID
  8424. simpler() {
  8425.     simplest();
  8426.     if (curtok == '!') {
  8427.         curtok = gettok();
  8428.         expval = fact(expval);
  8429.     }
  8430. }
  8431.  
  8432. /*
  8433.  * simple ::= {-,~,!} simpler | simpler
  8434.  *
  8435.  */
  8436.  
  8437. static VOID
  8438. simple() {
  8439.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8440.         int op = curtok;
  8441.         curtok = gettok();              /* skip over - sign */
  8442.         simpler();                      /* parse the factor again */
  8443.         if (op != '+')
  8444.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8445.     } else simpler();
  8446. }
  8447.  
  8448. /*  D C L A R R A Y  --  Declare an array  */
  8449. /*
  8450.   Call with:
  8451.    char a = single character designator for the array, e.g. "a".
  8452.    int  n = size of array.
  8453.   Returns:
  8454.    0 or greater on success, having created the requested array with
  8455.      with n+1 elements, 0..n.  If an array of the same name existed
  8456.      previously, it is destroyed.  The new array has all its elements
  8457.      initialized to NULL pointers.
  8458.   -1 on failure (because 'a' out of range or malloc failure).
  8459. */
  8460. int
  8461. #ifdef CK_ANSIC
  8462. dclarray(char a, int n)
  8463. #else
  8464. dclarray(a,n) char a; int n;
  8465. #endif /* CK_ANSIC */
  8466. /* dclarray */ {
  8467.     char c, **p; int i, n2, rc;
  8468.  
  8469.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8470.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8471.       return(-1);
  8472.  
  8473.     if (n < 0)                          /* Check arg */
  8474.       return(-1);
  8475.     if (n+1 < 0)                        /* MAXINT+1 wraps around */
  8476.       return(-1);
  8477.  
  8478.     c = a;
  8479.     a -= ARRAYBASE;                     /* Convert name to number */
  8480.     rc = a;
  8481.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8482.         if (a_link[a] > -1) {           /* Is it a link? */
  8483.             if (n == 0) {               /* If we're just deleting it */
  8484.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8485.                 a_dim[a] = 0;
  8486.                 a_link[a] = -1;
  8487.                 return(0);
  8488.             }                           /* Not deleting */
  8489.             a = a_link[a];              /* Switch to linked-to array */
  8490.         }
  8491.         n2 = a_dim[a];                  /* Real array */
  8492.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8493.             if (p[i]) {
  8494.                 free(p[i]);
  8495.                 p[i] = NULL;
  8496.             }
  8497.         }
  8498.         free((char *)a_ptr[a]);         /* Then the element list */
  8499.         if (n == 0) {                   /* If undeclaring this array... */
  8500.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8501.                 if (i != a && a_link[i] == a) {     /* Find them */
  8502.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8503.                     a_dim[i] = 0;
  8504.                     a_link[i] = -1;
  8505.                 }
  8506.             }
  8507.         }
  8508.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8509.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8510.         a_link[a] = -1;                 /* Unset link word */
  8511.         if (n == 0)
  8512.           return(0);                    /* If dimension 0, just deallocate. */
  8513.     }
  8514.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8515.     if (p == NULL) return(-1);          /* Check */
  8516.     a_ptr[a] = p;                       /* Save pointer to member list */
  8517.     a_dim[a] = n;                       /* Save dimension */
  8518.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8519.       p[i] = NULL;
  8520.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8521.         if (i != a && a_link[i] == a) { /* Find and update them */
  8522.             a_ptr[i] = p;
  8523.             a_dim[i] = n;
  8524.         }
  8525.     }
  8526.     return(rc);
  8527. }
  8528.  
  8529. /*  X A R R A Y  -- Convert array name to array index  */
  8530.  
  8531. int
  8532. xarray(s) char * s; {
  8533.     char buf[8];
  8534.     int x;
  8535.     char c;
  8536.  
  8537.     if (!s) s = "";
  8538.     debug(F110,"xarray",s,0);
  8539.     if (!*s)
  8540.       return(-1);
  8541.     x = strlen(s);
  8542.  
  8543.     buf[0] = NUL;
  8544.     buf[1] = NUL;
  8545.     buf[2] = s[0];
  8546.     buf[3] = (x > 0) ? s[1] : NUL;
  8547.     buf[4] = (x > 1) ? s[2] : NUL;
  8548.     buf[5] = (x > 2) ? s[3] : NUL;
  8549.     buf[6] = NUL;
  8550.     s = buf+2;
  8551.     if (*s == '&') {
  8552.         buf[1] = CMDQ;
  8553.         s--;
  8554.     } else if (*s != CMDQ) {
  8555.         buf[0] = CMDQ;
  8556.         buf[1] = '&';
  8557.         s = buf;
  8558.     }
  8559.     c = *(s+2);
  8560.     if (isupper(c))
  8561.       c = tolower(c);
  8562.     if (c == '@')
  8563.       c = 96;
  8564.     x = (int)c - ARRAYBASE;
  8565.     if (*(s+3) == '[')
  8566.       *(s+3) = NUL;
  8567.     return((x < 0 || x > 'z' - ARRAYBASE || *(s+3)) ? -1 : x);
  8568. }
  8569.  
  8570. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8571.  
  8572. /*
  8573.   Call with s = array reference, plus two pointers to ints.
  8574.   Returns -1 on error, or array index, with the two ints set as follows:
  8575.    \&a[]     -1, -1
  8576.    \&a[3]     3, -1
  8577.    \&a[3:17]  3, 17
  8578.   The array need not be declared -- this routine is just for parsing.
  8579. */
  8580. int
  8581. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8582.     int i, x, y, range[2];
  8583.     char buf[256], * p, * q;
  8584.     char * tmp = NULL;
  8585.  
  8586.     *lo = -1;                           /* Default bounds */
  8587.     *hi = -1;
  8588.  
  8589.     if (!s) s = "";                     /* Defense de null args */
  8590.     if (!*s)
  8591.       return(-1);
  8592.  
  8593.     x = xarray(s);                      /* Check basic structure */
  8594.     debug(F111,"arraybounds xarray",s,x);
  8595.  
  8596.     if (x < 0)                          /* Not OK, fail. */
  8597.       return(-1);
  8598.     range[0] = -1;                      /* It's OK -- get contents */
  8599.     range[1] = -1;                      /* of subscript brackets */
  8600.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8601.     s = tmp;
  8602.     p = s;
  8603.     for (p = s, q = NULL; *p; p++) {    /* First find the brackets */
  8604.         if (*p == '[') {
  8605.             q = p+1;
  8606.         } else if (*p == ']')
  8607.           break;
  8608.     }
  8609.     if (q && *p == ']') {               /* If we have brackets... */
  8610.         int quitnow = 0;
  8611.         for (i = 0; i < 2 && !quitnow; i++) { /* Loop thru their contents */
  8612.             for (p = q; *p; p++) {
  8613.                 if ((i == 0 && *p == ':') || *p == ']') {
  8614.                     if (*p == ']')
  8615.                       quitnow = 1;
  8616.                     *p = NUL;
  8617.                     if (*q) {           /* We have something */
  8618.                         y = 255;        /* Expand variables, etc. */
  8619.                         s = buf;
  8620.                         zzstring(q,&s,&y);
  8621.                         s = evalx(buf); /* Evaluate it arithmetically */
  8622.                         if (s) if (*s)
  8623.                           ckstrncpy(buf,s,256);
  8624.                         if (!chknum(buf)) { /* Did we get a number? */
  8625.                             makestr(&tmp,NULL); /* No, fail. */
  8626.                             return(-1);
  8627.                         }
  8628.                         q = (i == 0) ? p+1 : NULL; /* Point to next if any */
  8629.                         range[i] = atoi(buf); /* Set this one */
  8630.                     }
  8631.                     break;
  8632.                 }
  8633.             }
  8634.         }
  8635.     }
  8636.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8637.     *lo = range[0];                     /* Return what we got */
  8638.     *hi = range[1];
  8639.     debug(F101,"arraybounds lo","",*lo);
  8640.     debug(F101,"arraybounds hi","",*hi);
  8641.     return(x);
  8642. }
  8643.  
  8644. /*  A R R A Y N A M  --  Parse an array name  */
  8645.  
  8646. /*
  8647.   Call with pointer to string that starts with the array reference.
  8648.   String may begin with either \& or just &.
  8649.   On success,
  8650.     Returns letter ID (always lowercase) in argument c,
  8651.       which can also be accent grave (` = 96; '@' is converted to grave);
  8652.     Dimension or subscript in argument n;
  8653.     IMPORTANT: These arguments must be provided by the caller as addresses
  8654.     of ints (not chars), for example:
  8655.       char *s; int x, y;
  8656.       arraynam(s,&x,&y);
  8657.   On failure, returns a negative number, with args n and c set to zero.
  8658. */
  8659. int
  8660. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8661.     int i, y, pp, len;
  8662.     char x;
  8663.     char *s, *p, *sx, *vnp;
  8664.     /* On stack to allow for recursive calls... */
  8665.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8666.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8667.     char sxbuf[16];                     /* Evaluated subscript */
  8668.  
  8669.     *c = *n = 0;                        /* Initialize return values */
  8670.     len = strlen(ss);
  8671.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8672.         if (ss[i] == '[') {
  8673.             pp++;
  8674.         } else if (ss[i] == ']') {
  8675.             if (--pp == 0)
  8676.               break;
  8677.         }
  8678.     }
  8679.     if (i > ARRAYREFLEN) {
  8680.         printf("?Array reference too long - %s\n",ss);
  8681.         return(-9);
  8682.     }
  8683.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8684.     vnp = vnbuf;
  8685.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8686.     if (*vnp != '&') {
  8687.         printf("?Not an array - %s\n",vnbuf);
  8688.         return(-9);
  8689.     }
  8690.     x = *(vnp + 1);                     /* Fold case of array name */
  8691.  
  8692.     /* We don't use isupper & tolower here on purpose because these */
  8693.     /* would produce undesired effects with accented letters. */
  8694.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8695.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8696.         if (msgflg) {
  8697.             printf("?Invalid format for array name - %s\n",vnbuf);
  8698.             return(-9);
  8699.         } else
  8700.           return(-2);
  8701.     }
  8702.     *c = x;                             /* Return the array name */
  8703.     s = vnp+3;                          /* Get dimension */
  8704.     p = ssbuf;
  8705.     pp = 1;                             /* Bracket counter */
  8706.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8707.         if (*s == '[') pp++;
  8708.         if (*s == ']' && --pp == 0) break;
  8709.         *p++ = *s++;
  8710.     }
  8711.     if (*s != ']') {
  8712.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8713.         return(-9);
  8714.     }
  8715.     p--;                                /* Trim whitespace from end */
  8716.     while (*p == SP || *p == HT)
  8717.       p--;
  8718.     p++;
  8719.     *p = NUL;                           /* Terminate subscript with null */
  8720.     p = ssbuf;                          /* Point to beginning of subscript */
  8721.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8722.       p++;
  8723.     sx = sxbuf;                         /* Where to put expanded subscript */
  8724.     y = 16;
  8725.     zzstring(p,&sx,&y);                 /* Convert variables, etc. */
  8726.     sx = sxbuf;
  8727.     while (*sx == SP) sx++;
  8728.     /* debug(F110,"arraynam sx","",sx); */
  8729.     if (!*sx) {                         /* Empty brackets... */
  8730.         *n = -17;                       /* (Secret code :-) */
  8731.         return(-2);
  8732.     }
  8733.     p = evala(sx);                      /* Run it thru \fneval()... */
  8734.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8735.  
  8736.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8737.         if (msgflg) {
  8738.             printf("?Array dimension or subscript missing or not numeric\n");
  8739.             return(-9);
  8740.         } else
  8741.           return(-2);
  8742.     }
  8743.     if ((y = atoi(sxbuf)) < 0) {
  8744.         if (cmflgs == 0) printf("\n");
  8745.         if (msgflg) {
  8746.             printf("?Array dimension or subscript not positive or zero\n");
  8747.             return(-9);
  8748.         } else
  8749.           return(-2);
  8750.     }
  8751.     *n = y;                             /* Return the subscript or dimension */
  8752.     return(0);
  8753. }
  8754.  
  8755. int
  8756. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8757.     int x;                              /* and if subscript is in range */
  8758.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8759.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8760. #ifdef COMMENT
  8761.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8762.       return(0);
  8763. #endif /* COMMENT */
  8764.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8765.       return(-2);
  8766.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8767.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8768.     return(a_dim[x]);                   /* All ok, return dimension */
  8769. }
  8770.  
  8771. #ifdef COMMENT                          /* This isn't used. */
  8772. char *
  8773. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8774.     int x; char **p;                    /* (possibly NULL) */
  8775.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8776.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8777.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8778.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8779.       return(NULL);
  8780.     if (i > a_dim[x])                   /* Subscript out of range. */
  8781.       return(NULL);
  8782.     return(p[i]);                       /* All ok, return pointer to value. */
  8783. }
  8784. #endif /* COMMENT */
  8785.  
  8786. /*
  8787.   pusharray() is called when an array name is included in a LOCAL statement.
  8788.   It moves the pointers from the global definition to the stack, and removes
  8789.   the global definition.  Later, if the same array is declared in the local
  8790.   context, it occupies the global definition in the normal way.  But when
  8791.   popclvl() is called, it replaces the global definition with the one saved
  8792.   here.  The "secret code" is used to indicate to popclv() that it should
  8793.   remove the global array when popping through this level -- otherwise if a
  8794.   local array were declared that had no counterpart at any higher level, it
  8795.   would never be deleted.  This allows Algol-like inheritance to work both
  8796.   on the way down and on the way back up.
  8797. */
  8798. int
  8799. pusharray(x,z) int x, z; {
  8800.     int y;
  8801.     debug(F000,"pusharray x","",x);
  8802.     debug(F101,"pusharray z","",z);
  8803.     y = chkarray(x,z);
  8804.     debug(F101,"pusharray y","",y);
  8805.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8806.     if (x < 0 || x > 27)
  8807.       return(-1);
  8808.     if (y < 0) {
  8809.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8810.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8811.     } else {
  8812.         aa_ptr[cmdlvl][x] = a_ptr[x];
  8813.         aa_dim[cmdlvl][x] = y;
  8814.     }
  8815.     a_ptr[x] = (char **) NULL;
  8816.     a_dim[x] = 0;
  8817.     return(0);
  8818. }
  8819.  
  8820. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  8821. /*
  8822.  Call with:
  8823.    s  = pointer to candidate variable name or array reference.
  8824.    *c = address of integer in which to return variable ID.
  8825.    *i = address of integer in which to return array subscript.
  8826.  Returns:
  8827.    -2:  syntax error in variable name or array reference.
  8828.     1:  successful parse of a simple variable, with ID in c.
  8829.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  8830. */
  8831. int
  8832. parsevar(s,c,i) char *s; int *c, *i; {
  8833.     char *p;
  8834.     int x,y,z;
  8835.  
  8836.     p = s;
  8837.     if (*s == CMDQ) s++;                /* Point after backslash */
  8838.  
  8839.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  8840.         printf("?Not a variable name - %s\n",p);
  8841.         return(-9);
  8842.     }
  8843.     if ((int)strlen(s) < 2) {
  8844.         printf("?Incomplete variable name - %s\n",p);
  8845.         return(-9);
  8846.     }
  8847.     if (*s == '%' && *(s+2) != '\0') {
  8848.         printf("?Only one character after '%%' in variable name, please\n");
  8849.         return(-9);
  8850.     }
  8851.     if (*s == '&' && *(s+2) != '[') {
  8852.         printf("?Array subscript expected - %s\n",p);
  8853.         return(-9);
  8854.     }
  8855.     if (*s == '%') {                    /* Simple variable. */
  8856.         y = *(s+1);                     /* Get variable ID letter/char */
  8857.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  8858.         *c = y;                         /* Set the return values. */
  8859.         *i = -1;                        /* No array subscript. */
  8860.         return(1);                      /* Return 1 = simple variable */
  8861.     }
  8862.     if (*s == '&') {                    /* Array reference. */
  8863.         y = arraynam(s,&x,&z);          /* Go parse it. */
  8864.         debug(F101,"parsevar arraynam","",y);
  8865.         if ((y) < 0) {
  8866.             if (y == -2)
  8867.               return(pusharray(x,z));
  8868.             if (y != -9)
  8869.               printf("?Invalid array reference - %s\n",p);
  8870.             return(-9);
  8871.         }
  8872.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  8873.             printf("?Array not declared or subscript out of range\n");
  8874.             return(-9);
  8875.         }
  8876.         *c = x;                         /* Return array letter */
  8877.         *i = z;                         /* and subscript. */
  8878.         return(2);
  8879.     }
  8880.     return(-2);                         /* None of the above. */
  8881. }
  8882.  
  8883.  
  8884. #define VALN 32
  8885.  
  8886. /* Get the numeric value of a variable */
  8887. /*
  8888.   Call with pointer to variable name, pointer to int for return value.
  8889.   Returns:
  8890.     0 on success with second arg containing the value.
  8891.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  8892. */
  8893. int
  8894. varval(s,v) char *s; CK_OFF_T *v; {
  8895.     char valbuf[VALN+1];                /* s is pointer to variable name */
  8896.     char name[256];
  8897.     char *p;
  8898.     int y;
  8899.  
  8900.     if (*s != CMDQ) {                   /* Handle macro names too */
  8901.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  8902.         s = name;
  8903.     }
  8904.     p = valbuf;                         /* Expand variable into valbuf. */
  8905.     y = VALN;
  8906.     if (zzstring(s,&p,&y) < 0) return(-1);
  8907.     p = valbuf;                         /* Make sure value is numeric  */
  8908.     if (!*p) {                          /* Be nice -- let an undefined */
  8909.         valbuf[0] = '0';                /* variable be treated as 0.   */
  8910.         valbuf[1] = NUL;
  8911.     }
  8912.     if (chknum(p)) {                    /* Convert numeric string to int */
  8913.         *v = ckatofs(p);        /* OK */
  8914.     } else {                            /* Not OK */
  8915.         p = evala(p);                   /* Maybe it's an expression */
  8916.         if (!chknum(p))                 /* Did it evaluate? */
  8917.           return(-1);                   /* No, failure. */
  8918.         else                            /* Yes, */
  8919.           *v = ckatofs(p);        /* success */
  8920.     }
  8921.     return(0);
  8922. }
  8923.  
  8924. /* Increment or decrement a variable */
  8925. /* Returns -1 on failure, 0 on success */
  8926.  
  8927. int
  8928. incvar(s,x,z) char *s; CK_OFF_T x; int z; {  /* Increment a numeric variable */
  8929.     CK_OFF_T n;                /* s is pointer to variable name */
  8930.                                         /* x is amount to increment by */
  8931.                                         /* z != 0 means add */
  8932.                                         /* z = 0 means subtract */
  8933.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  8934.       return(-1);
  8935.     if (z)                              /* Increment it by the given amount */
  8936.       n += x;
  8937.     else                                /* or decrement as requested. */
  8938.       n -= x;
  8939.     addmac(s,ckfstoa(n));        /* Replace old variable */
  8940.     return(0);
  8941. }
  8942.  
  8943. /* D O D O  --  Do a macro */
  8944.  
  8945. /*
  8946.   Call with x = macro table index, s = pointer to arguments.
  8947.   Returns 0 on failure, 1 on success.
  8948. */
  8949.  
  8950. int
  8951. dodo(x,s,flags) int x; char *s; int flags; {
  8952.     int y;
  8953.     extern int tra_asg, tra_cmd; int tra_tmp;
  8954. #ifndef NOLOCAL
  8955. #ifdef OS2
  8956.     extern int term_io;
  8957.     int term_io_sav = term_io;
  8958. #endif /* OS2 */
  8959. #endif /* NOLOCAL */
  8960.  
  8961.     if (x < 0)                          /* It can happen! */
  8962.       return(-1);
  8963.  
  8964.     tra_tmp = tra_asg;
  8965.  
  8966.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  8967.         debug(F101,"dodo maclvl too deep","",maclvl);
  8968.         --maclvl;
  8969.         printf("Macros nested too deeply\n");
  8970.         return(0);
  8971.     }
  8972.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  8973.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  8974.  
  8975. #ifdef COMMENT
  8976.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  8977. #endif /* COMMENT */
  8978.  
  8979.     cmdlvl++;                           /* Entering a new command level */
  8980.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  8981.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  8982.         cmdlvl--;
  8983.         printf("?TAKE files and DO commands nested too deeply\n");
  8984.         return(0);
  8985.     }
  8986. #ifdef DEBUG
  8987.     if (deblog) {
  8988.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  8989.         debug(F010,"CMD ->",s,0);
  8990.     }
  8991. #endif /* DEBUG */
  8992.  
  8993. #ifdef VMS
  8994.     conres();                           /* So Ctrl-C, etc, will work. */
  8995. #endif /* VMS */
  8996. #ifndef NOLOCAL
  8997. #ifdef OS2
  8998.     term_io = 0;                        /* Disable terminal emulator I/O */
  8999. #endif /* OS2 */
  9000. #endif /* NOLOCAL */
  9001.     ifcmd[cmdlvl] = 0;
  9002.     iftest[cmdlvl] = 0;
  9003.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  9004.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  9005.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  9006.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  9007.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  9008.     xquiet[cmdlvl] = quiet;
  9009.     xcmdsrc = CMD_MD;
  9010.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  9011.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  9012.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  9013.  
  9014.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  9015.  
  9016.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  9017.         free(mrval[maclvl]);
  9018.         mrval[maclvl] = NULL;
  9019.     }
  9020.  
  9021.     /* Clear old %0..%9 arguments */
  9022.  
  9023.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  9024.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  9025.     varnam[0] = '%';
  9026.     varnam[2] = '\0';
  9027.     tra_asg = 0;
  9028.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  9029.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  9030.             varnam[1] = (char) (y + '0'); /* we have to... */
  9031.             delmac(varnam,0);
  9032.         }
  9033.     }
  9034.     tra_asg = tra_tmp;
  9035.  
  9036. /* Assign the new args one word per arg, allowing braces to group words */
  9037.  
  9038.     xwords(s,MAXARGLIST,NULL,0);
  9039.  
  9040. #ifndef NOLOCAL
  9041. #ifdef OS2
  9042.     term_io = term_io_sav;
  9043. #endif /* OS2 */
  9044. #endif /* NOLOCAL */
  9045.     if (tra_cmd)
  9046.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  9047.     return(1);
  9048. }
  9049.  
  9050. /* Insert "literal" quote around each comma-separated command to prevent */
  9051. /* its premature expansion.  Only do this if object command is surrounded */
  9052. /* by braces. */
  9053.  
  9054. static char* flit = "\\flit(";
  9055.  
  9056. int
  9057. litcmd(src,dest,n) char **src, **dest; int n; {
  9058.     int bc = 0, pp = 0;
  9059.     char c, *s, *lp, *ss;
  9060.  
  9061.     s = *src;
  9062.     lp = *dest;
  9063.  
  9064.     debug(F010,"litcmd",s,0);
  9065.  
  9066.     while (*s == SP) s++;               /* Strip extra leading spaces */
  9067.  
  9068.     if (*s == '{') {                    /* Starts with brace */
  9069.         pp = 0;                         /* Paren counter */
  9070.         bc = 1;                         /* Count leading brace */
  9071.         *lp++ = *s++;                   /* Copy it */
  9072.         if (--n < 1) return(-1);        /* Check space */
  9073.         while (*s == SP) s++;           /* Strip interior leading spaces */
  9074.         ss = flit;                      /* Point to "\flit(" */
  9075.         while ((*lp++ = *ss++))         /* Copy it */
  9076.           if (--n < 1)                  /* and check space */
  9077.             return(-1);
  9078.         lp--;                           /* Back up over null */
  9079.  
  9080.         while (*s) {                    /* Go thru rest of text */
  9081.             c = *s;
  9082.             if (c == '{') bc++;         /* Count brackets */
  9083.             if (c == '(') pp++;         /* and parens */
  9084.             if (c == ')') {             /* Right parenthesis. */
  9085.                 pp--;                   /* Count it. */
  9086.                 if (pp < 0) {           /* An unbalanced right paren... */
  9087. #ifdef COMMENT
  9088. /*
  9089.   The problem here is that "\{" appears to be a quoted brace and therefore
  9090.   isn't counted; then the "}" matches an earlier opening brace, causing
  9091.   (e.g.) truncation of macros by getncm().
  9092. */
  9093.                     if (n < 5)          /* Out of space in dest buffer? */
  9094.                       return(-1);       /* If so, give up. */
  9095.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9096.                     *lp++ = '}';        /* premature termination of */
  9097.                     *lp++ = '4';        /* \flit(...) */
  9098.                     *lp++ = '1';
  9099.                     *lp++ = '}';
  9100.                     n -= 5;
  9101. #else
  9102. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  9103.                     if (n < 4)          /* Out of space in dest buffer? */
  9104.                       return(-1);       /* If so, give up. */
  9105.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  9106.                     *lp++ = '0';        /* premature termination of */
  9107.                     *lp++ = '4';        /* \flit(...) */
  9108.                     *lp++ = '1';
  9109.                     n -= 4;
  9110. #endif /* COMMENT */
  9111.                     pp++;               /* Uncount it. */
  9112.                     s++;
  9113.                     continue;
  9114.                 }
  9115.             }
  9116.             if (c == '}') {             /* Closing brace. */
  9117.                 if (--bc == 0) {        /* Final one? */
  9118.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  9119.                     if (--n < 1) return(-1);
  9120.                     *lp++ = c;
  9121.                     if (--n < 1) return(-1);
  9122.                     s++;
  9123.                     break;
  9124.                 }
  9125.             }
  9126.             *lp++ = c;                  /* General case */
  9127.             if (--n < 1) return(-1);
  9128.             s++;
  9129.         }
  9130.         *lp = NUL;
  9131.     } else {                            /* No brackets around, */
  9132.         while ((*lp++ = *s++))          /* just copy. */
  9133.           if (--n < 1)
  9134.             return(-1);
  9135.         lp--;
  9136.     }
  9137.     *src = s;                           /* Return updated source */
  9138.     *dest = lp;                         /* and destination pointers */
  9139.     if (bc)                             /* Fail if braces unbalanced */
  9140.       return(-1);
  9141.     else                                /* Otherwise succeed. */
  9142.       return(0);
  9143. }
  9144. #endif /* NOSPL */
  9145.  
  9146. /* Functions moved here from ckuusr.c to even out the module sizes... */
  9147.  
  9148. /*
  9149.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  9150.   Pointers to each word go into the array list[].
  9151.   max is the maximum number of words (pointers).
  9152.   If list is NULL, then they are added to the macro table.
  9153.   flag = 0 means the last field is to be one word, like all the other fields,
  9154.          so anything after it is discarded.
  9155.   flag = 1 means the last field extends to the end of the string, even if
  9156.          there are lots of words left, so the last field contains the
  9157.          remainder of the string.
  9158. */
  9159. VOID
  9160. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  9161.     char *p;
  9162.     int b, i, k, q, y, z;
  9163. #ifndef NOSPL
  9164.     int macro;
  9165.     macro = (list == NULL);
  9166.     debug(F010,"xwords",s,0);
  9167. #endif /* NOSPL */
  9168.  
  9169. #ifdef XWORDSDEBUG
  9170.     printf("XWORDS string=%s\n",s);
  9171.     printf("XWORDS max=%d\n",max);
  9172. #endif /* XWORDSDEBUG */
  9173.     p = s;                              /* Pointer to beginning of string */
  9174.     q = 0;                              /* Flag for doublequote removal */
  9175.     b = 0;                              /* Flag for outer brace removal */
  9176.     k = 0;                              /* Flag for in-word */
  9177.     y = 0;                              /* Brace nesting level */
  9178.     z = 0;                              /* "Word" counter, 0 thru max */
  9179.  
  9180.     if (list)
  9181.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  9182.         list[i] = NULL;
  9183.  
  9184.     if (flag) max--;
  9185.  
  9186.     while (1) {                         /* Go thru word list */
  9187.         if (!s || (*s == '\0')) {       /* No more characters? */
  9188.             if (k != 0) {               /* Was I in a word? */
  9189.                 if (z == max) break;    /* Yes, only go up to max. */
  9190.                 z++;                    /* Count this word. */
  9191. #ifdef XWORDSDEBUG
  9192.                 printf("1 z++ = %d\n", z);
  9193. #endif /* XWORDSDEBUG */
  9194. #ifndef NOSPL
  9195.                 if (macro) {            /* Doing macro args */
  9196.                     if (z < 10) {
  9197.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  9198.                         addmac(varnam,p);
  9199.                     }
  9200.                     if (z <= max) {
  9201. #ifdef COMMENT
  9202.                         if (maclvl < 0)
  9203.                           addmac(varnam,p);
  9204.                         else
  9205. #endif /* COMMENT */
  9206.                           makestr(&(m_xarg[maclvl][z]),p);
  9207.                     }
  9208.                 } else {                /* Not doing macro args */
  9209. #endif /* NOSPL */
  9210.                     list[z] = p;        /* Assign pointer. */
  9211. #ifdef XWORDSDEBUG
  9212.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  9213. #endif /* XWORDSDEBUG */
  9214. #ifndef NOSPL
  9215.                 }
  9216. #endif /* NOSPL */
  9217.                 break;                  /* And get out. */
  9218.             } else break;               /* Was not in a word */
  9219.         }
  9220.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  9221.             s++;
  9222.             continue;
  9223.         } else if (q == 0 && *s == '{') { /* An opening brace */
  9224.             if (k == 0 && y == 0) {     /* If leading brace */
  9225.                 p = s+1;                /* point past it */
  9226.                 b = 1;                  /* and flag that we did this */
  9227.             }
  9228.             k = 1;                      /* Flag that we're in a word */
  9229.             y++;                        /* Count the brace. */
  9230.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  9231.             y--;                        /* Count it. */
  9232.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  9233.                 char c;
  9234.                 c = *(s+1);
  9235.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9236.                     *s = SP;            /* change it to a space */
  9237.                     b = 0;              /* and we're not in braces any more */
  9238.                 }
  9239.             }
  9240. #ifdef DOUBLEQUOTING
  9241.         /* Opening doublequote */
  9242.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9243.             y++;
  9244.             p = s+1;                    /* point past it */
  9245.             q = 1;                      /* and flag that we did this */
  9246.             k = 1;                      /* Flag that we're in a word */
  9247.         /* Closing double quote */
  9248.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9249.             char c;
  9250.             c = *(s+1);
  9251.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9252.                 y--;
  9253.                 *s = SP;                /* change it to a space */
  9254.                 q = 0;                  /* and we're not in quotes any more */
  9255.             }
  9256. #endif /* DOUBLEQUOTING */
  9257.  
  9258.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9259.             if (k == 0) {               /* If we weren't in a word before, */
  9260.                 p = s;                  /* Mark the beginning */
  9261.                 if (flag && z == max) { /* Want last word to be remainder? */
  9262.                     z++;
  9263. #ifdef XWORDSDEBUG
  9264.                     printf("1 z++ = %d\n", z);
  9265. #endif /* XWORDSDEBUG */
  9266.                     list[z] = p;        /* Yes, point to it */
  9267. #ifdef XWORDSDEBUG
  9268.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9269. #endif /* XWORDSDEBUG */
  9270.                     break;              /* and quit */
  9271.                 }
  9272.                 k = 1;                  /* Set in-word flag */
  9273.             }
  9274.         }
  9275.         /* If we're not inside a braced quantity, and we are in a word, and */
  9276.         /* we have hit whitespace, then we have a word. */
  9277.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9278.             if (!flag || z < max)       /* if we don't want to keep rest */
  9279.               *s = '\0';                /* terminate the arg with null */
  9280.             k = 0;                      /* say we're not in a word any more */
  9281.             y = 0;                      /* start braces off clean again */
  9282.             if (z == max) break;        /* Only go up to max. */
  9283.             z++;                        /* count this arg */
  9284. #ifdef XWORDSDEBUG
  9285.             printf("1 z++ = %d\n", z);
  9286. #endif /* XWORDSDEBUG */
  9287.  
  9288. #ifndef NOSPL
  9289.             if (macro) {
  9290.                 if (z < 10) {
  9291.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9292.                     addmac(varnam,p);   /* add it to the macro table */
  9293.                 }
  9294.                 if (z <= max) {
  9295. #ifdef COMMENT
  9296.                     if (maclvl < 0)
  9297.                       addmac(varnam,p);
  9298.                     else
  9299. #endif /* COMMENT */
  9300.                       makestr(&(m_xarg[maclvl][z]),p);
  9301.                 }
  9302.             } else {
  9303. #endif /* NOSPL */
  9304.                 list[z] = p;
  9305. #ifdef XWORDSDEBUG
  9306.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9307. #endif /* XWORDSDEBUG */
  9308. #ifndef NOSPL
  9309.             }
  9310. #endif /* NOSPL */
  9311.             p = s+1;
  9312.         }
  9313.         s++;                            /* Point past this character */
  9314.     }
  9315.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9316.         z++;
  9317. #ifndef NOSPL
  9318.         if (macro) {
  9319.             if (z < 10) {
  9320.                 varnam[1] = z + '0';    /* compute its name */
  9321.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9322.             }
  9323.             if (z <= max) {
  9324. #ifdef COMMENT
  9325.                 if (maclvl < 0)
  9326.                   addmac(varnam,p);
  9327.                 else
  9328. #endif /* COMMENT */
  9329.                   makestr(&(m_xarg[maclvl][z]),p);
  9330.             }
  9331.         } else {
  9332. #endif /* NOSPL */
  9333.             list[z] = p;
  9334. #ifdef XWORDSDEBUG
  9335.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9336. #endif /* XWORDSDEBUG */
  9337. #ifndef NOSPL
  9338.         }
  9339. #endif /* NOSPL */
  9340.     }
  9341. #ifndef NOSPL
  9342.     if (macro) {                        /* Macro */
  9343.         if (maclvl < 0) {
  9344.             a_dim[0] = z;               /* Array dimension is one less */
  9345.             topargc = z + 1;            /* than \v(argc) */
  9346.         debug(F111,"a_dim[0]","D",a_dim[0]);
  9347.         } else {
  9348.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9349.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9350.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9351.             a_dim[0] = z;               /* And give it this dimension */
  9352.         debug(F111,"a_dim[0]","E",a_dim[0]);
  9353.         }
  9354.     }
  9355. #endif /* NOSPL */
  9356.     return;
  9357. }
  9358.  
  9359. #ifndef NOSPL
  9360.  
  9361. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9362.  
  9363. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9364.  
  9365. int
  9366. doshift(n) int n; {                     /* n = shift count */
  9367.     int i, top, level;
  9368.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9369.     char * sx = tmpbuf;
  9370.     int nx = TMPBUFSIZ;
  9371.  
  9372.     debug(F101,"SHIFT count","",n);
  9373.     debug(F101,"SHIFT topargc","",topargc);
  9374.  
  9375.     if (n < 1)                          /* Stay in range */
  9376.       return(n == 0 ? 1 : 0);
  9377.  
  9378.     level = maclvl;
  9379.     top = (level < 0) ? topargc : macargc[level];
  9380.  
  9381.     if (n >= top)
  9382.       n = top - 1;
  9383.  
  9384. #ifdef DEBUG
  9385.     if (deblog) {
  9386.         debug(F101,"SHIFT count 2","",n);
  9387.         debug(F101,"SHIFT level","",level);
  9388.         if (level > -1)
  9389.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9390.     }
  9391. #endif /* DEBUG */
  9392.  
  9393.     buf[0] = '\\';                      /* Initialize name template */
  9394.     buf[1] = '%';
  9395.     buf[2] = NUL;
  9396.     buf[3] = NUL;
  9397.  
  9398.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9399.         if (level < 0) {
  9400.             makestr(&(toparg[i]),NULL);
  9401.         } else {
  9402.             makestr(&(m_xarg[level][i]),NULL);
  9403.         }
  9404.         if (i < 10) {                   /* Is this necessary? */
  9405.             buf[2] = (char)(i+'0');
  9406.             delmac(buf,0);
  9407.         }
  9408.     }
  9409.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9410.         if (level < 0) {
  9411. #ifdef COMMENT
  9412.             toparg[i] = toparg[i+n];    /* Full vector */
  9413. #else
  9414.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9415. #endif /* COMMENT */
  9416.             if (i < 10)                 /* Scalars... */
  9417.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9418.         } else {
  9419. #ifdef COMMENT
  9420.             m_xarg[level][i] = m_xarg[level][i+n];
  9421. #else
  9422.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9423. #endif /* COMMENT */
  9424.             if (i < 10) {
  9425.                 buf[2] = (char)(i+'0');
  9426.                 debug(F010,"SHIFT buf",buf,0);
  9427.                 addmac(buf,m_xarg[level][i+n]);
  9428.             }
  9429.         }
  9430.     }
  9431.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9432.         if (level < 0) {
  9433. #ifdef COMMENT
  9434.             toparg[i] = NULL;
  9435. #else
  9436.             makestr(&(toparg[i]),NULL);
  9437. #endif /* COMMENt */
  9438.             if (i < 10)
  9439.               makestr(&(g_var[i+'0']),NULL);
  9440.         } else {
  9441. #ifdef COMMENT
  9442.             m_xarg[level][i] = NULL;
  9443. #else
  9444.             makestr(&(m_xarg[level][i]),NULL);
  9445. #endif /* COMMENt */
  9446.             if (i < 10) {
  9447.                 buf[2] = (char)(i+'0');
  9448.                 delmac(buf,0);
  9449.             }
  9450.         }
  9451.     }
  9452.     if (level > -1) {                   /* Macro args */
  9453.         macargc[level] -= n;            /* Adjust count */
  9454.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9455.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9456.     debug(F111,"a_dim[0]","F",a_dim[0]);
  9457.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9458. #ifdef COMMENT
  9459.         makestr(&(m_line[level]),tmpbuf);
  9460. #endif /* COMMENT */
  9461.     } else {                            /* Ditto for top level */
  9462.         topargc -= n;
  9463.         a_dim[0] = topargc - 1;
  9464.     debug(F111,"a_dim[0]","G",a_dim[0]);
  9465.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9466. #ifdef COMMENT
  9467.         makestr(&topline,tmpbuf);
  9468. #endif /* COMMENT */
  9469.     }
  9470.     return(1);
  9471. }
  9472. #endif /* NOSPL */
  9473.  
  9474. int
  9475. docd(cx) int cx; {                      /* Do the CD command */
  9476.     int x;
  9477.     extern int server, srvcdmsg, cdactive;
  9478.     extern char * cdmsgfile[], * ckcdpath;
  9479.     char *s, *p;
  9480. #ifdef MAC
  9481.     char temp[34];
  9482. #endif /* MAC */
  9483. #ifdef IKSDCONF
  9484. extern int iksdcf;
  9485. #endif /* IKSDCONF */
  9486.  
  9487. #ifndef NOFRILLS
  9488.     if (cx == XXBACK) {
  9489.         if ((x = cmcfm()) < 0)
  9490.         cwdf = 1;
  9491.         if (prevdir) {
  9492.             s = zgtdir();
  9493.             if (!zchdir(prevdir)) {
  9494.                 cwdf = 0;
  9495.                 perror(s);
  9496.             } else {
  9497.                 makestr(&prevdir,s);
  9498.             }
  9499.         }
  9500.         return(cwdf);
  9501.     }
  9502. #endif /* NOFRILLS */
  9503.  
  9504.     if (cx == XXCDUP) {
  9505. #ifdef VMS
  9506.         s = "[-]";
  9507. #else
  9508. #ifdef datageneral
  9509.         s = "^";
  9510. #else
  9511.         s = "..";
  9512. #endif /* datageneral */
  9513. #endif /* VMS */
  9514.         ckstrncpy(line,s,LINBUFSIZ);
  9515.         goto gocd;
  9516.     }
  9517. #ifndef NOSPL
  9518.     if (cx == XXKCD) {            /* Symbolic (Kermit) CD */
  9519.     char * p;
  9520.     int n, k;
  9521.     x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9522.     if (x < 0)
  9523.       return(x);
  9524.     x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9525.     if (x < 0) {
  9526.         printf("?Lookup error\n");    /* shouldn't happen */
  9527.         return(-9);
  9528.     }
  9529.         if ((x = cmcfm()) < 0)
  9530.       return(x);
  9531.     if (k == VN_HOME) {        /* HOME: allow SET HOME to override */
  9532.         ckstrncpy(line,homepath(),LINBUFSIZ);
  9533.     } else {            /* Other symbolic name */
  9534.         /* Convert to variable syntax */
  9535.         ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9536.         p = line;            /* Expand the variable */
  9537.         n = LINBUFSIZ;
  9538.         zzstring(tmpbuf,&p,&n);
  9539.         if (!line[0]) {        /* Fail if variable not defined */
  9540.         printf("?%s - not defined\n",tmpbuf);
  9541.         return(success = 0);
  9542.         }
  9543.     }
  9544.     s = line;            /* All OK, go try to CD... */
  9545.     goto gocd;
  9546.     }
  9547. #endif /* NOSPL */
  9548.  
  9549.     cdactive = 1;
  9550. #ifdef GEMDOS
  9551.     if ((x = cmdir("Name of local directory, or carriage return",
  9552.                    homepath(),
  9553.                    &s,
  9554.                    NULL
  9555.                    )
  9556.          ) < 0 )
  9557.       return(x);
  9558. #else
  9559. #ifdef OS2
  9560.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9561.        or press the Enter key for the default",
  9562.                     homepath(),
  9563.                     &s,
  9564.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9565.                     xxstring
  9566.                     )
  9567.          ) < 0 )
  9568.       return(x);
  9569. #else
  9570. #ifdef MAC
  9571.     x = ckstrncpy(temp,homepath(),32);
  9572.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9573.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9574.  or press the Return key for the desktop on the boot disk",
  9575.                    temp,&s, xxstring)) < 0 )
  9576.       return(x);
  9577. #else
  9578.     if ((x = cmdirp("Carriage return for home directory,\n\
  9579. or name of directory on this computer",
  9580. #ifdef VMS
  9581.                     "SYS$LOGIN",        /* With no colon */
  9582. #else
  9583.                     homepath(),        /* In VMS this is "SYS$LOGIN:" */
  9584. #endif /* VMS */
  9585.                     &s,
  9586.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9587.                     xxstring
  9588.                     )) < 0)
  9589.       return(x);
  9590. #endif /* MAC */
  9591. #endif /* OS2 */
  9592. #endif /* GEMDOS */
  9593.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9594.     s = line;
  9595. #ifdef VMS
  9596.     if (ckmatch("*.DIR;1$",s,0,0))
  9597.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9598.         s = tmpbuf;
  9599. #endif /* VMS */
  9600.     debug(F110,"docd",s,0);
  9601. #ifndef MAC
  9602.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9603.       return(x);
  9604. #endif /* MAC */
  9605.  
  9606.   gocd:
  9607.  
  9608. #ifdef datageneral
  9609.     x = strlen(line);                   /* homdir ends in colon, */
  9610.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9611.       line[x-1] = NUL;
  9612. #endif /* datageneral */
  9613.  
  9614. #ifdef MAC
  9615.     cwdf = 1;
  9616.     if (!zchdir(s)) {
  9617.         cwdf = 0;
  9618.         if (*s != ':') {                /* If it failed, */
  9619.             char *p;                    /* supply leading colon */
  9620.             int len = (int)strlen(s) + 2;
  9621.             p = malloc(len);            /* and try again... */
  9622.             if (p) {
  9623.                 strcpy(p,":");          /* safe */
  9624.                 strcat(p,s);            /* safe */
  9625.                 if (zchdir(p))
  9626.                   cwdf = 1;
  9627.                 free(p);
  9628.                 p = NULL;
  9629.             }
  9630.         }
  9631.     }
  9632.     if (!cwdf)
  9633.       perror(s);
  9634. #else
  9635.     p = zgtdir();
  9636.     if (!zchdir(s)) {
  9637.         cwdf = 0;
  9638. #ifdef CKROOT
  9639.         if (ckrooterr)
  9640.           printf("?Off limits: \"%s\"\n",s);
  9641.         else
  9642. #endif /* CKROOT */
  9643.           perror(s);
  9644.     } else cwdf = 1;
  9645. #endif /* MAC */
  9646.  
  9647.     x = 0;
  9648.     if (cwdf) {
  9649.         makestr(&prevdir,p);
  9650.         debug(F111,"docd","srvcdmsg",srvcdmsg);
  9651.         if (srvcdmsg
  9652. #ifdef IKSDCONF
  9653.             && !(inserver && !iksdcf)
  9654. #endif /* IKSDCONF */
  9655.             ) {
  9656.             int i;
  9657.             for (i = 0; i < 8; i++) {
  9658.                 debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9659.                 if (zchki(cdmsgfile[i]) > -1) {
  9660.                     x = 1;
  9661.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9662.                     break;
  9663.                 }
  9664.             }
  9665.         }
  9666.     }
  9667. /* xdocd: */
  9668.     if (!x && srvcdmsg && !server
  9669. #ifdef IKSDCONF
  9670.         && !(inserver && !iksdcf)
  9671. #endif /* IKSDCONF */
  9672.         && !quiet && !xcmdsrc)
  9673.       printf("%s\n", zgtdir());
  9674.  
  9675.     return(cwdf);
  9676. }
  9677.  
  9678. static int on_ctrlc = 0;
  9679.  
  9680. VOID
  9681. fixcmd() {                      /* Fix command parser after interruption */
  9682. #ifndef NOSPL
  9683. #ifndef NOONCTRLC
  9684.     if (nmac) {                         /* Any macros defined? */
  9685.         int k;                          /* Yes */
  9686.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9687.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9688.         if (k >= 0) {                   /* If found, */
  9689.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9690.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9691.                   parser(1);            /* execute it, */
  9692.             }
  9693.             delmac(s,1);                /* and undefine it. */
  9694.         }
  9695.     }
  9696.     on_ctrlc = 0;
  9697. #endif /* NOONCTRLC */
  9698. #endif /* NOSPL */
  9699.     dostop();                   /* Back to top level (also calls conint()). */
  9700.     bgchk();                    /* Check background status */
  9701.     if (*psave) {               /* If old prompt saved, */
  9702.         cmsetp(psave);          /* restore it. */
  9703.         *psave = NUL;
  9704.     }
  9705.     success = 0;                /* Tell parser last command failed */
  9706. }
  9707.  
  9708. #ifndef NOSHOW                          /* SHOW FEATURES */
  9709. /*
  9710.   Note, presently optlist[] index overflow is not checked.
  9711.   There is plenty of room (less than 360 entries for 1000 slots).
  9712.   When space starts to get tight, check for noptlist >= NOPTLIST
  9713.   every time noptlist is incremented.
  9714. */
  9715. #define NOPTLIST 1024
  9716. static int noptlist = 0;
  9717. static char * optlist[NOPTLIST+1];
  9718. static int hpos = 0;
  9719.  
  9720. int
  9721. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9722.     int y, i;                           /* Does word wrap. */
  9723.     if (!s) s = "";
  9724.     i = *lines;
  9725.     if (!*s) {                          /* Empty argument */
  9726.         if (hpos > 0) {                 /* means to end this line. */
  9727.             printf("\n");               /* Not needed if already at */
  9728.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9729.                 if (!askmore())
  9730.                   return(0);
  9731.                 else
  9732.                   i = 0;
  9733.             }
  9734.         }
  9735.         printf("\n");                   /* And then make a blank line */
  9736.         if (++i > (cmd_rows - 3)) {
  9737.             if (!askmore())
  9738.               return(0);
  9739.             else
  9740.               i = 0;
  9741.         }
  9742.         hpos = 0;
  9743.         *lines = i;
  9744.         return(1);
  9745.     }
  9746.     y = (int)strlen(s) + 1;
  9747.     hpos += y;
  9748.     debug(F101,"prtopt hpos","",hpos);
  9749.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9750.  
  9751.     if (
  9752. #ifdef OS2
  9753.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9754. #else /* OS2 */
  9755.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9756. #endif /* OS2 */
  9757.         ) {
  9758.         printf("\n");
  9759.         if (++i > (cmd_rows - 3)) {
  9760.             if (!askmore())
  9761.               return(0);
  9762.             else
  9763.               i = 0;
  9764.         }
  9765.         printf(" %s",s);
  9766.         hpos = y;
  9767.     } else
  9768.       printf(" %s",s);
  9769.     *lines = i;
  9770.     return(1);
  9771. }
  9772.  
  9773. static VOID
  9774. initoptlist() {
  9775.     int i;
  9776.     if (noptlist > 0)
  9777.       return;
  9778.     for (i = 0; i < NOPTLIST; i++)
  9779.       optlist[i] = NULL;
  9780.  
  9781. #ifdef MAC
  9782. #ifdef MPW
  9783.     makestr(&(optlist[noptlist++]),"MPW");
  9784. #endif /* MPW */
  9785. #endif /* MAC */
  9786.  
  9787. #ifdef MAC
  9788. #ifdef THINK_C
  9789.     makestr(&(optlist[noptlist++]),"THINK_C");
  9790. #endif /* THINK_C */
  9791. #endif /* MAC */
  9792.  
  9793. #ifdef __386__
  9794.     makestr(&(optlist[noptlist++]),"__386__");
  9795. #endif /* __386__ */
  9796.  
  9797. /* Memory models... */
  9798.  
  9799. #ifdef __FLAT__
  9800.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9801. #endif /* __FLAT__ */
  9802. #ifdef __SMALL__
  9803.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9804. #endif /* __SMALL__ */
  9805. #ifdef __MEDIUM__
  9806.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9807. #endif /* __MEDIUM__ */
  9808. #ifdef __COMPACT__
  9809.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9810. #endif /* __COMPACT__ */
  9811. #ifdef __LARGE__
  9812.     makestr(&(optlist[noptlist++]),"__LARGE__");
  9813. #endif /* __LARGE__ */
  9814.  
  9815. #ifdef DEBUG
  9816. #ifdef IFDEBUG
  9817.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  9818. #else
  9819.     makestr(&(optlist[noptlist++]),"DEBUG");
  9820. #endif /* IFDEBUG */
  9821. #endif /* DEBUG */
  9822. #ifdef TLOG
  9823.     makestr(&(optlist[noptlist++]),"TLOG");
  9824. #endif /* TLOG */
  9825. #ifdef BIGBUFOK
  9826.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9827. #endif /* BIGBUFOK */
  9828. #ifdef INPBUFSIZ
  9829.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9830.     makestr(&(optlist[noptlist++]),line);
  9831. #endif /* INPBUFSIZE */
  9832. #ifdef LINBUFSIZ
  9833.     sprintf(line,"LINBUFSIZ=%d",LINBUFSIZ); /* SAFE */
  9834.     makestr(&(optlist[noptlist++]),line);
  9835. #endif /* LINBUFSIZE */
  9836. #ifdef INBUFSIZE
  9837.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9838.     makestr(&(optlist[noptlist++]),line);
  9839. #endif /* INBUFSIZE */
  9840. #ifdef OBUFSIZE
  9841.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9842.     makestr(&(optlist[noptlist++]),line);
  9843. #endif /* OBUFSIZE */
  9844. #ifdef FD_SETSIZE
  9845.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9846.     makestr(&(optlist[noptlist++]),line);
  9847. #endif /* FD_SETSIZE */
  9848. #ifdef XFRCAN
  9849.     makestr(&(optlist[noptlist++]),"XFRCAN");
  9850. #endif /* XFRCAN */
  9851. #ifdef XPRINT
  9852.     makestr(&(optlist[noptlist++]),"XPRINT");
  9853. #endif /* XPRINT */
  9854. #ifdef PIPESEND
  9855.     makestr(&(optlist[noptlist++]),"PIPESEND");
  9856. #endif /* PIPESEND */
  9857. #ifdef CK_SPEED
  9858.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  9859. #endif /* CK_SPEED */
  9860. #ifdef CK_FAST
  9861.     makestr(&(optlist[noptlist++]),"CK_FAST");
  9862. #endif /* CK_FAST */
  9863. #ifdef CK_APC
  9864.     makestr(&(optlist[noptlist++]),"CK_APC");
  9865. #endif /* CK_APC */
  9866. #ifdef CK_AUTODL
  9867.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  9868. #endif /* CK_AUTODL */
  9869. #ifdef CK_MKDIR
  9870.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  9871. #endif /* CK_MKDIR */
  9872. #ifdef NOMKDIR
  9873.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  9874. #endif /* NOMKDIR */
  9875. #ifdef CK_LABELED
  9876.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  9877. #endif /* CK_LABELED */
  9878. #ifdef NODIAL
  9879.     makestr(&(optlist[noptlist++]),"NODIAL");
  9880. #endif /* NODIAL */
  9881. #ifdef MINIDIAL
  9882.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  9883. #endif /* MINIDIAL */
  9884. #ifdef WHATAMI
  9885.     makestr(&(optlist[noptlist++]),"WHATAMI");
  9886. #endif /* WHATAMI */
  9887. #ifdef DYNAMIC
  9888.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  9889. #endif /* DYNAMIC */
  9890. #ifndef NOSPL
  9891.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  9892.     makestr(&(optlist[noptlist++]),line);
  9893. #endif /* NOSPL */
  9894.  
  9895. #ifdef MAXPATHLEN
  9896.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  9897.     makestr(&(optlist[noptlist++]),line);
  9898. #endif /* MAXPATHLEN */
  9899.  
  9900. #ifdef DEVNAMLEN
  9901.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  9902.     makestr(&(optlist[noptlist++]),line);
  9903. #endif /* DEVNAMLEN */
  9904.  
  9905. #ifdef NO_PARAM_H
  9906.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  9907. #endif /* NO_PARAM_H */
  9908.  
  9909. #ifdef INCL_PARAM_H
  9910.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  9911. #endif /* INCL_PARAM_H */
  9912.  
  9913.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  9914.     makestr(&(optlist[noptlist++]),line);
  9915.  
  9916.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  9917.     makestr(&(optlist[noptlist++]),line);
  9918.  
  9919.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  9920.     makestr(&(optlist[noptlist++]),line);
  9921.  
  9922. #ifdef OPEN_MAX
  9923.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  9924.     makestr(&(optlist[noptlist++]),line);
  9925. #endif /* OPEN_MAX */
  9926.  
  9927. #ifdef _POSIX_OPEN_MAX
  9928.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  9929.     makestr(&(optlist[noptlist++]),line);
  9930. #endif /* _POSIX_OPEN_MAX */
  9931.  
  9932. #ifdef CKCHANNELIO
  9933.     {
  9934.         extern int z_maxchan;
  9935. #ifdef UNIX
  9936.         extern int ckmaxfiles;
  9937.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  9938.         makestr(&(optlist[noptlist++]),line);
  9939. #endif /* UNIX */
  9940.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  9941.         makestr(&(optlist[noptlist++]),line);
  9942.     }
  9943. #endif /* CKCHANNELIO */
  9944.  
  9945. #ifdef FOPEN_MAX
  9946.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  9947.     makestr(&(optlist[noptlist++]),line);
  9948. #endif /* FOPEN_MAX */
  9949.  
  9950. #ifdef MAXGETPATH
  9951.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  9952.     makestr(&(optlist[noptlist++]),line);
  9953. #endif /* MAXGETPATH */
  9954.  
  9955. #ifdef CMDBL
  9956.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  9957.     makestr(&(optlist[noptlist++]),line);
  9958. #endif /* CMDBL */
  9959.  
  9960. #ifdef VNAML
  9961.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  9962.     makestr(&(optlist[noptlist++]),line);
  9963. #endif /* VNAML */
  9964.  
  9965. #ifdef ARRAYREFLEN
  9966.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  9967.     makestr(&(optlist[noptlist++]),line);
  9968. #endif /* ARRAYREFLEN */
  9969.  
  9970. #ifdef UIDBUFLEN
  9971.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  9972.     makestr(&(optlist[noptlist++]),line);
  9973. #endif /* UIDBUFLEN */
  9974.  
  9975. #ifdef FORDEPTH
  9976.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  9977.     makestr(&(optlist[noptlist++]),line);
  9978. #endif /* FORDEPTH */
  9979.  
  9980. #ifdef MAXTAKE
  9981.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  9982.     makestr(&(optlist[noptlist++]),line);
  9983. #endif /* MAXTAKE */
  9984.  
  9985. #ifdef MACLEVEL
  9986.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  9987.     makestr(&(optlist[noptlist++]),line);
  9988. #endif /* MACLEVEL */
  9989.  
  9990. #ifdef MAC_MAX
  9991.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  9992.     makestr(&(optlist[noptlist++]),line);
  9993. #endif /* MAC_MAX */
  9994.  
  9995. #ifdef _LARGEFILE_SOURCE
  9996.     makestr(&(optlist[noptlist++]),"_LARGEFILE_SOURCE");
  9997. #endif    /* _LARGEFILE_SOURCE */
  9998.  
  9999. #ifdef _FILE_OFFSET_BITS
  10000.     sprintf(line,"_FILE_OFFSET_BITS=%d",_FILE_OFFSET_BITS); /* SAFE */
  10001.     makestr(&(optlist[noptlist++]),line);
  10002. #endif    /* _FILE_OFFSET_BITS */
  10003.  
  10004. #ifdef __USE_FILE_OFFSET64
  10005.     makestr(&(optlist[noptlist++]),"__USE_FILE_OFFSET64");
  10006. #endif    /* __USE_FILE_OFFSET64 */
  10007.  
  10008. #ifdef __USE_LARGEFILE64
  10009.     makestr(&(optlist[noptlist++]),"__USE_LARGEFILE64");
  10010. #endif    /* __USE_LARGEFILE64 */
  10011.  
  10012. #ifdef COMMENT
  10013. #ifdef CHAR_MAX
  10014.     sprintf(line,"CHAR_MAX=%llx",CHAR_MAX); /* SAFE */
  10015.     makestr(&(optlist[noptlist++]),line);
  10016. #endif /* CHAR_MAX */
  10017. #ifdef UCHAR_MAX
  10018.     sprintf(line,"UCHAR_MAX=%llx",UCHAR_MAX); /* SAFE */
  10019.     makestr(&(optlist[noptlist++]),line);
  10020. #endif /* UCHAR_MAX */
  10021. #ifdef SHRT_MAX
  10022.     sprintf(line,"SHRT_MAX=%llx",SHRT_MAX); /* SAFE */
  10023.     makestr(&(optlist[noptlist++]),line);
  10024. #endif /* SHRT_MAX */
  10025. #ifdef USHRT_MAX
  10026.     sprintf(line,"USHRT_MAX=%llx",USHRT_MAX); /* SAFE */
  10027.     makestr(&(optlist[noptlist++]),line);
  10028. #endif /* USHRT_MAX */
  10029. #ifdef INT_MAX
  10030.     sprintf(line,"INT_MAX=%llx",INT_MAX); /* SAFE */
  10031.     makestr(&(optlist[noptlist++]),line);
  10032. #endif /* INT_MAX */
  10033. #ifdef UINT_MAX
  10034.     sprintf(line,"UINT_MAX=%llx",UINT_MAX); /* SAFE */
  10035.     makestr(&(optlist[noptlist++]),line);
  10036. #endif /* UINT_MAX */
  10037. #ifdef MAX_LONG
  10038.     sprintf(line,"MAX_LONG=%llx",MAX_LONG); /* SAFE */
  10039.     makestr(&(optlist[noptlist++]),line);
  10040. #endif /* MAX_LONG */
  10041. #ifdef LONG_MAX
  10042.     sprintf(line,"LONG_MAX=%llx",LONG_MAX); /* SAFE */
  10043.     makestr(&(optlist[noptlist++]),line);
  10044. #endif /* LONG_MAX */
  10045. #ifdef ULONG_MAX
  10046.     sprintf(line,"ULONG_MAX=%llx",ULONG_MAX); /* SAFE */
  10047.     makestr(&(optlist[noptlist++]),line);
  10048. #endif /* ULONG_MAX */
  10049. #ifdef MAXINT
  10050.     sprintf(line,"MAXINT=%llx",MAXINT); /* SAFE */
  10051.     makestr(&(optlist[noptlist++]),line);
  10052. #endif /* MAXINT */
  10053. #ifdef MAXLONG
  10054.     sprintf(line,"MAXLONG=%llx",MAXLONG); /* SAFE */
  10055.     makestr(&(optlist[noptlist++]),line);
  10056. #endif /* MAXLONG */
  10057. #ifdef NT
  10058. #ifdef LLONG_MAX
  10059.     sprintf(line,"LLONG_MAX=%I64x",LLONG_MAX); /* SAFE */
  10060.     makestr(&(optlist[noptlist++]),line);
  10061. #endif /* LLONG_MAX */
  10062. #ifdef ULLONG_MAX
  10063.     sprintf(line,"ULLONG_MAX=%I64x",ULLONG_MAX); /* SAFE */
  10064.     makestr(&(optlist[noptlist++]),line);
  10065. #endif /* ULLONG_MAX */
  10066. #ifdef MAXLONGLONG
  10067.     sprintf(line,"MAXLONGLONG=%I64x",MAXLONGLONG);  /* SAFE */
  10068.     makestr(&(optlist[noptlist++]),line);
  10069. #endif /* MAXLONGLONG */
  10070. #else
  10071. #ifdef LLONG_MAX
  10072.     sprintf(line,"LLONG_MAX=%llx",LLONG_MAX); /* SAFE */
  10073.     makestr(&(optlist[noptlist++]),line);
  10074. #endif /* LLONG_MAX */
  10075. #ifdef ULLONG_MAX
  10076.     sprintf(line,"ULLONG_MAX=%llx",ULLONG_MAX); /* SAFE */
  10077.     makestr(&(optlist[noptlist++]),line);
  10078. #endif /* ULLONG_MAX */
  10079. #ifdef MAXLONGLONG
  10080.     sprintf(line,"MAXLONGLONG=%llx",MAXLONGLONG);  /* SAFE */
  10081.     makestr(&(optlist[noptlist++]),line);
  10082. #endif /* MAXLONGLONG */
  10083. #endif
  10084. #ifdef _INTEGRAL_MAX_BITS
  10085.     sprintf(line,"_INTEGRAL_MAX_BITS=%d",_INTEGRAL_MAX_BITS);  /* SAFE */
  10086.     makestr(&(optlist[noptlist++]),line);
  10087. #endif /* _INTEGRAL_MAX_BITS */
  10088. #endif    /* COMMENT */
  10089.  
  10090. #ifdef MINPUTMAX
  10091.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  10092.     makestr(&(optlist[noptlist++]),line);
  10093. #endif /* MINPUTMAX */
  10094.  
  10095. #ifdef MAXWLD
  10096.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  10097.     makestr(&(optlist[noptlist++]),line);
  10098. #else
  10099. #ifdef OS2
  10100.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  10101. #endif /* OS2 */
  10102. #endif /* MAXWLD */
  10103.  
  10104. #ifdef MSENDMAX
  10105.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  10106.     makestr(&(optlist[noptlist++]),line);
  10107. #endif /* MSENDMAX */
  10108.  
  10109. #ifdef MAXDDIR
  10110.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  10111.     makestr(&(optlist[noptlist++]),line);
  10112. #endif /* MAXDDIR */
  10113.  
  10114. #ifdef MAXDNUMS
  10115.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  10116.     makestr(&(optlist[noptlist++]),line);
  10117. #endif /* MAXDNUMS */
  10118.  
  10119. #ifdef UNIX
  10120.     makestr(&(optlist[noptlist++]),"UNIX");
  10121. #endif /* UNIX */
  10122.  
  10123. #ifdef VMS
  10124.     makestr(&(optlist[noptlist++]),"VMS");
  10125. #ifdef __VMS_VER
  10126.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  10127.     makestr(&(optlist[noptlist++]),line);
  10128. #endif /* __VMS_VER */
  10129. #ifdef VMSV70
  10130.     makestr(&(optlist[noptlist++]),"VMSV70");
  10131. #endif /* VMSV70 */
  10132. #ifdef OLD_VMS
  10133.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  10134. #endif /* OLD_VMS */
  10135. #ifdef vms
  10136.     makestr(&(optlist[noptlist++]),"vms");
  10137. #endif /* vms */
  10138. #ifdef VMSV60
  10139.     makestr(&(optlist[noptlist++]),"VMSV60");
  10140. #endif /* VMSV60 */
  10141. #ifdef VMSV80
  10142.     makestr(&(optlist[noptlist++]),"VMSV80");
  10143. #endif /* VMSV80 */
  10144. #ifdef VMSSHARE
  10145.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  10146. #endif /* VMSSHARE */
  10147. #ifdef NOVMSSHARE
  10148.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  10149. #endif /* NOVMSSHARE */
  10150. #endif /* VMS */
  10151.  
  10152. #ifdef datageneral
  10153.     makestr(&(optlist[noptlist++]),"datageneral");
  10154. #endif /* datageneral */
  10155. #ifdef apollo
  10156.     makestr(&(optlist[noptlist++]),"apollo");
  10157. #endif /* apollo */
  10158. #ifdef aegis
  10159.     makestr(&(optlist[noptlist++]),"aegis");
  10160. #endif /* aegis */
  10161. #ifdef A986
  10162.     makestr(&(optlist[noptlist++]),"A986");
  10163. #endif /* A986 */
  10164. #ifdef AMIGA
  10165.     makestr(&(optlist[noptlist++]),"AMIGA");
  10166. #endif /* AMIGA */
  10167. #ifdef CONVEX9
  10168.     makestr(&(optlist[noptlist++]),"CONVEX9");
  10169. #endif /* CONVEX9 */
  10170. #ifdef CONVEX10
  10171.     makestr(&(optlist[noptlist++]),"CONVEX10");
  10172. #endif /* CONVEX9 */
  10173. #ifdef MAC
  10174.     makestr(&(optlist[noptlist++]),"MAC");
  10175. #endif /* MAC */
  10176. #ifdef AUX
  10177.     makestr(&(optlist[noptlist++]),"AUX");
  10178. #endif /* AUX */
  10179.  
  10180. #ifdef OS2
  10181.     makestr(&(optlist[noptlist++]),"OS2");
  10182. #ifdef NT
  10183.     makestr(&(optlist[noptlist++]),"NT");
  10184. #endif /* NT */
  10185. #endif /* OS2 */
  10186.  
  10187. #ifdef OSK
  10188.     makestr(&(optlist[noptlist++]),"OS9");
  10189. #endif /* OSK */
  10190.  
  10191. #ifdef MSDOS
  10192.     makestr(&(optlist[noptlist++]),"MSDOS");
  10193. #endif /* MSDOS */
  10194.  
  10195. #ifdef DIRENT
  10196.     makestr(&(optlist[noptlist++]),"DIRENT");
  10197. #endif /* DIRENT */
  10198.  
  10199. #ifdef SDIRENT
  10200.     makestr(&(optlist[noptlist++]),"SDIRENT");
  10201. #endif /* SDIRENT */
  10202.  
  10203. #ifdef NDIR
  10204.     makestr(&(optlist[noptlist++]),"NDIR");
  10205. #endif /* NDIR */
  10206.  
  10207. #ifdef XNDIR
  10208.     makestr(&(optlist[noptlist++]),"XNDIR");
  10209. #endif /* XNDIR */
  10210.  
  10211. #ifdef SAVEDUID
  10212.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  10213. #endif /* SAVEDUID */
  10214.  
  10215. #ifdef RENAME
  10216.     makestr(&(optlist[noptlist++]),"RENAME");
  10217. #endif /* RENAME */
  10218.  
  10219. #ifdef CK_TMPDIR
  10220.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  10221. #endif /* CK_TMPDIR */
  10222.  
  10223. #ifdef NOCCTRAP
  10224.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  10225. #endif /* NOCCTRAP */
  10226.  
  10227. #ifdef NOCOTFMC
  10228.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  10229. #endif /* NOCOTFMC */
  10230.  
  10231. #ifdef NOFRILLS
  10232.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  10233. #endif /* NOFRILLS */
  10234.  
  10235. #ifdef PARSENSE
  10236.     makestr(&(optlist[noptlist++]),"PARSENSE");
  10237. #endif /* PARSENSE */
  10238.  
  10239. #ifdef TIMEH
  10240.     makestr(&(optlist[noptlist++]),"TIMEH");
  10241. #endif /* TIMEH */
  10242.  
  10243. #ifdef NOTIMEH
  10244.     makestr(&(optlist[noptlist++]),"TIMEH");
  10245. #endif /* NOTIMEH */
  10246.  
  10247. #ifdef SYSTIMEH
  10248.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10249. #endif /* SYSTIMEH */
  10250.  
  10251. #ifdef NOSYSTIMEH
  10252.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  10253. #endif /* NOSYSTIMEH */
  10254.  
  10255. #ifdef SYSTIMEBH
  10256.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10257. #endif /* SYSTIMEBH */
  10258.  
  10259. #ifdef NOSYSTIMEBH
  10260.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  10261. #endif /* NOSYSTIMEBH */
  10262.  
  10263. #ifdef UTIMEH
  10264.     makestr(&(optlist[noptlist++]),"UTIMEH");
  10265. #endif /* UTIMEH */
  10266.  
  10267. #ifdef SYSUTIMEH
  10268.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  10269. #endif /* SYSUTIMEH */
  10270.  
  10271. #ifdef CK_NEED_SIG
  10272.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  10273. #endif /* CK_NEED_SIG */
  10274.  
  10275. #ifdef CK_TTYFD
  10276.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  10277. #endif /* CK_TTYFD */
  10278.  
  10279. #ifdef NETCONN
  10280.     makestr(&(optlist[noptlist++]),"NETCONN");
  10281. #endif /* NETCONN */
  10282.  
  10283. #ifdef TCPSOCKET
  10284.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  10285. #ifdef NOTCPOPTS
  10286.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  10287. #endif /* NOTCPOPTS */
  10288. #ifdef CK_DNS_SRV
  10289.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  10290. #endif /* CK_DNS_SRV */
  10291. #ifdef NO_DNS_SRV
  10292.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  10293. #endif /* NO_DNS_SRV */
  10294. #ifdef CKGHNLHOST
  10295.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  10296. #endif /* CKGHNLHOST */
  10297. #ifdef NOLISTEN
  10298.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  10299. #endif /* NOLISTEN */
  10300. #ifdef SOL_SOCKET
  10301.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  10302. #endif /* SOL_SOCKET */
  10303. #ifdef SO_OOBINLINE
  10304.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  10305. #endif /* SO_OOBINLNE */
  10306. #ifdef SO_DONTROUTE
  10307.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  10308. #endif /* SO_DONTROUTE */
  10309. #ifdef SO_KEEPALIVE
  10310.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  10311. #endif /* SO_KEEPALIVE */
  10312. #ifdef SO_LINGER
  10313.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  10314. #endif /* SO_LINGER */
  10315. #ifdef TCP_NODELAY
  10316.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  10317. #endif /* TCP_NODELAY */
  10318. #ifdef SO_SNDBUF
  10319.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  10320. #endif /* SO_SNDBUF */
  10321. #ifdef SO_RCVBUF
  10322.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  10323. #endif /* SO_RCVBUF */
  10324. #ifdef h_addr
  10325.     makestr(&(optlist[noptlist++]),"h_addr");
  10326. #endif /* h_addr */
  10327. #ifdef HADDRLIST
  10328.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  10329. #endif /* HADDRLIST */
  10330. #ifdef CK_SOCKS
  10331.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  10332. #ifdef CK_SOCKS5
  10333.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  10334. #endif /* CK_SOCKS5 */
  10335. #ifdef CK_SOCKS_NS
  10336.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  10337. #endif /* CK_SOCKS_NS */
  10338. #endif /* CK_SOCKS */
  10339. #ifdef RLOGCODE
  10340.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  10341. #endif /* RLOGCODE */
  10342. #ifdef NETCMD
  10343.     makestr(&(optlist[noptlist++]),"NETCMD");
  10344. #endif /* NETCMD */
  10345. #ifdef NONETCMD
  10346.     makestr(&(optlist[noptlist++]),"NONETCMD");
  10347. #endif /* NONETCMD */
  10348. #ifdef NETPTY
  10349.     makestr(&(optlist[noptlist++]),"NETPTY");
  10350. #endif /* NETPTY */
  10351. #ifdef CK_ENVIRONMENT
  10352.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  10353. #endif /* CK_ENVIRONMENT */
  10354. #endif /* TCPSOCKET */
  10355. #ifdef TNCODE
  10356.     makestr(&(optlist[noptlist++]),"TNCODE");
  10357. #endif /* TNCODE */
  10358. #ifdef CK_FORWARD_X
  10359.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  10360. #endif /* CK_FORWARD_X */
  10361. #ifdef TN_COMPORT
  10362.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  10363. #endif /* TN_COMPORT */
  10364. #ifdef MULTINET
  10365.     makestr(&(optlist[noptlist++]),"MULTINET");
  10366. #endif /* MULTINET */
  10367. #ifdef DEC_TCPIP
  10368.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  10369. #endif /* DEC_TCPIP */
  10370. #ifdef TCPWARE
  10371.     makestr(&(optlist[noptlist++]),"TCPWARE");
  10372. #endif /* TCPWARE */
  10373. #ifdef UCX50
  10374.     makestr(&(optlist[noptlist++]),"UCX50");
  10375. #endif /* UCX50 */
  10376. #ifdef CMU_TCPIP
  10377.     makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  10378. #endif /* CMU_TCPIP */
  10379. #ifdef TTLEBUF
  10380.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  10381. #endif /* TTLEBUF */
  10382. #ifdef NETLEBUF
  10383.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  10384. #endif /* NETLEBUF */
  10385. #ifdef IKS_OPTION
  10386.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10387. #endif /* IKS_OPTION */
  10388. #ifdef IKSDB
  10389.     makestr(&(optlist[noptlist++]),"IKSDB");
  10390. #endif /* IKSDB */
  10391. #ifdef IKSDCONF
  10392.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  10393. #endif /* IKSDCONF */
  10394. #ifdef CK_LOGIN
  10395.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10396. #endif /* CK_LOGIN */
  10397. #ifdef CK_PAM
  10398.     makestr(&(optlist[noptlist++]),"CK_PAM");
  10399. #endif /* CK_PAM */
  10400. #ifdef CK_SHADOW
  10401.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10402. #endif /* CK_SHADOW */
  10403. #ifdef CONGSPD
  10404.     makestr(&(optlist[noptlist++]),"CONGSPD");
  10405. #endif /* CONGSPD */
  10406. #ifdef SUNX25
  10407.     makestr(&(optlist[noptlist++]),"SUNX25");
  10408. #endif /* SUNX25 */
  10409. #ifdef IBMX25
  10410.     makestr(&(optlist[noptlist++]),"IBMX25");
  10411. #endif /* IBMX25 */
  10412. #ifdef HPX25
  10413.     makestr(&(optlist[noptlist++]),"HPX25");
  10414. #endif /* HPX25 */
  10415. #ifdef DECNET
  10416.     makestr(&(optlist[noptlist++]),"DECNET");
  10417. #endif /* DECNET */
  10418. #ifdef SUPERLAT
  10419.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  10420. #endif /* SUPERLAT */
  10421. #ifdef NPIPE
  10422.     makestr(&(optlist[noptlist++]),"NPIPE");
  10423. #endif /* NPIPE */
  10424. #ifdef CK_NETBIOS
  10425.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10426. #endif /* CK_NETBIOS */
  10427. #ifdef ATT7300
  10428.     makestr(&(optlist[noptlist++]),"ATT7300");
  10429. #endif /* ATT7300 */
  10430. #ifdef ATT6300
  10431.     makestr(&(optlist[noptlist++]),"ATT6300");
  10432. #endif /* ATT6300 */
  10433. #ifdef HDBUUCP
  10434.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10435. #endif /* HDBUUCP */
  10436. #ifdef USETTYLOCK
  10437.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10438. #endif /* USETTYLOCK */
  10439. #ifdef USE_UU_LOCK
  10440.     makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
  10441. #endif /* USE_UU_LOCK */
  10442. #ifdef HAVE_BAUDBOY
  10443.     makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
  10444. #endif /* HAVE_BAUDBOY */
  10445. #ifdef NOUUCP
  10446.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10447. #endif /* NOUUCP */
  10448. #ifdef LONGFN
  10449.     makestr(&(optlist[noptlist++]),"LONGFN");
  10450. #endif /* LONGFN */
  10451. #ifdef RDCHK
  10452.     makestr(&(optlist[noptlist++]),"RDCHK");
  10453. #endif /* RDCHK */
  10454. #ifdef SELECT
  10455.     makestr(&(optlist[noptlist++]),"SELECT");
  10456. #endif /* SELECT */
  10457. #ifdef USLEEP
  10458.     makestr(&(optlist[noptlist++]),"USLEEP");
  10459. #endif /* USLEEP */
  10460. #ifdef NAP
  10461.     makestr(&(optlist[noptlist++]),"NAP");
  10462. #endif /* NAP */
  10463. #ifdef NAPHACK
  10464.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10465. #endif /* NAPHACK */
  10466. #ifdef CK_POLL
  10467.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10468. #endif /* CK_POLL */
  10469. #ifdef NOIEXTEN
  10470.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10471. #endif /* NOIEXTEN */
  10472. #ifdef EXCELAN
  10473.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10474. #endif /* EXCELAN */
  10475. #ifdef INTERLAN
  10476.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10477. #endif /* INTERLAN */
  10478. #ifdef NOFILEH
  10479.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10480. #endif /* NOFILEH */
  10481. #ifdef NOSYSIOCTLH
  10482.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10483. #endif /* NOSYSIOCTLH */
  10484. #ifdef DCLPOPEN
  10485.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10486. #endif /* DCLPOPEN */
  10487. #ifdef NOSETBUF
  10488.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10489. #endif /* NOSETBUF */
  10490. #ifdef NOXFER
  10491.     makestr(&(optlist[noptlist++]),"NOXFER");
  10492. #endif /* NOXFER */
  10493. #ifdef NOCURSES
  10494.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10495. #endif /* NOCURSES */
  10496. #ifdef NOSERVER
  10497.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10498. #endif /* NOSERVER */
  10499. #ifdef NOPATTERNS
  10500.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10501. #else
  10502. #ifdef PATTERNS
  10503.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10504. #endif /* PATTERNS */
  10505. #endif /* NOPATTERNS */
  10506. #ifdef NOCKEXEC
  10507.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10508. #else
  10509. #ifdef CKEXEC
  10510.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10511. #endif /* CKEXEC */
  10512. #endif /* NOCKEXEC */
  10513. #ifdef NOAUTODL
  10514.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10515. #endif /* NOAUTODL */
  10516. #ifdef NOMSEND
  10517.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10518. #endif /* NOMSEND */
  10519. #ifdef NOFDZERO
  10520.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10521. #endif /* NOFDZERO */
  10522. #ifdef NOPOPEN
  10523.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10524. #endif /* NOPOPEN */
  10525. #ifdef NOPARTIAL
  10526.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10527. #endif /* NOPARTIAL */
  10528. #ifdef NOKVERBS
  10529.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10530. #endif /* NOKVERBS */
  10531. #ifdef NOSETREU
  10532.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10533. #endif /* NOSETREU */
  10534. #ifdef LCKDIR
  10535.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10536. #endif /* LCKDIR */
  10537. #ifdef ACUCNTRL
  10538.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10539. #endif /* ACUCNTRL */
  10540. #ifdef BSD4
  10541.     makestr(&(optlist[noptlist++]),"BSD4");
  10542. #endif /* BSD4 */
  10543. #ifdef BSD44
  10544.     makestr(&(optlist[noptlist++]),"BSD44");
  10545. #endif /* BSD44 */
  10546. #ifdef BSD41
  10547.     makestr(&(optlist[noptlist++]),"BSD41");
  10548. #endif /* BSD41 */
  10549. #ifdef BSD43
  10550.     makestr(&(optlist[noptlist++]),"BSD43");
  10551. #endif /* BSD43 */
  10552. #ifdef BSD29
  10553.     makestr(&(optlist[noptlist++]),"BSD29");
  10554. #endif /* BSD29 */
  10555. #ifdef BSDI
  10556.     makestr(&(optlist[noptlist++]),"BSDI");
  10557. #endif /* BSDI */
  10558. #ifdef __bsdi__
  10559.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10560. #endif /* __bsdi__ */
  10561. #ifdef __NetBSD__
  10562.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10563. #endif /* __NetBSD__ */
  10564. #ifdef __OpenBSD__
  10565.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10566. #endif /* __OpenBSD__ */
  10567. #ifdef __FreeBSD__
  10568.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10569. #endif /* __FreeBSD__ */
  10570. #ifdef __linux__
  10571.     makestr(&(optlist[noptlist++]),"__linux__");
  10572. #endif /* __linux__ */
  10573. #ifdef LINUX_HI_SPD
  10574.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10575. #endif /* LINUX_HI_SPD */
  10576. #ifdef LYNXOS
  10577.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10578. #endif /* LYNXOS */
  10579. #ifdef V7
  10580.     makestr(&(optlist[noptlist++]),"V7");
  10581. #endif /* V7 */
  10582. #ifdef AIX370
  10583.     makestr(&(optlist[noptlist++]),"AIX370");
  10584. #endif /* AIX370 */
  10585. #ifdef RTAIX
  10586.     makestr(&(optlist[noptlist++]),"RTAIX");
  10587. #endif /* RTAIX */
  10588. #ifdef HPUX
  10589.     makestr(&(optlist[noptlist++]),"HPUX");
  10590. #endif /* HPUX */
  10591. #ifdef HPUXPRE65
  10592.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10593. #endif /* HPUXPRE65 */
  10594. #ifdef DGUX
  10595.     makestr(&(optlist[noptlist++]),"DGUX");
  10596. #endif /* DGUX */
  10597. #ifdef DGUX430
  10598.     makestr(&(optlist[noptlist++]),"DGUX430");
  10599. #endif /* DGUX430 */
  10600. #ifdef DGUX540
  10601.     makestr(&(optlist[noptlist++]),"DGUX540");
  10602. #endif /* DGUX540 */
  10603. #ifdef DGUX543
  10604.     makestr(&(optlist[noptlist++]),"DGUX543");
  10605. #endif /* DGUX543 */
  10606. #ifdef DGUX54410
  10607.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10608. #endif /* DGUX54410 */
  10609. #ifdef DGUX54411
  10610.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10611. #endif /* DGUX54411 */
  10612. #ifdef sony_news
  10613.     makestr(&(optlist[noptlist++]),"sony_news");
  10614. #endif /* sony_news */
  10615. #ifdef CIE
  10616.     makestr(&(optlist[noptlist++]),"CIE");
  10617. #endif /* CIE */
  10618. #ifdef XENIX
  10619.     makestr(&(optlist[noptlist++]),"XENIX");
  10620. #endif /* XENIX */
  10621. #ifdef SCO_XENIX
  10622.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10623. #endif /* SCO_XENIX */
  10624. #ifdef ISIII
  10625.     makestr(&(optlist[noptlist++]),"ISIII");
  10626. #endif /* ISIII */
  10627. #ifdef I386IX
  10628.     makestr(&(optlist[noptlist++]),"I386IX");
  10629. #endif /* I386IX */
  10630. #ifdef RTU
  10631.     makestr(&(optlist[noptlist++]),"RTU");
  10632. #endif /* RTU */
  10633. #ifdef PROVX1
  10634.     makestr(&(optlist[noptlist++]),"PROVX1");
  10635. #endif /* PROVX1 */
  10636. #ifdef PYRAMID
  10637.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10638. #endif /* PYRAMID */
  10639. #ifdef TOWER1
  10640.     makestr(&(optlist[noptlist++]),"TOWER1");
  10641. #endif /* TOWER1 */
  10642. #ifdef UTEK
  10643.     makestr(&(optlist[noptlist++]),"UTEK");
  10644. #endif /* UTEK */
  10645. #ifdef ZILOG
  10646.     makestr(&(optlist[noptlist++]),"ZILOG");
  10647. #endif /* ZILOG */
  10648. #ifdef TRS16
  10649.     makestr(&(optlist[noptlist++]),"TRS16");
  10650. #endif /* TRS16 */
  10651. #ifdef MINIX
  10652.     makestr(&(optlist[noptlist++]),"MINIX");
  10653. #endif /* MINIX */
  10654. #ifdef MINIX2
  10655.     makestr(&(optlist[noptlist++]),"MINIX2");
  10656. #endif /* MINIX2 */
  10657. #ifdef MINIX3
  10658.     makestr(&(optlist[noptlist++]),"MINIX3");
  10659. #endif /* MINIX3 */
  10660. #ifdef C70
  10661.     makestr(&(optlist[noptlist++]),"C70");
  10662. #endif /* C70 */
  10663. #ifdef AIXPS2
  10664.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10665. #endif /* AIXPS2 */
  10666. #ifdef AIXRS
  10667.     makestr(&(optlist[noptlist++]),"AIXRS");
  10668. #endif /* AIXRS */
  10669. #ifdef UTSV
  10670.     makestr(&(optlist[noptlist++]),"UTSV");
  10671. #endif /* UTSV */
  10672. #ifdef ATTSV
  10673.     makestr(&(optlist[noptlist++]),"ATTSV");
  10674. #endif /* ATTSV */
  10675. #ifdef SVR3
  10676.     makestr(&(optlist[noptlist++]),"SVR3");
  10677. #endif /* SVR3 */
  10678. #ifdef SVR4
  10679.     makestr(&(optlist[noptlist++]),"SVR4");
  10680. #endif /* SVR4 */
  10681. #ifdef DELL_SVR4
  10682.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10683. #endif /* DELL_SVR4 */
  10684. #ifdef ICL_SVR4
  10685.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10686. #endif /* ICL_SVR4 */
  10687. #ifdef OSF
  10688.     makestr(&(optlist[noptlist++]),"OSF");
  10689. #endif /* OSF */
  10690. #ifdef OSF1
  10691.     makestr(&(optlist[noptlist++]),"OSF1");
  10692. #endif /* OSF1 */
  10693. #ifdef __OSF
  10694.     makestr(&(optlist[noptlist++]),"__OSF");
  10695. #endif /* __OSF */
  10696. #ifdef __OSF__
  10697.     makestr(&(optlist[noptlist++]),"__OSF__");
  10698. #endif /* __OSF__ */
  10699. #ifdef __osf__
  10700.     makestr(&(optlist[noptlist++]),"__osf__");
  10701. #endif /* __osf__ */
  10702. #ifdef __OSF1
  10703.     makestr(&(optlist[noptlist++]),"__OSF1");
  10704. #endif /* __OSF1 */
  10705. #ifdef __OSF1__
  10706.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10707. #endif /* __OSF1__ */
  10708. #ifdef PTX
  10709.     makestr(&(optlist[noptlist++]),"PTX");
  10710. #endif /* PTX */
  10711. #ifdef POSIX
  10712.     makestr(&(optlist[noptlist++]),"POSIX");
  10713. #endif /* POSIX */
  10714. #ifdef BSD44ORPOSIX
  10715.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10716. #endif /* BSD44ORPOSIX */
  10717. #ifdef SVORPOSIX
  10718.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10719. #endif /* SVORPOSIX */
  10720. #ifdef SVR4ORPOSIX
  10721.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10722. #endif /* SVR4ORPOSIX */
  10723. #ifdef OS2ORVMS
  10724.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10725. #endif /* OS2ORVMS */
  10726. #ifdef OS2ORUNIX
  10727.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10728. #endif /* OS2ORUNIX */
  10729. #ifdef VMSORUNIX
  10730.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10731. #endif /* VMSORUNIX */
  10732. #ifdef VMS64BIT
  10733.     makestr(&(optlist[noptlist++]),"VMS64BIT");    /* VMS on Alpha or IA64 */
  10734. #endif /* VMS64BIT */
  10735. #ifdef VMSI64
  10736.     makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
  10737. #endif /* VMSI64 */
  10738. #ifdef _POSIX_SOURCE
  10739.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10740. #endif /* _POSIX_SOURCE */
  10741. #ifdef _XOPEN_SOURCE
  10742.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10743. #endif
  10744. #ifdef _ALL_SOURCE
  10745.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10746. #endif
  10747. #ifdef _SVID3
  10748.     makestr(&(optlist[noptlist++]),"_SVID3");
  10749. #endif /* _SVID3 */
  10750. #ifdef Plan9
  10751.     makestr(&(optlist[noptlist++]),"Plan9");
  10752. #endif /* Plan9 */
  10753. #ifdef SOLARIS
  10754.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10755. #ifdef SOLARIS24
  10756.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10757. #endif /* SOLARIS24 */
  10758. #ifdef SOLARIS25
  10759.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10760. #endif /* SOLARIS25 */
  10761. #ifdef SOLARIS26
  10762.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10763. #endif /* SOLARIS26 */
  10764. #ifdef SOLARIS7
  10765.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10766. #endif /* SOLARIS7 */
  10767. #ifdef SOLARIS8
  10768.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10769. #endif /* SOLARIS8 */
  10770. #ifdef SOLARIS9
  10771.     makestr(&(optlist[noptlist++]),"SOLARIS9");
  10772. #endif /* SOLARIS9 */
  10773. #ifdef SOLARIS10
  10774.     makestr(&(optlist[noptlist++]),"SOLARIS10");
  10775. #endif /* SOLARIS10 */
  10776. #endif /* SOLARIS */
  10777.  
  10778. #ifdef SUNOS4
  10779.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10780. #endif /* SUNOS4 */
  10781. #ifdef SUN4S5
  10782.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10783. #endif /* SUN4S5 */
  10784. #ifdef IRIX
  10785.     makestr(&(optlist[noptlist++]),"IRIX");
  10786. #endif /* IRIX */
  10787. #ifdef ENCORE
  10788.     makestr(&(optlist[noptlist++]),"ENCORE");
  10789. #endif /* ENCORE */
  10790. #ifdef ultrix
  10791.     makestr(&(optlist[noptlist++]),"ultrix");
  10792. #endif
  10793. #ifdef sxaE50
  10794.     makestr(&(optlist[noptlist++]),"sxaE50");
  10795. #endif
  10796. #ifdef mips
  10797.     makestr(&(optlist[noptlist++]),"mips");
  10798. #endif
  10799. #ifdef MIPS
  10800.     makestr(&(optlist[noptlist++]),"MIPS");
  10801. #endif
  10802. #ifdef vax
  10803.     makestr(&(optlist[noptlist++]),"vax");
  10804. #endif
  10805. #ifdef VAX
  10806.     makestr(&(optlist[noptlist++]),"VAX");
  10807. #endif
  10808. #ifdef alpha
  10809.     makestr(&(optlist[noptlist++]),"alpha");
  10810. #endif
  10811. #ifdef ALPHA
  10812.     makestr(&(optlist[noptlist++]),"ALPHA");
  10813. #endif
  10814. #ifdef __ALPHA
  10815.     makestr(&(optlist[noptlist++]),"__ALPHA");
  10816. #endif
  10817. #ifdef __alpha
  10818.     makestr(&(optlist[noptlist++]),"__alpha");
  10819. #endif
  10820. #ifdef __AXP
  10821.     makestr(&(optlist[noptlist++]),"__AXP");
  10822. #endif
  10823. #ifdef AXP
  10824.     makestr(&(optlist[noptlist++]),"AXP");
  10825. #endif
  10826. #ifdef axp
  10827.     makestr(&(optlist[noptlist++]),"axp");
  10828. #endif
  10829. #ifdef __ALPHA__
  10830.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  10831. #endif
  10832. #ifdef __alpha__
  10833.     makestr(&(optlist[noptlist++]),"__alpha__");
  10834. #endif
  10835. #ifdef sun
  10836.     makestr(&(optlist[noptlist++]),"sun");
  10837. #endif
  10838. #ifdef sun3
  10839.     makestr(&(optlist[noptlist++]),"sun3");
  10840. #endif
  10841. #ifdef sun386
  10842.     makestr(&(optlist[noptlist++]),"sun386");
  10843. #endif
  10844. #ifdef _SUN
  10845.     makestr(&(optlist[noptlist++]),"_SUN");
  10846. #endif
  10847. #ifdef sun4
  10848.     makestr(&(optlist[noptlist++]),"sun4");
  10849. #endif
  10850. #ifdef sparc
  10851.     makestr(&(optlist[noptlist++]),"sparc");
  10852. #endif
  10853. #ifdef _CRAY
  10854.     makestr(&(optlist[noptlist++]),"_CRAY");
  10855. #endif /* _CRAY */
  10856. #ifdef NEXT33
  10857.     makestr(&(optlist[noptlist++]),"NEXT33");
  10858. #endif
  10859. #ifdef NEXT
  10860.     makestr(&(optlist[noptlist++]),"NEXT");
  10861. #endif
  10862. #ifdef NeXT
  10863.     makestr(&(optlist[noptlist++]),"NeXT");
  10864. #endif
  10865. #ifdef MACH
  10866.     makestr(&(optlist[noptlist++]),"MACH");
  10867. #endif
  10868.  
  10869. #ifdef MACOSX
  10870.     makestr(&(optlist[noptlist++]),"MACOSX");
  10871. #endif
  10872. #ifdef MACOSX10
  10873.     makestr(&(optlist[noptlist++]),"MACOSX10");
  10874. #endif
  10875. #ifdef MACOSX103
  10876.     makestr(&(optlist[noptlist++]),"MACOSX103");
  10877. #endif
  10878.  
  10879. #ifdef sgi
  10880.     makestr(&(optlist[noptlist++]),"sgi");
  10881. #endif
  10882. #ifdef M_SYS5
  10883.     makestr(&(optlist[noptlist++]),"M_SYS5");
  10884. #endif
  10885. #ifdef __SYSTEM_FIVE
  10886.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  10887. #endif
  10888. #ifdef sysV
  10889.     makestr(&(optlist[noptlist++]),"sysV");
  10890. #endif
  10891. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  10892.     makestr(&(optlist[noptlist++]),"M_XENIX");
  10893. #endif
  10894. #ifdef M_UNIX                           /* SCO UNIX */
  10895.     makestr(&(optlist[noptlist++]),"M_UNIX");
  10896. #endif
  10897. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  10898.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  10899. #endif
  10900. #ifdef CK_SCOV5
  10901.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  10902. #endif
  10903. #ifdef SCO_OSR504
  10904.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  10905. #endif
  10906. #ifdef M_IA64
  10907.     makestr(&(optlist[noptlist++]),"M_IA64");
  10908. #endif
  10909. #ifdef _M_IA64
  10910.     makestr(&(optlist[noptlist++]),"_M_IA64");
  10911. #endif
  10912. #ifdef ia64
  10913.     makestr(&(optlist[noptlist++]),"ia64");
  10914. #endif
  10915. #ifdef _ia64
  10916.     makestr(&(optlist[noptlist++]),"_ia64");
  10917. #endif
  10918. #ifdef _ia64_
  10919.     makestr(&(optlist[noptlist++]),"_ia64_");
  10920. #endif
  10921. #ifdef __ia64
  10922.     makestr(&(optlist[noptlist++]),"__ia64");
  10923. #endif
  10924. #ifdef M_I686
  10925.     makestr(&(optlist[noptlist++]),"M_I686");
  10926. #endif
  10927. #ifdef _M_I686
  10928.     makestr(&(optlist[noptlist++]),"_M_I686");
  10929. #endif
  10930. #ifdef i686
  10931.     makestr(&(optlist[noptlist++]),"i686");
  10932. #endif
  10933. #ifdef M_I586
  10934.     makestr(&(optlist[noptlist++]),"M_I586");
  10935. #endif
  10936. #ifdef _M_I586
  10937.     makestr(&(optlist[noptlist++]),"_M_I586");
  10938. #endif
  10939. #ifdef i586
  10940.     makestr(&(optlist[noptlist++]),"i586");
  10941. #endif
  10942. #ifdef M_I486
  10943.     makestr(&(optlist[noptlist++]),"M_I486");
  10944. #endif
  10945. #ifdef _M_I486
  10946.     makestr(&(optlist[noptlist++]),"_M_I486");
  10947. #endif
  10948. #ifdef i486
  10949.     makestr(&(optlist[noptlist++]),"i486");
  10950. #endif
  10951. #ifdef M_I386
  10952.     makestr(&(optlist[noptlist++]),"M_I386");
  10953. #endif
  10954. #ifdef _M_I386
  10955.     makestr(&(optlist[noptlist++]),"_M_I386");
  10956. #endif
  10957. #ifdef i386
  10958.     makestr(&(optlist[noptlist++]),"i386");
  10959. #endif
  10960. #ifdef __i386
  10961.     makestr(&(optlist[noptlist++]),"__i386");
  10962. #endif
  10963. #ifdef __x86
  10964.     makestr(&(optlist[noptlist++]),"__x86");
  10965. #endif
  10966. #ifdef __amd64
  10967.     makestr(&(optlist[noptlist++]),"__amd64");
  10968. #endif
  10969. #ifdef _ILP32
  10970.     makestr(&(optlist[noptlist++]),"_ILP32");
  10971. #endif
  10972. #ifdef _ILP64
  10973.     makestr(&(optlist[noptlist++]),"_ILP64");
  10974. #endif
  10975. #ifdef _LP32
  10976.     makestr(&(optlist[noptlist++]),"_LP32");
  10977. #endif
  10978. #ifdef _LP64
  10979.     makestr(&(optlist[noptlist++]),"_LP64");
  10980. #endif
  10981. #ifdef __LP32__
  10982.     makestr(&(optlist[noptlist++]),"__LP32__");
  10983. #endif
  10984. #ifdef __LP64__
  10985.     makestr(&(optlist[noptlist++]),"__LP64__");
  10986. #endif
  10987. #ifdef __ppc__
  10988.     makestr(&(optlist[noptlist++]),"__ppc__");
  10989. #endif
  10990. #ifdef __ppc32__
  10991.     makestr(&(optlist[noptlist++]),"__ppc32__");
  10992. #endif
  10993. #ifdef __ppc64__
  10994.     makestr(&(optlist[noptlist++]),"__ppc64__");
  10995. #endif
  10996. #ifdef CK_64BIT
  10997.     makestr(&(optlist[noptlist++]),"CK_64BIT");
  10998. #endif
  10999. #ifdef i286
  11000.     makestr(&(optlist[noptlist++]),"i286");
  11001. #endif
  11002. #ifdef M_I286
  11003.     makestr(&(optlist[noptlist++]),"M_I286");
  11004. #endif
  11005. #ifdef __sparc
  11006.     makestr(&(optlist[noptlist++]),"__sparc");
  11007. #endif
  11008. #ifdef __sparcv8
  11009.     makestr(&(optlist[noptlist++]),"__sparcv8");
  11010. #endif
  11011. #ifdef __sparcv9
  11012.     makestr(&(optlist[noptlist++]),"__sparcv9");
  11013. #endif
  11014. #ifdef mc68000
  11015.     makestr(&(optlist[noptlist++]),"mc68000");
  11016. #endif
  11017. #ifdef mc68010
  11018.     makestr(&(optlist[noptlist++]),"mc68010");
  11019. #endif
  11020. #ifdef mc68020
  11021.     makestr(&(optlist[noptlist++]),"mc68020");
  11022. #endif
  11023. #ifdef mc68030
  11024.     makestr(&(optlist[noptlist++]),"mc68030");
  11025. #endif
  11026. #ifdef mc68040
  11027.     makestr(&(optlist[noptlist++]),"mc68040");
  11028. #endif
  11029. #ifdef M_68000
  11030.     makestr(&(optlist[noptlist++]),"M_68000");
  11031. #endif
  11032. #ifdef M_68010
  11033.     makestr(&(optlist[noptlist++]),"M_68010");
  11034. #endif
  11035. #ifdef M_68020
  11036.     makestr(&(optlist[noptlist++]),"M_68020");
  11037. #endif
  11038. #ifdef M_68030
  11039.     makestr(&(optlist[noptlist++]),"M_68030");
  11040. #endif
  11041. #ifdef M_68040
  11042.     makestr(&(optlist[noptlist++]),"M_68040");
  11043. #endif
  11044. #ifdef m68k
  11045.     makestr(&(optlist[noptlist++]),"m68k");
  11046. #endif
  11047. #ifdef m88k
  11048.     makestr(&(optlist[noptlist++]),"m88k");
  11049. #endif
  11050. #ifdef pdp11
  11051.     makestr(&(optlist[noptlist++]),"pdp11");
  11052. #endif
  11053. #ifdef iAPX
  11054.     makestr(&(optlist[noptlist++]),"iAPX");
  11055. #endif
  11056. #ifdef hpux
  11057.     makestr(&(optlist[noptlist++]),"hpux");
  11058. #endif
  11059. #ifdef __hpux
  11060.     makestr(&(optlist[noptlist++]),"__hpux");
  11061. #endif
  11062. #ifdef __hp9000s800
  11063.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  11064. #endif
  11065. #ifdef __hp9000s700
  11066.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  11067. #endif
  11068. #ifdef __hp9000s500
  11069.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  11070. #endif
  11071. #ifdef __hp9000s300
  11072.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  11073. #endif
  11074. #ifdef __hp9000s200
  11075.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  11076. #endif
  11077. #ifdef AIX
  11078.     makestr(&(optlist[noptlist++]),"AIX");
  11079. #endif
  11080. #ifdef _AIXFS
  11081.     makestr(&(optlist[noptlist++]),"_AIXFS");
  11082. #endif
  11083. #ifdef u370
  11084.     makestr(&(optlist[noptlist++]),"u370");
  11085. #endif
  11086. #ifdef u3b
  11087.     makestr(&(optlist[noptlist++]),"u3b");
  11088. #endif
  11089. #ifdef u3b2
  11090.     makestr(&(optlist[noptlist++]),"u3b2");
  11091. #endif
  11092. #ifdef multimax
  11093.     makestr(&(optlist[noptlist++]),"multimax");
  11094. #endif
  11095. #ifdef balance
  11096.     makestr(&(optlist[noptlist++]),"balance");
  11097. #endif
  11098. #ifdef ibmrt
  11099.     makestr(&(optlist[noptlist++]),"ibmrt");
  11100. #endif
  11101. #ifdef _IBMRT
  11102.     makestr(&(optlist[noptlist++]),"_IBMRT");
  11103. #endif
  11104. #ifdef ibmrs6000
  11105.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  11106. #endif
  11107. #ifdef _AIX
  11108.     makestr(&(optlist[noptlist++]),"_AIX");
  11109. #endif /* _AIX */
  11110. #ifdef _IBMR2
  11111.     makestr(&(optlist[noptlist++]),"_IBMR2");
  11112. #endif
  11113. #ifdef UNIXWARE
  11114.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  11115. #endif
  11116. #ifdef QNX
  11117.     makestr(&(optlist[noptlist++]),"QNX");
  11118. #ifdef __QNX__
  11119.     makestr(&(optlist[noptlist++]),"__QNX__");
  11120. #ifdef __16BIT__
  11121.     makestr(&(optlist[noptlist++]),"__16BIT__");
  11122. #endif
  11123. #ifdef CK_QNX16
  11124.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  11125. #endif
  11126. #ifdef __32BIT__
  11127.     makestr(&(optlist[noptlist++]),"__32BIT__");
  11128. #endif
  11129. #ifdef CK_QNX32
  11130.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  11131. #endif
  11132. #endif /* __QNX__ */
  11133. #endif /* QNX */
  11134.  
  11135. #ifdef QNX6
  11136.     makestr(&(optlist[noptlist++]),"QNX6");
  11137. #endif /* QNX6 */
  11138.  
  11139. #ifdef NEUTRINO
  11140.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  11141. #endif /* NEUTRINO */
  11142.  
  11143. #ifdef __STRICT_BSD__
  11144.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  11145. #endif
  11146. #ifdef __STRICT_ANSI__
  11147.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  11148. #endif
  11149. #ifdef _ANSI_C_SOURCE
  11150.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  11151. #endif
  11152. #ifdef __STDC__
  11153.     makestr(&(optlist[noptlist++]),"__STDC__");
  11154. #endif
  11155. #ifdef __DECC
  11156.     makestr(&(optlist[noptlist++]),"__DECC");
  11157. #ifdef __DECC_VER
  11158.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  11159.     makestr(&(optlist[noptlist++]),line);
  11160. #endif /* __DECC_VER */
  11161. #endif /* __DECC */
  11162. #ifdef __CRTL_VER
  11163.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  11164.     makestr(&(optlist[noptlist++]),line);
  11165. #endif /* __CRTL_VER */
  11166. #ifdef __GNUC__                         /* gcc in ansi mode */
  11167.     makestr(&(optlist[noptlist++]),"__GNUC__");
  11168. #endif
  11169. #ifdef GNUC                             /* gcc in traditional mode */
  11170.     makestr(&(optlist[noptlist++]),"GNUC");
  11171. #endif
  11172. #ifdef __EGCS__                         /* egcs in ansi mode */
  11173.     makestr(&(optlist[noptlist++]),"__EGCS__");
  11174. #endif
  11175. #ifdef __egcs__                         /* egcs in ansi mode */
  11176.     makestr(&(optlist[noptlist++]),"__egcs__");
  11177. #endif
  11178. #ifdef __WATCOMC__
  11179.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  11180. #endif
  11181. #ifdef CK_ANSIC
  11182.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  11183. #endif
  11184. #ifdef CK_ANSILIBS
  11185.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  11186. #endif
  11187. #ifdef CKCONINTB4CB
  11188.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  11189. #endif /* CKCONINTB4CB */
  11190. #ifdef NOTERMCAP
  11191.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  11192. #endif /* NOTERMCAP */
  11193. #ifdef __GLIBC__
  11194.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  11195. #endif
  11196. #ifdef _SC_JOB_CONTROL
  11197.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  11198. #endif
  11199. #ifdef _POSIX_JOB_CONTROL
  11200.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  11201. #endif
  11202. #ifdef SIG_I
  11203.     makestr(&(optlist[noptlist++]),"SIG_I");
  11204. #endif /* SIG_I */
  11205. #ifdef SIG_V
  11206.     makestr(&(optlist[noptlist++]),"SIG_V");
  11207. #endif /* SIG_V */
  11208. #ifdef CK_POSIX_SIG
  11209.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  11210. #endif
  11211. #ifdef SVR3JC
  11212.     makestr(&(optlist[noptlist++]),"SVR3JC");
  11213. #endif
  11214. #ifdef _386BSD
  11215.     makestr(&(optlist[noptlist++]),"_386BSD");
  11216. #endif
  11217. #ifdef _BSD
  11218.     makestr(&(optlist[noptlist++]),"_BSD");
  11219. #endif
  11220. #ifdef USE_MEMCPY
  11221.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  11222. #endif /* USE_MEMCPY */
  11223. #ifdef USE_LSTAT
  11224.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  11225. #endif /* USE_LSTAT */
  11226. #ifdef TERMIOX
  11227.     makestr(&(optlist[noptlist++]),"TERMIOX");
  11228. #endif /* TERMIOX */
  11229. #ifdef STERMIOX
  11230.     makestr(&(optlist[noptlist++]),"STERMIOX");
  11231. #endif /* STERMIOX */
  11232. #ifdef CK_CURSES
  11233.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  11234. #endif /* CK_CURSES */
  11235. #ifdef CK_NEWTERM
  11236.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  11237. #endif /* CK_NEWTERM */
  11238. #ifdef CK_WREFRESH
  11239.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  11240. #endif /* CK_WREFRESH */
  11241. #ifdef CK_PCT_BAR
  11242.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  11243. #endif /* CK_PCT_BAR */
  11244. #ifdef CK_DTRCD
  11245.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  11246. #endif /* CK_DTRCD */
  11247. #ifdef CK_DTRCTS
  11248.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  11249. #endif /* CK_DTRCTS */
  11250. #ifdef CK_RTSCTS
  11251.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  11252. #endif /* CK_RTSCTS */
  11253. #ifdef POSIX_CRTSCTS
  11254.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  11255. #endif /* POSIX_CRTSCTS */
  11256. #ifdef FIXCRTSCTS
  11257.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  11258. #endif /* FIXCRTSCTS */
  11259. #ifdef HWPARITY
  11260.     makestr(&(optlist[noptlist++]),"HWPARITY");
  11261. #endif /* HWPARITY */
  11262. #ifdef CK_SYSINI
  11263. #ifdef CK_INI_A
  11264.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  11265.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11266.     makestr(&(optlist[noptlist++]),line);
  11267. #else
  11268. #ifdef CK_INI_B
  11269.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  11270.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  11271.     makestr(&(optlist[noptlist++]),line);
  11272. #else
  11273.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  11274. #endif /* CK_INI_B */
  11275. #endif /* CK_INI_A */
  11276. #endif /* CK_DSYSINI */
  11277. #ifdef CK_DSYSINI
  11278.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  11279. #endif /* CK_DSYSINI */
  11280. #ifdef CK_TTGWSIZ
  11281.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  11282. #endif /* CK_TTGWSIZ */
  11283. #ifdef CK_NAWS
  11284.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  11285. #endif /* CK_NAWS */
  11286. #ifdef MDMHUP
  11287.     makestr(&(optlist[noptlist++]),"MDMHUP");
  11288. #endif /* MDMHUP */
  11289. #ifdef HUP_CLOSE_POSIX
  11290.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  11291. #endif /* HUP_CLOSE_POSIX */
  11292. #ifdef NO_HUP_CLOSE_POSIX
  11293.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  11294. #endif /* NO_HUP_CLOSE_POSIX */
  11295. #ifdef DCMDBUF
  11296.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  11297. #endif /* DCMDBUF */
  11298. #ifdef CK_RECALL
  11299.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  11300. #endif /* CK_RECALL */
  11301. #ifdef BROWSER
  11302.     makestr(&(optlist[noptlist++]),"BROWSER");
  11303. #endif /* BROWSER */
  11304. #ifdef CLSOPN
  11305.     makestr(&(optlist[noptlist++]),"CLSOPN");
  11306. #endif /* CLSOPN */
  11307. #ifdef STRATUS
  11308.     makestr(&(optlist[noptlist++]),"STRATUS");
  11309. #endif /* STRATUS */
  11310. #ifdef __VOS__
  11311.     makestr(&(optlist[noptlist++]),"__VOS__");
  11312. #endif /* __VOS__ */
  11313. #ifdef STRATUSX25
  11314.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  11315. #endif /* STRATUSX25 */
  11316. #ifdef OS2MOUSE
  11317.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  11318. #endif /* OS2MOUSE */
  11319. #ifdef CK_REXX
  11320.     makestr(&(optlist[noptlist++]),"CK_REXX");
  11321. #endif /* CK_REXX */
  11322. #ifdef CK_TIMERS
  11323.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  11324. #endif /* CK_TIMERS */
  11325. #ifdef TTSPDLIST
  11326.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  11327. #endif /* TTSPDLIST */
  11328. #ifdef CK_PERMS
  11329.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  11330. #endif /* CK_PERMS */
  11331. #ifdef CKTUNING
  11332.     makestr(&(optlist[noptlist++]),"CKTUNING");
  11333. #endif /* CKTUNING */
  11334. #ifdef NEWFTP
  11335.     makestr(&(optlist[noptlist++]),"NEWFTP");
  11336. #endif /* NEWFTP */
  11337. #ifdef SYSFTP
  11338.     makestr(&(optlist[noptlist++]),"SYSFTP");
  11339. #endif /* SYSFTP */
  11340. #ifdef NOFTP
  11341.     makestr(&(optlist[noptlist++]),"NOFTP");
  11342. #endif /* NOFTP */
  11343. #ifdef CKHTTP
  11344.     makestr(&(optlist[noptlist++]),"CKHTTP");
  11345. #endif /* CKHTTP */
  11346. #ifdef NOHTTP
  11347.     makestr(&(optlist[noptlist++]),"NOHTTP");
  11348. #endif /* NOHTTP */
  11349. #ifdef CKROOT
  11350.     makestr(&(optlist[noptlist++]),"CKROOT");
  11351. #endif /* CKROOT */
  11352. #ifdef CKREALPATH
  11353.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  11354. #endif /* CKREALPATH */
  11355. #ifdef STREAMING
  11356.     makestr(&(optlist[noptlist++]),"STREAMING");
  11357. #endif /* STREAMING */
  11358. #ifdef UNPREFIXZERO
  11359.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11360. #endif /* UNPREFIXZERO */
  11361. #ifdef CKREGEX
  11362.     makestr(&(optlist[noptlist++]),"CKREGEX");
  11363. #endif /* CKREGEX */
  11364. #ifdef ZXREWIND
  11365.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  11366. #endif /* ZXREWIND */
  11367. #ifdef CKSYSLOG
  11368.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11369. #endif /* CKSYSLOG */
  11370. #ifdef SYSLOGLEVEL
  11371.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11372.     makestr(&(optlist[noptlist++]),line);
  11373. #endif /* SYSLOGLEVEL */
  11374. #ifdef NOSEXP
  11375.     makestr(&(optlist[noptlist++]),"NOSEXP");
  11376. #endif /* NOSEXP */
  11377. #ifdef CKLEARN
  11378.     makestr(&(optlist[noptlist++]),"CKLEARN");
  11379. #else
  11380. #ifdef NOLOEARN
  11381.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  11382. #endif /* NOLOEARN */
  11383. #endif /* CKLEARN */
  11384.  
  11385. #ifdef NOFLOAT
  11386.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  11387. #else
  11388. #ifdef FNFLOAT
  11389.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  11390. #endif /* FNFLOAT */
  11391. #ifdef CKFLOAT
  11392. #ifdef GFTIMER
  11393.     makestr(&(optlist[noptlist++]),"GFTIMER");
  11394. #endif /* GFTIMER */
  11395. #ifdef CKFLOAT_S
  11396.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11397.     makestr(&(optlist[noptlist++]),line);
  11398. #else
  11399.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  11400. #endif /* CKFLOAT_S */
  11401. #endif /* CKFLOAT */
  11402. #endif /* NOFLOAT */
  11403.  
  11404. #ifdef SSH
  11405.     makestr(&(optlist[noptlist++]),"SSH");
  11406. #endif /* SSH */
  11407. #ifdef NETDLL
  11408.     makestr(&(optlist[noptlist++]),"NETDLL");
  11409. #endif /* NETDLL */
  11410. #ifdef NETFILE
  11411.     makestr(&(optlist[noptlist++]),"NETFILE");
  11412. #endif /* NETFILE */
  11413. #ifdef CK_TAPI
  11414.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  11415. #endif /* CK_TAPI */
  11416. #ifdef CK_SSL
  11417.     makestr(&(optlist[noptlist++]),"CK_SSL");
  11418. #endif /* CK_SSL */
  11419.  
  11420.     debug(F101,"initoptlist noptlist","",noptlist);
  11421.     sh_sort(optlist,NULL,noptlist,0,0,0);
  11422. }
  11423.  
  11424. int
  11425. shofea() {
  11426.     int i;
  11427.     int flag = 0;
  11428.     int lines = 1;
  11429. #ifdef FNFLOAT
  11430.     extern int fp_digits, fp_rounding;
  11431. #endif /* FNFLOAT */
  11432.     extern int byteorder;
  11433.     printf("%s\n",versio);
  11434.     if (inserver)
  11435.       return(1);
  11436.  
  11437.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11438.     initoptlist();
  11439.     debug(F101,"shofea noptlist","",noptlist);
  11440. #ifdef OS2
  11441. #ifdef NT
  11442. #ifdef _M_ALPHA
  11443.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11444. #else /* _M_ALPHA */
  11445. #ifdef _M_PPC
  11446.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11447. #else /* _M_PPC */
  11448. #ifdef _M_MRX000
  11449.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11450. #else /* _M_MRX000 */
  11451. #ifdef _M_IX86
  11452.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11453. #else /* _M_IX86 */
  11454.     UNKNOWN WINDOWS PLATFORM
  11455. #endif /* _M_IX86 */
  11456. #endif /* _M_MRX000 */
  11457. #endif /* _M_PPC */
  11458. #endif /* _M_ALPHA */
  11459. #else /* NT */
  11460. #ifdef M_I286
  11461.     printf("IBM OS/2 16-bit.\n");
  11462. #else
  11463.     printf("IBM OS/2 32-bit.\n");
  11464. #endif /* M_I286 */
  11465. #endif /* NT */
  11466.     lines++;
  11467. #endif /* OS2 */
  11468.     printf("\n");
  11469.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11470.     printf("Major optional features included:\n");
  11471.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11472.  
  11473. #ifdef NETCONN
  11474.     printf(" Network support (type SHOW NET for further info)\n");
  11475.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11476. #ifdef IKS_OPTION
  11477.     printf(" Telnet Kermit Option\n");
  11478.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11479. #endif /* IKS_OPTION */
  11480. #ifdef CK_AUTHENTICATION
  11481.     printf(" Telnet Authentication Option\n");
  11482.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11483. #ifdef CK_KERBEROS
  11484. #ifdef KRB4
  11485. #ifdef KRB5
  11486.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11487.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11488. #else /* KRB5 */
  11489.     printf(" Kerberos(TM) IV authentication\n");
  11490.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11491. #endif /* KRB5 */
  11492. #else /* KRB4 */
  11493. #ifdef KRB5
  11494.     printf(" Kerberos(TM) V authentication\n");
  11495.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11496. #endif /* KRB5 */
  11497. #endif /* KRB4 */
  11498. #endif /* CK_KERBEROS */
  11499. #ifdef CK_SRP
  11500.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11501.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11502. #endif /* CK_SRP */
  11503. #ifdef CK_SSL
  11504.     printf(" Secure Sockets Layer (SSL)\n");
  11505.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11506.     printf(" Transport Layer Security (TLS)\n");
  11507.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11508. #endif /* CK_SSL */
  11509. #ifdef SSHBUILTIN
  11510.     printf(" Secure Shell (SSH) [internal]\n");
  11511.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11512. #endif /* SSHBUILTIN */
  11513. #ifdef SSHCMD
  11514.     printf(" Secure Shell (SSH) [external]\n");
  11515.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11516. #endif /* SSHCMD */
  11517. #ifdef CK_ENCRYPTION
  11518.     printf(" Telnet Encryption Option\n");
  11519.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11520. #ifdef CK_DES
  11521.     printf(" Telnet DES Encryption\n");
  11522.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11523. #endif /* CK_DES */
  11524. #ifdef CK_CAST
  11525.     printf(" Telnet CAST Encryption\n");
  11526.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11527. #endif /* CK_CAST */
  11528. #ifdef CK_KERBEROS
  11529. #ifdef KRB5
  11530. #ifdef ALLOW_KRB_3DES_ENCRYPT
  11531.     printf(" Kerberos 3DES/AES Telnet Encryption\n");
  11532.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11533. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11534. #endif /* KRB5 */
  11535. #endif /* CK_KERBEROS */
  11536. #endif /* CK_ENCRYPTION */
  11537. #endif /* CK_AUTHENTICATION */
  11538. #ifdef CK_FORWARD_X
  11539.     printf(" X Windows forwarding\n");
  11540.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11541. #endif /* CK_FORWARD_X */
  11542. #ifdef TN_COMPORT
  11543.     printf(" Telnet Remote Com Port Control Option\n");
  11544.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11545. #endif /* TN_COMPORT */
  11546. #ifdef CK_SOCKS
  11547. #ifdef CK_SOCKS5
  11548.     printf(" SOCKS 5\n");
  11549.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11550. #else /* CK_SOCKS5 */
  11551.     printf(" SOCKS 4\n");
  11552.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11553. #endif /* CK_SOCKS5 */
  11554. #endif /* CK_SOCKS */
  11555. #ifdef NEWFTP
  11556.     printf(" Built-in FTP client\n");
  11557.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11558. #endif /* NEWFTP */
  11559. #ifdef CKHTTP
  11560.     printf(" Built-in HTTP client\n");
  11561.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11562. #endif /* CKHTTP */
  11563. #endif /* NETCONN */
  11564.  
  11565. #ifdef CK_RTSCTS
  11566.     printf(" Hardware flow control\n");
  11567.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11568. #endif /* CK_RTSCTS */
  11569.  
  11570. #ifdef CK_XYZ
  11571. #ifdef XYZ_INTERNAL
  11572.     printf(" Built-in XYZMODEM protocols\n");
  11573. #else
  11574.     printf(" External XYZMODEM protocol support\n");
  11575. #endif /* XYZ_INTERNAL */
  11576.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11577. #endif /* CK_XYZ */
  11578.  
  11579. #ifndef NOCSETS
  11580.     printf(" Latin-1 (West European) character-set translation\n");
  11581.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11582. #ifdef LATIN2
  11583.     printf(" Latin-2 (East European) character-set translation\n");
  11584.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11585. #endif /* LATIN2 */
  11586. #ifdef CYRILLIC
  11587.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11588.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11589. #endif /* CYRILLIC */
  11590. #ifdef GREEK
  11591.     printf(" Greek character-set translation\n");
  11592.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11593. #endif /* GREEK */
  11594. #ifdef HEBREW
  11595.     printf(" Hebrew character-set translation\n");
  11596.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11597. #endif /* HEBREW */
  11598. #ifdef KANJI
  11599.     printf(" Japanese character-set translation\n");
  11600.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11601. #endif /* KANJI */
  11602. #ifdef UNICODE
  11603.     printf(" Unicode character-set translation\n");
  11604.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11605. #endif /* UNICODE */
  11606. #ifdef CKOUNI
  11607.     if (isunicode())
  11608.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11609.     else
  11610.       printf(" Unicode translation for Terminal Character-Sets\n");
  11611.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11612. #endif /* CKOUNI */
  11613. #endif /* NOCSETS */
  11614.  
  11615. #ifdef NETPTY
  11616.     printf(" Pseudoterminal control\n");
  11617.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11618. #endif /* NETPTY */
  11619.  
  11620. #ifdef CK_REDIR
  11621.     printf(" REDIRECT command\n");
  11622.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11623. #endif /* CK_REDIR */
  11624.  
  11625. #ifdef CK_RESEND
  11626.     printf(" RESEND command\n");
  11627.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11628. #endif /* CK_RESEND */
  11629.  
  11630. #ifndef NOXFER
  11631. #ifdef CK_CURSES
  11632.     printf(" Fullscreen file transfer display\n");
  11633.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11634. #endif /* CK_CURSES */
  11635. #endif /* NOXFER */
  11636.  
  11637. #ifdef CK_SPEED
  11638.     printf(" Control-character unprefixing\n");
  11639.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11640. #endif /* CK_SPEED */
  11641.  
  11642. #ifdef STREAMING
  11643.     printf(" Streaming\n");
  11644.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11645. #endif /* STREAMING */
  11646.  
  11647. #ifdef CK_AUTODL
  11648.     printf(" Autodownload\n");
  11649.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11650. #endif /* CK_AUTODL */
  11651.  
  11652. #ifdef OS2MOUSE
  11653.     printf(" Mouse support\n");
  11654.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11655. #endif /* OS2MOUSE */
  11656.  
  11657. #ifdef CK_REXX
  11658.     printf(" REXX script language interface\n");
  11659.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11660. #endif /* CK_REXX */
  11661.  
  11662. #ifdef IKSD
  11663. #ifdef CK_LOGIN
  11664.     printf(" Internet Kermit Service with user login support\n");
  11665. #else /* CK_LOGIN */
  11666.     printf(" Internet Kermit Service without user login support\n");
  11667. #endif /* CK_LOGIN */
  11668.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11669. #endif /* IKSD */
  11670.  
  11671.     printf("\n");
  11672.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11673.     printf("Major optional features not included:\n");
  11674.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11675.  
  11676. #ifdef NOXFER
  11677.     printf(" No file-transfer protocols\n");
  11678.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11679.     flag = 1;
  11680. #else
  11681. #ifndef CK_CURSES
  11682. #ifndef MAC
  11683.     printf(" No fullscreen file transfer display\n");
  11684.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11685.     flag = 1;
  11686. #endif /* MAC */
  11687. #endif /* CK_CURSES */
  11688.  
  11689. #ifdef NOSERVER
  11690.     printf(" No server mode\n");
  11691.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11692.     flag = 1;
  11693. #endif /* NOSERVER */
  11694.  
  11695. #ifndef CK_SPEED
  11696.     printf(" No control-character unprefixing\n");
  11697.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11698.     flag = 1;
  11699. #endif /* CK_SPEED */
  11700.  
  11701. #ifndef STREAMING
  11702.     printf(" No streaming\n");
  11703.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11704.     flag = 1;
  11705. #endif /* STREAMING */
  11706.  
  11707. #ifndef CK_AUTODL
  11708.     printf(" No autodownload\n");
  11709.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11710.     flag = 1;
  11711. #endif /* CK_AUTODL */
  11712.  
  11713. #ifndef CK_XYZ
  11714.     printf(" No built-in XYZMODEM protocols\n");
  11715.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11716.     flag = 1;
  11717. #endif /* CK_XYZ */
  11718.  
  11719. #ifdef NOTLOG
  11720.     printf(" No transaction log\n");
  11721.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11722.     flag = 1;
  11723. #endif /* NOTLOG */
  11724. #endif /* NOXFER */
  11725.  
  11726. #ifdef NODEBUG
  11727.     printf(" No debugging\n");
  11728.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11729.     flag = 1;
  11730. #endif /* NODEBUG */
  11731.  
  11732. #ifdef NOHELP
  11733.     printf(" No built-in help\n");
  11734.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11735.     flag = 1;
  11736. #endif /* NOHELP */
  11737.  
  11738. #ifdef NOLOCAL
  11739.     printf(" No making connections\n");
  11740.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11741.     flag = 1;
  11742. #else
  11743. #ifndef NETCONN
  11744.     printf(" No network support\n");
  11745.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11746.     flag = 1;
  11747. #else /* NETCONN */
  11748. #ifndef IKS_OPTION
  11749.     printf(" No Telnet Kermit Option\n");
  11750.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11751.     flag = 1;
  11752. #endif /* IKS_OPTION */
  11753. #endif /* NETCONN */
  11754.  
  11755. #ifdef NOSSH
  11756.     printf(" No Secure Shell (SSH)\n");
  11757.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11758. #endif /* NOSSH */
  11759. #ifndef CK_AUTHENTICATION
  11760.     printf(" No Kerberos(TM) authentication\n");
  11761.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11762.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11763.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11764.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11765.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11766.     printf(" No Transport Layer Security (TLS) protocol\n");
  11767.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11768.     printf(" No encryption\n");
  11769.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11770.     flag = 1;
  11771. #else /* CK_AUTHENTICATION */
  11772. #ifndef CK_KERBEROS
  11773.     printf(" No Kerberos(TM) authentication\n");
  11774.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11775.     flag = 1;
  11776. #else /* CK_KERBEROS */
  11777. #ifndef KRB4
  11778.     printf(" No Kerberos(TM) IV authentication\n");
  11779.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11780.     flag = 1;
  11781. #endif /* KRB4 */
  11782. #ifndef KRB5
  11783.     printf(" No Kerberos(TM) V authentication\n");
  11784.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11785.     flag = 1;
  11786. #endif /* KRB5 */
  11787. #endif /* CK_KERBEROS */
  11788. #ifndef CK_SRP
  11789.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11790.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11791.     flag = 1;
  11792. #endif /* CK_SRP */
  11793. #ifndef CK_SSL
  11794.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11795.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11796.     printf(" No Transport Layer Security (TLS) protocol\n");
  11797.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11798.     flag = 1;
  11799. #endif /* CK_SSL */
  11800. #ifndef CK_ENCRYPTION
  11801.     printf(" No Telnet Encryption Option\n");
  11802.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11803.     flag = 1;
  11804. #else /* CK_ENCRYPTION */
  11805. #ifndef OS2
  11806. #ifndef CK_DES
  11807.     printf(" No Telnet DES encryption\n");
  11808.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11809.     flag = 1;
  11810. #endif /* CK_DES */
  11811. #ifndef CK_CAST
  11812.     printf(" No Telnet CAST encryption\n");
  11813.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11814.     flag = 1;
  11815. #endif /* CK_CAST */
  11816. #ifdef CK_KERBEROS
  11817. #ifdef KRB5
  11818. #ifndef ALLOW_KRB_3DES_ENCRYPT
  11819.     printf(" No Kerberos 3DES/AES Telnet Encryption\n");
  11820.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11821. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11822. #endif /* KRB5 */
  11823. #endif /* CK_KERBEROS */
  11824. #endif /* OS2 */
  11825. #endif /* CK_ENCRYPTION */
  11826. #endif /* CK_AUTHENTICATION */
  11827. #ifndef CK_FORWARD_X
  11828.     printf(" No X Windows forwarding\n");
  11829.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11830. #endif /* CK_FORWARD_X */
  11831. #ifndef TN_COMPORT
  11832.     printf(" No Telnet Remote Com Port Control Option\n");
  11833.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11834. #endif /* TN_COMPORT */
  11835. #ifndef CK_SOCKS
  11836.     printf(" No SOCKS\n");
  11837.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11838. #endif /* CK_SOCKS */
  11839. #ifndef NEWFTP
  11840.     printf(" No built-in FTP client\n");
  11841.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11842. #endif /* NEWFTP */
  11843. #ifdef NOHTTP
  11844.     printf(" No built-in HTTP client\n");
  11845.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11846. #endif /* NOHTTP */
  11847.  
  11848. #ifdef NODIAL
  11849.     printf(" No DIAL command\n");
  11850.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11851.     flag = 1;
  11852. #else
  11853. #ifdef MINIDIAL
  11854.     printf(" Support for most modem types excluded\n");
  11855.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11856.     flag = 1;
  11857. #endif /* MINIDIAL */
  11858. #endif /* NODIAL */
  11859. #endif /* NOLOCAL */
  11860.  
  11861. #ifndef CK_RTSCTS
  11862. #ifndef MAC
  11863.     printf(" No hardware flow control\n");
  11864.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11865.     flag = 1;
  11866. #endif /* MAC */
  11867. #endif /* CK_RTSCTS */
  11868.  
  11869. #ifdef NOXMIT
  11870.     printf(" No TRANSMIT command\n");
  11871.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11872.     flag = 1;
  11873. #endif /* NOXMIT */
  11874.  
  11875. #ifdef NOSCRIPT
  11876.     printf(" No SCRIPT command\n");
  11877.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11878.     flag = 1;
  11879. #endif /* NOSCRIPT */
  11880.  
  11881. #ifdef NOSPL
  11882.     printf(" No script programming features\n");
  11883.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11884.     flag = 1;
  11885. #endif /* NOSPL */
  11886.  
  11887. #ifdef NOCSETS
  11888.     printf(" No character-set translation\n");
  11889.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11890.     flag = 1;
  11891. #else
  11892.  
  11893. #ifndef LATIN2
  11894.     printf(" No Latin-2 character-set translation\n");
  11895.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11896.     flag = 1;
  11897. #endif /* LATIN2 */
  11898.  
  11899. #ifdef NOGREEK
  11900.     printf(" No Greek character-set translation\n");
  11901.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11902.     flag = 1;
  11903. #endif /* NOGREEK */
  11904.  
  11905. #ifdef NOHEBREW
  11906.     printf(" No Hebrew character-set translation\n");
  11907.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11908.     flag = 1;
  11909. #endif /* NOHEBREW */
  11910.  
  11911. #ifdef NOUNICODE
  11912.     printf(" No Unicode character-set translation\n");
  11913.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11914.     flag = 1;
  11915. #endif /* NOUNICODE */
  11916.  
  11917. #ifdef NOCYRIL
  11918.     printf(" No Cyrillic character-set translation\n");
  11919.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11920.     flag = 1;
  11921. #endif /* NOCYRIL */
  11922.  
  11923. #ifndef KANJI
  11924.     printf(" No Kanji character-set translation\n");
  11925.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11926.     flag = 1;
  11927. #endif /* KANJI */
  11928. #endif /* NOCSETS */
  11929.  
  11930. #ifdef NOCMDL
  11931.     printf(" No command-line arguments\n");
  11932.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11933.     flag = 1;
  11934. #endif /* NOCMDL */
  11935.  
  11936. #ifdef NOPUSH
  11937.     printf(" No escape to system\n");
  11938.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11939.     flag = 1;
  11940. #endif /* NOPUSH */
  11941.  
  11942. #ifdef NOJC
  11943. #ifdef UNIX
  11944.     printf(" No UNIX job control\n");
  11945.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11946.     flag = 1;
  11947. #endif /* UNIX */
  11948. #endif /* NOJC */
  11949.  
  11950. #ifdef NOSETKEY
  11951.     printf(" No SET KEY command\n");
  11952.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11953.     flag = 1;
  11954. #endif /* NOSETKEY */
  11955.  
  11956. #ifndef CK_REDIR
  11957.     printf(" No REDIRECT or PIPE command\n");
  11958.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11959.     flag = 1;
  11960. #endif /* CK_REDIR */
  11961.  
  11962. #ifdef UNIX
  11963. #ifndef NETPTY
  11964.     printf(" No pseudoterminal control\n");
  11965.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11966.     flag = 1;
  11967. #endif /* NETPTY */
  11968. #endif /* UNIX */
  11969.  
  11970. #ifndef CK_RESEND
  11971.     printf(" No RESEND command\n");
  11972.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11973.     flag = 1;
  11974. #endif /* CK_RESEND */
  11975.  
  11976. #ifdef OS2
  11977. #ifdef __32BIT__
  11978. #ifndef OS2MOUSE
  11979.     printf(" No Mouse support\n");
  11980.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11981.     flag = 1;
  11982. #endif /* __32BIT__ */
  11983. #endif /* OS2 */
  11984. #endif /* OS2MOUSE */
  11985.  
  11986. #ifdef OS2
  11987. #ifndef NT
  11988. #ifndef CK_REXX
  11989.     printf(" No REXX script language interface\n");
  11990.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11991.     flag = 1;
  11992. #endif /* CK_REXX */
  11993. #endif /* NT */
  11994. #endif /* OS2 */
  11995.  
  11996. #ifndef IKSD
  11997.     printf(" No Internet Kermit Service\n");
  11998.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11999.     flag = 1;
  12000. #endif /* IKSD */
  12001.  
  12002.     if (flag == 0) {
  12003.         printf(" None\n");
  12004.         if (++lines > cmd_rows - 3)
  12005.           { if (!askmore()) return(1); else lines = 0; }
  12006.     }
  12007.     printf("\n");
  12008.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12009.  
  12010. #ifdef CK_UTSNAME
  12011.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12012.     printf("Host info:\n");
  12013.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12014.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  12015.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12016.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  12017.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12018.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  12019.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12020.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  12021.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12022.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  12023.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12024.     printf("\n");
  12025.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12026. #endif /* CK_UTSNAME */
  12027.  
  12028. /*
  12029.   Print compile-time (-D) options, as well as C preprocessor
  12030.   predefined symbols that might affect us...
  12031. */
  12032. #ifdef KTARGET
  12033.     {
  12034.         char * s;                       /* Makefile target */
  12035.         s = KTARGET;
  12036.         if (!s) s = "";
  12037.         if (!*s) s = "(unknown)";
  12038.         printf("\n");
  12039.         if (++lines > cmd_rows - 3) {
  12040.             if (!askmore()) return(1); else lines = 0;
  12041.         }
  12042.         printf("Target: %s\n", s);
  12043.         if (++lines > cmd_rows - 3) {
  12044.             if (!askmore()) return(1); else lines = 0;
  12045.         }
  12046.     }
  12047. #endif /* KTARGET */
  12048.  
  12049. #ifdef __VERSION__
  12050. #ifdef __GNUC__
  12051.     printf("GCC version: %s\n", __VERSION__);
  12052. #else
  12053.     printf("Compiler version: %s\n", __VERSION__);
  12054. #endif /* __GNUC__ */
  12055.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12056. #endif /* __VERSION__ */
  12057.  
  12058. #ifdef __DATE__                         /* GNU and other ANSI */
  12059. #ifdef __TIME__
  12060.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  12061. #else
  12062.     printf("Compiled %s, options:\n", __DATE__);
  12063. #endif /* __TIME__ */
  12064. #else /* !__DATE__ */
  12065.     printf("Compiler options:\n");
  12066. #endif /* __DATE__ */
  12067.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  12068.  
  12069.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  12070.       if (!prtopt(&lines,optlist[i]))
  12071.         return(0);
  12072.  
  12073.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12074.  
  12075. /* Sizes of data types */
  12076.  
  12077.     ckmakmsg(line,
  12078.              LINBUFSIZ,
  12079.              "byte order: ",
  12080.              byteorder ? "little" : "big",
  12081.              " endian",
  12082.              NULL
  12083.              );
  12084.     if (!prtopt(&lines,line)) return(0);
  12085.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12086.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  12087.     if (!prtopt(&lines,line)) return(0);
  12088.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  12089.     if (!prtopt(&lines,line)) return(0);
  12090.  
  12091. #ifdef NOLONGLONG
  12092.     sprintf(line,"long long=(navail)"); /* SAFE */
  12093. #else /* NOLONGLONG */
  12094.     sprintf(line,"long long=%ld",sizeof(long long)); /* SAFE */
  12095. #endif /* NOLONGLONG */
  12096.     if (!prtopt(&lines,line)) return(0);
  12097.  
  12098. #ifndef OS2
  12099.     /* Windows doesn't have off_t */
  12100.     sprintf(line,"off_t=%ld",sizeof(off_t)); /* SAFE */
  12101.     if (!prtopt(&lines,line)) return(0);
  12102. #endif /* OS2 */
  12103.  
  12104.     sprintf(line,"CK_OFF_T=%ld",sizeof(CK_OFF_T)); /* SAFE */
  12105.     if (!prtopt(&lines,line)) return(0);
  12106.  
  12107.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  12108.     if (!prtopt(&lines,line)) return(0);
  12109.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  12110.     if (!prtopt(&lines,line)) return(0);
  12111.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  12112.     if (!prtopt(&lines,line)) return(0);
  12113.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  12114.     if (!prtopt(&lines,line)) return(0);
  12115.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  12116.     if (!prtopt(&lines,line)) return(0);
  12117. #ifdef FNFLOAT
  12118.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  12119.     if (!prtopt(&lines,"floating-point:")) return(0);
  12120.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  12121.     if (!prtopt(&lines,line)) return(0);
  12122.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  12123.     if (!prtopt(&lines,line)) return(0);
  12124. #endif /* FNFLOAT */
  12125.  
  12126.     prtopt(&lines,"");
  12127.     return(0);
  12128. }
  12129. #endif /* NOSHOW */
  12130. #endif /* NOICP */
  12131.