home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku201.zip / ckuus5.c < prev    next >
C/C++ Source or Header  |  2002-02-09  |  379KB  |  11,584 lines

  1. #include "ckcsym.h"
  2.  
  3. int xcmdsrc = 0;
  4.  
  5. #ifdef NOICP
  6. int cmdsrc() { return(0); }
  7. #endif /* NOICP */
  8.  
  9. /*  C K U U S 5 --  "User Interface" for C-Kermit, part 5  */
  10.  
  11. /*
  12.   Author: Frank da Cruz <fdc@columbia.edu>,
  13.   Columbia University Academic Information Systems, New York City.
  14.  
  15.   Copyright (C) 1985, 2002,
  16.     Trustees of Columbia University in the City of New York.
  17.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  18.     copyright text in the ckcmai.c module for disclaimer and permissions.
  19. */
  20.  
  21. /* Includes */
  22.  
  23. #include "ckcdeb.h"
  24. #include "ckcasc.h"
  25. #include "ckcker.h"
  26. #include "ckuusr.h"
  27.  
  28. #ifdef DCMDBUF
  29. char *line;                             /* Character buffer for anything */
  30. char *tmpbuf;
  31. #else
  32. char line[LINBUFSIZ+1];
  33. char tmpbuf[TMPBUFSIZ+1];               /* Temporary buffer */
  34. #endif /* DCMDBUF */
  35.  
  36. #ifndef NOICP
  37.  
  38. #include "ckcnet.h"
  39. #ifndef NOCSETS
  40. #include "ckcxla.h"
  41. #endif /* NOCSETS */
  42. #ifdef MAC
  43. #include "ckmasm.h"
  44. #endif /* MAC */
  45. #ifdef CK_SSL
  46. #include "ck_ssl.h"
  47. #endif /* CK_SSL */
  48.  
  49. #ifdef OS2
  50. #include "ckoetc.h"
  51. #ifndef NT
  52. #define INCL_NOPM
  53. #define INCL_VIO /* Needed for ckocon.h */
  54. #include <os2.h>
  55. #undef COMMENT
  56. #else /* NT */
  57. #include <windows.h>
  58. #define TAPI_CURRENT_VERSION 0x00010004
  59. #include <tapi.h>
  60. #include <mcx.h>
  61. #include "ckntap.h"
  62. #define APIRET ULONG
  63. extern int DialerHandle;
  64. extern int StartedFromDialer;
  65. #endif /* NT */
  66. #include "ckocon.h"
  67. #include "ckokey.h"
  68. #ifdef putchar
  69. #undef putchar
  70. #endif /* putchar */
  71. #define putchar(x) conoc(x)
  72. extern int cursor_save ;
  73. extern bool cursorena[] ;
  74. #endif /* OS2 */
  75.  
  76. /* For formatted screens, "more?" prompting, etc. */
  77.  
  78. #ifdef FT18
  79. #define isxdigit(c) isdigit(c)
  80. #endif /* FT18 */
  81.  
  82. #ifdef STRATUS                          /* Stratus Computer, Inc.  VOS */
  83. #ifdef putchar
  84. #undef putchar
  85. #endif /* putchar */
  86. #define putchar(x) conoc(x)
  87. #ifdef getchar
  88. #undef getchar
  89. #endif /* getchar */
  90. #define getchar(x) coninc(0)
  91. #endif /* STRATUS */
  92.  
  93. /* External variables */
  94.  
  95. extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, suspend,
  96.   binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  97.   inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  98.   zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  99.   debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive;
  100.  
  101. #ifndef NOMSEND
  102. extern int addlist;
  103. #endif /* NOMSEND */
  104.  
  105. #ifdef CK_SPEED
  106. extern int prefixing;
  107. #endif /* CK_SPEED */
  108.  
  109. extern int g_matchdot;
  110.  
  111. #ifdef RECURSIVE
  112. extern int recursive;
  113. #endif /* RECURSIVE */
  114. extern int xfiletype;
  115.  
  116. #ifdef IKSDCONF
  117. extern char * iksdconf;
  118. extern int iksdcf;
  119. #endif /* IKSDCONF */
  120.  
  121. #ifdef CK_RECALL
  122. extern int on_recall;
  123. #endif /* CK_RECALL */
  124.  
  125. extern int ngetpath, exitonclose;
  126. extern char * getpath[];
  127. extern CHAR * epktmsg;
  128.  
  129. extern char * snd_move;
  130. extern char * snd_rename;
  131. extern char * rcv_move;
  132. extern char * rcv_rename;
  133. extern char * g_snd_move;
  134. extern char * g_snd_rename;
  135. extern char * g_rcv_move;
  136. extern char * g_rcv_rename;
  137.  
  138. extern char * nm[];
  139.  
  140. #ifdef CK_UTSNAME
  141. extern char unm_mch[];
  142. extern char unm_mod[];
  143. extern char unm_nam[];
  144. extern char unm_rel[];
  145. extern char unm_ver[];
  146. #endif /* CK_UTSNAME */
  147.  
  148. #ifndef NOPUSH
  149. #ifndef NOFRILLS
  150. extern char editor[];
  151. extern char editfile[];
  152. extern char editopts[];
  153. #ifdef BROWSER
  154. extern char browser[];
  155. extern char browsopts[];
  156. extern char browsurl[];
  157. #endif /* BROWSER */
  158. #endif /*  NOFRILLS */
  159. #endif /* NOPUSH */
  160.  
  161. #ifndef NOSERVER
  162. extern char * x_user, * x_passwd, * x_acct;
  163. #endif /* NOSERVER */
  164.  
  165. #ifdef CKLOGDIAL
  166. extern int dialog;
  167. extern char diafil[];
  168. #endif /* CKLOGDIAL */
  169.  
  170. #ifdef CKROOT
  171. extern int ckrooterr;
  172. #endif /* CKROOT */
  173.  
  174. #ifndef NOSPL
  175. extern int cfilef, xxdot;
  176. extern char cmdfil[];
  177.  
  178. struct localvar * localhead[CMDSTKL];
  179. struct localvar * localtail = NULL;
  180. struct localvar * localnext = NULL;
  181.  
  182. _PROTOTYP( VOID shosexp, (void) );
  183. _PROTOTYP( static VOID shoinput, (void) );
  184. _PROTOTYP( static char gettok,   (void) );
  185. _PROTOTYP( static VOID factor,   (void) );
  186. _PROTOTYP( static VOID term,     (void) );
  187. _PROTOTYP( static VOID termp,    (void) );
  188. _PROTOTYP( static VOID exprp,    (void) );
  189. _PROTOTYP( static VOID expr,     (void) );
  190. _PROTOTYP( static VOID simple,   (void) );
  191. _PROTOTYP( static VOID simpler,  (void) );
  192. _PROTOTYP( static VOID simplest, (void) );
  193. _PROTOTYP( static long xparse,   (void) );
  194. #endif /* NOSPL */
  195. #ifndef NOSHOW
  196. _PROTOTYP( int sho_iks, (void) );
  197. #endif /* NOSHOW */
  198.  
  199. #ifdef MAC
  200. char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
  201. char * ikprompt = "IKSD>";
  202. #else  /* Not MAC */
  203. #ifdef NOSPL
  204. #ifdef OS2
  205. char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
  206. char * ikprompt = "IKSD> ";
  207. #else
  208. char * ckprompt = "C-Kermit>";
  209. char * ikprompt = "IKSD>";
  210. #endif /* NT */
  211. #else  /* NOSPL */
  212. #ifdef OS2
  213. /* Default prompt for OS/2 and Win32 */
  214. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  215. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  216. #else
  217. #ifdef VMS
  218. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  219. char * ikprompt = "\\v(dir) IKSD>";
  220. #else
  221. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  222. char * ikprompt = "(\\v(dir)) IKSD>";
  223. #endif /* VMS */
  224. #endif /* NT */
  225. #endif /* NOSPL */
  226. #endif /* MAC */
  227.  
  228. #ifndef CCHMAXPATH
  229. #define CCHMAXPATH 257
  230. #endif /* CCHMAXPATH */
  231. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  232.  
  233. #ifdef TNCODE
  234. extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
  235. #endif /* TNCODE */
  236.  
  237. #ifndef NOKVERBS
  238. extern struct keytab kverbs[];          /* Table of \Kverbs */
  239. extern int nkverbs;                     /* Number of \Kverbs */
  240. #endif /* NOKVERBS */
  241.  
  242. #ifndef NOPUSH
  243. extern int nopush;
  244. #endif /* NOPUSH */
  245.  
  246. #ifdef CK_RECALL
  247. extern int cm_recall;
  248. #endif /* CK_RECALL */
  249.  
  250. extern char *ccntab[];
  251.  
  252. /* Printer stuff */
  253.  
  254. extern char *printername;
  255. extern int printpipe;
  256. #ifdef BPRINT
  257. extern int printbidi, pportparity, pportflow;
  258. extern long pportspeed;
  259. #endif /* BPRINT */
  260.  
  261. #ifdef OS2
  262. _PROTOTYP (int os2getcp, (void) );
  263. _PROTOTYP (int os2getcplist, (int *, int) );
  264. #ifdef OS2MOUSE
  265. extern int tt_mouse;
  266. #endif /* OS2MOUSE */
  267. extern int tt_update, tt_updmode, updmode;
  268. #ifndef IKSDONLY
  269. extern int tt_status[];
  270. #endif /* IKSDONLY */
  271. #ifdef PCFONTS
  272. extern struct keytab term_font[];
  273. #else
  274. #ifdef KUI
  275. extern struct keytab * term_font;
  276. #endif /* KUI */
  277. #endif /* PCFONTS */
  278. extern int ntermfont, tt_font, tt_font_size;
  279. extern unsigned char colornormal, colorunderline, colorstatus,
  280.     colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  281.     colorreverse, colorcmd;
  282. extern int priority;
  283. extern struct keytab prtytab[];
  284. extern int nprty;
  285. char * cmdmac = NULL;
  286. #endif /* OS2 */
  287.  
  288. #ifdef VMS
  289. _PROTOTYP (int zkermini, (char *, int, char *) );
  290. #endif /* VMS */
  291.  
  292. extern long vernum;
  293. extern int inecho, insilence, inbufsize, nvars, inintr;
  294. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  295.  *cknetv, *clcmds;
  296. #ifdef CK_AUTHENTICATION
  297. extern char * ckathv;
  298. #endif /* CK_AUTHENTICATION */
  299. #ifdef CK_SSL
  300. extern char * cksslv;
  301. #endif /* CK_SSL */
  302. #ifdef CK_ENCRYPTION
  303. #ifndef CRYPT_DLL
  304. extern char * ckcrpv;
  305. #endif /* CRYPT_DLL */
  306. #endif /* CK_ENCRYPTION */
  307.  
  308. #ifdef TNCODE
  309. extern char *cktelv;
  310. #endif /* TNCODE */
  311. #ifndef NOFTP
  312. #ifndef SYSFTP
  313. extern char * ckftpv;
  314. #endif /* SYSFTP */
  315. #endif /* NOFTP */
  316.  
  317. extern int srvidl;
  318.  
  319. #ifdef OS2
  320. extern char *ckonetv;
  321. extern int interm;
  322. #ifdef CK_NETBIOS
  323. extern char *ckonbiv;
  324. #endif /* CK_NETBIOS */
  325. #ifdef OS2MOUSE
  326. extern char *ckomouv;
  327. #endif /* OS2MOUSE */
  328. #endif /* OS2 */
  329.  
  330. #ifndef NOLOCAL
  331. extern char *connv;
  332. #endif /* NOLOCAL */
  333. #ifndef NODIAL
  334. extern char *dialv;
  335. #endif /* NODIAL */
  336. #ifndef NOSCRIPT
  337. extern char *loginv;
  338. extern int secho;
  339. #endif /* NOSCRIPT */
  340.  
  341. #ifndef NODIAL
  342. extern int nmdm, dirline;
  343. extern struct keytab mdmtab[];
  344. #endif /* NODIAL */
  345.  
  346. extern int network, nettype, ttnproto;
  347.  
  348. #ifdef OS2
  349. #ifndef NOTERM
  350. /* SET TERMINAL items... */
  351. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  352. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  353. extern char answerback[];
  354. extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
  355. extern int max_tt;
  356. #endif /* NOTERM */
  357. #endif /* OS2 */
  358.  
  359. _PROTOTYP( VOID shotrm, (void) );
  360. _PROTOTYP( int shofea, (void) );
  361.  
  362. #ifdef OS2
  363. extern int tt_rows[], tt_cols[];
  364. #else /* OS2 */
  365. extern int tt_rows, tt_cols;
  366. #endif /* OS2 */
  367. extern int cmd_rows, cmd_cols;
  368.  
  369. #ifdef CK_TMPDIR
  370. extern int f_tmpdir;                    /* Directory changed temporarily */
  371. extern char savdir[];                   /* Temporary directory */
  372. #endif /* CK_TMPDIR */
  373.  
  374. #ifndef NOLOCAL
  375. extern int tt_crd, tt_escape;
  376. #endif /* NOLOCAL */
  377.  
  378. #ifndef NOCSETS
  379. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  380. extern struct keytab fcstab[];
  381. extern struct csinfo fcsinfo[];
  382. #ifndef MAC
  383. extern struct keytab ttcstab[];
  384. #endif /* MAC */
  385. #endif /* NOCSETS */
  386.  
  387. extern long speed;
  388.  
  389. #ifndef NOXMIT
  390. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  391. extern char xmitbuf[];
  392. #endif /* NOXMIT */
  393.  
  394. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  395.  
  396. #ifdef DCMDBUF
  397. extern char *cmdbuf, *atmbuf;           /* Command buffers */
  398. #ifndef NOSPL
  399. extern char *savbuf;                    /* Command buffers */
  400. #endif /* NOSPL */
  401. #else
  402. extern char cmdbuf[], atmbuf[];         /* Command buffers */
  403. #ifndef NOSPL
  404. extern char savbuf[];                   /* Command buffers */
  405. #endif /* NOSPL */
  406. #endif /* DCMDBUF */
  407.  
  408. extern char toktab[], ttname[], psave[];
  409. extern CHAR sstate, feol;
  410. extern int cmflgs, techo, repars, ncmd;
  411. extern struct keytab cmdtab[];
  412.  
  413. #ifndef NOSETKEY
  414. KEY *keymap;
  415. #ifndef OS2
  416. #define mapkey(x) keymap[x]
  417. #endif /* OS2 */
  418. MACRO *macrotab;
  419. _PROTOTYP( VOID shostrdef, (CHAR *) );
  420. #endif /* NOSETKEY */
  421.  
  422. extern int cmdlvl;
  423.  
  424. #ifndef NOSPL
  425. extern struct mtab *mactab;
  426. extern struct keytab mackey[];
  427. extern struct keytab vartab[], fnctab[], iftab[];
  428. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  429. #endif /* NOSPL */
  430.  
  431. FILE *tfile[MAXTAKE];                   /* TAKE file stack */
  432. char *tfnam[MAXTAKE];
  433. int tfline[MAXTAKE];
  434.  
  435. int topcmd = -1;                        /* cmdtab index of current command */
  436. int havetoken = 0;
  437. extern int dblquo;                      /* Doublequoting enabled */
  438.  
  439. #ifdef DCMDBUF                          /* Initialization filespec */
  440. char *kermrc = NULL;
  441. #else
  442. char kermrcb[KERMRCL];
  443. char *kermrc = kermrcb;
  444. #endif /* DCMDBUF */
  445.  
  446. int noherald = 0;
  447. int cm_retry = 1;                       /* Command retry enabled */
  448. xx_strp xxstring = zzstring;
  449.  
  450. #ifndef NOXFER
  451. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  452.   keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  453.   srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  454.   fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  455.  
  456. #ifdef CK_AUTODL
  457. extern int inautodl, cmdadl;
  458. #endif /* CK_AUTODL */
  459.  
  460. #ifndef NOSERVER
  461. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  462.   en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  463.   en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  464. #endif /* NOSERVER */
  465.  
  466. extern int atcapr,
  467.   atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  468.   attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  469.  
  470. #ifdef STRATUS
  471. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  472. #endif /* STRATUS */
  473.  
  474. #ifdef CK_PERMS
  475. extern int atlpri, atlpro, atgpri, atgpro;
  476. #endif /* CK_PERMS */
  477.  
  478. #ifdef CK_LOGIN
  479. extern char * anonfile;                 /* Anonymous login init file */
  480. extern char * anonroot;                 /* Anonymous file-system root */
  481. extern char * userfile;                 /* Forbidden user file */
  482. extern int isguest;                     /* Flag for anonymous user */
  483. #endif /* CK_LOGIN */
  484. #endif /* NOXFER */
  485.  
  486. #ifdef DCMDBUF
  487. int *xquiet = NULL;
  488. #else
  489. int xquiet[CMDSTKL];
  490. #endif /* DCMDBUF */
  491.  
  492. char * prstring[CMDSTKL];
  493.  
  494. #ifndef NOSPL
  495.  
  496. extern long ck_alarm;
  497. extern char alrm_date[], alrm_time[];
  498.  
  499. /* Local declarations */
  500.  
  501. static int nulcmd = 0;                  /* Flag for next cmd to be ignored */
  502.  
  503. /* Definitions for predefined macros */
  504.  
  505. /* First, the single-line macros, installed with addmac()... */
  506.  
  507. /* IBM-LINEMODE macro */
  508. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  509.  
  510. /* FATAL macro */
  511. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  512.  
  513. #ifdef CK_SPEED
  514. #ifdef IRIX65
  515. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  516. #else
  517. #ifdef IRIX
  518. /* Because of bug in telnet server */
  519. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  520.  set pref cautious";
  521. #else
  522. #ifdef pdp11
  523. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  524. #else
  525. #ifdef BIGBUFOK
  526. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  527. #else
  528. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  529. #endif /* BIGBUFOK */
  530. #endif /* IRIX */
  531. #endif /* IRIX65 */
  532. #endif /* pdp11 */
  533. #ifdef pdp11
  534. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  535. #else
  536. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  537. #endif /* pdp11 */
  538. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  539. set reliable off, set clearchannel off";
  540. #else
  541. #ifdef BIGBUFOK
  542. #ifdef IRIX65
  543. char *m_fast = "set win 30, set rec pack 4000";
  544. #else
  545. #ifdef IRIX
  546. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  547. #else
  548. char *m_fast = "set win 30, set rec pack 4000";
  549. #endif /* IRIX */
  550. #endif /* IRIX65 */
  551. #else /* Not BIGBUFOK */
  552. char *m_fast = "set win 4, set rec pack 2200";
  553. #endif /* BIGBUFOK */
  554. char *m_cautious = "set win 4, set rec pack 1000";
  555. char *m_robust = "set win 1, set rec pack 90, set reliable off";
  556. #endif /* CK_SPEED */
  557.  
  558. #ifdef VMS
  559. char *m_purge = "run purge \\%*";
  560. #endif /* VMS */
  561.  
  562. #ifdef OS2
  563. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  564. #endif /* OS2 */
  565.  
  566. /* Now the multiline macros, defined with addmmac()... */
  567.  
  568. /* FOR macro for \%i-style loop variables (see dofor()...) */
  569.  
  570. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  571. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  572. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  573. "def break goto _..bot, def continue goto _..inc,",
  574. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  575. ""};
  576.  
  577. /* This is the FOR macro when the loop variable is itself a macro */
  578.  
  579. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  580. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  581. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  582. "def break goto _..bot, def continue goto _..inc,",
  583. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  584. ""};
  585.  
  586. /* WHILE macro */
  587. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  588. ":_..inc,\\%1,\\%2,goto _..inc,:_..bot,_putargs},",
  589. "_def break goto _..bot, _def continue goto _..inc,",
  590. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  591. ""};
  592.  
  593. /* SWITCH macro */
  594. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  595. "_forward \\%1,\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  596. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  597. ""};
  598.  
  599. /* XIF macro */
  600. char *xif_def[] = {
  601. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  602. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  603. ""};
  604.  
  605. /*
  606.   Variables declared here for use by other ckuus*.c modules.
  607.   Space is allocated here to save room in ckuusr.c.
  608. */
  609. #ifdef DCMDBUF
  610. struct cmdptr *cmdstk;
  611. int
  612.   *ifcmd  = NULL,
  613.   *count  = NULL,
  614.   *iftest = NULL,
  615.   *intime = NULL,
  616.   *inpcas = NULL,
  617.   *takerr = NULL,
  618.   *merror = NULL;
  619. #else
  620. struct cmdptr cmdstk[CMDSTKL];
  621. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  622.   inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  623. #endif /* DCMDBUF */
  624.  
  625. /* Macro stack */
  626.  
  627. #ifdef COMMENT
  628. char *topline = NULL;                   /* Program invocation arg line */
  629. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  630. #endif /* COMMENT */
  631.  
  632. char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
  633. int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
  634. char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
  635. int macargc[MACLEVEL];                  /* Argc of each level */
  636. char *macp[MACLEVEL];                   /* Current position in each macro */
  637. char *macx[MACLEVEL];                   /* Beginning of each macro def */
  638. char *mrval[MACLEVEL];                  /* RETURN value at each level */
  639. int lastcmd[MACLEVEL];                  /* Last command at each level */
  640. int topargc = 0;                        /* Argc at top level */
  641. char **topxarg = NULL;                  /* Argv at top level */
  642. char *toparg[MAXARGLIST+2];
  643.  
  644. /* Global Variables */
  645.  
  646. char *g_var[GVARS+1];                   /* Global \%a..z pointers */
  647. extern char varnam[];                   /* \%x variable name buffer */
  648.  
  649. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  650. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  651.  
  652. char **a_ptr[32];                       /* Array pointers, for arrays a-z */
  653. int a_dim[32];                          /* Dimensions for each array */
  654. int a_link[32];                         /* Link (index of linked-to-array) */
  655.  
  656. char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
  657. int aa_dim[CMDSTKL][32];                /* Dimensions for each array */
  658.  
  659. /* INPUT command buffers and variables */
  660.  
  661. char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
  662. extern char * inpbp;                    /* Global/static pointer to it  */
  663. char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
  664. int  incount = 0;                       /* INPUT character count */
  665. extern int instatus;                    /* INPUT status */
  666. static char * i_text[] = {              /* INPUT status text */
  667.     "success", "timeout", "interrupted", "internal error", "i/o error"
  668. };
  669.  
  670. char lblbuf[LBLSIZ];                    /* Buffer for labels */
  671.  
  672. #else  /* NOSPL */
  673.  
  674. int takerr[MAXTAKE];
  675. #endif /* NOSPL */
  676.  
  677. static char *prevdir = NULL;
  678.  
  679. int pacing = 0;                         /* OUTPUT pacing */
  680.  
  681. char *tp;                               /* Temporary buffer pointer */
  682.  
  683. int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */
  684.  
  685. #ifdef CK_APC                           /* Application Program Command (APC) */
  686. int apcactive = APC_INACTIVE;
  687. int apcstatus = APC_OFF;                /* OFF by default everywhere */
  688. #ifdef DCMDBUF
  689. char *apcbuf;
  690. #else
  691. char apcbuf[APCBUFLEN];
  692. #endif /* DCMDBUF */
  693. #endif /* CK_APC */
  694.  
  695. extern char pktfil[],
  696. #ifdef DEBUG
  697.   debfil[],
  698. #endif /* DEBUG */
  699. #ifdef TLOG
  700.   trafil[],
  701. #endif /* TLOG */
  702.   sesfil[];
  703.  
  704. #ifndef NOFRILLS
  705. extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
  706. extern char optbuf[];
  707. #endif /* NOFRILLS */
  708.  
  709. extern int noinit;
  710.  
  711. #ifndef NOSPL
  712. _PROTOTYP( VOID freelocal, (int) );
  713. _PROTOTYP( static long expon, (long, long) );
  714. _PROTOTYP( static long gcd, (long, long) );
  715. _PROTOTYP( static long fact, (long) );
  716.  
  717. int                     /* Initialize macro data structures. */
  718. macini() {              /* Allocate mactab and preset the first element. */
  719.     int i;
  720.     if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  721.       return(-1);
  722.     mactab[0].kwd = NULL;
  723.     mactab[0].mval = NULL;
  724.     mactab[0].flgs = 0;
  725.     for (i = 0; i < MACLEVEL; i++)
  726.       localhead[i] = NULL;
  727.     return(0);
  728. }
  729. #endif /* NOSPL */
  730.  
  731. /*  C M D S R C  --  Returns current command source  */
  732.  
  733. /*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  734.  
  735. /*
  736.   As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  737.   xcmdsrc can be checked instead to save the overhead of a function call.
  738. */
  739. int
  740. cmdsrc() {
  741. #ifdef COMMENT
  742.     return(xcmdsrc);
  743. #else
  744. #ifndef NOSPL
  745.     if (cmdlvl == 0)
  746.       return(0);
  747.     else if (cmdstk[cmdlvl].src == CMD_MD)
  748.       return(2);
  749.     else if (cmdstk[cmdlvl].src == CMD_TF)
  750.       return(1);
  751.     else
  752.       return(-1);
  753. #else
  754.     if (tlevel < 0)
  755.       return(0);
  756.     else
  757.       return(1);
  758. #endif /* NOSPL */
  759. #endif /* COMMENT */
  760. }
  761.  
  762. /*  C M D I N I  --  Initialize the interactive command parser  */
  763.  
  764. static int cmdinited = 0;               /* Command parser initialized */
  765. extern int cmdint;                      /* Interrupts are allowed */
  766. #ifdef CK_AUTODL
  767. int cmdadl = 1;                         /* Autodownload */
  768. #else
  769. int cmdadl = 0;
  770. #endif /* CK_AUTODL */
  771.  
  772. char * k_info_dir = NULL;               /* Where to find text files */
  773. #ifdef UNIX
  774. static char * txtdir[] = {
  775.     "/usr/local/doc/",                  /* Linux, SunOS, ... */
  776.     "/usr/share/lib/",                  /* HP-UX 10.xx... */
  777.     "/usr/share/doc/",                  /* Other possibilities... */
  778.     "/usr/local/lib/",                  /* NOTE: Each of these is tried */
  779.     "/usr/local/share/",                /* as is, and also with a kermit */
  780.     "/usr/local/share/doc/",            /* subdirectory. */
  781.     "/usr/local/share/lib/",
  782.     "/opt/kermit/",                     /* Solaris */
  783.     "/opt/kermit/doc/",
  784.     "/opt/",
  785.     "/usr/doc/",
  786.     "/doc/",
  787.     ""
  788. };
  789. #endif /* UNIX */
  790.  
  791. /*
  792.   lookup() cache to speed up script execution.
  793.  
  794.   This is a static cache.  Items are stored in decreasing frequency of
  795.   reference based on statistics from a range of scripts.  This gives
  796.   better performance than a dynamic cache, which would require a lot more
  797.   code and also would require system-dependent elements including system
  798.   calls (e.g. to get subsecond times for entry aging).
  799. */
  800. #ifdef USE_LUCACHE                      /* Set in ckuusr.h */
  801. #define LUCACHE 32                      /* Change this to reduce cache size */
  802. int lusize = 0;
  803. char * lucmd[LUCACHE];
  804. int luval[LUCACHE];
  805. int luidx[LUCACHE];
  806. struct keytab * lutab[LUCACHE];
  807. #endif /* USE_LUCACHE */
  808.  
  809. static VOID
  810. luinit() {                              /* Initialize lookup() cache */
  811.     int x, y;
  812.  
  813. #ifdef USE_LUCACHE
  814.     x = lookup(cmdtab,"if",ncmd,&y);
  815.     lucmd[lusize] = "if";
  816.     luval[lusize] = x;
  817.     luidx[lusize] = y;
  818.     lutab[lusize] = cmdtab;
  819.     if (++lusize > LUCACHE) return;
  820.  
  821.     x = lookup(iftab,"not",nif,&y);
  822.     lucmd[lusize] = "not";
  823.     luval[lusize] = x;
  824.     luidx[lusize] = y;
  825.     lutab[lusize] = iftab;
  826.     if (++lusize > LUCACHE) return;
  827.  
  828.     x = lookup(vartab,"cmdlevel",nvars,&y);
  829.     lucmd[lusize] = "cmdlevel";
  830.     luval[lusize] = x;
  831.     luidx[lusize] = y;
  832.     lutab[lusize] = vartab;
  833.     if (++lusize > LUCACHE) return;
  834.  
  835.     x = lookup(cmdtab,"goto",ncmd,&y);
  836.     lucmd[lusize] = "goto";
  837.     luval[lusize] = x;
  838.     luidx[lusize] = y;
  839.     lutab[lusize] = cmdtab;
  840.     if (++lusize > LUCACHE) return;
  841.  
  842.     x = lookup(iftab,">",nif,&y);
  843.     lucmd[lusize] = ">";
  844.     luval[lusize] = x;
  845.     luidx[lusize] = y;
  846.     lutab[lusize] = iftab;
  847.     if (++lusize > LUCACHE) return;
  848.  
  849.     x = lookup(cmdtab,"incr",ncmd,&y);
  850.     lucmd[lusize] = "incr";
  851.     luval[lusize] = x;
  852.     luidx[lusize] = y;
  853.     lutab[lusize] = cmdtab;
  854.     if (++lusize > LUCACHE) return;
  855.  
  856.     x = lookup(cmdtab,"def",ncmd,&y);
  857.     lucmd[lusize] = "def";
  858.     luval[lusize] = x;
  859.     luidx[lusize] = y;
  860.     lutab[lusize] = cmdtab;
  861.     if (++lusize > LUCACHE) return;
  862.  
  863.     x = lookup(cmdtab,"_assign",ncmd,&y);
  864.     lucmd[lusize] = "_assign";
  865.     luval[lusize] = x;
  866.     luidx[lusize] = y;
  867.     lutab[lusize] = cmdtab;
  868.     if (++lusize > LUCACHE) return;
  869.  
  870.     x = lookup(cmdtab,"echo",ncmd,&y);
  871.     lucmd[lusize] = "echo";
  872.     luval[lusize] = x;
  873.     luidx[lusize] = y;
  874.     lutab[lusize] = cmdtab;
  875.     if (++lusize > LUCACHE) return;
  876.  
  877.     x = lookup(fnctab,"eval",nfuncs,&y);
  878.     lucmd[lusize] = "eval";
  879.     luval[lusize] = x;
  880.     luidx[lusize] = y;
  881.     lutab[lusize] = fnctab;
  882.     if (++lusize > LUCACHE) return;
  883.  
  884.     x = lookup(fnctab,"lit",nfuncs,&y);
  885.     lucmd[lusize] = "lit";
  886.     luval[lusize] = x;
  887.     luidx[lusize] = y;
  888.     lutab[lusize] = fnctab;
  889.     if (++lusize > LUCACHE) return;
  890.  
  891.     x = lookup(cmdtab,"do",ncmd,&y);
  892.     lucmd[lusize] = "do";
  893.     luval[lusize] = x;
  894.     luidx[lusize] = y;
  895.     lutab[lusize] = cmdtab;
  896.     if (++lusize > LUCACHE) return;
  897.  
  898.     x = lookup(cmdtab,"_getargs",ncmd,&y);
  899.     lucmd[lusize] = "_getargs";
  900.     luval[lusize] = x;
  901.     luidx[lusize] = y;
  902.     lutab[lusize] = cmdtab;
  903.     if (++lusize > LUCACHE) return;
  904.  
  905.     x = lookup(iftab,"<",nif,&y);
  906.     lucmd[lusize] = "<";
  907.     luval[lusize] = x;
  908.     luidx[lusize] = y;
  909.     lutab[lusize] = iftab;
  910.     if (++lusize > LUCACHE) return;
  911.  
  912.     x = lookup(cmdtab,"_putargs",ncmd,&y);
  913.     lucmd[lusize] = "_putargs";
  914.     luval[lusize] = x;
  915.     luidx[lusize] = y;
  916.     lutab[lusize] = cmdtab;
  917.     if (++lusize > LUCACHE) return;
  918.  
  919.     x = lookup(cmdtab,"asg",ncmd,&y);
  920.     lucmd[lusize] = "asg";
  921.     luval[lusize] = x;
  922.     luidx[lusize] = y;
  923.     lutab[lusize] = cmdtab;
  924.     if (++lusize > LUCACHE) return;
  925.  
  926.     x = lookup(cmdtab,"else",ncmd,&y);
  927.     lucmd[lusize] = "else";
  928.     luval[lusize] = x;
  929.     luidx[lusize] = y;
  930.     lutab[lusize] = cmdtab;
  931. #endif /* USE_LUCACHE */
  932. }
  933.  
  934. VOID
  935. cmdini() {
  936.     int i = 0, x = 0, y = 0, z = 0, skip = 0;
  937.     char * p;
  938. #ifdef TTSPDLIST
  939.     long * ss = NULL;
  940.     extern int nspd;
  941.     extern struct keytab * spdtab;
  942. #endif /* TTSPDLIST */
  943.  
  944. #ifndef NOSPL
  945. /*
  946.   On stack to allow recursion!
  947. */
  948.     char vnambuf[VNAML];                /* Buffer for variable names */
  949. #endif /* NOSPL */
  950.  
  951.     if (cmdinited)                      /* Already initialized */
  952.       return;                           /* Don't do it again */
  953.  
  954.     for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
  955.       prstring[i] = NULL;               /* command level */
  956.  
  957. #ifndef NOCSETS
  958.     p = getenv("K_CHARSET");            /* Set default file character set */
  959.     if (p) {                            /* from environment */
  960.         x = lookup(fcstab,p,nfilc,&y);
  961.         if (x > -1)
  962.           fcharset = x;
  963.     }
  964. #endif /* NOCSETS */
  965.  
  966.     p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
  967.     if (p && *p && strlen(p) <= CKMAXPATH)
  968.       makestr(&k_info_dir,p);
  969.     if (!k_info_dir) {
  970.         p = getenv("K_INFO_DIR");
  971.         if (p && *p && strlen(p) <= CKMAXPATH)
  972.           makestr(&k_info_dir,p);
  973.     }
  974. #ifdef UNIX
  975.     if (k_info_dir) {                   /* Look for Kermit docs directory */
  976.         if (zchki(k_info_dir) == -2) {
  977.             char xbuf[CKMAXPATH+32], *s = "";
  978.             if (ckrchar(k_info_dir) != '/')
  979.               s = "/";
  980.             ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  981.             if (zchki(xbuf) < 0)
  982.               makestr(&k_info_dir,NULL);
  983.         }
  984.     }
  985.     if (!k_info_dir) {
  986.         char xbuf[CKMAXPATH+32];
  987.         int i;
  988.         for (i = 0; *(txtdir[i]); i++) {
  989.             ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  990.             if (zchki(xbuf) > 0) {
  991.                 makestr(&k_info_dir,txtdir[i]);
  992.                 debug(F110,"k_info_dir 1",k_info_dir,0);
  993.                 break;
  994.             }
  995.             ckmakmsg(xbuf,CKMAXPATH+32,
  996.                      txtdir[i],"kermit/","ckubwr.txt",NULL);
  997.             if (zchki(xbuf) > 0) {
  998.                 ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  999.                 makestr(&k_info_dir,xbuf);
  1000.                 debug(F110,"k_info_dir 2",k_info_dir,0);
  1001.                 break;
  1002.             }
  1003.         }
  1004.         if (k_info_dir) {               /* Make sure it ends with "/" */
  1005.             if (ckrchar(k_info_dir) != '/') {
  1006.                 char xbuf[CKMAXPATH+32];
  1007.                 ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1008.                 makestr(&k_info_dir,xbuf);
  1009.             }
  1010.         }
  1011.     }
  1012. #else
  1013. #ifdef OS2
  1014.     {
  1015.         char xdir[CKMAXPATH+8], *s = "";
  1016.         extern char startupdir[];
  1017.         xdir[0] = NUL;
  1018.         if (ckrchar(startupdir) != '/')
  1019.           s = "/";
  1020.         if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1021.           ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1022.         makestr(&k_info_dir,xdir);
  1023.     }
  1024. #endif /* OS2 */
  1025. #endif /* UNIX */
  1026.  
  1027. #ifdef TTSPDLIST
  1028.     if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1029.         int j, k, m = 0, n;             /* Create sorted keyword table */
  1030.         char buf[16];
  1031.         char * p;
  1032.         if ((spdtab =
  1033.              (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1034.             for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1035.                 if (ss[i] < 1L) break;     /* Shouldn't happen */
  1036.                 buf[0] = NUL;              /* Make string */
  1037.                 sprintf(buf,"%ld",ss[i]);  /* SAFE */
  1038.                 if (ss[i] == 8880L)
  1039.                   ckstrncpy(buf,"75/1200",sizeof(buf));
  1040.                 if (ss[i] == 134L)
  1041.                   ckstrncat(buf,".5",16);
  1042.                 n = strlen(buf);
  1043.                 if ((n > 0) && (p = (char *)malloc(n+1))) {
  1044.                     if (m > 0) {        /* Have at least one in list */
  1045.                         for (j = 0;     /* Find slot */
  1046.                              j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1047.                              j++
  1048.                              )
  1049.                           ;
  1050.                         if (j < m) {    /* Must insert */
  1051.                             for (k = m-1; k >= j; k--) { /* Move others down */
  1052.                                 spdtab[k+1].kwd = spdtab[k].kwd;
  1053.                                 spdtab[k+1].flgs = spdtab[k].flgs;
  1054.                                 spdtab[k+1].kwval = spdtab[k].kwval;
  1055.                             }
  1056.                         }
  1057.                     } else              /* First one */
  1058.                       j = 0;
  1059.                     ckstrncpy(p,buf,n+1); /* Add new speed */
  1060.                     spdtab[j].kwd = p;
  1061.                     spdtab[j].flgs = 0;
  1062.                     spdtab[j].kwval = (int) ss[i] / 10;
  1063.                     m++;                /* Count this one */
  1064.                 }
  1065.             }
  1066.         }
  1067.         nspd = m;
  1068.     }
  1069. #endif /* TTSPDLIST */
  1070.  
  1071. #ifndef NOSPL
  1072.     /* Allocate INPUT command buffer */
  1073.     if (!inpbuf) {
  1074.         if (!(inpbuf = (char *) malloc(INPBUFSIZ+1)))
  1075.           fatal("cmdini: no memory for INPUT buffer");
  1076.     }
  1077.     for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
  1078.       inpbuf[x] = NUL;
  1079.     inpbp = inpbuf;                     /* Initialize pointer */
  1080.     inbufsize = INPBUFSIZ;              /* and size. */
  1081. #endif /* NOSPL */
  1082.  
  1083. #ifdef DCMDBUF
  1084.     if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1085.  
  1086. #ifndef NOSPL
  1087.     /* Allocate command stack allowing command parser to call itself */
  1088.  
  1089.     if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1090.       fatal("cmdini: no memory for cmdstk");
  1091.     if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1092.       fatal("cmdini: no memory for ifcmd");
  1093.     if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1094.       fatal("cmdini: no memory for count");
  1095.     if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1096.       fatal("cmdini: no memory for iftest");
  1097.     if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1098.       fatal("cmdini: no memory for intime");
  1099.     if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1100.       fatal("cmdini: no memory for inpcas");
  1101.     if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1102.       fatal("cmdini: no memory for takerr");
  1103.     if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1104.       fatal("cmdini: no memory for merror");
  1105.     if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1106.       fatal("cmdini: no memory for xquiet");
  1107.     if (!kermrc)
  1108.       if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1109.         fatal("cmdini: no memory for kermrc");
  1110. #ifdef CK_APC
  1111. /* Application Program Command buffer */
  1112.     if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1113.         fatal("cmdini: no memory for apcbuf");
  1114. #endif /* CK_APC */
  1115. #endif /* NOSPL */
  1116.  
  1117. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1118.  
  1119.     if (!(line = malloc(LINBUFSIZ + 1)))
  1120.         fatal("cmdini: no memory for line");
  1121.     if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1122.         fatal("cmdini: no memory for tmpbuf");
  1123. #endif /* DCMDBUF */
  1124.  
  1125. #ifndef NOSPL
  1126. #ifdef CK_MINPUT
  1127.     {                                   /* Initialize MINPUT pointers */
  1128.         int i;
  1129.         extern char *ms[];
  1130.         for (i = 0; i < MINPMAX; i++)
  1131.           ms[i] = NULL;
  1132.     }
  1133. #endif /* CK_MINPUT */
  1134.  
  1135.     if (macini() < 0)                   /* Allocate macro buffers */
  1136.       fatal("Can't allocate macro buffers!");
  1137.  
  1138.     ifcmd[0] = 0;                       /* Command-level related variables. */
  1139.     iftest[0] = 0;                      /* Initialize variables at top level */
  1140.     count[0] = 0;                       /* of stack... */
  1141.     intime[0] = 0;
  1142.     inpcas[0] = 0;
  1143.     takerr[0] = 0;
  1144.     merror[0] = 0;
  1145.     xquiet[0] = quiet;
  1146. #endif /* NOSPL */
  1147.  
  1148. #ifndef NOSPL
  1149.     cmdlvl = 0;                         /* Initialize the command stack */
  1150.     xcmdsrc = CMD_KB;
  1151.     cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
  1152.     cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
  1153.     cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
  1154. #endif /* NOSPL */
  1155.  
  1156.     tlevel = -1;                        /* Take file level = keyboard */
  1157.     for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
  1158.       tfnam[i] = NULL;
  1159.  
  1160.     cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
  1161.                                         /* Can't set IKSD prompt here since */
  1162.                                         /* we do not yet know if we are IKSD */
  1163. #ifndef NOSPL
  1164.  
  1165.     initmac();                          /* Initialize macro table */
  1166.  
  1167. /* Predefine built-in one-line macros */
  1168.  
  1169.     addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
  1170.     addmac("fatal",m_fat);              /* FATAL macro */
  1171.     y = addmac("fast",m_fast);          /* FAST macro */
  1172.     addmac("cautious",m_cautious);      /* CAUTIOUS macro */
  1173.     addmac("robust",m_robust);          /* ROBUST macro */
  1174. #ifdef OS2
  1175.     addmac("manual",m_manual);          /* MANUAL macro */
  1176. #endif /* OS2 */
  1177. #ifdef VMS
  1178.     addmac("purge",m_purge);            /* PURGE macro */
  1179. #endif /* VMS */
  1180.  
  1181. /*
  1182.   Predefine built-in multiline macros; these are top-level commands
  1183.   that are implemented internally as macros.  NOTE: When adding a new
  1184.   one of these, remember to update the END and RETURN commands to
  1185.   account for it, or else END and RETURN from within it won't work right.
  1186. */
  1187.     x = addmmac("_forx",for_def);       /* FOR macro */
  1188.     if (x > -1) mactab[x].flgs = CM_INV;
  1189.     x = addmmac("_forz",foz_def);       /* Other FOR macro */
  1190.     if (x > -1) mactab[x].flgs = CM_INV;
  1191.     x = addmmac("_xif",xif_def);        /* XIF macro */
  1192.     if (x > -1) mactab[x].flgs = CM_INV;
  1193.     x = addmmac("_while",whil_def);     /* WHILE macro */
  1194.     if (x > -1) mactab[x].flgs = CM_INV;
  1195.     x = addmmac("_switx",sw_def);       /* SWITCH macro */
  1196.     if (x > -1) mactab[x].flgs = CM_INV;
  1197.  
  1198. /* Fill in command-line argument vector */
  1199.  
  1200.     sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
  1201.     if (inserver) {                     /* But hidden in IKSD */
  1202.         y = -1;
  1203.         xargs = 0;
  1204.     } else
  1205.       y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */
  1206.  
  1207.     tmpbuf[0] = NUL;
  1208.     if (y > -1) {
  1209.         int j = -1;
  1210.         int yy = 0;
  1211.         dclarray((char)x,z);            /* Declare the array */
  1212. #ifndef NOTAKEARGS
  1213.         /* Macro argument vector */
  1214.         sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
  1215.         yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
  1216.         if (yy > -1)                    /* Name is OK */
  1217.           dclarray((char)x,z);          /* Declare the array */
  1218. #endif /* NOTAKEARGS */
  1219.         skip = 0;
  1220.         for (i = 0; i < xargs; i++) {   /* Fill the arrays */
  1221.             sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1222.             addmac(vnambuf,xargv[i]);
  1223.             if (cfilef && i == 0)
  1224.               continue;
  1225. #ifdef KERBANG
  1226.             if (skip) {
  1227.                 j = 0;
  1228.                 skip = 0;
  1229.                 continue;
  1230.             }
  1231. #endif /* KERBANG */
  1232.             if (j < 0 &&                /* Assign items after "=" or "--"*/
  1233.                 (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1234.                 ) {
  1235.                 j = 0;                  /* to \%1..\%9 */
  1236. #ifdef KERBANG
  1237.             } else if (j < 0 &&
  1238.                        (!strcmp(xargv[i],"+") ||
  1239.                         !strncmp(xargv[i],"+ ",2) ||
  1240.                         !strncmp(xargv[i],"+\t",2))
  1241.                         ) {
  1242.                 skip = 1;
  1243.                 continue;
  1244. #endif /* KERBANG */
  1245.             } else if (j > -1) {
  1246.                 j++;
  1247.                 if (j <= 9) {
  1248.                     vnambuf[0] = '\\';
  1249.                     vnambuf[1] = '%';
  1250.                     vnambuf[2] = (char)(j+'0');
  1251.                     vnambuf[3] = NUL;
  1252.                     addmac(vnambuf,xargv[i]);
  1253.                 }
  1254.                 if (yy > -1) {
  1255.                     char c, * p;
  1256.                     int flag = 0;
  1257.                     p = xargv[i];
  1258.                     makestr(&(toparg[j]),p);
  1259.                     while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1260.                     if (flag)
  1261.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1262.                     ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1263.                     if (flag)
  1264.                       ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1265.                     ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1266.                 }
  1267.             }
  1268.         }
  1269.         if (cfilef) {
  1270.             addmac("\\%0",cmdfil);
  1271.             if (yy > -1)
  1272.               makestr(&(toparg[0]),cmdfil);
  1273.         } else {
  1274.             addmac("\\%0",xargv[0]);
  1275.             if (yy > -1)
  1276.               makestr(&(toparg[0]),xargv[0]);
  1277.         }
  1278.         if (yy > -1) {
  1279.             topargc = (j < 0) ? 1 : j + 1;
  1280.             topxarg = toparg;
  1281. #ifdef COMMENT
  1282.             /* This needs work */
  1283.             if (!cfilef)
  1284.               makestr(&topline,tmpbuf);
  1285. #endif /* COMMENT */
  1286.         } else {
  1287.             topargc = 0;
  1288.             topxarg = NULL;
  1289.         }
  1290.         a_dim[0] = topargc - 1;
  1291.         a_ptr[0] = topxarg;
  1292.     }
  1293.     *vnambuf = NUL;
  1294. #endif /* NOSPL */
  1295.  
  1296.     luinit();                           /* Initialize lookup() cache */
  1297.  
  1298. /* Get our home directory now.  This needed in lots of places. */
  1299.  
  1300.     cmdinited = 1;
  1301. }
  1302.  
  1303. #ifdef NT
  1304. _PROTOTYP(char * GetAppData,(int));
  1305. #endif /* NT */
  1306.  
  1307. VOID
  1308. doinit() {
  1309. #ifdef CKROOT
  1310. extern int ckrooterr;
  1311. #endif /* CKROOT */
  1312.     int x = 0, ok = 0;
  1313. #ifdef OS2
  1314.     char * ptr = 0;
  1315. #endif /* OS2 */
  1316.  
  1317.     if (!cmdinited)
  1318.       cmdini();
  1319.  
  1320. #ifdef MAC
  1321.     return;                             /* Mac Kermit has no init file */
  1322.  
  1323. #else /* !MAC */
  1324.  
  1325. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1326.  
  1327.     if (noinit) {
  1328.         kermrc[0] = '\0';
  1329.         inidir[0] = '\0';
  1330. /*
  1331.   But returning from here results in inidir[] never being set to anything.
  1332.   Instead it should be set to wherever the init file *would* have been
  1333.   executed from.  So this bit of code should be removed, and then we should
  1334.   sprinkle "if (noinit)" tests throughout the following code until we have
  1335.   set inidir[], and then return without actually taking the init file.
  1336. */
  1337.         return;
  1338.     }
  1339.  
  1340. #ifdef OS2
  1341. /*
  1342.   The -y init file must be fully specified or in the current directory.
  1343.   KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  1344.   own executable file path is taken and the .EXE suffix is replaced by .INI
  1345.   and this is tried as the initialization file.
  1346. */
  1347. #ifdef CK_LOGIN
  1348.     debug(F101,"doinit inserver","",inserver);
  1349.     debug(F101,"doinit isguest","",isguest);
  1350.     debug(F110,"doinit anonfile",anonfile,0);
  1351.  
  1352.     if (isguest && anonfile) {
  1353.       ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1354.     } else
  1355. #endif /* CK_LOGIN */
  1356.       if (rcflag) {
  1357.           ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1358. #ifdef CK_LOGIN
  1359.       } else if (inserver) {
  1360.           char * appdata = NULL;
  1361. #ifdef NT
  1362.           appdata = GetAppData(1);
  1363.           if ( appdata ) {
  1364.               ckmakmsg(line,LINBUFSIZ+1,appdata,
  1365.                         "Kermit 95/k95.ini",NULL,NULL);
  1366.               if ( zchki(line) < 0 )
  1367.                   line[0] = '\0';
  1368.           }
  1369.           if (line[0] == 0) {
  1370.               appdata = GetAppData(0);
  1371.               if ( appdata ) {
  1372.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1373.                             "Kermit 95/k95.ini",NULL,NULL);
  1374.                   if ( zchki(line) < 0 )
  1375.                       line[0] = '\0';
  1376.               }
  1377.           }
  1378. #endif /* NT */
  1379.           if (line[0] == 0) {
  1380.               appdata = zhome();
  1381.               if ( appdata ) {
  1382.                   ckmakmsg(line,LINBUFSIZ+1,appdata,
  1383. #ifdef NT
  1384.                           "k95.ini",
  1385. #else /* NT */
  1386.                           "k2.ini",
  1387. #endif /* NT */
  1388.                            NULL,NULL);
  1389.                   if ( zchki(line) < 0 )
  1390.                       line[0] = '\0';
  1391.               }
  1392.           }
  1393.           debug(F110,"doinit inserver inifile",line,0);
  1394. #endif /* CK_LOGIN */
  1395.     } else {
  1396.         char * env = 0;
  1397. #ifdef NT
  1398.         env = getenv("K95.KSC");
  1399. #else
  1400.         env = getenv("K2.KSC");
  1401. #endif /* NT */
  1402.         if (!env) {
  1403. #ifdef NT
  1404.             env = getenv("K95.INI");
  1405. #else
  1406.             env = getenv("K2.INI");
  1407. #endif /* NT */
  1408.         }
  1409.         if (!env)
  1410.           env = getenv("CKERMIT.INI");
  1411.         if (!env)
  1412.           env = getenv("CKERMIT_INI");
  1413.         line[0] = '\0';
  1414.  
  1415.         debug(F110,"doinit env",env,0);
  1416.         if (env)
  1417.           ckstrncpy(line,env,LINBUFSIZ+1);
  1418.  
  1419. #ifdef NT
  1420.         if (line[0] == 0) {
  1421.             env = GetAppData(1);
  1422.             if ( env ) {
  1423.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1424.                 if ( zchki(line) < 0 )
  1425.                     line[0] = '\0';
  1426.             }
  1427.         }
  1428.         if (line[0] == 0) {
  1429.             env = GetAppData(0);
  1430.             if ( env ) {
  1431.                 ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1432.                 if ( zchki(line) < 0 )
  1433.                     line[0] = '\0';
  1434.             }
  1435.         }
  1436. #endif /* NT */
  1437.  
  1438.         if (line[0] == 0) {
  1439.             env = zhome();
  1440.             if ( env ) {
  1441.                 ckmakmsg(line,LINBUFSIZ+1,env,
  1442. #ifdef NT
  1443.                           "k95.ini",
  1444. #else /* NT */
  1445.                           "k2.ini",
  1446. #endif /* NT */
  1447.                           NULL,NULL);
  1448.                 if ( zchki(line) < 0 )
  1449.                     line[0] = '\0';
  1450.             }
  1451.         }
  1452.  
  1453.         if (line[0] == 0)
  1454.           _searchenv(kermrc,"INIT",line);
  1455.         if (line[0] == 0)
  1456.           _searchenv(kermrc,"DPATH",line);
  1457.         if (line[0] == 0)
  1458.           _searchenv(kermrc,"PATH",line);
  1459.         if (line[0] == 0) {
  1460.             char *pgmptr = GetLoadPath();
  1461.             if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1462.                 lp = strrchr(pgmptr, '\\');
  1463.                 if (lp) {
  1464.                     strncpy(line, pgmptr, lp - pgmptr);
  1465. #ifdef NT
  1466.                     strcpy(line + (lp - pgmptr), "/k95.ini");
  1467. #else /* NT */
  1468.                     strcpy(line + (lp - pgmptr), "/k2.ini");
  1469. #endif /* NT */
  1470.                 } else {
  1471.                     lp = strrchr(pgmptr, '.');
  1472.                     if (lp) {
  1473.                         strncpy(line, pgmptr, lp - pgmptr);
  1474.                         strcpy(line + (lp - pgmptr), ".ini");
  1475.                     }
  1476.                 }
  1477.             }
  1478.         }
  1479.     }
  1480.  
  1481. #ifdef CKROOT
  1482.     if (!zinroot(line)) {
  1483.         debug(F110,"doinit setroot violation",line,0);
  1484.         return;
  1485.     }
  1486. #endif /* CKROOT */
  1487.  
  1488.     debug(F110,"doinit fopen()",line,0);
  1489.     if ((tfile[0] = fopen(line,"r")) != NULL) {
  1490.         ok = 1;
  1491.         tlevel = 0;
  1492.         tfline[tlevel] = 0;
  1493.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1494.           strcpy(tfnam[tlevel],line);   /* safe */
  1495. #ifndef NOSPL
  1496.         cmdlvl++;
  1497.         xcmdsrc = CMD_TF;
  1498.         cmdstk[cmdlvl].src = CMD_TF;
  1499.         cmdstk[cmdlvl].lvl = tlevel;
  1500.         cmdstk[cmdlvl].ccflgs = 0;
  1501.         ifcmd[cmdlvl] = 0;
  1502.         iftest[cmdlvl] = 0;
  1503.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1504.         intime[cmdlvl] = intime[cmdlvl-1];
  1505.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1506.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1507.         merror[cmdlvl] = merror[cmdlvl-1];
  1508.         xquiet[cmdlvl] = quiet;
  1509. #endif /* NOSPL */
  1510.         debug(F110,"doinit init file",line,0);
  1511.     } else {
  1512.         debug(F100,"doinit no init file","",0);
  1513.     }
  1514.     ckstrncpy(kermrc,line,KERMRCL);
  1515.     for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
  1516.        if (*ptr == '\\')
  1517.          *ptr = '/';
  1518. #else /* not OS2 */
  1519.     lp = line;
  1520.     lp[0] = '\0';
  1521.     debug(F101,"doinit rcflag","",rcflag);
  1522. #ifdef GEMDOS
  1523.     zkermini(line, rcflag, kermrc);
  1524. #else
  1525. #ifdef VMS
  1526.     {
  1527.     int x;
  1528.     x = zkermini(line,LINBUFSIZ,kermrc);
  1529.     debug(F111,"CUSTOM zkermini",line,x);
  1530.     if (x == 0)
  1531.       line[0] = NUL;
  1532.     }
  1533. #else /* not VMS */
  1534. #ifdef CK_LOGIN
  1535.     debug(F101,"doinit isguest","",isguest);
  1536.     if (isguest)
  1537.       ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1538.     else
  1539. #endif /* CK_LOGIN */
  1540.       if (rcflag) {                     /* If init file name from cmd line */
  1541.           ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1542.       } else {                          /* otherwise... */
  1543. #ifdef CK_INI_A                         /* If we've a system-wide init file */
  1544.           /* And it takes precedence over the user's... */
  1545.           ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1546.           if (zchki(lp) < 0) {          /* (if it exists...) */
  1547. #endif /* CK_INI_A */
  1548.               char * homdir;
  1549.               char * env = 0;
  1550.               line[0] = NUL;
  1551.  
  1552.               /* Add support for environment variable */
  1553.               env = getenv("CKERMIT.INI");
  1554.               if (!env)
  1555.                 env = getenv("CKERMIT_INI");
  1556.               if (env)
  1557.                 ckstrncpy(lp,env,KERMRCL);
  1558.  
  1559.               if (lp[0] == 0) {
  1560.                   homdir = zhome();
  1561.                   if (homdir) {         /* Home directory for init file. */
  1562.                       ckstrncpy(lp,homdir,KERMRCL);
  1563. #ifdef STRATUS
  1564.                       ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1565. #else
  1566.                       if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1567. #endif /* STRATUS */
  1568.                   }
  1569.                   ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1570.               }
  1571. #ifdef CK_INI_A
  1572.           }
  1573. #endif /* CK_INI_A */
  1574. #ifdef CK_INI_B                         /* System-wide init defined? */
  1575.           /* But user's ini file takes precedence */
  1576.           if (zchki(lp) < 0)            /* If user doesn't have her own, */
  1577.             ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1578. #endif /* CK_INI_B */
  1579.       }
  1580. #endif /* VMS */
  1581. #endif /* GEMDOS */
  1582.  
  1583. #ifdef AMIGA
  1584.     reqoff();                           /* Disable requestors */
  1585. #endif /* AMIGA */
  1586.  
  1587. #ifdef USE_CUSTOM
  1588.     /* If no init file was found, execute the customization file */
  1589.     debug(F110,"CUSTOM 1",line,0);
  1590.     if (!line[0] || zchki(line) < 0) {
  1591.     int x;
  1592. #ifdef OS2
  1593.     x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1594.     debug(F111,"CUSTOM 2",line,x);
  1595.     if (zchki(line) < 0) {
  1596.         x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1597.         debug(F111,"CUSTOM 3",line,x);
  1598.     }
  1599. #else  /* OS2 */
  1600.     x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1601. #ifndef VMS
  1602.     /* VMS zhome() returns "SYS$LOGIN:" */
  1603.     if (line[x-1] != DIRSEP) {
  1604.         line[x++] = DIRSEP;
  1605.         line[x] = NUL;
  1606.     }
  1607. #endif /* VMS */
  1608.     x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1609.     debug(F111,"CUSTOM 4",line,x);
  1610. #endif /* OS2 */
  1611.     }
  1612.     debug(F110,"CUSTOM 5",line,0);
  1613. #endif /* USE_CUSTOM */
  1614.  
  1615. #ifdef CKROOT
  1616.     if (!zinroot(line)) {
  1617.         debug(F110,"doinit setroot violation",line,0);
  1618.         return;
  1619.     }
  1620. #endif /* CKROOT */
  1621.  
  1622.     debug(F110,"doinit ini file is",line,0);
  1623.     if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1624.         ok = 1;
  1625.         tlevel = 0;
  1626.         tfline[tlevel] = 0;
  1627.         if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1628.           strcpy(tfnam[tlevel],line);   /* safe */
  1629.  
  1630.         ckstrncpy(kermrc,line,KERMRCL);
  1631.  
  1632. #ifndef NOSPL
  1633.         cmdlvl++;
  1634.         ifcmd[cmdlvl] = 0;
  1635.         iftest[cmdlvl] = 0;
  1636.         count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1637.         intime[cmdlvl] = intime[cmdlvl-1];
  1638.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1639.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1640.         merror[cmdlvl] = merror[cmdlvl-1];
  1641.         xquiet[cmdlvl] = quiet;
  1642.         debug(F101,"doinit open ok","",cmdlvl);
  1643.         xcmdsrc = CMD_TF;
  1644.         cmdstk[cmdlvl].src = CMD_TF;
  1645.         cmdstk[cmdlvl].lvl = tlevel;
  1646.         cmdstk[cmdlvl].ccflgs = 0;
  1647. #endif /* NOSPL */
  1648.     } else if (rcflag) {
  1649.         /* Print an error message only if a specific file was asked for. */
  1650.         printf("?%s - %s\n", ck_errstr(), line);
  1651.     }
  1652.  
  1653. #ifdef datageneral
  1654. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1655.     if (/* homdir && */ (tlevel < 0)) {
  1656.         ckstrncpy(lp,kermrc,LINBUFSIZ);
  1657.         if ((tfile[0] = fopen(line,"r")) != NULL) {
  1658.             ok = 1;
  1659.             tlevel = 0;
  1660.             tfline[tlevel] = 0;
  1661.             if (tfnam[tlevel] = malloc(strlen(line)+1))
  1662.               strcpy(tfnam[tlevel],line); /* safe */
  1663. #ifndef NOSPL
  1664.             cmdlvl++;
  1665.             xcmdsrc = CMD_TF;
  1666.             cmdstk[cmdlvl].src = CMD_TF;
  1667.             cmdstk[cmdlvl].lvl = tlevel;
  1668.             cmdstk[cmdlvl].ccflgs = 0;
  1669.             ifcmd[cmdlvl] = 0;
  1670.             iftest[cmdlvl] = 0;
  1671.             count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
  1672.             intime[cmdlvl] = intime[cmdlvl-1];
  1673.             inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1674.             takerr[cmdlvl] = takerr[cmdlvl-1];
  1675.             merror[cmdlvl] = merror[cmdlvl-1];
  1676.             xquiet[cmdlvl] = quiet;
  1677. #endif /* NOSPL */
  1678.         }
  1679.     }
  1680. #endif /* datageneral */
  1681.  
  1682. #ifdef AMIGA                            /* Amiga... */
  1683.     reqpop();                           /* Restore requestors */
  1684. #endif /* AMIGA */
  1685. #endif /* OS2 */
  1686. #endif /* MAC */
  1687.  
  1688.     /* Assign value to inidir */
  1689.  
  1690.     if (!ok) {
  1691.         inidir[0] = NUL;
  1692.     } else {
  1693.         ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1694.         x = strlen(inidir);
  1695.         if (x > 0) {
  1696.             int i;
  1697.             for (i = x - 1; i > 0; i-- ) {
  1698.                 if (ISDIRSEP(inidir[i])) {
  1699.                     inidir[i+1] = NUL;
  1700.                     break;
  1701.                 }
  1702.             }
  1703.         }
  1704. #ifdef NT
  1705.         GetShortPathName(inidir,inidir,CCHMAXPATH);
  1706. #endif /* NT */
  1707.     }
  1708. }
  1709.  
  1710. VOID
  1711. doiksdinit() {
  1712. #ifdef CK_SSL
  1713.     /* IKSD doesn't request client certs */
  1714.     ssl_verify_flag = SSL_VERIFY_NONE;
  1715. #endif /* CK_SSL */
  1716.  
  1717.     if (!cmdinited)
  1718.       cmdini();
  1719.  
  1720. #ifdef IKSDCONF
  1721. #ifdef OS2
  1722.     line[0] = '\0';
  1723.     _searchenv(iksdconf,"INIT",line);
  1724.     if (line[0] == 0)
  1725.       _searchenv(iksdconf,"DPATH",line);
  1726.     if (line[0] == 0)
  1727.       _searchenv(iksdconf,"PATH",line);
  1728.     if (line[0] == 0) {
  1729.         char *pgmptr = GetLoadPath();
  1730.         if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1731.             lp = strrchr(pgmptr, '\\');
  1732.             if (lp) {
  1733.                 strncpy(line, pgmptr, lp - pgmptr);
  1734.                 strcpy(line + (lp - pgmptr), "\\");
  1735.                 strcpy(line + (lp - pgmptr + 1), iksdconf);
  1736.             } else {
  1737.                 lp = strrchr(pgmptr, '.');
  1738.                 if (lp) {
  1739.                     strncpy(line, pgmptr, lp - pgmptr);
  1740.                     strcpy(line + (lp - pgmptr), ".ksc");
  1741.                 }
  1742.             }
  1743.         }
  1744.     }
  1745.     debug(F110,"doiksdinit() line",line,0);
  1746.     tfile[0] = fopen(line,"r");
  1747. #else /* OS2 */
  1748.     tfile[0] = fopen(iksdconf,"r");
  1749. #endif /* OS2 */
  1750.     if (tfile[0] != NULL) {
  1751.         tlevel = 0;
  1752.         tfline[tlevel] = 0;
  1753. #ifdef OS2
  1754.         if (tfnam[tlevel] = malloc(strlen(line)+1))
  1755.           strcpy(tfnam[tlevel],line);
  1756. #else /* OS2 */
  1757.         if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1758.           strcpy(tfnam[tlevel],iksdconf);
  1759. #endif /* OS2 */
  1760. #ifndef NOSPL
  1761.         cmdlvl++;
  1762.         xcmdsrc = CMD_TF;
  1763.         cmdstk[cmdlvl].src = CMD_TF;
  1764.         cmdstk[cmdlvl].lvl = tlevel;
  1765.         cmdstk[cmdlvl].ccflgs = 0;
  1766.         ifcmd[cmdlvl]  = 0;
  1767.         iftest[cmdlvl] = 0;
  1768.         count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
  1769.         intime[cmdlvl] = intime[cmdlvl-1];
  1770.         inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1771.         takerr[cmdlvl] = takerr[cmdlvl-1];
  1772.         merror[cmdlvl] = merror[cmdlvl-1];
  1773.         xquiet[cmdlvl] = quiet;
  1774. #endif /* NOSPL */
  1775.         debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1776.     } else {
  1777.         debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1778.     }
  1779. #endif /* IKSDCONF */
  1780. }
  1781.  
  1782. #ifndef NOSPL
  1783. /*
  1784.   G E T N C M
  1785.  
  1786.   Get next command from current macro definition.  Command is copied
  1787.   into string pointed to by argument s, max length n.   Returns:
  1788.    0 if a string was copied;
  1789.   -1 if there was no string to copy.
  1790. */
  1791. int
  1792. getncm(s,n) char *s; int n; {
  1793.     int y,                              /* Character counter */
  1794.     quote = 0,
  1795.     kp = 0,                             /* Brace up-down counter */
  1796.     pp = 0,                             /* Parenthesis up-down counter */
  1797. #ifndef NODQMACRO
  1798.     dq = 0;                             /* Doublequote counter */
  1799. #endif /* NODQMACRO */
  1800.     char *s2;                           /* Copy of destination pointer */
  1801.  
  1802.     s2 = s;                             /* Initialize string pointers */
  1803.     *s = NUL;                           /* and destination buffer */
  1804.  
  1805.     /* debug(F010,"getncm entry",macp[maclvl],0); */
  1806.  
  1807.     for (y = 0;                         /* Loop for n bytes max */
  1808.          macp[maclvl] && *macp[maclvl] && y < n;
  1809.          y++, s++, macp[maclvl]++) {
  1810.  
  1811.         *s = *macp[maclvl];             /* Get next char from macro def */
  1812.  
  1813. #ifndef COMMENT
  1814. /*
  1815.   This is to allow quoting of parentheses, commas, etc, in function
  1816.   arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  1817.   COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  1818.   everything again.)  <-- The preceding warning should be obsolete since the
  1819.   statements below have been fixed, but in case of fire, remove the "n" from
  1820.   the <#>ifndef above.
  1821. */
  1822.         if (!quote && *s == CMDQ) {
  1823.             quote = 1;
  1824.             continue;
  1825.         }
  1826.         if (quote) {
  1827.             quote = 0;
  1828.             continue;
  1829.         }
  1830. #endif /* COMMENT */
  1831.  
  1832. /*
  1833.   Allow braces around macro definition to prevent commas from being turned to
  1834.   end-of-lines and also treat any commas within parens as text so that
  1835.   multiple-argument functions won't cause the command to break prematurely.
  1836.   19 Oct 2001: Similar treatment was added for doublequotes, so
  1837.  
  1838.      define foo { echo "one, two, three" }
  1839.  
  1840.   would work as expected.  This doesn't seem to have broken anything but
  1841.   if something comes up later, rebuild with NODQMACRO defined.
  1842. */
  1843.         if (*s == '{') kp++;            /* Count braces */
  1844.         if (*s == '}' && kp > 0) kp--;
  1845.         if (*s == '(') pp++;            /* Count parentheses. */
  1846.         if (*s == ')' && pp > 0) pp--;
  1847. #ifndef NODQMACRO
  1848.         if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
  1849. #endif /* NODQMACRO */
  1850.         if (*s == ',' && pp <= 0 && kp <= 0
  1851. #ifndef NODQMACRO
  1852.             && dq == 0
  1853. #endif /* NODQMACRO */
  1854.             ) {
  1855.             macp[maclvl]++;             /* Comma not in {} or () */
  1856.             /* debug(F110,"next cmd",s,0); */
  1857.             kp = pp = 0;                /* so we have the next command */
  1858.             break;
  1859.         }
  1860.     }                                   /* Reached end. */
  1861. #ifdef COMMENT
  1862.     /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1863.     *s = NUL;
  1864. #endif /* COMMENT */
  1865.     if (*s2 == NUL) {                   /* If nothing was copied, */
  1866.         /* debug(F100,"getncm eom","",0); */
  1867.         popclvl();                      /* pop command level. */
  1868.         return(-1);
  1869.     } else {                            /* otherwise, tack CR onto end */
  1870.         *s++ = CR;
  1871.         *s = '\0';
  1872.         if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
  1873.           printf("%s\n",s2);
  1874.     }
  1875.     return(0);
  1876. }
  1877.  
  1878. /*  D O M A C  --  Define and then execute a macro */
  1879.  
  1880. int
  1881. domac(name, def, flags) char *name, *def; int flags; {
  1882.     int x, m;
  1883. #ifndef NOLOCAL
  1884. #ifdef OS2
  1885.     extern int term_io;
  1886.     int term_io_sav = term_io;
  1887.     term_io = 0;                        /* Disable Terminal Emulator I/O */
  1888. #endif /* OS2 */
  1889. #endif /* NOLOCAL */
  1890.     m = maclvl;                         /* Current macro stack level */
  1891.     x = addmac(name, def);              /* Define a new macro */
  1892.     if (x > -1) {                       /* If successful, */
  1893.         dodo(x,NULL,flags);             /* start it (increments maclvl). */
  1894.         while (maclvl > m) {            /* Keep going till done with it, */
  1895.             debug(F101,"domac loop maclvl 1","",maclvl);
  1896.             sstate = (CHAR) parser(1);  /* parsing & executing each command, */
  1897.             debug(F101,"domac loop maclvl 2","",maclvl);
  1898.             if (sstate) proto();        /* including protocol commands. */
  1899.         }
  1900.         debug(F101,"domac loop exit maclvl","",maclvl);
  1901.     }
  1902. #ifndef NOLOCAL
  1903. #ifdef OS2
  1904.     term_io = term_io_sav;
  1905. #endif /* OS2 */
  1906. #endif /* NOLOCAL */
  1907.     return(success);
  1908. }
  1909. #endif /* NOSPL */
  1910.  
  1911. /*
  1912.   G E T N C T
  1913.  
  1914.   Get next command from TAKE (command) file.
  1915.  
  1916.   Call with:
  1917.    s     Pointer to buffer to read into
  1918.    n     Length of buffer
  1919.    f     File descriptor of file to read from
  1920.    flag  0 == keep line terminator on and allow continuation
  1921.          1 == discard line terminator and don't allow continuation
  1922.  
  1923.   Call with flag == 0 to read a command from a TAKE file;
  1924.   Call with flag != 0 to read a line from a dialing or network directory.
  1925.  
  1926.   In both cases, trailing comments and/or trailing whitespace is/are stripped.
  1927.   If flag == 0, continued lines are combined into one line.  A continued line
  1928.   is one that ends in hypen, or any line in a "block", which starts with "{"
  1929.   at the end of a line and ends with a matching "}" at the beginning of a
  1930.   subsequent line; blocks may be nested.
  1931.  
  1932.   Returns:
  1933.    0 if a string was copied,
  1934.   -1 on EOF,
  1935.   -2 on malloc failure
  1936.   -3 if line is not properly terminated
  1937.   -4 if (possibly continued) line is too long.
  1938. */
  1939. static int lpxlen = 0;
  1940.  
  1941. int
  1942. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  1943.     int i = 0, len = 0, buflen = 0;
  1944.     char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  1945.     char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  1946.     char * prev = NULL;
  1947.     int bc = 0;                         /* Block counter */
  1948.  
  1949.     s2 = s;                             /* Remember original pointer */
  1950.     prev = s2;
  1951.     buflen = n;                         /* Remember original buffer length */
  1952.  
  1953.     if (n < 0)
  1954.       return(-2);
  1955.  
  1956.     /* Allocate a line buffer only if we don't have one that's big enough */
  1957.  
  1958.     debug(F111,"getnct",ckitoa(lpxlen),n);
  1959.  
  1960.     if (lpx && (n > lpxlen)) {          /* Have one already */
  1961.         debug(F101,"getnct new buffer","",lpxlen);
  1962.         free(lpx);                      /* But it's not big enough */
  1963.         lpx = NULL;                     /* Free current one */
  1964.         lpxlen = 0;
  1965.     }
  1966.     if (!lpx) {                         /* Get new one */
  1967.         if (!(lpx = (char *) malloc(n))) {
  1968.             debug(F101,"getnct malloc failure","",0);
  1969.             printf("?Memory allocation failure [getnct]\n");
  1970.             return(-2);
  1971.         }
  1972.         lpxlen = n;
  1973.     }
  1974.     lp2 = lpx;
  1975. #ifdef KLUDGE
  1976.     /* NOTE: No longer used as of 14 Aug 2000 */
  1977.     lp2++;
  1978. #endif /* KLUDGE */
  1979.  
  1980.     while (1) {                         /* Loop to read lines from file */
  1981.         debug(F101,"getnct while (1)","",n);
  1982.         if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
  1983.             debug(F110,"getnct EOF",s2,0); /* EOF */
  1984.             free(lpx);                  /* Free temporary storage */
  1985.             lpx = NULL;
  1986.             *s = NUL;                   /* Make destination be empty */
  1987.             return(-1);                 /* Return failure code */
  1988.         }
  1989. #ifndef NODIAL
  1990.         if (flag)                       /* Count this line */
  1991.           dirline++;
  1992.         else
  1993. #endif /* NODIAL */
  1994.           tfline[tlevel]++;
  1995.         len = strlen(lp2) - 1;          /* Position of line terminator */
  1996.         if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  1997.             lp2[++len] = '\n';          /* that is not a newline */
  1998.             lp2[len] = NUL;
  1999.         }
  2000.         debug(F010,"getnct",lp2,0);
  2001.         if (len < 0)
  2002.           len = 0;
  2003.         if (techo && pflag)             /* If TAKE ECHO ON, */
  2004.           printf("%3d. %s",             /* echo it this line. */
  2005. #ifndef NODIAL
  2006.                  flag ? dirline :
  2007. #endif /* NODIAL */
  2008.                  tfline[tlevel],
  2009.                  lp2
  2010.                  );
  2011.         lp3 = lp2;                      /* Working pointer */
  2012.         i = len;                        /* Get first nonwhitespace character */
  2013.         while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2014.             i--;
  2015.             lp3++;
  2016.         }
  2017.         if (i == 0 && bc > 0)           /* Blank line in {...} block */
  2018.           continue;
  2019.  
  2020.         /* Isolate, remove, and check terminator */
  2021.  
  2022.         c = lp2[len];                   /* Value of line terminator */
  2023.         /* debug(F101,"getnct terminator","",c); */
  2024.         if (c < LF || c > CR) {         /* It's not a terminator */
  2025.             /* debug(F111,"getnct bad line",lp2,c); */
  2026.             if (feof(f) && len > 0 && len < n) {
  2027.                 /* Kludge Alert... */
  2028.                 if (!quiet)
  2029.                   printf("WARNING: Last line of %s lacks terminator\n",
  2030.                          s2 == cmdbuf ? "command file" : "directory file");
  2031.                 c = lp2[++len] = '\n';  /* No big deal - supply one. */
  2032.             } else {                    /* Something's wrong, fail. */
  2033.                 free(lpx);
  2034.                 lpx = NULL;
  2035.                 return(-3);
  2036.             }
  2037.         }
  2038.         /* Trim trailing whitespace */
  2039.  
  2040.         for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2041.           ;
  2042.         /* debug(F101,"getnct i","",i); */
  2043.         lp2[i+1] = NUL;                 /* Terminate the string */
  2044.         /* debug(F110,"getnct lp2",lp2,0); */
  2045.         lp = lp2;                       /* Make a working pointer */
  2046.  
  2047.         /* Remove trailing or full-line comment */
  2048.  
  2049.         while ((cc = *lp)) {
  2050.             if (cc == ';' || cc == '#') { /* Comment introducer? */
  2051.                 if (lp == lp2) {        /* First char on line */
  2052.                     *lp = NUL;
  2053.                     break;
  2054.                 } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2055.                     lp--;
  2056.                     *lp = NUL;  /* Or preceded by whitespace */
  2057.                     break;
  2058.                 }
  2059.             }
  2060.             lp++;
  2061.         }
  2062.         if (lp > lp2)
  2063.           lp--;                         /* Back up over the NUL */
  2064.  
  2065.         /* Now trim any space that preceded the comment */
  2066.  
  2067.         while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2068.             *lp = NUL;
  2069.             if (lp <= lp2)
  2070.               break;
  2071.             lp--;
  2072.         }
  2073.         /* debug(F110,"getnct comment trimmed",lp2,0); */
  2074.  
  2075.         len = strlen(lp2);              /* Length after trimming */
  2076.  
  2077.         if (n - len < 2) {              /* Check remaining space */
  2078.             debug(F111,"getnct command too long",s2,buflen);
  2079.             printf("?Line too long, maximum length: %d.\n",buflen);
  2080.             free(lpx);
  2081.             return(-4);
  2082.         }
  2083.         ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
  2084.         ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */
  2085.  
  2086. #ifdef COMMENT
  2087.         /* Line containing only whitespace and ,- */
  2088.         if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2089.           continue;
  2090. #endif /* COMMENT */
  2091.  
  2092. #ifdef KLUDGE
  2093. /*
  2094.   If it is a command and it begins with a token (like ! or .) that is not
  2095.   followed by a space, insert a space now; otherwise cmkey() can get mighty
  2096.   confused.
  2097. */
  2098.         if (s == s2 && !flag) {
  2099.             char *p = toktab;
  2100.             while (*p) {
  2101.                 if (*p == *lp3 && *(p+1) != SP) {
  2102.                     debug(F110,"getnct token",p,0);
  2103.                     *lp3-- = SP;
  2104.                     *lp3 = *p;
  2105.                     if (lp3 < lp2) {
  2106.                         lp2--;
  2107.                         len++;
  2108.                     }
  2109.                     break;
  2110.                 } else
  2111.                   p++;
  2112.             }
  2113.         }
  2114. #endif /* KLUDGE */
  2115.         lp = lp2;
  2116.  
  2117.         while ((*s++ = *lp++))          /* Copy result to target buffer */
  2118.           n--;                          /* accounting for length */
  2119.         s--;                            /* Back up over the NUL */
  2120.  
  2121.         /* Check whether this line is continued */
  2122.  
  2123.         if (flag)                       /* No line continuation when flag=1 */
  2124.           break;                        /* So break out of read-lines loop */
  2125.  
  2126. #ifdef COMMENT
  2127.         debug(F000,"getnct first char","",*lp3);
  2128.         debug(F000,"getnct last char","",ccl);
  2129.         debug(F000,"getnct next-to-last char","",ccx);
  2130. #endif /* COMMENT */
  2131.  
  2132.         if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
  2133.             bc--;                               /* Decrement block counter */
  2134.         }
  2135.  
  2136.         if (bc == 0 &&                  /* Line is continued if bc > 0 */
  2137. #ifdef COMMENT
  2138.             /* Not supported as of C-Kermit 6.0 */
  2139.             ccl != CMDQ &&              /* or line ends with CMDQ */
  2140. #endif /* COMMENT */
  2141.             ccl != '-'  &&              /* or line ends with dash */
  2142.             ccl != '{')                 /* or line ends with opening brace */
  2143.           break;                        /* None of those, we're done. */
  2144.  
  2145.         if (ccl == '-' || ccl == '{')   /* Continuation character */
  2146.           if (ccx == CMDQ)              /* But it's quoted */
  2147.             break;                      /* so ignore it */
  2148.  
  2149.         if (ccl == '{') {               /* Last char on line is '{'? */
  2150.             bc++;                       /* Count the block opener. */
  2151.         } else if (ccl == '-') {        /* Explicit continue? */
  2152.             char c, * ss;
  2153.             int state = 0, nn;
  2154.             s--;                        /* Yes, back up over terminators */
  2155.             n++;                        /* and over continuation character */
  2156.             nn = n;                     /* Save current count */
  2157.             ss = s;                     /* and pointer */
  2158.             s--;                        /* Back up over dash */
  2159.             n++;
  2160.             while (state < 2 && s >= prev) { /* Check for "{,-" */
  2161.                 n++;
  2162.                 c = *s--;
  2163.                 if (c <= SP)
  2164.                   continue;
  2165.                 if (c != ',' && c != '{')
  2166.                   break;
  2167.                 switch (state) {
  2168.                   case 0:               /* Looking for comma */
  2169.                     if (c == ',')
  2170.                       state = 1;
  2171.                     break;
  2172.                   case 1:               /* Looking for left brace */
  2173.                     if (c == '{') {
  2174.                         state = 2;
  2175.                         s += 2;
  2176.                         *s = NUL;
  2177.                         bc++;
  2178.                     }
  2179.                     break;
  2180.                 }
  2181.             }
  2182.             if (state != 2) { s = ss; n = nn; }
  2183.             *s = NUL;
  2184.         } else {                        /* None of those but (bc > 0) */
  2185.             lastcomma = s;
  2186.             *s++ = ',';                 /* and insert a comma */
  2187.             n--;
  2188.         }
  2189. #ifdef COMMENT
  2190.         debug(F101,"getnct bc","",bc);
  2191.         debug(F100,"getnct continued","",0);
  2192. #endif /* COMMENT */
  2193.  
  2194.         *s = NUL;
  2195.         prev = s;
  2196.  
  2197.     } /* read-lines while loop */
  2198.  
  2199.     if (lastcomma)
  2200.       *lastcomma = SP;
  2201.     if (!flag)                          /* Tack line terminator back on */
  2202.       *s++ = c;
  2203.     *s++ = NUL;                         /* Terminate the string */
  2204.     untab(s2);                          /* Done, convert tabs to spaces */
  2205. #ifdef DEBUG
  2206.     if (!flag) {
  2207.         debug(F010,"CMD(F)",s2,0);
  2208.     }
  2209. #endif /* DEBUG */
  2210.     free(lpx);                          /* Free temporary storage */
  2211.     return(0);                          /* Return success */
  2212. }
  2213.  
  2214. VOID
  2215. shostack() {                            /* Dump the command stack */
  2216.     int i;
  2217.     char *p;
  2218. #ifndef NOSPL
  2219.     for (i = cmdlvl; i > 0; i--) {
  2220.         if (cmdstk[i].src == CMD_TF) {
  2221.             p = tfnam[cmdstk[i].lvl];
  2222.             if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2223.               p = tmpbuf;
  2224.             printf(" %2d. File  : %s (line %d)\n",
  2225.                    i,
  2226.                    p,
  2227.                    tfline[cmdstk[i].lvl]
  2228.                    );
  2229.         } else if (cmdstk[i].src == CMD_MD) {
  2230.             char * m;
  2231.             m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2232.             if (i > 0) {                 /* Special handling for 2-level */
  2233.                 char *s;                 /* built-in macros... */
  2234.                 s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2235.                 if (s && cmdstk[i-1].src == CMD_MD) {
  2236.                     if (!strcmp(s,"_forx"))
  2237.                       m = "FOR";
  2238.                     else if (!strcmp(s,"_xif"))
  2239.                       m = "XIF";
  2240.                     else if (!strcmp(s,"_while"))
  2241.                       m = "WHILE";
  2242.                     else if (!strcmp(s,"_switx"))
  2243.                       m = "SWITCH";
  2244.                 }
  2245.             }
  2246.             printf(" %2d. Macro : %s\n",i,m);
  2247.         } else if (cmdstk[i].src == CMD_KB) {
  2248.             printf(" %2d. Prompt:\n",i);
  2249.         } else {
  2250.             printf(" %2d. ERROR : Command source unknown\n",i);
  2251.         }
  2252.     }
  2253. #else
  2254.     for (i = tlevel; i > -1; i--) {
  2255.         p = tfnam[i];
  2256.         if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2257.           p = tmpbuf;
  2258.         printf(" %2d. File  : %s (line %d)\n",
  2259.                i,
  2260.                p,
  2261.                tfline[i]
  2262.                );
  2263.     }
  2264. #endif /* NOSPL */
  2265.     if (i == 0)
  2266.       printf(" %2d. Prompt: (top level)\n",0);
  2267. }
  2268.  
  2269.  
  2270. /*  P A R S E R  --  Top-level interactive command parser.  */
  2271.  
  2272. /*
  2273.   Call with:
  2274.     m = 0 for normal behavior: keep parsing and executing commands
  2275.           until an action command is parsed, then return with a
  2276.           Kermit start-state as the value of this function.
  2277.     m = 1 to parse only one command, can also be used to call parser()
  2278.           recursively.
  2279.     m = 2 to read but do not execute one command.
  2280.   In all cases, parser() returns:
  2281.     0     if no Kermit protocol action required
  2282.     > 0   with a Kermit protocol start-state.
  2283.     < 0   upon error.
  2284. */
  2285. int
  2286. parser(m) int m; {
  2287.     int tfcode, xx, yy, zz;             /* Workers */
  2288.     int is_tn = 0;
  2289.     int cdlost = 0;
  2290.  
  2291. #ifndef NOSPL
  2292.     int inlevel;                        /* Level we were called at */
  2293.     extern int askflag;
  2294. #endif /* NOSPL */
  2295.     char *cbp;                          /* Command buffer pointer */
  2296. #ifdef MAC
  2297.     extern char *lfiles;                /* Fake extern cast */
  2298. #endif /* MAC */
  2299.     extern int interrupted;
  2300. #ifndef NOXFER
  2301.     extern int sndcmd, getcmd, fatalio, clearrq;
  2302. #endif /* NOXFER */
  2303.  
  2304.     debok = 1;                          /* Undisable debugging */
  2305.  
  2306. #ifdef AMIGA
  2307.     reqres();                           /* Restore AmigaDOS requestors */
  2308. #endif /* AMIGA */
  2309.  
  2310. #ifdef OS2
  2311.     if (cursor_save > -1) {             /* Restore cursor if it was */
  2312.         cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
  2313.         cursor_save = -1;
  2314.     }
  2315. #endif /* OS2 */
  2316.  
  2317. #ifdef IKSDB
  2318.     if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2319. #endif /* IKSDB */
  2320.  
  2321.     is_tn = (local && network && IS_TELNET()) ||
  2322.       (!local && sstelnet);
  2323.  
  2324.     if (!xcmdsrc)                       /* If at top (interactive) level ... */
  2325.       concb((char)escape);              /* put console in 'cbreak' mode. */
  2326.  
  2327. #ifdef CK_TMPDIR
  2328. /* If we were cd'd temporarily to another device or directory ... */
  2329.     if (f_tmpdir) {
  2330.         int x;
  2331.         x = zchdir((char *) savdir);    /* ... restore previous directory */
  2332.         f_tmpdir = 0;                   /* and remember we did it. */
  2333.         debug(F111,"parser tmpdir restoring",savdir,x);
  2334.     }
  2335. #endif /* CK_TMPDIR */
  2336.  
  2337. #ifndef NOSPL
  2338.     inlevel = cmdlvl;           /* Current macro level */
  2339. #ifdef DEBUG
  2340.     if (deblog) {
  2341.         debug(F101,"&parser entry maclvl","",maclvl);
  2342.         debug(F101,"&parser entry inlevel","",inlevel);
  2343.         debug(F101,"&parser entry tlevel","",tlevel);
  2344.         debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2345.         debug(F101,"&parser entry m","",m);
  2346.     }
  2347. #endif /* DEBUG */
  2348. #endif /* NOSPL */
  2349.  
  2350. #ifndef NOXFER
  2351.     ftreset();                          /* Reset global file settings */
  2352. #endif /* NOXFER */
  2353. /*
  2354.   sstate becomes nonzero when a command has been parsed that requires some
  2355.   action from the protocol module.  Any non-protocol actions, such as local
  2356.   directory listing or terminal emulation, are invoked directly from below.
  2357. */
  2358.     sstate = 0;                         /* Start with no start state. */
  2359.  
  2360. #ifndef NOXFER
  2361. #ifndef NOSPL
  2362.     query = 0;                          /* QUERY not active */
  2363. #endif /* NOSPL */
  2364. #ifndef NOHINTS
  2365.     if (!success) {
  2366.         if (local && !network && carrier != CAR_OFF) {
  2367.             int x;                      /* Serial connection */
  2368.             x = ttgmdm();               /* with carrier checking */
  2369.             if (x > -1) {
  2370.                 if (!(x & BM_DCD)) {
  2371.                     cdlost = 1;
  2372.                     fatalio = 1;
  2373.                 }
  2374.             }
  2375.         }
  2376.     }
  2377. #ifdef DEBUG
  2378.     if (deblog) {
  2379.         debug(F101,"parser top what","",what);
  2380.         debug(F101,"parser top interrupted","",interrupted);
  2381.         debug(F101,"parser top cdlost","",cdlost);
  2382.         debug(F101,"parser top sndcmd","",sndcmd);
  2383.         debug(F101,"parser top getcmd","",getcmd);
  2384.     }
  2385. #endif /* DEBUG */
  2386.     if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2387.         printf("?Connection broken (carrier signal lost)\n");
  2388.     }
  2389.     if (sndcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2390.         int x = 0, n = 0;
  2391.         printf("\n*************************\n");
  2392.         printf("SEND-class command failed.\n");
  2393.         printf(" Packets sent: %d\n", spackets);
  2394.         printf(" Retransmissions: %d\n",retrans);
  2395.         printf(" Timeouts: %d\n", timeouts);
  2396.         printf(" Damaged packets: %d\n", crunched);
  2397.         if (epktrcvd) {
  2398.             printf(" Transfer canceled by receiver.\n");
  2399.             printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2400.             n++;
  2401.         } else {
  2402.             if (epktmsg) if (*epktmsg) {
  2403.                 printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2404.                 n++;
  2405.             }
  2406.         }
  2407.         if (local && !network && carrier != CAR_OFF) {
  2408.             int xx;                     /* Serial connection */
  2409.             xx = ttgmdm();              /* with carrier checking */
  2410.             if (xx > -1) {
  2411.                 if (!(xx & BM_DCD))
  2412.                   cdlost = 1;
  2413.             }
  2414.         }
  2415.  
  2416. #ifdef UNIX
  2417.         if (errno != 0)
  2418. #endif /* UNIX */
  2419.           {
  2420.               printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2421.               n++;
  2422.           }
  2423.         printf(
  2424.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2425.                (n > 1) ? "s do" : " does"
  2426.                );
  2427. #ifndef NOLOCAL
  2428.         if (local) {
  2429.             if (rpackets == 0) {
  2430.                 printf(" . Did you start a Kermit receiver on the far end?\n");
  2431.             } else {
  2432.                 printf(
  2433.                 " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2434.                 if (!network && mdmtyp > 0)
  2435.                   if ((3 * crunched) > spackets)
  2436.                     printf(
  2437.                 " . Try placing a new call to get a cleaner connection.\n");
  2438.             }
  2439.         } else if (rpackets > 0) {
  2440.             if (flow == FLO_NONE)
  2441.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2442.             else
  2443.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2444.         }
  2445.         x++;
  2446. #endif /* NOLOCAL */
  2447.  
  2448.         if ((3 * timeouts) > spackets)
  2449.           printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2450.         if ((3 * retrans) > spackets)
  2451.           printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2452.  
  2453. #ifdef CK_SPEED
  2454.         if (prefixing != PX_ALL && rpackets > 2) {
  2455.             printf(" . Try it again with SET PREFIXING ALL.\n");
  2456.             x++;
  2457.         }
  2458. #endif /* CK_SPEED */
  2459. #ifdef STREAMING
  2460.         if (streamed) {
  2461.             printf(" . Try it again with SET STREAMING OFF.\n");
  2462.             x++;
  2463.         } else if (reliable) {
  2464.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2465.             x++;
  2466.         }
  2467. #endif /* STREAMING */
  2468.  
  2469. #ifdef CK_SPEED
  2470.         if (clearrq > 0 && prefixing == PX_NON) {
  2471.             printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");
  2472.             x++;
  2473.         }
  2474. #endif /* CK_SPEED */
  2475.         if (!parity) {
  2476.             printf(" . Try it again with SET PARITY SPACE.\n");
  2477.             x++;
  2478.         }
  2479.         printf(" . %sive a ROBUST command and try again.\n",
  2480.                (x > 0) ? "As a last resort, g" : "G"
  2481.                );
  2482.         printf("Also:\n");
  2483.         printf(" . Be sure the source file has read permission.\n");
  2484.         printf(" . Be sure the target directory has write permission.\n");
  2485.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2486.         printf("*************************\n\n");
  2487.     }
  2488.     debug(F101,"topcmd","",topcmd);
  2489.     if (getcmd && !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2490.         int x = 0;
  2491.         extern int urpsiz, wslotr;
  2492.         printf("\n*************************\n");
  2493.         printf("RECEIVE- or GET-class command failed.\n");
  2494.         printf(" Packets received: %d\n", rpackets);
  2495.         printf(" Damaged packets: %d\n", crunched);
  2496.         printf(" Timeouts: %d\n", timeouts);
  2497.         if (rpackets > 0)
  2498.           printf(" Packet length: %d\n", urpsiz);
  2499.         if (epktrcvd) {
  2500.             printf(" Transfer canceled by sender.\n");
  2501.             printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2502.         }
  2503. #ifdef UNIX
  2504.         if (errno != 0)
  2505. #endif /* UNIX */
  2506.           printf(" Most recent local error: \"%s\"\n",ck_errstr());
  2507.         printf(
  2508.    "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2509.                epktrcvd ? "s do" : " does"
  2510.                );
  2511. #ifndef NOLOCAL
  2512.         if (local) {
  2513.             if (topcmd == XXGET)
  2514.               printf(" . Did you start a Kermit SERVER on the far end?\n");
  2515.             if (rpackets == 0) {
  2516.                 if (topcmd != XXGET)
  2517.                   printf(" . Did you start a Kermit SENDer on the far end?\n");
  2518.             } else {
  2519.                 printf(
  2520.                 " . Choose a different FLOW-CONTROL setting and try again.\n");
  2521.             }
  2522.         } else if (topcmd == XXGET)
  2523.           printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2524.         if (rpackets > 0 && urpsiz > 90)
  2525.           printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2526.         if (rpackets > 0 && wslotr > 1 && !streamed)
  2527.           printf(" . Try a smaller window size (SET WINDOW).\n");
  2528.         if (!local && rpackets > 0) {
  2529.             if (flow == FLO_NONE)
  2530.              printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2531.             else
  2532.              printf(" . Give me a SET FLOW NONE command and try again.\n");
  2533.         }
  2534.         x++;
  2535. #endif /* NOLOCAL */
  2536. #ifdef STREAMING
  2537.         if (streamed) {
  2538.             printf(" . Try it again with SET STREAMING OFF.\n");
  2539.             x++;
  2540.         } else if (reliable && local) {
  2541.             printf(" . Try it again with SET RELIABLE OFF.\n");
  2542.             x++;
  2543.         } else
  2544. #endif /* STREAMING */
  2545.         if (!parity) {
  2546.             printf(" . Try it again with SET PARITY SPACE.\n");
  2547.             x++;
  2548.         }
  2549.         printf((x > 0) ?
  2550.                " . As a last resort, give a ROBUST command and try again.\n" :
  2551.                " . Give a ROBUST command and try again.\n"
  2552.                );
  2553.         printf("Also:\n");
  2554.         printf(" . Be sure the target directory has write permission.\n");
  2555.         printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2556.                topcmd == XXGET ? "server" : "sender"
  2557.                );
  2558.         printf(" . Try giving a ROBUST command to the %s.\n",
  2559.                topcmd == XXGET ? "server" : "sender"
  2560.                );
  2561.         printf("(Use SET HINTS OFF to suppress hints.)\n");
  2562.         printf("*************************\n\n");
  2563.     }
  2564. #endif /* NOHINTS */
  2565.     getcmd = 0;
  2566.     sndcmd = 0;
  2567.     interrupted = 0;
  2568. #endif /* NOXFER */
  2569.  
  2570.     what = W_COMMAND;                   /* Now we're parsing commands. */
  2571.  
  2572.     while (sstate == 0) {               /* Parse cmds until action requested */
  2573.         debug(F100,"parse top","",0);
  2574. #ifdef OS2
  2575.         if (apcactive == APC_INACTIVE)
  2576.           WaitCommandModeSem(-1);
  2577. #endif /* OS2 */
  2578. #ifdef IKS_OPTION
  2579.         if ((local &&
  2580.              !xcmdsrc &&
  2581.              is_tn &&
  2582.              TELOPT_ME(TELOPT_KERMIT) &&
  2583.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2584.             (!local &&
  2585.              !cmdadl &&
  2586.              TELOPT_ME(TELOPT_KERMIT) &&
  2587.              TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2588.             ) {
  2589.             tn_siks(KERMIT_STOP);
  2590.         }
  2591. #endif /* IKS_OPTION */
  2592.  
  2593. #ifndef NOXFER
  2594.         if (autopath) {
  2595.             fnrpath = PATH_AUTO;
  2596.             autopath = 0;
  2597.         }
  2598.         remfile = 0;                    /* Clear these in case REMOTE */
  2599.         remappd = 0;                    /* command was interrupted... */
  2600.         rempipe = 0;
  2601.         makestr(&snd_move,g_snd_move);  /* Restore these */
  2602.         makestr(&rcv_move,g_rcv_move);
  2603.         makestr(&snd_rename,g_snd_rename);
  2604.         makestr(&rcv_rename,g_rcv_rename);
  2605. #endif /* NOXFER */
  2606.         xaskmore = saveask;             /* Restore global more-prompting */
  2607.         diractive = 0;
  2608.         cdactive = 0;
  2609.  
  2610. #ifndef NOSPL
  2611.         askflag = 0;
  2612. #endif /* NOSPL */
  2613.  
  2614.     /* Take requested action if there was an error in the previous command */
  2615.  
  2616.         setint();
  2617.         debug(F101,"parser tlevel","",tlevel);
  2618.         debug(F101,"parser cmd_rows","",cmd_rows);
  2619.  
  2620. #ifndef NOLOCAL
  2621.         debug(F101,"parser wasclosed","",wasclosed);
  2622.         if (wasclosed) {                /* If connection was just closed */
  2623. #ifndef NOSPL
  2624.             int k;
  2625.             k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2626.             if (k >= 0) {               /* If found, */
  2627.                 /* printf("ON_CLOSE CMD LOOP\n"); */
  2628.                 dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2629.             }
  2630. #endif /* NOSPL */
  2631.             whyclosed = WC_REMO;
  2632.             wasclosed = 0;
  2633.         }
  2634. #endif /* NOLOCAL */
  2635.  
  2636. #ifndef NOSPL
  2637.         xxdot = 0;                      /* Clear this... */
  2638.  
  2639.         debug(F101,"parser success","",success);
  2640.         if (success == 0) {
  2641.             if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2642.                 printf("Command file terminated by error.\n");
  2643.                 popclvl();
  2644.                 if (cmdlvl == 0) return(0);
  2645.             }
  2646.             if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2647.                 printf("Command error: macro terminated.\n");
  2648.                 popclvl();
  2649.                 if (m && (cmdlvl < inlevel))
  2650.                   return((int) sstate);
  2651.             }
  2652.         }
  2653.         nulcmd = (m == 2);
  2654.         debug(F101,"parser nulcmd","",nulcmd);
  2655. #else
  2656.         if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2657.             printf("Command file terminated by error.\n");
  2658.             popclvl();
  2659.             cmini(ckxech);              /* Clear the cmd buffer. */
  2660.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2661.               return(0);                /* End of init file or whatever. */
  2662.         }
  2663. #endif /* NOSPL */
  2664.  
  2665. #ifdef MAC
  2666.         /* Check for TAKE initiated by menu. */
  2667.         if ((tlevel == -1) && lfiles)
  2668.             startlfile();
  2669. #endif /* MAC */
  2670.  
  2671.         /* If in TAKE file, check for EOF */
  2672. #ifndef NOSPL
  2673. #ifdef MAC
  2674.         if
  2675. #else
  2676.         while
  2677. #endif /* MAC */
  2678.           ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
  2679.                && (tlevel > -1)
  2680.                && feof(tfile[tlevel])) {
  2681.             popclvl();                  /* pop command level */
  2682.             cmini(ckxech);              /* and clear the cmd buffer. */
  2683.             if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
  2684.                 return(0);              /* End of init file or whatever. */
  2685.             }
  2686.         }
  2687. #ifdef MAC
  2688.         miniparser(1);
  2689.         if (sstate == 'a') {            /* if cmd-. cancel */
  2690.             debug(F100, "parser: cancel take due to sstate", "", sstate);
  2691.             sstate = '\0';
  2692.             dostop();
  2693.             return(0);                  /* End of init file or whatever. */
  2694.         }
  2695. #endif /*  MAC */
  2696.  
  2697. #else /* NOSPL */
  2698.         if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2699.             popclvl();                  /* Pop up one level. */
  2700.             cmini(ckxech);              /* and clear the cmd buffer. */
  2701.             if (tlevel < 0)             /* Just popped out of cmd files? */
  2702.               return(0);                /* End of init file or whatever. */
  2703.         }
  2704. #endif /* NOSPL */
  2705.  
  2706.  
  2707. #ifndef NOSPL
  2708.         debug(F101,"parser cmdlvl","",cmdlvl);
  2709.         debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2710.  
  2711.         if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2712.             debug(F100,"parser macro","",0);
  2713.             maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2714.             debug(F101,"parser maclvl","",maclvl);
  2715.             cbp = cmdbuf;               /* Copy next cmd to command buffer. */
  2716.             *cbp = NUL;
  2717.             if (*savbuf) {              /* In case then-part of 'if' command */
  2718.                 ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2719.                 *savbuf = '\0';
  2720.             } else {                    /* Else get next cmd from macro def */
  2721.                 if (getncm(cbp,CMDBL) < 0) {
  2722. #ifdef DEBUG
  2723.                     if (deblog) {
  2724.                         debug(F101,"parser end of macro m","",m);
  2725.                         debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2726.                         debug(F101,"parser end of macro inlevel","",inlevel);
  2727.                     }
  2728. #endif /* DEBUG */
  2729.                     if (m && (cmdlvl < inlevel))
  2730.                       return((int) sstate);
  2731.                     else /* if (!m) */ continue;
  2732.                 }
  2733.             }
  2734.             debug(F010,"CMD(M)",cmdbuf,0);
  2735.  
  2736.         } else if (cmdstk[cmdlvl].src == CMD_TF)
  2737. #else
  2738.           if (tlevel > -1)
  2739. #endif /* NOSPL */
  2740.           {
  2741. #ifndef NOSPL
  2742.             debug(F111,"parser savbuf",savbuf,tlevel);
  2743.             if (*savbuf) {              /* In case THEN-part of IF command */
  2744.                 ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2745.                 *savbuf = '\0';
  2746.             } else
  2747. #endif /* NOSPL */
  2748.  
  2749.               /* Get next line from TAKE file */
  2750.  
  2751.               if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2752.                   debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2753.                   if (tfcode < -1) {    /* Error */
  2754.                       printf("?Error in TAKE command file: %s\n",
  2755.                              (tfcode == -2) ? "Memory allocation failure" :
  2756.                              "Line too long or contains NUL characters"
  2757.                              );
  2758.                       dostop();
  2759.                   }
  2760.                   continue;             /* -1 means EOF */
  2761.               }
  2762.  
  2763.         /* If interactive, get next command from user. */
  2764.  
  2765.         } else {                        /* User types it in. */
  2766.             if (pflag) prompt(xxstring);
  2767.             cmini(ckxech);
  2768.         }
  2769.  
  2770.     /* Now we know where next command is coming from. Parse and execute it. */
  2771.  
  2772.         repars = 1;                     /* 1 = command needs parsing */
  2773. #ifndef NOXFER
  2774.         displa = 0;                     /* Assume no file transfer display */
  2775. #endif /* NOXFER */
  2776.  
  2777.         while (repars) {                /* Parse this cmd until entered. */
  2778.  
  2779.             debug(F101,"parser top of while loop","",0);
  2780.  
  2781. #ifdef RECURSIVE
  2782.             /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2783.             recursive = 0;              /* This is never sticky */
  2784. #endif /* RECURSIVE */
  2785.             xfiletype = -1;             /* Reset this between each command */
  2786. #ifndef NOMSEND
  2787.             addlist = 0;
  2788. #endif /* NOMSEND */
  2789. #ifdef CK_RECALL
  2790.             on_recall = 1;
  2791. #endif /* CK_RECALL */
  2792.             /* This might have been changed by a switch */
  2793.             if (g_matchdot > -1) {
  2794.                 matchdot = g_matchdot;
  2795.                 g_matchdot = -1;
  2796.             }
  2797.             cmres();                    /* Reset buffer pointers. */
  2798.  
  2799. #ifdef OS2
  2800. #ifdef COMMENT
  2801.             /* we check to see if a macro is waiting to be executed */
  2802.             /* if so, we call domac on it */
  2803.             if (cmdmac) {
  2804.                 ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2805.                 free(cmdmac);
  2806.                 cmdmac = NULL;
  2807.             }
  2808. #endif /* COMMENT */
  2809. #endif /* OS2 */
  2810. #ifndef NOXFER
  2811.             bye_active = 0;
  2812. #endif /* NOXFER */
  2813.             havetoken = 0;
  2814.             xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2815.             debug(F101,"top-level cmkey2","",xx);
  2816.             if (xx == -5) {
  2817.                 yy = chktok(toktab);
  2818.                 debug(F101,"top-level cmkey token","",yy);
  2819. #ifndef COMMENT
  2820.                 /* Either way makes absolutely no difference */
  2821.                 debug(F110,"NO UNGWORD",atmbuf,0);
  2822.                 /* ungword(); */
  2823. #else
  2824.                 debug(F110,"TOKEN UNGWORD",atmbuf,0);
  2825.                 ungword();
  2826. #endif /* COMMENT */
  2827.                 switch (yy) {
  2828.                   case '#': xx = XXCOM; break; /* Comment */
  2829.                   case ';': xx = XXCOM; break; /* Comment */
  2830. #ifndef NOSPL
  2831.                   case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  2832.                   case ':': xx = XXLBL; break; /* GOTO label */
  2833. #endif /* NOSPL */
  2834.  
  2835. #ifndef NOPUSH
  2836. #ifdef CK_REDIR
  2837.                   case '<':
  2838. #endif /* CK_REDIR */
  2839.                   case '@':
  2840.                   case '!':
  2841.                     if (nopush) {
  2842.                         char *s; int x;
  2843.                         if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  2844.                           return(x);
  2845.                         success = 0;
  2846.                         xx = XXCOM;
  2847.                     } else {
  2848.                         switch(yy) {
  2849. #ifdef CK_REDIR
  2850.                           case '<': xx = XXFUN; break; /* REDIRECT */
  2851. #endif /* CK_REDIR */
  2852.                           case '@':
  2853.                           case '!': xx = XXSHE; break; /* Shell escape */
  2854.                         }
  2855.                     }
  2856.                     break;
  2857. #endif /* NOPUSH */
  2858. #ifdef CK_RECALL
  2859.                   case '^': xx = XXREDO;  break;
  2860. #endif /* CK_RECALL */
  2861. #ifndef NOSPL
  2862.                   case '{': xx = XXMACRO; break;
  2863.                   case '(': xx = XXSEXP;  break;
  2864. #endif /* NOSPL */
  2865.  
  2866.                   default:
  2867.                     if (!quiet) {
  2868.                         printf("\n?Invalid - \"%s\"\n",cmdbuf);
  2869. #ifdef COMMENT
  2870. #ifndef NOSPL
  2871.                         if (maclvl > -1 && xcmdsrc == 2)
  2872.                           printf("Macro: %s; ",
  2873.                                  m_arg[maclvl][0] ?
  2874.                                  m_arg[maclvl][0] : "");
  2875. #endif /* NOSPL */
  2876.                         if (tlevel > -1) {
  2877.                             printf("Command file: %s, line %d\n",
  2878.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  2879.                                    tfline[tlevel]
  2880.                                    );
  2881.                         }
  2882. #else
  2883.                         if (xcmdsrc > 0) {
  2884.                             printf("Command stack:\n");
  2885.                             shostack();
  2886.                         }
  2887. #endif /* COMMENT */
  2888.  
  2889.                     }
  2890.                     xx = -2;
  2891.                 }
  2892.                 havetoken = 1;
  2893.                 debug(F101,"HAVE TOKEN","",xx);
  2894.             }
  2895.             if (xx > -1) {
  2896.                 topcmd = xx;            /* Top-level command index */
  2897. #ifndef NOSPL
  2898.                 if (maclvl > -1)
  2899.                   lastcmd[maclvl] = xx;
  2900. #endif /* NOSPL */
  2901.                 debug(F101,"topcmd","",topcmd);
  2902.                 debug(F101,"cmflgs","",cmflgs);
  2903.             }
  2904.  
  2905. #ifndef NOSPL
  2906.             /* Special handling for IF..ELSE */
  2907.  
  2908.             debug(F101,"cmdlvl","",cmdlvl);
  2909.             debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  2910.  
  2911.             if (ifcmd[cmdlvl])          /* Count stmts after IF */
  2912.               ifcmd[cmdlvl]++;
  2913.             if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  2914.               ifcmd[cmdlvl] = 0;
  2915.  
  2916.             /* Execute the command and take action based on return code. */
  2917.  
  2918.             if (nulcmd) {               /* Ignoring this command? */
  2919.                 xx = XXCOM;             /* Make this command a comment. */
  2920.             }
  2921.             fnsuccess = 1;              /* For catching \function() errors */
  2922. #endif /* NOSPL */
  2923.  
  2924.             debug(F101,"calling docmd()","",xx);
  2925.             zz = docmd(xx);             /* Parse rest of command & execute. */
  2926.  
  2927. #ifndef NOSPL
  2928.             if (fnerror && !fnsuccess)
  2929.               success = 0;
  2930. #endif /* NOSPL */
  2931.             debug(F101,"docmd returns","",zz);
  2932.             /* debug(F011,"cmdbuf",cmdbuf,30); */
  2933.             /* debug(F011,"atmbuf",atmbuf,30); */
  2934. #ifdef MAC
  2935.             if (tlevel > -1) {
  2936.                 if (sstate == 'a') {    /* if cmd-. cancel */
  2937.                     debug(F110, "parser: cancel take, sstate:", "a", 0);
  2938.                     sstate = '\0';
  2939.                     dostop();
  2940.                     return(0);          /* End of init file or whatever. */
  2941.                 }
  2942.             }
  2943. #endif /* MAC */
  2944.             switch (zz) {
  2945.               case -4:                  /* EOF (e.g. on redirected stdin) */
  2946.                 doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  2947.               case -1:                  /* Reparse needed */
  2948.                 repars = 1;             /* Just set reparse flag and... */
  2949.                 continue;
  2950. #ifdef OS2
  2951.               case -7:                  /* They typed a disk letter */
  2952.                 if (!zchdir((char *)cmdbuf)) {
  2953.                     perror((char *)cmdbuf);
  2954.                     success = 0;
  2955.                 } else success = 1;
  2956.                 repars = 0;
  2957.                 continue;
  2958.  
  2959. #endif /* OS2 */
  2960.               case -6:                  /* Invalid command given w/no args */
  2961.               case -2:                  /* Invalid command given w/args */
  2962. #ifdef COMMENT
  2963. #ifndef NOSPL
  2964.                     /* This is going to be really ugly... */
  2965.                     yy = mlook(mactab,atmbuf,nmac); /* Look in macro table */
  2966.                     if (yy > -1) {                  /* If it's there */
  2967.                         if (zz == -2) {             /* insert "do" */
  2968.                             char *mp;
  2969.                             mp = malloc((int)strlen(cmdbuf) + 5);
  2970.                             if (!mp) {
  2971.                                 printf("?malloc error 1\n");
  2972.                                 return(-2);
  2973.                             }
  2974.                             sprintf(mp,"do %s ",cmdbuf); /* SAFE (checked) */
  2975.                             ckstrncpy(cmdbuf,mp,CMDBL);
  2976.                             free(mp);
  2977.                             mp = NULL;
  2978.                         } else {
  2979.                             if (((int)strlen(atmbuf) + 5) < CMDBL)
  2980.                               sprintf(cmdbuf,"do %s %c",atmbuf, CR); /* SAFE */
  2981.                             else
  2982.                               ckstrncpy(cmdbuf,"echo ?Too long\r",CMDBL);
  2983.                         }
  2984.                         if (ifcmd[cmdlvl] == 2) /* This one doesn't count! */
  2985.                           ifcmd[cmdlvl]--;
  2986.                         debug(F111,"stuff cmdbuf",cmdbuf,zz);
  2987.                         repars = 1;     /* Go for reparse */
  2988.                         continue;
  2989.                     } else {
  2990.                         char *p;
  2991.                         int n;
  2992.                         p = cmdbuf;
  2993.                         lp = line;
  2994.                         n = LINBUFSIZ;
  2995.                         if (cmflgs == 0) printf("\n");
  2996.                         if (zzstring(p,&lp,&n) > -1)
  2997.                           printf("?Invalid: %s\n",line);
  2998.                         else
  2999.                           printf("?Invalid: %s\n",cmdbuf);
  3000.                     } /* (fall thru...) */
  3001. #else
  3002.                     printf("?Invalid: %s\n",cmdbuf);
  3003. #endif /* NOSPL */
  3004. #else /* Not COMMENT */
  3005.                     printf("?Invalid: %s\n",cmdbuf);
  3006. #endif /* COMMENT */
  3007.  
  3008.                 case -9:                /* Bad, error message already done */
  3009.                     success = 0;
  3010.                     debug(F110,"top-level cmkey failed",cmdbuf,0);
  3011.                     /* If in background w/ commands coming stdin, terminate */
  3012.                     if (pflag == 0 && tlevel < 0)
  3013.                       fatal("Kermit command error in background execution");
  3014. /*
  3015.   Command retry feature, edit 190.  If we're at interactive prompting level,
  3016.   reprompt the user with as much of the command as didn't fail.
  3017. */
  3018. #ifdef CK_RECALL
  3019.                     if (cm_retry && !xcmdsrc) { /* If at top level */
  3020.                         int len;
  3021.                         char *p, *s;
  3022.                         len = strlen(cmdbuf); /* Length of command buffer */
  3023.                         p = malloc(len + 1);  /* Allocate space for copy */
  3024.                         if (p) {              /* If we got the space copy */
  3025.                             strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3026.                             /* Chop off final field, the one that failed. */
  3027.                             s = p + len - 1;          /* Point to end */
  3028.                             while (*s == SP && s > p) /* Trim blanks */
  3029.                               s--;
  3030.                             while (*s != SP && s > p) /* Trim last field */
  3031.                               s--;
  3032.                             if (s > p)        /* Keep the space */
  3033.                               s++;            /* after last good field */
  3034.                             if (s >= p)       /* Cut off remainder */
  3035.                               *s = NUL;
  3036.                             cmini(ckxech);    /* Reinitialize the parser */
  3037.                             ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3038.                             free(p);          /* Free temporary storage */
  3039.                             p = NULL;
  3040.                             prompt(xxstring); /* Reprint the prompt */
  3041.                             printf("%s",cmdbuf); /* Reprint partial command */
  3042.                             repars = 1;          /* Force reparse */
  3043.                             continue;
  3044.                         }
  3045.                     } else
  3046. #endif /* CK_RECALL */
  3047.                       if (!quiet) {
  3048. #ifdef COMMENT
  3049. #ifndef NOSPL
  3050.                           if (maclvl > -1)
  3051.                             printf("Macro: %s; ",
  3052.                                    m_arg[maclvl][0] ?
  3053.                                    m_arg[maclvl][0] : "");
  3054. #endif /* NOSPL */
  3055.                           if (tlevel > -1)
  3056.                             printf("Command file: %s, line %d\n",
  3057.                                    tfnam[tlevel] ? tfnam[tlevel] : "",
  3058.                                    tfline[tlevel]
  3059.                                    );
  3060. #else
  3061.                           if (xcmdsrc > 0) {
  3062.                               printf("Command stack:\n");
  3063.                               shostack();
  3064.                           }
  3065. #endif /* COMMENT */
  3066.                       }
  3067.                       cmini(ckxech);    /* (fall thru) */
  3068.  
  3069.                 case -3:                /* Empty command OK at top level */
  3070.                     repars = 0;         /* Don't need to reparse. */
  3071.                     continue;           /* Go back and get another command. */
  3072.  
  3073.                 default:                /* Command was successful. */
  3074. #ifndef NOSPL
  3075.                     debug(F101,"parser preparing to continue","",maclvl);
  3076. #endif /* NOSPL */
  3077.                     debug(F101,"parser success","",success);
  3078.                     repars = 0;         /* Don't need to reparse. */
  3079.                     continue;           /* Go back and get another command. */
  3080.                 }
  3081.         }
  3082. #ifndef NOSPL
  3083.         debug(F101,"parser breaks out of while loop","",maclvl);
  3084.         if (m && (cmdlvl < inlevel))  return((int) sstate);
  3085. #endif /* NOSPL */
  3086.     }
  3087.  
  3088. /* Got an action command, return start state. */
  3089.  
  3090.     return((int) sstate);
  3091. }
  3092.  
  3093. #ifndef NOSPL
  3094. /*
  3095.   OUTPUT command.
  3096.   Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3097. */
  3098. #define OBSIZE 80                       /* Size of local character buffer */
  3099.  
  3100. static int obn;                         /* Buffer offset (high water mark) */
  3101. static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
  3102. static char *obp;                       /* Pointer to output buffer. */
  3103. _PROTOTYP( static int oboc, (char) );
  3104. _PROTOTYP( static int xxout, (char *, int) );
  3105.  
  3106. static int
  3107. #ifdef CK_ANSIC
  3108. xxout(char *obuf, int obsize)
  3109. #else
  3110. xxout(obuf, obsize) char *obuf; int obsize;
  3111. #endif /* CK_ANSIC */
  3112. /* xxout */ {                           /* OUTPUT command's output function */
  3113.     int i, rc;
  3114.  
  3115.     debug(F101,"xxout obsize","",obsize);
  3116.     debug(F101,"xxout pacing","",pacing);
  3117.     debug(F111,"xxout string",obuf,strlen(obuf));
  3118.  
  3119.     rc = 0;                             /* Initial return code. */
  3120.     if (!obuf || (obsize <= 0))         /* Nothing to output. */
  3121.       goto xxout_x;                     /* Return successfully */
  3122.  
  3123.     rc = -1;                              /* Now assume failure */
  3124.     if (pacing == 0) {                    /* Is pacing enabled? */
  3125.         if ((local ?                      /* No, write entire string at once */
  3126.              ttol((CHAR *)obuf, obsize) : /* to communications device */
  3127.              conxo(obsize, obuf))         /* or to console */
  3128.             != obsize)
  3129.           goto xxout_x;
  3130.     } else {
  3131.         for (i = 0; i < obsize; i++) {  /* Write individual chars */
  3132.             if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3133.               goto xxout_x;
  3134.             msleep(pacing);
  3135.         }
  3136.     }
  3137.     if (duplex) {
  3138. #ifdef OS2
  3139.         if (inecho && local) {
  3140. #ifndef NOLOCAL
  3141.             for (i = 0; i < obsize; i++) { /* Write to emulator */
  3142.                 scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3143.             }
  3144. #endif /* NOLOCAL */
  3145.             conxo(obsize,obuf);
  3146.         } else if (seslog) {            /* or log session here */
  3147.             logstr((char *) obuf, obsize);
  3148.         }
  3149. #else /* OS2 */
  3150.         if (seslog) {
  3151.             logstr((char *) obuf, obsize);
  3152.         }
  3153.         if (inecho && local) {
  3154.             conxo(obsize,obuf);
  3155.         }
  3156. #endif /* OS2 */
  3157.     }
  3158.     rc = 0;                             /* Success */
  3159.   xxout_x:
  3160.     obn = 0;                            /* Reset count */
  3161.     obp = obuf;                         /* and pointers */
  3162.     return(rc);                         /* return our return code */
  3163. }
  3164.  
  3165. #ifdef COMMENT
  3166. /*
  3167.   Macros for OUTPUT command execution, to make it go faster.
  3168. */
  3169. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3170. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3171.  
  3172. #else /* The macros cause some compilers to generate bad code. */
  3173.  
  3174. static int
  3175. #ifdef CK_ANSIC
  3176. oboc(char c)
  3177. #else
  3178. oboc(c) char c;
  3179. #endif /* CK_ANSIC */
  3180. /* oboc */ {                            /* OUTPUT command's output function */
  3181.  
  3182.     *obp++ = c;                         /* Deposit character */
  3183.     *obp = NUL;                         /* Flush buffer if it's now full */
  3184.  
  3185.     return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3186. }
  3187. #endif /* COMMENT */
  3188.  
  3189. /*  Routines for handling local variables -- also see popclvl().  */
  3190.  
  3191. VOID
  3192. freelocal(m) int m; {                   /* Free local variables */
  3193.     struct localvar * v, * tv;          /* at macro level m... */
  3194.     debug(F101,"freelocal level","",m);
  3195.     if (m < 0) return;
  3196.     v = localhead[m];                   /* List head for level m */
  3197.     while (v) {
  3198.         if (v->lv_name)                 /* Variable name */
  3199.           free(v->lv_name);
  3200.         if (v->lv_value)                /* Value */
  3201.           free(v->lv_value);
  3202.         tv = v;                         /* Save pointer to this node */
  3203.         v = v->lv_next;                 /* Get next one */
  3204.         if (tv)                         /* Free this one */
  3205.           free((char *)tv);
  3206.     }
  3207.     localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3208. }
  3209.  
  3210. #define MAXLOCALVAR 64
  3211.  
  3212. /* Return a pointer to the definition of a user-defined variable */
  3213.  
  3214. static char *
  3215. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3216.     char * p;
  3217.     char c;
  3218.     *isarray = 0;
  3219.     if (!s) return(NULL);
  3220.     if (!*s) return(NULL);
  3221.     p = s;
  3222.     if (*s == CMDQ) {
  3223.         p++;
  3224.         if (!*p)
  3225.           return(NULL);
  3226.         if ((c = *p) == '%') {          /* Scalar variable. */
  3227.             c = *++p;                   /* Get ID character. */
  3228.             p = "";                     /* Assume definition is empty */
  3229.             if (!c)
  3230.               return(NULL);
  3231.             if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3232.                 if (maclvl < 0)         /* Digit variables are global */
  3233.                   return(g_var[c]);     /* if no macro is active */
  3234.                 else                    /* otherwise */
  3235.                   return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3236.             } else if (isalpha(c)) {
  3237.                 if (isupper(c)) c -= ('a'-'A');
  3238.                 return(g_var[c]);           /* Letter for global variable */
  3239.             } else
  3240.               return(NULL);
  3241.         } else if (c == '&') {          /* Array reference. */
  3242.             int x, vbi, d;
  3243.             x = arraynam(p,&vbi,&d);    /* Get name and subscript */
  3244.             if (x > -1 || d == -17) {
  3245.                 *isarray = 1;
  3246.                 *x1 = vbi;
  3247.                 *x2 = (d == -17) ? 0 : d;
  3248.             }
  3249.             if (x < 0)
  3250.               return(NULL);
  3251.             if (chkarray(vbi,d) > 0) {  /* Array is declared? */
  3252.                 vbi -= ARRAYBASE;       /* Convert name to index */
  3253.                 if (a_dim[vbi] >= d) {  /* If subscript in range */
  3254.                     char **ap;
  3255.                     ap = a_ptr[vbi];
  3256.                     return((ap) ? ap[d] : NULL);
  3257.                 }
  3258.             }
  3259.         }
  3260.         return(NULL);
  3261.     } else {
  3262.         int k;
  3263.         k = mxlook(mactab,s,nmac);
  3264.         return((k > -1) ? mactab[k].mval : NULL);
  3265.     }
  3266. }
  3267.  
  3268.  
  3269. int
  3270. addlocal(p) char * p; {
  3271.     int x, z, isarray = 0;
  3272.     char * s;
  3273.     struct localvar * v, *prev = (struct localvar *)NULL;
  3274.     extern int tra_asg; int tra_tmp;
  3275.  
  3276.     tra_tmp = tra_asg;
  3277.  
  3278.     s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
  3279.     if (isarray) {                      /* Arrays are handled specially */
  3280.         pusharray(x,z);
  3281.         return(0);
  3282.     }
  3283.     if (!s) s = "";
  3284.     if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
  3285.         while (v) {                     /* Find end of list */
  3286.             prev = v;
  3287.             v = v->lv_next;
  3288.         }
  3289.     }
  3290.     v = (struct localvar *) malloc(sizeof(struct localvar));
  3291.     if (!v) {
  3292.         printf("?Failure to allocate storage for local variables");
  3293.         return(-9);
  3294.     }
  3295.     if (!localhead[cmdlvl])             /* If first, set list head */
  3296.       localhead[cmdlvl] = v;
  3297.     else                                /* Otherwise link previous to this */
  3298.       prev->lv_next = v;
  3299.     prev = v;                           /* And make this previous */
  3300.     v->lv_next = (struct localvar *) NULL; /* No next yet */
  3301.  
  3302.     if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3303.       return(-1);
  3304.     strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */
  3305.  
  3306.     if (*s) {
  3307.         if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3308.           return(-1);
  3309.         strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
  3310.     } else
  3311.       v->lv_value = NULL;
  3312.  
  3313.     tra_asg = 0;
  3314.     delmac(p,1);                        /* Delete the original macro */
  3315.     tra_asg = tra_tmp;
  3316.     return(0);
  3317. }
  3318.  
  3319. int
  3320. dolocal() {                             /* Do the LOCAL command */
  3321.     int i, x;
  3322.     char * s;
  3323.     char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */
  3324.  
  3325.     if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3326.       return(x);
  3327.  
  3328.     xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */
  3329.  
  3330.     /* Note: Arrays do not use the localhead list, but have their own stack */
  3331.  
  3332.     for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3333.         if (addlocal(list[i]) < 0)
  3334.           goto localbad;
  3335.     }
  3336.     return(success = 1);
  3337.  
  3338.   localbad:
  3339.     printf("?Failure to allocate storage for local variables");
  3340.     freelocal(cmdlvl);
  3341.     return(-9);
  3342. }
  3343.  
  3344. /*  D O O U T P U T  --  Returns 0 on failure, 1 on success */
  3345.  
  3346. #ifndef NOKVERBS
  3347. #define K_BUFLEN 30
  3348. #define SEND_BUFLEN 255
  3349. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3350.  if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3351. #endif /* NOKVERBS */
  3352.  
  3353. int outesc = 1;                         /* Process special OUTPUT escapes */
  3354.  
  3355. int
  3356. dooutput(s, cx) char *s; int cx; {
  3357.  
  3358.     int x, xx, y, quote;                /* Workers */
  3359.     int is_tn = 0;
  3360.  
  3361.     is_tn = (local && network && IS_TELNET()) ||
  3362.       (!local && sstelnet);
  3363.  
  3364.     debug(F111,"dooutput s",s,(int)strlen(s));
  3365.  
  3366.     if (local) {                        /* Condition external line */
  3367. #ifdef NOLOCAL
  3368.         goto outerr;
  3369. #else
  3370.         if (ttchk() < 0) {
  3371.             printf("?Connection %s %s is not open.\n",
  3372.                    network ? "to" : "on",
  3373.                    ttname
  3374.                    );
  3375.             return(0);
  3376.         }
  3377.         if (ttvt(speed,flow) < 0) {
  3378.             printf("?OUTPUT initialization error\n");
  3379.             return(0);
  3380.         }
  3381. #endif /* NOLOCAL */
  3382.     }
  3383.     if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
  3384.         x = strlen(s);                  /* Just send the string literally */
  3385.         xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3386.         return(success = (xx == x) ? 1 : 0);
  3387.     }
  3388.     quote = 0;                          /* Initialize backslash (\) quote */
  3389.     obn = 0;                            /* Reset count */
  3390.     obp = obuf;                         /* and pointers */
  3391.  
  3392.   outagain:
  3393.     while ((x = *s++)) {                /* Loop through the string */
  3394.         y = 0;                          /* Error code, 0 = no error. */
  3395.         debug(F000,"dooutput","",x);
  3396.         if (quote) {                    /* This character is quoted */
  3397. #ifndef NOKVERBS
  3398.            if (x == 'k' || x == 'K') {  /* \k or \K */
  3399.                extern struct keytab kverbs[];
  3400.                extern int nkverbs;
  3401.                extern char * keydefptr;
  3402.                extern int keymac;
  3403.                extern int keymacx;
  3404.                int x, y, brace = 0;
  3405.                int pause;
  3406.                char * p, * b;
  3407.                char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3408.                char osendbuf[SEND_BUFLEN +1];
  3409.                int  sendndx = 0;
  3410.  
  3411.                if (xxout(obuf,obn) < 0) /* Flush buffer */
  3412.                  goto outerr;
  3413.                debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3414.                {                        /* Have K verb? */
  3415.                    if (!*s) {
  3416.                        break;
  3417.                    }
  3418. /*
  3419.   We assume that the verb name is {braced}, or it extends to the end of the
  3420.   string, s, or it ends with a space, control character, or backslash.
  3421. */
  3422.                    p = kbuf;            /* Copy verb name into local buffer */
  3423.                    x = 0;
  3424.                    while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3425.                        if (brace && *s == '}') {
  3426.                            break;
  3427.                        }
  3428.                        *p++ = *s++;
  3429.                    }
  3430.                    if (*s && !brace)    /* If we broke because of \, etc, */
  3431.                      s--;               /*  back up so we get another look. */
  3432.                    brace = 0;
  3433.                    *p = NUL;            /* Terminate. */
  3434.                    p = kbuf;            /* Point back to beginning */
  3435.                    debug(F110,"dooutput kverb",p,0);
  3436.                    y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3437.                    debug(F101,"dooutput lookup",0,y);
  3438.                    if (y > -1) {
  3439.                        if (sendndx) {
  3440.                            dooutput(osendbuf,cx);
  3441.                            sendndx = 0;
  3442.                        }
  3443.                        dokverb(VCMD,y);
  3444. #ifndef NOSPL
  3445.                    } else {             /* Is it a macro? */
  3446.                        y = mxlook(mactab,p,nmac);
  3447.                        if (y > -1) {
  3448.                            cmpush();
  3449.                            keymac = 1;  /* Flag for key macro active */
  3450.                            keymacx = y; /* Key macro index */
  3451.                            keydefptr = s; /* Where to resume next time */
  3452.                            debug(F111,"dooutput mxlook",keydefptr,y);
  3453.                            parser(1);
  3454.                            cmpop();
  3455.                        }
  3456. #endif /* NOSPL */
  3457.                    }
  3458.                }
  3459.                quote = 0;
  3460.                continue;
  3461.            } else
  3462. #endif /* NOKVERBS */
  3463.              if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3464.                  if (xxout(obuf,obn) < 0) /* Flush buffer */
  3465.                    goto outerr;
  3466.                  debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3467.                  if (local)
  3468.                    ttoc(NUL);
  3469.                  else
  3470.                    conoc(NUL);
  3471.                  quote = 0;
  3472.                  continue;
  3473.  
  3474.              } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3475.  
  3476.                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3477.                   goto outerr;
  3478.                 debug(F100,"OUTPUT BREAK","",0);
  3479. #ifndef NOLOCAL
  3480.                 ttsndb();               /* Send BREAK signal */
  3481. #else
  3482.                  if (local)
  3483.                    ttoc(NUL);
  3484.                  else
  3485.                    conoc(NUL);
  3486. #endif /* NOLOCAL */
  3487.                 quote = 0;              /* Turn off quote flag */
  3488.                 continue;               /* and not the b or B */
  3489. #ifdef CK_LBRK
  3490.              } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3491.                  if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3492.                    goto outerr;
  3493.                  debug(F100,"OUTPUT Long BREAK","",0);
  3494. #ifndef NOLOCAL
  3495.                  ttsndlb();             /* Send Long BREAK signal */
  3496. #else
  3497.                  if (local)
  3498.                    ttoc(NUL);
  3499.                  else
  3500.                    conoc(NUL);
  3501. #endif /* NOLOCAL */
  3502.                  quote = 0;             /* Turn off quote flag */
  3503.                  continue;              /* and not the l or L */
  3504. #endif /* CK_LBRK */
  3505.  
  3506.              } else if (x == CMDQ) {    /* Backslash itself */
  3507.                  debug(F100,"OUTPUT CMDQ","",0);
  3508.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3509.                  if (xx < 0)
  3510.                    goto outerr;
  3511.                  quote = 0;
  3512.                  continue;
  3513.  
  3514.              } else {                   /* if \ not followed by special esc */
  3515.                 /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3516.                  xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3517.                  if (xx < 0)
  3518.                    goto outerr;
  3519.                  quote = 0;             /* Turn off quote flag */
  3520.              }
  3521.         } else if (x == CMDQ) {         /* This is the quote character */
  3522.             quote = 1;                  /* Go back and get next character */
  3523.             continue;                   /* which is quoted */
  3524.         }
  3525.         xx = oboc(dopar((char)x));      /* Output this character */
  3526.         debug(F111,"dooutput",obuf,obn);
  3527.         if (xx < 0)
  3528.           goto outerr;
  3529. #ifdef COMMENT
  3530.         if (seslog && duplex) {         /* Log the character if log is on */
  3531.             logchar((char)x);
  3532.         }
  3533. #endif /* COMMENT */
  3534.         if (x == '\015') {              /* String contains carriage return */
  3535.             int stuff = -1, stuff2 = -1;
  3536.             if (tnlm) {                 /* TERMINAL NEWLINE ON */
  3537.                 stuff = LF;             /* Stuff LF */
  3538.             }
  3539. #ifdef TNCODE
  3540.             /* TELNET NEWLINE ON/OFF/RAW */
  3541.             if (is_tn) {
  3542.                 switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3543.                         tn_b_nlm :
  3544.                         tn_nlm
  3545.                         ) {
  3546.                   case TNL_CR:
  3547.                     break;
  3548.                   case TNL_CRNUL:
  3549.                     stuff2 = stuff;
  3550.                     stuff  = NUL;
  3551.                     break;
  3552.                   case TNL_CRLF:
  3553.                     stuff2 = stuff;
  3554.                     stuff = LF;
  3555.                     break;
  3556.                 }
  3557.             }
  3558. #endif /* TNCODE */
  3559.             if (stuff > -1) {           /* Stuffing another character... */
  3560.                 xx = oboc(dopar((CHAR)stuff));
  3561.                 if (xx < 0)
  3562.                   goto outerr;
  3563. #ifdef COMMENT
  3564.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3565.                     logchar((char)stuff);
  3566.                 }
  3567. #endif /* COMMENT */
  3568.             }
  3569.             if (stuff2 > -1) {          /* Stuffing another character... */
  3570.                 xx = oboc(dopar((CHAR)stuff2));
  3571.                 if (xx < 0)
  3572.                   goto outerr;
  3573. #ifdef COMMENT
  3574.                 if (seslog && duplex) { /* Log stuffed char if appropriate */
  3575.                     logchar((char)stuff2);
  3576.                 }
  3577. #endif /* COMMENT */
  3578.             }
  3579.             if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
  3580.               goto outerr;
  3581.         }
  3582.     }
  3583.     if (cx == XXLNOUT) {
  3584.         s = "\015";
  3585.         cx = 0;
  3586.         goto outagain;
  3587.     }
  3588.     if (quote == 1)                     /* String ended with backslash */
  3589.       xx = oboc(dopar(CMDQ));
  3590.  
  3591.     if (obn > 0)                        /* OUTPUT done */
  3592.       if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
  3593.         goto outerr;
  3594.     return(1);
  3595.  
  3596. outerr:                                 /* OUTPUT command error handler */
  3597.     if (msgflg) printf("?OUTPUT execution error\n");
  3598.     return(0);
  3599.  
  3600. /* Remove "local" OUTPUT macro defininitions */
  3601.  
  3602. #ifdef COMMENT
  3603. /* No more macros ... */
  3604. #undef oboc
  3605. #undef obfls
  3606. #endif /* COMMENT */
  3607. }
  3608. #endif /* NOSPL */
  3609.  
  3610. /* Display version herald and initial prompt */
  3611.  
  3612. VOID
  3613. herald() {
  3614.     int x = 0, i;
  3615.     extern int srvcdmsg;
  3616.     extern char * cdmsgfile[];
  3617. #ifndef NOCMDL
  3618.     extern char * bannerfile;
  3619.     if (bannerfile) {
  3620.         concb((char)escape);
  3621.         if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3622.             if (srvcdmsg) {
  3623.                 for (i = 0; i < 8; i++) {
  3624.                     if (zchki(cdmsgfile[i]) > -1) {
  3625.                         printf("\n");
  3626.                         dotype(cdmsgfile[i],
  3627.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3628.                         break;
  3629.                     }
  3630.                 }
  3631.             }
  3632.             return;
  3633.         }
  3634.     }
  3635. #endif /* NOCMDL */
  3636.  
  3637. #ifdef COMMENT
  3638.     /* The following generates bad code in SCO compilers. */
  3639.     /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3640.     /* statement when all conditions are false, x has a value of -32. */
  3641.     if (noherald || bgset > 0 || (bgset != 0 && backgrd != 0)) x = 1;
  3642. #else
  3643.     x = 0;
  3644.     if (noherald)
  3645.       x = 1;
  3646.     else if (bgset > 0)
  3647.       x = 1;
  3648.     else if (bgset < 0 && backgrd > 0)
  3649.       x = 1;
  3650. #endif /* COMMENT */
  3651.  
  3652.     if (x == 0) {
  3653. #ifdef datageneral
  3654.         printf("%s, for%s\n",versio,ckxsys);
  3655. #else
  3656. #ifdef OSK
  3657.         printf("%s, for%s\n",versio,ckxsys);
  3658. #else
  3659.         printf("%s, for%s\n\r",versio,ckxsys);
  3660. #endif /* OSK */
  3661. #endif /* datageneral */
  3662.         printf(" Copyright (C) 1985, 2002,\n");
  3663.         printf("  Trustees of Columbia University in the City of New York.\n");
  3664.  
  3665. #ifdef OS2
  3666.        shoreg();
  3667. #endif /* OS2 */
  3668.  
  3669.         if (!quiet && !backgrd) {
  3670. #ifdef COMMENT
  3671. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3672.             char * s;
  3673.             extern int xfermode;
  3674. #ifdef VMS
  3675.             s = "AUTOMATIC";
  3676. #else
  3677.             if (xfermode == XMODE_A) {
  3678.                 s = "AUTOMATIC";
  3679.             } else {
  3680.                 s = gfmode(binary,1);
  3681.             }
  3682.             if (!s) s = "";
  3683. #endif /* VMS */
  3684.             if (*s)
  3685.               printf("Default file-transfer mode is %s\n", s);
  3686. #endif /* COMMENT */
  3687.  
  3688.             if (srvcdmsg) {
  3689.                 for (i = 0; i < 8; i++) {
  3690.                     if (zchki(cdmsgfile[i]) > -1) {
  3691.                         printf("\n");
  3692.                         dotype(cdmsgfile[i],
  3693.                                xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3694.                         break;
  3695.                     }
  3696.                 }
  3697.             }
  3698.             printf("Type ? or HELP for help.\n");
  3699.         }
  3700.     }
  3701. }
  3702.  
  3703. /*  G F M O D E  --  Get File (transfer) Mode  */
  3704.  
  3705. char *
  3706. gfmode(binary,upcase) int binary, upcase; {
  3707.     char * s;
  3708.     switch (binary) {
  3709.       case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3710. #ifdef VMS
  3711.       case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3712.       case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3713.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3714.       case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3715. #else
  3716. #ifdef MAC
  3717.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3718.       case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3719. #else
  3720.       case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3721. #ifdef CK_LABELED
  3722.       case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3723. #endif /* CK_LABELED */
  3724. #endif /* MAC */
  3725. #endif /* VMS */
  3726.       case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3727.       default: s = "";
  3728.     }
  3729.     return(s);
  3730. }
  3731.  
  3732. #ifndef NOSPL
  3733. static int
  3734. isaa(s) char * s; {                     /* Is associative array */
  3735.     char c;
  3736.     int x;
  3737.     if (!s) s = "";
  3738.     if (!*s) return(0);
  3739.     s++;
  3740.     while ((c = *s++)) {
  3741.         if (c == '<') {
  3742.             x = strlen(s);
  3743.             return ((*(s+x-1) == '>') ? 1 : 0);
  3744.         }
  3745.     }
  3746.     return(0);
  3747. }
  3748.  
  3749. /*  M L O O K  --  Lookup the macro name in the macro table  */
  3750.  
  3751. /*
  3752.   Call this way:  v = mlook(table,word,n);
  3753.  
  3754.     table - a 'struct mtab' table.
  3755.     word  - the target string to look up in the table.
  3756.     n     - the number of elements in the table.
  3757.  
  3758.   The keyword table must be arranged in ascending alphabetical order, and
  3759.   all letters must be lowercase.
  3760.  
  3761.   Returns the table index, 0 or greater, if the name was found, or:
  3762.  
  3763.    -3 if nothing to look up (target was null),
  3764.    -2 if ambiguous,
  3765.    -1 if not found.
  3766.  
  3767.   A match is successful if the target matches a keyword exactly, or if
  3768.   the target is a prefix of exactly one keyword.  It is ambiguous if the
  3769.   target matches two or more keywords from the table.
  3770. */
  3771. int
  3772. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3773.     register int i;
  3774.     int v, w, cmdlen = 0;
  3775.     char c = 0, c1, * s;
  3776.     if (!cmd) cmd = "";
  3777.  
  3778.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3779.     debug(F111,"MLOOK",cmd,cmdlen);
  3780.  
  3781.     c1 = *cmd;
  3782.     if (isupper(c1))
  3783.       c1 = tolower(c1);
  3784.     if (cmdlen < 1)
  3785.       return(-3);
  3786.  
  3787. /* Not null, look it up */
  3788.  
  3789.     if (n < 12) {                       /* Not worth it for small tables */
  3790.         i = 0;
  3791.     } else {                            /* Binary search for where to start */
  3792.         int lo = 0;
  3793.         int hi = n;
  3794.         int count = 0;
  3795.         while (lo+2 < hi && ++count < 12) {
  3796.             i = lo + ((hi - lo) / 2);
  3797.             c = *(table[i].kwd);
  3798.             if (isupper(c)) c = tolower(c);
  3799.             if (c < c1) {
  3800.                 lo = i;
  3801.             } else {
  3802.                 hi = i;
  3803.             }
  3804.         }
  3805.         i = (c < c1) ? lo+1 : lo;
  3806.     }
  3807.     for ( ; i < n-1; i++) {
  3808.         s = table[i].kwd;
  3809.         if (!s) s = "";
  3810.         if (!*s) continue;              /* Empty table entry */
  3811.         c = *s;
  3812.         if (isupper(c)) c = tolower(c);
  3813.         if (c1 != c) continue;          /* First char doesn't match */
  3814.         if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
  3815.           return(i);
  3816.         v = !ckstrcmp(s,cmd,cmdlen,0);
  3817.         w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3818.         if (v && w)                     /* Have abbreviated match? */
  3819.           return(i);
  3820.         if (v)                          /* Ambiguous? */
  3821.           return(-2);
  3822.         if (w > 0)                      /* Past our alphabetic area? */
  3823.           return(-1);
  3824.     }
  3825.  
  3826. /* Last (or only) element */
  3827.  
  3828.     if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3829.       return(n-1);
  3830.  
  3831.     return(-1);
  3832. }
  3833.  
  3834. /* mxlook is like mlook, but an exact full-length match is required */
  3835.  
  3836. int
  3837. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3838.     register int i;
  3839.     int w, cmdlen = 0, one = 0;
  3840.     register char c = 0, c1, * s;
  3841.  
  3842.     if (!cmd) cmd = "";                 /* Check args */
  3843.  
  3844.     for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
  3845.     debug(F111,"MXLOOK",cmd,cmdlen);
  3846.  
  3847.     c1 = *cmd;                          /* First char of string to look up */
  3848.     if (isupper(c1))
  3849.       c1 = tolower(c1);
  3850.     if (!*(cmd+1))                      /* Special handling for 1-char names */
  3851.       one = 1;
  3852.  
  3853.     if (cmdlen < 1)                     /* Nothing to look up */
  3854.       return(-3);
  3855.  
  3856.     if (n < 12) {                       /* Not worth it for small tables */
  3857.         i = 0;
  3858.     } else {                            /* Binary search for where to start */
  3859.         int lo = 0;
  3860.         int hi = n;
  3861.         int count = 0;
  3862.         while (lo+2 < hi && ++count < 12) {
  3863.             i = lo + ((hi - lo) / 2);
  3864.             c = *(table[i].kwd);
  3865.             if (isupper(c)) c = tolower(c);
  3866.             if (c < c1) {
  3867.                 lo = i;
  3868.             } else {
  3869.                 hi = i;
  3870.             }
  3871.         }
  3872.         i = (c < c1) ? lo+1 : lo;
  3873.     }
  3874.     for ( ; i < n; i++) {               /* Look thru table */
  3875.         s = table[i].kwd;               /* This entry */
  3876.         if (!s) s = "";
  3877.         if (!*s) continue;              /* Empty table entry */
  3878.         c = *s;
  3879.         if (isupper(c)) c = tolower(c);
  3880.         if (c1 != c) continue;          /* First char doesn't match */
  3881.         if (one) {                      /* Name is one char long */
  3882.             if (!*(s+1))
  3883.               return(i);                /* So is table entry */
  3884.         }
  3885. #ifdef COMMENT
  3886.         if (((int)strlen(s) == cmdlen) &&
  3887.             (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  3888. #else
  3889.         w = ckstrcmp(s,cmd,-1,0);
  3890.         if (!w) return(i);
  3891.         if (w > 0) return(-1);
  3892. #endif /* COMMENT */
  3893.     }
  3894.     return(-1);
  3895. }
  3896.  
  3897. /* mxxlook is like mxlook, but case-sensitive */
  3898.  
  3899. int
  3900. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3901.     int i, cmdlen;
  3902.     if (!cmd) cmd = "";
  3903.     if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  3904.     /* debug(F111,"mxxlook target",cmd,n); */
  3905.     for (i = 0; i < n; i++) {
  3906.         if (((int)strlen(table[i].kwd) == cmdlen) &&
  3907.             (!strncmp(table[i].kwd,cmd,cmdlen)))
  3908.           return(i);
  3909.     }
  3910.     return(-1);
  3911. }
  3912.  
  3913. static int
  3914. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  3915.     if (val)
  3916.       printf(">>> %s: \"%s\"\n", nam, val);
  3917.     else
  3918.       printf(">>> %s: (undef)\n", nam);
  3919.     return(0);
  3920. }
  3921.  
  3922. #ifdef USE_VARLEN                       /* Not used */
  3923.  
  3924. /*  V A R L E N  --  Get length of variable's value.
  3925.  
  3926.   Given a variable name, return the length of its definition or 0 if the
  3927.   variable is not defined.  If it is defined, set argument s to point to its
  3928.   definition.  Otherwise set s to NULL.
  3929. */
  3930. int
  3931. varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
  3932.     int x, z;
  3933.     char *p = NULL, c;
  3934.  
  3935.     *s = NULL;
  3936.     if (!nam) return(0);                /* Watch out for null pointer */
  3937.     if (*nam == CMDQ) {
  3938.         nam++;
  3939.         if (*nam == '%') {              /* If it's a variable name */
  3940.             if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  3941.             p = (char *)0;              /* Initialize value pointer */
  3942.             if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  3943.                 p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  3944.             } else {                    /* It's a global variable */
  3945.                 if (c < 33 || c > GVARS) return(0);
  3946.                 p = g_var[c];           /* Get pointer from global-var table */
  3947.             }
  3948.         } else if (*nam == '&') {               /* An array reference? */
  3949.             char **q;
  3950.             if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  3951.               return(-1);               /* return -1. */
  3952.             x -= ARRAYBASE;             /* Convert name to number. */
  3953.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  3954.               return(0);                /* return -2. */
  3955.             if (z > a_dim[x])           /* If subscript out of range, */
  3956.               return(0);                /* return -3. */
  3957.             p = q[z];
  3958.         }
  3959.     } else {                            /* Macro */
  3960.         z = isaa(nam);
  3961.         x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  3962.         if (x < 0)
  3963.           return(0);
  3964.         p = mactab[x].mval;
  3965.     }
  3966.     if (p)
  3967.       *s = p;
  3968.     else
  3969.       p = "";
  3970.     return((int)strlen(p));
  3971. }
  3972. #endif /* USE_VARLEN */
  3973.  
  3974. /*
  3975.   This routine is for the benefit of those compilers that can't handle
  3976.   long string constants or continued lines within them.  Long predefined
  3977.   macros like FOR, WHILE, and XIF have their contents broken up into
  3978.   arrays of string pointers.  This routine concatenates them back into a
  3979.   single string again, and then calls the real addmac() routine to enter
  3980.   the definition into the macro table.
  3981. */
  3982. int
  3983. addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
  3984.     int i, x, y; char *p;
  3985.     x = 0;                              /* Length counter */
  3986.     for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  3987.         debug(F111,"addmmac line",s[i],y);
  3988.         x += y;
  3989.     }
  3990.     debug(F101,"addmmac lines","",i);
  3991.     debug(F101,"addmmac loop exit","",y);
  3992.     debug(F111,"addmmac length",nam,x);
  3993.     if (x < 0) return(-1);
  3994.  
  3995.     p = malloc(x+1);                    /* Allocate space for all of it. */
  3996.     if (!p) {
  3997.         printf("?addmmac malloc error: %s\n",nam);
  3998.         debug(F110,"addmmac malloc error",nam,0);
  3999.         return(-1);
  4000.     }
  4001.     *p = '\0';                          /* Start off with null string. */
  4002.     for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
  4003.       ckstrncat(p,s[i],x+1);
  4004.     y = (int)strlen(p);                 /* Final precaution. */
  4005.     debug(F111,"addmmac constructed string",p,y);
  4006.     if (y == x) {
  4007.         y = addmac(nam,p);              /* Add result to the macro table. */
  4008.     } else {
  4009.         debug(F100,"addmmac length mismatch","",0);
  4010.         printf("\n!addmmac internal error!\n");
  4011.         y = -1;
  4012.     }
  4013.     free(p);                            /* Free the temporary copy. */
  4014.     return(y);
  4015. }
  4016.  
  4017. /* Here is the real addmac routine. */
  4018.  
  4019. /* Returns -1 on failure, macro table index >= 0 on success. */
  4020.  
  4021. int mtchanged = 0;
  4022.  
  4023. int
  4024. addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
  4025.     int i, x, y, z, namlen, deflen, flag = 0;
  4026.     int replacing = 0, deleting = 0;
  4027.     char * p = NULL, c, *s;
  4028.     extern int tra_asg; int tra_tmp;
  4029.  
  4030.     if (!nam) return(-1);
  4031.     if (!*nam) return(-1);
  4032.  
  4033. #ifdef IKSD
  4034.     if (inserver &&
  4035. #ifdef IKSDCONF
  4036.         iksdcf
  4037. #else /* IKSDCONF */
  4038.         1
  4039. #endif /* IKSDCONF */
  4040.         ) {
  4041.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4042.             !ckstrcmp("on_logout",nam,-1,0))
  4043.           return(-1);
  4044.     }
  4045. #endif /* IKSD */
  4046.  
  4047.     namlen = 0;
  4048.     p = nam;
  4049.     while (*p++) namlen++;              /* (instead of strlen) */
  4050.  
  4051.     tra_tmp = tra_asg;                  /* trace... */
  4052.     debug(F111,"addmac nam",nam,namlen);
  4053.     if (!def) {                         /* Watch out for null pointer */
  4054.         deflen = 0;
  4055.         debug(F111,"addmac def","(null pointer)",deflen);
  4056.     } else {
  4057.         deflen = 0;
  4058.         p = def;
  4059.         while (*p++) deflen++;          /* (instead of strlen) */
  4060.         debug(F010,"addmac def",def,0);
  4061.     }
  4062. #ifdef USE_VARLEN                       /* NOT USED */
  4063.     /* This does not boost performance much because varlen() does a lot */
  4064.     x = varlen(nam,&s);
  4065.     if (x > 0 && x >= deflen) {
  4066.         strcpy(s,def);                  /* NOT USED */
  4067.         flag = 1;
  4068.         p = s;
  4069.     }
  4070. #endif /* USE_VARLEN */
  4071.  
  4072.     if (*nam == CMDQ) nam++;            /* Backslash quote? */
  4073.     if (*nam == '%') {                  /* Yes, if it's a variable name, */
  4074.         if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4075.         if (!flag) {
  4076.             tra_asg = 0;
  4077.             delmac(nam,0);              /* Delete any old value. */
  4078.             tra_asg = tra_tmp;
  4079.         }
  4080.         if (deflen < 1) {               /* Null definition */
  4081.             p = NULL;                   /* Better not malloc or strcpy! */
  4082.         } else if (!flag) {             /* A substantial definition */
  4083.             p = malloc(deflen + 1);     /* Allocate space for it */
  4084.             if (!p) {
  4085.                 printf("?addmac malloc error 2\n");
  4086.                 return(-1);
  4087.             } else strcpy(p,def);       /* Copy def into new space (SAFE) */
  4088.         }
  4089.  
  4090.         /* Now p points to the definition, or is a null pointer */
  4091.  
  4092.         if (c >= '0' && c <= '9') {     /* \%0-9 variable */
  4093.             if (maclvl < 0) {           /* Are we calling or in a macro? */
  4094.                 g_var[c] = p;           /* No, it's top level one */
  4095.                 makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4096.             } else {                    /* Yes, it's a macro argument */
  4097.                 m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4098.                 makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4099.             }
  4100.         } else {                        /* It's a \%a-z variable */
  4101.             if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4102.             if (isupper(c)) c = (char) tolower(c);
  4103.             g_var[c] = p;               /* Put pointer in global-var table */
  4104.         }
  4105.         if (tra_asg) traceval(nam,p);
  4106.         return(0);
  4107.     } else if (*nam == '&') {           /* An array reference? */
  4108.         char **q = NULL;
  4109.         int rc = 0;
  4110.         if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4111.           return(-1);                   /* return -1. */
  4112.         if (chkarray(x,z) < 0)          /* If array not declared or */
  4113.           rc = -2;                      /* subscript out of range, ret -2 */
  4114.         if (!flag) {
  4115.             tra_asg = 0;
  4116.             delmac(nam,0);              /* Delete any old value. */
  4117.             tra_asg = tra_tmp;
  4118.         }
  4119.         x -= ARRAYBASE;                 /* Convert name letter to index. */
  4120.         if (x > 'z' - ARRAYBASE + 1)
  4121.           rc = -1;
  4122.         if (rc != -1) {
  4123.             if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4124.               return(-3);               /* return -3. */
  4125.         }
  4126.         if (rc < 0)
  4127.           return(rc);
  4128.         if (!flag) {
  4129.             if (deflen > 0) {
  4130.                 if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4131.                     printf("addmac macro error 7: %s\n",nam);
  4132.                     return(-4);         /* for new def, return -4 on fail. */
  4133.                 }
  4134.                 strcpy(p,def);          /* Copy def into new space (SAFE). */
  4135.             } else p = NULL;
  4136.         }
  4137.         q[z] = p;                       /* Store pointer to it. */
  4138.         if (x == 0) {                   /* Arg vector array */
  4139.             if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
  4140.                 if (maclvl < 0) {       /* \%1..9 variables. */
  4141.                     makestr(&(toparg[z]),p);
  4142.                 } else {
  4143.                     makestr(&(m_arg[maclvl][z]),p);
  4144.                 }
  4145.             }
  4146.         }
  4147.         if (tra_asg) traceval(nam,p);
  4148.         return(0);                      /* Done. */
  4149.     }
  4150.  
  4151. /* Not a macro argument or a variable, so it's a macro definition */
  4152.  
  4153. #ifdef USE_VARLEN
  4154.     if (flag) {
  4155.         if (tra_asg) traceval(nam,p);
  4156.         return(0);
  4157.     }
  4158. #endif /* USE_VARLEN */
  4159.     x = isaa(nam) ?                     /* If it's an associative array */
  4160.       mxxlook(mactab,nam,nmac) :        /* look it up this way */
  4161.         mxlook(mactab,nam,nmac);        /* otherwise this way. */
  4162.     if (x > -1) {                       /* If found... */
  4163.         if (deflen > 0)                 /* and a new definition was given */
  4164.           replacing = 1;                /* we're replacing */
  4165.         else                            /* otherwise */
  4166.           deleting = 1;                 /* we're deleting */
  4167.     }
  4168.     if (deleting) {                     /* Deleting... */
  4169.         if (delmac(nam,0) < 0)
  4170.           return(-1);
  4171.         mtchanged++;
  4172.         if (tra_asg) traceval(nam,p);
  4173.         return(0);
  4174.     } else if (deflen < 1)              /* New macro with no definition */
  4175.       return(0);                        /* Nothing to do. */
  4176.  
  4177.     if (replacing) {                    /* Replacing an existing macro */
  4178.         if (mactab[x].mval) {           /* If it currently has a definition, */
  4179.             free(mactab[x].mval);       /* free it. */
  4180.             mactab[x].mval = NULL;
  4181.         }
  4182.         mtchanged++;
  4183.         y = x;                          /* Replacement index. */
  4184.  
  4185.     } else {                            /* Adding a new macro... */
  4186.         char c1, c2;                    /* Use fast lookup to find the */
  4187.         c1 = *nam;                      /* alphabetical slot. */
  4188.         if (isupper(c1)) c1 = (char) tolower(c1);
  4189.  
  4190.         if (nmac < 5) {                 /* Not worth it for small tables */
  4191.             y = 0;
  4192.         } else {                        /* First binary search to find */
  4193.             int lo = 0;                 /* where to start */
  4194.             int hi = nmac;
  4195.             int count = 0;
  4196.             char c = 0;
  4197.             while (lo+2 < hi && ++count < 12) {
  4198.                 y = lo + ((hi - lo) / 2);
  4199.                 c = *(mactab[y].kwd);
  4200.                 if (isupper(c)) c = (char) tolower(c);
  4201.                 if (c < c1) {
  4202.                     lo = y;
  4203.                 } else {
  4204.                     hi = y;
  4205.                 }
  4206.             }
  4207.             y = (c < c1) ? lo+1 : lo;
  4208.         }
  4209.         /* Now search linearly from starting location */
  4210.         for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4211.             c2 = *(mactab[y].kwd);
  4212.             if (isupper(c2)) c2 = (char) tolower(c2);
  4213.             if (c1 > c2)
  4214.               continue;
  4215.             if (c1 < c2)
  4216.               break;
  4217.             if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4218.               break;
  4219.         }
  4220.         if (y == MAC_MAX) {             /* Macro table is full. */
  4221.             debug(F101,"addmac table overflow","",y);
  4222.             printf("?Macro table overflow\n");
  4223.             return(-1);
  4224.         }
  4225.         if (mactab[y].kwd != NULL) {    /* Must insert */
  4226.             for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4227.                 mactab[i].kwd = mactab[i-1].kwd;
  4228.                 mactab[i].mval = mactab[i-1].mval;
  4229.                 mactab[i].flgs = mactab[i-1].flgs;
  4230.             }
  4231.         }
  4232.         mtchanged++;
  4233.         p = malloc(namlen + 1);         /* Allocate space for name */
  4234.         if (!p) {
  4235.             printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4236.             return(-1);
  4237.         }
  4238.         strcpy(p,nam);                  /* Copy name into new space (SAFE) */
  4239.         mactab[y].kwd = p;              /* Add pointer to table */
  4240.     }
  4241.     if (deflen > 0) {                   /* If we have a definition */
  4242.         p = malloc(deflen + 1);         /* Get space */
  4243.         if (p == NULL) {
  4244.             printf("?Space exhausted - \"%s\"\n", nam);
  4245.             if (mactab[y].kwd) {
  4246.                 free(mactab[y].kwd);
  4247.                 mactab[y].kwd = NULL;
  4248.             }
  4249.             return(-1);
  4250.         } else {
  4251.             strcpy(p,def);              /* Copy the definition (SAFE) */
  4252.         }
  4253.     } else {                            /* definition is empty */
  4254.         p = NULL;
  4255.     }
  4256.     mactab[y].mval = p;                 /* Macro points to definition */
  4257.     mactab[y].flgs = 0;                 /* No flags */
  4258.     if (!replacing)                     /* If new macro */
  4259.       nmac++;                           /* count it */
  4260.     if (tra_asg) traceval(nam,p);
  4261.     return(y);
  4262. }
  4263.  
  4264. int
  4265. xdelmac(x) int x; {                     /* Delete a macro given its index */
  4266.     int i;
  4267.     extern int tra_asg;
  4268.     if (x < 0) return(x);
  4269.     if (tra_asg)
  4270.       traceval(mactab[x].kwd,NULL);
  4271.  
  4272.     if (mactab[x].kwd) {                /* Free the storage for the name */
  4273.         free(mactab[x].kwd);
  4274.         mactab[x].kwd = NULL;
  4275.     }
  4276.     if (mactab[x].mval) {               /* and for the definition */
  4277.         free(mactab[x].mval);
  4278.         mactab[x].mval = NULL;
  4279.     }
  4280.     for (i = x; i < nmac; i++) {        /* Now move up the others. */
  4281.         mactab[i].kwd = mactab[i+1].kwd;
  4282.         mactab[i].mval = mactab[i+1].mval;
  4283.         mactab[i].flgs = mactab[i+1].flgs;
  4284.     }
  4285.     nmac--;                             /* One less macro */
  4286.  
  4287.     mactab[nmac].kwd = NULL;            /* Delete last item from table */
  4288.     mactab[nmac].mval = NULL;
  4289.     mactab[nmac].flgs = 0;
  4290.     mtchanged++;
  4291.     return(0);
  4292. }
  4293.  
  4294. int
  4295. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4296.     int x, z;
  4297.     char *p, c;
  4298.     extern int tra_asg;
  4299.  
  4300.     if (!nam) return(0);                /* Watch out for null pointer */
  4301.     debug(F110,"delmac nam",nam,0);
  4302. #ifdef IKSD
  4303.     if ( inserver &&
  4304. #ifdef IKSDCONF
  4305.         iksdcf
  4306. #else /* IKSDCONF */
  4307.         1
  4308. #endif /* IKSDCONF */
  4309.         ) {
  4310.         if (!ckstrcmp("on_exit",nam,-1,0) ||
  4311.             !ckstrcmp("on_logout",nam,-1,0))
  4312.           return(-1);
  4313.     }
  4314. #endif /* IKSD */
  4315.  
  4316.     if (*nam == CMDQ) nam++;
  4317.     if (*nam == '%') {                  /* If it's a variable name */
  4318.         if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4319.         p = (char *)0;                  /* Initialize value pointer */
  4320.         if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4321.             p = toparg[c - '0'];
  4322.             if (p) if (p != g_var[c]) {
  4323.                 free(p);
  4324.                 toparg[c - '0'] = NULL;
  4325.             }
  4326.             p = g_var[c];
  4327.             g_var[c] = NULL;            /* Zero the table entry */
  4328.         } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4329.             p = m_xarg[maclvl][c - '0'];
  4330.             if (p) if (p != g_var[c]) {
  4331.                 free(p);
  4332.                 m_xarg[maclvl][c - '0'] = NULL;
  4333.             }
  4334.             p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4335.             m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4336.         } else {                        /* It's a global variable */
  4337.             if (c < 33 || (unsigned int)c > GVARS) return(0);
  4338.             p = g_var[c];               /* Get pointer from global-var table */
  4339.             g_var[c] = NULL;            /* Zero the table entry */
  4340.         }
  4341.         if (p) {
  4342.             debug(F010,"delmac def",p,0);
  4343.             free(p);                    /* Free the storage */
  4344.             p = NULL;
  4345.         } else debug(F110,"delmac def","(null pointer)",0);
  4346.         if (tra_asg) traceval(nam,NULL);
  4347.         return(0);
  4348.     }
  4349.     if (*nam == '&') {                  /* An array reference? */
  4350.         char **q;
  4351.         if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
  4352.           return(-1);                   /* return -1. */
  4353.         x -= ARRAYBASE;                 /* Convert name to number. */
  4354.         if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
  4355.           return(-2);                   /* return -2. */
  4356.         if (z > a_dim[x])               /* If subscript out of range, */
  4357.           return(-3);                   /* return -3. */
  4358.         if (q[z]) {                     /* If there is an old value, */
  4359.             debug(F010,"delmac def",q[z],0);
  4360.             if (x != 0)                 /* Macro arg vector is just a copy */
  4361.               free(q[z]);               /* Others are real so free them */
  4362.             q[z] = NULL;
  4363.             if (x == 0) {               /* Arg vector array */
  4364.                 if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
  4365.                     if (maclvl < 0) {   /* \%1..9 variables. */
  4366.                         makestr(&(toparg[z]),NULL);
  4367.                     } else {
  4368.                         makestr(&(m_arg[maclvl][z]),NULL);
  4369.                     }
  4370.                 }
  4371.             }
  4372.             if (tra_asg) traceval(nam,NULL);
  4373.         } else debug(F010,"delmac def","(null pointer)",0);
  4374.     }
  4375.  
  4376.    /* Not a variable or an array, so it must be a macro. */
  4377.  
  4378.     z = isaa(nam);
  4379.     debug(F111,"delmac isaa",nam,z);
  4380.     x = z ? mxxlook(mactab,nam,nmac) :
  4381.       exact ? mxlook(mactab,nam,nmac) :
  4382.         mlook(mactab,nam,nmac);
  4383.     if (x < 0) {
  4384.         debug(F111,"delmac mlook",nam,x);
  4385.         return(x);
  4386.     }
  4387.     return(xdelmac(x));
  4388. }
  4389.  
  4390. VOID
  4391. initmac() {                             /* Init macro & variable tables */
  4392.     int i, j, x;
  4393.  
  4394.     nmac = 0;                           /* No macros */
  4395.     for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
  4396.         mactab[i].kwd = NULL;
  4397.         mactab[i].mval = NULL;
  4398.         mactab[i].flgs = 0;
  4399.     }
  4400.     mtchanged++;
  4401.     x = (MAXARGLIST + 1) * sizeof(char **);
  4402.     for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
  4403.         m_xarg[i] = (char **) malloc(x);
  4404.         mrval[i] = NULL;                /* Macro return value */
  4405.         /* Pointer to entire argument vector, level i, for \&_[] array */
  4406.         for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4407.             if (j < 10)                 /* For the \%0..\%9 variables */
  4408.               m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
  4409.             if (m_xarg[i])              /* For \&_[] - all args. */
  4410.               m_xarg[i][j] = NULL;
  4411.         }
  4412.     }
  4413.     for (i = 0; i < GVARS; i++) {       /* And the global variables table */
  4414.         g_var[i] = NULL;
  4415.     }
  4416.     /* And the table of arrays */
  4417.     for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4418.         a_ptr[i] = (char **) NULL;      /* Null pointer for each */
  4419.         a_dim[i] = 0;                   /* and a dimension of zero */
  4420.         a_link[i] = -1;
  4421.         for (j = 0; j < CMDSTKL; j++) {
  4422.             aa_ptr[j][i] = (char **) NULL;
  4423.             aa_dim[j][i] = 0;
  4424.         }
  4425.     }
  4426. }
  4427.  
  4428. int
  4429. popclvl() {                             /* Pop command level, return cmdlvl */
  4430.     extern int tra_cmd;
  4431.     struct localvar * v;
  4432.     int i, topcmd;
  4433.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4434.     if (cmdlvl > 0) {
  4435.         if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
  4436.             while (v) {                 /* Yes */
  4437.                 if (v->lv_value)        /* Copy old ones back */
  4438.                   addmac(v->lv_name,v->lv_value);
  4439.                 else
  4440.                   delmac(v->lv_name,0);
  4441.                 v = v->lv_next;
  4442.             }
  4443.             freelocal(cmdlvl);          /* Free local storage */
  4444.         }
  4445.         /* Automatic arrays do not use the localhead list */
  4446.  
  4447.         for (i = 0; i < 28; i++) {      /* Free any local arrays */
  4448.             if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
  4449.                 dclarray((char)(i+ARRAYBASE),0); /* Destroy global one */
  4450.                 a_ptr[i] = aa_ptr[cmdlvl][i];
  4451.                 a_dim[i] = aa_dim[cmdlvl][i];
  4452.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4453.                 aa_dim[cmdlvl][i] = 0;
  4454.             } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4455.                 dclarray((char)(i+ARRAYBASE),0); /* (see pusharray()) */
  4456.                 aa_ptr[cmdlvl][i] = (char **)NULL;
  4457.                 aa_dim[cmdlvl][i] = 0;
  4458.             }
  4459.             /* Otherwise do nothing - it is a local array that was declared */
  4460.             /* at a level above this one so leave it alone. */
  4461.         }
  4462.     }
  4463.     if (cmdlvl < 1) {                   /* If we're already at top level */
  4464.         cmdlvl = 0;                     /* just make sure all the */
  4465.         tlevel = -1;                    /* stack pointers are set right */
  4466.         maclvl = -1;                    /* and return */
  4467.     } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4468.         debug(F101,"popclvl tlevel","",tlevel);
  4469.         if (tlevel > -1) {              /* Yes, */
  4470.             fclose(tfile[tlevel]);      /* close it */
  4471.  
  4472.             if (tra_cmd)
  4473.               printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4474.             debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4475.             if (tfnam[tlevel]) {        /* free storage for name */
  4476.                 free(tfnam[tlevel]);
  4477.                 tfnam[tlevel] = NULL;
  4478.             }
  4479.             tlevel--;                   /* and pop take level */
  4480.             cmdlvl--;                   /* and command level */
  4481.             quiet = xquiet[cmdlvl];
  4482.         } else
  4483.           tlevel = -1;
  4484.     } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4485.         topcmd = lastcmd[maclvl];
  4486.         debug(F101,"popclvl maclvl","",maclvl);
  4487.         if (maclvl > -1) {              /* Yes, */
  4488. #ifdef COMMENT
  4489.             int i;
  4490.             char **q;
  4491. #endif /* COMMENT */
  4492.             macp[maclvl] = "";          /* set macro pointer to null string */
  4493.             *cmdbuf = '\0';             /* clear the command buffer */
  4494.  
  4495.             if ((maclvl > 0) &&         /* 2 May 1999 */
  4496.                 (m_arg[maclvl-1][0]) &&
  4497.                 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4498.                  !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4499.                  !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4500.                  !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4501.                 mrval[maclvl+1]) {
  4502.                 makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4503.             }
  4504.             if (maclvl+1 < MACLEVEL) {
  4505.                 if (mrval[maclvl+1]) {  /* Free any deeper return values. */
  4506.                     free(mrval[maclvl+1]);
  4507.                     mrval[maclvl+1] = NULL;
  4508.                 }
  4509.             }
  4510.             if (tra_cmd)
  4511.               printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4512.             debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4513.  
  4514.             maclvl--;                   /* Pop macro level */
  4515.             cmdlvl--;                   /* and command level */
  4516.             debug(F101,"popclvl mac new maclvl","",maclvl);
  4517.             debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4518.  
  4519.             quiet = xquiet[cmdlvl];
  4520.             if (maclvl > -1) {
  4521.                 a_ptr[0] = m_xarg[maclvl];
  4522.                 a_dim[0] = n_xarg[maclvl] - 1;
  4523.             } else {
  4524.                 a_ptr[0] = topxarg;
  4525.                 a_dim[0] = topargc - 1;
  4526.             }
  4527.         } else {
  4528.             maclvl = -1;
  4529.         }
  4530. #ifndef NOSEXP
  4531.         debug(F101,"popclvl topcmd","",topcmd);
  4532.         if (topcmd == XXSEXP) {
  4533.             extern char * sexpval;
  4534.             makestr(&(mrval[maclvl+1]),sexpval);
  4535.         }
  4536. #endif /* NOSEXP */
  4537.     } else {
  4538.         cmdlvl--;
  4539.     }
  4540.     debug(F101,"popclvl cmdlvl","",cmdlvl);
  4541.     if (prstring[cmdlvl]) {
  4542.         cmsetp(prstring[cmdlvl]);
  4543.         makestr(&(prstring[cmdlvl]),NULL);
  4544.     }
  4545. #ifndef MAC
  4546.     if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4547.         setint();
  4548.         concb((char)escape);            /* Go into cbreak mode */
  4549.     }
  4550. #endif /* MAC */
  4551.     xcmdsrc = cmdstk[cmdlvl].src;
  4552.     debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4553.     debug(F101,"popclvl tlevel","",tlevel);
  4554.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4555. }
  4556. #else /* No script programming language */
  4557. int popclvl() {                         /* Just close current take file. */
  4558.     if (tlevel > -1) {                  /* if any... */
  4559.         if (tfnam[tlevel]) {
  4560.             free(tfnam[tlevel]);
  4561.             tfnam[tlevel] = NULL;
  4562.         }
  4563.         fclose(tfile[tlevel--]);
  4564.     }
  4565.     if (tlevel == -1) {                 /* And if back at top level */
  4566.         setint();
  4567.         concb((char)escape);            /* and go back into cbreak mode. */
  4568.     }
  4569.     xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4570.     return(tlevel + 1);
  4571. }
  4572. #endif /* NOSPL */
  4573.  
  4574.  
  4575. #ifndef NOSPL
  4576. static int
  4577. iseom(m) char * m; {                    /* Test if at end of macro def */
  4578.     if (!m)
  4579.       m = "";
  4580.     debug(F111,"iseom",m,maclvl);
  4581.     while (*m) {
  4582.         /* Anything but Space and Comma means more macro is left */
  4583.         if ((*m > SP) && (*m != ',')) {
  4584.             debug(F111,"iseom return",m,0);
  4585.             return(0);
  4586.         }
  4587.         m++;
  4588.     }
  4589.     debug(F111,"iseom return",m,1);
  4590.     return(1);                          /* Nothing left */
  4591. }
  4592. #endif /* NOSPL */
  4593.  
  4594. /* Pop all command levels that can be popped */
  4595.  
  4596. int
  4597. prepop() {
  4598.     if (cmdlvl > 0) {                   /* If command level is > 0 and... */
  4599.         while (
  4600. #ifndef NOSPL
  4601.                ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4602. #endif /* NOSPL */
  4603.             (tlevel > -1) &&
  4604.             feof(tfile[tlevel]))        /* And at end of file... */
  4605. #ifndef NOSPL
  4606.                /* Or command source is macro... */
  4607.                || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4608.                 (maclvl > -1) &&
  4609.                 !iseom(macp[maclvl])))  /* and at end of macro, then... */
  4610. #endif /* NOSPL */
  4611.         {
  4612.               popclvl();                /* pop command level. */
  4613.         }
  4614.     }
  4615.     return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
  4616. }
  4617.  
  4618. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4619.  
  4620. int
  4621. dostop() {
  4622.     extern int cmddep;
  4623.     while (popclvl()) ;         /* Pop all macros & take files */
  4624. #ifndef NOSPL
  4625.     if (cmddep > -1)            /* And all recursive cmd pkg invocations */
  4626.       while (cmpop() > -1) ;
  4627. #endif /* NOSPL */
  4628.     cmini(ckxech);              /* Clear the command buffer. */
  4629.     return(0);
  4630. }
  4631.  
  4632. /* Close the given log */
  4633.  
  4634. int
  4635. doclslog(x) int x; {
  4636.     int y;
  4637.     switch (x) {
  4638. #ifdef DEBUG
  4639.       case LOGD:
  4640.         if (deblog <= 0) {
  4641.             printf("?Debugging log wasn't open\n");
  4642.             return(0);
  4643.         }
  4644.         debug(F100,"Debug Log Closed","",0L);
  4645.         *debfil = '\0';
  4646.         deblog = 0;
  4647.         return(zclose(ZDFILE));
  4648. #endif /* DEBUG */
  4649.  
  4650. #ifndef NOXFER
  4651.       case LOGP:
  4652.         if (pktlog <= 0) {
  4653.             printf("?Packet log wasn't open\n");
  4654.             return(0);
  4655.         }
  4656.         *pktfil = '\0';
  4657.         pktlog = 0;
  4658.         return(zclose(ZPFILE));
  4659. #endif /* NOXFER */
  4660.  
  4661. #ifndef NOLOCAL
  4662.       case LOGS:
  4663.         if (seslog <= 0) {
  4664.             printf("?Session log wasn't open\n");
  4665.             return(0);
  4666.         }
  4667.         *sesfil = '\0';
  4668.         seslog = 0;
  4669.         return(zclose(ZSFILE));
  4670. #endif /* NOLOCAL */
  4671.  
  4672. #ifdef TLOG
  4673.       case LOGT: {
  4674. #ifdef IKSD
  4675.           extern int iklogopen, xferlog;
  4676. #endif /* IKSD */
  4677.           if (tralog <= 0
  4678. #ifdef IKSD
  4679.               && !iklogopen
  4680. #endif /* IKSD */
  4681.               ) {
  4682.               if (msgflg)
  4683.                 printf("?Transaction log wasn't open\n");
  4684.               return(0);
  4685.           }
  4686. #ifdef IKSD
  4687.           if (iklogopen && !inserver) {
  4688.               close(xferlog);
  4689.               iklogopen = 0;
  4690.           }
  4691. #endif /* IKSD */
  4692.           if (tralog) {
  4693.               tlog(F100,"Transaction Log Closed","",0L);
  4694.               zclose(ZTFILE);
  4695.           }
  4696.           *trafil = '\0';
  4697.           tralog = 0;
  4698.           return(1);
  4699.       }
  4700. #endif /* TLOG */
  4701.  
  4702. #ifdef CKLOGDIAL
  4703.       case LOGM:
  4704.         if (dialog <= 0) {
  4705.             if (msgflg) printf("?Connection log wasn't open\n");
  4706.             return(0);
  4707.         }
  4708.         *diafil = '\0';
  4709.         dialog = 0;
  4710.         return(zclose(ZDIFIL));
  4711. #endif /* CKLOGDIAL */
  4712.  
  4713. #ifndef NOSPL
  4714.       case LOGW:                        /* WRITE file */
  4715.       case LOGR:                        /* READ file */
  4716.         y = (x == LOGR) ? ZRFILE : ZWFILE;
  4717.         if (chkfn(y) < 1)               /* If no file to close */
  4718.           return(1);                    /* succeed silently. */
  4719.         return(zclose(y));              /* Otherwise, close the file. */
  4720. #endif /* NOSPL */
  4721.  
  4722.       default:
  4723.         printf("\n?Unexpected log designator - %d\n", x);
  4724.         return(0);
  4725.     }
  4726. }
  4727.  
  4728. static int slc = 0;                     /* Screen line count */
  4729.  
  4730. char *
  4731. showstring(s) char * s; {
  4732.     return(s ? s : "(null)");
  4733. }
  4734.  
  4735. char *
  4736. showoff(x) int x; {
  4737.     return(x ? "on" : "off");
  4738. }
  4739.  
  4740. char *
  4741. showooa(x) int x; {
  4742.     switch (x) {
  4743.       case SET_OFF:  return("off");
  4744.       case SET_ON:   return("on");
  4745.       case SET_AUTO: return("automatic");
  4746.       default:       return("(unknown)");
  4747.     }
  4748. }
  4749.  
  4750. #ifdef GEMDOS
  4751. isxdigit(c) int c; {
  4752.     return(isdigit(c) ||
  4753.            (c >= 'a' && c <= 'f') ||
  4754.            (c >= 'A' && c <= 'F'));
  4755. }
  4756. #endif /* GEMDOS */
  4757.  
  4758. #ifndef NOSETKEY
  4759. #ifdef OS2
  4760. static struct keytab shokeytab[] = {    /* SHOW KEY modes */
  4761.     "all",    1, 0,
  4762.     "one",    0, 0
  4763. };
  4764. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4765.  
  4766. #define SHKEYDEF TT_MAX+5
  4767. struct keytab shokeymtab[] = {
  4768.     "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
  4769.     "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
  4770.     "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
  4771.     "at386",     TT_AT386,   0,         /* Unixware ANSI */
  4772.     "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
  4773.     "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
  4774.     "be",        TT_BEOS,    CM_INV|CM_ABR,
  4775.     "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
  4776.     "beterm",    TT_BEOS,    0,         /* BeOS Console */
  4777.     "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
  4778.     "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
  4779.     "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
  4780.     "default",   SHKEYDEF,   0,
  4781.     "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
  4782.     "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
  4783.     "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
  4784.     "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
  4785.     "h19",       TT_H19,     CM_INV,    /* Heath-19 */
  4786.     "heath19",   TT_H19,     0,         /* Heath-19 */
  4787.     "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
  4788.     "hft",       TT_HFT,     0,         /* IBM HFT */
  4789.     "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
  4790.     "hpterm",    TT_HPTERM,  0,         /* HP TERM */
  4791.     "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
  4792.     "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
  4793.     "linux",     TT_LINUX,   0,         /* Linux */
  4794.     "qansi",     TT_QANSI,   0,         /* QNX ANSI */
  4795.     "qnx",       TT_QNX,     0,         /* QNX */
  4796.     "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
  4797.     "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
  4798.     "sni-97801", TT_97801,   0,         /* Sinix 97801 */
  4799. #ifdef OS2PM
  4800. #ifdef COMMENT
  4801.     "tek4014", TT_TEK40, 0,
  4802. #endif /* COMMENT */
  4803. #endif /* OS2PM */
  4804.     "tty",     TT_NONE,  0,
  4805.     "tvi910+", TT_TVI910, 0,
  4806.     "tvi925",  TT_TVI925, 0,
  4807.     "tvi950",  TT_TVI950, 0,
  4808.     "vc404",   TT_VC4404, 0,
  4809.     "vc4404",  TT_VC4404, CM_INV,
  4810.     "vip7809", TT_VIP7809, 0,
  4811.     "vt100",   TT_VT100, 0,
  4812.     "vt102",   TT_VT102, 0,
  4813.     "vt220",   TT_VT220, 0,
  4814.     "vt220pc", TT_VT220PC, 0,
  4815.     "vt320",   TT_VT320, 0,
  4816.     "vt320pc", TT_VT320PC, 0,
  4817.     "vt52",    TT_VT52,  0,
  4818.     "wp",      TT_KBM_WP, 0,
  4819.     "wy160",   TT_WY160,  0,
  4820.     "wy30",    TT_WY30,  0,
  4821.     "wy370",   TT_WY370, 0,
  4822.     "wy50",    TT_WY50,  0,
  4823.     "wy60",    TT_WY60,  0,
  4824.     "wyse30",  TT_WY30,  CM_INV,
  4825.     "wyse370", TT_WY370, CM_INV,
  4826.     "wyse50",  TT_WY50,  CM_INV,
  4827.     "wyse60",  TT_WY60,  CM_INV
  4828. };
  4829. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4830. #endif /* OS2 */
  4831.  
  4832. VOID
  4833. #ifdef OS2
  4834. shokeycode(c,m) int c, m;
  4835. #else
  4836. shokeycode(c) int c;
  4837. #endif
  4838. /* shokeycode */ {
  4839.     KEY ch;
  4840.     CHAR *s;
  4841. #ifdef OS2
  4842.     int i;
  4843.     con_event km;
  4844. #else /* OS2 */
  4845.     int km;
  4846. #endif /* OS2 */
  4847.  
  4848. #ifdef OS2
  4849.     extern int mskkeys;
  4850.     char * mstr = "";
  4851.  
  4852.     if (c >= KMSIZE) {
  4853.         bleep(BP_FAIL);
  4854.         return;
  4855.     }
  4856. #else /* OS2 */
  4857.     printf(" Key code \\%d => ", c);
  4858. #endif /* OS2 */
  4859.  
  4860. #ifndef OS2
  4861.     km = mapkey(c);
  4862.  
  4863. #ifndef NOKVERBS
  4864.     if (IS_KVERB(km)) {                 /* \Kverb? */
  4865.         int i, kv;
  4866.         kv = km & ~(F_KVERB);
  4867.         printf("Verb: ");
  4868.         for (i = 0; i < nkverbs; i++)
  4869.           if (kverbs[i].kwval == kv) {
  4870.               printf("\\K%s",kverbs[i].kwd);
  4871.               break;
  4872.           }
  4873.         printf("\n");
  4874.     } else
  4875. #endif /* NOKVERBS */
  4876.       if (IS_CSI(km)) {
  4877.           int xkm = km & 0xFF;
  4878.           if (xkm <= 32 || xkm >= 127)
  4879.             printf("String: \\{27}[\\{%d}\n",xkm);
  4880.           else
  4881.             printf("String: \\{27}[%c\n",xkm);
  4882.       } else if (IS_ESC(km)) {
  4883.           int xkm = km & 0xFF;
  4884.           if (xkm <= 32 || xkm >= 127)
  4885.             printf("String: \\{27}\\{%d}\n",xkm);
  4886.           else
  4887.             printf("String: \\{27}%c\n",xkm);
  4888.       } else if (macrotab[c]) {         /* See if there's a macro */
  4889.           printf("String: ");           /* If so, display its definition */
  4890.           s = macrotab[c];
  4891.           shostrdef(s);
  4892.           printf("\n");
  4893. #ifndef NOKVERBS
  4894.     } else if (km >= 0x100) {           /* This means "undefined" */
  4895.         printf("Undefined\n");
  4896. #endif /* NOKVERBS */
  4897.     } else {                            /* No macro, show single character */
  4898.         printf("Character: ");
  4899.         ch = km;
  4900.         if (ch < 32 || ch == 127
  4901. #ifdef OS2
  4902.             || ch > 255
  4903. #endif /* OS2 */
  4904. #ifndef NEXT
  4905. #ifndef AUX
  4906. #ifndef XENIX
  4907. #ifndef OS2
  4908.             || (ch > 127 && ch < 160)
  4909. #endif /* OS2 */
  4910. #endif /* XENIX */
  4911. #endif /* AUX */
  4912. #endif /* NEXT */
  4913.             )
  4914. /*
  4915.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  4916.   %u is supposed to be totally portable.
  4917. */
  4918.           printf("\\%u",(unsigned int) ch);
  4919.         else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  4920.         if (ch == (KEY) c)
  4921.           printf(" (self, no translation)\n");
  4922.         else
  4923.           printf("\n");
  4924.     }
  4925. #else /* OS2 */
  4926.     if (m < 0) {
  4927.         km = mapkey(c);
  4928.         mstr = "default";
  4929.     } else {
  4930.         km = maptermkey(c,m);
  4931.         for (i = 0; i < nshokeym; i++) {
  4932.             if (m == shokeymtab[i].kwval) {
  4933.                 mstr = shokeymtab[i].kwd;
  4934.                 break;
  4935.             }
  4936.         }
  4937.     }
  4938.     s = keyname(c);
  4939.     debug(F111,"shokeycode mstr",mstr,m);
  4940.     debug(F111,"shokeycode keyname",s,c);
  4941.     printf(" %sKey code \\%d %s (%s) => ",
  4942.             mskkeys ? "mskermit " : "",
  4943.             mskkeys ? cktomsk(c) : c,
  4944.             s == NULL ? "" : s, mstr);
  4945.  
  4946.     switch (km.type) {
  4947. #ifndef NOKVERBS
  4948.       case kverb: {
  4949.           int i, kv;
  4950.           kv = km.kverb.id & ~(F_KVERB);
  4951.           printf("Verb: ");
  4952.           for (i = 0; i < nkverbs; i++) {
  4953.               if (kverbs[i].kwval == kv) {
  4954.                   printf("\\K%s",kverbs[i].kwd);
  4955.                   break;
  4956.               }
  4957.           }
  4958.           printf("\n");
  4959.           break;
  4960.       }
  4961. #endif /* NOKVERBS */
  4962.       case csi: {
  4963.           int xkm = km.csi.key & 0xFF;
  4964.           if (xkm <= 32 || xkm >= 127)
  4965.             printf("String: \\{27}[\\{%d}\n",xkm);
  4966.           else
  4967.             printf("String: \\{27}[%c\n",xkm);
  4968.           break;
  4969.       }
  4970.       case esc: {
  4971.           int xkm = km.esc.key & 0xFF;
  4972.           if (xkm <= 32 || xkm >= 127)
  4973.             printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  4974.           else
  4975.             printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  4976.           break;
  4977.       }
  4978.       case macro: {
  4979.           printf("String: ");           /* Macro, display its definition */
  4980.           shostrdef(km.macro.string);
  4981.           printf("\n");
  4982.           break;
  4983.       }
  4984.       case literal: {
  4985.           printf("Literal string: ");   /* Literal, display its definition */
  4986.           shostrdef(km.literal.string);
  4987.           printf("\n");
  4988.           break;
  4989.       }
  4990.       case error: {
  4991.           if (c >= 0x100) {
  4992.               printf("Undefined\n");
  4993.           } else {
  4994.               printf("Character: ");
  4995.               ch = c;
  4996.               if (ch < 32 || ch == 127 || ch > 255
  4997. #ifndef NEXT
  4998. #ifndef AUX
  4999. #ifndef XENIX
  5000. #ifndef OS2
  5001.                    || (ch > 127 && ch < 160)
  5002. #endif /* OS2 */
  5003. #endif /* XENIX */
  5004. #endif /* AUX */
  5005. #endif /* NEXT */
  5006.                    )
  5007. /*
  5008.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5009.   %u is supposed to be totally portable.
  5010. */
  5011.                   printf("\\%u",(unsigned int) ch);
  5012.               else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5013.               printf(" (self, no translation)\n");
  5014.           }
  5015.           break;
  5016.       }
  5017.       case key: {
  5018.           printf("Character: ");
  5019.           ch = km.key.scancode;
  5020.           if (ch < 32 || ch == 127 || ch > 255
  5021. #ifndef NEXT
  5022. #ifndef AUX
  5023. #ifndef XENIX
  5024. #ifndef OS2
  5025.               || (ch > 127 && ch < 160)
  5026. #else
  5027.                || (ch > 127)
  5028. #endif /* OS2 */
  5029. #endif /* XENIX */
  5030. #endif /* AUX */
  5031. #endif /* NEXT */
  5032.               )
  5033. /*
  5034.   These used to be %d, but gcc 1.93 & later complain about type mismatches.
  5035.   %u is supposed to be totally portable.
  5036. */
  5037.             printf("\\%u",(unsigned int) ch);
  5038.           else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  5039.           if (ch == (KEY) c)
  5040.             printf(" (self, no translation)\n");
  5041.           else
  5042.             printf("\n");
  5043.           break;
  5044.       }
  5045.     }
  5046. #endif /* OS2 */
  5047. }
  5048. #endif /* NOSETKEY */
  5049.  
  5050. VOID
  5051. shostrdef(s) CHAR * s; {
  5052.     CHAR ch;
  5053.     if (!s) s = (CHAR *)"";
  5054.     while ((ch = *s++)) {
  5055.         if (ch < 32 || ch == 127 || ch == 255
  5056. /*
  5057.   Systems whose native character sets have graphic characters in C1...
  5058. */
  5059. #ifndef NEXT                            /* NeXT */
  5060. #ifndef AUX                             /* Macintosh */
  5061. #ifndef XENIX                           /* IBM PC */
  5062. #ifdef OS2
  5063. /*
  5064.   It doesn't matter whether the local host can display 8-bit characters;
  5065.   they are not portable among character-sets and fonts.  Who knows what
  5066.   would be displayed...
  5067. */
  5068.             || (ch > 127)
  5069. #else /* OS2 */
  5070.             || (ch > 127 && ch < 160)
  5071. #endif /* OS2 */
  5072. #endif /* XENIX */
  5073. #endif /* AUX */
  5074. #endif /* NEXT */
  5075.             )
  5076.           printf("\\{%d}",ch);          /* Display control characters */
  5077.         else putchar((char) ch);        /* in backslash notation */
  5078.     }
  5079. }
  5080.  
  5081. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  5082.  
  5083. #ifndef NOSHOW
  5084. VOID
  5085. shover() {
  5086. #ifdef OS2
  5087.     extern char ckxsystem[];
  5088. #endif /* OS2 */
  5089.     extern char *ck_patch, * cklibv;
  5090.     printf("\nVersions:\n %s\n",versio);
  5091.     printf(" Numeric: %ld\n",vernum);
  5092. #ifdef OS2
  5093.     printf(" Operating System: %s\n", ckxsystem);
  5094. #else /* OS2 */
  5095.     printf(" Built for: %s\n", ckxsys);
  5096. #ifdef CK_UTSNAME
  5097.     if (unm_nam[0])
  5098.       printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5099. #endif /* CK_UTSNAME */
  5100.     printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5101. #endif /* OS2 */
  5102.     if (xxdiff(ckxv,ckxsys))
  5103.       printf(" %s for%s\n",ckxv,ckxsys);
  5104.     else
  5105.       printf(" %s\n",ckxv);
  5106.     if (xxdiff(ckzv,ckzsys))
  5107.       printf(" %s for%s\n",ckzv,ckzsys);
  5108.     else
  5109.       printf(" %s\n",ckzv);
  5110.     printf(" %s\n",cklibv);
  5111.     printf(" %s\n",protv);
  5112.     printf(" %s\n",fnsv);
  5113.     printf(" %s\n %s\n",cmdv,userv);
  5114. #ifndef NOCSETS
  5115.     printf(" %s\n",xlav);
  5116. #endif /* NOCSETS */
  5117. #ifndef MAC
  5118. #ifndef NOLOCAL
  5119.     printf(" %s\n",connv);
  5120. #endif /* NOLOCAL */
  5121. #endif /* MAC */
  5122. #ifndef NODIAL
  5123.     printf(" %s\n",dialv);
  5124. #endif /* NODIAL */
  5125. #ifndef NOSCRIPT
  5126.     printf(" %s\n",loginv);
  5127. #endif /* NOSCRIPT */
  5128. #ifdef NETCONN
  5129.     printf(" %s\n",cknetv);
  5130. #ifdef OS2
  5131.     printf(" %s\n",ckonetv);
  5132. #ifdef CK_NETBIOS
  5133.     printf(" %s\n",ckonbiv);
  5134. #endif /* CK_NETBIOS */
  5135. #endif /* OS2 */
  5136. #endif /* NETCONN */
  5137. #ifdef TNCODE
  5138.     printf(" %s\n",cktelv);
  5139. #endif /* TNCODE */
  5140. #ifdef OS2
  5141. #ifdef OS2MOUSE
  5142.     printf(" %s\n",ckomouv);
  5143. #endif /* OS2MOUSE */
  5144. #endif /* OS2 */
  5145. #ifdef NEWFTP
  5146.     printf(" %s\n",ckftpv);
  5147. #endif /* NEWFTP */
  5148. #ifdef CK_AUTHENTICATION
  5149.     printf(" %s\n",ckathv);
  5150. #endif /* CK_AUTHENTICATION */
  5151. #ifdef CK_ENCRYPTION
  5152. #ifdef CRYPT_DLL
  5153.     printf(" %s\n",ck_crypt_dll_version());
  5154. #else /* CRYPT_DLL */
  5155.     printf(" %s\n",ckcrpv);
  5156. #endif /* CRYPT_DLL */
  5157. #endif /* CK_ENCRYPTION */
  5158. #ifdef CK_SSL
  5159.     printf(" %s\n",cksslv);
  5160. #endif /* CK_SSL */
  5161.     printf("\n");
  5162. }
  5163.  
  5164. #ifdef CK_LABELED
  5165. VOID
  5166. sholbl() {
  5167. #ifdef VMS
  5168.     printf("VMS Labeled File Features:\n");
  5169.     printf(" acl %s (ACL info %s)\n",
  5170.            showoff(lf_opts & LBL_ACL),
  5171.            lf_opts & LBL_ACL ? "preserved" : "discarded");
  5172.     printf(" backup-date %s (backup date/time %s)\n",
  5173.            showoff(lf_opts & LBL_BCK),
  5174.            lf_opts & LBL_BCK ? "preserved" : "discarded");
  5175.     printf(" name %s (original filename %s)\n",
  5176.            showoff(lf_opts & LBL_NAM),
  5177.            lf_opts & LBL_NAM ? "preserved" : "discarded");
  5178.     printf(" owner %s (original file owner id %s)\n",
  5179.            showoff(lf_opts & LBL_OWN),
  5180.            lf_opts & LBL_OWN ? "preserved" : "discarded");
  5181.     printf(" path %s (original file's disk:[directory] %s)\n",
  5182.            showoff(lf_opts & LBL_PTH),
  5183.            lf_opts & LBL_PTH ? "preserved" : "discarded");
  5184. #else
  5185. #ifdef OS2
  5186.     printf("OS/2 Labeled File features (attributes):\n");
  5187.     printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
  5188.     printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
  5189.     printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
  5190.     printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5191.     printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
  5192. #endif /* OS2 */
  5193. #endif /* VMS */
  5194. }
  5195. #endif /* CK_LABELED */
  5196.  
  5197. VOID
  5198. shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
  5199. #ifndef NOCSETS
  5200. #ifdef OS2
  5201. #ifndef NOTERM
  5202.     extern struct _vtG G[4], *GL, *GR;
  5203.     extern int decnrcm, sni_chcode;
  5204.     extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5205.  
  5206.     printf(" Terminal character-sets:\n");
  5207.     if (IS97801(tt_type_mode)) {
  5208.         if (cmask == 0377)
  5209.           printf("     Mode: 8-bit Mode\n");
  5210.         else
  5211.           printf("     Mode: 7-bit Mode\n");
  5212.         printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
  5213.     } else if (ISVT100(tt_type_mode)) {
  5214.         if (decnrcm)
  5215.           printf("     Mode: 7-bit National Mode\n");
  5216.         else
  5217.           printf("     Mode: 8-bit Multinational Mode\n");
  5218.     }
  5219.     if ( isunicode() )
  5220.         printf("    Local: Unicode display / %s input\n",
  5221.                 csl == TX_TRANSP ? "transparent" :
  5222.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5223.     else
  5224.         printf("    Local: %s\n",
  5225.                 csl == TX_TRANSP ? "transparent" :
  5226.                 csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5227.  
  5228.     if ( tt_utf8 ) {
  5229.         printf("   Remote: UTF-8\n");
  5230.     } else {
  5231.         printf("   Remote: %sG0: %s (%s)\n",
  5232.            GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
  5233.            txrinfo[G[0].designation]->keywd,
  5234.            G[0].designation == TX_TRANSP ? "" :
  5235.            G[0].size == cs94 ? "94 chars" :
  5236.            G[0].size == cs96 ? "96 chars" : "multi-byte");
  5237.         printf("           %sG1: %s (%s)\n",
  5238.            GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
  5239.            txrinfo[G[1].designation]->keywd,
  5240.            G[1].designation == TX_TRANSP ? "" :
  5241.            G[1].size == cs94 ? "94 chars" :
  5242.            G[1].size == cs96 ? "96 chars" : "multi-byte");
  5243.         printf("           %sG2: %s (%s)\n",
  5244.            GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
  5245.            txrinfo[G[2].designation]->keywd,
  5246.            G[2].designation == TX_TRANSP ? "" :
  5247.            G[2].size == cs94 ? "94 chars" :
  5248.            G[2].size == cs96 ? "96 chars" : "multi-byte");
  5249.         printf("           %sG3: %s (%s)\n",
  5250.            GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
  5251.            txrinfo[G[3].designation]->keywd,
  5252.            G[3].designation == TX_TRANSP ? "" :
  5253.            G[3].size == cs94 ? "94 chars" :
  5254.            G[3].size == cs96 ? "96 chars" : "multi-byte");
  5255.     }
  5256.     printf("\n");
  5257.     printf(" Keyboard character-sets:\n");
  5258.     printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5259.     printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
  5260. #endif /* NOTERM */
  5261. #else /* OS2 */
  5262. #ifndef MAC
  5263.     char *s;
  5264.  
  5265.     debug(F101,"TERM LOCAL CSET","",csl);
  5266.     debug(F101,"TERM REMOTE CSET","",csr);
  5267.     printf(" Terminal character-set: ");
  5268.     if (tcs_transp) {                   /* No translation */
  5269.         printf("transparent\n");
  5270.     } else {                            /* Translation */
  5271.         printf("%s (remote) %s (local)\n",
  5272.                fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5273.         if (csr != csl) {
  5274.             switch(gettcs(csr,csl)) {
  5275.               case TC_USASCII:  s = "ascii";        break;
  5276.               case TC_1LATIN:   s = "latin1-iso";   break;
  5277.               case TC_2LATIN:   s = "latin2-iso";   break;
  5278.               case TC_CYRILL:   s = "cyrillic-iso"; break;
  5279.               case TC_JEUC:     s = "japanese-euc"; break;
  5280.               case TC_HEBREW:   s = "hebrew-iso";   break;
  5281.               case TC_GREEK:    s = "greek-iso";    break;
  5282.               case TC_9LATIN:   s = "latin9-iso";   break;
  5283.               default:          s = "transparent";  break;
  5284.             }
  5285.             if (strcmp(s,fcsinfo[csl].keyword) &&
  5286.                 strcmp(s,fcsinfo[csr].keyword))
  5287.               printf("                         (via %s)\n",s);
  5288.         }
  5289.     }
  5290. #endif /* MAC */
  5291. #endif /* OS2 */
  5292. #endif /* NOCSETS */
  5293. }
  5294.  
  5295. #ifndef NOLOCAL
  5296. #ifdef OS2
  5297. extern char htab[];
  5298. VOID
  5299. shotabs() {
  5300.     int i;
  5301.  
  5302.     printf("Tab Stops:\n\n");
  5303.     for (i = 1; i <= 70; i++)
  5304.       printf("%c",htab[i]=='T'?'T':'-');
  5305.     printf("\n1.......10........20........30........40........50........60\
  5306. ........70\n\n");
  5307.     for (; i <= 140; i++)
  5308.       printf("%c",htab[i]=='T'?'T':'-');
  5309.     printf("\n........80........90.......100.......110.......120.......130\
  5310. .......140\n\n");
  5311.     for (; i <= 210; i++)
  5312.       printf("%c",htab[i]=='T'?'T':'-');
  5313.     printf("\n.......150.......160.......170.......180.......190.......200\
  5314. .......210\n\n");
  5315.     for (; i <= 255; i++)
  5316.       printf("%c",htab[i]=='T'?'T':'-');
  5317.     printf("\n.......220.......230.......240.......250..255\n");
  5318. }
  5319. #endif /* OS2 */
  5320. #endif /* NOLOCAL */
  5321.  
  5322. #ifdef OS2MOUSE
  5323. VOID
  5324. shomou() {
  5325.     int button, event, id, i;
  5326.     char * name = "";
  5327.  
  5328.     printf("Mouse settings:\n");
  5329.     printf("   Button Count:   %d\n",mousebuttoncount());
  5330.     printf("   Active:         %s\n\n",showoff(tt_mouse));
  5331.  
  5332.     for (button = 0; button < MMBUTTONMAX; button++)
  5333.       for (event = 0; event < MMEVENTSIZE; event++)
  5334.         if (mousemap[button][event].type != error)
  5335.           switch (mousemap[button][event].type) {
  5336.             case key:
  5337.               printf("   %s = Character: %c \\%d\n",
  5338.                      mousename(button,event),
  5339.                      mousemap[button][event].key.scancode,
  5340.                      mousemap[button][event].key.scancode );
  5341.               break;
  5342.             case kverb:
  5343.               id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5344.               if (id != K_IGNORE) {
  5345.                   for (i = 0; i< nkverbs; i++)
  5346.                     if (id == kverbs[i].kwval) {
  5347.                         name = kverbs[i].kwd;
  5348.                         break;
  5349.                     }
  5350.                   printf("   %s = Kverb: \\K%s\n",
  5351.                          mousename(button,event),
  5352.                          name
  5353.                          );
  5354.               }
  5355.               break;
  5356.             case macro:
  5357.               printf("   %s = Macro: ",
  5358.                      mousename(button,event) );
  5359.               shostrdef(mousemap[button][event].macro.string);
  5360.               printf("\n");
  5361.               break;
  5362.           }
  5363. }
  5364. #endif /* OS2MOUSE */
  5365.  
  5366. #ifndef NOLOCAL
  5367. VOID
  5368. shotrm() {
  5369.     char *s;
  5370.     extern char * getiact();
  5371.     extern int tt_print, adl_err;
  5372. #ifndef NOTRIGGER
  5373.     extern char * tt_trigger[];
  5374. #endif /* NOTRIGGER */
  5375. #ifdef CKTIDLE
  5376.     extern char * tt_idlesnd_str;
  5377.     extern int tt_idlesnd_tmo;
  5378.     extern int tt_idlelimit, tt_idleact;
  5379. #endif /* CKTIDLE */
  5380. #ifdef OS2
  5381.     extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5382.       decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5383.       wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5384.     int lines = 0;
  5385.  
  5386. #ifdef PCFONTS
  5387.     int i;
  5388.     char *font;
  5389.  
  5390.     if (IsOS2FullScreen()) {            /* Determine the font name */
  5391.         if (!os2LoadPCFonts()) {
  5392.             for (i = 0; i < ntermfont; i++) {
  5393.                 if (tt_font == term_font[i].kwval) {
  5394.                     font = term_font[i].kwd;
  5395.                     break;
  5396.                 }
  5397.             }
  5398.         } else {
  5399.             font = "(DLL not available)";
  5400.         }
  5401.     } else {
  5402.         font =     "(full screen only)";
  5403.     }
  5404. #endif /* PCFONTS */
  5405. #ifdef KUI
  5406.     char * font = "(unknown)";
  5407.     char * fontsize = ckitoa(tt_font_size);
  5408.     if ( ntermfont > 0 )
  5409.         font = term_font[tt_font].kwd;
  5410. #endif /* KUI */
  5411.  
  5412.     printf("Terminal parameters:\n");
  5413.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5414.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5415.            "Bytesize: Command",
  5416.            (cmdmsk == 0377) ? 8 : 7,
  5417.            " bits","Terminal",
  5418.            (cmask == 0377) ? 8 : 7," bits");
  5419.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5420.     printf(" %19s: %-13s","Type",
  5421.            (tt_type >= 0 && tt_type <= max_tt) ?
  5422.            tt_info[tt_type].x_name :
  5423.            "unknown" );
  5424.     if (tt_type >= 0 && tt_type <= max_tt)
  5425.       if (strlen(tt_info[tt_type].x_id))
  5426.         printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5427.     printf("\n");
  5428.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5429.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5430.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5431.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5432.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5433.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5434.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5435.     printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
  5436.            (tt_cursor == 2) ? "full" :
  5437.            (tt_cursor == 1) ? "half" : "underline",
  5438. #ifdef CK_AUTODL
  5439.            "autodownload",autodl ?
  5440.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5441. #else /* CK_AUTODL */
  5442.            "", ""
  5443. #endif /* CK_AUTODL */
  5444.            );
  5445.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5446.     printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
  5447.            tt_arrow ? "application" : "cursor",
  5448.            "Keypad-mode", tt_keypad ? "application" : "numeric"
  5449.            );
  5450.  
  5451.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5452.  
  5453.     /* Just to make sure we are using current info */
  5454.     updanswerbk();
  5455.  
  5456.     /*
  5457.        This line doesn't end with '\n' because the answerback string
  5458.        is terminated with a newline
  5459.     */
  5460.     printf(" %19s: %-13s  %13s: %-15s","Answerback",
  5461.            showoff(tt_answer),"response",answerback);
  5462.     switch (tt_bell) {
  5463.       case XYB_NONE:
  5464.         s = "none";
  5465.         break;
  5466.       case XYB_VIS:
  5467.         s= "visible";
  5468.         break;
  5469.       case XYB_AUD | XYB_BEEP:
  5470.         s="beep";
  5471.         break;
  5472.       case XYB_AUD | XYB_SYS:
  5473.         s="system sounds";
  5474.         break;
  5475.       default:
  5476.         s="(unknown)";
  5477.     }
  5478.     printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
  5479.            "Wrap",showoff(tt_wrap));
  5480.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5481.     printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5482.            "Autoscroll",showoff(autoscroll));
  5483.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5484.     printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5485.            "ESC[0m color",colorreset?"default-color":"current-color");
  5486.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5487.     printf(" %19s: %-13s  %13s: %-15s\n",
  5488.             "Erase color",user_erasemode?"default-color":"current-color",
  5489.            "Screen mode",decscnm?"reverse":"normal");
  5490.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5491.  
  5492.     printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5493.            "Output-pacing",tt_pacing);
  5494.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5495.  
  5496.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5497.            "Idle-action", getiact());
  5498.  
  5499.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5500.     printf(" %19s: %-13s  %13s: %-15s\n","Send data",
  5501.           showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5502.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5503. #ifndef NOTRIGGER
  5504.     printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
  5505.            tt_trigger[0],"Output pacing",tt_pacing );
  5506.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5507. #endif /* NOTRIGGER */
  5508.     printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
  5509.            showoff(marginbell),"at column", marginbellcol);
  5510.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5511.     switch (tt_modechg) {
  5512.       case TVC_DIS: s = "disabled"; break;
  5513.       case TVC_ENA: s = "enabled";  break;
  5514.       case TVC_W95: s = "win95-restricted"; break;
  5515.       default: s = "(unknown)";
  5516.     }
  5517.     printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
  5518.            showoff(dgunix),"Video change", s);
  5519.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5520.  
  5521. #ifdef CK_APC
  5522.     if (apcstatus == APC_ON) s = "on";
  5523.     else if (apcstatus == APC_OFF) s = "off";
  5524.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5525.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5526.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5527.     printf(" %19s: %-13s  %13s: %-15s\n",
  5528.            "APC", s,
  5529. #ifdef PCFONTS
  5530.            "Font (VGA)",font
  5531. #else /* PCFONTS */
  5532. #ifdef KUI
  5533.            "Font",font
  5534. #else
  5535.            "Font (VGA)","(not supported)"
  5536. #endif /* KUI */
  5537. #endif /* PCFONTS */
  5538.  
  5539.            );
  5540. #endif /* CK_APC */
  5541.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5542.  
  5543. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5544.     if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5545.       ttgwsiz();                        /* Try to get latest size */
  5546. #endif /* CK_TTGWSIZ */
  5547.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
  5548.            "Width",tt_cols[VTERM]);
  5549.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5550.     printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
  5551.           tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5552.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5553.  
  5554.     if (updmode == tt_updmode)
  5555.       if (updmode == TTU_FAST)
  5556.         s = "fast (fast)";
  5557.       else
  5558.         s = "smooth (smooth)";
  5559.     else
  5560.       if (updmode == TTU_FAST)
  5561.         s = "fast (smooth)";
  5562.       else
  5563.         s = "smooth (fast)";
  5564.  
  5565.     printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
  5566.            "interval",tt_update);
  5567.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5568.     printf(" %19s: %-13s  %13s: %-15s\n",
  5569.            "Screen-optimization",showoff(tt_diff_upd),
  5570.            "Status line",showoff(tt_status[VTERM]));
  5571.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5572.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5573.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5574.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5575.  
  5576.     /* Display colors (should become SHOW COLORS) */
  5577.     {
  5578.         USHORT row, col;
  5579.         char * colors[16] = {
  5580.             "black","blue","green","cyan","red","magenta","brown","lgray",
  5581.             "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5582.         };
  5583.         printf("\n");
  5584.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5585.  
  5586.         printf(" Color:");
  5587. #ifndef ONETERMUPD
  5588.         GetCurPos(&row, &col);
  5589.         WrtCharStrAtt("border",    6, row, 9, &colorborder );
  5590.         WrtCharStrAtt("debug",     5, row, 17, &colordebug );
  5591.         WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
  5592.         WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
  5593.         WrtCharStrAtt("select",    6, row, 42, &colorselect );
  5594.         WrtCharStrAtt("status",    6, row, 50, &colorstatus );
  5595.         WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
  5596.         WrtCharStrAtt("underline",  9, row, 67, &colorunderline );
  5597. #endif /* ONETERMUPD */
  5598.         row = VscrnGetCurPos(VCMD)->y+1;
  5599.         VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
  5600.         VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
  5601.         VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
  5602.         VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
  5603.         VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
  5604.         VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
  5605.         VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
  5606.         VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
  5607.         printf("\n");
  5608.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5609.  
  5610.         /* Foreground color names */
  5611.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5612.                 "",
  5613.                 colors[colordebug&0x0F],
  5614.                 colors[colorhelp&0x0F],
  5615.                 colors[colorreverse&0x0F],
  5616.                 colors[colorselect&0x0F],
  5617.                 colors[colorstatus&0x0F],
  5618.                 colors[colornormal&0x0F],
  5619.                 colors[colorunderline&0x0F] );
  5620.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5621.  
  5622.         /* Background color names */
  5623.         printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5624.                 colors[colorborder],
  5625.                 colors[colordebug>>4],
  5626.                 colors[colorhelp>>4],
  5627.                 colors[colorreverse>>4],
  5628.                 colors[colorselect>>4],
  5629.                 colors[colorstatus>>4],
  5630.                 colors[colornormal>>4],
  5631.                 colors[colorunderline>>4] );
  5632.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5633.         printf("\n");
  5634.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5635.         printf(" Color:");
  5636. #ifndef ONETERMUPD
  5637.         GetCurPos(&row, &col);
  5638.         WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
  5639.         WrtCharStrAtt("command",   7, row, 17, &colorcmd );
  5640. #endif /* ONETERMUPD */
  5641.         row = VscrnGetCurPos(VCMD)->y+1;
  5642.         VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
  5643.         VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
  5644.         printf("\n");
  5645.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5646.  
  5647.         /* Foreground color names */
  5648.         printf("%6s: %-8s%-8s\n","fore",
  5649.                 colors[colorgraphic&0x0F],
  5650.                 colors[colorcmd&0x0F] );
  5651.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5652.  
  5653.         /* Background color names */
  5654.         printf("%6s: %-8s%-8s\n","back",
  5655.                 colors[colorgraphic>>4],
  5656.                 colors[colorcmd>>4] );
  5657.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5658.     }
  5659.     printf("\n");
  5660.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5661.     {
  5662.         extern int trueblink, truereverse, trueunderline;
  5663.         printf(" Attribute:  blink: %-3s  reverse: %-3s  underline: %-3s\n",
  5664.                 trueblink?"on":"off", truereverse?"on":"off",
  5665.                 trueunderline?"on":"off");
  5666.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5667.     }
  5668.     {
  5669.         extern vtattrib WPattrib;
  5670.         printf(" ASCII Protected chars: %s%s%s%s%s%s\n",
  5671.                 WPattrib.blinking?"blink ":"",
  5672.                 WPattrib.reversed?"reverse ":"",
  5673.                 WPattrib.underlined?"underline ":"",
  5674.                 WPattrib.bold?"bold ":"",
  5675.                 WPattrib.dim?"dim ":"",
  5676.                 WPattrib.invisible?"invisible ":"");
  5677.         if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5678.     }
  5679.  
  5680.     printf("\n");
  5681.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5682.     (VOID) shoesc(escape);
  5683.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5684.     printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5685.     if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5686.  
  5687. #else /* OS2 */   /* Beginning of new non-OS2 version */
  5688.  
  5689.     printf("\n");
  5690.     printf("Terminal parameters:\n");
  5691.     printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
  5692.            "Bytesize: Command",
  5693.            (cmdmsk == 0377) ? 8 : 7,
  5694.            " bits","Terminal",
  5695.            (cmask == 0377) ? 8 : 7," bits");
  5696.     s = getenv("TERM");
  5697. #ifdef XPRINT
  5698.     printf(" %19s: %-13s  %13s: %-15s\n",
  5699.            "Type",
  5700.            s ? s : "(unknown)",
  5701.            "Print",
  5702.            showoff(tt_print)
  5703.            );
  5704. #else
  5705.     printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5706. #endif /* XPRINT */
  5707.     printf(" %19s: %-13s  %13s: %-15s\n","Echo",
  5708.            duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5709.     printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
  5710.            showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5711.  
  5712. #ifdef CK_APC
  5713.     if (apcstatus == APC_ON) s = "on";
  5714.     else if (apcstatus == APC_OFF) s = "off";
  5715.     else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5716.     else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5717.     else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5718.     printf(" %19s: %-13s  %13s: %-15s\n",
  5719.            "APC", s,
  5720. #ifdef CK_AUTODL
  5721.            "Autodownload", autodl ?
  5722.            (adl_err ? "on, error stop" : "on, error continue") : "off"
  5723. #else
  5724.            "",""
  5725. #endif /* CK_AUTODL */
  5726.            );
  5727. #endif /* CK_APC */
  5728.  
  5729. #ifdef CK_TTGWSIZ                       /* Console terminal screen size */
  5730.     ttgwsiz();                          /* Try to get latest size */
  5731.     printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5732. #endif /* CK_TTGWSIZ */
  5733.  
  5734.     printf(" %19s: %-13s  %13s: %-15s\n","Debug",
  5735.            showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5736.  
  5737. #ifdef CKTIDLE
  5738.     printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
  5739.            "Idle-action", getiact());
  5740. #endif /* CKTIDLE */
  5741.  
  5742. #ifndef NOTRIGGER
  5743.     printf(" %19s: %-13s\n","Trigger",
  5744.            tt_trigger[0] ? tt_trigger[0] : "(none)");
  5745. #endif /* NOTRIGGER */
  5746. #ifdef UNIX
  5747. #ifndef NOJC
  5748.     printf(" %19s: %-13s\n\n","Suspend", showoff(suspend));
  5749. #endif /* NOJC */
  5750. #endif /* UNIX */
  5751.  
  5752.     printf("\n");
  5753.     (VOID) shoesc(escape);
  5754. #ifndef NOCSETS
  5755.     shotcs(tcsl,tcsr);          /* Show terminal character sets */
  5756. #endif /* NOCSETS */
  5757.  
  5758. #endif /* OS2 */
  5759. }
  5760.  
  5761. VOID
  5762. shmdmlin() {                            /* Briefly show modem & line */
  5763. #ifndef NODIAL
  5764. #ifndef MINIDIAL
  5765. #ifdef OLDTBCODE
  5766.     extern int tbmodel;
  5767.     _PROTOTYP( char * gtbmodel, (void) );
  5768. #endif /* OLDTBCODE */
  5769. #endif /* MINIDIAL */
  5770. #endif /* NODIAL */
  5771.     if (local)
  5772. #ifdef OS2
  5773.       printf(" Port: %s, Modem type: ",ttname);
  5774. #else
  5775.       printf(" Line: %s, Modem type: ",ttname);
  5776. #endif /* OS2 */
  5777.     else
  5778.       printf(
  5779. #ifdef OS2
  5780. " Communication device not yet selected with SET PORT\n Modem type: "
  5781. #else
  5782. " Communication device not yet selected with SET LINE\n Modem type: "
  5783. #endif /* OS2 */
  5784.              );
  5785. #ifndef NODIAL
  5786.     printf("%s",gmdmtyp());
  5787. #ifndef MINIDIAL
  5788. #ifdef OLDTBCODE
  5789.     if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  5790. #endif /* OLDTBCODE */
  5791. #endif /* MINIDIAL */
  5792. #else
  5793.     printf("(disabled)");
  5794. #endif /* NODIAL */
  5795. }
  5796.  
  5797. #ifdef CK_TAPI
  5798. void
  5799. shotapi(int option) {
  5800.     int rc=0,k ;
  5801.     char *s=NULL;
  5802.     LPDEVCFG        lpDevCfg = NULL;
  5803.     LPCOMMCONFIG    lpCommConfig = NULL;
  5804.     LPMODEMSETTINGS lpModemSettings = NULL;
  5805.     DCB *           lpDCB = NULL;
  5806.     extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
  5807.     extern int ntapiloc;
  5808.     extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  5809.     extern int ntapiline;
  5810.     extern int tttapi;                  /* TAPI in use */
  5811.     extern int tapipass;                /* TAPI Passthrough mode */
  5812.     extern int tapiconv;                /* TAPI Conversion mode */
  5813.     extern int tapilights;
  5814.     extern int tapipreterm;
  5815.     extern int tapipostterm;
  5816.     extern int tapimanual;
  5817.     extern int tapiinactivity;
  5818.     extern int tapibong;
  5819.     extern int tapiusecfg;
  5820.     extern char tapiloc[];
  5821.     extern int tapilocid;
  5822.     extern int TAPIAvail;
  5823.  
  5824.     if (!TAPIAvail) {
  5825.         printf("TAPI Support not enabled\r\n");
  5826.         return;
  5827.     }
  5828.     switch (option) {
  5829.       case 0:
  5830.         printf("TAPI Settings:\n");
  5831.         printf("  Line:                      %s\n",
  5832.                tttapi ? ttname : "(none in use)");
  5833.  
  5834.         cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  5835.         if (tapilocid == -1)
  5836.           tapilocid = cktapiGetCurrentLocationID();
  5837.  
  5838.         /* Find the current tapiloc entry */
  5839.         /* and use it as the default. */
  5840.         for (k = 0; k < ntapiloc; k++) {
  5841.             if (tapiloctab[k].kwval == tapilocid)
  5842.               break;
  5843.         }
  5844.         if (k >= 0 && k < ntapiloc)
  5845.           s = tapiloctab[k].kwd;
  5846.         else
  5847.           s = "(unknown)";
  5848.         printf("  Location:                  %s\n",s);
  5849.         printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
  5850.         printf("  Phone-number-conversions:  %s\n",
  5851.                 tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  5852.         printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
  5853.                 tapipass?"(n/a)":"");
  5854.         printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
  5855.                 tapipass?"(n/a)":"");
  5856.         printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
  5857.                 tapipass?"(n/a)":"");
  5858.         printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
  5859.                 tapipass?"(n/a)":"");
  5860.         printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
  5861.                 tapipass?"(n/a)":"");
  5862.         printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
  5863.                 tapipass?"(n/a)":"");
  5864.         printf("  Use-windows-configuration: %s %s\n",
  5865.                 tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  5866.         printf("\n");
  5867.  
  5868. #ifdef BETATEST
  5869.         if (tapipass) {
  5870. printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
  5871. printf("may open the device but may not place calls nor answer calls.\n");
  5872. printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
  5873. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  5874. printf("definition associated with the active TAPI LINE device.\n\n");
  5875.  
  5876.         } else {
  5877.  
  5878. printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
  5879. printf("may open the device, place and answer calls.  Dialing is performed\n");
  5880. printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
  5881.         }
  5882.  
  5883.         if (tapiconv == CK_ON ||
  5884.             tapiconv == CK_AUTO && !tapipass) {
  5885. printf(
  5886. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  5887. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  5888. printf("dialog.\n\n");
  5889.  
  5890.         } else {
  5891.  
  5892. printf(
  5893. "Phone numbers are converted from canonical to dialable form by K-95\n");
  5894. printf(
  5895. "using the dialing rules specified with the SET DIAL commands.  TAPI\n");
  5896. printf(
  5897. "Dialing Properties are imported automaticly upon startup and whenever\n");
  5898. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  5899. printf("is changed.\n\n");
  5900.         }
  5901. #endif /* BETATEST */
  5902.  
  5903.         if (tapipass) {
  5904.             printf("Type SHOW MODEM to see MODEM configuration.\n");
  5905.             if (tapiconv == CK_ON)
  5906.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  5907.         } else {
  5908.             if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  5909.               printf("Type SHOW DIAL to see DIAL-related items.\n");
  5910.         }
  5911.         break;
  5912.       case 1:
  5913.         cktapiDisplayTapiLocationInfo();
  5914.         break;
  5915.       case 2:
  5916.         rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  5917.                                      &lpCommConfig,&lpDCB);
  5918.         if (rc) {
  5919.             cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  5920.                                          lpCommConfig,lpDCB);
  5921.         } else {
  5922.             printf("?Unable to retrieve Modem Settings\n");
  5923.         }
  5924.         break;
  5925.       case 3: {
  5926.           HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  5927.           if (hModem)
  5928.             DisplayCommProperties(hModem);
  5929.           else
  5930.             printf("?Unable to retrieve a valid Modem Handle\n");
  5931.           CloseHandle(hModem);
  5932.           break;
  5933.       }
  5934.     }
  5935.     printf("\n");
  5936. }
  5937. #endif /* CK_TAPI */
  5938. #endif /* NOLOCAL */
  5939.  
  5940. #ifdef PATTERNS
  5941. static VOID
  5942. shopat() {
  5943.     extern char * binpatterns[], * txtpatterns[];
  5944.     extern int patterns, filepeek;
  5945.     char **p, *s;
  5946.     int i, j, k, n, flag, width;
  5947. #ifdef CK_TTGWSIZ
  5948.     ttgwsiz();                          /* Try to get latest size */
  5949. #ifdef OS2
  5950.     width = tt_cols[VCMD];
  5951. #else /* OS2 */
  5952.     width = tt_cols;
  5953. #endif /* OS2 */
  5954.     if (width < 1)
  5955. #endif /* CK_TTGWSIZ */
  5956.       width = 80;
  5957.     printf("\n");
  5958.     printf(" Set file type:            %s\n",gfmode(binary,1));
  5959.     printf(" Set file patterns:        %s", showooa(patterns));
  5960. #ifdef CK_LABELED
  5961.     if (binary == XYFT_L)
  5962.       printf(" (but SET FILE TYPE LABELED overrides)\n");
  5963.     else
  5964. #endif /* CK_LABELED */
  5965. #ifdef VMS
  5966.     if (binary == XYFT_I)
  5967.       printf(" (but SET FILE TYPE IMAGE overrides)\n");
  5968.     else
  5969. #endif /* VMS */
  5970.     if (filepeek)
  5971.       printf(" (but SET FILE SCAN ON overrides)\n");
  5972.     else
  5973.       printf("\n");
  5974.     printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  5975.     for (k = 0; k < 2; k++) {           /* For each kind of patter */
  5976.         printf("\n");
  5977.         if (k == 0) {                   /* binary... */
  5978.             printf(" File binary-patterns: ");
  5979.             p = binpatterns;
  5980.         } else {                        /* text... */
  5981.             printf(" File text-patterns:   ");
  5982.             p = txtpatterns;
  5983.         }
  5984.         if (!p[0]) {
  5985.             printf("(none)\n");
  5986.         } else {
  5987.             printf("\n ");
  5988.             n = 2;
  5989.             for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  5990.                 if (!p[i])              /* Done */
  5991.                   break;
  5992.                 s = p[i];               /* Look for embedded space */
  5993.                 for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  5994.                   if (*s == SP)
  5995.                     flag = 3;
  5996.                 n += j + flag;          /* Length of this line */
  5997.                 if (n >= width - 1) {
  5998.                     printf("\n ");
  5999.                     n = j+2;
  6000.                 }
  6001.                 printf(flag == 3 ? " {%s}" : " %s", p[i]);
  6002.             }
  6003.             if (n > 2)
  6004.               printf("\n");
  6005.         }
  6006.     }
  6007.     printf("\n");
  6008. }
  6009. #endif /* PATTERNS */
  6010.  
  6011. #ifndef NOSPL
  6012. static VOID
  6013. shooutput() {
  6014.     printf(" Output pacing:          %d (milliseconds)\n",pacing);
  6015.     printf(" Output special-escapes: %s\n", showoff(outesc));
  6016. }
  6017.  
  6018. static VOID
  6019. shoinput() {
  6020. #ifdef CK_AUTODL
  6021.     printf(" Input autodownload:     %s\n", showoff(inautodl));
  6022. #endif /* CK_AUTODL */
  6023.     printf(" Input cancellation:     %s\n", showoff(inintr));
  6024.     printf(" Input case:             %s\n", inpcas[cmdlvl] ?
  6025.            "observe" : "ignore");
  6026.     printf(" Input buffer-length:    %d\n", inbufsize);
  6027.     printf(" Input echo:             %s\n", showoff(inecho));
  6028.     printf(" Input silence:          %d (seconds)\n", insilence);
  6029. #ifdef OS2
  6030.     printf(" Input terminal:         %s\n", showoff(interm));
  6031. #endif /* OS2 */
  6032.     printf(" Input timeout:          %s\n", intime[cmdlvl] ?
  6033.            "quit" : "proceed");
  6034.     if (instatus < 0)
  6035.       printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
  6036.     else
  6037.       printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
  6038. }
  6039. #endif /* NOSPL */
  6040.  
  6041. #ifndef NOSPL
  6042. int
  6043. showarray() {
  6044. #ifdef COMMENT
  6045.     char * p, * q, ** ap;
  6046.     int i;
  6047. #endif /* COMMENT */
  6048.     char *s; int x = 0, y;
  6049.     int range[2];
  6050.  
  6051.     if ((y = cmfld("Array name","",&s,NULL)) < 0)
  6052.       if (y != -3)
  6053.         return(y);
  6054.     ckstrncpy(line,s,LINBUFSIZ);
  6055.     s = line;
  6056.     if ((y = cmcfm()) < 0)
  6057.       return(y);
  6058.     if (*s) {
  6059.         char ** ap;
  6060.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6061.             printf("?Bad array: %s\n",s);
  6062.             return(-9);
  6063.         }
  6064.         ap = a_ptr[x];
  6065.         if (!ap) {
  6066.             printf("Array not declared: %s\n", s);
  6067.             return(success = 1);
  6068.         } else {
  6069.             int i, n, max;
  6070.             max = (range[1] > 0) ?
  6071.               range[1] :
  6072.                 ((range[0] > 0) ? range[0] : a_dim[x]);
  6073.             if (range[0] < 0)
  6074.               range[0] = 0;
  6075.             if (max > a_dim[x])
  6076.               max = a_dim[x];
  6077.             n = 1;
  6078.             printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6079.             if (a_link[x] > -1)
  6080.               printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6081.             printf("\n");
  6082.             for (i = range[0]; i <= max; i++) {
  6083.                 if (ap[i]) {
  6084.                     printf("%3d. %s\n",i,ap[i]);
  6085.                     if (xaskmore) {
  6086.                         if (cmd_cols > 0) {
  6087.                             x = strlen(ap[i]) + 5;
  6088.                             y = (x % cmd_cols) ? 1 : 0;
  6089.                             n += (x / cmd_cols) + y;
  6090.                         } else {
  6091.                             n++;
  6092.                         }
  6093.                         if (n > (cmd_rows - 3)) {
  6094.                             if (!askmore())
  6095.                               break;
  6096.                             else
  6097.                               n = 0;
  6098.                         }
  6099.                     }
  6100.                 }
  6101.             }
  6102.         }
  6103.         return(1);
  6104.     }
  6105.  
  6106.     /* All arrays - just show name and dimension */
  6107.  
  6108.     for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6109.         if (a_ptr[y]) {
  6110.             if (x == 0) printf("Declared arrays:\n");
  6111.             x = 1;
  6112.             printf(" \\&%c[%d]",
  6113.                    (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6114.             if (a_link[y] > -1)
  6115.               printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6116.             printf("\n");
  6117.         }
  6118.         if (!x) printf(" No arrays declared\n");
  6119.     }
  6120.     return(1);
  6121. }
  6122. #endif /* NOSPL */
  6123.  
  6124. int
  6125. doshow(x) int x; {
  6126.     int y, z, i; long zz;
  6127.     extern int optlines;
  6128.     char *s;
  6129. #ifdef OS2
  6130.     extern int os2gks;
  6131.     extern int tt_kb_mode;
  6132. #endif /* OS2 */
  6133.     extern int srvcdmsg;
  6134.     extern char * cdmsgstr, * ckcdpath;
  6135.  
  6136. #ifndef NOSETKEY
  6137.     if (x == SHKEY) {                   /* SHOW KEY */
  6138.         int c;
  6139. #ifdef OS2
  6140.         if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6141.                         "one",xxstring)) < 0) return(x);
  6142.         switch (tt_kb_mode) {
  6143.           case KBM_EM:
  6144.             s = "emacs";
  6145.             break;
  6146.           case KBM_HE:
  6147.             s = "hebrew";
  6148.             break;
  6149.           case KBM_RU:
  6150.             s = "russian";
  6151.             break;
  6152.           case KBM_EN:
  6153.           default:
  6154.             s = "default";
  6155.             break;
  6156.         }
  6157.         if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6158.                         s,xxstring)) < 0) return(z);
  6159.         if (z == SHKEYDEF)
  6160.           z = -1;
  6161. #endif /* OS2 */
  6162.         if ((y = cmcfm()) < 0) return(y);
  6163. #ifdef IKSD
  6164.         if (inserver) {
  6165.             printf("Sorry, command disabled.\r\n");
  6166.             return(success = 0);
  6167.         }
  6168. #endif /* IKSD */
  6169.  
  6170. #ifdef MAC
  6171.         printf("Not implemented\n");
  6172.         return(0);
  6173. #else /* Not MAC */
  6174. #ifdef OS2
  6175.         if (x) {
  6176.             con_event evt;
  6177.             for (c = 0; c < KMSIZE; c++) {
  6178.                 evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6179.                 if (evt.type != error) {
  6180.                     shokeycode(c,z);
  6181.                 }
  6182.             }
  6183.         } else {
  6184. #endif /* OS2 */
  6185.             printf(" Press key: ");
  6186. #ifdef UNIX
  6187. #ifdef NOSETBUF
  6188.             fflush(stdout);
  6189. #endif /* NOSETBUF */
  6190. #endif /* UNIX */
  6191.             conbin((char)escape);       /* Put terminal in binary mode */
  6192. #ifdef OS2
  6193.             os2gks = 0;                 /* Raw scancode processing */
  6194. #endif /* OS2 */
  6195.             c = congks(0);              /* Get character or scan code */
  6196. #ifdef OS2
  6197.             os2gks = 1;                 /* Cooked scancode processing */
  6198. #endif /* OS2 */
  6199.             concb((char)escape);        /* Restore terminal to cbreak mode */
  6200.             if (c < 0) {                /* Check for error */
  6201.                 printf("?Error reading key\n");
  6202.                 return(0);
  6203.             }
  6204. #ifndef OS2
  6205. /*
  6206.   Do NOT mask when it can be a raw scan code, perhaps > 255
  6207. */
  6208.             c &= cmdmsk;                /* Apply command mask */
  6209. #endif /* OS2 */
  6210.             printf("\n");
  6211. #ifdef OS2
  6212.             shokeycode(c,z);
  6213. #else /* OS2 */
  6214.             shokeycode(c);
  6215. #endif /* OS2 */
  6216. #ifdef OS2
  6217.         }
  6218. #endif /* OS2 */
  6219.         return(1);
  6220. #endif /* MAC */
  6221.     }
  6222. #ifndef NOKVERBS
  6223.     if (x == SHKVB) {                   /* SHOW KVERBS */
  6224.         if ((y = cmcfm()) < 0) return(y);
  6225. #ifdef IKSD
  6226.         if (inserver) {
  6227.             printf("Sorry, command disabled.\r\n");
  6228.             return(success = 0);
  6229.         }
  6230. #endif /* IKSD */
  6231.         printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6232.         kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6233.         printf("\n");
  6234.         return(1);
  6235.     }
  6236. #ifdef OS2
  6237.     if (x == SHUDK) {                   /* SHOW UDKs */
  6238.         extern void showudk(void);
  6239.         if ((y = cmcfm()) < 0) return(y);
  6240. #ifdef IKSD
  6241.         if (inserver) {
  6242.             printf("Sorry, command disabled.\r\n");
  6243.             return(success = 0);
  6244.         }
  6245. #endif /* IKSD */
  6246.         showudk();
  6247.         return(1);
  6248.     }
  6249. #endif /* OS2 */
  6250. #endif /* NOKVERBS */
  6251. #endif /* NOSETKEY */
  6252.  
  6253. #ifndef NOSPL
  6254.     if (x == SHMAC) {                   /* SHOW MACRO */
  6255.         struct FDB kw, fl, cm;
  6256.         int i, k, n = 0, left, flag, confirmed = 0;
  6257.         char * p, *q[64];
  6258.         for (i = 0; i < nmac; i++) {    /* copy the macro table */
  6259.             mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6260.             mackey[i].kwval = i;        /* with value = pointer to macro tbl */
  6261.             mackey[i].flgs = mactab[i].flgs;
  6262.         }
  6263.         p = line;
  6264.         left = LINBUFSIZ;
  6265.         while (!confirmed && n < 64) {
  6266.             cmfdbi(&kw,                 /* First FDB - macro table */
  6267.                    _CMKEY,              /* fcode */
  6268.                    "Macro name",        /* hlpmsg */
  6269.                    "",                  /* default */
  6270.                    "",                  /* addtl string data */
  6271.                    nmac,                /* addtl numeric data 1: tbl size */
  6272.                    0,                   /* addtl numeric data 2: 4 = cmswi */
  6273.                    xxstring,            /* Processing function */
  6274.                    mackey,              /* Keyword table */
  6275.                    &fl                  /* Pointer to next FDB */
  6276.                    );
  6277.             cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
  6278.                    _CMFLD,              /* fcode */
  6279.                    "",                  /* hlpmsg */
  6280.                    "",                  /* default */
  6281.                    "",                  /* addtl string data */
  6282.                    0,                   /* addtl numeric data 1 */
  6283.                    0,                   /* addtl numeric data 2 */
  6284.                    xxstring,
  6285.                    NULL,
  6286.                    &cm
  6287.                    );
  6288.             cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
  6289.                    _CMCFM,              /* fcode */
  6290.                    "",                  /* hlpmsg */
  6291.                    "",                  /* default */
  6292.                    "",                  /* addtl string data */
  6293.                    0,                   /* addtl numeric data 1 */
  6294.                    0,                   /* addtl numeric data 2 */
  6295.                    NULL,
  6296.                    NULL,
  6297.                    NULL
  6298.                    );
  6299.             x = cmfdb(&kw);             /* Parse something */
  6300.             if (x < 0)
  6301.               return(x);
  6302.             s = atmbuf;                 /* What the user typed */
  6303.             switch (cmresult.fcode) {
  6304.               case _CMKEY:              /* If it was a keyword */
  6305.                 y = mlook(mactab,atmbuf,nmac); /* get full name */
  6306.                 if (y > -1)
  6307.                   s = mactab[y].kwd;    /* (fall thru on purpose...) */
  6308.               case _CMFLD:
  6309.                 k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6310.                 left -= k;
  6311.                 if (left <= 0) {
  6312.                     *p = NUL;
  6313.                     break;
  6314.                 }
  6315.                 q[n++] = p;             /* Point to this item */
  6316.                 p += k;                 /* Move buffer pointer past it */
  6317.                 break;
  6318.               case _CMCFM:              /* End of command */
  6319.                 confirmed++;
  6320.               default:
  6321.                 break;
  6322.             }
  6323.         }
  6324.         if (n == 0) {
  6325.             printf("Macros:\n");
  6326.             slc = 1;
  6327.             for (y = 0; y < nmac; y++)
  6328.               if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6329.             return(1);
  6330.         }
  6331.         slc = 0;
  6332.         for (i = 0; i < n; i++) {
  6333.             flag = 0;
  6334.             s = q[i];
  6335.             if (!s) s = "";
  6336.             if (!*s) continue;
  6337.             if (iswild(s)) {            /* Pattern match */
  6338.                 for (k = 0, x = 0; x < nmac; x++) {
  6339.                     if (ckmatch(s,mactab[x].kwd,0,1)) {
  6340.                         shomac(mactab[x].kwd,mactab[x].mval);
  6341.                         k++;
  6342.                     }
  6343.                 }
  6344.                 if (!k)
  6345.                   x = -1;
  6346.                 else
  6347.                   continue;
  6348.             } else {                    /* Exact match */
  6349.                 x = mxlook(mactab,s,nmac);
  6350.                 flag = 1;
  6351.             }
  6352.             if (flag && x == -1)
  6353.               x = mlook(mactab,s,nmac);
  6354.             switch (x) {
  6355.               case -3:                  /* Nothing to look up */
  6356.               case -1:                  /* Not found */
  6357.                 printf("%s - (not defined)\n",s);
  6358.                 break;
  6359.               case -2:                  /* Ambiguous, matches more than one */
  6360.                 printf("%s - ambiguous\n",s);
  6361.                 break;
  6362.               default:                  /* Matches one exactly */
  6363.                 shomac(mactab[x].kwd,mactab[x].mval);
  6364.                 break;
  6365.             }
  6366.         }
  6367.         return(1);
  6368.     }
  6369. #endif /* NOSPL */
  6370.  
  6371. /*
  6372.   Other SHOW commands only have two fields.  Get command confirmation here,
  6373.   then handle with big switch() statement.
  6374. */
  6375. #ifndef NOSPL
  6376.     if (x != SHBUI && x != SHARR)
  6377. #endif /* NOSPL */
  6378.       if ((y = cmcfm()) < 0)
  6379.         return(y);
  6380.  
  6381. #ifdef COMMENT
  6382.     /* This restriction is too general. */
  6383. #ifdef IKSD
  6384.     if (inserver &&
  6385. #ifdef CK_LOGIN
  6386.         isguest
  6387. #else
  6388.         0
  6389. #endif /* CK_LOGIN */
  6390.         ) {
  6391.         printf("Sorry, command disabled.\r\n");
  6392.         return(success = 0);
  6393.     }
  6394. #endif /* IKSD */
  6395. #endif /* COMMENT */
  6396.  
  6397.     switch (x) {
  6398.  
  6399. #ifdef ANYX25
  6400. #ifndef IBMX25
  6401.       case SHPAD:
  6402.         shopad(0);
  6403.         break;
  6404. #endif /* IBMX25 */
  6405. #endif /* ANYX25 */
  6406.  
  6407.       case SHNET:
  6408. #ifdef NOLOCAL
  6409.         printf(" No network support in this version of C-Kermit.\n");
  6410. #else
  6411. #ifndef NETCONN
  6412.         printf(" No network support in this version of C-Kermit.\n");
  6413. #else
  6414.         shonet();
  6415. #endif /* NETCONN */
  6416. #endif /* NOLOCAL */
  6417.         break;
  6418.  
  6419.       case SHPAR:
  6420.         shopar();
  6421.         break;
  6422.  
  6423. #ifndef NOXFER
  6424.       case SHATT:
  6425.         shoatt();
  6426.         break;
  6427. #endif /* NOXFER */
  6428.  
  6429. #ifndef NOSPL
  6430.       case SHCOU:
  6431.         printf(" %d\n",count[cmdlvl]);
  6432.         break;
  6433. #endif /* NOSPL */
  6434.  
  6435. #ifndef NOSERVER
  6436.       case SHSER:                       /* Show Server */
  6437.         i = 0;
  6438. #ifndef NOFRILLS
  6439.         printf("Function:          Status:\n");
  6440.         i++;
  6441.         printf(" GET                %s\n",nm[en_get]);
  6442.         i++;
  6443.         printf(" SEND               %s\n",nm[en_sen]);
  6444.         i++;
  6445.         printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
  6446.         i++;
  6447.         printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
  6448.         i++;
  6449. #ifndef NOSPL
  6450.         printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
  6451.         i++;
  6452. #endif /* NOSPL */
  6453.         printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
  6454.         i++;
  6455. #ifdef ZCOPY
  6456.         printf(" REMOTE COPY        %s\n",nm[en_cpy]);
  6457.         i++;
  6458. #endif /* ZCOPY */
  6459.         printf(" REMOTE DELETE      %s\n",nm[en_del]);
  6460.         printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
  6461.         printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
  6462.         i += 3;
  6463. #ifndef NOSPL
  6464.         printf(" REMOTE QUERY       %s\n",nm[en_que]);
  6465.         i++;
  6466. #endif /* NOSPL */
  6467.         printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
  6468.         printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
  6469.         printf(" REMOTE RENAME      %s\n",nm[en_ren]);
  6470.         printf(" REMOTE SET         %s\n",nm[en_set]);
  6471.         printf(" REMOTE SPACE       %s\n",nm[en_spa]);
  6472.         printf(" REMOTE TYPE        %s\n",nm[en_typ]);
  6473.         printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
  6474.         printf(" BYE                %s\n",nm[en_bye]);
  6475.         printf(" FINISH             %s\n",nm[en_fin]);
  6476.         printf(" EXIT               %s\n",nm[en_xit]);
  6477.         printf(" ENABLE             %s\n",nm[en_ena]);
  6478.         i += 11;
  6479. #endif /* NOFRILLS */
  6480.         if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6481.         printf("Server timeout:      %d\n",srvtim);
  6482.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6483.         printf("Server idle-timeout: %d\n",srvidl);
  6484.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6485.         printf("Server keepalive     %s\n", showoff(srvping));
  6486.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6487.         printf("Server cd-message    %s\n", showoff(srvcdmsg));
  6488.         if (srvcdmsg && cdmsgstr)
  6489.           printf("Server cd-message    %s\n", cdmsgstr);
  6490.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6491.         printf("Server display:      %s\n", showoff(srvdis));
  6492.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6493.         printf("Server login:        ");
  6494.         if (!x_user) {
  6495.             printf("(none)\n");
  6496.         } else {
  6497.             printf("\"%s\", \"%s\", \"%s\"\n",
  6498.                    x_user,
  6499.                    x_passwd ? x_passwd : "",
  6500.                    x_acct ? x_acct : ""
  6501.                    );
  6502.         }
  6503.         if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6504.         printf("Server get-path: ");
  6505.         if (ngetpath == 0) {
  6506.             printf("    (none)\n");
  6507.         } else {
  6508.             printf("\n");
  6509.             i += 3;
  6510.             for (x = 0; x < ngetpath; x++) {
  6511.                 if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6512.                 if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6513.                     if (!askmore())
  6514.                       break;
  6515.                     else
  6516.                       i = 0;
  6517.                 }
  6518.             }
  6519.         }
  6520.         break;
  6521. #endif /* NOSERVER */
  6522.  
  6523.       case SHSTA:                       /* Status of last command */
  6524.         printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6525.         return(0);                      /* Don't change it */
  6526.  
  6527.       case SHSTK: {                     /* Stack for MAC debugging */
  6528. #ifdef MAC
  6529.           long sp;
  6530.           sp = -1;
  6531.           loadA0 ((char *)&sp);         /* set destination address */
  6532.           SPtoaA0();                    /* move SP to destination */
  6533.           printf("Stack at 0x%x\n", sp);
  6534.           show_queue();                 /* more debugging */
  6535.           break;
  6536. #else
  6537.           shostack();
  6538. #endif /* MAC */
  6539.           break;
  6540.       }
  6541.  
  6542.  
  6543. #ifndef NOLOCAL
  6544. #ifdef OS2
  6545.       case SHTAB:                       /* SHOW TABS */
  6546. #ifdef IKSD
  6547.         if (inserver) {
  6548.             printf("Sorry, command disabled.\r\n");
  6549.             return(success = 0);
  6550.         }
  6551. #endif /* IKSD */
  6552.         shotabs();
  6553.         break;
  6554. #endif /* OS2 */
  6555.  
  6556.       case SHTER:                       /* SHOW TERMINAL */
  6557. #ifdef IKSD
  6558.         if (inserver) {
  6559.             printf("Sorry, command disabled.\r\n");
  6560.             return(success = 0);
  6561.         }
  6562. #endif /* IKSD */
  6563.         shotrm();
  6564.         break;
  6565.  
  6566. #ifdef OS2
  6567.       case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
  6568.         shovscrn();
  6569.         break;
  6570. #endif /* OS2 */
  6571. #endif /* NOLOCAL */
  6572.  
  6573. #ifdef OS2MOUSE
  6574.       case SHMOU:                       /* SHOW MOUSE */
  6575. #ifdef IKSD
  6576.         if (inserver) {
  6577.             printf("Sorry, command disabled.\r\n");
  6578.             return(success = 0);
  6579.         }
  6580. #endif /* IKSD */
  6581.         shomou();
  6582.         break;
  6583. #endif /* OS2MOUSE */
  6584.  
  6585. #ifndef NOFRILLS
  6586.       case SHVER:
  6587.         shover();
  6588.         break;
  6589. #endif /* NOFRILLS */
  6590.  
  6591. #ifndef NOSPL
  6592.       case SHBUI:                       /* Built-in variables */
  6593.         if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6594.           return(y);
  6595.         ckstrncpy(line,s,LINBUFSIZ);
  6596.         /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6597.  
  6598.       case SHFUN:                       /* or built-in functions */
  6599. #ifdef CK_TTGWSIZ
  6600. #ifdef OS2
  6601.         if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6602.           ttgwsiz();
  6603. #else /* OS2 */
  6604.         if (ttgwsiz() > 0) {            /* Get current screen size */
  6605.             if (tt_rows > 0 && tt_cols > 0) {
  6606.                 cmd_rows = tt_rows;
  6607.                 cmd_cols = tt_cols;
  6608.             }
  6609.         }
  6610. #endif /* OS2 */
  6611. #endif /* CK_TTGWSIZ */
  6612.  
  6613.         if (x == SHFUN) {               /* Functions */
  6614.             printf("\nThe following functions are available:\n\n");
  6615.             kwdhelp(fnctab,nfuncs,"","\\F","()",3,0);
  6616.             printf("\n");
  6617. #ifndef NOHELP
  6618.             printf(
  6619. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6620.                    );
  6621. #endif /* NOHELP */
  6622.             break;
  6623.         } else {                        /* Variables */
  6624.         int j, flag = 0, havearg = 0;
  6625.         struct stringarray * q = NULL;
  6626.         char ** pp;
  6627.         if (line[0]) {        /* Have something to search for */
  6628.         havearg = 1;        /* Maybe a list of things */
  6629.         q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0);
  6630.         if (!q) break;
  6631.         pp = q->a_head;
  6632.         }
  6633.         i = 0;
  6634.         for (y = 0; y < nvars; y++) {
  6635.         if ((vartab[y].flgs & CM_INV))
  6636.           continue;
  6637.         if (havearg) {        /* If I have something to match */
  6638.             char * s2;
  6639.             for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6640.             s2 = pp[j] ? pp[j] : "";
  6641. #ifdef COMMENT
  6642. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6643.             len = strlen(s2);
  6644.             if (len > 0) {
  6645.                 if (s2[len-1] != '$') {/* To allow anchors */
  6646.                 ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6647.                 s2 = line;
  6648.                 }
  6649.             }
  6650. #endif /* COMMENT */
  6651.             if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6652.                 flag = 1;    /* Matches */
  6653.                 break;
  6654.             }
  6655.             }
  6656.             if (!flag)        /* Doesn't match */
  6657.               continue;
  6658.         }
  6659.         s = nvlook(vartab[y].kwd);
  6660.         printf(" \\v(%s) = ",vartab[y].kwd);
  6661.         if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6662.             while (*s)        /* Show control chars symbolically */
  6663.               printf("\\{%d}",*s++);
  6664.             printf("\n");
  6665.         } else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
  6666.                vartab[y].kwval == VN_QUE   || /* \v(query) */
  6667. #ifdef OS2
  6668.                vartab[y].kwval == VN_SELCT || /* \v(select) */
  6669. #endif /* OS2 */
  6670.                (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6671.                 vartab[y].kwval <= VN_M_ZZZ)
  6672.                ) {
  6673.             int r = 12;        /* This one can wrap around */
  6674.             char buf[10];
  6675.             while (*s) {
  6676.             if (isprint(*s)) {
  6677.                 buf[0] = *s;
  6678.                 buf[1] = NUL;
  6679.                 r++;
  6680.             } else {
  6681.                 sprintf(buf,"\\{%d}",*s); /* SAFE */
  6682.                 r += (int) strlen(buf);
  6683.             }
  6684.             if (r >= cmd_cols - 1) {
  6685.                 printf("\n");
  6686.                 r = 0;
  6687.                 i++;
  6688.             }
  6689.             printf("%s",buf);
  6690.             s++;
  6691.             }
  6692.             printf("\n");
  6693.         } else
  6694.           printf("%s\n",s);
  6695.         if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6696.             if ((y >= nvars - 1) || !askmore())
  6697.               break;
  6698.             else
  6699.               i = 0;
  6700.         }
  6701.         }
  6702.         }
  6703.         break;
  6704.  
  6705.       case SHVAR:                       /* Global variables */
  6706.         x = 0;                          /* Variable count */
  6707.         slc = 1;                        /* Screen line count for "more?" */
  6708.         for (y = 33; y < GVARS; y++)
  6709.           if (g_var[y]) {
  6710.               if (x++ == 0) printf("Global variables:\n");
  6711.               sprintf(line," \\%%%c",y); /* SAFE */
  6712.               if (shomac(line,g_var[y]) < 0) break;
  6713.           }
  6714.         if (!x) printf(" No variables defined\n");
  6715.         break;
  6716.  
  6717.       case SHARG: {                     /* Args */
  6718.           char * s1, * s2;
  6719.           if (maclvl > -1) {
  6720.               printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6721.                      maclvl,
  6722.                      macargc[maclvl]
  6723.                      );
  6724.               for (y = 0; y < macargc[maclvl]; y++) {
  6725.                   s1 = m_arg[maclvl][y];
  6726.                   if (!s1) s1 = "(NULL)";
  6727.                   s2 = m_xarg[maclvl][y];
  6728.                   if (!s2) s2 = "(NULL)";
  6729.                   if (y < 10)
  6730.                     printf(" \\%%%d = %s\n",y,s1);
  6731.                   else
  6732.                     printf(" \\&_[%d] = %s\n",y,s2);
  6733.               }
  6734.           } else {
  6735.               printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  6736.               for (y = 0; y < topargc; y++) {
  6737.                   s1 = g_var[y + '0'];
  6738.                   if (!s1) s1 = "(NULL)";
  6739.                   s2 = toparg[y];
  6740.                   if (!s2) s2 = "(NULL)";
  6741.                   if (y < 10 && g_var[y])
  6742.                     printf(" \\%%%d = %s\n",y,s1);
  6743.                   if (toparg[y])
  6744.                     printf(" \\&_[%d] = %s\n",y,s2);
  6745.               }
  6746.           }
  6747.         }
  6748.         break;
  6749.  
  6750.       case SHARR:                       /* Arrays */
  6751.         return(showarray());
  6752. #endif /* NOSPL */
  6753.  
  6754. #ifndef NOXFER
  6755.       case SHPRO:                       /* Protocol parameters */
  6756.         shoparp();
  6757.         printf("\n");
  6758.         break;
  6759. #endif /* NOXFER */
  6760.  
  6761. #ifndef NOLOCAL
  6762.       case SHCOM:                       /* Communication parameters */
  6763.         printf("\n");
  6764.         shoparc();
  6765. #ifdef OS2
  6766.         {
  6767.             int i;
  6768.             char *s = "(unknown)";
  6769.             for (i = 0; i < nprty; i++)
  6770.               if (prtytab[i].kwval == priority) {
  6771.                   s = prtytab[i].kwd;
  6772.                   break;
  6773.               }
  6774.             printf(" Priority: %s\n", s );
  6775.         }
  6776. #endif /* OS2 */
  6777.  
  6778.         printf("\n");
  6779. #ifdef NETCONN
  6780.         if (!network
  6781. #ifdef IKSD
  6782.              && !inserver
  6783. #endif /* IKSD */
  6784.              ) {
  6785. #endif /* NETCONN */
  6786.             shomdm();
  6787.             printf("\n");
  6788. #ifdef NETCONN
  6789.         }
  6790. #endif /* NETCONN */
  6791.  
  6792. #ifndef NODIAL
  6793. #ifdef IKSD
  6794.         if ( !inserver )
  6795. #endif /* IKSD */
  6796.         {
  6797.             printf("Type SHOW DIAL to see DIAL-related items.\n");
  6798.             printf("Type SHOW MODEM to see modem-related items.\n");
  6799. #ifdef CK_TAPI
  6800.             printf("Type SHOW TAPI to see TAPI-related items.\n");
  6801. #endif /* CK_TAPI */
  6802.             printf("\n");
  6803.         }
  6804. #endif /* NODIAL */
  6805.         break;
  6806. #endif /* NOLOCAL */
  6807.  
  6808.       case SHFIL:                       /* File parameters */
  6809.         shofil();
  6810.         /* printf("\n"); */             /* (out o' space) */
  6811.         break;
  6812.  
  6813. #ifndef NOCSETS
  6814.       case SHLNG:                       /* Languages */
  6815.         shoparl();
  6816.         break;
  6817. #endif /* NOCSETS */
  6818.  
  6819. #ifndef NOSPL
  6820.       case SHSCR:                       /* Scripts */
  6821.         printf(" Command quoting:        %s\n", showoff(cmdgquo()));
  6822.         printf(" Take  echo:             %s\n", showoff(techo));
  6823.         printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
  6824.         printf(" Macro echo:             %s\n", showoff(mecho));
  6825.         printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
  6826.         printf(" Quiet:                  %s\n", showoff(quiet));
  6827.         printf(" Function diagnostics:   %s\n", showoff(fndiags));
  6828.         printf(" Function error:         %s\n", showoff(fnerror));
  6829. #ifdef CKLEARN
  6830.         {
  6831.             extern char * learnfile;
  6832.             extern int learning;
  6833.             if (learnfile) {
  6834.                 printf(" LEARN file:             %s (%s)\n",
  6835.                        learnfile,
  6836.                        learning ? "ON" : "OFF"
  6837.                        );
  6838.             } else
  6839.               printf(" LEARN file:             (none)\n");
  6840.         }
  6841. #endif /* CKLEARN */
  6842.         shoinput();
  6843.         shooutput();
  6844. #ifndef NOSCRIPT
  6845.         printf(" Script echo:            %s\n", showoff(secho));
  6846. #endif /* NOSCRIPT */
  6847.         printf(" Command buffer length:  %d\n", CMDBL);
  6848.         printf(" Atom buffer length:     %d\n", ATMBL);
  6849.         break;
  6850. #endif /* NOSPL */
  6851.  
  6852. #ifndef NOXMIT
  6853.       case SHXMI:
  6854.         printf("\n");
  6855.         printf(" File type:                       %s\n",
  6856.                binary ? "binary" : "text");
  6857. #ifndef NOCSETS
  6858.         printf(" File character-set:              %s\n",
  6859.                fcsinfo[fcharset].keyword);
  6860.         printf(" Terminal character-set (remote): %s\n",
  6861.                fcsinfo[tcsr].keyword);
  6862.         printf(" Terminal character-set (local):  %s\n",
  6863.                fcsinfo[tcsl].keyword);
  6864. #endif /* NOCSETS */
  6865.         printf(" Terminal bytesize:               %d\n",
  6866.                (cmask == 0xff) ? 8 : 7);
  6867.         printf(" Terminal echo:                   %s\n",
  6868.                duplex ? "local" : "remote");
  6869.         printf(" Transmit EOF:                    ");
  6870.         if (*xmitbuf == NUL) {
  6871.             printf("(none)\n");
  6872.         } else {
  6873.             char *p;
  6874.             p = xmitbuf;
  6875.             while (*p) {
  6876.                 if (*p < SP)
  6877.                   printf("^%c",ctl(*p));
  6878.                 else
  6879.                   printf("%c",*p);
  6880.                 p++;
  6881.             }
  6882.             printf("\n");
  6883.         }
  6884.         if (xmitf)
  6885.           printf(" Transmit Fill:                   %d\n", xmitf);
  6886.         else
  6887.           printf(" Transmit Fill:                   (none)\n");
  6888.         printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
  6889.         if (xmitp)
  6890.           printf(" Transmit Prompt:                 %d (%s)\n",
  6891.                  xmitp,
  6892.                  chartostr(xmitp)
  6893.                  );
  6894.         else
  6895.           printf(" Transmit Prompt:                 (none)\n");
  6896.         printf(" Transmit Echo:                   %s\n", showoff(xmitx));
  6897.         printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
  6898.         printf(" Transmit Pause:                  %d (millisecond%s)\n",
  6899.                xmitw,
  6900.                (xmitw == 1) ? "" : "s"
  6901.                );
  6902.         printf(" Transmit Timeout:                %d (second%s)\n",
  6903.                xmitt,
  6904.                (xmitt == 1) ? "" : "s"
  6905.                );
  6906.         printf("\n");
  6907.         break;
  6908. #endif /* NOXMIT */
  6909.  
  6910. #ifndef NODIAL
  6911.       case SHMOD:                       /* SHOW MODEM */
  6912. #ifdef IKSD
  6913.         if (inserver) {
  6914.             printf("Sorry, command disabled.\r\n");
  6915.             return(success = 0);
  6916.         }
  6917. #endif /* IKSD */
  6918.         shomodem();                     /* Show SET MODEM items */
  6919.         break;
  6920. #endif /* NODIAL */
  6921.  
  6922. #ifndef MAC
  6923.       case SHDFLT:
  6924.         printf("%s\n",zgtdir());
  6925.         break;
  6926. #endif /* MAC */
  6927.  
  6928. #ifndef NOLOCAL
  6929.       case SHESC:
  6930. #ifdef IKSD
  6931.         if (inserver) {
  6932.             printf("Sorry, command disabled.\r\n");
  6933.             return(success = 0);
  6934.         }
  6935. #endif /* IKSD */
  6936.         return(shoesc(escape));
  6937.  
  6938. #ifndef NODIAL
  6939.       case SHDIA:                       /* SHOW DIAL */
  6940. #ifdef IKSD
  6941.         if (inserver) {
  6942.             printf("Sorry, command disabled.\r\n");
  6943.             return(success = 0);
  6944.         }
  6945. #endif /* IKSD */
  6946.         shmdmlin();
  6947.         printf(", speed: ");
  6948.         if ((zz = ttgspd()) < 0) {
  6949.             printf("unknown");
  6950.         } else {
  6951.             if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  6952.         }
  6953.         if (carrier == CAR_OFF) s = "off";
  6954.         else if (carrier == CAR_ON) s = "on";
  6955.         else if (carrier == CAR_AUT) s = "auto";
  6956.         else s = "unknown";
  6957.         printf(", carrier: %s", s);
  6958.         if (carrier == CAR_ON) {
  6959.             if (cdtimo) printf(", timeout: %d sec", cdtimo);
  6960.             else printf(", timeout: none");
  6961.         }
  6962.         printf("\n");
  6963.         doshodial();
  6964.         if (local
  6965. #ifdef NETCONN
  6966.             && !network
  6967. #endif /* NETCONN */
  6968.             ) {
  6969.             printf("Type SHOW MODEM to see modem settings.\n");
  6970. #ifdef CK_TAPI
  6971.             printf("Type SHOW TAPI to see TAPI-related items\n");
  6972. #endif /* CK_TAPI */
  6973.             printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  6974.         }
  6975.         break;
  6976. #endif /* NODIAL */
  6977. #endif /* NOLOCAL */
  6978.  
  6979. #ifndef NOXFER
  6980. #ifdef CK_LABELED
  6981.       case SHLBL:                       /* Labeled file info */
  6982.         sholbl();
  6983.         break;
  6984. #endif /* CK_LABELED */
  6985. #endif /* NOXFER */
  6986.  
  6987.       case SHCSE:                       /* Character sets */
  6988. #ifdef NOCSETS
  6989.         printf(
  6990. " Character set translation is not supported in this version of C-Kermit\n");
  6991. #else
  6992.         shocharset();
  6993. #ifndef NOXFER
  6994.         printf("\n Unknown-Char-Set: %s\n",
  6995.                unkcs ? "Keep" : "Discard");
  6996. #endif /* NOXFER */
  6997. #ifdef OS2
  6998.         printf("\n");
  6999. #endif /* OS2 */
  7000.         shotcs(tcsl,tcsr);
  7001.         printf("\n");
  7002. #ifdef OS2
  7003.         /* PC Code Page information */
  7004.         {
  7005.             char cpbuf[128];
  7006.             int cplist[16], cps;
  7007.             int activecp;
  7008.             cps = os2getcplist(cplist, sizeof(cplist));
  7009.  
  7010.             sprintf(cpbuf,              /* SAFE */
  7011.                     "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  7012.                      cps > 1 ? cplist[1] : 0,
  7013.                      cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  7014.                      cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  7015.                      cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  7016.                      cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  7017.                      cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  7018.                      cps > 12 ? cplist[12] : 0
  7019.                      );
  7020.             printf(" Code Pages:\n");
  7021.             activecp = os2getcp();
  7022.             if ( activecp ) {
  7023.               printf("     Active: %d\n",activecp);
  7024.               if (!isWin95())
  7025.                 printf("  Available: %s\n",cpbuf);
  7026.             } else
  7027.               printf("     Active: n/a\n");
  7028.             printf("\n");
  7029.         }
  7030. #endif /* OS2 */
  7031. #endif /* NOCSETS */
  7032.         break;
  7033.  
  7034.       case SHFEA:                       /* Features */
  7035.         shofea();
  7036.         break;
  7037.  
  7038. #ifdef CK_SPEED
  7039.       case SHCTL:                       /* Control-Prefix table */
  7040.         shoctl();
  7041.         break;
  7042. #endif /* CK_SPEED */
  7043.  
  7044.       case SHEXI: {
  7045.           extern int exithangup;
  7046.           printf("\n Exit warning %s\n", xitwarn ?
  7047.                  (xitwarn == 1 ? "on" : "always") : "off");
  7048.           printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  7049.           printf(" Exit hangup: %s\n", showoff(exithangup));
  7050.           printf(" Current exit status: %d\n\n", xitsta);
  7051.           break;
  7052.       }
  7053.       case SHPRT: {
  7054. #ifdef PRINTSWI
  7055.           extern int printtimo, printertype, noprinter;
  7056.           extern char * printterm, * printsep;
  7057. #ifdef BPRINT
  7058.           extern int printbidi;
  7059. #endif /* BPRINT */
  7060. #endif /* PRINTSWI */
  7061.  
  7062. #ifdef IKSD
  7063.         if (inserver &&
  7064. #ifdef CK_LOGIN
  7065.             isguest
  7066. #else /* CK_LOGIN */
  7067.             0
  7068. #endif /* CK_LOGIN */
  7069.              ) {
  7070.             printf("Sorry, command disabled.\r\n");
  7071.             return(success = 0);
  7072.         }
  7073. #endif /* IKSD */
  7074. #ifdef PRINTSWI
  7075.           if (noprinter) {
  7076.               printf("Printer: (none)\n\n");
  7077.               break;
  7078.           }
  7079. #endif /* PRINTSWI */
  7080.  
  7081.           printf("Printer: %s%s\n",
  7082.  
  7083.                  printpipe ? "| " : "",
  7084.                  printername ? printername :
  7085. #ifdef OS2
  7086.                  "PRN"
  7087. #else
  7088.                  "(default)"
  7089. #endif /* OS2 */
  7090.                  );
  7091. #ifdef PRINTSWI
  7092. #ifdef BPRINT
  7093.           if (printbidi) {
  7094.               printf(" /BIDIRECTIONAL\n");
  7095.               if (pportspeed > 0)
  7096.                 printf(" /SPEED:%ld\n",pportspeed);
  7097.               printf(" /PARITY:%s\n",parnam((char)pportparity));
  7098.               printf(" /FLOW:%s\n",
  7099.                      pportflow == FLO_NONE ? "NONE" :
  7100.                      (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7101.                      );
  7102.           } else
  7103.             printf(" /OUTPUT-ONLY\n");
  7104. #endif /* BPRINT */
  7105.           switch (printertype) {
  7106.             case PRT_NON: printf(" /NONE\n"); break;
  7107.             case PRT_FIL: printf(" /FILE\n"); break;
  7108.             case PRT_PIP: printf(" /PIPE\n"); break;
  7109.             case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7110.             case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7111.           }
  7112.           printf(" /TIMEOUT:%d\n",printtimo);
  7113.           if (printterm) {
  7114.               printf(" /END-OF-JOB-STRING:");
  7115.               shostrdef(printterm);
  7116.               printf("\n");
  7117.           } else
  7118.             printf(" /END-OF-JOB-STRING:(none)\n");
  7119.           printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7120. #endif /* PRINTSWI */
  7121.           printf("\n");
  7122.           break;
  7123.       }
  7124.  
  7125.       case SHCMD: {
  7126. #ifdef DOUBLEQUOTING
  7127.           extern int dblquo;
  7128. #endif /* DOUBLEQUOTING */
  7129. #ifdef LOCUS
  7130.           extern int locus, autolocus;
  7131. #endif /* LOCUS */
  7132. #ifdef CK_AUTODL
  7133.           printf(" Command autodownload: %s\n",showoff(cmdadl));
  7134. #else
  7135.           printf(" Command autodownload: (not available)\n");
  7136. #endif /* CK_AUTODL */
  7137.           printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7138. #ifdef CK_RECALL
  7139.           printf(" Command recall-buffer-size: %d\n",cm_recall);
  7140. #else
  7141.           printf(" Command recall-buffer not available in this version\n");
  7142. #endif /* CK_RECALL */
  7143. #ifdef CK_RECALL
  7144.           printf(" Command retry: %s\n",showoff(cm_retry));
  7145. #else
  7146.           printf(" Command retry not available in this version\n");
  7147. #endif /* CK_RECALL */
  7148.           printf(" Command interruption: %s\n", showoff(cmdint));
  7149.           printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7150. #ifdef DOUBLEQUOTING
  7151.           printf(" Command doublequoting: %s\n", showoff(dblquo));
  7152. #endif /* DOUBLEQUOTING */
  7153.           printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7154.           printf(" Command height: %d\n", cmd_rows);
  7155.           printf(" Command width:  %d\n", cmd_cols);
  7156. #ifndef IKSDONLY
  7157. #ifdef OS2
  7158.           printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7159. #endif /* OS2 */
  7160. #endif /* IKSDONLY */
  7161. #ifdef LOCUS
  7162.           printf(" Locus:          %s",
  7163.                  autolocus ? "auto" : (locus ? "local" : "remote"));
  7164.           if (autolocus)
  7165.             printf(" (%s)", locus ? "local" : "remote");
  7166.           printf("\n");
  7167. #endif /* LOCUS */
  7168.           printf(" Hints:          %s\n", showoff(hints));
  7169.           printf(" Quiet:          %s\n", showoff(quiet));
  7170.           printf(" Maximum command length: %d\n", CMDBL);
  7171. #ifndef NOSPL
  7172.           {
  7173.               char * s;
  7174.               int k;
  7175.               printf(" Maximum number of macros: %d\n", MAC_MAX);
  7176.               printf(" Macros defined: %d\n", nmac);
  7177.               printf(" Maximum macro depth: %d\n", MACLEVEL);
  7178.               printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7179.               s = "(not defined)";
  7180.               k = mlook(mactab,"on_unknown_command",nmac);
  7181.               if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7182.               printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7183.           }
  7184. #endif /* NOSPL */
  7185. #ifdef UNIX
  7186. #ifndef NOJC
  7187.           printf(" Suspend: %s\n", showoff(suspend));
  7188. #endif /* NOJC */
  7189. #endif /* UNIX */
  7190.           printf(" Access to external commands and programs%s allowed\n",
  7191. #ifndef NOPUSH
  7192.                  !nopush ? "" :
  7193. #endif /* NOPUSH */
  7194.                   " not");
  7195.           break;
  7196.       }
  7197.  
  7198. #ifndef NOSPL
  7199.       case SHALRM:
  7200.         if (ck_alarm)
  7201.           printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7202.         else
  7203.           printf("(no alarm set)\n");
  7204.         break;
  7205. #endif /* NOSPL */
  7206.  
  7207. #ifndef NOMSEND
  7208.       case SHSFL: {
  7209.           extern struct filelist * filehead;
  7210.           if (!filehead) {
  7211.               printf("send-list is empty\n");
  7212.           } else {
  7213.               struct filelist * flp;
  7214.               char * s;
  7215.               flp = filehead;
  7216.               while (flp) {
  7217.                   s = flp->fl_alias;
  7218.                   if (!s) s = "(none)";
  7219.                   printf("%s, mode: %s, alias: %s\n",
  7220.                          flp->fl_name,
  7221.                          gfmode(flp->fl_mode,0),
  7222.                          s
  7223.                          );
  7224.                   flp = flp->fl_next;
  7225.               }
  7226.           }
  7227.       }
  7228.       break;
  7229. #endif /* NOMSEND */
  7230.  
  7231. #ifdef CKXXCHAR
  7232.       case SHDBL:
  7233.         shodbl();
  7234.         break;
  7235. #endif /* CKXXCHAR */
  7236.  
  7237. #ifndef NOPUSH
  7238. #ifndef NOFRILLS
  7239.       case SHEDIT:
  7240.         if (!editor[0]) {
  7241.             s = getenv("EDITOR");
  7242.             if (s) ckstrncpy(editor,s,CKMAXPATH);
  7243.         }
  7244.         printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
  7245.         if (editor[0]) {
  7246.             printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7247.             printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
  7248.         }
  7249.         printf("\n");
  7250.         break;
  7251.  
  7252. #ifdef BROWSER
  7253.       case SHBROWSE:
  7254.         if (!browser[0]) {
  7255.             s = getenv("BROWSER");
  7256.             if (s) ckstrncpy(browser,s,CKMAXPATH);
  7257.         }
  7258.         printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7259.         if (browser[0]) {
  7260.             printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7261.             printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
  7262.         }
  7263.         printf("\n");
  7264.         break;
  7265. #endif /* BROWSER */
  7266. #endif /*  NOFRILLS */
  7267. #endif /* NOPUSH */
  7268.  
  7269. #ifndef NOLOCAL
  7270. #ifdef CK_TAPI
  7271.       case SHTAPI:                      /* TAPI options */
  7272. #ifdef IKSD
  7273.         if (inserver) {
  7274.             printf("Sorry, command disabled.\r\n");
  7275.             return(success = 0);
  7276.         }
  7277. #endif /* IKSD */
  7278.         shotapi(0);
  7279.         break;
  7280.       case SHTAPI_L:                    /* TAPI Locations */
  7281. #ifdef IKSD
  7282.         if (inserver) {
  7283.             printf("Sorry, command disabled.\r\n");
  7284.             return(success = 0);
  7285.         }
  7286. #endif /* IKSD */
  7287.         shotapi(1);
  7288.         break;
  7289.       case SHTAPI_M:                    /* TAPI Modem */
  7290. #ifdef IKSD
  7291.         if (inserver) {
  7292.             printf("Sorry, command disabled.\r\n");
  7293.             return(success = 0);
  7294.         }
  7295. #endif /* IKSD */
  7296.         shotapi(2);
  7297.         break;
  7298.       case SHTAPI_C:                    /* TAPI Comm */
  7299. #ifdef IKSD
  7300.         if (inserver) {
  7301.             printf("Sorry, command disabled.\r\n");
  7302.             return(success = 0);
  7303.         }
  7304. #endif /* IKSD */
  7305.         shotapi(3);
  7306.         break;
  7307. #endif /* CK_TAPI */
  7308.  
  7309.       case SHTCP:                       /* SHOTCP */
  7310.         printf("\n");
  7311.         shotcp(0);
  7312.         printf("\n");
  7313.         break;
  7314.  
  7315. #ifdef TNCODE
  7316.       case SHTEL:                       /* TELNET */
  7317.         printf("\n");
  7318.         shotel(0);
  7319.         printf("\n");
  7320.         break;
  7321.  
  7322.       case SHTOPT:                      /* TELNET OPTIONS */
  7323.         printf("\n");
  7324.         shotopt(0);
  7325.         printf("\n");
  7326.         break;
  7327. #endif /* TNCODE */
  7328.  
  7329. #ifdef CK_TRIGGER
  7330.       case SHTRIG: {
  7331.           extern char * tt_trigger[], * triggerval;
  7332.           int i;
  7333.           if (!tt_trigger[0]) {
  7334.               printf(" Triggers: (none)\n");
  7335.           } else {
  7336.               printf(" Triggers:\n");
  7337.               for (i = 0; i < TRIGGERS; i++) {
  7338.                   if (!tt_trigger[i])
  7339.                     break;
  7340.                   printf("  \"%s\"\n",tt_trigger[i]);
  7341.               }
  7342.               printf(" Most recent trigger encountered: ");
  7343.               if (triggerval)
  7344.                 printf("\"%s\"\n",triggerval);
  7345.               else
  7346.                 printf("(none)\n");
  7347.           }
  7348.           break;
  7349.       }
  7350. #endif /* CK_TRIGGER */
  7351. #endif /* NOLOCAL */
  7352.  
  7353. #ifndef NOSPL
  7354.       case SHINP:
  7355.         shoinput();
  7356.         break;
  7357. #endif /* NOSPL */
  7358.  
  7359.       case SHLOG: {
  7360. #ifndef MAC
  7361. #ifdef IKSD
  7362.           if (inserver &&
  7363. #ifdef CK_LOGIN
  7364.               isguest
  7365. #else /* CK_LOGIN */
  7366.               0
  7367. #endif /* CK_LOGIN */
  7368.              ) {
  7369.             printf("Sorry, command disabled.\r\n");
  7370.             return(success = 0);
  7371.         }
  7372. #endif /* IKSD */
  7373. #ifdef DEBUG
  7374.           printf("\n Debug log:       %s\n", deblog ? debfil : "(none)");
  7375. #endif /* DEBUG */
  7376. #ifndef NOXFER
  7377.           printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
  7378. #endif /* NOXFER */
  7379. #ifndef NOLOCAL
  7380.           printf(" Session log:     %s\n",   seslog ? sesfil : "(none)");
  7381. #endif /* NOLOCAL */
  7382. #ifdef TLOG
  7383.           printf(" Transaction log: %s (%s)\n",
  7384.                  (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7385.                  (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7386.                  );
  7387. #endif /* TLOG */
  7388. #ifdef CKLOGDIAL
  7389.             printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
  7390. #endif /* CKLOGDIAL */
  7391.           printf("\n");
  7392. #endif /* MAC */
  7393.           break;
  7394.       }
  7395.  
  7396. #ifndef NOSPL
  7397.       case SHOUTP:                      /* OUTPUT */
  7398.         shooutput();
  7399.         break;
  7400. #endif /* NOSPL */
  7401.  
  7402. #ifdef PATTERNS
  7403.       case SHOPAT:                      /* PATTERNS */
  7404.         shopat();
  7405.         break;
  7406. #endif /* PATTERNS */
  7407.  
  7408. #ifdef STREAMING
  7409.       case SHOSTR: {                    /* STREAMING */
  7410.           extern int streamrq, clearrq, cleared;
  7411.           extern long tfcps;
  7412.           debug(F101,"SHOW RELIABLE reliable","",reliable);
  7413.           printf("\n Reliable:     %s\n",showooa(reliable));
  7414.           printf(" Clearchannel: %s\n",showooa(clearrq));
  7415.           printf(" Streaming:    %s\n\n",showooa(streamrq));
  7416.           if ((!local && (streamrq == SET_ON)) ||
  7417.               (streamrq == SET_AUTO && reliable))
  7418.             printf(" Streaming will be done if requested.\n");
  7419.           else if ((streamrq == SET_OFF) ||
  7420.                    ((streamrq == SET_AUTO) && !reliable))
  7421.             printf(" Streaming will not be requested and will not be done.\n");
  7422.           else if ((streamrq == SET_ON) ||
  7423.                    ((streamrq == SET_AUTO) && reliable))
  7424.             printf(
  7425. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7426.           printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7427.                  streamed > 0 ? "" : "no ",
  7428.                  cleared ? ", clearchannel" : "",
  7429.                  tfcps
  7430.                  );
  7431.           printf("\n");
  7432.           break;
  7433.       }
  7434. #endif /* STREAMING */
  7435.  
  7436.       case SHOIKS:
  7437.         return(sho_iks());
  7438.         break;
  7439.  
  7440. #ifdef CK_AUTHENTICATION
  7441.       case SHOAUTH:
  7442.         return(sho_auth(0));
  7443. #endif /* CK_AUTHENTICATION */
  7444.  
  7445. #ifndef NOFTP
  7446.       case SHOFTP: {
  7447. #ifdef IKSD
  7448.         if (inserver) {
  7449.             printf("Sorry, command disabled.\r\n");
  7450.             return(success = 0);
  7451.         }
  7452. #endif /* IKSD */
  7453. #ifdef SYSFTP
  7454.         {
  7455.             extern char ftpapp[], ftpopts[];
  7456.             printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
  7457.             if (ftpapp[0])
  7458.               printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7459.         }
  7460. #else
  7461. #ifdef NEWFTP
  7462.         shoftp(0);
  7463. #else
  7464.         printf("(No FTP client included in this version of Kermit.)\n");
  7465. #endif /* NEWFTP */
  7466. #endif /* SYSFTP */
  7467.         break;
  7468.       }
  7469. #endif /* NOFTP */
  7470.  
  7471. #ifndef NOCMDL
  7472.       case SHXOPT: {
  7473. #ifdef IKSDB
  7474.           extern int dbenabled;
  7475.           extern char * dbfile, * dbdir;
  7476. #endif /* IKSDB */
  7477. #ifdef CKWTMP
  7478.           extern int ckxwtmp;
  7479.           extern char * wtmpfile;
  7480. #endif /* CKWTMP */
  7481. #ifdef CK_LOGIN
  7482.           extern int ckxanon, xferlog, logintimo;
  7483.           extern char * xferfile;
  7484. #ifdef UNIX
  7485.           extern int ckxpriv;
  7486. #endif /* UNIX */
  7487. #ifdef CK_PERMS
  7488.           extern int ckxperms;
  7489. #endif /* CK_PERMS */
  7490. #endif /* CK_LOGIN */
  7491.           extern char * bannerfile, * helpfile;
  7492.  
  7493. #ifdef IKSD
  7494.           if (inserver &&
  7495. #ifdef CK_LOGIN
  7496.               isguest
  7497. #else /* CK_LOGIN */
  7498.               0
  7499. #endif /* CK_LOGIN */
  7500.               ) {
  7501.               printf("Sorry, command disabled.\r\n");
  7502.               return(success = 0);
  7503.           }
  7504. #endif /* IKSD */
  7505.           printf("\n");
  7506.           if (!cmdint)
  7507.             printf(" --nointerrupts\n");
  7508.           printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7509.           printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7510.           printf(" --cdmessage:%d\n",srvcdmsg);
  7511.           printf(" --helpfile:%d\n",helpfile);
  7512.           if (inserver) {
  7513.               printf("\n");
  7514.               break;
  7515.           }
  7516. #ifdef CKSYSLOG
  7517. #ifdef SYSLOGLEVEL
  7518.           printf(" --syslog:%d (forced)\n",ckxsyslog);
  7519. #else
  7520.           printf(" --syslog:%d\n",ckxsyslog);
  7521. #endif /* SYSLOGLEVEL */
  7522. #endif /* CKSYSLOG */
  7523. #ifdef CKWTMP
  7524.           printf(" --wtmplog:%d\n",ckxwtmp);
  7525.           printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7526. #endif /* CKWTMP */
  7527. #ifdef IKSD
  7528. #ifdef CK_LOGIN
  7529.           printf(" --anonymous:%d\n",ckxanon);
  7530. #ifdef UNIX
  7531.           printf(" --privid:%d\n",ckxpriv);
  7532. #endif /* UNIX */
  7533. #ifdef CK_PERMS
  7534.           printf(" --permission:%04o\n",ckxperms);
  7535. #endif /* CK_PERMS */
  7536.           printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7537.           printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7538.           printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7539.           printf(" --xferlog=%d\n",xferlog);
  7540.           printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7541.           printf(" --timeout=%d\n",logintimo);
  7542. #endif /* CK_LOGIN */
  7543. #ifdef IKSDB
  7544.           printf(" --database=%d\n",dbenabled);
  7545.           printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7546.           if (dbdir)
  7547.             printf("   (db directory=[%s])\n",dbdir);
  7548. #endif /* IKSDB */
  7549. #ifdef IKSDCONF
  7550.           printf(" IKSD conf=%s\n",iksdconf);
  7551. #endif /* IKSDCONF */
  7552. #endif /* IKSD */
  7553.           printf("\n");
  7554.           break;
  7555.       }
  7556. #endif /* NOCMDL */
  7557.  
  7558.       case SHCD:
  7559.         s = getenv("CDPATH");
  7560.         if (!s) s = "(none)";
  7561.         printf("\n current directory:  %s\n", zgtdir());
  7562.         printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7563.         printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
  7564.         printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
  7565.         printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
  7566.         printf(" cd message file:    %s\n\n", cdmsgstr ? cdmsgstr : "(none)");
  7567.         break;
  7568.  
  7569. #ifndef NOCSETS
  7570.       case SHASSOC:
  7571.         (VOID) showassoc();
  7572.         break;
  7573. #endif /* NOCSETS */
  7574.  
  7575. #ifdef CKLOGDIAL
  7576.       case SHCONNX:
  7577. #ifdef NEWFTP
  7578.         if (ftpisconnected()) {
  7579.             extern char cxlogbuf[];
  7580.             dologshow(W_FTP | 1);
  7581.             if (cxlogbuf[0])
  7582.               dologshow(1);
  7583.         } else {
  7584. #endif /* NEWFTP */
  7585.             dologshow(1);
  7586. #ifdef NEWFTP
  7587.         }
  7588. #endif /* NEWFTP */
  7589.         break;
  7590. #endif /* CKLOGDIAL */
  7591.  
  7592.       case SHOPTS:
  7593.         optlines = 0;
  7594. #ifndef NOFRILLS
  7595.         (VOID) showdelopts();
  7596. #endif /* NOFRILLS */
  7597. #ifdef DOMYDIR
  7598.         (VOID) showdiropts();
  7599. #endif /* DOMYDIR */
  7600. #ifdef CKPURGE
  7601.         (VOID) showpurgopts();
  7602. #endif /* CKPURGE */
  7603.         (VOID) showtypopts();
  7604.         break;
  7605.  
  7606. #ifndef NOLOCAL
  7607.       case SHOFLO:
  7608.         (VOID) shoflow();
  7609.         break;
  7610. #endif /* NOLOCAL */
  7611.  
  7612. #ifndef NOXFER
  7613.       case SHOXFER:
  7614.         (VOID) shoxfer();
  7615.         break;
  7616. #endif /* NOXFER */
  7617.  
  7618. #ifdef CK_RECALL
  7619.       case SHHISTORY:
  7620.         (VOID) cmhistory();
  7621.         break;
  7622. #endif /* CK_RECALL */
  7623.  
  7624. #ifndef NOSEXP
  7625. #ifndef NOSPL
  7626.       case SHSEXP:
  7627.         (VOID) shosexp();
  7628.         break;
  7629. #endif /* NOSPL */
  7630. #endif /* NOSEXP */
  7631.  
  7632. #ifdef ANYSSH
  7633.       case SHOSSH:
  7634.         (VOID) shossh();
  7635.         break;
  7636. #endif /* ANYSSH */
  7637.  
  7638. #ifdef KUI
  7639.       case SHOGUI:
  7640.         (VOID) shogui();
  7641.         break;
  7642. #endif /* KUI */
  7643.  
  7644.       default:
  7645.         printf("\nNothing to show...\n");
  7646.         return(-2);
  7647.     }
  7648.     return(success = 1);
  7649. }
  7650.  
  7651. #ifndef NOXFER
  7652. int
  7653. shoatt() {
  7654.     printf("Attributes: %s\n", showoff(atcapr));
  7655.     if (!atcapr) return(0);
  7656.     printf(" Blocksize: %s\n", showoff(atblki));
  7657.     printf(" Date: %s\n", showoff(atdati));
  7658.     printf(" Disposition: %s\n", showoff(atdisi));
  7659.     printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7660.     printf(" Length: %s\n", showoff(atleni));
  7661.     printf(" Type (text/binary): %s\n", showoff(attypi));
  7662.     printf(" System ID: %s\n", showoff(atsidi));
  7663.     printf(" System Info: %s\n", showoff(atsysi));
  7664. #ifdef CK_PERMS
  7665.     printf(" Protection: %s\n", showoff(atlpri));
  7666. #endif /* CK_PERMS */
  7667. #ifdef STRATUS
  7668.     printf(" Format: %s\n", showoff(atfrmi));
  7669.     printf(" Creator: %s\n", showoff(atcrei));
  7670.     printf(" Account: %s\n", showoff(atacti));
  7671. #endif /* STRATUS */
  7672.     return(0);
  7673. }
  7674. #endif /* NOXFER */
  7675.  
  7676. #ifndef NOSPL
  7677. int                                     /* SHOW MACROS */
  7678. shomac(s1, s2) char *s1, *s2; {
  7679.     int x, n, pp;
  7680.     pp = 0;                             /* Parenthesis counter */
  7681.  
  7682.     debug(F110,"shomac s1",s1,0);
  7683.     debug(F110,"shomac s2",s2,0);
  7684.  
  7685. #ifdef IKSD
  7686.     if ( inserver &&
  7687. #ifdef IKSDCONF
  7688.         iksdcf
  7689. #else /* IKSDCONF */
  7690.         1
  7691. #endif /* IKSDCONF */
  7692.         ) {
  7693.         if (!ckstrcmp("on_exit",s1,-1,0) ||
  7694.             !ckstrcmp("on_logout",s1,-1,0))
  7695.           return(0);
  7696.     }
  7697. #endif /* IKSD */
  7698.  
  7699.     if (!s1)
  7700.       return(0);
  7701.     else
  7702.       printf("%s = ",s1);               /* Print blank line and macro name */
  7703.     n = (int)strlen(s1) + 4;            /* Width of current line */
  7704.     if (!s2) s2 = "(not defined)";
  7705.  
  7706.     while ((x = *s2++)) {               /* Loop thru definition */
  7707.         if (x == '(') pp++;             /* Treat commas within parens */
  7708.         if (x == ')') pp--;             /* as ordinary text */
  7709.         if (pp < 0) pp = 0;             /* Outside parens, */
  7710.         if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
  7711.             putchar(',');
  7712.             putchar('-');
  7713.             x = '\n';
  7714.         }
  7715.         if (inserver && (x == '\n'))    /* Send CR before LF */
  7716.           putchar(CR);
  7717.         putchar((CHAR)x);               /* Output the character */
  7718.         if (x == '\n') {                /* If it was a newline */
  7719. #ifdef UNIX
  7720. #ifdef NOSETBUF
  7721.             fflush(stdout);
  7722. #endif /* NOSETBUF */
  7723. #endif /* UNIX */
  7724.             putchar(' ');               /* Indent the next line 1 space */
  7725.             while(*s2 == ' ') s2++;     /* skip past leading blanks */
  7726.             n = 2;                      /* restart the character counter */
  7727.             slc++;                      /* and increment the line counter. */
  7728.         } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  7729.             putchar('-');               /* output a dash */
  7730.             if (inserver)
  7731.               putchar(CR);              /* and a carriage return */
  7732.             putchar(NL);                /* and a newline */
  7733. #ifdef UNIX
  7734. #ifdef NOSETBUF
  7735.             fflush(stdout);
  7736. #endif /* NOSETBUF */
  7737. #endif /* UNIX */
  7738.             n = 1;                      /* and restart the char counter */
  7739.             slc++;                      /* and increment the line counter */
  7740.         }
  7741.         if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  7742.             if (!askmore()) return(-1); /* ask if they want more. */
  7743.             n = 1;                      /* They do, start a new line */
  7744.             slc = 0;                    /* and restart line counter */
  7745.         }
  7746.     }
  7747.     if (inserver)
  7748.       putchar(CR);
  7749.     putchar(NL);                        /* End of definition */
  7750.     if (++slc > (cmd_rows - 3)) {
  7751.         if (!askmore()) return(-1);
  7752.         slc = 0;
  7753.     }
  7754.     return(0);
  7755. }
  7756. #endif /* NOSPL */
  7757. #endif /* NOSHOW */
  7758.  
  7759. int x_ifnum = 0;                        /* Flag for IF NUMERIC active */
  7760.  
  7761. #ifndef NOSPL
  7762. /* Evaluate an arithmetic expression. */
  7763. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  7764.  
  7765. static int xerror = 0;
  7766. int divbyzero = 0;
  7767. static char *cp;
  7768. static long tokval;
  7769. static char curtok;
  7770. static long expval;
  7771.  
  7772. #define LONGBITS (8*sizeof (long))
  7773. #define NUMBER 'N'
  7774. #define N_EOT 'E'
  7775.  
  7776. /*
  7777.  Replacement for strchr() and index(), neither of which seem to be universal.
  7778. */
  7779.  
  7780. static char *
  7781. #ifdef CK_ANSIC
  7782. windex(char * s, char c)
  7783. #else
  7784. windex(s,c) char *s, c;
  7785. #endif /* CK_ANSIC */
  7786. /* windex */ {
  7787.     while (*s != NUL && *s != c) s++;
  7788.     if (*s == c) return(s); else return(NULL);
  7789. }
  7790.  
  7791.  
  7792. /*
  7793.  g e t t o k
  7794.  
  7795.  Returns the next token.  If token is a NUMBER, sets tokval appropriately.
  7796. */
  7797. static char
  7798. gettok() {
  7799.     char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */
  7800.  
  7801.     while (isspace(*cp))                /* Skip past leading spaces */
  7802.       cp++;
  7803.  
  7804.     debug(F110,"GETTOK",cp,0);
  7805.  
  7806.     switch (*cp) {
  7807.       case '$':                         /* ??? */
  7808.       case '+':                         /* Add */
  7809.       case '-':                         /* Subtract or Negate */
  7810.       case '@':                         /* Greatest Common Divisor */
  7811.       case '*':                         /* Multiply */
  7812.       case '/':                         /* Divide */
  7813.       case '%':                         /* Modulus */
  7814.       case '<':                         /* Left shift */
  7815.       case '>':                         /* Right shift */
  7816.       case '&':                         /* And */
  7817.       case '|':                         /* Or */
  7818.       case '#':                         /* Exclusive Or */
  7819.       case '~':                         /* Not */
  7820.       case '^':                         /* Exponent */
  7821.       case '!':                         /* Factorial */
  7822.       case '(':                         /* Parens for grouping */
  7823.       case ')': return(*cp++);          /* operator, just return it */
  7824.       case '\n':
  7825.       case '\0': return(N_EOT);         /* End of line, return that */
  7826.     }
  7827. #ifdef COMMENT
  7828. /* This is the original code, which allows only integer numbers. */
  7829.  
  7830.     if (isxdigit(*cp)) {                /* Digit, must be a number */
  7831.         int radix = 10;                 /* Default radix */
  7832.         for (tp = tbuf; isxdigit(*cp); cp++)
  7833.           *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  7834.         *tp = '\0';                     /* End number */
  7835.         switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  7836.           case 'h':
  7837.           case 'x': radix = 16; cp++; break; /* if radix signifier... */
  7838.           case 'o':
  7839.           case 'q': radix = 8; cp++; break;
  7840.           case 't': radix = 2; cp++; break;
  7841.         }
  7842.         for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
  7843.             int dig;
  7844.             dig = *tp - '0';            /* Convert number */
  7845.             if (dig > 10) dig -= 'a'-'0'-10;
  7846.             if (dig >= radix) {
  7847.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  7848.                   printf("?Invalid digit '%c' in number\n",*tp);
  7849.                 xerror = 1;
  7850.                 return(NUMBER);
  7851.             }
  7852.             tokval = radix*tokval + dig;
  7853.         }
  7854.         return(NUMBER);
  7855.     }
  7856.     if (cmdlvl == 0 && !x_ifnum && !xerror)
  7857.       printf("Invalid character '%c' in input\n",*cp);
  7858.     xerror = 1;
  7859.     cp++;
  7860.     return(gettok());
  7861. #else
  7862. /* This code allows non-numbers to be treated as macro names */
  7863.     {
  7864.         int i, x;
  7865.         char * s, * cp1;
  7866.         cp1 = cp;
  7867.         tp = tbuf;
  7868.         for (i = 0; i < 80; i++) {
  7869.             /* Look ahead to next break character */
  7870.             /* pretty much anything that is not in the switch() above. */
  7871.             if (isalpha(*cp) || isdigit(*cp) ||
  7872.                 *cp == '_' || *cp == ':' || *cp == '.' ||
  7873.                 *cp == '[' || *cp == ']' ||
  7874.                 *cp == '{' || *cp == '}'
  7875.                 )
  7876.               tbuf[i] = *cp++;
  7877.             else
  7878.               break;
  7879.         }
  7880.         if (i >= 80) {
  7881.             printf("Too long - \"%s\"\n", cp1);
  7882.             xerror = 1;
  7883.             cp++;
  7884.             return(gettok());
  7885.         }
  7886.         if (xerror) return(NUMBER);
  7887.  
  7888.         tbuf[i] = NUL;
  7889.         s = tbuf;
  7890.         if (!isdigit(tbuf[0])) {
  7891.             char * s2 = NULL;
  7892.             x = mxlook(mactab,tbuf,nmac);
  7893.             debug(F111,"gettok mxlook",tbuf,x);
  7894.             if (x < 0) {
  7895.                 if (cmdlvl == 0 && !x_ifnum && !xerror)
  7896.                   printf("Bad number - \"%s\"\n",tbuf);
  7897.                 xerror = 1;
  7898.                 cp++;
  7899.                 return(gettok());
  7900.             }
  7901.             s2 = mactab[x].mval;
  7902.             if (!s2) s2 = "";
  7903.             if (*s2) s = s2;
  7904.         }
  7905. #ifdef CKFLOAT
  7906.         x = isfloat(s,0);
  7907. #else
  7908.         x = chknum(s);
  7909. #endif /* CKFLOAT */
  7910.         if (x > 0) {
  7911.             tokval = atoi(s);
  7912.         } else {
  7913.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  7914.               printf("Bad number - \"%s\"\n",tbuf);
  7915.             xerror = 1;
  7916.             cp++;
  7917.             return(gettok());
  7918.         }
  7919.         return(NUMBER);
  7920.     }
  7921. #endif /* COMMENT */
  7922. }
  7923.  
  7924. static long
  7925. #ifdef CK_ANSIC
  7926. expon(long x, long y)
  7927. #else
  7928. expon(x,y) long x,y;
  7929. #endif /* CK_ANSIC */
  7930. /* expon */ {
  7931.     long result = 1;
  7932.     int sign = 1;
  7933.     if (y < 0) return(0);
  7934.     if (x < 0) {
  7935.         x = -x;
  7936.         if (y & 1) sign = -1;
  7937.     }
  7938.     while (y != 0) {
  7939.         if (y & 1) result *= x;
  7940.         y >>= 1;
  7941.         if (y != 0) x *= x;
  7942.   }
  7943.   return(result * sign);
  7944. }
  7945.  
  7946. /*
  7947.  * factor ::= simple | simple ^ factor
  7948.  *
  7949.  */
  7950. static VOID
  7951. factor() {
  7952.     long oldval;
  7953.     simple();
  7954.     if (curtok == '^') {
  7955.         oldval = expval;
  7956.         curtok = gettok();
  7957.         factor();
  7958.         expval = expon(oldval,expval);
  7959.     }
  7960. }
  7961.  
  7962. /*
  7963.  * termp ::= NULL | {*,/,%,&} factor termp
  7964.  *
  7965.  */
  7966. static VOID
  7967. termp() {
  7968.     while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  7969.         long oldval;
  7970.         char op;
  7971.         op = curtok;
  7972.         curtok = gettok();              /* skip past operator */
  7973.         oldval = expval;
  7974.         factor();
  7975.         switch(op) {
  7976.           case '*': expval = oldval * expval; break;
  7977.           case '/':
  7978.           case '%':
  7979.             if (expval == 0) {
  7980.                 if (!x_ifnum)
  7981.                   printf("?Divide by zero\n");
  7982.                 xerror = 1;
  7983.                 divbyzero = 1;
  7984.                 expval = -1;
  7985.             } else
  7986.               expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  7987.             break;
  7988.           case '&':
  7989.             expval = oldval & expval; break;
  7990.         }
  7991.     }
  7992. }
  7993.  
  7994. static long
  7995. #ifdef CK_ANSIC
  7996. fact(long x)
  7997. #else
  7998. fact(x) long x;
  7999. #endif /* CK_ANSIC */
  8000. /* fact */ {                            /* factorial */
  8001.     long result = 1;
  8002.     while (x > 1)
  8003.       result *= x--;
  8004.     return(result);
  8005. }
  8006.  
  8007. /*
  8008.  * term ::= factor termp
  8009.  *
  8010.  */
  8011. static VOID
  8012. term() {
  8013.     factor();
  8014.     termp();
  8015. }
  8016.  
  8017. static long
  8018. #ifdef CK_ANSIC
  8019. gcd(long x, long y)
  8020. #else
  8021. gcd(x,y) long x,y;
  8022. #endif /* CK_ANSIC */
  8023. /* gcd */ {                             /* Greatest Common Divisor */
  8024.     int nshift = 0;
  8025.     if (x < 0) x = -x;
  8026.     if (y < 0) y = -y;                  /* validate arguments */
  8027.     if (x == 0 || y == 0) return(x + y);    /* this is bogus */
  8028.  
  8029.     while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
  8030.         nshift++;
  8031.         x >>= 1;
  8032.         y >>= 1;
  8033.     }
  8034.     while (x != 1 && y != 1 && x != 0 && y != 0) {
  8035.         while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
  8036.         while (!(y & 1)) y >>= 1;       /* powers of 2 */
  8037.         if (x < y) {                    /* force x to be larger */
  8038.             long t;
  8039.             t = x;
  8040.             x = y;
  8041.             y = t;
  8042.         }
  8043.         x -= y;
  8044.     }
  8045.     if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  8046.     else return((long) 1 << nshift);    /* else gcd is 1 */
  8047. }
  8048.  
  8049. /*
  8050.  * exprp ::= NULL | {+,-,|,...} term exprp
  8051.  *
  8052.  */
  8053. static VOID
  8054. exprp() {
  8055.     while (windex("+-|<>#@",curtok) != NULL) {
  8056.         long oldval;
  8057.         char op;
  8058.         op = curtok;
  8059.         curtok = gettok();              /* skip past operator */
  8060.         oldval = expval;
  8061.         term();
  8062.         switch(op) {
  8063.           case '+' : expval = oldval + expval; break;
  8064.           case '-' : expval = oldval - expval; break;
  8065.           case '|' : expval = oldval | expval; break;
  8066.           case '#' : expval = oldval ^ expval; break;
  8067.           case '@' : expval = gcd(oldval,expval); break;
  8068.           case '<' : expval = oldval << expval; break;
  8069.           case '>' : expval = oldval >> expval; break;
  8070.         }
  8071.     }
  8072. }
  8073.  
  8074. /*
  8075.  * expr ::= term exprp
  8076.  *
  8077.  */
  8078. static VOID
  8079. expr() {
  8080.     term();
  8081.     exprp();
  8082. }
  8083.  
  8084. static long
  8085. xparse() {
  8086.     curtok = gettok();
  8087.     expr();
  8088. #ifdef COMMENT
  8089.     if (curtok == '$') {
  8090.         curtok = gettok();
  8091.         if (curtok != NUMBER) {
  8092.             if (cmdlvl == 0 && !x_ifnum)
  8093.               printf("?Illegal radix\n");
  8094.             xerror = 1;
  8095.             return(0);
  8096.         }
  8097.         curtok = gettok();
  8098.     }
  8099. #endif /* COMMENT */
  8100.     if (curtok != N_EOT) {
  8101.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8102.           printf("?Extra characters after expression\n");
  8103.         xerror = 1;
  8104.     }
  8105.     return(expval);
  8106. }
  8107.  
  8108. char *                                  /* Silent front end for evala() */
  8109. evalx(s) char *s; {
  8110.     char * p;
  8111.     int t;
  8112.     t = x_ifnum;
  8113.     x_ifnum = 1;
  8114.     p = evala(s);
  8115.     x_ifnum = t;
  8116.     return(p);
  8117. }
  8118.  
  8119. char *
  8120. evala(s) char *s; {
  8121.     long v;                             /* Numeric value */
  8122.     if (!s) return("");
  8123.     xerror = 0;                         /* Start out with no error */
  8124.     divbyzero = 0;
  8125.     cp = s;                             /* Make the argument global */
  8126.     v = xparse();                       /* Parse the string */
  8127.     return(xerror ? "" : ckltoa(v));    /* Return empty string on error */
  8128. }
  8129.  
  8130. /*
  8131.  * simplest ::= NUMBER | ( expr )
  8132.  *
  8133.  */
  8134. static VOID
  8135. simplest() {
  8136.     char * p;
  8137.     p = cp;
  8138.     if (curtok == NUMBER)
  8139.       expval = tokval;
  8140.     else if (curtok == '(') {
  8141.         curtok = gettok();              /* skip over paren */
  8142.         expr();
  8143.         if (curtok != ')') {
  8144.             if (cmdlvl == 0 && !x_ifnum && !xerror)
  8145.               printf("?Missing right parenthesis\n");
  8146.             xerror = 1;
  8147.         }
  8148.         debug(F110,"GETTOK SIMPLEST ()",p,0);
  8149.  
  8150.     } else {
  8151.         if (cmdlvl == 0 && !x_ifnum && !xerror)
  8152.           printf("?Operator unexpected\n");
  8153.         xerror = 1;
  8154.     }
  8155.     curtok = gettok();
  8156. }
  8157.  
  8158. /*
  8159.  * simpler ::= simplest | simplest !
  8160.  *
  8161.  */
  8162. static VOID
  8163. simpler() {
  8164.     simplest();
  8165.     if (curtok == '!') {
  8166.         curtok = gettok();
  8167.         expval = fact(expval);
  8168.     }
  8169. }
  8170.  
  8171. /*
  8172.  * simple ::= {-,~,!} simpler | simpler
  8173.  *
  8174.  */
  8175.  
  8176. static VOID
  8177. simple() {
  8178.     if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8179.         int op = curtok;
  8180.         curtok = gettok();              /* skip over - sign */
  8181.         simpler();                      /* parse the factor again */
  8182.         if (op != '+')
  8183.           expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8184.     } else simpler();
  8185. }
  8186.  
  8187. /*  D C L A R R A Y  --  Declare an array  */
  8188. /*
  8189.   Call with:
  8190.    char a = single character designator for the array, e.g. "a".
  8191.    int  n = size of array.
  8192.   Returns:
  8193.    0 or greater on success, having created the requested array with
  8194.      with n+1 elements, 0..n.  If an array of the same name existed
  8195.      previously, it is destroyed.  The new array has all its elements
  8196.      initialized to NULL pointers.
  8197.   -1 on failure (because 'a' out of range or malloc failure).
  8198. */
  8199. int
  8200. #ifdef CK_ANSIC
  8201. dclarray(char a, int n)
  8202. #else
  8203. dclarray(a,n) char a; int n;
  8204. #endif /* CK_ANSIC */
  8205. /* dclarray */ {
  8206.     char c, **p; int i, n2, rc;
  8207.  
  8208.     if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
  8209.     if (a < ARRAYBASE || a > 122)       /* Verify name */
  8210.       return(-1);
  8211.     c = a;
  8212.     a -= ARRAYBASE;                     /* Convert name to number */
  8213.     rc = a;
  8214.     if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
  8215.         if (a_link[a] > -1) {           /* Is it a link? */
  8216.             if (n == 0) {               /* If we're just deleting it */
  8217.                 a_ptr[a] = (char **) NULL; /* clear all the info. */
  8218.                 a_dim[a] = 0;
  8219.                 a_link[a] = -1;
  8220.                 return(0);
  8221.             }                           /* Not deleting */
  8222.             a = a_link[a];              /* Switch to linked-to array */
  8223.         }
  8224.         n2 = a_dim[a];                  /* Real array */
  8225.         for (i = 0; i <= n2; i++) {     /* First delete its elements */
  8226.             if (p[i]) {
  8227.                 free(p[i]);
  8228.                 p[i] = NULL;
  8229.             }
  8230.         }
  8231.         free((char *)a_ptr[a]);         /* Then the element list */
  8232.         if (n == 0) {                   /* If undeclaring this array... */
  8233.             for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8234.                 if (i != a && a_link[i] == a) {     /* Find them */
  8235.                     a_ptr[i] = (char **) NULL;      /* and remove them */
  8236.                     a_dim[i] = 0;
  8237.                     a_link[i] = -1;
  8238.                 }
  8239.             }
  8240.         }
  8241.         a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
  8242.         a_dim[a] = 0;                   /* Set dimension at zero. */
  8243.         a_link[a] = -1;                 /* Unset link word */
  8244.         if (n == 0)
  8245.           return(0);                    /* If dimension 0, just deallocate. */
  8246.     }
  8247.     p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8248.     if (p == NULL) return(-1);          /* Check */
  8249.     a_ptr[a] = p;                       /* Save pointer to member list */
  8250.     a_dim[a] = n;                       /* Save dimension */
  8251.     for (i = 0; i <= n; i++)            /* Initialize members to null */
  8252.       p[i] = NULL;
  8253.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8254.         if (i != a && a_link[i] == a) { /* Find and update them */
  8255.             a_ptr[i] = p;
  8256.             a_dim[i] = n;
  8257.         }
  8258.     }
  8259.     return(rc);
  8260. }
  8261.  
  8262. /*  X A R R A Y  -- Convert array name to array index  */
  8263.  
  8264. int
  8265. xarray(s) char * s; {
  8266.     char buf[8];
  8267.     int x;
  8268.     char c;
  8269.  
  8270.     if (!s) s = "";
  8271.     debug(F110,"xarray",s,0);
  8272.     if (!*s)
  8273.       return(-1);
  8274.     x = strlen(s);
  8275.  
  8276.     buf[0] = NUL;
  8277.     buf[1] = NUL;
  8278.     buf[2] = s[0];
  8279.     buf[3] = (x > 0) ? s[1] : NUL;
  8280.     buf[4] = (x > 1) ? s[2] : NUL;
  8281.     buf[5] = (x > 2) ? s[3] : NUL;
  8282.     buf[6] = NUL;
  8283.     s = buf+2;
  8284.     if (*s == '&') {
  8285.         buf[1] = CMDQ;
  8286.         s--;
  8287.     } else if (*s != CMDQ) {
  8288.         buf[0] = CMDQ;
  8289.         buf[1] = '&';
  8290.         s = buf;
  8291.     }
  8292.     c = *(s+2);
  8293.     if (isupper(c))
  8294.       c = tolower(c);
  8295.     if (c == '@')
  8296.       c = 96;
  8297.     x = (int)c - ARRAYBASE;
  8298.     if (*(s+3) == '[')
  8299.       *(s+3) = NUL;
  8300.     return((x < 0 || x > 'z' - ARRAYBASE || *(s+3)) ? -1 : x);
  8301. }
  8302.  
  8303. /*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */
  8304.  
  8305. /*
  8306.   Call with s = array reference, plus two pointers to ints.
  8307.   Returns -1 on error, or array index, with the two ints set as follows:
  8308.    \&a[]     -1, -1
  8309.    \&a[3]     3, -1
  8310.    \&a[3:17]  3, 17
  8311.   The array need not be declared -- this routine is just for parsing.
  8312. */
  8313. int
  8314. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8315.     int i, x, y, range[2];
  8316.     char buf[256], * p, * q;
  8317.     char * tmp = NULL;
  8318.  
  8319.     *lo = -1;                           /* Default bounds */
  8320.     *hi = -1;
  8321.  
  8322.     if (!s) s = "";                     /* Defense de null args */
  8323.     if (!*s)
  8324.       return(-1);
  8325.  
  8326.     x = xarray(s);                      /* Check basic structure */
  8327.     debug(F111,"arraybounds xarray",s,x);
  8328.  
  8329.     if (x < 0)                          /* Not OK, fail. */
  8330.       return(-1);
  8331.     range[0] = -1;                      /* It's OK -- get contents */
  8332.     range[1] = -1;                      /* of subscript brackets */
  8333.     makestr(&tmp,s);                    /* Make a pokeable copy */
  8334.     s = tmp;
  8335.     p = s;
  8336.     for (p = s, q = NULL; *p; p++) {    /* First find the brackets */
  8337.         if (*p == '[') {
  8338.             q = p+1;
  8339.         } else if (*p == ']')
  8340.           break;
  8341.     }
  8342.     if (q && *p == ']') {               /* If we have brackets... */
  8343.         int quitnow = 0;
  8344.         for (i = 0; i < 2 && !quitnow; i++) { /* Loop thru their contents */
  8345.             for (p = q; *p; p++) {
  8346.                 if ((i == 0 && *p == ':') || *p == ']') {
  8347.                     if (*p == ']')
  8348.                       quitnow = 1;
  8349.                     *p = NUL;
  8350.                     if (*q) {           /* We have something */
  8351.                         y = 255;        /* Expand variables, etc. */
  8352.                         s = buf;
  8353.                         zzstring(q,&s,&y);
  8354.                         s = evalx(buf); /* Evaluate it arithmetically */
  8355.                         if (s) if (*s)
  8356.                           ckstrncpy(buf,s,256);
  8357.                         if (!chknum(buf)) { /* Did we get a number? */
  8358.                             makestr(&tmp,NULL); /* No, fail. */
  8359.                             return(-1);
  8360.                         }
  8361.                         q = (i == 0) ? p+1 : NULL; /* Point to next if any */
  8362.                         range[i] = atoi(buf); /* Set this one */
  8363.                     }
  8364.                     break;
  8365.                 }
  8366.             }
  8367.         }
  8368.     }
  8369.     makestr(&tmp,NULL);                 /* Free temporary poked string */
  8370.     *lo = range[0];                     /* Return what we got */
  8371.     *hi = range[1];
  8372.     debug(F101,"arraybounds lo","",*lo);
  8373.     debug(F101,"arraybounds hi","",*hi);
  8374.     return(x);
  8375. }
  8376.  
  8377. /*  A R R A Y N A M  --  Parse an array name  */
  8378.  
  8379. /*
  8380.   Call with pointer to string that starts with the array reference.
  8381.   String may begin with either \& or just &.
  8382.   On success,
  8383.     Returns letter ID (always lowercase) in argument c,
  8384.       which can also be accent grave (` = 96; '@' is converted to grave);
  8385.     Dimension or subscript in argument n;
  8386.     IMPORTANT: These arguments must be provided by the caller as addresses
  8387.     of ints (not chars), for example:
  8388.       char *s; int x, y;
  8389.       arraynam(s,&x,&y);
  8390.   On failure, returns a negative number, with args n and c set to zero.
  8391. */
  8392. int
  8393. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8394.     int i, y, pp, len;
  8395.     char x;
  8396.     char *s, *p, *sx, *vnp;
  8397.     /* On stack to allow for recursive calls... */
  8398.     char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
  8399.     char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
  8400.     char sxbuf[16];                     /* Evaluated subscript */
  8401.  
  8402.     *c = *n = 0;                        /* Initialize return values */
  8403.     len = strlen(ss);
  8404.     for (pp = 0,i = 0; i < len; i++) {          /* Check length */
  8405.         if (ss[i] == '[') {
  8406.             pp++;
  8407.         } else if (ss[i] == ']') {
  8408.             if (--pp == 0)
  8409.               break;
  8410.         }
  8411.     }
  8412.     if (i > ARRAYREFLEN) {
  8413.         printf("?Array reference too long - %s\n",ss);
  8414.         return(-9);
  8415.     }
  8416.     ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8417.     vnp = vnbuf;
  8418.     if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8419.     if (*vnp != '&') {
  8420.         printf("?Not an array - %s\n",vnbuf);
  8421.         return(-9);
  8422.     }
  8423.     x = *(vnp + 1);                     /* Fold case of array name */
  8424.  
  8425.     /* We don't use isupper & tolower here on purpose because these */
  8426.     /* would produce undesired effects with accented letters. */
  8427.     if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
  8428.     if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8429.         if (msgflg) {
  8430.             printf("?Invalid format for array name - %s\n",vnbuf);
  8431.             return(-9);
  8432.         } else
  8433.           return(-2);
  8434.     }
  8435.     *c = x;                             /* Return the array name */
  8436.     s = vnp+3;                          /* Get dimension */
  8437.     p = ssbuf;
  8438.     pp = 1;                             /* Bracket counter */
  8439.     for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8440.         if (*s == '[') pp++;
  8441.         if (*s == ']' && --pp == 0) break;
  8442.         *p++ = *s++;
  8443.     }
  8444.     if (*s != ']') {
  8445.         printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8446.         return(-9);
  8447.     }
  8448.     p--;                                /* Trim whitespace from end */
  8449.     while (*p == SP || *p == HT)
  8450.       p--;
  8451.     p++;
  8452.     *p = NUL;                           /* Terminate subscript with null */
  8453.     p = ssbuf;                          /* Point to beginning of subscript */
  8454.     while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
  8455.       p++;
  8456.     sx = sxbuf;                         /* Where to put expanded subscript */
  8457.     y = 16;
  8458.     zzstring(p,&sx,&y);                 /* Convert variables, etc. */
  8459.     sx = sxbuf;
  8460.     while (*sx == SP) sx++;
  8461.     debug(F110,"arraynam sx","",sx);
  8462.     if (!*sx) {                         /* Empty brackets... */
  8463.         *n = -17;                       /* (Secret code :-) */
  8464.         return(-2);
  8465.     }
  8466.     p = evala(sx);                      /* Run it thru \fneval()... */
  8467.     if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8468.  
  8469.     if (!chknum(sxbuf)) {               /* Make sure it's all digits */
  8470.         if (msgflg) {
  8471.             printf("?Array dimension or subscript missing or not numeric\n");
  8472.             return(-9);
  8473.         } else
  8474.           return(-2);
  8475.     }
  8476.     if ((y = atoi(sxbuf)) < 0) {
  8477.         if (cmflgs == 0) printf("\n");
  8478.         if (msgflg) {
  8479.             printf("?Array dimension or subscript not positive or zero\n");
  8480.             return(-9);
  8481.         } else
  8482.           return(-2);
  8483.     }
  8484.     *n = y;                             /* Return the subscript or dimension */
  8485.     return(0);
  8486. }
  8487.  
  8488. int
  8489. chkarray(a,i) int a, i; {               /* Check if array is declared */
  8490.     int x;                              /* and if subscript is in range */
  8491.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8492.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8493. #ifdef COMMENT
  8494.     if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
  8495.       return(0);
  8496. #endif /* COMMENT */
  8497.     if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
  8498.       return(-2);
  8499.     if (a_ptr[x] == NULL) return(-1);   /* Not declared */
  8500.     if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
  8501.     return(a_dim[x]);                   /* All ok, return dimension */
  8502. }
  8503.  
  8504. #ifdef COMMENT                          /* This isn't used. */
  8505. char *
  8506. arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
  8507.     int x; char **p;                    /* (possibly NULL) */
  8508.     if (a == 64) a = 96;                /* Convert atsign to grave accent */
  8509.     x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
  8510.     if (x < 0 || x > 27) return(NULL);  /* Not in range */
  8511.     if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8512.       return(NULL);
  8513.     if (i > a_dim[x])                   /* Subscript out of range. */
  8514.       return(NULL);
  8515.     return(p[i]);                       /* All ok, return pointer to value. */
  8516. }
  8517. #endif /* COMMENT */
  8518.  
  8519. /*
  8520.   pusharray() is called when an array name is included in a LOCAL statement.
  8521.   It moves the pointers from the global definition to the stack, and removes
  8522.   the global definition.  Later, if the same array is declared in the local
  8523.   context, it occupies the global definition in the normal way.  But when
  8524.   popclvl() is called, it replaces the global definition with the one saved
  8525.   here.  The "secret code" is used to indicate to popclv() that it should
  8526.   remove the global array when popping through this level -- otherwise if a
  8527.   local array were declared that had no counterpart at any higher level, it
  8528.   would never be deleted.  This allows Algol-like inheritance to work both
  8529.   on the way down and on the way back up.
  8530. */
  8531. int
  8532. pusharray(x,z) int x, z; {
  8533.     int y;
  8534.     debug(F000,"pusharray x","",x);
  8535.     debug(F101,"pusharray z","",z);
  8536.     y = chkarray(x,z);
  8537.     debug(F101,"pusharray y","",y);
  8538.     x -= ARRAYBASE;                     /* Convert name letter to index. */
  8539.     if (x < 0 || x > 27)
  8540.       return(-1);
  8541.     if (y < 0) {
  8542.         aa_ptr[cmdlvl][x] = (char **) NULL;
  8543.         aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
  8544.     } else {
  8545.         aa_ptr[cmdlvl][x] = a_ptr[x];
  8546.         aa_dim[cmdlvl][x] = y;
  8547.     }
  8548.     a_ptr[x] = (char **) NULL;
  8549.     a_dim[x] = 0;
  8550.     return(0);
  8551. }
  8552.  
  8553. /*  P A R S E V A R  --  Parse a variable name or array reference.  */
  8554. /*
  8555.  Call with:
  8556.    s  = pointer to candidate variable name or array reference.
  8557.    *c = address of integer in which to return variable ID.
  8558.    *i = address of integer in which to return array subscript.
  8559.  Returns:
  8560.    -2:  syntax error in variable name or array reference.
  8561.     1:  successful parse of a simple variable, with ID in c.
  8562.     2:  successful parse of an array reference, w/ID in c and subscript in i.
  8563. */
  8564. int
  8565. parsevar(s,c,i) char *s; int *c, *i; {
  8566.     char *p;
  8567.     int x,y,z;
  8568.  
  8569.     p = s;
  8570.     if (*s == CMDQ) s++;                /* Point after backslash */
  8571.  
  8572.     if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
  8573.         printf("?Not a variable name - %s\n",p);
  8574.         return(-9);
  8575.     }
  8576.     if ((int)strlen(s) < 2) {
  8577.         printf("?Incomplete variable name - %s\n",p);
  8578.         return(-9);
  8579.     }
  8580.     if (*s == '%' && *(s+2) != '\0') {
  8581.         printf("?Only one character after '%%' in variable name, please\n");
  8582.         return(-9);
  8583.     }
  8584.     if (*s == '&' && *(s+2) != '[') {
  8585.         printf("?Array subscript expected - %s\n",p);
  8586.         return(-9);
  8587.     }
  8588.     if (*s == '%') {                    /* Simple variable. */
  8589.         y = *(s+1);                     /* Get variable ID letter/char */
  8590.         if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  8591.         *c = y;                         /* Set the return values. */
  8592.         *i = -1;                        /* No array subscript. */
  8593.         return(1);                      /* Return 1 = simple variable */
  8594.     }
  8595.     if (*s == '&') {                    /* Array reference. */
  8596.         y = arraynam(s,&x,&z);          /* Go parse it. */
  8597.         debug(F101,"parsevar arraynam","",y);
  8598.         if ((y) < 0) {
  8599.             if (y == -2)
  8600.               return(pusharray(x,z));
  8601.             if (y != -9)
  8602.               printf("?Invalid array reference - %s\n",p);
  8603.             return(-9);
  8604.         }
  8605.         if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
  8606.             printf("?Array not declared or subscript out of range\n");
  8607.             return(-9);
  8608.         }
  8609.         *c = x;                         /* Return array letter */
  8610.         *i = z;                         /* and subscript. */
  8611.         return(2);
  8612.     }
  8613.     return(-2);                         /* None of the above. */
  8614. }
  8615.  
  8616.  
  8617. #define VALN 32
  8618.  
  8619. /* Get the numeric value of a variable */
  8620. /*
  8621.   Call with pointer to variable name, pointer to int for return value.
  8622.   Returns:
  8623.     0 on success with second arg containing the value.
  8624.    -1 on failure (bad variable syntax, variable not defined or not numeric).
  8625. */
  8626. int
  8627. varval(s,v) char *s; int *v; {
  8628.     char valbuf[VALN+1];                /* s is pointer to variable name */
  8629.     char name[256];
  8630.     char *p;
  8631.     int y;
  8632.  
  8633.     if (*s != CMDQ) {                   /* Handle macro names too */
  8634.         ckmakmsg(name,256,"\\m(",s,")",NULL);
  8635.         s = name;
  8636.     }
  8637.     p = valbuf;                         /* Expand variable into valbuf. */
  8638.     y = VALN;
  8639.     if (zzstring(s,&p,&y) < 0) return(-1);
  8640.     p = valbuf;                         /* Make sure value is numeric  */
  8641.     if (!*p) {                          /* Be nice -- let an undefined */
  8642.         valbuf[0] = '0';                /* variable be treated as 0.   */
  8643.         valbuf[1] = NUL;
  8644.     }
  8645.     if (chknum(p)) {                    /* Convert numeric string to int */
  8646.         *v = atoi(p);                   /* OK */
  8647.     } else {                            /* Not OK */
  8648.         p = evala(p);                   /* Maybe it's an expression */
  8649.         if (!chknum(p))                 /* Did it evaluate? */
  8650.           return(-1);                   /* No, failure. */
  8651.         else                            /* Yes, */
  8652.           *v = atoi(p);                 /* success */
  8653.     }
  8654.     return(0);
  8655. }
  8656.  
  8657. /* Increment or decrement a variable */
  8658. /* Returns -1 on failure, 0 on success */
  8659.  
  8660. int
  8661. incvar(s,x,z) char *s; int x; int z; {  /* Increment a numeric variable */
  8662.     int n;                              /* s is pointer to variable name */
  8663.                                         /* x is amount to increment by */
  8664.                                         /* z != 0 means add */
  8665.                                         /* z = 0 means subtract */
  8666.     if (varval(s,&n) < 0)               /* Convert numeric string to int */
  8667.       return(-1);
  8668.     if (z)                              /* Increment it by the given amount */
  8669.       n += x;
  8670.     else                                /* or decrement as requested. */
  8671.       n -= x;
  8672.     addmac(s,ckitoa(n));                /* Replace old variable */
  8673.     return(0);
  8674. }
  8675.  
  8676. /* D O D O  --  Do a macro */
  8677.  
  8678. /*
  8679.   Call with x = macro table index, s = pointer to arguments.
  8680.   Returns 0 on failure, 1 on success.
  8681. */
  8682.  
  8683. int
  8684. dodo(x,s,flags) int x; char *s; int flags; {
  8685.     int y;
  8686.     extern int tra_asg, tra_cmd; int tra_tmp;
  8687. #ifndef NOLOCAL
  8688. #ifdef OS2
  8689.     extern int term_io;
  8690.     int term_io_sav = term_io;
  8691. #endif /* OS2 */
  8692. #endif /* NOLOCAL */
  8693.  
  8694.     if (x < 0)                          /* It can happen! */
  8695.       return(-1);
  8696.  
  8697.     tra_tmp = tra_asg;
  8698.  
  8699.     if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
  8700.         debug(F101,"dodo maclvl too deep","",maclvl);
  8701.         --maclvl;
  8702.         printf("Macros nested too deeply\n");
  8703.         return(0);
  8704.     }
  8705.     macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
  8706.     macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */
  8707.  
  8708. #ifdef COMMENT
  8709.     makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
  8710. #endif /* COMMENT */
  8711.  
  8712.     cmdlvl++;                           /* Entering a new command level */
  8713.     if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
  8714.         debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  8715.         cmdlvl--;
  8716.         printf("?TAKE files and DO commands nested too deeply\n");
  8717.         return(0);
  8718.     }
  8719. #ifdef DEBUG
  8720.     if (deblog) {
  8721.         debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  8722.         debug(F010,"CMD ->",s,0);
  8723.     }
  8724. #endif /* DEBUG */
  8725.  
  8726. #ifdef VMS
  8727.     conres();                           /* So Ctrl-C, etc, will work. */
  8728. #endif /* VMS */
  8729. #ifndef NOLOCAL
  8730. #ifdef OS2
  8731.     term_io = 0;                        /* Disable terminal emulator I/O */
  8732. #endif /* OS2 */
  8733. #endif /* NOLOCAL */
  8734.     ifcmd[cmdlvl] = 0;
  8735.     iftest[cmdlvl] = 0;
  8736.     count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
  8737.     intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
  8738.     inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
  8739.     takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
  8740.     merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
  8741.     xquiet[cmdlvl] = quiet;
  8742.     xcmdsrc = CMD_MD;
  8743.     cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
  8744.     cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
  8745.     cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  8746.  
  8747.     /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  8748.  
  8749.     if (!(flags & CF_IMAC) && mrval[maclvl]) {
  8750.         free(mrval[maclvl]);
  8751.         mrval[maclvl] = NULL;
  8752.     }
  8753.  
  8754.     /* Clear old %0..%9 arguments */
  8755.  
  8756.     addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
  8757.     makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  8758.     varnam[0] = '%';
  8759.     varnam[2] = '\0';
  8760.     tra_asg = 0;
  8761.     for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
  8762.         if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
  8763.             varnam[1] = (char) (y + '0'); /* we have to... */
  8764.             delmac(varnam,0);
  8765.         }
  8766.     }
  8767.     tra_asg = tra_tmp;
  8768.  
  8769. /* Assign the new args one word per arg, allowing braces to group words */
  8770.  
  8771.     xwords(s,MAXARGLIST,NULL,0);
  8772.  
  8773. #ifndef NOLOCAL
  8774. #ifdef OS2
  8775.     term_io = term_io_sav;
  8776. #endif /* OS2 */
  8777. #endif /* NOLOCAL */
  8778.     if (tra_cmd)
  8779.       printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  8780.     return(1);
  8781. }
  8782.  
  8783. /* Insert "literal" quote around each comma-separated command to prevent */
  8784. /* its premature expansion.  Only do this if object command is surrounded */
  8785. /* by braces. */
  8786.  
  8787. static char* flit = "\\flit(";
  8788.  
  8789. int
  8790. litcmd(src,dest,n) char **src, **dest; int n; {
  8791.     int bc = 0, pp = 0;
  8792.     char c, *s, *lp, *ss;
  8793.  
  8794.     s = *src;
  8795.     lp = *dest;
  8796.  
  8797.     debug(F010,"litcmd",s,0);
  8798.  
  8799.     while (*s == SP) s++;               /* Strip extra leading spaces */
  8800.  
  8801.     if (*s == '{') {                    /* Starts with brace */
  8802.         pp = 0;                         /* Paren counter */
  8803.         bc = 1;                         /* Count leading brace */
  8804.         *lp++ = *s++;                   /* Copy it */
  8805.         if (--n < 1) return(-1);        /* Check space */
  8806.         while (*s == SP) s++;           /* Strip interior leading spaces */
  8807.         ss = flit;                      /* Point to "\flit(" */
  8808.         while ((*lp++ = *ss++))         /* Copy it */
  8809.           if (--n < 1)                  /* and check space */
  8810.             return(-1);
  8811.         lp--;                           /* Back up over null */
  8812.  
  8813.         while (*s) {                    /* Go thru rest of text */
  8814.             c = *s;
  8815.             if (c == '{') bc++;         /* Count brackets */
  8816.             if (c == '(') pp++;         /* and parens */
  8817.             if (c == ')') {             /* Right parenthesis. */
  8818.                 pp--;                   /* Count it. */
  8819.                 if (pp < 0) {           /* An unbalanced right paren... */
  8820. #ifdef COMMENT
  8821. /*
  8822.   The problem here is that "\{" appears to be a quoted brace and therefore
  8823.   isn't counted; then the "}" matches an earlier opening brace, causing
  8824.   (e.g.) truncation of macros by getncm().
  8825. */
  8826.                     if (n < 5)          /* Out of space in dest buffer? */
  8827.                       return(-1);       /* If so, give up. */
  8828.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  8829.                     *lp++ = '}';        /* premature termination of */
  8830.                     *lp++ = '4';        /* \flit(...) */
  8831.                     *lp++ = '1';
  8832.                     *lp++ = '}';
  8833.                     n -= 5;
  8834. #else
  8835. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  8836.                     if (n < 4)          /* Out of space in dest buffer? */
  8837.                       return(-1);       /* If so, give up. */
  8838.                     *lp++ = CMDQ;       /* Must be quoted to prevent */
  8839.                     *lp++ = '0';        /* premature termination of */
  8840.                     *lp++ = '4';        /* \flit(...) */
  8841.                     *lp++ = '1';
  8842.                     n -= 4;
  8843. #endif /* COMMENT */
  8844.                     pp++;               /* Uncount it. */
  8845.                     s++;
  8846.                     continue;
  8847.                 }
  8848.             }
  8849.             if (c == '}') {             /* Closing brace. */
  8850.                 if (--bc == 0) {        /* Final one? */
  8851.                     *lp++ = ')';        /* Add closing paren for "\flit()" */
  8852.                     if (--n < 1) return(-1);
  8853.                     *lp++ = c;
  8854.                     if (--n < 1) return(-1);
  8855.                     s++;
  8856.                     break;
  8857.                 }
  8858.             }
  8859.             *lp++ = c;                  /* General case */
  8860.             if (--n < 1) return(-1);
  8861.             s++;
  8862.         }
  8863.         *lp = NUL;
  8864.     } else {                            /* No brackets around, */
  8865.         while ((*lp++ = *s++))          /* just copy. */
  8866.           if (--n < 1)
  8867.             return(-1);
  8868.         lp--;
  8869.     }
  8870.     *src = s;                           /* Return updated source */
  8871.     *dest = lp;                         /* and destination pointers */
  8872.     if (bc)                             /* Fail if braces unbalanced */
  8873.       return(-1);
  8874.     else                                /* Otherwise succeed. */
  8875.       return(0);
  8876. }
  8877. #endif /* NOSPL */
  8878.  
  8879. /* Functions moved here from ckuusr.c to even out the module sizes... */
  8880.  
  8881. /*
  8882.   Breaks up string s -- IN PLACE! -- into a list of up to max words.
  8883.   Pointers to each word go into the array list[].
  8884.   max is the maximum number of words (pointers).
  8885.   If list is NULL, then they are added to the macro table.
  8886.   flag = 0 means the last field is to be one word, like all the other fields,
  8887.          so anything after it is discarded.
  8888.   flag = 1 means the last field extends to the end of the string, even if
  8889.          there are lots of words left, so the last field contains the
  8890.          remainder of the string.
  8891. */
  8892. VOID
  8893. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  8894.     char *p;
  8895.     int b, i, k, q, y, z;
  8896. #ifndef NOSPL
  8897.     int macro;
  8898.     macro = (list == NULL);
  8899.     debug(F010,"xwords",s,0);
  8900. #endif /* NOSPL */
  8901.  
  8902. #ifdef XWORDSDEBUG
  8903.     printf("XWORDS string=%s\n",s);
  8904.     printf("XWORDS max=%d\n",max);
  8905. #endif /* XWORDSDEBUG */
  8906.     p = s;                              /* Pointer to beginning of string */
  8907.     q = 0;                              /* Flag for doublequote removal */
  8908.     b = 0;                              /* Flag for outer brace removal */
  8909.     k = 0;                              /* Flag for in-word */
  8910.     y = 0;                              /* Brace nesting level */
  8911.     z = 0;                              /* "Word" counter, 0 thru max */
  8912.  
  8913.     if (list)
  8914.       for (i = 0; i <= max; i++)        /* Initialize pointers */
  8915.         list[i] = NULL;
  8916.  
  8917.     if (flag) max--;
  8918.  
  8919.     while (1) {                         /* Go thru word list */
  8920.         if (!s || (*s == '\0')) {       /* No more characters? */
  8921.             if (k != 0) {               /* Was I in a word? */
  8922.                 if (z == max) break;    /* Yes, only go up to max. */
  8923.                 z++;                    /* Count this word. */
  8924. #ifdef XWORDSDEBUG
  8925.                 printf("1 z++ = %d\n", z);
  8926. #endif /* XWORDSDEBUG */
  8927. #ifndef NOSPL
  8928.                 if (macro) {            /* Doing macro args */
  8929.                     if (z < 10) {
  8930.                         varnam[1] = (char) (z + '0'); /* Assign last arg */
  8931.                         addmac(varnam,p);
  8932.                     }
  8933.                     if (z <= max) {
  8934. #ifdef COMMENT
  8935.                         if (maclvl < 0)
  8936.                           addmac(varnam,p);
  8937.                         else
  8938. #endif /* COMMENT */
  8939.                           makestr(&(m_xarg[maclvl][z]),p);
  8940.                     }
  8941.                 } else {                /* Not doing macro args */
  8942. #endif /* NOSPL */
  8943.                     list[z] = p;        /* Assign pointer. */
  8944. #ifdef XWORDSDEBUG
  8945.                     printf("[1]LIST[%d]=\"%s\"\n",z,list[z]);
  8946. #endif /* XWORDSDEBUG */
  8947. #ifndef NOSPL
  8948.                 }
  8949. #endif /* NOSPL */
  8950.                 break;                  /* And get out. */
  8951.             } else break;               /* Was not in a word */
  8952.         }
  8953.         if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  8954.             s++;
  8955.             continue;
  8956.         } else if (q == 0 && *s == '{') { /* An opening brace */
  8957.             if (k == 0 && y == 0) {     /* If leading brace */
  8958.                 p = s+1;                /* point past it */
  8959.                 b = 1;                  /* and flag that we did this */
  8960.             }
  8961.             k = 1;                      /* Flag that we're in a word */
  8962.             y++;                        /* Count the brace. */
  8963.         } else if (q == 0 && *s == '}') { /* A closing brace. */
  8964.             y--;                        /* Count it. */
  8965.             if (y <= 0 && b != 0) {     /* If it matches the leading brace */
  8966.                 char c;
  8967.                 c = *(s+1);
  8968.                 if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  8969.                     *s = SP;            /* change it to a space */
  8970.                     b = 0;              /* and we're not in braces any more */
  8971.                 }
  8972.             }
  8973. #ifdef DOUBLEQUOTING
  8974.         /* Opening doublequote */
  8975.         } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  8976.             y++;
  8977.             p = s+1;                    /* point past it */
  8978.             q = 1;                      /* and flag that we did this */
  8979.             k = 1;                      /* Flag that we're in a word */
  8980.         /* Closing double quote */
  8981.         } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  8982.             char c;
  8983.             c = *(s+1);
  8984.             if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  8985.                 y--;
  8986.                 *s = SP;                /* change it to a space */
  8987.                 q = 0;                  /* and we're not in quotes any more */
  8988.             }
  8989. #endif /* DOUBLEQUOTING */
  8990.  
  8991.         } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  8992.             if (k == 0) {               /* If we weren't in a word before, */
  8993.                 p = s;                  /* Mark the beginning */
  8994.                 if (flag && z == max) { /* Want last word to be remainder? */
  8995.                     z++;
  8996. #ifdef XWORDSDEBUG
  8997.                     printf("1 z++ = %d\n", z);
  8998. #endif /* XWORDSDEBUG */
  8999.                     list[z] = p;        /* Yes, point to it */
  9000. #ifdef XWORDSDEBUG
  9001.                     printf("[4]LIST[%d]=\"%s\"\n",z,list[z]);
  9002. #endif /* XWORDSDEBUG */
  9003.                     break;              /* and quit */
  9004.                 }
  9005.                 k = 1;                  /* Set in-word flag */
  9006.             }
  9007.         }
  9008.         /* If we're not inside a braced quantity, and we are in a word, and */
  9009.         /* we have hit whitespace, then we have a word. */
  9010.         if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9011.             if (!flag || z < max)       /* if we don't want to keep rest */
  9012.               *s = '\0';                /* terminate the arg with null */
  9013.             k = 0;                      /* say we're not in a word any more */
  9014.             y = 0;                      /* start braces off clean again */
  9015.             if (z == max) break;        /* Only go up to max. */
  9016.             z++;                        /* count this arg */
  9017. #ifdef XWORDSDEBUG
  9018.             printf("1 z++ = %d\n", z);
  9019. #endif /* XWORDSDEBUG */
  9020.  
  9021. #ifndef NOSPL
  9022.             if (macro) {
  9023.                 if (z < 10) {
  9024.                     varnam[1] = (char) (z + '0'); /* compute its name */
  9025.                     addmac(varnam,p);   /* add it to the macro table */
  9026.                 }
  9027.                 if (z <= max) {
  9028. #ifdef COMMENT
  9029.                     if (maclvl < 0)
  9030.                       addmac(varnam,p);
  9031.                     else
  9032. #endif /* COMMENT */
  9033.                       makestr(&(m_xarg[maclvl][z]),p);
  9034.                 }
  9035.             } else {
  9036. #endif /* NOSPL */
  9037.                 list[z] = p;
  9038. #ifdef XWORDSDEBUG
  9039.                 printf("[2]LIST[%d]=\"%s\"\n",z,list[z]);
  9040. #endif /* XWORDSDEBUG */
  9041. #ifndef NOSPL
  9042.             }
  9043. #endif /* NOSPL */
  9044.             p = s+1;
  9045.         }
  9046.         s++;                            /* Point past this character */
  9047.     }
  9048.     if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
  9049.         z++;
  9050. #ifndef NOSPL
  9051.         if (macro) {
  9052.             if (z < 10) {
  9053.                 varnam[1] = z + '0';    /* compute its name */
  9054.                 addmac(varnam,p);       /* Add rest of line to last arg */
  9055.             }
  9056.             if (z <= max) {
  9057. #ifdef COMMENT
  9058.                 if (maclvl < 0)
  9059.                   addmac(varnam,p);
  9060.                 else
  9061. #endif /* COMMENT */
  9062.                   makestr(&(m_xarg[maclvl][z]),p);
  9063.             }
  9064.         } else {
  9065. #endif /* NOSPL */
  9066.             list[z] = p;
  9067. #ifdef XWORDSDEBUG
  9068.             printf("[3]LIST[%d]=\"%s\"\n",z,list[z]);
  9069. #endif /* XWORDSDEBUG */
  9070. #ifndef NOSPL
  9071.         }
  9072. #endif /* NOSPL */
  9073.     }
  9074. #ifndef NOSPL
  9075.     if (macro) {                        /* Macro */
  9076.         if (maclvl < 0) {
  9077.             a_dim[0] = z;               /* Array dimension is one less */
  9078.             topargc = z + 1;            /* than \v(argc) */
  9079.         } else {
  9080.             macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
  9081.             n_xarg[maclvl] = z + 1;     /* This is the actual number */
  9082.             a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
  9083.             a_dim[0] = z;               /* And give it this dimension */
  9084.         }
  9085.     }
  9086. #endif /* NOSPL */
  9087.     return;
  9088. }
  9089.  
  9090. #ifndef NOSPL
  9091.  
  9092. /*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */
  9093.  
  9094. /*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9095.  
  9096. int
  9097. doshift(n) int n; {                     /* n = shift count */
  9098.     int i, top, level;
  9099.     char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
  9100.     char * sx = tmpbuf;
  9101.     int nx = TMPBUFSIZ;
  9102.  
  9103.     debug(F101,"SHIFT count","",n);
  9104.     debug(F101,"SHIFT topargc","",topargc);
  9105.  
  9106.     if (n < 1)                          /* Stay in range */
  9107.       return(n == 0 ? 1 : 0);
  9108.  
  9109.     level = maclvl;
  9110.     top = (level < 0) ? topargc : macargc[level];
  9111.  
  9112.     if (n >= top)
  9113.       n = top - 1;
  9114.  
  9115. #ifdef DEBUG
  9116.     if (deblog) {
  9117.         debug(F101,"SHIFT count 2","",n);
  9118.         debug(F101,"SHIFT level","",level);
  9119.         if (level > -1)
  9120.           debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9121.     }
  9122. #endif /* DEBUG */
  9123.  
  9124.     buf[0] = '\\';                      /* Initialize name template */
  9125.     buf[1] = '%';
  9126.     buf[2] = NUL;
  9127.     buf[3] = NUL;
  9128.  
  9129.     for (i = 1; i <= n; i++) {          /* Free shifted-over args */
  9130.         if (level < 0) {
  9131.             makestr(&(toparg[i]),NULL);
  9132.         } else {
  9133.             makestr(&(m_xarg[level][i]),NULL);
  9134.         }
  9135.         if (i < 10) {                   /* Is this necessary? */
  9136.             buf[2] = (char)(i+'0');
  9137.             delmac(buf,0);
  9138.         }
  9139.     }
  9140.     for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
  9141.         if (level < 0) {
  9142. #ifdef COMMENT
  9143.             toparg[i] = toparg[i+n];    /* Full vector */
  9144. #else
  9145.             makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9146. #endif /* COMMENT */
  9147.             if (i < 10)                 /* Scalars... */
  9148.               makestr(&(g_var[i+'0']),toparg[i+n]);
  9149.         } else {
  9150. #ifdef COMMENT
  9151.             m_xarg[level][i] = m_xarg[level][i+n];
  9152. #else
  9153.             makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9154. #endif /* COMMENT */
  9155.             if (i < 10) {
  9156.                 buf[2] = (char)(i+'0');
  9157.                 debug(F010,"SHIFT buf",buf,0);
  9158.                 addmac(buf,m_xarg[level][i+n]);
  9159.             }
  9160.         }
  9161.     }
  9162.     for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
  9163.         if (level < 0) {
  9164. #ifdef COMMENT
  9165.             toparg[i] = NULL;
  9166. #else
  9167.             makestr(&(toparg[i]),NULL);
  9168. #endif /* COMMENt */
  9169.             if (i < 10)
  9170.               makestr(&(g_var[i+'0']),NULL);
  9171.         } else {
  9172. #ifdef COMMENT
  9173.             m_xarg[level][i] = NULL;
  9174. #else
  9175.             makestr(&(m_xarg[level][i]),NULL);
  9176. #endif /* COMMENt */
  9177.             if (i < 10) {
  9178.                 buf[2] = (char)(i+'0');
  9179.                 delmac(buf,0);
  9180.             }
  9181.         }
  9182.     }
  9183.     if (level > -1) {                   /* Macro args */
  9184.         macargc[level] -= n;            /* Adjust count */
  9185.         n_xarg[maclvl] = macargc[level]; /* Here too */
  9186.         a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
  9187.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9188. #ifdef COMMENT
  9189.         makestr(&(m_line[level]),tmpbuf);
  9190. #endif /* COMMENT */
  9191.     } else {                            /* Ditto for top level */
  9192.         topargc -= n;
  9193.         a_dim[0] = topargc - 1;
  9194.         zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9195. #ifdef COMMENT
  9196.         makestr(&topline,tmpbuf);
  9197. #endif /* COMMENT */
  9198.     }
  9199.     return(1);
  9200. }
  9201. #endif /* NOSPL */
  9202.  
  9203. int
  9204. docd(cx) int cx; {                      /* Do the CD command */
  9205.     int x;
  9206.     extern int server, srvcdmsg, cdactive;
  9207.     extern char * cdmsgfile[], * ckcdpath;
  9208.     char *s, *p;
  9209. #ifdef MAC
  9210.     char temp[34];
  9211. #endif /* MAC */
  9212. #ifdef IKSDCONF
  9213. extern int iksdcf;
  9214. #endif /* IKSDCONF */
  9215.  
  9216. #ifndef NOFRILLS
  9217.     if (cx == XXBACK) {
  9218.         if ((x = cmcfm()) < 0)
  9219.         cwdf = 1;
  9220.         if (prevdir) {
  9221.             s = zgtdir();
  9222.             if (!zchdir(prevdir)) {
  9223.                 cwdf = 0;
  9224.                 perror(s);
  9225.             } else {
  9226.                 makestr(&prevdir,s);
  9227.             }
  9228.         }
  9229.         return(cwdf);
  9230.     }
  9231. #endif /* NOFRILLS */
  9232.  
  9233.     if (cx == XXCDUP) {
  9234. #ifdef VMS
  9235.         s = "[-]";
  9236. #else
  9237. #ifdef datageneral
  9238.         s = "^";
  9239. #else
  9240.         s = "..";
  9241. #endif /* datageneral */
  9242. #endif /* VMS */
  9243.         ckstrncpy(line,s,LINBUFSIZ);
  9244.         goto gocd;
  9245.     }
  9246.  
  9247.     cdactive = 1;
  9248. #ifdef GEMDOS
  9249.     if ((x = cmdir("Name of local directory, or carriage return",
  9250.                    zhome(),
  9251.                    &s,
  9252.                    NULL
  9253.                    )
  9254.          ) < 0 )
  9255.       return(x);
  9256. #else
  9257. #ifdef OS2
  9258.     if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9259.        or press the Enter key for the default",
  9260.                     zhome(),
  9261.                     &s,
  9262.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9263.                     xxstring
  9264.                     )
  9265.          ) < 0 )
  9266.       return(x);
  9267. #else
  9268. #ifdef MAC
  9269.     x = ckstrncpy(temp,zhome(),32);
  9270.     if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9271.     if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9272.  or press the Return key for the desktop on the boot disk",
  9273.                    temp,&s, xxstring)) < 0 )
  9274.       return(x);
  9275. #else
  9276.     if ((x = cmdirp("Carriage return for home directory,\n\
  9277. or name of directory on this computer",
  9278. #ifdef VMS
  9279.                     "SYS$LOGIN",        /* With no colon */
  9280. #else
  9281.                     zhome(),            /* In VMS this is "SYS$LOGIN:" */
  9282. #endif /* VMS */
  9283.                     &s,
  9284.                     ckcdpath ? ckcdpath : getenv("CDPATH"),
  9285.                     xxstring
  9286.                     )) < 0)
  9287.       return(x);
  9288. #endif /* MAC */
  9289. #endif /* OS2 */
  9290. #endif /* GEMDOS */
  9291.     ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
  9292.     s = line;
  9293. #ifdef VMS
  9294.     if (ckmatch("*.DIR;1$",s,0,0))
  9295.       if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9296.         s = tmpbuf;
  9297. #endif /* VMS */
  9298.     debug(F110,"docd",s,0);
  9299. #ifndef MAC
  9300.     if ((x = cmcfm()) < 0)              /* Get confirmation */
  9301.       return(x);
  9302. #endif /* MAC */
  9303.  
  9304.   gocd:
  9305.  
  9306. #ifdef datageneral
  9307.     x = strlen(line);                   /* homdir ends in colon, */
  9308.     if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
  9309.       line[x-1] = NUL;
  9310. #endif /* datageneral */
  9311.  
  9312. #ifdef MAC
  9313.     cwdf = 1;
  9314.     if (!zchdir(s)) {
  9315.         cwdf = 0;
  9316.         if (*s != ':') {                /* If it failed, */
  9317.             char *p;                    /* supply leading colon */
  9318.             int len = (int)strlen(s) + 2;
  9319.             p = malloc(len);            /* and try again... */
  9320.             if (p) {
  9321.                 strcpy(p,":");          /* safe */
  9322.                 strcat(p,s);            /* safe */
  9323.                 if (zchdir(p))
  9324.                   cwdf = 1;
  9325.                 free(p);
  9326.                 p = NULL;
  9327.             }
  9328.         }
  9329.     }
  9330.     if (!cwdf)
  9331.       perror(s);
  9332. #else
  9333.     p = zgtdir();
  9334.     if (!zchdir(s)) {
  9335.         cwdf = 0;
  9336. #ifdef CKROOT
  9337.         if (ckrooterr)
  9338.           printf("?Off limits: \"%s\"\n",s);
  9339.         else
  9340. #endif /* CKROOT */
  9341.           perror(s);
  9342.     } else cwdf = 1;
  9343. #endif /* MAC */
  9344.  
  9345.     x = 0;
  9346.     if (cwdf) {
  9347.         makestr(&prevdir,p);
  9348.         if (srvcdmsg
  9349. #ifdef IKSDCONF
  9350.             && !(inserver && !iksdcf)
  9351. #endif /* IKSDCONF */
  9352.             ) {
  9353.             int i;
  9354.             for (i = 0; i < 8; i++) {
  9355.                 if (zchki(cdmsgfile[i]) > -1) {
  9356.                     x = 1;
  9357.                     dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9358.                     break;
  9359.                 }
  9360.             }
  9361.         }
  9362.     }
  9363. /* xdocd: */
  9364.     if (!x && srvcdmsg && !server
  9365. #ifdef IKSDCONF
  9366.         && !(inserver && !iksdcf)
  9367. #endif /* IKSDCONF */
  9368.         && !quiet && !xcmdsrc)
  9369.       printf("%s\n", zgtdir());
  9370.  
  9371.     return(cwdf);
  9372. }
  9373.  
  9374. static int on_ctrlc = 0;
  9375.  
  9376. VOID
  9377. fixcmd() {                      /* Fix command parser after interruption */
  9378. #ifndef NOSPL
  9379. #ifndef NOONCTRLC
  9380.     if (nmac) {                         /* Any macros defined? */
  9381.         int k;                          /* Yes */
  9382.         char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
  9383.         k = mlook(mactab,s,nmac);       /* Look it up. */
  9384.         if (k >= 0) {                   /* If found, */
  9385.             if (on_ctrlc++ == 0) {      /* if not already executing, */
  9386.                 if (dodo(k,"",0) > -1)  /* set it up, */
  9387.                   parser(1);            /* execute it, */
  9388.             }
  9389.             delmac(s,1);                /* and undefine it. */
  9390.         }
  9391.     }
  9392.     on_ctrlc = 0;
  9393. #endif /* NOONCTRLC */
  9394. #endif /* NOSPL */
  9395.     dostop();                   /* Back to top level (also calls conint()). */
  9396.     bgchk();                    /* Check background status */
  9397.     if (*psave) {               /* If old prompt saved, */
  9398.         cmsetp(psave);          /* restore it. */
  9399.         *psave = NUL;
  9400.     }
  9401.     success = 0;                /* Tell parser last command failed */
  9402. }
  9403.  
  9404. #ifndef NOSHOW                          /* SHOW FEATURES */
  9405. /*
  9406.   Note, presently optlist[] index overflow is not checked.
  9407.   There is plenty of room (less than 360 entries for 1000 slots).
  9408.   When space starts to get tight, check for noptlist >= NOPTLIST
  9409.   every time noptlist is incremented.
  9410. */
  9411. #define NOPTLIST 1024
  9412. static int noptlist = 0;
  9413. static char * optlist[NOPTLIST+1];
  9414. static int hpos = 0;
  9415.  
  9416. int
  9417. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9418.     int y, i;                           /* Does word wrap. */
  9419.     if (!s) s = "";
  9420.     i = *lines;
  9421.     if (!*s) {                          /* Empty argument */
  9422.         if (hpos > 0) {                 /* means to end this line. */
  9423.             printf("\n");               /* Not needed if already at */
  9424.             if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9425.                 if (!askmore())
  9426.                   return(0);
  9427.                 else
  9428.                   i = 0;
  9429.             }
  9430.         }
  9431.         printf("\n");                   /* And then make a blank line */
  9432.         if (++i > (cmd_rows - 3)) {
  9433.             if (!askmore())
  9434.               return(0);
  9435.             else
  9436.               i = 0;
  9437.         }
  9438.         hpos = 0;
  9439.         *lines = i;
  9440.         return(1);
  9441.     }
  9442.     y = (int)strlen(s) + 1;
  9443.     hpos += y;
  9444.     debug(F101,"prtopt hpos","",hpos);
  9445.     debug(F101,"prtopt cmd_cols","",cmd_cols);
  9446.  
  9447.     if (
  9448. #ifdef OS2
  9449.         hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9450. #else /* OS2 */
  9451.         hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9452. #endif /* OS2 */
  9453.         ) {
  9454.         printf("\n");
  9455.         if (++i > (cmd_rows - 3)) {
  9456.             if (!askmore())
  9457.               return(0);
  9458.             else
  9459.               i = 0;
  9460.         }
  9461.         printf(" %s",s);
  9462.         hpos = y;
  9463.     } else
  9464.       printf(" %s",s);
  9465.     *lines = i;
  9466.     return(1);
  9467. }
  9468.  
  9469. static VOID
  9470. initoptlist() {
  9471.     int i;
  9472.     if (noptlist > 0)
  9473.       return;
  9474.     for (i = 0; i < NOPTLIST; i++)
  9475.       optlist[i] = NULL;
  9476.  
  9477. #ifdef MAC
  9478. #ifdef MPW
  9479.     makestr(&(optlist[noptlist++]),"MPW");
  9480. #endif /* MPW */
  9481. #endif /* MAC */
  9482.  
  9483. #ifdef MAC
  9484. #ifdef THINK_C
  9485.     makestr(&(optlist[noptlist++]),"THINK_C");
  9486. #endif /* THINK_C */
  9487. #endif /* MAC */
  9488.  
  9489. #ifdef __386__
  9490.     makestr(&(optlist[noptlist++]),"__386__");
  9491. #endif /* __386__ */
  9492.  
  9493. /* Memory models... */
  9494.  
  9495. #ifdef __FLAT__
  9496.     makestr(&(optlist[noptlist++]),"__FLAT__");
  9497. #endif /* __FLAT__ */
  9498. #ifdef __SMALL__
  9499.     makestr(&(optlist[noptlist++]),"__SMALL__");
  9500. #endif /* __SMALL__ */
  9501. #ifdef __MEDIUM__
  9502.     makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9503. #endif /* __MEDIUM__ */
  9504. #ifdef __COMPACT__
  9505.     makestr(&(optlist[noptlist++]),"__COMPACT__");
  9506. #endif /* __COMPACT__ */
  9507. #ifdef __LARGE__
  9508.     makestr(&(optlist[noptlist++]),"__LARGE__");
  9509. #endif /* __LARGE__ */
  9510.  
  9511. #ifdef DEBUG
  9512. #ifdef IFDEBUG
  9513.     makestr(&(optlist[noptlist++]),"IFDEBUG");
  9514. #else
  9515.     makestr(&(optlist[noptlist++]),"DEBUG");
  9516. #endif /* IFDEBUG */
  9517. #endif /* DEBUG */
  9518. #ifdef TLOG
  9519.     makestr(&(optlist[noptlist++]),"TLOG");
  9520. #endif /* TLOG */
  9521. #ifdef BIGBUFOK
  9522.     makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9523. #endif /* BIGBUFOK */
  9524. #ifdef INPBUFSIZ
  9525.     sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9526.     makestr(&(optlist[noptlist++]),line);
  9527. #endif /* INPBUFSIZE */
  9528. #ifdef INBUFSIZE
  9529.     sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9530.     makestr(&(optlist[noptlist++]),line);
  9531. #endif /* INBUFSIZE */
  9532. #ifdef OBUFSIZE
  9533.     sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9534.     makestr(&(optlist[noptlist++]),line);
  9535. #endif /* OBUFSIZE */
  9536. #ifdef FD_SETSIZE
  9537.     sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9538.     makestr(&(optlist[noptlist++]),line);
  9539. #endif /* FD_SETSIZE */
  9540. #ifdef XFRCAN
  9541.     makestr(&(optlist[noptlist++]),"XFRCAN");
  9542. #endif /* XFRCAN */
  9543. #ifdef XPRINT
  9544.     makestr(&(optlist[noptlist++]),"XPRINT");
  9545. #endif /* XPRINT */
  9546. #ifdef PIPESEND
  9547.     makestr(&(optlist[noptlist++]),"PIPESEND");
  9548. #endif /* PIPESEND */
  9549. #ifdef CK_SPEED
  9550.     makestr(&(optlist[noptlist++]),"CK_SPEED");
  9551. #endif /* CK_SPEED */
  9552. #ifdef CK_FAST
  9553.     makestr(&(optlist[noptlist++]),"CK_FAST");
  9554. #endif /* CK_FAST */
  9555. #ifdef CK_APC
  9556.     makestr(&(optlist[noptlist++]),"CK_APC");
  9557. #endif /* CK_APC */
  9558. #ifdef CK_AUTODL
  9559.     makestr(&(optlist[noptlist++]),"CK_AUTODL");
  9560. #endif /* CK_AUTODL */
  9561. #ifdef CK_MKDIR
  9562.     makestr(&(optlist[noptlist++]),"CK_MKDIR");
  9563. #endif /* CK_MKDIR */
  9564. #ifdef NOMKDIR
  9565.     makestr(&(optlist[noptlist++]),"NOMKDIR");
  9566. #endif /* NOMKDIR */
  9567. #ifdef CK_LABELED
  9568.     makestr(&(optlist[noptlist++]),"CK_LABELED");
  9569. #endif /* CK_LABELED */
  9570. #ifdef NODIAL
  9571.     makestr(&(optlist[noptlist++]),"NODIAL");
  9572. #endif /* NODIAL */
  9573. #ifdef MINIDIAL
  9574.     makestr(&(optlist[noptlist++]),"MINIDIAL");
  9575. #endif /* MINIDIAL */
  9576. #ifdef WHATAMI
  9577.     makestr(&(optlist[noptlist++]),"WHATAMI");
  9578. #endif /* WHATAMI */
  9579. #ifdef DYNAMIC
  9580.     makestr(&(optlist[noptlist++]),"DYNAMIC");
  9581. #endif /* IFDEBUG */
  9582. #ifndef NOSPL
  9583.     sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
  9584.     makestr(&(optlist[noptlist++]),line);
  9585. #endif /* NOSPL */
  9586.  
  9587. #ifdef MAXPATHLEN
  9588.     sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  9589.     makestr(&(optlist[noptlist++]),line);
  9590. #endif /* MAXPATHLEN */
  9591.  
  9592. #ifdef DEVNAMLEN
  9593.     sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  9594.     makestr(&(optlist[noptlist++]),line);
  9595. #endif /* DEVNAMLEN */
  9596.  
  9597. #ifdef NO_PARAM_H
  9598.     makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  9599. #endif /* NO_PARAM_H */
  9600.  
  9601. #ifdef INCL_PARAM_H
  9602.     makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  9603. #endif /* INCL_PARAM_H */
  9604.  
  9605.     sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  9606.     makestr(&(optlist[noptlist++]),line);
  9607.  
  9608.     sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  9609.     makestr(&(optlist[noptlist++]),line);
  9610.  
  9611.     sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  9612.     makestr(&(optlist[noptlist++]),line);
  9613.  
  9614. #ifdef OPEN_MAX
  9615.     sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  9616.     makestr(&(optlist[noptlist++]),line);
  9617. #endif /* OPEN_MAX */
  9618.  
  9619. #ifdef _POSIX_OPEN_MAX
  9620.     sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  9621.     makestr(&(optlist[noptlist++]),line);
  9622. #endif /* _POSIX_OPEN_MAX */
  9623.  
  9624. #ifdef CKCHANNELIO
  9625.     {
  9626.         extern int z_maxchan;
  9627. #ifdef UNIX
  9628.         extern int ckmaxfiles;
  9629.         sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  9630.         makestr(&(optlist[noptlist++]),line);
  9631. #endif /* UNIX */
  9632.         sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  9633.         makestr(&(optlist[noptlist++]),line);
  9634.     }
  9635. #endif /* CKCHANNELIO */
  9636.  
  9637. #ifdef FOPEN_MAX
  9638.     sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  9639.     makestr(&(optlist[noptlist++]),line);
  9640. #endif /* FOPEN_MAX */
  9641.  
  9642. #ifdef MAXGETPATH
  9643.     sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  9644.     makestr(&(optlist[noptlist++]),line);
  9645. #endif /* MAXGETPATH */
  9646.  
  9647. #ifdef CMDBL
  9648.     sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
  9649.     makestr(&(optlist[noptlist++]),line);
  9650. #endif /* CMDBL */
  9651.  
  9652. #ifdef VNAML
  9653.     sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
  9654.     makestr(&(optlist[noptlist++]),line);
  9655. #endif /* VNAML */
  9656.  
  9657. #ifdef ARRAYREFLEN
  9658.     sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  9659.     makestr(&(optlist[noptlist++]),line);
  9660. #endif /* ARRAYREFLEN */
  9661.  
  9662. #ifdef UIDBUFLEN
  9663.     sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  9664.     makestr(&(optlist[noptlist++]),line);
  9665. #endif /* UIDBUFLEN */
  9666.  
  9667. #ifdef FORDEPTH
  9668.     sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  9669.     makestr(&(optlist[noptlist++]),line);
  9670. #endif /* FORDEPTH */
  9671.  
  9672. #ifdef MAXTAKE
  9673.     sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  9674.     makestr(&(optlist[noptlist++]),line);
  9675. #endif /* MAXTAKE */
  9676.  
  9677. #ifdef MACLEVEL
  9678.     sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  9679.     makestr(&(optlist[noptlist++]),line);
  9680. #endif /* MACLEVEL */
  9681.  
  9682. #ifdef MAC_MAX
  9683.     sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  9684.     makestr(&(optlist[noptlist++]),line);
  9685. #endif /* MAC_MAX */
  9686.  
  9687. #ifdef MINPUTMAX
  9688.     sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  9689.     makestr(&(optlist[noptlist++]),line);
  9690. #endif /* MINPUTMAX */
  9691.  
  9692. #ifdef MAXWLD
  9693.     sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  9694.     makestr(&(optlist[noptlist++]),line);
  9695. #else
  9696. #ifdef OS2
  9697.     makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  9698. #endif /* OS2 */
  9699. #endif /* MAXWLD */
  9700.  
  9701. #ifdef MSENDMAX
  9702.     sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  9703.     makestr(&(optlist[noptlist++]),line);
  9704. #endif /* MSENDMAX */
  9705.  
  9706. #ifdef MAXDDIR
  9707.     sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  9708.     makestr(&(optlist[noptlist++]),line);
  9709. #endif /* MAXDDIR */
  9710.  
  9711. #ifdef MAXDNUMS
  9712.     sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  9713.     makestr(&(optlist[noptlist++]),line);
  9714. #endif /* MAXDNUMS */
  9715.  
  9716. #ifdef UNIX
  9717.     makestr(&(optlist[noptlist++]),"UNIX");
  9718. #endif /* UNIX */
  9719. #ifdef VMS
  9720.     makestr(&(optlist[noptlist++]),"VMS");
  9721. #ifdef __VMS_VER
  9722.     sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  9723.     makestr(&(optlist[noptlist++]),line);
  9724. #endif /* __VMS_VER */
  9725. #ifdef VMSV70
  9726.     makestr(&(optlist[noptlist++]),"VMSV70");
  9727. #endif /* VMSV70 */
  9728. #endif /* VMS */
  9729. #ifdef OLD_VMS
  9730.     makestr(&(optlist[noptlist++]),"OLD_VMS");
  9731. #endif /* OLD_VMS */
  9732. #ifdef vms
  9733.     makestr(&(optlist[noptlist++]),"vms");
  9734. #endif /* vms */
  9735. #ifdef VMSV60
  9736.     makestr(&(optlist[noptlist++]),"VMSV60");
  9737. #endif /* VMSV60 */
  9738. #ifdef VMSV70
  9739.     makestr(&(optlist[noptlist++]),"VMSV70");
  9740. #endif /* VMSV70 */
  9741. #ifdef VMSSHARE
  9742.     makestr(&(optlist[noptlist++]),"VMSSHARE");
  9743. #endif /* VMSSHARE */
  9744. #ifdef NOVMSSHARE
  9745.     makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  9746. #endif /* NOVMSSHARE */
  9747. #ifdef datageneral
  9748.     makestr(&(optlist[noptlist++]),"datageneral");
  9749. #endif /* datageneral */
  9750. #ifdef apollo
  9751.     makestr(&(optlist[noptlist++]),"apollo");
  9752. #endif /* apollo */
  9753. #ifdef aegis
  9754.     makestr(&(optlist[noptlist++]),"aegis");
  9755. #endif /* aegis */
  9756. #ifdef A986
  9757.     makestr(&(optlist[noptlist++]),"A986");
  9758. #endif /* A986 */
  9759. #ifdef AMIGA
  9760.     makestr(&(optlist[noptlist++]),"AMIGA");
  9761. #endif /* AMIGA */
  9762. #ifdef CONVEX9
  9763.     makestr(&(optlist[noptlist++]),"CONVEX9");
  9764. #endif /* CONVEX9 */
  9765. #ifdef CONVEX10
  9766.     makestr(&(optlist[noptlist++]),"CONVEX10");
  9767. #endif /* CONVEX9 */
  9768. #ifdef MAC
  9769.     makestr(&(optlist[noptlist++]),"MAC");
  9770. #endif /* MAC */
  9771. #ifdef AUX
  9772.     makestr(&(optlist[noptlist++]),"AUX");
  9773. #endif /* AUX */
  9774. #ifdef OS2
  9775.     makestr(&(optlist[noptlist++]),"OS2");
  9776. #ifdef NT
  9777.     makestr(&(optlist[noptlist++]),"NT");
  9778. #endif /* NT */
  9779. #endif /* OS2 */
  9780. #ifdef OSK
  9781.     makestr(&(optlist[noptlist++]),"OS9");
  9782. #endif /* OSK */
  9783. #ifdef MSDOS
  9784.     makestr(&(optlist[noptlist++]),"MSDOS");
  9785. #endif /* MSDOS */
  9786. #ifdef DIRENT
  9787.     makestr(&(optlist[noptlist++]),"DIRENT");
  9788. #endif /* DIRENT */
  9789. #ifdef SDIRENT
  9790.     makestr(&(optlist[noptlist++]),"SDIRENT");
  9791. #endif /* SDIRENT */
  9792. #ifdef NDIR
  9793.     makestr(&(optlist[noptlist++]),"NDIR");
  9794. #endif /* NDIR */
  9795. #ifdef XNDIR
  9796.     makestr(&(optlist[noptlist++]),"XNDIR");
  9797. #endif /* XNDIR */
  9798. #ifdef SAVEDUID
  9799.     makestr(&(optlist[noptlist++]),"SAVEDUID");
  9800. #endif /* SAVEDUID */
  9801. #ifdef RENAME
  9802.     makestr(&(optlist[noptlist++]),"RENAME");
  9803. #endif /* RENAME */
  9804. #ifdef CK_TMPDIR
  9805.     makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  9806. #endif /* CK_TMPDIR */
  9807. #ifdef NOCCTRAP
  9808.     makestr(&(optlist[noptlist++]),"NOCCTRAP");
  9809. #endif /* NOCCTRAP */
  9810. #ifdef NOCOTFMC
  9811.     makestr(&(optlist[noptlist++]),"NOCOTFMC");
  9812. #endif /* NOCOTFMC */
  9813. #ifdef NOFRILLS
  9814.     makestr(&(optlist[noptlist++]),"NOFRILLS");
  9815. #endif /* NOFRILLS */
  9816. #ifdef PARSENSE
  9817.     makestr(&(optlist[noptlist++]),"PARSENSE");
  9818. #endif /* PARSENSE */
  9819. #ifdef TIMEH
  9820.     makestr(&(optlist[noptlist++]),"TIMEH");
  9821. #endif /* TIMEH */
  9822. #ifdef NOTIMEH
  9823.     makestr(&(optlist[noptlist++]),"TIMEH");
  9824. #endif /* NOTIMEH */
  9825.  
  9826. #ifdef SYSTIMEH
  9827.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  9828. #endif /* SYSTIMEH */
  9829. #ifdef NOSYSTIMEH
  9830.     makestr(&(optlist[noptlist++]),"SYSTIMEH");
  9831. #endif /* NOSYSTIMEH */
  9832.  
  9833. #ifdef SYSTIMEBH
  9834.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  9835. #endif /* SYSTIMEBH */
  9836. #ifdef NOSYSTIMEBH
  9837.     makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  9838. #endif /* NOSYSTIMEBH */
  9839. #ifdef UTIMEH
  9840.     makestr(&(optlist[noptlist++]),"UTIMEH");
  9841. #endif /* UTIMEH */
  9842. #ifdef SYSUTIMEH
  9843.     makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  9844. #endif /* SYSUTIMEH */
  9845.  
  9846. #ifdef CK_NEED_SIG
  9847.     makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  9848. #endif /* CK_NEED_SIG */
  9849. #ifdef CK_TTYFD
  9850.     makestr(&(optlist[noptlist++]),"CK_TTYFD");
  9851. #endif /* CK_TTYFD */
  9852. #ifdef NETCONN
  9853.     makestr(&(optlist[noptlist++]),"NETCONN");
  9854. #endif /* NETCONN */
  9855. #ifdef TCPSOCKET
  9856.     makestr(&(optlist[noptlist++]),"TCPSOCKET");
  9857. #ifdef NOTCPOPTS
  9858.     makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  9859. #endif /* NOTCPOPTS */
  9860. #ifdef CK_DNS_SRV
  9861.     makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  9862. #endif /* CK_DNS_SRV */
  9863. #ifdef NO_DNS_SRV
  9864.     makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  9865. #endif /* NO_DNS_SRV */
  9866. #ifdef CKGHNLHOST
  9867.     makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  9868. #endif /* CKGHNLHOST */
  9869. #ifdef NOLISTEN
  9870.     makestr(&(optlist[noptlist++]),"NOLISTEN");
  9871. #endif /* NOLISTEN */
  9872. #ifdef SOL_SOCKET
  9873.     makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  9874. #endif /* SOL_SOCKET */
  9875. #ifdef SO_OOBINLINE
  9876.     makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  9877. #endif /* SO_OOBINLNE */
  9878. #ifdef SO_DONTROUTE
  9879.     makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  9880. #endif /* SO_DONTROUTE */
  9881. #ifdef SO_KEEPALIVE
  9882.     makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  9883. #endif /* SO_KEEPALIVE */
  9884. #ifdef SO_LINGER
  9885.     makestr(&(optlist[noptlist++]),"SO_LINGER");
  9886. #endif /* SO_LINGER */
  9887. #ifdef TCP_NODELAY
  9888.     makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  9889. #endif /* TCP_NODELAY */
  9890. #ifdef SO_SNDBUF
  9891.     makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  9892. #endif /* SO_SNDBUF */
  9893. #ifdef SO_RCVBUF
  9894.     makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  9895. #endif /* SO_RCVBUF */
  9896. #ifdef h_addr
  9897.     makestr(&(optlist[noptlist++]),"h_addr");
  9898. #endif /* h_addr */
  9899. #ifdef HADDRLIST
  9900.     makestr(&(optlist[noptlist++]),"HADDRLIST");
  9901. #endif /* HADDRLIST */
  9902. #ifdef CK_SOCKS
  9903.     makestr(&(optlist[noptlist++]),"CK_SOCKS");
  9904. #ifdef CK_SOCKS5
  9905.     makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  9906. #endif /* CK_SOCKS5 */
  9907. #ifdef CK_SOCKS_NS
  9908.     makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  9909. #endif /* CK_SOCKS_NS */
  9910. #endif /* CK_SOCKS */
  9911. #ifdef RLOGCODE
  9912.     makestr(&(optlist[noptlist++]),"RLOGCODE");
  9913. #endif /* RLOGCODE */
  9914. #ifdef NETCMD
  9915.     makestr(&(optlist[noptlist++]),"NETCMD");
  9916. #endif /* NETCMD */
  9917. #ifdef NONETCMD
  9918.     makestr(&(optlist[noptlist++]),"NONETCMD");
  9919. #endif /* NONETCMD */
  9920. #ifdef NETPTY
  9921.     makestr(&(optlist[noptlist++]),"NETPTY");
  9922. #endif /* NETPTY */
  9923. #ifdef CK_ENVIRONMENT
  9924.     makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  9925. #endif /* CK_ENVIRONMENT */
  9926. #endif /* TCPSOCKET */
  9927. #ifdef TNCODE
  9928.     makestr(&(optlist[noptlist++]),"TNCODE");
  9929. #endif /* TNCODE */
  9930. #ifdef CK_FORWARD_X
  9931.     makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  9932. #endif /* CK_FORWARD_X */
  9933. #ifdef TN_COMPORT
  9934.     makestr(&(optlist[noptlist++]),"TN_COMPORT");
  9935. #endif /* TN_COMPORT */
  9936. #ifdef MULTINET
  9937.     makestr(&(optlist[noptlist++]),"MULTINET");
  9938. #endif /* MULTINET */
  9939. #ifdef DEC_TCPIP
  9940.     makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  9941. #endif /* DEC_TCPIP */
  9942. #ifdef TCPWARE
  9943.     makestr(&(optlist[noptlist++]),"TCPWARE");
  9944. #endif /* TCPWARE */
  9945. #ifdef UCX50
  9946.     makestr(&(optlist[noptlist++]),"UCX50");
  9947. #endif /* UCX50 */
  9948. #ifdef TTLEBUF
  9949.     makestr(&(optlist[noptlist++]),"TTLEBUF");
  9950. #endif /* TTLEBUF */
  9951. #ifdef NETLEBUF
  9952.     makestr(&(optlist[noptlist++]),"NETLEBUF");
  9953. #endif /* NETLEBUF */
  9954. #ifdef IKS_OPTION
  9955.     makestr(&(optlist[noptlist++]),"IKS_OPTION");
  9956. #endif /* IKS_OPTION */
  9957. #ifdef IKSDB
  9958.     makestr(&(optlist[noptlist++]),"IKSDB");
  9959. #endif /* IKSDB */
  9960. #ifdef IKSDCONF
  9961.     makestr(&(optlist[noptlist++]),"IKSDCONF");
  9962. #endif /* IKSDCONF */
  9963. #ifdef CK_LOGIN
  9964.     makestr(&(optlist[noptlist++]),"CK_LOGIN");
  9965. #endif /* CK_LOGIN */
  9966. #ifdef CK_PAM
  9967.     makestr(&(optlist[noptlist++]),"CK_PAM");
  9968. #endif /* CK_PAM */
  9969. #ifdef CK_SHADOW
  9970.     makestr(&(optlist[noptlist++]),"CK_SHADOW");
  9971. #endif /* CK_SHADOW */
  9972. #ifdef CONGSPD
  9973.     makestr(&(optlist[noptlist++]),"CONGSPD");
  9974. #endif /* CONGSPD */
  9975. #ifdef SUNX25
  9976.     makestr(&(optlist[noptlist++]),"SUNX25");
  9977. #endif /* SUNX25 */
  9978. #ifdef IBMX25
  9979.     makestr(&(optlist[noptlist++]),"IBMX25");
  9980. #endif /* IBMX25 */
  9981. #ifdef HPX25
  9982.     makestr(&(optlist[noptlist++]),"HPX25");
  9983. #endif /* HPX25 */
  9984. #ifdef DECNET
  9985.     makestr(&(optlist[noptlist++]),"DECNET");
  9986. #endif /* DECNET */
  9987. #ifdef SUPERLAT
  9988.     makestr(&(optlist[noptlist++]),"SUPERLAT");
  9989. #endif /* SUPERLAT */
  9990. #ifdef NPIPE
  9991.     makestr(&(optlist[noptlist++]),"NPIPE");
  9992. #endif /* NPIPE */
  9993. #ifdef CK_NETBIOS
  9994.     makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  9995. #endif /* CK_NETBIOS */
  9996. #ifdef ATT7300
  9997.     makestr(&(optlist[noptlist++]),"ATT7300");
  9998. #endif /* ATT7300 */
  9999. #ifdef ATT6300
  10000.     makestr(&(optlist[noptlist++]),"ATT6300");
  10001. #endif /* ATT6300 */
  10002. #ifdef HDBUUCP
  10003.     makestr(&(optlist[noptlist++]),"HDBUUCP");
  10004. #endif /* HDBUUCP */
  10005. #ifdef USETTYLOCK
  10006.     makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10007. #endif /* USETTYLOCK */
  10008. #ifdef NOUUCP
  10009.     makestr(&(optlist[noptlist++]),"NOUUCP");
  10010. #endif /* NOUUCP */
  10011. #ifdef LONGFN
  10012.     makestr(&(optlist[noptlist++]),"LONGFN");
  10013. #endif /* LONGFN */
  10014. #ifdef RDCHK
  10015.     makestr(&(optlist[noptlist++]),"RDCHK");
  10016. #endif /* RDCHK */
  10017. #ifdef SELECT
  10018.     makestr(&(optlist[noptlist++]),"SELECT");
  10019. #endif /* SELECT */
  10020. #ifdef USLEEP
  10021.     makestr(&(optlist[noptlist++]),"USLEEP");
  10022. #endif /* USLEEP */
  10023. #ifdef NAP
  10024.     makestr(&(optlist[noptlist++]),"NAP");
  10025. #endif /* NAP */
  10026. #ifdef NAPHACK
  10027.     makestr(&(optlist[noptlist++]),"NAPHACK");
  10028. #endif /* NAPHACK */
  10029. #ifdef CK_POLL
  10030.     makestr(&(optlist[noptlist++]),"CK_POLL");
  10031. #endif /* CK_POLL */
  10032. #ifdef NOIEXTEN
  10033.     makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10034. #endif /* NOIEXTEN */
  10035. #ifdef EXCELAN
  10036.     makestr(&(optlist[noptlist++]),"EXCELAN");
  10037. #endif /* EXCELAN */
  10038. #ifdef INTERLAN
  10039.     makestr(&(optlist[noptlist++]),"INTERLAN");
  10040. #endif /* INTERLAN */
  10041. #ifdef NOFILEH
  10042.     makestr(&(optlist[noptlist++]),"NOFILEH");
  10043. #endif /* NOFILEH */
  10044. #ifdef NOSYSIOCTLH
  10045.     makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10046. #endif /* NOSYSIOCTLH */
  10047. #ifdef DCLPOPEN
  10048.     makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10049. #endif /* DCLPOPEN */
  10050. #ifdef NOSETBUF
  10051.     makestr(&(optlist[noptlist++]),"NOSETBUF");
  10052. #endif /* NOSETBUF */
  10053. #ifdef NOXFER
  10054.     makestr(&(optlist[noptlist++]),"NOXFER");
  10055. #endif /* NOXFER */
  10056. #ifdef NOCURSES
  10057.     makestr(&(optlist[noptlist++]),"NOCURSES");
  10058. #endif /* NOCURSES */
  10059. #ifdef NOSERVER
  10060.     makestr(&(optlist[noptlist++]),"NOSERVER");
  10061. #endif /* NOSERVER */
  10062. #ifdef NOPATTERNS
  10063.     makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10064. #else
  10065. #ifdef PATTERNS
  10066.     makestr(&(optlist[noptlist++]),"PATTERNS");
  10067. #endif /* PATTERNS */
  10068. #endif /* NOPATTERNS */
  10069. #ifdef NOCKEXEC
  10070.     makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10071. #else
  10072. #ifdef CKEXEC
  10073.     makestr(&(optlist[noptlist++]),"CKEXEC");
  10074. #endif /* CKEXEC */
  10075. #endif /* NOCKEXEC */
  10076. #ifdef NOAUTODL
  10077.     makestr(&(optlist[noptlist++]),"NOAUTODL");
  10078. #endif /* NOAUTODL */
  10079. #ifdef NOMSEND
  10080.     makestr(&(optlist[noptlist++]),"NOMSEND");
  10081. #endif /* NOMSEND */
  10082. #ifdef NOFDZERO
  10083.     makestr(&(optlist[noptlist++]),"NOFDZERO");
  10084. #endif /* NOFDZERO */
  10085. #ifdef NOPOPEN
  10086.     makestr(&(optlist[noptlist++]),"NOPOPEN");
  10087. #endif /* NOPOPEN */
  10088. #ifdef NOPARTIAL
  10089.     makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10090. #endif /* NOPARTIAL */
  10091. #ifdef NOKVERBS
  10092.     makestr(&(optlist[noptlist++]),"NOKVERBS");
  10093. #endif /* NOKVERBS */
  10094. #ifdef NOSETREU
  10095.     makestr(&(optlist[noptlist++]),"NOSETREU");
  10096. #endif /* NOSETREU */
  10097. #ifdef LCKDIR
  10098.     makestr(&(optlist[noptlist++]),"LCKDIR");
  10099. #endif /* LCKDIR */
  10100. #ifdef ACUCNTRL
  10101.     makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10102. #endif /* ACUCNTRL */
  10103. #ifdef BSD4
  10104.     makestr(&(optlist[noptlist++]),"BSD4");
  10105. #endif /* BSD4 */
  10106. #ifdef BSD44
  10107.     makestr(&(optlist[noptlist++]),"BSD44");
  10108. #endif /* BSD44 */
  10109. #ifdef BSD41
  10110.     makestr(&(optlist[noptlist++]),"BSD41");
  10111. #endif /* BSD41 */
  10112. #ifdef BSD43
  10113.     makestr(&(optlist[noptlist++]),"BSD43");
  10114. #endif /* BSD43 */
  10115. #ifdef BSD29
  10116.     makestr(&(optlist[noptlist++]),"BSD29");
  10117. #endif /* BSD29 */
  10118. #ifdef BSDI
  10119.     makestr(&(optlist[noptlist++]),"BSDI");
  10120. #endif /* BSDI */
  10121. #ifdef __bsdi__
  10122.     makestr(&(optlist[noptlist++]),"__bsdi__");
  10123. #endif /* __bsdi__ */
  10124. #ifdef __NetBSD__
  10125.     makestr(&(optlist[noptlist++]),"__NetBSD__");
  10126. #endif /* __NetBSD__ */
  10127. #ifdef __OpenBSD__
  10128.     makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10129. #endif /* __OpenBSD__ */
  10130. #ifdef __FreeBSD__
  10131.     makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10132. #endif /* __FreeBSD__ */
  10133. #ifdef __linux__
  10134.     makestr(&(optlist[noptlist++]),"__linux__");
  10135. #endif /* __linux__ */
  10136. #ifdef LINUX_HI_SPD
  10137.     makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10138. #endif /* LINUX_HI_SPD */
  10139. #ifdef LYNXOS
  10140.     makestr(&(optlist[noptlist++]),"LYNXOS");
  10141. #endif /* LYNXOS */
  10142. #ifdef V7
  10143.     makestr(&(optlist[noptlist++]),"V7");
  10144. #endif /* V7 */
  10145. #ifdef AIX370
  10146.     makestr(&(optlist[noptlist++]),"AIX370");
  10147. #endif /* AIX370 */
  10148. #ifdef RTAIX
  10149.     makestr(&(optlist[noptlist++]),"RTAIX");
  10150. #endif /* RTAIX */
  10151. #ifdef HPUX
  10152.     makestr(&(optlist[noptlist++]),"HPUX");
  10153. #endif /* HPUX */
  10154. #ifdef HPUXPRE65
  10155.     makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10156. #endif /* HPUXPRE65 */
  10157. #ifdef DGUX
  10158.     makestr(&(optlist[noptlist++]),"DGUX");
  10159. #endif /* DGUX */
  10160. #ifdef DGUX430
  10161.     makestr(&(optlist[noptlist++]),"DGUX430");
  10162. #endif /* DGUX430 */
  10163. #ifdef DGUX540
  10164.     makestr(&(optlist[noptlist++]),"DGUX540");
  10165. #endif /* DGUX540 */
  10166. #ifdef DGUX543
  10167.     makestr(&(optlist[noptlist++]),"DGUX543");
  10168. #endif /* DGUX543 */
  10169. #ifdef DGUX54410
  10170.     makestr(&(optlist[noptlist++]),"DGUX54410");
  10171. #endif /* DGUX54410 */
  10172. #ifdef DGUX54411
  10173.     makestr(&(optlist[noptlist++]),"DGUX54411");
  10174. #endif /* DGUX54411 */
  10175. #ifdef sony_news
  10176.     makestr(&(optlist[noptlist++]),"sony_news");
  10177. #endif /* sony_news */
  10178. #ifdef CIE
  10179.     makestr(&(optlist[noptlist++]),"CIE");
  10180. #endif /* CIE */
  10181. #ifdef XENIX
  10182.     makestr(&(optlist[noptlist++]),"XENIX");
  10183. #endif /* XENIX */
  10184. #ifdef SCO_XENIX
  10185.     makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10186. #endif /* SCO_XENIX */
  10187. #ifdef ISIII
  10188.     makestr(&(optlist[noptlist++]),"ISIII");
  10189. #endif /* ISIII */
  10190. #ifdef I386IX
  10191.     makestr(&(optlist[noptlist++]),"I386IX");
  10192. #endif /* I386IX */
  10193. #ifdef RTU
  10194.     makestr(&(optlist[noptlist++]),"RTU");
  10195. #endif /* RTU */
  10196. #ifdef PROVX1
  10197.     makestr(&(optlist[noptlist++]),"PROVX1");
  10198. #endif /* PROVX1 */
  10199. #ifdef PYRAMID
  10200.     makestr(&(optlist[noptlist++]),"PYRAMID");
  10201. #endif /* PYRAMID */
  10202. #ifdef TOWER1
  10203.     makestr(&(optlist[noptlist++]),"TOWER1");
  10204. #endif /* TOWER1 */
  10205. #ifdef UTEK
  10206.     makestr(&(optlist[noptlist++]),"UTEK");
  10207. #endif /* UTEK */
  10208. #ifdef ZILOG
  10209.     makestr(&(optlist[noptlist++]),"ZILOG");
  10210. #endif /* ZILOG */
  10211. #ifdef TRS16
  10212.     makestr(&(optlist[noptlist++]),"TRS16");
  10213. #endif /* TRS16 */
  10214. #ifdef MINIX
  10215.     makestr(&(optlist[noptlist++]),"MINIX");
  10216. #endif /* MINIX */
  10217. #ifdef C70
  10218.     makestr(&(optlist[noptlist++]),"C70");
  10219. #endif /* C70 */
  10220. #ifdef AIXPS2
  10221.     makestr(&(optlist[noptlist++]),"AIXPS2");
  10222. #endif /* AIXPS2 */
  10223. #ifdef AIXRS
  10224.     makestr(&(optlist[noptlist++]),"AIXRS");
  10225. #endif /* AIXRS */
  10226. #ifdef UTSV
  10227.     makestr(&(optlist[noptlist++]),"UTSV");
  10228. #endif /* UTSV */
  10229. #ifdef ATTSV
  10230.     makestr(&(optlist[noptlist++]),"ATTSV");
  10231. #endif /* ATTSV */
  10232. #ifdef SVR3
  10233.     makestr(&(optlist[noptlist++]),"SVR3");
  10234. #endif /* SVR3 */
  10235. #ifdef SVR4
  10236.     makestr(&(optlist[noptlist++]),"SVR4");
  10237. #endif /* SVR4 */
  10238. #ifdef DELL_SVR4
  10239.     makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10240. #endif /* DELL_SVR4 */
  10241. #ifdef ICL_SVR4
  10242.     makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10243. #endif /* ICL_SVR4 */
  10244. #ifdef OSF
  10245.     makestr(&(optlist[noptlist++]),"OSF");
  10246. #endif /* OSF */
  10247. #ifdef OSF1
  10248.     makestr(&(optlist[noptlist++]),"OSF1");
  10249. #endif /* OSF1 */
  10250. #ifdef __OSF
  10251.     makestr(&(optlist[noptlist++]),"__OSF");
  10252. #endif /* __OSF */
  10253. #ifdef __OSF__
  10254.     makestr(&(optlist[noptlist++]),"__OSF__");
  10255. #endif /* __OSF__ */
  10256. #ifdef __osf__
  10257.     makestr(&(optlist[noptlist++]),"__osf__");
  10258. #endif /* __osf__ */
  10259. #ifdef __OSF1
  10260.     makestr(&(optlist[noptlist++]),"__OSF1");
  10261. #endif /* __OSF1 */
  10262. #ifdef __OSF1__
  10263.     makestr(&(optlist[noptlist++]),"__OSF1__");
  10264. #endif /* __OSF1__ */
  10265. #ifdef PTX
  10266.     makestr(&(optlist[noptlist++]),"PTX");
  10267. #endif /* PTX */
  10268. #ifdef POSIX
  10269.     makestr(&(optlist[noptlist++]),"POSIX");
  10270. #endif /* POSIX */
  10271. #ifdef BSD44ORPOSIX
  10272.     makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10273. #endif /* BSD44ORPOSIX */
  10274. #ifdef SVORPOSIX
  10275.     makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10276. #endif /* SVORPOSIX */
  10277. #ifdef SVR4ORPOSIX
  10278.     makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10279. #endif /* SVR4ORPOSIX */
  10280. #ifdef OS2ORVMS
  10281.     makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10282. #endif /* OS2ORVMS */
  10283. #ifdef OS2ORUNIX
  10284.     makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10285. #endif /* OS2ORUNIX */
  10286. #ifdef VMSORUNIX
  10287.     makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10288. #endif /* VMSORUNIX */
  10289. #ifdef _POSIX_SOURCE
  10290.     makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10291. #endif /* _POSIX_SOURCE */
  10292. #ifdef _XOPEN_SOURCE
  10293.     makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10294. #endif
  10295. #ifdef _ALL_SOURCE
  10296.     makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10297. #endif
  10298. #ifdef _SVID3
  10299.     makestr(&(optlist[noptlist++]),"_SVID3");
  10300. #endif /* _SVID3 */
  10301. #ifdef Plan9
  10302.     makestr(&(optlist[noptlist++]),"Plan9");
  10303. #endif /* Plan9 */
  10304. #ifdef SOLARIS
  10305.     makestr(&(optlist[noptlist++]),"SOLARIS");
  10306. #ifdef SOLARIS24
  10307.     makestr(&(optlist[noptlist++]),"SOLARIS24");
  10308. #endif /* SOLARIS24 */
  10309. #ifdef SOLARIS25
  10310.     makestr(&(optlist[noptlist++]),"SOLARIS25");
  10311. #endif /* SOLARIS25 */
  10312. #ifdef SOLARIS26
  10313.     makestr(&(optlist[noptlist++]),"SOLARIS26");
  10314. #endif /* SOLARIS26 */
  10315. #ifdef SOLARIS7
  10316.     makestr(&(optlist[noptlist++]),"SOLARIS7");
  10317. #endif /* SOLARIS7 */
  10318. #ifdef SOLARIS8
  10319.     makestr(&(optlist[noptlist++]),"SOLARIS8");
  10320. #endif /* SOLARIS8 */
  10321. #endif /* SOLARIS */
  10322.  
  10323. #ifdef SUNOS4
  10324.     makestr(&(optlist[noptlist++]),"SUNOS4");
  10325. #endif /* SUNOS4 */
  10326. #ifdef SUN4S5
  10327.     makestr(&(optlist[noptlist++]),"SUN4S5");
  10328. #endif /* SUN4S5 */
  10329. #ifdef IRIX
  10330.     makestr(&(optlist[noptlist++]),"IRIX");
  10331. #endif /* IRIX */
  10332. #ifdef ENCORE
  10333.     makestr(&(optlist[noptlist++]),"ENCORE");
  10334. #endif /* ENCORE */
  10335. #ifdef ultrix
  10336.     makestr(&(optlist[noptlist++]),"ultrix");
  10337. #endif
  10338. #ifdef sxaE50
  10339.     makestr(&(optlist[noptlist++]),"sxaE50");
  10340. #endif
  10341. #ifdef mips
  10342.     makestr(&(optlist[noptlist++]),"mips");
  10343. #endif
  10344. #ifdef MIPS
  10345.     makestr(&(optlist[noptlist++]),"MIPS");
  10346. #endif
  10347. #ifdef vax
  10348.     makestr(&(optlist[noptlist++]),"vax");
  10349. #endif
  10350. #ifdef VAX
  10351.     makestr(&(optlist[noptlist++]),"VAX");
  10352. #endif
  10353. #ifdef alpha
  10354.     makestr(&(optlist[noptlist++]),"alpha");
  10355. #endif
  10356. #ifdef ALPHA
  10357.     makestr(&(optlist[noptlist++]),"ALPHA");
  10358. #endif
  10359. #ifdef __ALPHA
  10360.     makestr(&(optlist[noptlist++]),"__ALPHA");
  10361. #endif
  10362. #ifdef __alpha
  10363.     makestr(&(optlist[noptlist++]),"__alpha");
  10364. #endif
  10365. #ifdef __AXP
  10366.     makestr(&(optlist[noptlist++]),"__AXP");
  10367. #endif
  10368. #ifdef AXP
  10369.     makestr(&(optlist[noptlist++]),"AXP");
  10370. #endif
  10371. #ifdef axp
  10372.     makestr(&(optlist[noptlist++]),"axp");
  10373. #endif
  10374. #ifdef __ALPHA__
  10375.     makestr(&(optlist[noptlist++]),"__ALPHA__");
  10376. #endif
  10377. #ifdef __alpha__
  10378.     makestr(&(optlist[noptlist++]),"__alpha__");
  10379. #endif
  10380. #ifdef sun
  10381.     makestr(&(optlist[noptlist++]),"sun");
  10382. #endif
  10383. #ifdef sun3
  10384.     makestr(&(optlist[noptlist++]),"sun3");
  10385. #endif
  10386. #ifdef sun386
  10387.     makestr(&(optlist[noptlist++]),"sun386");
  10388. #endif
  10389. #ifdef _SUN
  10390.     makestr(&(optlist[noptlist++]),"_SUN");
  10391. #endif
  10392. #ifdef sun4
  10393.     makestr(&(optlist[noptlist++]),"sun4");
  10394. #endif
  10395. #ifdef sparc
  10396.     makestr(&(optlist[noptlist++]),"sparc");
  10397. #endif
  10398. #ifdef _CRAY
  10399.     makestr(&(optlist[noptlist++]),"_CRAY");
  10400. #endif /* _CRAY */
  10401. #ifdef NEXT33
  10402.     makestr(&(optlist[noptlist++]),"NEXT33");
  10403. #endif
  10404. #ifdef NEXT
  10405.     makestr(&(optlist[noptlist++]),"NEXT");
  10406. #endif
  10407. #ifdef NeXT
  10408.     makestr(&(optlist[noptlist++]),"NeXT");
  10409. #endif
  10410. #ifdef MACH
  10411.     makestr(&(optlist[noptlist++]),"MACH");
  10412. #endif
  10413. #ifdef sgi
  10414.     makestr(&(optlist[noptlist++]),"sgi");
  10415. #endif
  10416. #ifdef M_SYS5
  10417.     makestr(&(optlist[noptlist++]),"M_SYS5");
  10418. #endif
  10419. #ifdef __SYSTEM_FIVE
  10420.     makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  10421. #endif
  10422. #ifdef sysV
  10423.     makestr(&(optlist[noptlist++]),"sysV");
  10424. #endif
  10425. #ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
  10426.     makestr(&(optlist[noptlist++]),"M_XENIX");
  10427. #endif
  10428. #ifdef M_UNIX                           /* SCO UNIX */
  10429.     makestr(&(optlist[noptlist++]),"M_UNIX");
  10430. #endif
  10431. #ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
  10432.     makestr(&(optlist[noptlist++]),"_M_UNIX");
  10433. #endif
  10434. #ifdef CK_SCOV5
  10435.     makestr(&(optlist[noptlist++]),"CK_SCOV5");
  10436. #endif
  10437. #ifdef SCO_OSR504
  10438.     makestr(&(optlist[noptlist++]),"SCO_OSR504");
  10439. #endif
  10440. #ifdef M_IA64
  10441.     makestr(&(optlist[noptlist++]),"M_IA64");
  10442. #endif
  10443. #ifdef _M_IA64
  10444.     makestr(&(optlist[noptlist++]),"_M_IA64");
  10445. #endif
  10446. #ifdef ia64
  10447.     makestr(&(optlist[noptlist++]),"ia64");
  10448. #endif
  10449. #ifdef _ia64
  10450.     makestr(&(optlist[noptlist++]),"_ia64");
  10451. #endif
  10452. #ifdef _ia64_
  10453.     makestr(&(optlist[noptlist++]),"_ia64_");
  10454. #endif
  10455. #ifdef M_I686
  10456.     makestr(&(optlist[noptlist++]),"M_I686");
  10457. #endif
  10458. #ifdef _M_I686
  10459.     makestr(&(optlist[noptlist++]),"_M_I686");
  10460. #endif
  10461. #ifdef i686
  10462.     makestr(&(optlist[noptlist++]),"i686");
  10463. #endif
  10464. #ifdef M_I586
  10465.     makestr(&(optlist[noptlist++]),"M_I586");
  10466. #endif
  10467. #ifdef _M_I586
  10468.     makestr(&(optlist[noptlist++]),"_M_I586");
  10469. #endif
  10470. #ifdef i586
  10471.     makestr(&(optlist[noptlist++]),"i586");
  10472. #endif
  10473. #ifdef M_I486
  10474.     makestr(&(optlist[noptlist++]),"M_I486");
  10475. #endif
  10476. #ifdef _M_I486
  10477.     makestr(&(optlist[noptlist++]),"_M_I486");
  10478. #endif
  10479. #ifdef i486
  10480.     makestr(&(optlist[noptlist++]),"i486");
  10481. #endif
  10482. #ifdef M_I386
  10483.     makestr(&(optlist[noptlist++]),"M_I386");
  10484. #endif
  10485. #ifdef _M_I386
  10486.     makestr(&(optlist[noptlist++]),"_M_I386");
  10487. #endif
  10488. #ifdef i386
  10489.     makestr(&(optlist[noptlist++]),"i386");
  10490. #endif
  10491. #ifdef i286
  10492.     makestr(&(optlist[noptlist++]),"i286");
  10493. #endif
  10494. #ifdef M_I286
  10495.     makestr(&(optlist[noptlist++]),"M_I286");
  10496. #endif
  10497. #ifdef mc68000
  10498.     makestr(&(optlist[noptlist++]),"mc68000");
  10499. #endif
  10500. #ifdef mc68010
  10501.     makestr(&(optlist[noptlist++]),"mc68010");
  10502. #endif
  10503. #ifdef mc68020
  10504.     makestr(&(optlist[noptlist++]),"mc68020");
  10505. #endif
  10506. #ifdef mc68030
  10507.     makestr(&(optlist[noptlist++]),"mc68030");
  10508. #endif
  10509. #ifdef mc68040
  10510.     makestr(&(optlist[noptlist++]),"mc68040");
  10511. #endif
  10512. #ifdef M_68000
  10513.     makestr(&(optlist[noptlist++]),"M_68000");
  10514. #endif
  10515. #ifdef M_68010
  10516.     makestr(&(optlist[noptlist++]),"M_68010");
  10517. #endif
  10518. #ifdef M_68020
  10519.     makestr(&(optlist[noptlist++]),"M_68020");
  10520. #endif
  10521. #ifdef M_68030
  10522.     makestr(&(optlist[noptlist++]),"M_68030");
  10523. #endif
  10524. #ifdef M_68040
  10525.     makestr(&(optlist[noptlist++]),"M_68040");
  10526. #endif
  10527. #ifdef m68k
  10528.     makestr(&(optlist[noptlist++]),"m68k");
  10529. #endif
  10530. #ifdef m88k
  10531.     makestr(&(optlist[noptlist++]),"m88k");
  10532. #endif
  10533. #ifdef pdp11
  10534.     makestr(&(optlist[noptlist++]),"pdp11");
  10535. #endif
  10536. #ifdef iAPX
  10537.     makestr(&(optlist[noptlist++]),"iAPX");
  10538. #endif
  10539. #ifdef hpux
  10540.     makestr(&(optlist[noptlist++]),"hpux");
  10541. #endif
  10542. #ifdef __hpux
  10543.     makestr(&(optlist[noptlist++]),"__hpux");
  10544. #endif
  10545. #ifdef __hp9000s800
  10546.     makestr(&(optlist[noptlist++]),"__hp9000s800");
  10547. #endif
  10548. #ifdef __hp9000s700
  10549.     makestr(&(optlist[noptlist++]),"__hp9000s700");
  10550. #endif
  10551. #ifdef __hp9000s500
  10552.     makestr(&(optlist[noptlist++]),"__hp9000s500");
  10553. #endif
  10554. #ifdef __hp9000s300
  10555.     makestr(&(optlist[noptlist++]),"__hp9000s300");
  10556. #endif
  10557. #ifdef __hp9000s200
  10558.     makestr(&(optlist[noptlist++]),"__hp9000s200");
  10559. #endif
  10560. #ifdef AIX
  10561.     makestr(&(optlist[noptlist++]),"AIX");
  10562. #endif
  10563. #ifdef _AIXFS
  10564.     makestr(&(optlist[noptlist++]),"_AIXFS");
  10565. #endif
  10566. #ifdef u370
  10567.     makestr(&(optlist[noptlist++]),"u370");
  10568. #endif
  10569. #ifdef u3b
  10570.     makestr(&(optlist[noptlist++]),"u3b");
  10571. #endif
  10572. #ifdef u3b2
  10573.     makestr(&(optlist[noptlist++]),"u3b2");
  10574. #endif
  10575. #ifdef multimax
  10576.     makestr(&(optlist[noptlist++]),"multimax");
  10577. #endif
  10578. #ifdef balance
  10579.     makestr(&(optlist[noptlist++]),"balance");
  10580. #endif
  10581. #ifdef ibmrt
  10582.     makestr(&(optlist[noptlist++]),"ibmrt");
  10583. #endif
  10584. #ifdef _IBMRT
  10585.     makestr(&(optlist[noptlist++]),"_IBMRT");
  10586. #endif
  10587. #ifdef ibmrs6000
  10588.     makestr(&(optlist[noptlist++]),"ibmrs6000");
  10589. #endif
  10590. #ifdef _AIX
  10591.     makestr(&(optlist[noptlist++]),"_AIX");
  10592. #endif /* _AIX */
  10593. #ifdef _IBMR2
  10594.     makestr(&(optlist[noptlist++]),"_IBMR2");
  10595. #endif
  10596. #ifdef UNIXWARE
  10597.     makestr(&(optlist[noptlist++]),"UNIXWARE");
  10598. #endif
  10599. #ifdef QNX
  10600.     makestr(&(optlist[noptlist++]),"QNX");
  10601. #ifdef __QNX__
  10602.     makestr(&(optlist[noptlist++]),"__QNX__");
  10603. #ifdef __16BIT__
  10604.     makestr(&(optlist[noptlist++]),"__16BIT__");
  10605. #endif
  10606. #ifdef CK_QNX16
  10607.     makestr(&(optlist[noptlist++]),"CK_QNX16");
  10608. #endif
  10609. #ifdef __32BIT__
  10610.     makestr(&(optlist[noptlist++]),"__32BIT__");
  10611. #endif
  10612. #ifdef CK_QNX32
  10613.     makestr(&(optlist[noptlist++]),"CK_QNX32");
  10614. #endif
  10615. #endif /* __QNX__ */
  10616. #endif /* QNX */
  10617.  
  10618. #ifdef QNX6
  10619.     makestr(&(optlist[noptlist++]),"QNX6");
  10620. #endif /* QNX6 */
  10621.  
  10622. #ifdef NEUTRINO
  10623.     makestr(&(optlist[noptlist++]),"NEUTRINO");
  10624. #endif /* NEUTRINO */
  10625.  
  10626. #ifdef __STRICT_BSD__
  10627.     makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  10628. #endif
  10629. #ifdef __STRICT_ANSI__
  10630.     makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  10631. #endif
  10632. #ifdef _ANSI_C_SOURCE
  10633.     makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  10634. #endif
  10635. #ifdef __STDC__
  10636.     makestr(&(optlist[noptlist++]),"__STDC__");
  10637. #endif
  10638. #ifdef __DECC
  10639.     makestr(&(optlist[noptlist++]),"__DECC");
  10640. #ifdef __DECC_VER
  10641.     sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  10642.     makestr(&(optlist[noptlist++]),line);
  10643. #endif /* __DECC_VER */
  10644. #endif /* __DECC */
  10645. #ifdef __CRTL_VER
  10646.     sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  10647.     makestr(&(optlist[noptlist++]),line);
  10648. #endif /* __CRTL_VER */
  10649. #ifdef __GNUC__                         /* gcc in ansi mode */
  10650.     makestr(&(optlist[noptlist++]),"__GNUC__");
  10651. #endif
  10652. #ifdef GNUC                             /* gcc in traditional mode */
  10653.     makestr(&(optlist[noptlist++]),"GNUC");
  10654. #endif
  10655. #ifdef __EGCS__                         /* egcs in ansi mode */
  10656.     makestr(&(optlist[noptlist++]),"__EGCS__");
  10657. #endif
  10658. #ifdef __egcs__                         /* egcs in ansi mode */
  10659.     makestr(&(optlist[noptlist++]),"__egcs__");
  10660. #endif
  10661. #ifdef __WATCOMC__
  10662.     makestr(&(optlist[noptlist++]),"__WATCOMC__");
  10663. #endif
  10664. #ifdef CK_ANSIC
  10665.     makestr(&(optlist[noptlist++]),"CK_ANSIC");
  10666. #endif
  10667. #ifdef CK_ANSILIBS
  10668.     makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  10669. #endif
  10670. #ifdef CKCONINTB4CB
  10671.     makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  10672. #endif /* CKCONINTB4CB */
  10673. #ifdef NOTERMCAP
  10674.     makestr(&(optlist[noptlist++]),"NOTERMCAP");
  10675. #endif /* NOTERMCAP */
  10676. #ifdef __GLIBC__
  10677.     makestr(&(optlist[noptlist++]),"__GLIBC__");
  10678. #endif
  10679. #ifdef _SC_JOB_CONTROL
  10680.     makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  10681. #endif
  10682. #ifdef _POSIX_JOB_CONTROL
  10683.     makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  10684. #endif
  10685. #ifdef SIG_I
  10686.     makestr(&(optlist[noptlist++]),"SIG_I");
  10687. #endif /* SIG_I */
  10688. #ifdef SIG_V
  10689.     makestr(&(optlist[noptlist++]),"SIG_V");
  10690. #endif /* SIG_V */
  10691. #ifdef CK_POSIX_SIG
  10692.     makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  10693. #endif
  10694. #ifdef SVR3JC
  10695.     makestr(&(optlist[noptlist++]),"SVR3JC");
  10696. #endif
  10697. #ifdef _386BSD
  10698.     makestr(&(optlist[noptlist++]),"_386BSD");
  10699. #endif
  10700. #ifdef _BSD
  10701.     makestr(&(optlist[noptlist++]),"_BSD");
  10702. #endif
  10703. #ifdef USE_MEMCPY
  10704.     makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  10705. #endif /* USE_MEMCPY */
  10706. #ifdef USE_LSTAT
  10707.     makestr(&(optlist[noptlist++]),"USE_LSTAT");
  10708. #endif /* USE_LSTAT */
  10709. #ifdef TERMIOX
  10710.     makestr(&(optlist[noptlist++]),"TERMIOX");
  10711. #endif /* TERMIOX */
  10712. #ifdef STERMIOX
  10713.     makestr(&(optlist[noptlist++]),"STERMIOX");
  10714. #endif /* STERMIOX */
  10715. #ifdef CK_CURSES
  10716.     makestr(&(optlist[noptlist++]),"CK_CURSES");
  10717. #endif /* CK_CURSES */
  10718. #ifdef CK_NEWTERM
  10719.     makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  10720. #endif /* CK_NEWTERM */
  10721. #ifdef CK_WREFRESH
  10722.     makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  10723. #endif /* CK_WREFRESH */
  10724. #ifdef CK_PCT_BAR
  10725.     makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  10726. #endif /* CK_PCT_BAR */
  10727. #ifdef CK_DTRCD
  10728.     makestr(&(optlist[noptlist++]),"CK_DTRCD");
  10729. #endif /* CK_DTRCD */
  10730. #ifdef CK_DTRCTS
  10731.     makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  10732. #endif /* CK_DTRCTS */
  10733. #ifdef CK_RTSCTS
  10734.     makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  10735. #endif /* CK_RTSCTS */
  10736. #ifdef POSIX_CRTSCTS
  10737.     makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  10738. #endif /* POSIX_CRTSCTS */
  10739. #ifdef FIXCRTSCTS
  10740.     makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  10741. #endif /* FIXCRTSCTS */
  10742. #ifdef HWPARITY
  10743.     makestr(&(optlist[noptlist++]),"HWPARITY");
  10744. #endif /* HWPARITY */
  10745. #ifdef CK_SYSINI
  10746. #ifdef CK_INI_A
  10747.     makestr(&(optlist[noptlist++]),"CK_INI_A");
  10748.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10749.     makestr(&(optlist[noptlist++]),line);
  10750. #else
  10751. #ifdef CK_INI_B
  10752.     makestr(&(optlist[noptlist++]),"CK_INI_B");
  10753.     ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10754.     makestr(&(optlist[noptlist++]),line);
  10755. #else
  10756.     makestr(&(optlist[noptlist++]),"CK_SYSINI");
  10757. #endif /* CK_INI_B */
  10758. #endif /* CK_INI_A */
  10759. #endif /* CK_DSYSINI */
  10760. #ifdef CK_DSYSINI
  10761.     makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  10762. #endif /* CK_DSYSINI */
  10763. #ifdef CK_TTGWSIZ
  10764.     makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  10765. #endif /* CK_TTGWSIZ */
  10766. #ifdef CK_NAWS
  10767.     makestr(&(optlist[noptlist++]),"CK_NAWS");
  10768. #endif /* CK_NAWS */
  10769. #ifdef MDMHUP
  10770.     makestr(&(optlist[noptlist++]),"MDMHUP");
  10771. #endif /* MDMHUP */
  10772. #ifdef HUP_CLOSE_POSIX
  10773.     makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  10774. #endif /* HUP_CLOSE_POSIX */
  10775. #ifdef NO_HUP_CLOSE_POSIX
  10776.     makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  10777. #endif /* NO_HUP_CLOSE_POSIX */
  10778. #ifdef DCMDBUF
  10779.     makestr(&(optlist[noptlist++]),"DCMDBUF");
  10780. #endif /* DCMDBUF */
  10781. #ifdef CK_RECALL
  10782.     makestr(&(optlist[noptlist++]),"CK_RECALL");
  10783. #endif /* CK_RECALL */
  10784. #ifdef BROWSER
  10785.     makestr(&(optlist[noptlist++]),"BROWSER");
  10786. #endif /* BROWSER */
  10787. #ifdef CLSOPN
  10788.     makestr(&(optlist[noptlist++]),"CLSOPN");
  10789. #endif /* CLSOPN */
  10790. #ifdef STRATUS
  10791.     makestr(&(optlist[noptlist++]),"STRATUS");
  10792. #endif /* STRATUS */
  10793. #ifdef __VOS__
  10794.     makestr(&(optlist[noptlist++]),"__VOS__");
  10795. #endif /* __VOS__ */
  10796. #ifdef STRATUSX25
  10797.     makestr(&(optlist[noptlist++]),"STRATUSX25");
  10798. #endif /* STRATUSX25 */
  10799. #ifdef OS2MOUSE
  10800.     makestr(&(optlist[noptlist++]),"OS2MOUSE");
  10801. #endif /* OS2MOUSE */
  10802. #ifdef CK_REXX
  10803.     makestr(&(optlist[noptlist++]),"CK_REXX");
  10804. #endif /* CK_REXX */
  10805. #ifdef CK_TIMERS
  10806.     makestr(&(optlist[noptlist++]),"CK_TIMERS");
  10807. #endif /* CK_TIMERS */
  10808. #ifdef TTSPDLIST
  10809.     makestr(&(optlist[noptlist++]),"TTSPDLIST");
  10810. #endif /* TTSPDLIST */
  10811. #ifdef CK_PERMS
  10812.     makestr(&(optlist[noptlist++]),"CK_PERMS");
  10813. #endif /* CK_PERMS */
  10814. #ifdef CKTUNING
  10815.     makestr(&(optlist[noptlist++]),"CKTUNING");
  10816. #endif /* CKTUNING */
  10817. #ifdef NEWFTP
  10818.     makestr(&(optlist[noptlist++]),"NEWFTP");
  10819. #endif /* NEWFTP */
  10820. #ifdef SYSFTP
  10821.     makestr(&(optlist[noptlist++]),"SYSFTP");
  10822. #endif /* SYSFTP */
  10823. #ifdef NOFTP
  10824.     makestr(&(optlist[noptlist++]),"NOFTP");
  10825. #endif /* NOFTP */
  10826. #ifdef CKHTTP
  10827.     makestr(&(optlist[noptlist++]),"CKHTTP");
  10828. #endif /* CKHTTP */
  10829. #ifdef NOHTTP
  10830.     makestr(&(optlist[noptlist++]),"NOHTTP");
  10831. #endif /* NOHTTP */
  10832. #ifdef CKROOT
  10833.     makestr(&(optlist[noptlist++]),"CKROOT");
  10834. #endif /* CKROOT */
  10835. #ifdef CKREALPATH
  10836.     makestr(&(optlist[noptlist++]),"CKREALPATH");
  10837. #endif /* CKREALPATH */
  10838. #ifdef STREAMING
  10839.     makestr(&(optlist[noptlist++]),"STREAMING");
  10840. #endif /* STREAMING */
  10841. #ifdef UNPREFIXZERO
  10842.     makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  10843. #endif /* UNPREFIXZERO */
  10844. #ifdef CKREGEX
  10845.     makestr(&(optlist[noptlist++]),"CKREGEX");
  10846. #endif /* CKREGEX */
  10847. #ifdef ZXREWIND
  10848.     makestr(&(optlist[noptlist++]),"ZXREWIND");
  10849. #endif /* ZXREWIND */
  10850. #ifdef CKSYSLOG
  10851.     makestr(&(optlist[noptlist++]),"CKSYSLOG");
  10852. #endif /* CKSYSLOG */
  10853. #ifdef SYSLOGLEVEL
  10854.     sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  10855.     makestr(&(optlist[noptlist++]),line);
  10856. #endif /* SYSLOGLEVEL */
  10857. #ifdef NOSEXP
  10858.     makestr(&(optlist[noptlist++]),"NOSEXP");
  10859. #endif /* NOSEXP */
  10860. #ifdef CKLEARN
  10861.     makestr(&(optlist[noptlist++]),"CKLEARN");
  10862. #else
  10863. #ifdef NOLOEARN
  10864.     makestr(&(optlist[noptlist++]),"NOLOEARN");
  10865. #endif /* NOLOEARN */
  10866. #endif /* CKLEARN */
  10867. #ifdef NOFLOAT
  10868.     makestr(&(optlist[noptlist++]),"NOFLOAT");
  10869. #else
  10870. #ifdef FNFLOAT
  10871.     makestr(&(optlist[noptlist++]),"FNFLOAT");
  10872. #endif /* FNFLOAT */
  10873. #ifdef CKFLOAT
  10874. #ifdef GFTIMER
  10875.     makestr(&(optlist[noptlist++]),"GFTIMER");
  10876. #endif /* GFTIMER */
  10877. #ifdef CKFLOAT_S
  10878.     ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  10879.     makestr(&(optlist[noptlist++]),line);
  10880. #else
  10881.     makestr(&(optlist[noptlist++]),"CKFLOAT");
  10882. #endif /* CKFLOAT_S */
  10883. #endif /* CKFLOAT */
  10884. #endif /* NOFLOAT */
  10885.  
  10886. #ifdef SSH
  10887.     makestr(&(optlist[noptlist++]),"SSH");
  10888. #endif /* SSH */
  10889. #ifdef NETDLL
  10890.     makestr(&(optlist[noptlist++]),"NETDLL");
  10891. #endif /* NETDLL */
  10892. #ifdef NETFILE
  10893.     makestr(&(optlist[noptlist++]),"NETFILE");
  10894. #endif /* NETFILE */
  10895. #ifdef CK_TAPI
  10896.     makestr(&(optlist[noptlist++]),"CK_TAPI");
  10897. #endif /* CK_TAPI */
  10898. #ifdef CK_SSL
  10899.     makestr(&(optlist[noptlist++]),"CK_SSL");
  10900. #endif /* CK_SSL */
  10901.  
  10902.     debug(F101,"initoptlist noptlist","",noptlist);
  10903.     sh_sort(optlist,NULL,noptlist,0,0,0);
  10904. }
  10905.  
  10906. int
  10907. shofea() {
  10908.     int i;
  10909.     int flag = 0;
  10910.     int lines = 1;
  10911. #ifdef FNFLOAT
  10912.     extern int fp_digits, fp_rounding;
  10913. #endif /* FNFLOAT */
  10914.     extern int byteorder;
  10915.     printf("%s\n",versio);
  10916.     if (inserver)
  10917.       return(1);
  10918.     debug(F101,"shofea NOPTLIST","",NOPTLIST);
  10919.     initoptlist();
  10920.     debug(F101,"shofea noptlist","",noptlist);
  10921. #ifdef OS2
  10922. #ifdef NT
  10923. #ifdef _M_ALPHA
  10924.     printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  10925. #else /* _M_ALPHA */
  10926. #ifdef _M_PPC
  10927.     printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  10928. #else /* _M_PPC */
  10929. #ifdef _M_MRX000
  10930.     printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  10931. #else /* _M_MRX000 */
  10932. #ifdef _M_IX86
  10933.     printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  10934. #else /* _M_IX86 */
  10935.     UNKNOWN WINDOWS PLATFORM
  10936. #endif /* _M_IX86 */
  10937. #endif /* _M_MRX000 */
  10938. #endif /* _M_PPC */
  10939. #endif /* _M_ALPHA */
  10940. #else /* NT */
  10941. #ifdef M_I286
  10942.     printf("IBM OS/2 16-bit.\n");
  10943. #else
  10944.     printf("IBM OS/2 32-bit.\n");
  10945. #endif /* M_I286 */
  10946. #endif /* NT */
  10947.     lines++;
  10948. #endif /* OS2 */
  10949.     printf("\n");
  10950.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10951.     printf("Major optional features included:\n");
  10952.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10953.  
  10954. #ifdef NETCONN
  10955.     printf(" Network support (type SHOW NET for further info)\n");
  10956.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10957. #ifdef IKS_OPTION
  10958.     printf(" Telnet Kermit Option\n");
  10959.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10960. #endif /* IKS_OPTION */
  10961. #ifdef CK_AUTHENTICATION
  10962.     printf(" Telnet Authentication Option\n");
  10963.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10964. #ifdef CK_KERBEROS
  10965. #ifdef KRB4
  10966. #ifdef KRB5
  10967.     printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  10968.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10969. #else /* KRB5 */
  10970.     printf(" Kerberos(TM) IV authentication\n");
  10971.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10972. #endif /* KRB5 */
  10973. #else /* KRB4 */
  10974. #ifdef KRB5
  10975.     printf(" Kerberos(TM) V authentication\n");
  10976.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10977. #endif /* KRB5 */
  10978. #endif /* KRB4 */
  10979. #endif /* CK_KERBEROS */
  10980. #ifdef CK_SRP
  10981.     printf(" SRP(TM) (Secure Remote Password) authentication\n");
  10982.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10983. #endif /* CK_SRP */
  10984. #ifdef CK_SSL
  10985.     printf(" Secure Sockets Layer (SSL)\n");
  10986.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10987.     printf(" Transport Layer Security (TLS)\n");
  10988.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10989. #endif /* CK_SSL */
  10990. #ifdef SSHBUILTIN
  10991.     printf(" Secure Shell (SSH) [internal]\n");
  10992.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10993. #endif /* SSHBUILTIN */
  10994. #ifdef SSHCMD
  10995.     printf(" Secure Shell (SSH) [external]\n");
  10996.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  10997. #endif /* SSHCMD */
  10998. #ifdef CK_ENCRYPTION
  10999.     printf(" Telnet Encryption Option\n");
  11000.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11001. #ifdef CK_DES
  11002.     printf(" DES Encryption\n");
  11003.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11004. #endif /* CK_DES */
  11005. #ifdef CK_CAST
  11006.     printf(" CAST Encryption\n");
  11007.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11008. #endif /* CK_CAST */
  11009. #endif /* CK_ENCRYPTION */
  11010. #endif /* CK_AUTHENTICATION */
  11011. #ifdef CK_FORWARD_X
  11012.     printf(" X Windows forwarding\n");
  11013.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11014. #endif /* CK_FORWARD_X */
  11015. #ifdef TN_COMPORT
  11016.     printf(" Telnet Remote Com Port Control Option\n");
  11017.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11018. #endif /* TN_COMPORT */
  11019. #ifdef CK_SOCKS
  11020. #ifdef CK_SOCKS5
  11021.     printf(" SOCKS 5\n");
  11022.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11023. #else /* CK_SOCKS5 */
  11024.     printf(" SOCKS 4\n");
  11025.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11026. #endif /* CK_SOCKS5 */
  11027. #endif /* CK_SOCKS */
  11028. #ifdef NEWFTP
  11029.     printf(" Built-in FTP client\n");
  11030.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11031. #endif /* NEWFTP */
  11032. #ifdef CKHTTP
  11033.     printf(" Built-in HTTP client\n");
  11034.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11035. #endif /* CKHTTP */
  11036. #endif /* NETCONN */
  11037.  
  11038. #ifdef CK_RTSCTS
  11039.     printf(" Hardware flow control\n");
  11040.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11041. #endif /* CK_RTSCTS */
  11042.  
  11043. #ifdef CK_XYZ
  11044. #ifdef XYZ_INTERNAL
  11045.     printf(" Built-in XYZMODEM protocols\n");
  11046. #else
  11047.     printf(" External XYZMODEM protocol support\n");
  11048. #endif /* XYZ_INTERNAL */
  11049.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11050. #endif /* CK_XYZ */
  11051.  
  11052. #ifndef NOCSETS
  11053.     printf(" Latin-1 (West European) character-set translation\n");
  11054.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11055. #ifdef LATIN2
  11056.     printf(" Latin-2 (East European) character-set translation\n");
  11057.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11058. #endif /* LATIN2 */
  11059. #ifdef CYRILLIC
  11060.     printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11061.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11062. #endif /* CYRILLIC */
  11063. #ifdef GREEK
  11064.     printf(" Greek character-set translation\n");
  11065.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11066. #endif /* GREEK */
  11067. #ifdef HEBREW
  11068.     printf(" Hebrew character-set translation\n");
  11069.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11070. #endif /* HEBREW */
  11071. #ifdef KANJI
  11072.     printf(" Japanese character-set translation\n");
  11073.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11074. #endif /* KANJI */
  11075. #ifdef UNICODE
  11076.     printf(" Unicode character-set translation\n");
  11077.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11078. #endif /* UNICODE */
  11079. #ifdef CKOUNI
  11080.     if (isunicode())
  11081.       printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11082.     else
  11083.       printf(" Unicode translation for Terminal Character-Sets\n");
  11084.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11085. #endif /* CKOUNI */
  11086. #endif /* NOCSETS */
  11087.  
  11088. #ifdef NETPTY
  11089.     printf(" Pseudoterminal control\n");
  11090.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11091. #endif /* NETPTY */
  11092.  
  11093. #ifdef CK_REDIR
  11094.     printf(" REDIRECT command\n");
  11095.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11096. #endif /* CK_REDIR */
  11097.  
  11098. #ifdef CK_RESEND
  11099.     printf(" RESEND command\n");
  11100.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11101. #endif /* CK_RESEND */
  11102.  
  11103. #ifndef NOXFER
  11104. #ifdef CK_CURSES
  11105.     printf(" Fullscreen file transfer display\n");
  11106.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11107. #endif /* CK_CURSES */
  11108. #endif /* NOXFER */
  11109.  
  11110. #ifdef CK_SPEED
  11111.     printf(" Control-character unprefixing\n");
  11112.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11113. #endif /* CK_SPEED */
  11114.  
  11115. #ifdef STREAMING
  11116.     printf(" Streaming\n");
  11117.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11118. #endif /* STREAMING */
  11119.  
  11120. #ifdef CK_AUTODL
  11121.     printf(" Autodownload\n");
  11122.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11123. #endif /* CK_AUTODL */
  11124.  
  11125. #ifdef OS2MOUSE
  11126.     printf(" Mouse support\n");
  11127.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11128. #endif /* OS2MOUSE */
  11129.  
  11130. #ifdef CK_REXX
  11131.     printf(" REXX script language interface\n");
  11132.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11133. #endif /* CK_REXX */
  11134.  
  11135. #ifdef IKSD
  11136. #ifdef CK_LOGIN
  11137.     printf(" Internet Kermit Service with user login support\n");
  11138. #else /* CK_LOGIN */
  11139.     printf(" Internet Kermit Service without user login support\n");
  11140. #endif /* CK_LOGIN */
  11141.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11142. #endif /* IKSD */
  11143.  
  11144.     printf("\n");
  11145.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11146.     printf("Major optional features not included:\n");
  11147.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11148.  
  11149. #ifdef NOXFER
  11150.     printf(" No file-transfer protocols\n");
  11151.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11152.     flag = 1;
  11153. #else
  11154. #ifndef CK_CURSES
  11155. #ifndef MAC
  11156.     printf(" No fullscreen file transfer display\n");
  11157.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11158.     flag = 1;
  11159. #endif /* MAC */
  11160. #endif /* CK_CURSES */
  11161.  
  11162. #ifdef NOSERVER
  11163.     printf(" No server mode\n");
  11164.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11165.     flag = 1;
  11166. #endif /* NOSERVER */
  11167.  
  11168. #ifndef CK_SPEED
  11169.     printf(" No control-character unprefixing\n");
  11170.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11171.     flag = 1;
  11172. #endif /* CK_SPEED */
  11173.  
  11174. #ifndef STREAMING
  11175.     printf(" No streaming\n");
  11176.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11177.     flag = 1;
  11178. #endif /* STREAMING */
  11179.  
  11180. #ifndef CK_AUTODL
  11181.     printf(" No autodownload\n");
  11182.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11183.     flag = 1;
  11184. #endif /* CK_AUTODL */
  11185.  
  11186. #ifndef CK_XYZ
  11187.     printf(" No built-in XYZMODEM protocols\n");
  11188.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11189.     flag = 1;
  11190. #endif /* CK_XYZ */
  11191.  
  11192. #ifdef NOTLOG
  11193.     printf(" No transaction log\n");
  11194.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11195.     flag = 1;
  11196. #endif /* NOTLOG */
  11197. #endif /* NOXFER */
  11198.  
  11199. #ifdef NODEBUG
  11200.     printf(" No debugging\n");
  11201.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11202.     flag = 1;
  11203. #endif /* NODEBUG */
  11204.  
  11205. #ifdef NOHELP
  11206.     printf(" No built-in help\n");
  11207.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11208.     flag = 1;
  11209. #endif /* NOHELP */
  11210.  
  11211. #ifdef NOLOCAL
  11212.     printf(" No making connections\n");
  11213.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11214.     flag = 1;
  11215. #else
  11216. #ifndef NETCONN
  11217.     printf(" No network support\n");
  11218.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11219.     flag = 1;
  11220. #else /* NETCONN */
  11221. #ifndef IKS_OPTION
  11222.     printf(" No Telnet Kermit Option\n");
  11223.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11224.     flag = 1;
  11225. #endif /* IKS_OPTION */
  11226. #endif /* NETCONN */
  11227.  
  11228. #ifdef NOSSH
  11229.     printf(" No Secure Shell (SSH)\n");
  11230.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11231. #endif /* NOSSH */
  11232. #ifndef CK_AUTHENTICATION
  11233.     printf(" No Kerberos(TM) authentication\n");
  11234.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11235.     printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11236.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11237.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11238.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11239.     printf(" No Transport Layer Security (TLS) protocol\n");
  11240.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11241.     printf(" No encryption\n");
  11242.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11243.     flag = 1;
  11244. #else /* CK_AUTHENTICATION */
  11245. #ifndef CK_KERBEROS
  11246.     printf(" No Kerberos(TM) authentication\n");
  11247.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11248.     flag = 1;
  11249. #else /* CK_KERBEROS */
  11250. #ifndef KRB4
  11251.     printf(" No Kerberos(TM) IV authentication\n");
  11252.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11253.     flag = 1;
  11254. #endif /* KRB4 */
  11255. #ifndef KRB5
  11256.     printf(" No Kerberos(TM) V authentication\n");
  11257.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11258.     flag = 1;
  11259. #endif /* KRB5 */
  11260. #endif /* CK_KERBEROS */
  11261. #ifndef CK_SRP
  11262.     printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11263.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11264.     flag = 1;
  11265. #endif /* CK_SRP */
  11266. #ifndef CK_SSL
  11267.     printf(" No Secure Sockets Layer (SSL) protocol\n");
  11268.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11269.     printf(" No Transport Layer Security (TLS) protocol\n");
  11270.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11271.     flag = 1;
  11272. #endif /* CK_SSL */
  11273. #ifndef CK_ENCRYPTION
  11274.     printf(" No encryption\n");
  11275.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11276.     flag = 1;
  11277. #else /* CK_ENCRYPTION */
  11278. #ifndef OS2
  11279. #ifndef CK_DES
  11280.     printf(" No DES encryption\n");
  11281.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11282.     flag = 1;
  11283. #endif /* CK_DES */
  11284. #ifndef CK_CAST
  11285.     printf(" No CAST encryption\n");
  11286.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11287.     flag = 1;
  11288. #endif /* CK_CAST */
  11289. #endif /* OS2 */
  11290. #endif /* CK_ENCRYPTION */
  11291. #endif /* CK_AUTHENTICATION */
  11292. #ifndef CK_FORWARD_X
  11293.     printf(" No X Windows forwarding\n");
  11294.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11295. #endif /* CK_FORWARD_X */
  11296. #ifndef TN_COMPORT
  11297.     printf(" No Telnet Remote Com Port Control Option\n");
  11298.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11299. #endif /* TN_COMPORT */
  11300. #ifndef CK_SOCKS
  11301.     printf(" No SOCKS\n");
  11302.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11303. #endif /* CK_SOCKS */
  11304. #ifndef NEWFTP
  11305.     printf(" No built-in FTP client\n");
  11306.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11307. #endif /* NEWFTP */
  11308. #ifdef NOHTTP
  11309.     printf(" No built-in HTTP client\n");
  11310.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11311. #endif /* NOHTTP */
  11312.  
  11313. #ifdef NODIAL
  11314.     printf(" No DIAL command\n");
  11315.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11316.     flag = 1;
  11317. #else
  11318. #ifdef MINIDIAL
  11319.     printf(" Support for most modem types excluded\n");
  11320.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11321.     flag = 1;
  11322. #endif /* MINIDIAL */
  11323. #endif /* NODIAL */
  11324. #endif /* NOLOCAL */
  11325.  
  11326. #ifndef CK_RTSCTS
  11327. #ifndef MAC
  11328.     printf(" No hardware flow control\n");
  11329.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11330.     flag = 1;
  11331. #endif /* MAC */
  11332. #endif /* CK_RTSCTS */
  11333.  
  11334. #ifdef NOXMIT
  11335.     printf(" No TRANSMIT command\n");
  11336.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11337.     flag = 1;
  11338. #endif /* NOXMIT */
  11339.  
  11340. #ifdef NOSCRIPT
  11341.     printf(" No SCRIPT command\n");
  11342.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11343.     flag = 1;
  11344. #endif /* NOSCRIPT */
  11345.  
  11346. #ifdef NOSPL
  11347.     printf(" No script programming features\n");
  11348.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11349.     flag = 1;
  11350. #endif /* NOSPL */
  11351.  
  11352. #ifdef NOCSETS
  11353.     printf(" No character-set translation\n");
  11354.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11355.     flag = 1;
  11356. #else
  11357.  
  11358. #ifndef LATIN2
  11359.     printf(" No Latin-2 character-set translation\n");
  11360.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11361.     flag = 1;
  11362. #endif /* LATIN2 */
  11363.  
  11364. #ifdef NOGREEK
  11365.     printf(" No Greek character-set translation\n");
  11366.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11367.     flag = 1;
  11368. #endif /* NOGREEK */
  11369.  
  11370. #ifdef NOHEBREW
  11371.     printf(" No Hebrew character-set translation\n");
  11372.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11373.     flag = 1;
  11374. #endif /* NOHEBREW */
  11375.  
  11376. #ifdef NOUNICODE
  11377.     printf(" No Unicode character-set translation\n");
  11378.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11379.     flag = 1;
  11380. #endif /* NOUNICODE */
  11381.  
  11382. #ifdef NOCYRIL
  11383.     printf(" No Cyrillic character-set translation\n");
  11384.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11385.     flag = 1;
  11386. #endif /* NOCYRIL */
  11387.  
  11388. #ifndef KANJI
  11389.     printf(" No Kanji character-set translation\n");
  11390.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11391.     flag = 1;
  11392. #endif /* KANJI */
  11393. #endif /* NOCSETS */
  11394.  
  11395. #ifdef NOCMDL
  11396.     printf(" No command-line arguments\n");
  11397.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11398.     flag = 1;
  11399. #endif /* NOCMDL */
  11400.  
  11401. #ifdef NOPUSH
  11402.     printf(" No escape to system\n");
  11403.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11404.     flag = 1;
  11405. #endif /* NOPUSH */
  11406.  
  11407. #ifdef NOJC
  11408. #ifdef UNIX
  11409.     printf(" No UNIX job control\n");
  11410.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11411.     flag = 1;
  11412. #endif /* UNIX */
  11413. #endif /* NOJC */
  11414.  
  11415. #ifdef NOSETKEY
  11416.     printf(" No SET KEY command\n");
  11417.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11418.     flag = 1;
  11419. #endif /* NOSETKEY */
  11420.  
  11421. #ifndef CK_REDIR
  11422.     printf(" No REDIRECT or PIPE command\n");
  11423.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11424.     flag = 1;
  11425. #endif /* CK_REDIR */
  11426.  
  11427. #ifdef UNIX
  11428. #ifndef NETPTY
  11429.     printf(" No pseudoterminal control\n");
  11430.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11431.     flag = 1;
  11432. #endif /* NETPTY */
  11433. #endif /* UNIX */
  11434.  
  11435. #ifndef CK_RESEND
  11436.     printf(" No RESEND command\n");
  11437.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11438.     flag = 1;
  11439. #endif /* CK_RESEND */
  11440.  
  11441. #ifdef OS2
  11442. #ifdef __32BIT__
  11443. #ifndef OS2MOUSE
  11444.     printf(" No Mouse support\n");
  11445.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11446.     flag = 1;
  11447. #endif /* __32BIT__ */
  11448. #endif /* OS2 */
  11449. #endif /* OS2MOUSE */
  11450.  
  11451. #ifdef OS2
  11452. #ifndef NT
  11453. #ifndef CK_REXX
  11454.     printf(" No REXX script language interface\n");
  11455.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11456.     flag = 1;
  11457. #endif /* CK_REXX */
  11458. #endif /* NT */
  11459. #endif /* OS2 */
  11460.  
  11461. #ifndef IKSD
  11462.     printf(" No Internet Kermit Service\n");
  11463.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11464.     flag = 1;
  11465. #endif /* IKSD */
  11466.  
  11467.     if (flag == 0) {
  11468.         printf(" None\n");
  11469.         if (++lines > cmd_rows - 3)
  11470.           { if (!askmore()) return(1); else lines = 0; }
  11471.     }
  11472.     printf("\n");
  11473.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11474.  
  11475. #ifdef CK_UTSNAME
  11476.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11477.     printf("Host info:\n");
  11478.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11479.     printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  11480.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11481.     printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  11482.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11483.     printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  11484.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11485.     printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  11486.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11487.     printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  11488.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11489.     printf("\n");
  11490.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11491. #endif /* CK_UTSNAME */
  11492.  
  11493. /*
  11494.   Print compile-time (-D) options, as well as C preprocessor
  11495.   predefined symbols that might affect us...
  11496. */
  11497. #ifdef KTARGET
  11498.     {
  11499.         char * s;                       /* Makefile target */
  11500.         s = KTARGET;
  11501.         if (!s) s = "";
  11502.         if (!*s) s = "(unknown)";
  11503.         printf("\n");
  11504.         if (++lines > cmd_rows - 3) {
  11505.             if (!askmore()) return(1); else lines = 0;
  11506.         }
  11507.         printf("Target: %s\n", s);
  11508.         if (++lines > cmd_rows - 3) {
  11509.             if (!askmore()) return(1); else lines = 0;
  11510.         }
  11511.     }
  11512. #endif /* KTARGET */
  11513.  
  11514. #ifdef __VERSION__
  11515. #ifdef __GNUC__
  11516.     printf("GCC version: %s\n", __VERSION__);
  11517. #else
  11518.     printf("Compiler version: %s\n", __VERSION__);
  11519. #endif /* __GNUC__ */
  11520.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11521. #endif /* __VERSION__ */
  11522.  
  11523. #ifdef __DATE__                         /* GNU and other ANSI */
  11524. #ifdef __TIME__
  11525.     printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  11526. #else
  11527.     printf("Compiled %s, options:\n", __DATE__);
  11528. #endif /* __TIME__ */
  11529. #else /* !__DATE__ */
  11530.     printf("Compiler options:\n");
  11531. #endif /* __DATE__ */
  11532.     if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11533.  
  11534.     for (i = 0; i < noptlist; i++)      /* Print sorted option list */
  11535.       if (!prtopt(&lines,optlist[i]))
  11536.         return(0);
  11537.  
  11538.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11539.  
  11540. /* Sizes of data types */
  11541.  
  11542.     ckmakmsg(line,
  11543.              LINBUFSIZ,
  11544.              "byte order: ",
  11545.              byteorder ? "little" : "big",
  11546.              " endian",
  11547.              NULL
  11548.              );
  11549.     if (!prtopt(&lines,line)) return(0);
  11550.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11551.     sprintf(line,"sizeofs: int=%ld",sizeof(int)); /* SAFE */
  11552.     if (!prtopt(&lines,line)) return(0);
  11553.     sprintf(line,"long=%ld",sizeof(long)); /* SAFE */
  11554.     if (!prtopt(&lines,line)) return(0);
  11555.     sprintf(line,"short=%ld",sizeof(short)); /* SAFE */
  11556.     if (!prtopt(&lines,line)) return(0);
  11557.     sprintf(line,"char=%ld",sizeof(char)); /* SAFE */
  11558.     if (!prtopt(&lines,line)) return(0);
  11559.     sprintf(line,"char*=%ld",sizeof(char *)); /* SAFE */
  11560.     if (!prtopt(&lines,line)) return(0);
  11561. #ifdef LONG_MAX
  11562.     sprintf(line,"LONG_MAX=%d",LONG_MAX); /* SAFE */
  11563. #endif /* LONG_MAX */
  11564. #ifdef CKFLOAT
  11565.     sprintf(line,"float=%ld",sizeof(float)); /* SAFE */
  11566.     if (!prtopt(&lines,line)) return(0);
  11567.     sprintf(line,"double=%ld",sizeof(double)); /* SAFE */
  11568.     if (!prtopt(&lines,line)) return(0);
  11569. #ifdef FNFLOAT
  11570.     if (!prtopt(&lines,"")) return(0);  /* Start a new section */
  11571.     if (!prtopt(&lines,"floating-point:")) return(0);
  11572.     sprintf(line,"precision=%d",fp_digits); /* SAFE */
  11573.     if (!prtopt(&lines,line)) return(0);
  11574.     sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  11575.     if (!prtopt(&lines,line)) return(0);
  11576. #endif /* FNFLOAT */
  11577. #endif /* CKFLOAT */
  11578.  
  11579.     prtopt(&lines,"");
  11580.     return(0);
  11581. }
  11582. #endif /* NOSHOW */
  11583. #endif /* NOICP */
  11584.