home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku206.zip / ckuusr.c < prev    next >
C/C++ Source or Header  |  2002-10-23  |  338KB  |  12,246 lines

  1. #ifdef SSHTEST
  2. #define SSHBUILTIN
  3. #endif /* SSHTEST */
  4.  
  5. #include "ckcsym.h"
  6. char *userv = "User Interface 8.0.261, 11 Sep 2002";
  7.  
  8. /*  C K U U S R --  "User Interface" for C-Kermit (Part 1)  */
  9.  
  10. /*
  11.   Author: Frank da Cruz <fdc@columbia.edu>
  12.   Columbia University Academic Information Systems, New York City.
  13.  
  14.   Copyright (C) 1985, 2002,
  15.     Trustees of Columbia University in the City of New York.
  16.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  17.     copyright text in the ckcmai.c module for disclaimer and permissions.
  18. */
  19.  
  20. /*
  21.   Originally the entire user interface was in one module, ckuusr.c.  Over
  22.   the years it has been split into many modules: ckuus2.c, ckuus3.c, ...,
  23.   ckuus7.c.  ckuus2.c contains the HELP command parser and help-text strings;
  24.   ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains
  25.   routines needed by both the command-line interface and the interactive
  26.   command parser.
  27. */
  28.  
  29. /*
  30.   The ckuus*.c modules depend on the existence of C library features like
  31.   fopen, fgets, feof, (f)printf, argv/argc, etc.  Other functions that are
  32.   likely to vary among different platforms -- like setting terminal modes or
  33.   interrupts -- are invoked via calls to functions that are defined in the
  34.   system- dependent modules, ck?[ft]io.c.  The command line parser processes
  35.   any arguments found on the command line, as passed to main() via argv/argc.
  36.   The interactive parser uses the facilities of the cmd package (developed for
  37.   this program, but usable by any program).  Any command parser may be
  38.   substituted for this one.  The only requirements for the Kermit command
  39.   parser are these:
  40.  
  41.   . Set parameters via global variables like duplex, speed, ttname, etc.  See
  42.     ckmain.c for the declarations and descriptions of these variables.
  43.  
  44.   . If a command can be executed without the use of Kermit protocol, then
  45.     execute the command directly and set the variable sstate to 0. Examples
  46.     include 'set' commands, local directory listings, the 'connect' command.
  47.  
  48.   . If a command requires the Kermit protocol, set the following variables:
  49.  
  50.      sstate                             string data
  51.        'x' (enter server mode)            (none)
  52.        'r' (send a 'get' command)         cmarg, cmarg2
  53.        'v' (enter receive mode)           cmarg2
  54.        'g' (send a generic command)       cmarg
  55.        's' (send files)                   nfils, cmarg & cmarg2 OR cmlist
  56.        'c' (send a remote host command)   cmarg
  57.  
  58.      cmlist is an array of pointers to strings.
  59.      cmarg, cmarg2 are pointers to strings.
  60.      nfils is an integer.
  61.  
  62.      cmarg can be a filename string (possibly wild), or
  63.     a pointer to a prefabricated generic command string, or
  64.     a pointer to a host command string.
  65.      cmarg2 is an "as-name" - the name to send file(s) under, or
  66.     the name under which to store incoming file(s); must not be wild.
  67.     A null or empty value means to use the file's own name.
  68.      cmlist is a list of filenames, such as passed via argv.
  69.      nfils is an integer, interpreted as follows:
  70.        -1: filespec (possibly wild) in cmarg, must be expanded internally.
  71.     0: send from stdin (standard input).
  72.        >0: number of files to send, from cmlist.
  73.  
  74.   The screen() function is used to update the screen during file transfer.
  75.   The tlog() function writes to a transaction log.
  76.   The debug() function writes to a debugging log.
  77.   The intmsg() and chkint() functions provide the user i/o for interrupting
  78.     file transfers.
  79. */
  80.  
  81. /* Includes */
  82.  
  83. #ifdef MULTINET
  84. #define MULTINET_OLD_STYLE        /* Leave select prototype undefined */
  85. #endif /* MULTINET */
  86.  
  87. #include "ckcdeb.h"
  88. #include "ckcasc.h"
  89. #include "ckcker.h"
  90. #include "ckcnet.h"            /* Network symbols */
  91. #include "ckuusr.h"
  92. #include "ckcxla.h"
  93.  
  94. int g_fncact = -1;            /* Needed for NOICP builds */
  95. int noinit = 0;                /* Flag for skipping init file */
  96. int nscanfile = SCANFILEBUF;
  97.  
  98. int rcdactive = 0;
  99.  
  100. int locus = 1;                /* Current LOCUS is LOCAL */
  101. #ifdef OS2
  102. int autolocus = 2;            /* Automatic LOCUS switching: ASK */
  103. #else /* OS2 */
  104. int autolocus = 1;            /* Automatic LOCUS switching enabled */
  105. #endif /* OS2 */
  106.  
  107. #ifndef NOICP
  108. #ifdef CKLEARN
  109. #ifdef VMS
  110. #include <time.h>            /* For CKLEARN */
  111. #endif /* VMS */
  112. #endif /* CKLEARN */
  113. #ifdef OS2
  114. #ifndef NT
  115. #define INCL_NOPM
  116. #define INCL_VIO            /* Needed for ckocon.h */
  117. #include <os2.h>
  118. #undef COMMENT
  119. #else
  120. #define APIRET ULONG
  121. #include <windows.h>
  122. #include <tapi.h>
  123. #include "cknwin.h"
  124. #include "ckntap.h"            /* CK_TAPI definition */
  125. #endif /* NT */
  126. #include "ckowin.h"
  127. #include "ckocon.h"
  128. extern int tcp_avail;
  129. extern bool viewonly;
  130. extern int k95stdout;
  131. #ifndef NOTERM
  132. extern tt_status[VNUM];
  133. #endif /* NOTERM */
  134. int display_demo = 1;
  135. #include "ckossh.h"
  136. #ifdef KUI
  137. #include "ikui.h"
  138. #endif /* KUI */
  139. #endif /* OS2 */
  140.  
  141. int optlines = 0;
  142. int didsetlin = 0;
  143.  
  144. #ifdef NEWFTP
  145. extern int ftpget, ftpisopen(), ftpbye(), doftpres();
  146. _PROTOTYP(int doftptyp,(int));
  147. #endif /* NEWFTP */
  148.  
  149. #ifdef VMS
  150. extern int batch;
  151. #endif /* VMS */
  152.  
  153. #ifdef datageneral
  154. #include <packets:common.h>
  155. #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
  156. #endif /* datageneral */
  157.  
  158. extern int xcmdsrc, hints, cmflgs, whyclosed;
  159.  
  160. char * hlptok = NULL;
  161.  
  162. #ifdef CK_TTGWSIZ            /* Whether to use more-prompting */
  163. int xaskmore = 1;            /* Momentary setting */
  164. int saveask  = 1;            /* Permanent setting */
  165. #else
  166. int xaskmore = 0;
  167. int saveask  = 0;
  168. #endif /* CK_TTGWSIZ */
  169.  
  170. #ifndef NOCSETS
  171. extern int nfilc;
  172. extern struct keytab fcstab[];
  173. extern int fcharset;
  174. #endif /* NOCSETS */
  175.  
  176. char * g_pswd = NULL;
  177. int g_pcpt = -1;
  178. int g_pflg = -1;
  179.  
  180. extern int cmd_rows, cmd_cols;
  181.  
  182. #ifdef CKROOT
  183. extern int ckrooterr;
  184. #endif /* CKROOT */
  185.  
  186. extern int inserver, filepeek;
  187.  
  188. #ifdef CKLEARN
  189. FILE * learnfp = NULL;
  190. char * learnfile = NULL;
  191. int learning = 0;
  192. #endif /* CKLEARN */
  193.  
  194. #ifndef NOXFER
  195. extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size,
  196.   sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz,
  197.   spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable,
  198.   setreliable;
  199.  
  200. #ifdef IKSDCONF
  201. extern int iksdcf;
  202. #endif /* IKSDCONF */
  203.  
  204. #ifdef CK_LOGIN
  205. extern int isguest;
  206. #endif /* CK_LOGIN */
  207.  
  208. extern long sendstart;
  209.  
  210. extern char *cmarg, *cmarg2, **cmlist, *dftty;
  211.  
  212. extern struct keytab fntab[]; extern int nfntab;
  213. extern struct ck_p ptab[NPROTOS];
  214.  
  215. int sndcmd = 0;        /* Last command was a SEND-class command. */
  216.  
  217. int g_xfermode = -1;
  218. int g_proto  = -1;
  219. int g_urpsiz = -1;
  220. int g_spsizf = -1;
  221. int g_spsiz  = -1;
  222. int g_spsizr = -1;
  223. int g_spmax  = -1;
  224. int g_wslotr = -1;
  225. int g_prefixing = -1;
  226. int g_fncnv  = -1;
  227. int g_fnspath = -1;
  228. int g_fnrpath = -1;
  229. int g_fnact  = -1;
  230. int g_displa = -1;
  231. int g_spath  = -1;
  232. int g_rpath  = -1;
  233. char * g_sfilter = NULL;
  234. char * g_rfilter = NULL;
  235.  
  236. extern int patterns;
  237. #ifdef PATTERNS
  238. extern char *txtpatterns[], *binpatterns[];
  239. int g_patterns = -1;
  240. #endif /* PATTERNS */
  241. int g_skipbup = -1;
  242.  
  243. #ifdef PIPESEND
  244. extern int usepipes, pipesend;
  245. extern char * sndfilter;
  246. #endif /* PIPESEND */
  247.  
  248. #ifndef NOSPL
  249. extern int sndxlo, sndxhi, sndxin;
  250. #endif /* NOSPL */
  251.  
  252. extern char fspec[];            /* Most recent filespec */
  253. extern int fspeclen;            /* Length of fspec[] buffer */
  254.  
  255. #ifndef NOFRILLS
  256. extern int rmailf;            /* MAIL command items */
  257. extern char optbuf[];
  258. #endif /* NOFRILLS */
  259.  
  260. extern int
  261.   en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri,
  262.   en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit,
  263.   en_mkd, en_rmd, en_asg;
  264.  
  265. #ifndef NOMSEND                /* Multiple SEND */
  266. extern char *msfiles[];
  267. int filesinlist = 0;            /* And ADD ... */
  268. extern struct filelist * filehead;
  269. extern struct filelist * filetail;
  270. extern struct filelist * filenext;
  271. extern int addlist;
  272. #endif /* NOMSEND */
  273.  
  274. static struct keytab addtab[] = {
  275. #ifdef PATTERNS
  276.     { "binary-patterns", ADD_BIN, 0 },
  277. #endif /* PATTERNS */
  278. #ifndef NOMSEND
  279.     { "send-list", ADD_SND, 0 },
  280. #endif /* NOMSEND */
  281. #ifdef PATTERNS
  282.     { "text-patterns", ADD_TXT, 0 },
  283. #endif /* PATTERNS */
  284.     { "", 0, 0 }
  285. };
  286. static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;
  287.  
  288. #ifndef NOCSETS
  289. struct keytab assoctab[] = {
  290.     { "file-character-set",     ASSOC_FC, 0 },
  291.     { "transfer-character-set", ASSOC_TC, 0 },
  292.     { "xfer-character-set",     ASSOC_TC, CM_INV }
  293. };
  294. static int nassoc = sizeof(assoctab)/sizeof(struct keytab);
  295. extern int afcset[MAXFCSETS+1];        /* Character-set associations */
  296. extern int axcset[MAXTCSETS+1];
  297. #endif /* NOCSETS */
  298.  
  299. #ifndef ADDCMD
  300. #ifndef NOMSEND
  301. #define ADDCMD
  302. #endif /* NOMSEND */
  303. #ifndef ADDCMD
  304. #ifdef PATTERNS
  305. #define ADDCMD
  306. #endif /* PATTERNS */
  307. #endif /* ADDCMD */
  308. #endif /* ADDCMD */
  309. #endif /* NOXFER */
  310.  
  311. /* External Kermit Variables, see ckmain.c for description. */
  312.  
  313. extern xx_strp xxstring;
  314. extern long xvernum;
  315.  
  316. extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel,
  317.   pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;
  318. #ifdef TNCODE
  319. extern int debses;
  320. extern char tn_msg[];
  321. #endif /* TNCODE */
  322.  
  323. int sleepcan = 1;
  324. int g_binary = -1;
  325. int g_recursive = -1;
  326. int g_matchdot = -1;
  327. extern int nolinks;
  328.  
  329. extern long vernum;
  330. extern char *versio, *copyright[];
  331. extern char *ckxsys;
  332. #ifndef NOHELP
  333. extern char *introtxt[];
  334. extern char *newstxt[];
  335. #endif /* NOHELP */
  336.  
  337. #ifndef OS2
  338. #ifndef UNIX
  339. extern char *PWDCMD;
  340. #endif /* UNIX */
  341. extern char *WHOCMD;
  342. #endif /* OS2 */
  343.  
  344. extern char ttname[];
  345.  
  346. extern CHAR sstate;
  347.  
  348. extern int network;            /* Have active network connection */
  349. extern int nettype;            /* Type of network */
  350. extern int ttnproto;                    /* NET_TCPB protocol */
  351.  
  352. #ifndef NODIAL
  353. extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */
  354. #endif /* NODIAL */
  355.  
  356. #ifdef CK_APC
  357. extern int apcactive, apcstatus;
  358. #endif /* CK_APC */
  359.  
  360. #ifndef NOPUSH
  361. #ifndef NOFRILLS
  362. extern char editor[];
  363. extern char editopts[];
  364. extern char editfile[];
  365. #endif /* NOFRILLS */
  366. #endif /* NOPUSH */
  367.  
  368. #ifdef BROWSER
  369. extern char browser[];            /* Web browser application */
  370. extern char browsopts[];        /* Web browser options */
  371. extern char browsurl[];            /* Most recent URL */
  372. #endif /* BROWSER */
  373. #ifndef NOFTP
  374. char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */
  375. char ftpopts[128] = { NUL, NUL };    /* ftp command-line options */
  376. #endif /* NOFTP */
  377. extern struct keytab onoff[];        /* On/Off keyword table */
  378.  
  379. #ifdef CK_TMPDIR
  380. int f_tmpdir = 0;            /* Directory changed temporarily */
  381. char savdir[TMPDIRLEN];            /* For saving current directory */
  382. #endif /* CK_TMPDIR */
  383.  
  384. int activecmd = -1;            /* Keyword index of active command */
  385. int doconx = -1;            /* CONNECT-class command active */
  386. int ooflag = 0;                /* User-settable on/off flag */
  387.  
  388. int rcflag = 0;                /* Pointer to home directory string */
  389. int repars,                /* Reparse needed */
  390.     techo = 0;                /* Take echo */
  391. int secho = 1;                /* SCRIPT echo */
  392.  
  393. int xitwarn =            /* Warn about open connection on exit */
  394. #ifdef NOWARN
  395. 0
  396. #else
  397. 1
  398. #endif /* NOWARN */
  399. ;
  400.  
  401. struct keytab onoffsw[] = {
  402.     { "/off", 0, 0 },
  403.     { "/on",  1, 0 }
  404. };
  405.  
  406. #ifdef CKEXEC
  407. struct keytab redirsw[] = {
  408.     { "/redirect", 1, 0 }
  409. };
  410. #endif /* CKEXEC */
  411.  
  412. #ifndef NOXMIT
  413. /* Variables for TRANSMIT command */
  414.  
  415. int xmitx = 1;            /* Whether to echo during TRANSMIT */
  416. int xmitf = 0;            /* Character to fill empty lines */
  417. int xmitl = 0;            /* 0 = Don't send linefeed too */
  418. int xmitp = LF;            /* Host line prompt */
  419. int xmits = 0;            /* Use shift-in/shift-out, 0 = no */
  420. int xmitw = 0;            /* Milliseconds to pause during TRANSMIT */
  421. int xmitt = 1;            /* Seconds to wait for each char to echo */
  422. int xmita = 1;            /* Action upon timeout */
  423.  
  424. #define XMI_BIN 1
  425. #define XMI_TXT 2
  426. #define XMI_CMD 3
  427. #define XMI_TRA 4
  428. #define XMI_VRB 5
  429. #define XMI_QUI 6
  430. #define XMI_NOW 7
  431. #define XMI_NOE 8
  432.  
  433. static struct keytab xmitsw[] = {    /* TRANSMIT command options */
  434.     { "/binary",          XMI_BIN, 0 },
  435. #ifdef PIPESEND
  436.     { "/command",         XMI_CMD, CM_INV|CM_PSH },
  437. #endif /* PIPESEND */
  438.     { "/noecho",          XMI_NOE, 0 },
  439.     { "/nowait",          XMI_NOW, 0 },
  440. #ifdef PIPESEND
  441.     { "/pipe",            XMI_CMD, 0 },
  442. #endif /* PIPESEND */
  443. #ifdef COMMENT
  444.     { "/quiet",           XMI_QUI, 0 },
  445. #endif /* COMMENT */
  446.     { "/text",            XMI_TXT, 0 },
  447.     { "/transparent",     XMI_TRA, 0 },
  448. #ifdef COMMENT
  449.     { "/verbose",         XMI_VRB, 0 },
  450. #endif /* COMMENT */
  451.     { "", 0, 0 }
  452. };
  453. #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1
  454. static int nxmitsw = NXMITSW;
  455.  
  456. #endif /* NOXMIT */
  457.  
  458. /* Declarations from ck?fio.c module */
  459.  
  460. extern char *SPACMD, *SPACM2;        /* SPACE commands */
  461.  
  462. /* Command-oriented items */
  463.  
  464. #ifdef DCMDBUF
  465. extern char *cmdbuf;            /* Command buffers */
  466. extern char *atmbuf;
  467. extern char *line;            /* Character buffer for anything */
  468. extern char *tmpbuf;            /* Short temporary string buffer */
  469. extern int *ifcmd;
  470. extern int *intime;
  471. extern int *inpcas;
  472. #else
  473. extern char cmdbuf[];            /* Command buffers */
  474. extern char atmbuf[];
  475. extern char line[];            /* Character buffer for anything */
  476. extern char tmpbuf[];            /* Temporary buffer */
  477. extern int ifcmd[];
  478. extern int intime[];
  479. extern int inpcas[];
  480. #endif /* DCMDBUF */
  481.  
  482. #ifndef NOSPL
  483. extern char * prstring[];
  484. #endif /* NOSPL */
  485.  
  486. char *lp;                /* Pointer to line buffer */
  487.  
  488. #ifndef NOSPL
  489. int unkmacro = 0;            /* Flag for in ON_UNKNOWN_COMMAND */
  490. int oldeval = 0;
  491. char evalbuf[33];            /* EVALUATE result */
  492. extern char * inpbuf;            /* Buffer for INPUT and REINPUT */
  493. char *inpbp;                /* And pointer to same */
  494. extern char lblbuf[];            /* Buffer for labels */
  495. int m_found;                /* MINPUT result */
  496. int i_active = 0;            /* INPUT command is active */
  497. char *ms[MINPMAX];            /* Pointers to MINPUT strings */
  498. static int mp[MINPMAX];            /* and flags */
  499. extern int fndiags, fnerror, fnsuccess;    /* Function diagnostics */
  500. #ifndef NOSEXP
  501. char * lastsexp = NULL;            /* S-Expressions */
  502. char * sexpval = NULL;
  503. int sexpecho = SET_AUTO;
  504. #endif /* NOSEXP */
  505. #endif /* NOSPL */
  506.  
  507. char psave[PROMPTL] = { NUL };        /* For saving & restoring prompt */
  508.  
  509. extern int success;            /* Command success/failure flag */
  510. extern int cmdlvl;            /* Current position in command stack */
  511.  
  512. #ifndef NOSPL
  513. int                    /* SET INPUT parameters. */
  514. /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */
  515.   inbufsize = 0,            /* INPUT buffer size */
  516.   indef = 1,                /* default timeout, seconds */
  517.   inecho = 1,                /* 1 = echo on */
  518.   inautodl = 0,                /* INPUT autodownload */
  519.   inintr = 1,                /* INPUT interrupion allowed */
  520.   insilence = 0;            /* 0 = no silence constraint */
  521. #ifdef OS2
  522. int interm = 1;                /* Terminal emulator displays input */
  523. #endif /* OS2 */
  524. int maclvl = -1;            /* Macro nesting level */
  525. int mecho = 0;                /* Macro echo, 0 = don't */
  526. char varnam[6];                /* For variable names */
  527. extern int macargc[];            /* ARGC from macro invocation */
  528.  
  529. extern char *m_arg[MACLEVEL][NARGS];    /* Stack of macro arguments */
  530. extern char *mrval[];
  531.  
  532. extern char **a_ptr[];            /* Array pointers */
  533. extern int a_dim[];            /* Array dimensions */
  534. extern int a_link[];
  535.  
  536. #ifdef DCMDBUF
  537. extern struct cmdptr *cmdstk;        /* The command stack itself */
  538. #else
  539. extern struct cmdptr cmdstk[];        /* The command stack itself */
  540. #endif /* DCMDBUF */
  541.  
  542. long ck_alarm = 0;            /* SET ALARM value */
  543. char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  544. char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' };
  545.  
  546. #endif /* NOSPL */
  547.  
  548. static int x, y, z = 0;            /* Local workers */
  549. static char *s;
  550.  
  551. #define xsystem(s) zsyscmd(s)
  552.  
  553. /* Top-Level Interactive Command Keyword Table */
  554. /* Keywords must be in lowercase and in alphabetical order. */
  555.  
  556. struct keytab cmdtab[] = {
  557. #ifndef NOPUSH
  558.     { "!",       XXSHE, CM_INV|CM_PSH }, /* Shell escape */
  559. #else
  560.     { "!",       XXNOTAV, CM_INV|CM_PSH },
  561. #endif /* NOPUSH */
  562.     { "#",           XXCOM, CM_INV },    /* Comment */
  563. #ifndef NOSPL
  564.     { "(",           XXSEXP,CM_INV },    /* S-Expression */
  565.     { ".",           XXDEF, CM_INV },    /* Assignment */
  566.     { ":",           XXLBL, CM_INV },    /* Label */
  567. #endif /* NOSPL */
  568. #ifdef CK_REDIR
  569. #ifndef NOPUSH
  570.     { "<",           XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  571. #else
  572.     { "<",           XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */
  573. #endif /* NOPUSH */
  574. #endif /* CK_REDIR */
  575. #ifndef NOPUSH
  576.     { "@",           XXSHE, CM_INV|CM_PSH }, /* DCL escape */
  577. #else
  578.     { "@",           XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */
  579. #endif /* NOPUSH */
  580.  
  581. #ifdef CK_RECALL
  582.     { "^",           XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */
  583. #endif /* CK_RECALL */
  584. #ifndef NOSPL
  585.     { "_asg",        XXASX,   CM_INV },    /* Used internally by FOR, etc */
  586.     { "_assign",     XXASX,   CM_INV },    /* Used internally by FOR, etc */
  587.     { "_decrement",  XX_DECR, CM_INV },
  588.     { "_define",     XXDFX,   CM_INV },    /* Used internally by FOR, etc */
  589.     { "_evaluate",   XX_EVAL, CM_INV },
  590.     { "_forward",    XXXFWD,  CM_INV },    /* Used internally by SWITCH   */
  591.     { "_getargs",    XXGTA,   CM_INV },    /* Used internally by FOR, etc */
  592.     { "_increment",  XX_INCR, CM_INV },
  593.     { "_putargs",    XXPTA,   CM_INV },    /* Used internally by FOR, etc */
  594.     { "_undefine",   XXUNDFX, CM_INV },
  595. #endif /* NOSPL */
  596.  
  597.     { "about",       XXVER,   CM_INV },    /* Synonym for VERSION */
  598. #ifndef NOSPL
  599. #ifdef NEWFTP
  600.     { "account",     XXACCT,  CM_INV }, /* (FTP) Account */
  601. #endif /* NEWFTP */
  602. #ifdef ADDCMD
  603.     { "add",         XXADD, 0 },    /* ADD */
  604. #endif /* ADDCMD */
  605. #ifndef NODIAL
  606.     { "answer",      XXANSW, CM_LOC },    /* ANSWER the phone */
  607. #else
  608.     { "answer",      XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */
  609. #endif /* NODIAL */
  610.     { "apc",         XXAPC, 0 },    /* Application Program Command */
  611. #ifndef NOSPL
  612.     { "array",       XXARRAY, 0 },    /* Array operations */
  613. #endif /* NOSPL */
  614.     { "ascii",       XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  615.     { "asg",         XXASS, CM_INV },    /* Invisible synonym for ASSIGN */
  616.     { "ask",         XXASK, 0 },    /* ASK for text, assign to variable */
  617.     { "askq",        XXASKQ,0 },    /* ASK quietly (no echo) */
  618. #ifndef NOSPL
  619.     { "ass",         XXASS, CM_INV|CM_ABR }, /* ASSIGN */
  620.     { "assert",      XXASSER, CM_INV },    /* ASSERT */
  621.     { "assign",      XXASS, 0 },    /* ASSIGN */
  622. #endif /* NOSPL */
  623. #ifndef NOXFER
  624. #ifndef NOCSETS
  625.     { "associate",   XXASSOC, 0 },    /* ASSOCIATE */
  626. #else
  627.     { "associate",   XXNOTAV, CM_INV },    /* ASSOCIATE */
  628. #endif /* NOCSETS */
  629. #endif /* NOXFER */
  630. #ifdef CK_KERBEROS
  631. #ifdef CK_AUTHENTICATION
  632.     { "authenticate",XXAUTH, 0 },    /* Authentication */
  633. #else
  634.     { "authenticate",XXAUTH, CM_INV },
  635. #endif /* CK_AUTHENTICATION */
  636. #endif /* CK_KERBEROS */
  637. #endif /* NOSPL */
  638. #ifndef NOFRILLS
  639.     { "back",        XXBACK, 0 },    /* BACK to previous directory */
  640. #else
  641.     { "back",        XXNOTAV,CM_INV },
  642. #endif /* NOFRILLS */
  643.     { "beep",        XXBEEP,CM_INV },    /* BEEP */
  644. #ifndef NOXFER
  645.     { "binary",      XXBIN, CM_INV },    /* == SET FILE TYPE BINARY */
  646. #endif /* NOXFER */
  647. #ifndef NOFRILLS
  648.     { "bug",         XXBUG, CM_INV },    /* BUG report instructions */
  649. #else
  650.     { "bug",         XXNOTAV, CM_INV },
  651. #endif /* NOFRILLS */
  652. #ifdef BROWSER
  653.     { "browse",      XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */
  654. #else
  655.     { "browse",      XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  656. #endif /* BROWSER */
  657. #ifndef NOXFER
  658.     { "bye",         XXBYE, 0 },    /* BYE to remote server */
  659. #endif /* NOXFER */
  660. #ifndef NOLOCAL
  661.     { "c",           XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */
  662. #endif /* NOLOCAL */
  663. #ifndef NOFRILLS
  664.     { "cat",         XXCAT, CM_INV },    /* Invisible synonym for TYPE */
  665. #endif /* NOFRILLS */
  666. #ifndef NOSPL
  667.  
  668. #ifndef NOXFER
  669.     { "cautious",    XXCAU, CM_INV },
  670. #endif /* NOXFER */
  671.  
  672. #endif /* NOSPL */
  673.  
  674.     { "cd",          XXCWD, 0 },    /* Change Directory */
  675.     { "cdup",        XXCDUP, CM_INV },    /* Change Directory Up */
  676.  
  677. #ifndef NOXFER
  678. #ifdef PIPESEND
  679.     { "cget",        XXCGET, CM_INV|CM_PSH }, /* CGET */
  680. #else
  681.     { "cget",        XXNOTAV, CM_INV|CM_PSH }, /* CGET */
  682. #endif /* PIPESEND */
  683. #endif /* NOXFER */
  684.     { "ch",          XXCHK,   CM_INV|CM_ABR },
  685.     { "check",       XXCHK,   0 },    /* CHECK for a feature */
  686. #ifdef CK_PERMS
  687. #ifdef UNIX
  688.     { "chmod",       XXCHMOD, 0 },    /* CHMOD */
  689. #else
  690.     { "chmod",       XXNOTAV, CM_INV },
  691. #endif /* UNIX */
  692. #else
  693.     { "chmod",       XXNOTAV, CM_INV },
  694. #endif /* CK_PERMS */
  695. #ifdef CKROOT
  696.     { "chroot",      XXCHRT,  CM_INV },    /* CHROOT */
  697. #endif /* CKROOT */
  698.     { "ckermit",     XXKERMI, CM_INV },    /* CKERMIT (like KERMIT) */
  699.     { "cl",          XXCLO,   CM_ABR|CM_INV },
  700. #ifndef NOFRILLS
  701.     { "clear",       XXCLE, 0 },    /* CLEAR input and/or device buffer */
  702. #else
  703.     { "clear",       XXNOTAV, CM_INV },
  704. #endif /* NOFRILLS */
  705.     { "close",         XXCLO, 0 },    /* CLOSE a log or other file */
  706.     { "cls",         XXCLS, CM_INV },    /* Clear Screen (CLS) */
  707.     { "comment",     XXCOM, CM_INV },    /* Introduce a comment */
  708. #ifndef NOLOCAL
  709.     { "connect",     XXCON, CM_LOC },    /* Begin terminal connection */
  710. #else
  711.     { "connect",     XXNOTAV, CM_LOC },
  712. #endif /* NOLOCAL */
  713.     { "continue",    XXCONT,  CM_INV },    /* CONTINUE */
  714. #ifndef NOFRILLS
  715. #ifdef ZCOPY
  716.     { "co",          XXCPY, CM_INV|CM_ABR },
  717.     { "cop",         XXCPY, CM_INV|CM_ABR },
  718.     { "copy",        XXCPY, 0 },    /* COPY a file */
  719. #else
  720.     { "copy",        XXNOTAV, CM_INV },
  721. #endif /* ZCOPY */
  722.     { "copyright",   XXCPR, CM_INV },    /* COPYRIGHT */
  723. #ifdef ZCOPY
  724.     { "cp",          XXCPY, CM_INV },    /* COPY a file */
  725. #endif /* ZCOPY */
  726. #ifndef NOLOCAL
  727. #ifndef OS2
  728.     { "cq",          XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */
  729. #endif /* OS2 */
  730. #endif /* NOLOCAL */
  731. #ifndef NOXFER
  732. #ifdef PIPESEND
  733.     { "creceive",    XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */
  734.     { "csend",       XXCSEN,CM_INV|CM_PSH }, /* SEND from command */
  735. #else
  736.     { "creceive",    XXNOTAV,CM_INV|CM_PSH },
  737.     { "csend",       XXNOTAV,CM_INV|CM_PSH },
  738. #endif /* PIPESEND */
  739. #endif /* NOXFER */
  740. #endif /* NOFRILLS */
  741.  
  742.     { "cwd",         XXCWD,   CM_INV },    /* Traditional synonym for cd */
  743.  
  744. #ifndef NOSPL
  745.     { "date",        XXDATE,  0 },    /* DATE */
  746.     { "dcl",         XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  747.     { "debug",       XXDEBUG, CM_INV },
  748.     { "declare",     XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  749.     { "decrement",   XXDEC,   0 },    /* DECREMENT a numeric variable */
  750.     { "define",      XXDEF,   0 },    /* DEFINE a macro or variable */
  751. #else
  752.     { "date",        XXNOTAV, CM_INV },
  753.     { "dcl",         XXNOTAV, CM_INV },
  754.     { "declare",     XXNOTAV, CM_INV },
  755.     { "decrement",   XXNOTAV, CM_INV },
  756.     { "define",      XXNOTAV, CM_INV },
  757. #endif /* NOSPL */
  758.  
  759. #ifndef NOFRILLS
  760.     { "delete",      XXDEL, 0 },    /* DELETE a file */
  761. #else
  762.     { "delete",      XXNOTAV, CM_INV },
  763. #endif /* NOFRILLS */
  764.  
  765. #ifndef NODIAL
  766.     { "dial",        XXDIAL,  CM_LOC },    /* DIAL a phone number */
  767. #else
  768.     { "dial",        XXNOTAV, CM_INV|CM_LOC },
  769. #endif /* NODIAL */
  770.  
  771. #ifdef NT
  772.     { "dialer",      XXDIALER, CM_INV }, /* K95 Dialer */
  773. #endif /* NT */
  774.  
  775.     { "directory",   XXDIR, 0 },    /* DIRECTORY of files */
  776.  
  777. #ifndef NOFRILLS
  778. #ifndef NOSERVER
  779.     { "disable",     XXDIS, 0 },    /* DISABLE a server function */
  780. #else
  781.     { "disable",     XXNOTAV, CM_INV },
  782. #endif /* NOSERVER */
  783. #endif /* NOFRILLS */
  784.  
  785. #ifndef NOSPL
  786.     { "do",          XXDO,  0 },    /* DO (execute) a macro */
  787. #else
  788.     { "do",          XXNOTAV, CM_INV },
  789. #endif /* NOSPL */
  790.  
  791.     { "e",           XXEXI, CM_INV|CM_ABR },
  792.  
  793. #ifndef NOFRILLS
  794. #ifndef NOXFER
  795.     { "e-packet",    XXERR, CM_INV },    /* Send an Error-Packet */
  796. #endif /* NOXFER */
  797. #endif /* NOFRILLS */
  798.  
  799.     { "echo",        XXECH, 0 },    /* ECHO text */
  800.  
  801. #ifndef NOFRILLS
  802. #ifndef NOPUSH
  803.     { "edit",        XXEDIT, CM_PSH },    /* EDIT */
  804. #else
  805.     { "edit",        XXNOTAV, CM_INV|CM_PSH }, /* EDIT */
  806. #endif /* NOPUSH */
  807. #endif /* NOFRILLS */
  808.  
  809.     { "eightbit",    XXEIGHT, CM_INV },    /* EIGHTBIT */
  810.  
  811. #ifndef NOSPL
  812.     { "else",        XXELS, CM_INV },    /* ELSE part of IF statement */
  813. #else
  814.     { "else",        XXNOTAV, CM_INV },    /* ELSE part of IF statement */
  815. #endif /* NOSPL */
  816.  
  817. #ifndef NOSERVER
  818. #ifndef NOFRILLS
  819.     { "enable",      XXENA,  0 },    /* ENABLE a server function */
  820. #else
  821.     { "enable",      XXNOTAV, CM_INV },
  822. #endif /* NOFRILLS */
  823. #endif /* NOSERVER */
  824.  
  825. #ifndef NOSPL
  826.     { "end",         XXEND,  0 },    /* END command file or macro */
  827. #else
  828.     { "end",         XXNOTAV, CM_INV },
  829. #endif /* NOSPL */
  830.  
  831.     { "erase",       XXDEL, CM_INV },    /* Synonym for DELETE */
  832.  
  833. #ifndef NOSPL
  834.     { "evaluate",    XXEVAL, 0 },    /* EVALUATE */
  835. #else
  836.     { "evaluate",    XXNOTAV, CM_INV },
  837. #endif /* NOSPL */
  838.  
  839.     { "ex",          XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */
  840.  
  841. #ifdef CKEXEC
  842.     { "exec",        XXEXEC, CM_INV|CM_LOC }, /* exec() */
  843. #else
  844.     { "exec",        XXNOTAV, CM_INV|CM_LOC },
  845. #endif /* CKEXEC */
  846.  
  847.     { "exit",       XXEXI, 0 },        /* EXIT from C-Kermit */
  848.     { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */
  849.  
  850. #ifdef OS2
  851.     { "extproc",     XXCOM, CM_INV },    /* Dummy command for OS/2 */
  852. #endif /* OS2 */
  853.  
  854. #ifndef NOXFER
  855.     { "f",           XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */
  856. #endif /* NOXFER */
  857.  
  858. #ifndef NOSPL
  859.     { "fail",        XXFAIL, CM_INV },    /* FAIL */
  860.  
  861. #ifndef NOXFER
  862.     { "fast",        XXFAST, CM_INV },
  863. #endif /* NOXFER */
  864.  
  865. #ifdef CKCHANNELIO
  866.     { "fclose",      XXF_CL, CM_INV },    /* FCLOSE */
  867.     { "fcount",      XXF_CO, CM_INV },    /* FCOUNT */
  868.     { "fflush",      XXF_FL, CM_INV },    /* FFLUSH */
  869. #endif /* CKCHANNELIO */
  870.  
  871. #ifndef NOXFER
  872.     { "fi",          XXFIN, CM_INV|CM_ABR }, /* FINISH */
  873. #endif /* NOXFER */
  874.  
  875. #ifdef CKCHANNELIO
  876.     { "file",        XXFILE, 0 },    /* FILE */
  877. #endif /* CKCHANNELIO */
  878. #endif /* NOSPL */
  879.  
  880. #ifndef NOXFER
  881.     { "fin",         XXFIN, CM_INV|CM_ABR }, /* FINISH */
  882. #endif /* NOXFER */
  883.  
  884. #ifndef UNIXOROSK
  885.     { "find",        XXGREP, 0 },    /* FIND (grep) */
  886. #else
  887.     { "find",        XXGREP,CM_INV },
  888. #endif /* UNIXOROSK */
  889.  
  890. #ifndef NOXFER
  891.     { "finish",      XXFIN, 0 },    /* FINISH */
  892. #endif /* NOXFER */
  893.  
  894. #ifdef TCPSOCKET
  895.     { "firewall",    XXFIREW, CM_INV|CM_HLP },
  896. #endif /* TCPSOCKET */
  897.  
  898. #ifdef CKCHANNELIO
  899.     { "flist",       XXF_LI, CM_INV },    /* FLIST */
  900.     { "fopen",       XXF_OP, CM_INV },    /* FOPEN */
  901. #endif /* CKCHANNELIO */
  902.  
  903. #ifndef NOSPL
  904.     { "fo",          XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */
  905.     { "for",         XXFOR, 0 },    /* FOR loop */
  906.     { "forward",     XXFWD, CM_INV },    /* FORWARD */
  907. #endif /* NOSPL */
  908. #ifndef NOFRILLS
  909.     { "fot",       XXDIR, CM_INV },    /* "fot" = "dir" (for Chris) */
  910. #endif /* NOFRILLS */
  911.  
  912. #ifdef CKCHANNELIO
  913.     { "fread",      XXF_RE, CM_INV },    /* FREAD */
  914.     { "frewind",    XXF_RW, CM_INV },    /* FREWIND */
  915.     { "fseek",      XXF_SE, CM_INV },    /* FSEEK */
  916.     { "fstatus",    XXF_ST, CM_INV },    /* FSTATUS */
  917. #endif /* CKCHANNELIO */
  918.  
  919. #ifdef TCPSOCKET
  920. #ifndef NOFTP
  921. #ifdef SYSFTP
  922. #ifndef NOPUSH
  923.     { "ftp",       XXFTP,   CM_INV|CM_PSH|CM_LOC }, /* System FTP */
  924. #else
  925.     { "ftp",       XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  926. #endif /* NOPUSH */
  927. #else  /* SYSFTP */
  928.     { "ftp",       XXFTP,   0 },    /* Built-in FTP */
  929. #endif /* SYSFTP */
  930. #else  /* NOFTP */
  931.     { "ftp",       XXNOTAV, CM_INV },    /* No FTP */
  932. #endif /* NOFTP */
  933. #endif /* TCPSOCKET */
  934.  
  935. #ifndef NOSPL
  936.     { "function",    XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */
  937. #endif /* NOSPL */
  938.  
  939. #ifdef CKCHANNELIO
  940.     { "fwrite",      XXF_WR, CM_INV },    /* FWRITE */
  941. #endif /* CKCHANNELIO */
  942.  
  943. #ifndef NOXFER
  944.     { "g",           XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */
  945. #ifndef NOSPL
  946.     { "ge",          XXGET, CM_INV|CM_ABR }, /* Ditto */
  947. #endif /* NOSPL */
  948.     { "get",         XXGET, 0 },    /* GET */
  949. #endif /* NOXFER */
  950. #ifndef NOSPL
  951.     { "getc",        XXGETC, 0 },    /* GETC */
  952. #ifdef OS2
  953.     { "getkeycode",  XXGETK, 0 },    /* GETKEYCODE */
  954. #endif /* OS2 */
  955. #ifndef NOFRILLS
  956.     { "getok",       XXGOK, 0 },    /* GETOK (ask for Yes/No/OK) */
  957. #endif /* NOFRILLS */
  958. #endif /* NOSPL */
  959. #ifndef NOSPL
  960.     { "goto",        XXGOTO,0 },    /* GOTO label in take file or macro */
  961. #endif /* NOSPL */
  962. #ifdef UNIXOROSK
  963.     { "grep",        XXGREP,0 },    /* GREP (find) */
  964. #else
  965.     { "grep",        XXGREP,CM_INV },    /* GREP (find) */
  966. #endif /* UNIXOROSK */
  967.     { "h",           XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  968.     { "he",          XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  969. #ifndef NOFRILLS
  970.     { "head",        XXHEAD, 0 },
  971. #endif /* NOFRILLS */
  972. #ifndef NOLOCAL
  973.     { "hangup",      XXHAN, CM_LOC },    /* HANGUP the connection */
  974. #endif /* NOLOCAL */
  975.     { "HELP",        XXHLP, 0 },    /* Display HELP text */
  976. #ifndef NOHTTP
  977. #ifdef TCPSOCKET
  978.     { "http",        XXHTTP, 0 },    /* HTTP operations */
  979. #endif /* TCPSOCKET */
  980. #endif /* NOHTTP */
  981. #ifndef NOSPL
  982.     { "i",           XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  983.     { "if",          XXIF,  0 },         /* IF ( condition ) command */
  984. #ifdef TCPSOCKET
  985.     { "iksd",        XXIKSD, CM_INV },         /* Make connection to IKSD */
  986. #else
  987.     { "iksd",        XXNOTAV, CM_INV },
  988. #endif /* TCPSOCKET */
  989.     { "in",          XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  990.     { "increment",   XXINC, 0 },    /* Increment a numeric variable */
  991.     { "input",       XXINP, 0 },    /* INPUT text from comm device */
  992. #endif /* NOSPL */
  993.  
  994. #ifndef NOHELP
  995.     { "int",         XXINT, CM_INV|CM_ABR },
  996.     { "intr",        XXINT, CM_INV|CM_ABR },
  997.     { "INTRO",       XXINT, 0 },
  998.     { "introduction",XXINT, CM_INV },    /* Print introductory text */
  999. #else
  1000.     { "intro",       XXNOTAV, CM_INV },
  1001.     { "introduction",XXNOTAV, CM_INV },
  1002. #endif /* NOHELP */
  1003.  
  1004. #ifdef OS2
  1005.     { "k95",         XXKERMI, CM_INV },    /* Hmmm what's this... */
  1006. #endif /* OS2 */
  1007.  
  1008. #ifndef NOSPL
  1009.     { "kcd",         XXKCD,   0      },
  1010. #endif /* NOSPL */
  1011.  
  1012.     { "kermit",      XXKERMI, CM_INV },
  1013.  
  1014. #ifdef OS2
  1015. #ifndef NOKVERBS
  1016.     { "kverb",       XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */
  1017. #endif /* NOKVERBS */
  1018. #endif /* OS2 */
  1019.  
  1020. #ifndef NOFRILLS
  1021.     { "l",           XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
  1022. #endif /* NOFRILLS */
  1023.  
  1024.     { "lcd",         XXLCWD, CM_INV },
  1025.     { "lcdup",       XXLCDU, CM_INV },
  1026.     { "lcwd",        XXLCWD, CM_INV },
  1027.     { "ldelete",     XXLDEL, CM_INV },
  1028.     { "ldirectory",  XXLDIR, CM_INV },
  1029.  
  1030. #ifdef CKLEARN
  1031.     { "learn",       XXLEARN, 0 },    /* LEARN - automatic script writing */
  1032. #else
  1033.     { "learn",       XXNOTAV, CM_INV },
  1034. #endif /* CKLEARN */
  1035.  
  1036.     { "li",          XXLNOUT, CM_INV|CM_ABR },
  1037.     { "LICENSE",     XXCPR, 0 },    /* LICENSE */
  1038.  
  1039. #ifndef NOSPL
  1040.     { "lineout",     XXLNOUT, 0 },    /* LINEOUT = OUTPUT + eol */
  1041. #endif /* NOSPL */
  1042.  
  1043. #ifdef NT
  1044.     { "link",        XXLINK, 0 },       /* LINK source destination */
  1045. #endif /* NT */
  1046.  
  1047.     { "lmkdir",      XXLMKD, CM_INV },
  1048.  
  1049. #ifndef NOFRILLS
  1050.     { "lo",          XXLOG,  CM_INV|CM_ABR }, /* Invisible synonym for log */
  1051. #endif /* NOFRILLS */
  1052.  
  1053. #ifndef NOSPL
  1054.     { "local",       XXLOCAL, CM_INV },    /* LOCAL variable declaration */
  1055. #else
  1056.     { "local",       XXNOTAV, CM_INV },
  1057. #endif /* NOSPL */
  1058.  
  1059.     { "log",           XXLOG, 0 },    /* Open a log file */
  1060.  
  1061.     { "login",       XXLOGIN,  0 },    /* (REMOTE) LOGIN to server or IKSD */
  1062.     { "logout",      XXLOGOUT, 0 },    /* LOGOUT from server or IKSD */
  1063.  
  1064. #ifndef NOFRILLS
  1065. #ifndef NODIAL
  1066.     { "lookup",      XXLOOK,  0 },    /* LOOKUP */
  1067. #else
  1068.     { "lookup",      XXNOTAV, CM_INV },
  1069. #endif /* NODIAL */
  1070.  
  1071.     { "lpwd",        XXLPWD, CM_INV },
  1072.     { "lrename",     XXLREN, CM_INV },
  1073.     { "lrmdir",      XXLRMD, CM_INV },
  1074.  
  1075. #ifdef UNIXOROSK
  1076.     { "ls",          XXLS,  CM_INV|CM_PSH }, /* UNIX ls command */
  1077. #else
  1078.     { "ls",          XXDIR, CM_INV },    /* Invisible synonym for DIR */
  1079. #endif /* UNIXOROSK */
  1080. #ifndef NOXFER
  1081.     { "mail",        XXMAI, 0 },    /* Send a file as e-mail */
  1082. #endif /* NOXFER */
  1083. #ifndef NOHELP
  1084.     { "manual",      XXMAN, CM_PSH },    /* MAN(UAL) */
  1085. #else
  1086.     { "manual",      XXNOTAV, CM_INV|CM_PSH },
  1087. #endif /* NOHELP */
  1088. #endif /* NOFRILLS */
  1089. #ifdef CK_MKDIR
  1090.     { "md",          XXMKDIR, CM_INV },    /* Synonym for MKDIR */
  1091. #endif /* CK_MKDIR */
  1092. #ifdef CK_MINPUT
  1093.     { "minput",      XXMINP, 0 },    /* MINPUT */
  1094. #else
  1095.     { "minput",      XXNOTAV, CM_INV },
  1096. #endif /* CK_MINPUT */
  1097. #ifndef NOMSEND
  1098.     { "mget",        XXMGET, 0 },    /* MGET */
  1099. #else
  1100.     { "mget",        XXNOTAV, CM_INV },
  1101. #endif /* NOMSEND */
  1102. #ifdef CK_MKDIR
  1103.     { "mkdir",       XXMKDIR, 0 },    /* MKDIR */
  1104. #else
  1105.     { "mkdir",       XXNOTAV, CM_INV },
  1106. #endif /* CK_MKDIR */
  1107.  
  1108. #ifndef NOXFER
  1109. #ifndef NOMSEND
  1110.     { "mmove",       XXMMOVE, 0 },    /* MMOVE */
  1111. #else
  1112.     { "mmove",       XXNOTAV, CM_INV },
  1113. #endif /* NOMSEND */
  1114. #endif /* NOXFER */
  1115.  
  1116. #ifndef NOFRILLS
  1117.     { "more",        XXMORE, CM_INV },    /* MORE */
  1118. #endif /* NOFRILLS */
  1119.  
  1120. #ifndef NOXFER
  1121.     { "move",        XXMOVE, 0 },    /* MOVE  */
  1122. #endif /* NOXFER */
  1123.  
  1124. #ifndef NOSPL
  1125.     { "mpause",      XXMSL, CM_INV },    /* Millisecond sleep */
  1126. #else
  1127.     { "mpause",      XXNOTAV, CM_INV },
  1128. #endif /* NOSPL */
  1129.  
  1130. #ifndef NOXFER
  1131. #ifndef NOMSEND
  1132.     { "mput",        XXMSE, CM_INV },    /* MPUT = MSEND */
  1133.     { "ms",          XXMSE, CM_INV|CM_ABR },
  1134.     { "msend",       XXMSE, 0 },    /* Multiple SEND */
  1135. #else
  1136.     { "mput",        XXNOTAV, CM_INV },
  1137.     { "msend",       XXNOTAV, CM_INV },
  1138. #endif /* NOMSEND */
  1139. #endif /* NOXFER */
  1140. #ifndef NOSPL
  1141.     { "msleep",      XXMSL, 0 },    /* Millisecond sleep */
  1142. #else
  1143.     { "msleep",      XXNOTAV, CM_INV },
  1144. #endif /* NOSPL */
  1145. #ifndef NOFRILLS
  1146.     { "mv",          XXREN, CM_INV },    /* Synonym for rename */
  1147. #endif /* NOFRILLS */
  1148. #ifndef NOHELP
  1149.     { "news",        XXNEW, CM_INV },    /* Display NEWS of new features */
  1150. #else
  1151.     { "news",        XXNOTAV, CM_INV },
  1152. #endif /* NOHELP */
  1153.     { "nolocal",     XXNLCL, CM_INV },    /* Disable SET LINE / SET HOST */
  1154.     { "nopush",      XXNPSH, CM_INV },    /* Disable PUSH command/features */
  1155. #ifndef NOSPL
  1156.     { "o",           XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */
  1157.     { "open",        XXOPE, 0 },    /* OPEN file for reading or writing */
  1158. #else
  1159.     { "open",        XXNPSH, CM_INV },    /* Disable PUSH command/features */
  1160. #endif /* NOSPL */
  1161. #ifndef NOHELP
  1162.     { "options",     XXOPTS,CM_INV|CM_HLP }, /* Options */
  1163. #endif /* NOHELP */
  1164.     { "orientation", XXORIE, 0 },
  1165. #ifndef NOSPL
  1166.     { "output",      XXOUT, 0 },    /* OUTPUT text to comm device */
  1167. #else
  1168.     { "output",      XXNOTAV, CM_INV },
  1169. #endif /* NOSPL */
  1170. #ifdef ANYX25
  1171. #ifndef IBMX25
  1172.     { "pad",         XXPAD, CM_LOC },    /* X.3 PAD commands */
  1173. #endif /* IBMX25 */
  1174. #endif /* ANYX25 */
  1175.  
  1176. #ifdef NEWFTP
  1177.     { "passive",     XXPASV, CM_INV },    /* (FTP) PASSIVE */
  1178. #endif /* NEWFTP */
  1179.  
  1180. #ifndef NOHELP
  1181.     { "patterns",    XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */
  1182. #endif /* NOHELP */
  1183.  
  1184. #ifndef NOSPL
  1185.     { "pause",       XXPAU, 0 },    /* Sleep for specified interval */
  1186. #else
  1187.     { "pause",       XXNOTAV, CM_INV },
  1188. #endif /* NOSPL */
  1189. #ifndef NODIAL
  1190.     { "pdial",       XXPDIA,  CM_LOC },    /* PDIAL (partial dial) */
  1191. #else
  1192.     { "pdial",       XXNOTAV, CM_INV|CM_LOC },
  1193. #endif /* NODIAL */
  1194. #ifdef TCPSOCKET
  1195. #ifndef NOPUSH
  1196.     { "ping",        XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */
  1197. #else
  1198.     { "ping",        XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  1199. #endif /* NOPUSH */
  1200. #endif /* TCPSOCKET */
  1201. #ifdef NETCMD
  1202. #ifndef NOPUSH
  1203.     { "pipe",        XXPIPE, CM_PSH },    /* PIPE */
  1204. #else
  1205.     { "pipe",        XXNOTAV, CM_INV|CM_PSH }, /* PIPE */
  1206. #endif /* NOPUSH */
  1207. #endif /* NETCMD */
  1208.  
  1209. #ifndef NOSPL
  1210.     { "pop",         XXEND, CM_INV },    /* Invisible synonym for END */
  1211. #endif /* NOSPL */
  1212. #ifndef NOFRILLS
  1213.     { "print",       XXPRI, 0 },    /* PRINT a file locally */
  1214. #endif /* NOFRILLS */
  1215.  
  1216.     { "prompt",      XXPROMP, CM_INV },    /* Go interactive (from script) */
  1217.  
  1218. #ifndef NOXFER
  1219. #ifdef CK_RESEND
  1220.     { "psend",       XXPSEN, CM_INV },    /* PSEND */
  1221. #else
  1222.     { "psend",       XXNOTAV, CM_INV },
  1223. #endif /* CK_RESEND */
  1224. #endif /* NOXFER */
  1225.  
  1226. #ifdef NETPTY
  1227.     { "pty",         XXPTY, CM_PSH },    /* PTY */
  1228. #else
  1229.     { "pty",         XXNOTAV, CM_INV|CM_PSH },
  1230. #endif /* NETPTY */
  1231.  
  1232. #ifndef NOPUSH
  1233.     { "pu",          XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */
  1234. #endif /* NOPUSH */
  1235.  
  1236. #ifdef CKPURGE
  1237.     { "purge",       XXPURGE, 0 },    /* PURGE (real) */
  1238. #else
  1239. #ifdef VMS
  1240.     { "purge",       XXPURGE, 0 },    /* PURGE (fake) */
  1241. #else
  1242.     { "purge",       XXNOTAV, CM_INV },
  1243. #endif /* VMS */
  1244. #endif /* CKPURGE */
  1245.  
  1246. #ifndef NOPUSH
  1247.     { "push",        XXSHE, CM_PSH },    /* PUSH command (like RUN, !) */
  1248. #else
  1249.     { "push",        XXNOTAV, CM_INV|CM_PSH },
  1250. #endif /* NOPUSH */
  1251.  
  1252. #ifndef NOXFER
  1253.     { "put",         XXSEN, CM_INV },    /* PUT = SEND */
  1254. #endif /* NOXFER */
  1255.  
  1256.     { "pwd",         XXPWD, 0 },    /* Print Working Directory */
  1257.     { "q",           XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */
  1258.  
  1259. #ifndef NOXFER
  1260.     { "query",       XXRQUE,CM_INV },    /* (= REMOTE QUERY) */
  1261. #endif /* NOXFER */
  1262.  
  1263.     { "quit",        XXQUI, 0 },    /* QUIT from program = EXIT */
  1264.  
  1265. #ifndef NOXFER
  1266.     { "r",           XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */
  1267. #endif /* NOXFER */
  1268.  
  1269. #ifndef NOXFER
  1270.     { "rasg",        XXRASG, CM_INV },    /* REMOTE ASSIGN */
  1271.     { "rassign",     XXRASG, CM_INV },    /* ditto */
  1272.     { "rcd",         XXRCWD, CM_INV },    /* REMOTE CD */
  1273.     { "rcdup",       XXRCDUP,CM_INV },    /* REMOTE CD */
  1274.     { "rcopy",       XXRCPY, CM_INV },    /* REMOTE COPY */
  1275.     { "rcwd",        XXRCWD, CM_INV },    /* REMOTE CWD */
  1276.     { "rdelete",     XXRDEL, CM_INV },    /* REMOTE DELETE */
  1277.     { "rdirectory",  XXRDIR, CM_INV },    /* REMODE DIRECTORY */
  1278. #endif /* NOXFER */
  1279.  
  1280. #ifndef NOSPL
  1281.     { "read",        XXREA, 0 },    /* READ a line from a file */
  1282. #else
  1283.     { "read",        XXNOTAV, CM_INV },
  1284. #endif /* NOSPL */
  1285.  
  1286. #ifndef NOXFER
  1287.     { "receive",     XXREC, 0 },    /* RECEIVE files */
  1288. #endif /* NOXFER */
  1289.  
  1290. #ifndef NODIAL
  1291.     { "red",         XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */
  1292.     { "redi",        XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */
  1293.     { "redial",      XXRED, CM_LOC },    /* REDIAL last DIAL number */
  1294. #else
  1295.     { "red",         XXNOTAV, CM_INV|CM_LOC },
  1296.     { "redi",        XXNOTAV, CM_INV|CM_LOC },
  1297.     { "redial",      XXNOTAV, CM_INV|CM_LOC },
  1298. #endif /* NODIAL */
  1299.  
  1300. #ifdef CK_REDIR
  1301. #ifdef OS2
  1302. #ifndef NOPUSH
  1303.     { "redirect",    XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  1304. #else
  1305.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1306. #endif /* NOPUSH */
  1307. #else /* OS2 */
  1308. #ifndef NOPUSH
  1309.     { "redirect",    XXFUN, CM_PSH },    /* REDIRECT */
  1310. #else
  1311.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1312. #endif /* NOPUSH */
  1313. #endif /* OS2 */
  1314. #endif /* CK_REDIR */
  1315.  
  1316. #ifdef CK_RECALL
  1317.     { "redo",        XXREDO,  CM_NOR },    /* REDO */
  1318. #else
  1319.     { "redo",        XXNOTAV, CM_INV },
  1320. #endif /* CK_RECALL */
  1321.  
  1322. #ifndef NOXFER
  1323. #ifdef CK_RESEND
  1324.     { "reget",       XXREGET, 0 },    /* REGET */
  1325. #else
  1326.     { "reget",       XXNOTAV, CM_INV },
  1327. #endif /* CK_RESEND */
  1328. #endif /* NOXFER */
  1329.  
  1330. #ifndef NOSPL
  1331.     { "reinput",     XXREI, CM_INV },    /* REINPUT (from INPUT buffer) */
  1332. #else
  1333.     { "reinput",     XXNOTAV, CM_INV },
  1334. #endif /* NOSPL */
  1335.  
  1336. #ifndef NOXFER
  1337. #ifdef ADDCMD
  1338.     { "rem",         XXREM, CM_INV|CM_ABR },
  1339.     { "remo",        XXREM, CM_INV|CM_ABR },
  1340. #endif /* ADDCMD */
  1341.     { "remote",         XXREM, 0 },    /* Send REMOTE command to server */
  1342. #endif /* NOXFER */
  1343.  
  1344. #ifdef ADDCMD
  1345.     { "remove",      XXREMV,0 },    /* REMOVE (something from a list) */
  1346. #else
  1347.     { "remove",      XXNOTAV, CM_INV },
  1348. #endif /* ADDCMD */
  1349.  
  1350. #ifndef NOFRILLS
  1351. #ifndef NORENAME
  1352.     { "rename",      XXREN, 0 },    /* RENAME a local file */
  1353. #else
  1354.     { "rename",      XXNOTAV, CM_INV },
  1355. #endif /* NORENAME */
  1356.     { "replay",      XXTYP, CM_INV },    /* REPLAY (for now, just type) */
  1357. #endif /* NOFRILLS */
  1358.  
  1359. #ifndef NOXFER
  1360. #ifdef CK_RESEND
  1361.     { "res",         XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1362.     { "rese",        XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1363.     { "resend",      XXRSEN, 0 },    /* RESEND */
  1364. #else
  1365.     { "res",         XXNOTAV, CM_INV },
  1366.     { "rese",        XXNOTAV, CM_INV },
  1367.     { "resend",      XXNOTAV, CM_INV },
  1368. #endif /* CK_RESEND */
  1369. #endif /* NOXFER */
  1370.  
  1371.     { "reset",       XXRESET, CM_INV },    /* RESET */
  1372.  
  1373. #ifdef CK_RESEND
  1374. #ifndef NOSPL
  1375.     { "ret",         XXRET, CM_INV|CM_ABR },
  1376. #endif /* NOSPL */
  1377. #endif /* CK_RESEND */
  1378.  
  1379. #ifndef NOXFER
  1380.     { "retrieve",    XXRETR, CM_INV },    /* RETRIEVE */
  1381. #endif /* NOXFER */
  1382.  
  1383. #ifndef NOSPL
  1384.     { "return",      XXRET, 0 },    /* RETURN from a function */
  1385. #else
  1386.     { "return",      XXNOTAV, CM_INV },
  1387. #endif /* NOSPL */
  1388.  
  1389. #ifndef NOXFER
  1390.     { "rexit",       XXRXIT, CM_INV },    /* REMOTE EXIT */
  1391. #endif /* NOXFER */
  1392.  
  1393. #ifdef CK_REXX
  1394. #ifndef NOPUSH
  1395.     { "rexx",        XXREXX, CM_PSH },    /* Execute a Rexx command */
  1396. #else
  1397.     { "rexx",        XXNOTAV, CM_INV|CM_PSH },
  1398. #endif /* NOPUSH */
  1399. #endif /* CK_REXX */
  1400.  
  1401. #ifndef NOXFER
  1402.     { "rhelp",       XXRHLP, CM_INV },    /* REMOTE HELP */
  1403.     { "rhost",       XXRHOS, CM_INV },    /* REMOTE HOST */
  1404.     { "rkermit",     XXRKER, CM_INV },    /* REMOTE KERMIT */
  1405. #endif /* NOXFER */
  1406.  
  1407. #ifdef TCPSOCKET
  1408.     { "rlogin",      XXRLOG, CM_LOC },    /* Make an Rlogin connection */
  1409. #else
  1410.     { "rlogin",      XXNOTAV, CM_INV|CM_LOC },
  1411. #endif /* TCPSOCKET */
  1412.  
  1413. #ifndef NOFRILLS
  1414.     { "rm",          XXDEL, CM_INV },    /* Invisible synonym for delete */
  1415. #endif /* NOFRILLS */
  1416.  
  1417. #ifdef CK_MKDIR
  1418.     { "rmdir",       XXRMDIR, 0 },    /* RMDIR */
  1419. #else
  1420.     { "rmdir",       XXNOTAV, CM_INV },
  1421. #endif /* CK_MKDIR */
  1422.  
  1423. #ifndef NOXFER
  1424.     { "rmkdir",      XXRMKD, CM_INV },    /* REMOTE MKDIR */
  1425. #ifndef NOSPL
  1426.     { "robust",      XXROB,  CM_INV },
  1427. #else
  1428.     { "robust",      XXNOTAV, CM_INV },
  1429. #endif /* NOSPL */
  1430.     { "rprint",      XXRPRI, CM_INV },  /* REMOTE PRINT */
  1431.     { "rpwd",        XXRPWD, CM_INV },    /* REMOTE PWD */
  1432.     { "rquery",      XXRQUE, CM_INV },    /* REMOTE QUERY */
  1433. #endif /* NOXFER */
  1434.  
  1435. #ifdef CK_RECALL
  1436.     { "rr",          XXREDO, CM_INV|CM_NOR },
  1437. #endif /* CK_RECALL */
  1438.  
  1439. #ifndef NOXFER
  1440.     { "rrename",    XXRREN, CM_INV },    /* REMOTE RENAME */
  1441.     { "rrmdir",     XXRRMD, CM_INV },    /* REMOTE REMDIR */
  1442.     { "rset",       XXRSET, CM_INV },    /* REMOTE SET */
  1443.     { "rspace",     XXRSPA, CM_INV },    /* REMOTE SPACE */
  1444.     { "rtype",      XXRTYP, CM_INV },    /* REMOTE TYPE */
  1445. #endif /* NOXFER */
  1446.  
  1447. #ifndef NOPUSH
  1448.     { "run",         XXSHE, CM_PSH },    /* RUN a program or command */
  1449. #else
  1450.     { "run",         XXNOTAV, CM_INV|CM_PSH },
  1451. #endif /* NOPUSH */
  1452.  
  1453. #ifndef NOXFER
  1454.     { "rwho",        XXRWHO, CM_INV },    /* REMOTE WHO */
  1455.     { "s",           XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */
  1456. #endif /* NOXFER */
  1457.  
  1458. #ifndef NOSETKEY
  1459. #ifdef OS2
  1460.     { "save",       XXSAVE, 0 },        /* SAVE something */
  1461. #else
  1462.     { "save",       XXSAVE, CM_INV },
  1463. #endif /* OS2 */
  1464. #else
  1465.     { "save",       XXNOTAV, CM_INV },
  1466. #endif /* NOSETKEY */
  1467.  
  1468. #ifndef NOSCRIPT
  1469.     { "sc",        XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1470.     { "scr",       XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1471. #endif /* NOSCRIPT */
  1472.     { "screen",      XXSCRN, 0 },    /* SCREEN actions */
  1473. #ifndef NOSCRIPT
  1474.     { "script",       XXLOGI, CM_LOC },    /* Expect-Send-style script line */
  1475. #else
  1476.     { "script",       XXNOTAV, CM_INV|CM_LOC },
  1477. #endif /* NOSCRIPT */
  1478.  
  1479.     { "search",    XXGREP,CM_INV },    /* Synonym for GREP and FIND */
  1480.  
  1481. #ifndef NOXFER
  1482.     { "send",       XXSEN, 0 },        /* Send (a) file(s) */
  1483. #ifndef NOSERVER
  1484.     { "server",       XXSER, 0 },        /* Be a SERVER */
  1485. #else
  1486.     { "server",       XXNOTAV, CM_INV },
  1487. #endif /* NOSERVER */
  1488. #endif /* NOXFER */
  1489.  
  1490.     { "set",       XXSET, 0 },        /* SET parameters */
  1491.  
  1492. #ifndef NOSPL
  1493. #ifndef NOSEXP
  1494.     { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */
  1495. #endif /* NOSEXP */
  1496. #ifndef NOSHOW
  1497.     { "sh",          XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */
  1498. #endif /* NOSHOW */
  1499.     { "shift",       XXSHIFT, 0 },    /* SHIFT args */
  1500. #else
  1501.     { "shift",       XXNOTAV, CM_INV },
  1502. #endif /* NOSPL */
  1503.  
  1504. #ifndef NOSHOW
  1505.     { "show",        XXSHO, 0 },        /* SHOW parameters */
  1506. #else
  1507.     { "show",        XXNOTAV, CM_INV },
  1508. #endif /* NOSHOW */
  1509.  
  1510. #ifndef NOSPL
  1511. #ifndef NOFRILLS
  1512.     { "sleep",       XXPAU, CM_INV },    /* SLEEP for specified interval */
  1513. #endif /* NOFRILLS */
  1514. #endif /* NOSPL */
  1515.  
  1516. #ifdef NEWFTP
  1517.     { "site",        XXSITE, CM_INV },    /* (FTP) SITE */
  1518. #endif /* NEWFTP */
  1519.  
  1520. #ifndef NOSPL
  1521.     { "sort",        XXSORT, CM_INV },    /* (see ARRAY) */
  1522. #else
  1523.     { "sort",        XXNOTAV, CM_INV },
  1524. #endif /* NOSPL */
  1525.  
  1526. #ifndef MAC
  1527. #ifndef NOFRILLS
  1528.     { "sp",          XXSPA, CM_INV|CM_ABR },
  1529.     { "spa",         XXSPA, CM_INV|CM_ABR },
  1530. #endif /* NOFRILLS */
  1531.     { "space",       XXSPA, 0 },    /* Show available disk SPACE */
  1532. #endif /* MAC */
  1533.  
  1534. #ifndef NOFRILLS
  1535. #ifndef NOPUSH
  1536.     { "spawn",       XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1537. #else
  1538.     { "spawn",       XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1539. #endif /* NOPUSH */
  1540. #endif /* NOFRILLS */
  1541.  
  1542. #ifdef ANYSSH
  1543.     { "ssh",         XXSSH, 0 },
  1544. #endif /* ANYSSH */
  1545.  
  1546. #ifndef NOXFER
  1547.     { "sta",         XXSTA, CM_INV|CM_ABR },
  1548.     { "stat",        XXSTA, CM_INV|CM_ABR },
  1549.     { "statistics",  XXSTA, 0 },    /* Display file transfer stats */
  1550. #endif /* NOXFER */
  1551.  
  1552.     { "status",      XXSTATUS,0 },    /* Show status of previous command */
  1553.  
  1554. #ifndef NOSPL
  1555.     { "stop",        XXSTO,   0 },    /* STOP all take files and macros */
  1556.     { "succeed",     XXSUCC,  CM_INV },    /* SUCCEED */
  1557. #else
  1558.     { "stop",        XXNOTAV, CM_INV },
  1559.     { "succeed",     XXNOTAV, CM_INV },
  1560. #endif /* NOSPL */
  1561.  
  1562. #ifndef NOFRILLS
  1563.     { "SUPPORT",     XXBUG, 0 },    /* Tech support instructions */
  1564. #else
  1565.     { "support",     XXNOTAV, CM_INV },
  1566. #endif /* NOFRILLS */
  1567.  
  1568. #ifndef NOJC
  1569.     { "suspend",     XXSUS, CM_PSH },    /* SUSPEND C-Kermit (UNIX only) */
  1570. #else
  1571.     { "suspend",     XXNOTAV, CM_INV|CM_PSH },
  1572. #endif /* NOJC */
  1573.  
  1574. #ifndef NOSPL
  1575.     { "switch",      XXSWIT, 0 },    /* SWITCH */
  1576. #else
  1577.     { "switch",      XXNOTAV, CM_INV },
  1578. #endif /* NOSPL */
  1579.  
  1580. #ifdef CK_TAPI
  1581.     { "ta",       XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */
  1582. #endif /* CK_TAPI */
  1583.  
  1584. #ifndef NOFRILLS
  1585.     { "tail",        XXTAIL, 0 },    /* Display end of a local file */
  1586. #endif /* NOFRILLS */
  1587.  
  1588.     { "take",       XXTAK, 0 },        /* TAKE commands from a file */
  1589.  
  1590. #ifdef CK_TAPI
  1591.     { "tapi",       XXTAPI, CM_LOC },    /* Microsoft TAPI commands */
  1592. #else
  1593.     { "tapi",       XXNOTAV, CM_INV|CM_LOC },
  1594. #endif /* CK_TAPI */
  1595.  
  1596. #ifndef NOFRILLS
  1597. #ifdef TCPSOCKET
  1598.     { "tel",         XXTEL, CM_INV|CM_ABR|CM_LOC },
  1599.     { "telnet",      XXTEL, CM_LOC },    /* TELNET (TCP/IP only) */
  1600.     { "telopt",      XXTELOP, CM_INV },    /* TELOPT (ditto) */
  1601. #else
  1602.     { "tel",         XXNOTAV, CM_INV|CM_LOC },
  1603.     { "telnet",      XXNOTAV, CM_INV|CM_LOC },
  1604.     { "telopt",      XXNOTAV, CM_INV },
  1605. #endif /* TCPSOCKET */
  1606. #ifdef OS2
  1607.     { "terminal",    XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */
  1608. #else
  1609.     { "terminal",    XXTERM, CM_INV },
  1610. #endif /* OS2 */
  1611. #endif /* NOFRILLS */
  1612. #ifndef NOXFER
  1613.     { "text",        XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  1614. #endif /* NOXFER */
  1615.  
  1616. #ifndef NOSPL
  1617.     { "trace",       XXTRACE, 0 },    /* TRACE */
  1618. #else
  1619.     { "trace",       XXNOTAV, CM_INV },
  1620. #endif /* NOSPL */
  1621.  
  1622. #ifndef NOCSETS
  1623.     { "translate",   XXXLA, 0 },    /* TRANSLATE local file char sets */
  1624. #else
  1625.     { "translate",   XXNOTAV, CM_INV },
  1626. #endif /* NOCSETS */
  1627.  
  1628. #ifndef NOXMIT
  1629.     { "transmit",    XXTRA, 0 },    /* Send (upload) a file, no protocol */
  1630. #else
  1631.     { "transmit",    XXNOTAV, CM_INV },
  1632. #endif /* NOXMIT */
  1633.  
  1634. #ifndef NOFRILLS
  1635.     { "type",        XXTYP, 0 },    /* Display a local file */
  1636. #endif /* NOFRILLS */
  1637.  
  1638. #ifndef NOSPL
  1639.     { "undcl",       XXUNDCL, CM_INV },
  1640.     { "undeclare",   XXUNDCL, 0 },    /* UNDECLARE an array */
  1641.     { "undefine",    XXUNDEF, 0 },    /* UNDEFINE a variable or macro */
  1642. #else
  1643.     { "undcl",       XXNOTAV, CM_INV },
  1644.     { "undeclare",   XXNOTAV, CM_INV },
  1645.     { "undefine",    XXNOTAV, CM_INV },
  1646. #endif /* NOSPL */
  1647.  
  1648. #ifdef NEWFTP
  1649.     { "user",        XXUSER,  CM_INV }, /* (FTP) USER */
  1650. #endif /* NEWFTP */
  1651.  
  1652.     { "version",     XXVER, 0 },    /* VERSION-number display */
  1653.  
  1654. #ifdef OS2
  1655.     { "viewonly",    XXVIEW, CM_LOC },    /* VIEWONLY Terminal Mode */
  1656. #endif /* OS2 */
  1657.  
  1658.     { "void",        XXVOID, 0 },    /* VOID */
  1659.  
  1660. #ifndef NOSPL
  1661.     { "wait",        XXWAI, 0 },    /* WAIT */
  1662. #else
  1663.     { "wait",        XXNOTAV, CM_INV },
  1664. #endif /* NOSPL */
  1665.  
  1666.     { "wermit",      XXKERMI, CM_INV },
  1667.  
  1668. #ifndef NOXFER
  1669.     { "where",       XXWHERE, 0 },    /* WHERE (did my file go?) */
  1670. #endif /* NOXFER */
  1671.  
  1672. #ifndef NOSPL
  1673.     { "while",       XXWHI, 0 },    /* WHILE loop */
  1674. #else
  1675.     { "while",       XXNOTAV, CM_INV },
  1676. #endif /* NOSPL */
  1677.  
  1678. #ifndef OS2
  1679. #ifndef MAC
  1680. #ifndef NOFRILLS
  1681.     { "who",         XXWHO, CM_PSH },    /* WHO's logged in? */
  1682. #endif /* NOFRILLS */
  1683. #endif /* MAC */
  1684. #endif /* OS2 */
  1685.  
  1686. #ifndef NOHELP
  1687.     { "wildcards",   XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */
  1688. #endif /* NOHELP */
  1689.  
  1690. #ifndef NOSPL
  1691.     { "wr",          XXWRI, CM_INV|CM_ABR },
  1692.     { "wri",         XXWRI, CM_INV|CM_ABR },
  1693.     { "writ",        XXWRI, CM_INV|CM_ABR },
  1694.     { "write",       XXWRI, 0 },    /* WRITE characters to a file */
  1695.     { "write-line",  XXWRL, CM_INV },    /* WRITE a line to a file */
  1696.     { "writeln",     XXWRL, CM_INV },    /* Pascalisch synonym for write-line */
  1697. #else
  1698.     { "wr",          XXNOTAV, CM_INV },
  1699.     { "wri",         XXNOTAV, CM_INV },
  1700.     { "writ",        XXNOTAV, CM_INV },
  1701.     { "write",       XXNOTAV, CM_INV },
  1702.     { "write-line",  XXNOTAV, CM_INV },
  1703.     { "writeln",     XXNOTAV, CM_INV },
  1704. #endif /* NOSPL */
  1705.  
  1706. #ifndef NOFRILLS
  1707.     { "xecho",       XXXECH,0 },    /* XECHO */
  1708. #endif /* NOFRILLS */
  1709.  
  1710. #ifndef NOSPL
  1711.     { "xif",         XXIFX, CM_INV },    /* Extended IF command (obsolete) */
  1712. #else
  1713.     { "xif",         XXNOTAV, CM_INV },
  1714. #endif /* NOSPL */
  1715.  
  1716. #ifndef NOCSETS
  1717.     { "xlate",       XXXLA, CM_INV },    /* Synonym for TRANSLATE */
  1718. #else
  1719.     { "xlate",       XXNOTAV, CM_INV },
  1720. #endif /* NOCSETS */
  1721.  
  1722. #ifndef NOXMIT
  1723.     { "xmit",        XXTRA, CM_INV },    /* Synonym for TRANSMIT */
  1724. #else
  1725.     { "xmit",        XXNOTAV, CM_INV },
  1726. #endif /* NOXMIT */
  1727.  
  1728. #ifndef OS2
  1729. #ifndef NOJC
  1730.     { "z",           XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */
  1731. #else
  1732.     { "z",           XXNOTAV, CM_INV|CM_PSH },
  1733. #endif /* NOJC */
  1734. #endif /* OS2 */
  1735.  
  1736. #ifndef NOSPL
  1737.     { "{",           XXMACRO, CM_INV },    /* Immediate macro */
  1738. #endif /* NOSPL */
  1739.     { "", 0, 0 }
  1740. };
  1741. int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1;
  1742.  
  1743. /* NOTE: Tokens must also be entered above into cmdtab[]. */
  1744.  
  1745. char toktab[] = {
  1746. #ifndef NOPUSH
  1747.     '!',                /* Shell escape */
  1748. #endif /* NOPUSH */
  1749.     '#',                /* Comment */
  1750. #ifndef NOSPL
  1751.     '(',                /* S-Expression */
  1752.     '.',                /* Assignment */
  1753. #endif /* NOSPL */
  1754.     ';',                /* Comment */
  1755. #ifndef NOSPL
  1756.     ':',                /* Label */
  1757. #endif /* NOSPL */
  1758. #ifndef NOPUSH
  1759. #ifdef CK_REDIR
  1760.     '<',                /* REDIRECT */
  1761. #endif /* CK_REDIR */
  1762.     '@',                /* DCL escape */
  1763. #endif /* NOPUSH */
  1764. #ifdef CK_RECALL
  1765.     '^',                /* Command recall */
  1766. #endif /* CK_RECALL */
  1767. #ifndef NOSPL
  1768.     '{',                /* Immediate macro */
  1769. #endif /* NOSPL */
  1770.     '\0'                /* End of this string */
  1771. };
  1772. int xxdot = 0;                /* Used with "." token */
  1773.  
  1774. struct keytab yesno[] = {        /* Yes/No keyword table */
  1775.     { "no",    0, 0 },
  1776.     { "ok",    1, 0 },
  1777.     { "yes",   1, 0 }
  1778. };
  1779. int nyesno = (sizeof(yesno) / sizeof(struct keytab));
  1780.  
  1781. /* Save keyword table */
  1782.  
  1783. struct keytab savtab[] = {
  1784. #ifdef OS2
  1785.     { "command",  XSCMD, 0 },
  1786. #else
  1787. #ifdef CK_RECALL
  1788.     { "command",  XSCMD, 0 },
  1789. #endif /* CK_RECALL */
  1790. #endif /* OS2 */
  1791. #ifndef NOSETKEY
  1792.     { "keymap",   XSKEY, 0 },
  1793. #endif /* NOSETKEY */
  1794. #ifdef OS2
  1795.     { "terminal", XSTERM, 0 },
  1796. #endif /* OS2 */
  1797.     { "", 0, 0 }
  1798. };
  1799. int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1;
  1800.  
  1801. /* Parameter keyword table */
  1802.  
  1803. struct keytab prmtab[] = {
  1804.     { "alarm",            XYALRM,  0 },
  1805. #ifdef COMMENT                /* SET ANSWER not implemented yet */
  1806. #ifndef NODIAL
  1807.     { "answer",           XYANSWER,0 },
  1808. #endif /* NODIAL */
  1809. #endif /* COMMENT */
  1810.     { "ask-timer",        XYTIMER, 0 },
  1811. #ifndef NOXFER
  1812.     { "attributes",       XYATTR,  0 },
  1813. #endif /* NOXFER */
  1814. #ifdef CK_AUTHENTICATION
  1815.     { "authentication",   XYAUTH,  0 },
  1816. #else  /* CK_AUTHENTICATION */
  1817. #ifdef CK_SSL
  1818.     { "authentication",   XYAUTH,  0 },
  1819. #endif /* CK_SSL */
  1820. #endif /* CK_AUTHENTICATION */
  1821.     { "b",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1822.     { "ba",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1823. #ifdef VMS
  1824.     { "background",       XYBACK,  CM_INV|CM_PSH },
  1825.     { "batch",            XYBACK,  CM_PSH },
  1826. #else
  1827.     { "background",       XYBACK,  CM_PSH },
  1828.     { "batch",            XYBACK,  CM_INV|CM_PSH },
  1829. #endif /* VMS */
  1830. #ifndef NOLOCAL
  1831.     { "baud",              XYSPEE,  CM_INV|CM_LOC },
  1832. #endif /* NOLOCAL */
  1833.     { "bell",             XYBELL,  0 },
  1834. #ifndef NOXFER
  1835.     { "block-check",        XYCHKT,  0 },
  1836. #endif /* NOXFER */
  1837. #ifdef OS2
  1838. #ifdef BPRINT
  1839.     { "bprinter",         XYBDCP,  CM_INV },
  1840. #endif /* BPRINT */
  1841. #endif /*  OS2 */
  1842. #ifdef BROWSER
  1843.     { "browser",          XYBROWSE,CM_PSH|CM_LOC },
  1844. #endif /* BROWSER */
  1845. #ifndef NOXFER
  1846. #ifdef DYNAMIC
  1847.     { "buffers",          XYBUF,   0 },
  1848. #endif /* DYNAMIC */
  1849. #endif /* NOXFER */
  1850. #ifndef NOLOCAL
  1851. #ifndef MAC
  1852.     { "carrier-watch",    XYCARR,  CM_LOC },
  1853. #endif /* MAC */
  1854. #endif /* NOLOCAL */
  1855. #ifndef NOSPL
  1856.     { "case",             XYCASE,  0 },
  1857. #endif /* NOSPL */
  1858.     { "cd",               XYCD,    0 },
  1859. #ifndef NOXFER
  1860.     { "cl",               XYCLEAR, CM_INV|CM_ABR },
  1861.     { "cle",              XYCLEAR, CM_INV|CM_ABR },
  1862.     { "clea",             XYCLEAR, CM_INV|CM_ABR },
  1863.     { "clear",            XYCLEAR, CM_INV|CM_ABR },
  1864.     { "clear-channel",    XYCLEAR, 0 },
  1865.     { "clearchannel",     XYCLEAR, CM_INV },
  1866. #endif /* NOXFER */
  1867. #ifndef NOLOCAL
  1868.     { "close-on-disconnect", XYDISC, CM_INV|CM_LOC },
  1869. #endif /* NOLOCAL */
  1870.     { "cmd",              XYCMD,   CM_INV },
  1871.     { "command",          XYCMD,   0 },
  1872. #ifdef CK_SPEED
  1873.     { "con",              XYQCTL,  CM_INV|CM_ABR },
  1874. #endif /* CK_SPEED */
  1875.     { "console",          XYCMD,   CM_INV },
  1876. #ifdef CK_SPEED
  1877.     { "control-character",XYQCTL,  0 },
  1878. #endif /* CK_SPEED */
  1879. #ifndef NOSPL
  1880.     { "count",            XYCOUN,  0 },
  1881. #endif /* NOSPL */
  1882. #ifndef NOXFER
  1883.     { "d",          XYDELA,  CM_INV|CM_ABR },
  1884.     { "de",          XYDELA,  CM_INV|CM_ABR },
  1885. #endif /* NOXFER */
  1886.     { "debug",            XYDEBU,  0 },
  1887. #ifdef VMS
  1888.     { "default",          XYDFLT,  0 },
  1889. #else
  1890. #ifndef MAC
  1891.     { "default",          XYDFLT,  CM_INV },
  1892. #endif /* MAC */
  1893. #endif /* VMS */
  1894. #ifndef NOXFER
  1895.     { "delay",              XYDELA,  0 },
  1896.     { "destination",      XYDEST,  0 },
  1897. #endif /* NOXFER */
  1898. #ifndef NODIAL
  1899.     { "di",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1900.     { "dia",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1901.     { "dial",             XYDIAL,  CM_LOC },
  1902. #endif /* NODIAL */
  1903. #ifdef OS2
  1904.     { "dialer",          XYDLR,   CM_INV },
  1905. #endif /* OS2 */
  1906. #ifndef NOLOCAL
  1907.     { "disconnect",       XYDISC,  CM_LOC },
  1908.     { "duplex",              XYDUPL,  CM_LOC },
  1909. #endif /* NOLOCAL */
  1910. #ifndef NOPUSH
  1911. #ifndef NOFRILLS
  1912.     { "editor",           XYEDIT,  CM_PSH },
  1913. #endif /*  NOFRILLS */
  1914. #endif /* NOPUSH */
  1915. #ifdef CK_CTRLZ
  1916.     { "eof",              XYEOF,   CM_INV },
  1917. #endif /* CK_CTRLZ */
  1918. #ifndef NOLOCAL
  1919.     { "escape-character", XYESC,   CM_LOC },
  1920. #endif /* NOLOCAL */
  1921. #ifndef NOSPL
  1922.     { "evaluate",         XYEVAL,  CM_INV },
  1923. #endif /* NOSPL */
  1924.     { "exit",          XYEXIT,  0 },
  1925. #ifndef NOXFER
  1926.     { "f-ack-bug",        XYFACKB, CM_INV },
  1927.     { "f-ack-path",       XYFACKP, CM_INV },
  1928. #endif /* NOXFER */
  1929.     { "file",             XYFILE,  0 },
  1930.     { "fl",                 XYFLOW,  CM_INV|CM_ABR },
  1931. #ifndef NOSPL
  1932.     { "flag",             XYFLAG,  0 },
  1933. #endif /* NOSPL */
  1934. #ifdef TCPSOCKET
  1935. #ifndef SYSFTP
  1936. #ifndef NOFTP
  1937.     { "ft",                 XYFTPX,  CM_INV|CM_ABR },
  1938.     { "ftp",                XYFTPX,  0 },
  1939. #endif /* NOFTP */
  1940. #endif /* SYSFTP */
  1941. #endif /* TCPSOCKET */
  1942. #ifdef BROWSER
  1943.     { "ftp-client",       XYFTP,   CM_PSH },
  1944. #endif /* BROWSER */
  1945.     { "flow-control",       XYFLOW,  0 },
  1946. #ifndef NOSPL
  1947.     { "function",         XYFUNC,  0 },
  1948. #endif /* NOSPL */
  1949. #ifdef NEWFTP
  1950.     { "get-put-remote",   XYGPR,   0 },
  1951. #endif /* NEWFTP */
  1952. #ifdef KUI
  1953.     { "gui",              XYGUI,   0 },
  1954. #endif /* KUI */
  1955.     { "handshake",          XYHAND,  0 },
  1956.     { "hints",            XYHINTS, 0 },
  1957. #ifdef NETCONN
  1958.     { "host",             XYHOST,  CM_LOC },
  1959. #endif /* NETCONN */
  1960. #ifndef NOSPL
  1961.     { "i",          XYINPU,  CM_INV|CM_ABR },
  1962. #endif /* NOSPL */
  1963. #ifdef IKSD
  1964.     { "iks",              XYIKS,   0 },
  1965. #else
  1966.     { "iks",              XYIKS,   CM_INV },
  1967. #endif /* IKSD */
  1968. #ifndef NOSPL
  1969.     { "in",          XYINPU,  CM_INV|CM_ABR },
  1970. #endif /* NOSPL */
  1971. #ifndef NOXFER
  1972.     { "incomplete",         XYIFD,   CM_INV },
  1973. #endif /* NOXFER */
  1974. #ifndef NOSPL
  1975.     { "input",            XYINPU,  0 },
  1976. #endif /* NOSPL */
  1977. #ifndef NOSETKEY
  1978.     { "key",          XYKEY,   0 },
  1979. #endif /* NOSETKEY */
  1980.     { "l",                XYLINE,  CM_INV|CM_ABR },
  1981. #ifndef NOCSETS
  1982.     { "language",         XYLANG,  0 },
  1983. #endif /* NOCSETS */
  1984. #ifndef NOLOCAL
  1985.     { "line",             XYLINE,  CM_LOC },
  1986.     { "local-echo",      XYLCLE,  CM_INV|CM_LOC },
  1987. #endif /* NOLOCAL */
  1988. #ifdef LOCUS
  1989.     { "locus",            XYLOCUS, 0 },
  1990. #endif /* LOCUS */
  1991. #ifndef NOSPL
  1992.     { "login",          XYLOGIN, CM_LOC },
  1993. #endif /* NOSPL */
  1994. #ifndef NOSPL
  1995.     { "macro",            XYMACR,  0 },
  1996. #endif /* NOSPL */
  1997.     { "match",            XYMATCH, 0 },
  1998. #ifdef COMMENT
  1999. #ifdef VMS
  2000.     { "messages",         XYMSGS,  0 },
  2001. #endif /* VMS */
  2002. #endif /* COMMENT */
  2003. #ifndef NODIAL
  2004.     { "modem",          XYMODM,  CM_LOC },
  2005. #endif /* NODIAL */
  2006. #ifndef NOLOCAL
  2007. #ifdef OS2MOUSE
  2008.     { "mouse",          XYMOUSE, 0 },
  2009. #endif /* OS2MOUSE */
  2010. #endif /* NOLOCAL */
  2011. #ifdef OS2
  2012.     { "mskermit",         XYMSK,   0 },
  2013. #endif /* OS2 */
  2014. #ifdef NETCONN
  2015.     { "network",          XYNET,   CM_LOC },
  2016. #endif /* NETCONN */
  2017. #ifndef NOSPL
  2018.     { "output",           XYOUTP,  0 },
  2019. #endif /* NOSPL */
  2020.     { "options",          XYOPTS,  0 },
  2021.     { "pause",            XYSLEEP, CM_INV },
  2022. #ifdef ANYX25
  2023. #ifndef IBMX25
  2024.     { "pad",              XYPAD,   CM_LOC },
  2025. #endif /* IBMX25 */
  2026. #endif /* ANYX25 */
  2027.     { "parity",              XYPARI,  0 },
  2028. #ifndef NOLOCAL
  2029. #ifdef OS2
  2030.     { "port",             XYLINE,  CM_LOC },
  2031. #else
  2032.     { "port",             XYLINE,  CM_INV|CM_LOC },
  2033. #endif /* OS2 */
  2034. #endif /* NOLOCAL */
  2035. #ifndef NOFRILLS
  2036.     { "pr",                 XYPROM,  CM_INV|CM_ABR },
  2037.     { "printer",          XYPRTR,  0 },
  2038. #endif /* NOFRILLS */
  2039. #ifdef OS2
  2040.     { "priority",         XYPRTY,  0 },
  2041. #endif /* OS2 */
  2042. #ifdef CK_SPEED
  2043.     { "prefixing",        XYPREFIX, 0 },
  2044. #endif /* CK_SPEED */
  2045. #ifndef NOFRILLS
  2046.     { "prompt",              XYPROM,  0 },
  2047. #endif /* NOFRILLS */
  2048. #ifndef NOXFER
  2049.     { "protocol",      XYPROTO, 0 },
  2050. #endif /* NOXFER */
  2051.     { "q",          XYQUIE,  CM_INV|CM_ABR },
  2052. #ifndef NOXFER
  2053.     { "q8flag",           XYQ8FLG, CM_INV },
  2054. #endif /* NOXFER */
  2055. #ifdef QNX
  2056.     { "qnx-port-lock",    XYQNXPL, 0 },
  2057. #else
  2058.     { "qnx-port-lock",    XYQNXPL, CM_INV },
  2059. #endif /* QNX */
  2060.     { "quiet",          XYQUIE,  0 },
  2061. #ifndef NOXFER
  2062.     { "rec",              XYRECV,  CM_INV|CM_ABR },
  2063.     { "receive",          XYRECV,  0 },
  2064.     { "recv",             XYRECV,  CM_INV },
  2065. #endif /* NOXFER */
  2066.     { "reliable",         XYRELY,  0 },
  2067. #ifndef NOXFER
  2068.     { "repeat",           XYREPT,  0 },
  2069.     { "retry-limit",      XYRETR,  0 },
  2070. #endif /* NOXFER */
  2071. #ifdef CKROOT
  2072.     { "root",             XYROOT,  0 },
  2073. #endif /* CKROOT */
  2074. #ifndef NOSCRIPT
  2075.     { "script",          XYSCRI,  CM_LOC },
  2076. #endif /* NOSCRIPT */
  2077. #ifndef NOXFER
  2078.     { "send",             XYSEND,  0 },
  2079. #ifndef NOLOCAL
  2080. #ifndef NOSERVER
  2081.     { "ser",              XYSERV,  CM_INV|CM_ABR },
  2082. #endif /* NOSERVER */
  2083. #endif /* NOXFER */
  2084.     { "serial",           XYSERIAL,CM_LOC },
  2085. #endif /* NOLOCAL */
  2086. #ifndef NOSERVER
  2087.     { "server",           XYSERV,  0 },
  2088. #endif /* NOSERVER */
  2089. #ifdef SESLIMIT
  2090. #ifndef NOLOCAL
  2091.     { "session-l",        XYSESS,  CM_INV|CM_ABR },
  2092. #endif /* NOLOCAL */
  2093.     { "session-limit",    XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */
  2094. #endif /* SESLIMIT */
  2095.  
  2096. #ifndef NOLOCAL
  2097.     { "session-log",      XYSESS,  CM_LOC },
  2098. #endif /* NOLOCAL */
  2099.  
  2100. #ifndef NOSPL
  2101. #ifndef NOSEXP
  2102.     { "sexpression",      XYSEXP,  CM_INV },
  2103. #endif /* NOSEXP */
  2104. #endif /* NOSPL */
  2105.  
  2106.     { "sleep",            XYSLEEP, 0 },
  2107.  
  2108. #ifndef NOLOCAL
  2109.     { "speed",              XYSPEE,  CM_LOC },
  2110. #endif /* NOLOCAL */
  2111.  
  2112. #ifdef ANYSSH
  2113.     { "ssh",              XYSSH,   0 },
  2114. #endif /* ANYSSH */
  2115.  
  2116. #ifndef NOSPL
  2117.     { "startup-file",     XYSTARTUP, CM_INV },
  2118. #endif /* NOSPL */
  2119.  
  2120. #ifndef NOLOCAL
  2121. #ifdef HWPARITY
  2122.     { "stop-bits",        XYSTOP, CM_LOC },
  2123. #else
  2124. #ifdef TN_COMPORT
  2125.     { "stop-bits",        XYSTOP, CM_LOC },
  2126. #endif /* TN_COMPORT */
  2127. #endif /* HWPARITY */
  2128. #endif /* NOLOCAL */
  2129.  
  2130. #ifndef NOXFER
  2131. #ifdef STREAMING
  2132.     { "streaming",        XYSTREAM, 0 },
  2133. #endif /* STREAMING */
  2134. #endif /* NOXFER */
  2135.  
  2136. #ifndef NOJC
  2137.     { "suspend",          XYSUSP,  CM_PSH },
  2138. #endif /* NOJC */
  2139. #ifdef CKSYSLOG
  2140.     { "syslog",           XYSYSL,  CM_INV },
  2141. #endif /* CKSYSLOG */
  2142.     { "take",             XYTAKE,  0 },
  2143.  
  2144. #ifdef CK_TAPI
  2145.     { "tapi",             XYTAPI,  CM_LOC },
  2146. #endif /* CK_TAPI */
  2147.  
  2148. #ifndef NOTCPOPTS
  2149. #ifdef TCPSOCKET
  2150.     { "tcp",              XYTCP,   CM_LOC },
  2151. #endif /* TCPSOCKET */
  2152. #endif /* NOTCPOPTS */
  2153.  
  2154. #ifdef TNCODE
  2155.     { "tel",              XYTEL,   CM_INV|CM_ABR },
  2156.     { "telnet",           XYTEL,   0 },
  2157.     { "telopt",           XYTELOP, 0 },
  2158. #endif /* TNCODE */
  2159.  
  2160. #ifndef NOSPL
  2161.     { "temp-directory",   XYTMPDIR,0 },
  2162. #endif /* NOSPL */
  2163.  
  2164. #ifndef NOLOCAL
  2165.     { "terminal",         XYTERM,  CM_LOC },
  2166. #endif /* NOLOCAL */
  2167.  
  2168. #ifdef OS2
  2169.     { "title",          XYTITLE, CM_LOC },
  2170. #endif /* OS2 */
  2171. #ifdef TLOG
  2172.     { "transaction-log",  XYTLOG,  0 },
  2173. #endif /* TLOG */
  2174. #ifndef NOXFER
  2175.     { "transfer",         XYXFER,  0 },
  2176. #endif /* NOXFER */
  2177. #ifndef NOXMIT
  2178.     { "transmit",         XYXMIT,  0 },
  2179. #endif /* NOXMIT */
  2180. #ifndef NOXFER
  2181. #ifndef NOCSETS
  2182.     { "unknown-char-set", XYUNCS,  0 },
  2183. #endif /* NOCSETS */
  2184. #endif /* NOXFER */
  2185.     { "wait",             XYSLEEP, CM_INV },
  2186. #ifndef NOPUSH
  2187. #ifdef UNIX
  2188.     { "wildcard-expansion", XYWILD, 0 },
  2189. #endif /* UNIX */
  2190. #endif /* NOPUSH */
  2191. #ifdef NT
  2192.     { "w",                XYWIND,  CM_INV|CM_ABR },
  2193.     { "wi",               XYWIND,  CM_INV|CM_ABR },
  2194.     { "win",              XYWIND,  CM_INV|CM_ABR },
  2195. #endif /* NT */
  2196.     { "window-size",      XYWIND,  0 },
  2197. #ifdef NT
  2198.     { "win95",            XYWIN95, 0 },
  2199. #endif /* NT */
  2200. #ifdef ANYX25
  2201.     { "x.25",             XYX25,   CM_LOC },
  2202.     { "x25",              XYX25,   CM_INV|CM_LOC },
  2203. #endif /* ANYX25 */
  2204.     { "xfer",             XYXFER,  CM_INV },
  2205. #ifndef NOXMIT
  2206.     { "xmit",             XYXMIT,  CM_INV },
  2207. #endif /* NOXMIT */
  2208.     { "", 0, 0 }
  2209. };
  2210. int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */
  2211.  
  2212. struct keytab scntab[] = {        /* Screen commands */
  2213.     { "clear",   SCN_CLR, 0 },
  2214.     { "cleol",   SCN_CLE, 0 },
  2215.     { "move-to", SCN_MOV, 0 }
  2216. };
  2217. int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */
  2218.  
  2219. #ifdef ANYSSH                /* SSH command table */
  2220. #ifdef SSHBUILTIN
  2221. int    ssh_pf_lcl_n = 0,
  2222.        ssh_pf_rmt_n = 0;
  2223. struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */
  2224. struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */
  2225. extern char * ssh_hst, * ssh_cmd, * ssh_prt;
  2226. extern int    ssh_ver,   ssh_xfw;
  2227. char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL,
  2228.      * ssh_tmpstr = NULL;
  2229.  
  2230. int
  2231.  sshk_type = SSHKT_2D,            /* SSH KEY CREATE /TYPE:x */
  2232.  sshk_bits = 1024,            /* SSH KEY CREATE /BITS:n */
  2233.  sshk_din  = SKDF_OSSH,            /* SSH KEY DISPLAY /IN-FORMAT: */
  2234.  sshk_dout = SKDF_OSSH;            /* SSH KEY DISPLAY /OUT-FORMAT: */
  2235.  
  2236. char
  2237.  * sshk1_comment = NULL,        /* SSH V1 COMMENT */
  2238.  * sshkp_old = NULL,            /* Old key passphrase */
  2239.  * sshkp_new = NULL,            /* New key passphrase */
  2240.  * sshkc_pass = NULL,            /* KEY CREATE /PASS:xxx */
  2241.  * sshkc_comm = NULL,            /* KEY CREATE /V1-RSA-COMMENT:xxx */
  2242.  * sshd_file = NULL,            /* DISPLAY file */
  2243.  * sshk_file = NULL;            /* SSH CREATE KEY file */
  2244.  
  2245. static struct keytab sshclr[] = {
  2246.     { "local-port-forward",  SSHC_LPF, 0 },
  2247.     { "remote-port-forward", SSHC_RPF, 0 },
  2248.     { "", 0, 0 }
  2249. };
  2250. static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1;
  2251.  
  2252. struct keytab sshopnsw[] = {
  2253.     { "/command",        SSHSW_CMD, CM_ARG },
  2254.     { "/password",       SSHSW_PWD, CM_ARG },
  2255.     { "/subsystem",      SSHSW_SUB, CM_ARG },
  2256.     { "/user",           SSHSW_USR, CM_ARG },
  2257.     { "/version",        SSHSW_VER, CM_ARG },
  2258.     { "/x11-forwarding", SSHSW_X11, CM_ARG },
  2259.     { "", 0, 0 }
  2260. };
  2261. int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1;
  2262.  
  2263. static struct keytab sshkwtab[] = {
  2264.     { "add",                 XSSH_ADD, 0 },
  2265.     { "agent",               XSSH_AGT, 0 },
  2266.     { "clear",               XSSH_CLR, 0 },
  2267.     { "forward-local-port",  XSSH_FLP, CM_INV },
  2268.     { "forward-remote-port", XSSH_FRP, CM_INV },
  2269.     { "key",                 XSSH_KEY, 0 },
  2270.     { "open",                XSSH_OPN, 0 },
  2271.     { "v2",                  XSSH_V2,  0 },
  2272.     { "", 0, 0 }
  2273. };
  2274. static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1;
  2275.  
  2276. static struct keytab ssh2tab[] = {
  2277.     { "rekey", XSSH2_RKE, 0 },
  2278.     { "", 0, 0 }
  2279. };
  2280. static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab));
  2281.  
  2282. static struct keytab addfwd[] = {    /* SET SSH ADD command table */
  2283.     { "local-port-forward",  SSHF_LCL, 0 },
  2284.     { "remote-port-forward", SSHF_RMT, 0 },
  2285.     { "", 0, 0 }
  2286. };
  2287. static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
  2288.  
  2289. static struct keytab sshagent[] = {    /* SET SSH AGENT command table */
  2290.     { "add",    SSHA_ADD, 0 },
  2291.     { "delete", SSHA_DEL, 0 },
  2292.     { "list",   SSHA_LST, 0 },
  2293.     { "", 0, 0 }
  2294. };
  2295. static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1;
  2296.  
  2297. static struct keytab sshagtsw[] = {    /* SET SSH AGENT LIST switch table */
  2298.     { "/fingerprint", SSHASW_FP, 0 },
  2299.     { "", 0, 0 }
  2300. };
  2301. static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1;
  2302.  
  2303. static struct keytab sshkey[] = {    /* SET SSH KEY command table */
  2304.     { "change-passphrase",  SSHK_PASS, 0 },
  2305.     { "create",             SSHK_CREA, 0 },
  2306.     { "display",            SSHK_DISP, 0 },
  2307.     { "v1",                 SSHK_V1,   0 },
  2308.     { "", 0, 0 }
  2309. };
  2310. static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1;
  2311.  
  2312. static struct keytab sshkv1[] = {    /* SET SSH KEY V1 command table */
  2313.     { "set-comment",  1, 0 }
  2314. };
  2315.  
  2316. static struct keytab sshkpsw[] = {    /* SET SSH KEY PASSPHRASE table */
  2317.     { "/new-passphrase",  2, CM_ARG },
  2318.     { "/old-passphrase",  1, CM_ARG }
  2319. };
  2320.  
  2321. static struct keytab sshkcrea[] = {    /* SSH KEY CREATE table */
  2322.     { "/bits",           SSHKC_BI, CM_ARG },
  2323.     { "/passphrase",     SSHKC_PP, CM_ARG },
  2324.     { "/type",           SSHKC_TY, CM_ARG },
  2325.     { "/v1-rsa-comment", SSHKC_1R, CM_ARG }
  2326. };
  2327. static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab));
  2328.  
  2329. static struct keytab sshkcty[] = {    /* SSH KEY CREATE /TYPE:xxx */
  2330.     { "srp",    SSHKT_SRP, 0 },
  2331.     { "v1-rsa", SSHKT_1R, 0 },
  2332.     { "v2-dsa", SSHKT_2D, 0 },
  2333.     { "v2-rsa", SSHKT_2R, 0 }
  2334. };
  2335. static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab));
  2336.  
  2337. static struct keytab sshdswi[] = {    /* SET SSH KEY DISPLAY /switches */
  2338.     { "/format", SSHKD_OUT, CM_ARG }
  2339. };
  2340. static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab));
  2341.  
  2342. #ifdef COMMENT
  2343. static struct keytab sshdifmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2344.     { "openssh", SKDF_OSSH, 0 },
  2345.     { "ssh.com", SKDF_SSHC, 0 }
  2346. };
  2347. static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab));
  2348. #endif /* COMMENT */
  2349.  
  2350. static struct keytab sshdofmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2351.     { "fingerprint", SKDF_FING, 0 },
  2352.     { "ietf",        SKDF_IETF, 0 },
  2353.     { "openssh",     SKDF_OSSH, 0 },
  2354.     { "ssh.com",     SKDF_SSHC, 0 }
  2355. };
  2356. static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab));
  2357. #endif /* SSHBUILTIN */
  2358. #endif /* ANYSSH */
  2359.  
  2360. #ifdef NETCONN
  2361. struct keytab netkey[] = {        /* SET NETWORK table */
  2362.     { "directory", XYNET_D,  0 },
  2363.     { "type",      XYNET_T,  0 }
  2364. };
  2365. int nnetkey = (sizeof(netkey) / sizeof(struct keytab));
  2366.  
  2367. struct keytab netcmd[] = {
  2368. /*
  2369.   These are the network types.
  2370. */
  2371. #ifdef NETCMD
  2372.     { "command",       NET_CMD,  CM_INV }, /* Command */
  2373. #endif /* NETCMD */
  2374.  
  2375. #ifdef DECNET                /* DECnet / PATHWORKS */
  2376.     { "decnet",        NET_DEC,  0 },
  2377. #endif /* DECNET */
  2378.  
  2379. #ifdef NETDLL
  2380.     { "dll",           NET_DLL,  CM_INV }, /* DLL to be loaded */
  2381. #endif /* NETDLL */
  2382.  
  2383. #ifdef NETFILE
  2384.     { "file",           NET_FILE, CM_INV }, /* FILE (real crude) */
  2385. #endif /* NETFILE */
  2386.  
  2387. #ifdef NPIPE                /* Named Pipes */
  2388.     { "named-pipe",     NET_PIPE,  0 },
  2389. #endif /* NPIPE */
  2390.  
  2391. #ifdef CK_NETBIOS
  2392.     { "netbios",        NET_BIOS,  0 },    /* NETBIOS */
  2393. #endif /* CK_NETBIOS */
  2394.  
  2395. #ifdef DECNET                /* DECnet / PATHWORKS (alias) */
  2396.     { "pathworks",     NET_DEC,  CM_INV },
  2397. #endif /* DECNET */
  2398.  
  2399. #ifdef NETCMD
  2400.     { "pipe",          NET_CMD,  0 },    /* Pipe */
  2401. #endif /* NETCMD */
  2402.  
  2403. #ifdef NETPTY
  2404.     { "pseudoterminal",NET_PTY, 0 },    /* Pseudoterminal */
  2405. #endif /* NETPTY */
  2406.  
  2407. #ifdef NETPTY
  2408.     { "pty",          NET_PTY,  CM_INV }, /* Inv syn for pseudoterm */
  2409. #endif /* NETPTY */
  2410.  
  2411. #ifdef SSHBUILTIN
  2412.     { "ssh",          NET_SSH,  0 },
  2413. #endif /* SSHBUILTIN */
  2414.  
  2415. #ifdef SUPERLAT
  2416.     { "superlat",     NET_SLAT, 0 },    /* Meridian Technologies' SuperLAT */
  2417. #endif /* SUPERLAT */
  2418.  
  2419. #ifdef TCPSOCKET            /* TCP/IP sockets library */
  2420.     { "tcp/ip",       NET_TCPB, 0 },
  2421. #endif /* TCPSOCKET */
  2422. #ifdef SUPERLAT
  2423.     { "tes32",        NET_SLAT, 0 },    /* Emulux TES32 */
  2424. #endif /* SUPERLAT */
  2425. #ifdef ANYX25                /* X.25 */
  2426. #ifdef SUNX25
  2427.     { "x",            NET_SX25, CM_INV|CM_ABR },
  2428.     { "x.25",         NET_SX25, 0 },
  2429.     { "x25",          NET_SX25, CM_INV },
  2430. #else
  2431. #ifdef STRATUSX25
  2432.     { "x",            NET_VX25, CM_INV|CM_ABR },
  2433.     { "x.25",         NET_VX25, 0 },
  2434.     { "x25",          NET_VX25, CM_INV },
  2435. #endif /* STRATUSX25 */
  2436. #endif /* SUNX25 */
  2437. #ifdef IBMX25
  2438.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2439.     { "x.25",         NET_IX25, CM_INV },
  2440.     { "x25",          NET_IX25, CM_INV },
  2441. #endif /* IBMX25 */
  2442. #ifdef HPX25
  2443.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2444.     { "x.25",         NET_IX25, 0 },
  2445.     { "x25",          NET_IX25, CM_INV },
  2446. #endif /* HPX25 */
  2447. #endif /* ANYX25 */
  2448.     { "", 0, 0 }
  2449. };
  2450. int nnets = (sizeof(netcmd) / sizeof(struct keytab));
  2451.  
  2452. #ifndef NOTCPOPTS
  2453. #ifdef TCPSOCKET
  2454.  
  2455. /* TCP options */
  2456.  
  2457. struct keytab tcpopt[] = {
  2458.     { "address",   XYTCP_ADDRESS, 0 },
  2459. #ifdef CK_DNS_SRV
  2460.     { "dns-service-records", XYTCP_DNS_SRV, 0 },
  2461. #endif /* CK_DNS_SRV */
  2462. #ifdef SO_DONTROUTE
  2463.     { "dontroute",   XYTCP_DONTROUTE, 0 },
  2464. #endif /* SO_DONTROUTE */
  2465. #ifndef NOHTTP
  2466.     { "http-proxy", XYTCP_HTTP_PROXY, 0 },
  2467. #endif /* NOHTTP */
  2468. #ifdef SO_KEEPALIVE
  2469.     { "keepalive", XYTCP_KEEPALIVE, 0 },
  2470. #endif /* SO_KEEPALIVE */
  2471. #ifdef SO_LINGER
  2472.     { "linger", XYTCP_LINGER, 0 },
  2473. #endif /* SO_LINGER */
  2474. #ifdef TCP_NODELAY
  2475.     { "nagle",  XYTCP_NAGLE,    CM_INV },
  2476.     { "nodelay", XYTCP_NODELAY, 0 },
  2477. #endif /* TCP_NODELAY */
  2478.     { "reverse-dns-lookup", XYTCP_RDNS, 0 },
  2479. #ifdef SO_RCVBUF
  2480.     { "recvbuf", XYTCP_RECVBUF, 0 },
  2481. #endif /* SO_RCVBUF */
  2482. #ifdef SO_SNDBUF
  2483.     { "sendbuf", XYTCP_SENDBUF, 0 },
  2484. #endif /* SO_SNDBUF */
  2485. #ifdef NT
  2486. #ifdef CK_SOCKS
  2487.     { "socks-server", XYTCP_SOCKS_SVR, 0 },
  2488. #endif /* CK_SOCKS */
  2489. #endif /* NT */
  2490. #ifdef VMS
  2491. #ifdef DEC_TCPIP
  2492.     { "ucx-port-bug", XYTCP_UCX, 0 },
  2493. #endif /* DEC_TCPIP */
  2494. #endif /* VMS */
  2495.     { "",0,0 }
  2496. };
  2497. int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab));
  2498. #endif /* TCPSOCKET */
  2499. #endif /* NOTCPOPTS */
  2500. #endif /* NETCONN */
  2501.  
  2502. #ifdef OS2
  2503. /* K95 Manual Chapter Table -- Keep these two tables in sync! */
  2504.  
  2505. static char * linktbl[] = {        /* Internal links in k95.htm */
  2506.     "#top",                /* 00 */
  2507.     "#what",                /* 01 */
  2508.     "#install",                /* 02 */
  2509.     "#start",                /* 03 */
  2510.     "#dialer",                /* 04 */
  2511.     "#entries",                /* 05 */
  2512.     "#command",                /* 06 */
  2513.     "#terminal",            /* 07 */
  2514.     "#transfer",            /* 08 */
  2515.     "#hostmode"                /* 09 */
  2516. };
  2517.  
  2518. static struct keytab chaptbl[] = {
  2519.     { "Command-Screen",     6, 0 },
  2520.     { "Contents",           0, 0 },
  2521.     { "Dialer-Entries",     5, 0 },
  2522.     { "File-Transfer",      8, 0 },
  2523.     { "Getting-Started",    3, 0 },
  2524.     { "Host-Mode",          9, 0 },
  2525.     { "Installation",       2, 0 },
  2526.     { "Terminal-Emulation", 7, 0 },
  2527.     { "Using-The-Dialer",   4, 0 },
  2528.     { "What-Is-K95",        1, 0 },
  2529.     { "",                   0, 0 }
  2530. };
  2531. static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1);
  2532. #endif /* OS2 */
  2533.  
  2534. #ifndef NOXFER
  2535. /* Remote Command Table */
  2536.  
  2537. struct keytab remcmd[] = {
  2538. #ifndef NOSPL
  2539.     { "as",        XZASG, CM_INV|CM_ABR },
  2540.     { "asg",       XZASG, CM_INV },
  2541.     { "assign",    XZASG, 0 },
  2542. #endif /* NOSPL */
  2543.     { "cd",        XZCWD, 0 },
  2544.     { "cdup",      XZCDU, CM_INV },
  2545.     { "copy",      XZCPY, 0 },
  2546.     { "cwd",       XZCWD, CM_INV },
  2547.     { "delete",    XZDEL, 0 },
  2548.     { "directory", XZDIR, 0 },
  2549.     { "e",         XZXIT, CM_ABR|CM_INV },
  2550.     { "erase",     XZDEL, CM_INV },
  2551.     { "exit",      XZXIT, 0 },
  2552.     { "help",      XZHLP, 0 },
  2553. #ifndef NOPUSH
  2554.     { "host",      XZHOS, 0 },
  2555. #endif /* NOPUSH */
  2556. #ifndef NOFRILLS
  2557.     { "kermit",    XZKER, 0 },
  2558.     { "l",         XZLGI, CM_ABR|CM_INV },
  2559.     { "lo",        XZLGI, CM_ABR|CM_INV },
  2560.     { "log",       XZLGI, CM_ABR|CM_INV },
  2561.     { "login",     XZLGI, 0 },
  2562.     { "logout",    XZLGO, 0 },
  2563.     { "mkdir",     XZMKD, 0 },
  2564.     { "print",     XZPRI, 0 },
  2565. #endif /* NOFRILLS */
  2566.     { "pwd",       XZPWD, 0 },
  2567. #ifndef NOSPL
  2568.     { "query",       XZQUE, 0 },
  2569. #endif /* NOSPL */
  2570.     { "rename",    XZREN, 0 },
  2571.     { "rmdir",     XZRMD, 0 },
  2572.     { "set",       XZSET, 0 },
  2573.     { "space",       XZSPA, 0 },
  2574. #ifndef NOFRILLS
  2575.     { "type",      XZTYP, 0 },
  2576.     { "who",       XZWHO, 0 },
  2577. #endif /* NOFRILLS */
  2578.     { "", 0, 0}
  2579. };
  2580. int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1;
  2581. #endif /* NOXFER */
  2582.  
  2583. struct keytab logtab[] = {
  2584. #ifdef CKLOGDIAL
  2585.     { "connections",  LOGM, CM_INV },
  2586.     { "cx",           LOGM, 0 },
  2587. #endif /* CKLOGDIAL */
  2588. #ifdef DEBUG
  2589.     { "debugging",    LOGD, 0 },
  2590. #endif /* DEBUG */
  2591.     { "packets",      LOGP, 0 },
  2592. #ifndef NOLOCAL
  2593.     { "session",      LOGS, 0 },
  2594. #endif /* NOLOCAL */
  2595. #ifdef TLOG
  2596.     { "transactions", LOGT, 0 },
  2597. #endif /* TLOG */
  2598.     { "", 0, 0 }
  2599. };
  2600. int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1;
  2601.  
  2602. struct keytab writab[] = {
  2603. #ifndef NOSPL
  2604.     { "append-file",     LOGW, CM_INV },
  2605. #endif /* NOSPL */
  2606.     { "debug-log",       LOGD, 0 },
  2607.     { "error",           LOGE, 0 },
  2608. #ifndef NOSPL
  2609.     { "file",            LOGW, 0 },
  2610. #endif /* NOSPL */
  2611.     { "packet-log",      LOGP, 0 },
  2612.     { "screen",          LOGX, 0 },
  2613. #ifndef NOLOCAL
  2614.     { "session-log",     LOGS, 0 },
  2615. #endif /* NOLOCAL */
  2616.     { "sys$output",      LOGX, CM_INV },
  2617.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2618.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2619.     { "tra",             LOGT, CM_ABR|CM_INV },
  2620.     { "tran",            LOGT, CM_ABR|CM_INV },
  2621.     { "trans",           LOGT, CM_ABR|CM_INV },
  2622.     { "transa",          LOGT, CM_ABR|CM_INV },
  2623.     { "transac",         LOGT, CM_ABR|CM_INV },
  2624.     { "transact",        LOGT, CM_ABR|CM_INV },
  2625.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2626.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2627.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2628.     { "transaction-log", LOGT, 0 },
  2629.     { "transactions",    LOGT, CM_INV }
  2630. };
  2631. int nwri = (sizeof(writab) / sizeof(struct keytab));
  2632.  
  2633. #ifdef COMMENT                /* INPUT switches not used yet... */
  2634. static struct keytab inswtab[] = {
  2635. #ifdef COMMENT
  2636.     { "/assign",       IN_ASG, CM_ARG },
  2637. #endif /* COMMENT */
  2638.     { "/autodownload", IN_ADL, CM_ARG },
  2639.     { "/case",         IN_CAS, CM_ARG },
  2640.     { "/echo",         IN_ECH, CM_ARG },
  2641.     { "/interrupts",   IN_NOI, CM_ARG },
  2642.     { "/silence",      IN_SIL, CM_ARG },
  2643. #ifdef COMMENT
  2644.     { "/pattern",      IN_PAT, CM_ARG },
  2645. #endif /* COMMENT */
  2646.     { "", 0, 0 }
  2647. };
  2648. static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1;
  2649. #endif /* COMMENT */
  2650.  
  2651. static struct keytab clrtab[] = {    /* Keywords for CLEAR command */
  2652. #ifndef NOSPL
  2653.     { "alarm",            CLR_ALR,         0 },
  2654. #ifdef CK_APC
  2655.     { "apc",              CLR_APC,         0 },
  2656. #endif /* CK_APC */
  2657. #ifdef PATTERNS
  2658.     { "binary-patterns",  CLR_BIN,         0 },
  2659. #endif /* PATTERNS */
  2660.     { "both",             CLR_DEV|CLR_INP, CM_INV },
  2661. #endif /* NOSPL */
  2662. #ifdef OS2
  2663.     { "command-screen",   CLR_CMD,         0 },
  2664. #endif /* OS2 */
  2665. #ifndef NOSPL
  2666.     { "device",           CLR_DEV,         CM_INV|CM_ABR },
  2667.     { "device-and-input", CLR_DEV|CLR_INP, 0 },
  2668. #endif /* NOSPL */
  2669.     { "device-buffer",    CLR_DEV,         0 },
  2670. #ifndef NODIAL
  2671.     { "dial-status",      CLR_DIA,     0 },
  2672. #endif /* NODIAL */
  2673. #ifndef NOSPL
  2674.     { "input-buffer",     CLR_INP,         0 },
  2675. #endif /* NOSPL */
  2676.     { "keyboard-buffer",  CLR_KBD,         0 },
  2677.     { "send-list",        CLR_SFL,         0 },
  2678. #ifdef OS2
  2679.     { "scr",              CLR_SCL,         CM_INV|CM_ABR },
  2680. #endif /* OS2 */
  2681.     { "screen",           CLR_SCR,         0 },
  2682. #ifdef OS2
  2683.     { "scrollback",       CLR_SCL,         CM_INV },
  2684.     { "terminal-screen",  CLR_TRM,         0 },
  2685. #endif /* OS2 */
  2686. #ifdef PATTERNS
  2687.     { "text-patterns",    CLR_TXT,         0 },
  2688. #endif /* PATTERNS */
  2689.     { "", 0, 0 }
  2690. };
  2691. int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1;
  2692.  
  2693. struct keytab clstab[] = {        /* Keywords for CLOSE command */
  2694. #ifndef NOSPL
  2695.     { "!read",           LOGR, CM_INV },
  2696.     { "!write",          LOGW, CM_INV },
  2697. #ifndef NOPUSH
  2698. #endif /* NOPUSH */
  2699. #endif /* NOSPL */
  2700. #ifndef NOSPL
  2701.     { "append-file",     LOGW, CM_INV },
  2702. #endif /* NOSPL */
  2703. #ifndef NOLOCAL
  2704.     { "connection",      9999, 0 },
  2705. #endif /* NOLOCAL */
  2706. #ifdef CKLOGDIAL
  2707.     { "cx-log",          LOGM, 0 },
  2708. #endif /* CKLOGDIAL */
  2709. #ifdef DEBUG
  2710.     { "debug-log",       LOGD, 0 },
  2711. #endif /* DEBUG */
  2712.     { "host",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2713.     { "line",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2714.     { "p",               LOGP, CM_INV|CM_ABR },
  2715.     { "packet-log",      LOGP, 0 },
  2716.     { "port",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2717. #ifndef NOSPL
  2718.     { "read-file",       LOGR, 0 },
  2719. #endif /* NOSPL */
  2720. #ifndef NOLOCAL
  2721.     { "session-log",     LOGS, 0 },
  2722. #endif /* NOLOCAL */
  2723. #ifdef TLOG
  2724.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2725.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2726.     { "tra",             LOGT, CM_ABR|CM_INV },
  2727.     { "tran",            LOGT, CM_ABR|CM_INV },
  2728.     { "trans",           LOGT, CM_ABR|CM_INV },
  2729.     { "transa",          LOGT, CM_ABR|CM_INV },
  2730.     { "transac",         LOGT, CM_ABR|CM_INV },
  2731.     { "transact",        LOGT, CM_ABR|CM_INV },
  2732.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2733.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2734.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2735.     { "transaction-log", LOGT, 0 },
  2736.     { "transactions",    LOGT, CM_INV },
  2737. #endif /* TLOG */
  2738. #ifndef NOSPL
  2739.     { "write-file",      LOGW, 0 },
  2740. #endif /* NOSPL */
  2741.     { "", 0, 0 }
  2742. };
  2743. int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1;
  2744.  
  2745. /* SHOW command arguments */
  2746.  
  2747. #ifndef NOSHOW
  2748. struct keytab shotab[] = {
  2749. #ifndef NOSPL
  2750.     { "alarm",        SHALRM, 0 },
  2751.     { "arg",          SHARG, CM_INV|CM_ABR },
  2752.     { "arguments",    SHARG, 0 },
  2753.     { "args",         SHARG, CM_INV },
  2754.     { "arrays",       SHARR, 0 },
  2755. #endif /* NOSPL */
  2756.  
  2757. #ifndef NOCSETS
  2758.     { "associations", SHASSOC, 0 },
  2759. #endif /* NOCSETS */
  2760.  
  2761. #ifndef NOXFER
  2762.     { "attributes",   SHATT, 0 },
  2763. #endif /* NOXFER */
  2764.  
  2765. #ifdef CK_AUTHENTICATION
  2766.     { "authentication", SHOAUTH, CM_INV },
  2767. #endif /* CK_AUTHENTICATION */
  2768.  
  2769. #ifndef NOPUSH
  2770. #ifdef BROWSER
  2771.     { "browser",      SHBROWSE, CM_PSH|CM_LOC },
  2772. #endif /*  BROWSER */
  2773. #endif /* NOPUSH */
  2774.     { "cd",           SHCD, 0 },
  2775.     { "character-sets", SHCSE, 0 },
  2776.     { "cmd",          SHCMD, CM_INV },
  2777. #ifndef NOLOCAL
  2778.     { "com",          SHCOM, CM_INV|CM_ABR },
  2779.     { "comm",         SHCOM, CM_INV|CM_ABR },
  2780.     { "communications", SHCOM, 0 },
  2781. #endif /* NOLOCAL */
  2782.     { "command",      SHCMD, 0 },
  2783.     { "connection",   SHCONNX, 0 },
  2784. #ifdef CK_SPEED
  2785.     { "control-prefixing", SHCTL, 0 },
  2786. #endif /* CK_SPEED */
  2787. #ifdef CKLOGDIAL
  2788.     { "cx",           SHCONNX, CM_INV },
  2789. #endif /* CKLOGDIAL */
  2790. #ifndef NOSPL
  2791.     { "count",        SHCOU, 0 },
  2792. #endif /* NOSPL */
  2793.     { "d",            SHDIA, CM_INV|CM_ABR },
  2794. #ifdef VMS
  2795.     { "default",      SHDFLT, 0 },
  2796. #else
  2797.     { "default",      SHDFLT, CM_INV },
  2798. #endif /* VMS */
  2799. #ifndef NODIAL
  2800.     { "dial",         SHDIA, CM_LOC },
  2801. #endif /* NODIAL */
  2802.     { "double/ignore",SHDBL, 0 },
  2803. #ifndef NOPUSH
  2804. #ifndef NOFRILLS
  2805.     { "editor",       SHEDIT, CM_PSH },
  2806. #endif /*  NOFRILLS */
  2807. #endif /* NOPUSH */
  2808. #ifndef NOLOCAL
  2809.     { "escape",       SHESC, CM_LOC },
  2810. #endif /* NOLOCAL */
  2811.     { "exit",         SHEXI, 0 },
  2812.     { "extended-options", SHXOPT, CM_INV },
  2813.     { "features",     SHFEA, 0 },
  2814.     { "file",         SHFIL, 0 },
  2815. #ifndef NOLOCAL
  2816.     { "flow-control", SHOFLO, 0 },
  2817. #endif /* NOLOCAL */
  2818. #ifdef BROWSER
  2819.     { "ftp",          SHOFTP, CM_PSH|CM_LOC },
  2820. #else
  2821. #ifndef NOFTP
  2822. #ifndef SYSFTP
  2823. #ifdef TCPSOCKET
  2824.     { "ftp",          SHOFTP, 0 },    /* (built-in ftp) */
  2825. #endif /* TCPSOCKET */
  2826. #endif /* SYSFTP */
  2827. #endif /* NOFTP */
  2828. #endif /* BROWSER */
  2829. #ifndef NOSPL
  2830.     { "functions",    SHFUN, 0 },
  2831.     { "globals",      SHVAR, 0 },
  2832. #endif /* NOSPL */
  2833. #ifdef KUI
  2834.     { "gui",          SHOGUI, 0 },
  2835. #endif /* KUI */
  2836. #ifdef CK_RECALL
  2837.     { "history",      SHHISTORY, 0 },
  2838. #endif /* CK_RECALL */
  2839.     { "ignore/double",SHDBL, CM_INV },
  2840.     { "iksd",         SHOIKS, CM_INV },
  2841. #ifndef NOSPL
  2842.     { "input",        SHINP, 0 },
  2843. #endif /* NOSPL */
  2844. #ifndef NOSETKEY
  2845.     { "k",            SHKEY, CM_INV|CM_ABR },
  2846.     { "key",          SHKEY, 0 },
  2847. #ifndef NOKVERBS
  2848.     { "kverbs",       SHKVB, 0 },
  2849. #endif /* NOKVERBS */
  2850. #endif /* NOSETKEY */
  2851. #ifdef CK_LABELED
  2852.     { "labeled-file-info", SHLBL, 0 },
  2853. #endif /* CK_LABELED */
  2854. #ifndef NOCSETS
  2855.     { "languages",    SHLNG, 0 },
  2856. #endif /* NOCSETS */
  2857.     { "logs",         SHLOG, 0 },
  2858. #ifndef NOSPL
  2859.     { "macros",       SHMAC, 0 },
  2860. #endif /* NOSPL */
  2861. #ifndef NODIAL
  2862.     { "modem",        SHMOD, CM_LOC },
  2863. #else
  2864.     { "modem-signals",SHCOM, CM_INV|CM_LOC },
  2865. #endif /* NODIAL */
  2866. #ifndef NOLOCAL
  2867. #ifdef OS2MOUSE
  2868.     { "mouse",        SHMOU, CM_LOC },
  2869. #endif /* OS2MOUSE */
  2870. #endif /* NOLOCAL */
  2871. #ifdef NETCONN
  2872.     { "network",      SHNET, CM_LOC },
  2873. #else
  2874.     { "network",      SHNET, CM_INV|CM_LOC },
  2875. #endif /* NETCONN */
  2876.     { "options",      SHOPTS, 0 },
  2877. #ifndef NOSPL
  2878.     { "output",       SHOUTP, CM_INV },
  2879. #endif /* NOSPL */
  2880. #ifdef ANYX25
  2881. #ifndef IBMX25
  2882.     { "pad",          SHPAD,  CM_LOC },
  2883. #endif /* IBMX25 */
  2884. #endif /* ANYX25 */
  2885.     { "parameters",   SHPAR,  CM_INV },
  2886. #ifdef PATTERNS
  2887.     { "patterns",     SHOPAT, 0 },
  2888. #endif /* PATTERNS */
  2889.     { "printer",      SHPRT,  0 },
  2890. #ifdef CK_SPEED
  2891.     { "prefixing",    SHCTL,  CM_INV },
  2892. #endif /* CK_SPEED */
  2893. #ifndef NOXFER
  2894.     { "protocol",     SHPRO,  0 },
  2895. #endif /* NOXFER */
  2896. #ifndef NOSPL
  2897.     { "scripts",      SHSCR,  CM_LOC },
  2898. #endif /* NOSPL */
  2899.     { "send-list",    SHSFL,  0 },
  2900. #ifndef NOSERVER
  2901.     { "server",       SHSER,  0 },
  2902. #endif /* NOSERVER */
  2903. #ifndef NOSEXP
  2904.     { "sexpression",  SHSEXP, 0 },
  2905. #endif /* NOSEXP */
  2906. #ifdef ANYSSH
  2907.     { "ssh",          SHOSSH, 0 },
  2908. #endif /* ANYSSH */
  2909.     { "stack",        SHSTK,  0 },
  2910.     { "status",       SHSTA,  0 },
  2911. #ifdef STREAMING
  2912.     { "streaming",    SHOSTR, 0 },
  2913. #endif /* STREAMING */
  2914. #ifndef NOLOCAL
  2915. #ifdef OS2
  2916.     { "tabs",          SHTAB, CM_INV|CM_LOC },
  2917. #endif /* OS2 */
  2918. #ifdef CK_TAPI
  2919.     { "tapi",          SHTAPI, CM_LOC },
  2920.     { "tapi-comm",     SHTAPI_C, CM_INV|CM_LOC },
  2921.     { "tapi-location", SHTAPI_L, CM_INV|CM_LOC },
  2922.     { "tapi-modem",    SHTAPI_M, CM_INV|CM_LOC },
  2923. #endif /* CK_TAPI */
  2924.     { "tcp",           SHTCP,  CM_LOC },
  2925. #ifdef TNCODE
  2926.     { "tel",           SHTEL,  CM_INV|CM_ABR },
  2927.     { "telnet",        SHTEL,  0 },
  2928.     { "telopt",        SHTOPT, 0 },
  2929. #endif /* TNCODE */
  2930.     { "terminal",      SHTER,  CM_LOC },
  2931. #endif /* NOLOCAL */
  2932. #ifndef NOXMIT
  2933.     { "tr",            SHXMI, CM_INV|CM_ABR },
  2934.     { "tra",           SHXMI, CM_INV|CM_ABR },
  2935.     { "tran",          SHXMI, CM_INV|CM_ABR },
  2936.     { "trans",         SHXMI, CM_INV|CM_ABR },
  2937. #endif /* NOXMIT */
  2938. #ifndef NOXFER
  2939.     { "transfer",      SHOXFER, 0 },
  2940. #endif /* NOXFER */
  2941. #ifndef NOXMIT
  2942.     { "transmit",      SHXMI, 0 },
  2943. #endif /* NOXMIT */
  2944. #ifdef CK_TRIGGER
  2945.     { "trigger",       SHTRIG, CM_LOC },
  2946. #endif /* CK_TRIGGER */
  2947. #ifndef NOSETKEY
  2948. #ifndef NOKVERBS
  2949. #ifdef OS2
  2950.     { "udk",           SHUDK, CM_LOC },
  2951. #endif /* OS2 */
  2952. #endif /* NOKVERBS */
  2953. #endif /* NOSETKEY */
  2954. #ifndef NOSPL
  2955.     { "variables",     SHBUI, 0 },
  2956. #endif /* NOSPL */
  2957. #ifndef NOFRILLS
  2958.     { "versions",      SHVER, 0 },
  2959. #endif /* NOFRILLS */
  2960. #ifdef OS2
  2961.     { "vscrn",         SHVSCRN, CM_INV|CM_LOC },
  2962. #endif /* OS2 */
  2963.     { "xfer",          SHOXFER,  CM_INV },
  2964. #ifndef NOXMIT
  2965.     { "xmit",          SHXMI,    CM_INV },
  2966. #endif /* NOXMIT */
  2967.     { "", 0, 0 }
  2968. };
  2969. int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1;
  2970. #endif /* NOSHOW */
  2971.  
  2972. #ifdef ANYX25
  2973. #ifndef IBMX25
  2974. struct keytab padtab[] = {              /* PAD commands */
  2975.     { "clear",      XYPADL, 0 },
  2976.     { "interrupt",  XYPADI, 0 },
  2977.     { "reset",      XYPADR, 0 },
  2978.     { "status",     XYPADS, 0 }
  2979. };
  2980. int npadc = (sizeof(padtab) / sizeof(struct keytab));
  2981. #endif /* IBMX25 */
  2982. #endif /* ANYX25 */
  2983.  
  2984. #ifndef NOSERVER
  2985. static struct keytab kmstab[] = {
  2986.     { "both",    3, 0 },
  2987.     { "local",   1, 0 },
  2988.     { "remote",  2, 0 }
  2989. };
  2990.  
  2991. static struct keytab enatab[] = {    /* ENABLE commands */
  2992.     { "all",        EN_ALL,  0 },
  2993. #ifndef NOSPL
  2994.     { "as",         EN_ASG,  CM_INV|CM_ABR },
  2995.     { "asg",        EN_ASG,  CM_INV },
  2996.     { "assign",     EN_ASG,  0 },
  2997. #endif /* NOSPL */
  2998. #ifndef datageneral
  2999.     { "bye",        EN_BYE,  0 },
  3000. #endif /* datageneral */
  3001.     { "cd",         EN_CWD,  0 },
  3002. #ifdef ZCOPY
  3003.     { "copy",       EN_CPY,  0 },
  3004. #endif /* ZCOPY */
  3005.     { "cwd",        EN_CWD,  CM_INV },
  3006.     { "delete",     EN_DEL,  0 },
  3007.     { "directory",  EN_DIR,  0 },
  3008.     { "enable",     EN_ENA,  CM_INV },
  3009.     { "exit",       EN_XIT,  0 },
  3010.     { "finish",     EN_FIN,  0 },
  3011.     { "get",        EN_GET,  0 },
  3012.     { "host",       EN_HOS,  0 },
  3013.     { "mail",       EN_MAI,  0 },
  3014.     { "mkdir",      EN_MKD,  0 },
  3015. #ifndef NOSPL
  3016.     { "query",      EN_QUE,  0 },
  3017. #endif /* NOSPL */
  3018.     { "print",      EN_PRI,  0 },
  3019.     { "rename",     EN_REN,  0 },
  3020.     { "retrieve",   EN_RET,  CM_INV },
  3021.     { "rmdir",      EN_RMD,  0 },
  3022.     { "send",       EN_SEN,  0 },
  3023.     { "set",        EN_SET,  0 },
  3024.     { "space",      EN_SPA,  0 },
  3025.     { "type",       EN_TYP,  0 },
  3026.     { "who",        EN_WHO,  0 }
  3027. };
  3028. static int nena = (sizeof(enatab) / sizeof(struct keytab));
  3029. #endif /* NOSERVER */
  3030.  
  3031. struct keytab txtbin[] = {
  3032.     { "all",        2, 0 },
  3033.     { "binary",     1, 0 },
  3034.     { "text",       0, 0 }
  3035. };
  3036.  
  3037. #ifndef NOXFER
  3038. static struct keytab sndtab[] = {    /* SEND command options */
  3039.     { "/after",           SND_AFT, CM_ARG },
  3040. #ifndef NOSPL
  3041.     { "/array",           SND_ARR, CM_ARG },
  3042. #endif /* NOSPL */
  3043.     { "/as-name",         SND_ASN, CM_ARG },
  3044.     { "/b",               SND_BIN, CM_INV|CM_ABR },
  3045.     { "/before",          SND_BEF, CM_ARG },
  3046.     { "/binary",          SND_BIN, 0 },
  3047. #ifdef CALIBRATE
  3048.     { "/c",               SND_CMD, CM_INV|CM_ABR },
  3049.     { "/calibrate",       SND_CAL, CM_INV|CM_ARG },
  3050. #endif /* CALIBRATE */
  3051.     { "/command",         SND_CMD, CM_PSH },
  3052.     { "/delete",          SND_DEL, 0 },
  3053. #ifdef UNIXOROSK
  3054.     { "/dotfiles",        SND_DOT, 0 },
  3055. #endif /* UNIXOROSK */
  3056.     { "/except",          SND_EXC, CM_ARG },
  3057. #ifdef PIPESEND
  3058.     { "/filter",          SND_FLT, CM_ARG|CM_PSH },
  3059. #endif /* PIPESEND */
  3060.     { "/filenames",       SND_NAM, CM_ARG },
  3061. #ifdef CKSYMLINK
  3062.     { "/followlinks",      SND_LNK, 0 },
  3063. #endif /* CKSYMLINK */
  3064. #ifdef VMS
  3065.     { "/image",           SND_IMG, 0 },
  3066. #else
  3067.     { "/image",           SND_BIN, CM_INV },
  3068. #endif /* VMS */
  3069. #ifdef CK_LABELED
  3070.     { "/labeled",         SND_LBL, 0 },
  3071. #endif /* CK_LABELED */
  3072.     { "/larger-than",     SND_LAR, CM_ARG },
  3073.     { "/listfile",        SND_FIL, CM_ARG },
  3074. #ifndef NOFRILLS
  3075.     { "/mail",            SND_MAI, CM_ARG },
  3076. #endif /* NOFRILLS */
  3077. #ifdef CK_TMPDIR
  3078.     { "/move-to",         SND_MOV, CM_ARG },
  3079. #endif /* CK_TMPDIR */
  3080.     { "/nobackupfiles",   SND_NOB, 0 },
  3081. #ifdef UNIXOROSK
  3082.     { "/nodotfiles",      SND_NOD, 0 },
  3083. #endif /* UNIXOROSK */
  3084. #ifdef CKSYMLINK
  3085.     { "/nofollowlinks",      SND_NLK, 0 },
  3086. #endif /* CKSYMLINK */
  3087.     { "/not-after",       SND_NAF, CM_ARG },
  3088.     { "/not-before",      SND_NBE, CM_ARG },
  3089.     { "/pathnames",       SND_PTH, CM_ARG },
  3090.     { "/print",           SND_PRI, CM_ARG },
  3091. #ifdef CK_XYZ
  3092.     { "/protocol",        SND_PRO, CM_ARG },
  3093. #else
  3094.     { "/protocol",        SND_PRO, CM_ARG|CM_INV },
  3095. #endif /* CK_XYZ */
  3096.     { "/quiet",           SND_SHH, 0 },
  3097.     { "/recover",         SND_RES, 0 },
  3098. #ifdef RECURSIVE
  3099. /* Systems where we do recursion */
  3100.     { "/recursive",       SND_REC, 0 },
  3101. #else
  3102. #ifdef VMS
  3103. /* Systems that do recursion themselves without our assistance */
  3104. /* if we give them the right kind of wildcard */
  3105.     { "/recursive",       SND_REC, 0 },
  3106. #else
  3107. #ifdef datageneral
  3108.     { "/recursive",       SND_REC, 0 },
  3109. #else
  3110.     { "/recursive",       SND_REC, CM_INV },
  3111. #endif /* datageneral */
  3112. #endif /* VMS */
  3113. #endif /* RECURSIVE */
  3114.     { "/rename-to",       SND_REN, CM_ARG },
  3115.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3116.     { "/smaller-than",    SND_SMA, CM_ARG },
  3117.     { "/starting-at",     SND_STA, CM_ARG },
  3118. #ifndef NOFRILLS
  3119.     { "/su",              SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3120.     { "/sub",             SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3121.     { "/subject",         SND_ASN, CM_ARG },
  3122. #endif /* NOFRILLS */
  3123. #ifdef RECURSIVE
  3124.     { "/subdirectories",  SND_REC, CM_INV },
  3125. #endif /* RECURSIVE */
  3126.     { "/text",            SND_TXT, 0 },
  3127.     { "/transparent",     SND_XPA, 0 },
  3128.     { "/type",            SND_TYP, CM_ARG }
  3129. };
  3130. #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab)
  3131. static int nsndtab = NSNDTAB;
  3132.  
  3133. #ifndef NOMSEND
  3134. static struct keytab msndtab[] = {    /* MSEND options */
  3135.     { "/after",           SND_AFT, CM_ARG },
  3136.     { "/before",          SND_BEF, CM_ARG },
  3137.     { "/binary",          SND_BIN, 0 },
  3138.     { "/delete",          SND_DEL, 0 },
  3139.     { "/except",          SND_EXC, CM_ARG },
  3140.     { "/filenames",       SND_NAM, CM_ARG },
  3141. #ifdef CKSYMLINK
  3142.     { "/followlinks",      SND_LNK, 0 },
  3143. #endif /* CKSYMLINK */
  3144. #ifdef VMS
  3145.     { "/image",           SND_IMG, 0 },
  3146. #else
  3147.     { "/image",           SND_BIN, CM_INV },
  3148. #endif /* VMS */
  3149. #ifdef CK_LABELED
  3150.     { "/labeled",         SND_LBL, 0 },
  3151. #endif /* CK_LABELED */
  3152.     { "/larger-than",     SND_LAR, CM_ARG },
  3153.     { "/list",            SND_FIL, CM_ARG },
  3154. #ifndef NOFRILLS
  3155.     { "/mail",            SND_MAI, CM_ARG },
  3156. #endif /* NOFRILLS */
  3157. #ifdef CK_TMPDIR
  3158.     { "/move-to",         SND_MOV, CM_ARG },
  3159. #endif /* CK_TMPDIR */
  3160. #ifdef CKSYMLINK
  3161.     { "/nofollowlinks",    SND_NLK, 0 },
  3162. #endif /* CKSYMLINK */
  3163.     { "/not-after",       SND_NAF, CM_ARG },
  3164.     { "/not-before",      SND_NBE, CM_ARG },
  3165.     { "/pathnames",       SND_PTH, CM_ARG },
  3166.     { "/print",           SND_PRI, CM_ARG },
  3167. #ifdef CK_XYZ
  3168.     { "/protocol",        SND_PRO, CM_ARG },
  3169. #endif /* CK_XYZ */
  3170.     { "/quiet",           SND_SHH, 0 },
  3171.     { "/recover",         SND_RES, 0 },
  3172.     { "/rename-to",       SND_REN, CM_ARG },
  3173.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3174.     { "/smaller-than",    SND_SMA, CM_ARG },
  3175.     { "/starting-at",     SND_STA, CM_ARG },
  3176. #ifndef NOFRILLS
  3177.     { "/subject",         SND_ASN, CM_ARG },
  3178. #endif /* NOFRILLS */
  3179.     { "/text",            SND_TXT, 0 },
  3180.     { "/transparent",     SND_XPA, 0 },
  3181.     { "/type",            SND_TYP, CM_ARG }
  3182. };
  3183. #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab)
  3184. static int nmsndtab = NMSNDTAB;
  3185. #endif /* NOMSEND */
  3186. #endif /* NOXFER */
  3187.  
  3188. /* CONNECT command switches */
  3189.  
  3190. #define CONN_II  0    /* Idle interval */
  3191. #define CONN_IS  1    /* Idle string */
  3192. #define CONN_IL  2    /* Idle limit */
  3193. #define CONN_NV  3    /* Non-Verbose */
  3194. #define CONN_TL  4    /* Time limit */
  3195. #define CONN_TS  5    /* Trigger string */
  3196. #define CONN_AS  6    /* Asynchronous */
  3197. #define CONN_SY  7    /* Synchronous */
  3198. #define CONN_MAX 7    /* Number of CONNECT switches */
  3199.  
  3200. #ifndef NOLOCAL
  3201. static struct keytab conntab[] = {
  3202. #ifdef OS2
  3203.     { "/asynchronous",    CONN_AS, CM_INV },
  3204. #endif /* OS2 */
  3205. #ifdef XLIMITS
  3206.     { "/idle-interval",   CONN_II, CM_ARG },
  3207.     { "/idle-limit",      CONN_IL, CM_ARG },
  3208.     { "/idle-string",     CONN_IS, CM_ARG },
  3209.     { "/quietly",         CONN_NV, CM_INV },
  3210. #else
  3211.     { "/quietly",         CONN_NV, 0 },
  3212. #endif /* XLIMITS */
  3213. #ifdef OS2
  3214.     { "/synchronous",     CONN_SY, CM_INV },
  3215. #endif /* OS2 */
  3216. #ifdef XLIMITS
  3217.     { "/time-limit",      CONN_TL, CM_ARG },
  3218. #endif /* XLIMITS */
  3219. #ifdef CK_TRIGGER
  3220.     { "/trigger",         CONN_TS, CM_ARG },
  3221. #endif /* CK_TRIGGER */
  3222.     { "",0,0 }
  3223. };
  3224. #define NCONNTAB sizeof(conntab)/sizeof(struct keytab)
  3225. static int nconntab = NCONNTAB;
  3226. #endif /* NOLOCAL */
  3227.  
  3228. #ifndef NOXFER
  3229. static struct keytab stattab[] = {    /* STATISTICS command switches */
  3230.     { "/brief",   1, 0 },
  3231.     { "/verbose", 0, 0 }
  3232. };
  3233. #endif /* NOXFER */
  3234.  
  3235. #ifndef NOSPL
  3236. #ifdef COMMENT
  3237. struct mtab mactab[MAC_MAX] = {        /* Preinitialized macro table */
  3238.     { NULL, NULL, 0 }
  3239. };
  3240. #else
  3241. struct mtab *mactab;            /* Dynamically allocated macro table */
  3242. #endif /* COMMENT */
  3243. int nmac = 0;
  3244.  
  3245. struct keytab mackey[MAC_MAX];        /* Macro names as command keywords */
  3246. #endif /* NOSPL */
  3247.  
  3248. #ifndef NOSPL
  3249. #ifdef  OS2
  3250. struct keytab beeptab[] = {        /* Beep options */
  3251.     { "error", BP_FAIL, 0 },
  3252.     { "information", BP_NOTE, 0 },
  3253.     { "warning", BP_WARN, 0 }
  3254. };
  3255. int nbeeptab = sizeof(beeptab)/sizeof(struct keytab);
  3256.  
  3257. /* CLEAR COMMMAND-SCREEN options */
  3258.  
  3259. #define CLR_C_ALL 0
  3260. #define CLR_C_BOL 1
  3261. #define CLR_C_BOS 2
  3262. #define CLR_C_EOL 3
  3263. #define CLR_C_EOS 4
  3264. #define CLR_C_LIN 5
  3265. #define CLR_C_SCR 6
  3266.  
  3267. struct keytab clrcmdtab[] = {
  3268.     { "all",        CLR_C_ALL, 0 },
  3269.     { "bol",        CLR_C_BOL, 0 },
  3270.     { "bos",        CLR_C_BOS, 0 },
  3271.     { "eol",        CLR_C_EOL, 0 },
  3272.     { "eos",        CLR_C_EOS, 0 },
  3273.     { "line",       CLR_C_LIN, 0 },
  3274.     { "scrollback", CLR_C_SCR, 0 }
  3275. };
  3276. int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab);
  3277. #endif /* OS2 */
  3278. #endif /* NOSPL */
  3279.  
  3280. #ifdef COMMENT
  3281. /* Not used at present */
  3282. static struct keytab pagetab[] = {
  3283.     { "/more",   1, CM_INV },
  3284.     { "/nopage", 0, 0 },
  3285.     { "/page",   1, 0 }
  3286. };
  3287. int npagetab = sizeof(pagetab)/sizeof(struct keytab);
  3288. #endif /* COMMENT */
  3289.  
  3290. #define TYP_NOP  0            /* /NOPAGE */
  3291. #define TYP_PAG  1            /* /PAGE */
  3292. #define TYP_HEA  2            /* /HEAD:n */
  3293. #define TYP_TAI  3            /* /TAIL:n */
  3294. #define TYP_PAT  4            /* /MATCH:pattern */
  3295. #define TYP_WID  5            /* /WIDTH:cols */
  3296. #define TYP_COU  6            /* /COUNT */
  3297. #define TYP_OUT  7            /* /OUTPUT:file */
  3298. #define TYP_PFX  8            /* /PREFIX:string */
  3299. #ifdef UNICODE
  3300. #define TYP_XIN  9            /* /TRANSLATE-FROM:charset */
  3301. #define TYP_XUT 10            /* /TRANSLATE-TO:charset */
  3302. #define TYP_XPA 11            /* /TRANSPARENT */
  3303. #endif /* UNICODE */
  3304. #define TYP_NUM 12            /* /NUMBER */
  3305.  
  3306. static struct keytab typetab[] = {    /* TYPE command switches */
  3307.     { "/count",          TYP_COU, 0 },
  3308. #ifdef UNICODE
  3309.     { "/character-set",  TYP_XIN, CM_ARG },
  3310. #endif /* UNICODE */
  3311.     { "/head",           TYP_HEA, CM_ARG },
  3312.     { "/match",          TYP_PAT, CM_ARG },
  3313. #ifdef CK_TTGWSIZ
  3314.     { "/more",           TYP_PAG, CM_INV },
  3315.     { "/nopage",         TYP_NOP, 0 },
  3316.     { "/number",         TYP_NUM, 0 },
  3317.     { "/output",         TYP_OUT, CM_ARG },
  3318.     { "/page",           TYP_PAG, 0 },
  3319. #endif /* CK_TTGWSIZ */
  3320.     { "/prefix",         TYP_PFX, CM_ARG },
  3321.     { "/tail",           TYP_TAI, CM_ARG },
  3322. #ifdef UNICODE
  3323.     { "/translate-to",   TYP_XUT, CM_ARG },
  3324.     { "/transparent",    TYP_XPA, 0 },
  3325. #endif /* UNICODE */
  3326.     { "/width",          TYP_WID, CM_ARG },
  3327. #ifdef UNICODE
  3328.     { "/xlate-to",       TYP_XUT, CM_INV|CM_ARG },
  3329. #endif /* UNICODE */
  3330.     { "", 0, 0 }
  3331. };
  3332. int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1;
  3333.  
  3334. int typ_page = -1;            /* TYPE /[NO]PAGE default */
  3335. int typ_wid  = -1;
  3336.  
  3337. #ifndef NOSPL
  3338. #define TRA_ALL 999            /* TRACE command */
  3339. #define TRA_ASG 0
  3340. #define TRA_CMD 1
  3341.  
  3342. int tra_asg = 0;
  3343. int tra_cmd = 0;
  3344.  
  3345. static struct keytab tracetab[] = {    /* TRACE options */
  3346.     { "all",            TRA_ALL, 0 },
  3347.     { "assignments",    TRA_ASG, 0 },
  3348.     { "command-level",  TRA_CMD, 0 }
  3349. };
  3350. static int ntracetab = sizeof(tracetab)/sizeof(struct keytab);
  3351. #endif /* NOSPL */
  3352.  
  3353. #ifndef NOSHOW
  3354. VOID
  3355. showtypopts() {
  3356.     printf(" TYPE ");
  3357.     if (typ_page > -1) {
  3358.     prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE");
  3359.     } else
  3360.       prtopt(&optlines,"(no options set)");
  3361.     if (typ_wid > -1) {
  3362.     ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL);
  3363.     prtopt(&optlines,tmpbuf);
  3364.     }
  3365.     prtopt(&optlines,"");
  3366. }
  3367. #endif /* NOSHOW */
  3368.  
  3369. #ifdef LOCUS
  3370. /* isauto == 1 if locus is being switched automatically */
  3371.  
  3372. VOID
  3373. setlocus(x, isauto) int x, isauto; {
  3374.     extern int quitting;
  3375.     if (x) x = 1;
  3376.     if (x && locus) return;
  3377.     if (!x && !locus) return;
  3378.     /* Get here if it actually needs to be changed */
  3379. #ifdef OS2
  3380.     if (isauto &&            /* Automatically switching */
  3381.     !quitting &&            /* not exiting */
  3382.     autolocus == 2) {        /* and AUTOLOCUS is set to ASK */
  3383.     char locmsg[300];
  3384.     ckmakmsg(locmsg,300,
  3385.          "Switching Locus to ",
  3386.          x ? "LOCAL" : "REMOTE",
  3387.          " for file management commands\n"
  3388.                  "such as CD, DIRECTORY, DELETE, RENAME.  Type HELP SET\n"
  3389.                  "LOCUS at the K-95> prompt for further info.  Use the\n"
  3390. #ifdef KUI
  3391.                   "Actions menu or SET LOCUS command to disable automatic\n"
  3392.                   "Locus switching or to disable these queries.",
  3393. #else /* KUI */
  3394.                   "SET LOCUS command to disable automatic locus switching\n"
  3395.                   "or to disable these queries.",
  3396. #endif /* KUI */
  3397.                   NULL);
  3398.     if (uq_ok(locmsg,"OK to switch Locus?",3,NULL,1)) {
  3399.         locus = x;
  3400. #ifdef KUI
  3401.         KuiSetProperty(KUI_LOCUS,x,0);
  3402. #endif /* KUI */
  3403.         return;
  3404.     }
  3405.     } else {
  3406. #endif /* OS2 */
  3407.         if (isauto && msgflg && !quitting)
  3408.           printf("Switching LOCUS for file-management commands to %s.\n",
  3409.          x ? "LOCAL" : "REMOTE"
  3410.          );
  3411.     locus = x;
  3412. #ifdef OS2
  3413. #ifdef KUI
  3414.     KuiSetProperty(KUI_LOCUS,x,0);
  3415. #endif /* KUI */
  3416.     }
  3417. #endif /* OS2 */
  3418. }
  3419.  
  3420. VOID
  3421. setautolocus(x) int x; {
  3422.     autolocus = x;
  3423. #ifdef KUI
  3424.     KuiSetProperty(KUI_AUTO_LOCUS,x,0);
  3425. #endif /* KUI */
  3426. }
  3427. #endif /* LOCUS */
  3428.  
  3429. int
  3430. settypopts() {                /* Set TYPE option defaults */
  3431.     int xp = -1;
  3432.     int c, getval;
  3433.     while (1) {
  3434.     if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) {
  3435.         if (y == -3)
  3436.           break;
  3437.         else
  3438.           return(y);
  3439.     }
  3440.     c = cmgbrk();
  3441.     if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  3442.         printf("?This switch does not take an argument\n");
  3443.         return(-9);
  3444.     }
  3445.     switch (y) {
  3446.       case TYP_NOP: xp = 0; break;
  3447.       case TYP_PAG: xp = 1; break;
  3448.       case TYP_WID:
  3449.         if (getval)
  3450.           if ((x = cmnum("Column at which to truncate",
  3451.                  ckitoa(cmd_cols),10,&y,xxstring)) < 0)
  3452.         return(x);
  3453.         typ_wid = y;
  3454.         break;
  3455.  
  3456.           default:
  3457.         printf("?Sorry, this option can not be set\n");
  3458.         return(-9);
  3459.     }
  3460.     }
  3461.     if ((x = cmcfm()) < 0)        /* Get confirmation */
  3462.       return(x);
  3463.     if (xp > -1) typ_page = xp;        /* Confirmed, save defaults */
  3464.     return(success = 1);
  3465. }
  3466.  
  3467. /* Forward declarations of functions local to this module */
  3468.  
  3469. #ifdef UNIX
  3470. _PROTOTYP (int douchmod, ( void ) );
  3471. #endif /* UNIX */
  3472. #ifdef CKPURGE
  3473. _PROTOTYP (int dopurge,  ( void ) );
  3474. #endif /* CKPURGE */
  3475. #ifndef NOSPL
  3476. _PROTOTYP (int doundef,  ( int  ) );
  3477. _PROTOTYP (int doask,    ( int  ) );
  3478. _PROTOTYP (int dodef,    ( int  ) );
  3479. _PROTOTYP (int doelse,   ( void ) );
  3480. _PROTOTYP (int dofor,    ( void ) );
  3481. _PROTOTYP (int doincr,   ( int  ) );
  3482. #endif /* NOSPL  */
  3483. #ifndef NODIAL
  3484. _PROTOTYP (int dodial,   ( int  ) );
  3485. #endif /* NODIAL */
  3486. _PROTOTYP (int dodel,    ( void ) );
  3487. _PROTOTYP (int dopaus,   ( int  ) );
  3488. #ifndef NOPUSH
  3489. #ifdef TCPSOCKET
  3490. _PROTOTYP (int doping,   ( void ) );
  3491. _PROTOTYP (int doftp,    ( void ) );
  3492. #endif /* TCPSOCKET */
  3493. #endif /* NOPUSH */
  3494. #ifndef NORENAME
  3495. #ifndef NOFRILLS
  3496. _PROTOTYP (int dorenam,  ( void ) );
  3497. #endif /* NOFRILLS */
  3498. #endif /* NORENAME */
  3499. #ifdef ZCOPY
  3500. _PROTOTYP (int docopy,   ( void ) );
  3501. #endif /* ZCOPY */
  3502. #ifdef NT
  3503. _PROTOTYP (int dolink,   ( void ));
  3504. #endif /* NT */
  3505. #ifdef CK_REXX
  3506. _PROTOTYP (int dorexx,   ( void ) );
  3507. #endif /* CK_REXX */
  3508.  
  3509. #ifdef TNCODE
  3510. static struct keytab telcmd[] = {
  3511.     { "abort", TN_ABORT, CM_INV },    /* Emotionally toned - don't show */
  3512.     { "ao",    TN_AO,    0 },
  3513.     { "ayt",   TN_AYT,   0 },
  3514.     { "break", BREAK,    0 },
  3515.     { "cancel",TN_ABORT, 0 },
  3516.     { "dmark", TN_DM,    0 },
  3517.     { "do",    DO,       0 },
  3518.     { "dont",  DONT,     0 },
  3519.     { "ec",    TN_EC,    0 },
  3520.     { "el",    TN_EL,    0 },
  3521.     { "eof",   TN_EOF,   0 },
  3522.     { "eor",   TN_EOR,   0 },
  3523. #ifdef CK_KERBEROS
  3524. #ifdef KRB5
  3525. #define TN_FWD 1
  3526.     { "forward", TN_FWD, CM_INV },
  3527. #endif /* KRB5 */
  3528. #endif /* CK_KERBEROS */
  3529.     { "ga",    TN_GA,    0 },
  3530.     { "ip",    TN_IP,    0 },
  3531.     { "nop",   TN_NOP,   0 },
  3532.     { "sak",   TN_SAK,   CM_INV },
  3533.     { "sb",    SB,       0 },
  3534.     { "se",    SE,       0 },
  3535.     { "susp",  TN_SUSP,  0 },
  3536.     { "will",  WILL,     0 },
  3537.     { "wont",  WONT,     0 }
  3538. };
  3539. static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab));
  3540.  
  3541. static struct keytab tnopts[] = {
  3542. #ifdef CK_AUTHENTICATION
  3543.     { "auth",   TELOPT_AUTHENTICATION,   0 },
  3544. #else
  3545.     { "auth",   TELOPT_AUTHENTICATION,   CM_INV },
  3546. #endif /* CK_AUTHENTICATION */
  3547.     { "binary", TELOPT_BINARY, 0 },
  3548. #ifdef TN_COMPORT
  3549.     { "c",      TELOPT_COMPORT, CM_INV|CM_ABR},
  3550.     { "co",     TELOPT_COMPORT, CM_INV|CM_ABR},
  3551.     { "com",    TELOPT_COMPORT, CM_INV|CM_ABR},
  3552.     { "com-port-control", TELOPT_COMPORT, 0 },
  3553.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3554. #else  /* TN_COMPORT */
  3555.     { "com-port-control", TELOPT_COMPORT, CM_INV },
  3556.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3557. #endif /* TN_COMPORT */
  3558.     { "echo", TELOPT_ECHO, 0 },
  3559. #ifdef CK_ENCRYPTION
  3560.     { "encrypt", TELOPT_ENCRYPTION, 0 },
  3561. #else
  3562.     { "encrypt", TELOPT_ENCRYPTION, CM_INV },
  3563. #endif /* CK_ENCRYPTION */
  3564. #ifdef CK_FORWARD_X
  3565.     { "forward-x", TELOPT_FORWARD_X, 0 },
  3566. #else
  3567.     { "forward-x", TELOPT_FORWARD_X, CM_INV },
  3568. #endif /* CK_FORWARD_X */
  3569. #ifdef IKS_OPTION
  3570.     { "kermit", TELOPT_KERMIT, 0 },
  3571. #else
  3572.     { "kermit", TELOPT_KERMIT, CM_INV },
  3573. #endif /* IKS_OPTION */
  3574.     { "lflow",  TELOPT_LFLOW, CM_INV },
  3575.     { "logout", TELOPT_LOGOUT, CM_INV },
  3576. #ifdef CK_NAWS
  3577.     { "naws", TELOPT_NAWS, 0 },
  3578. #else
  3579.     { "naws", TELOPT_NAWS, CM_INV },
  3580. #endif /* CK_NAWS */
  3581. #ifdef CK_ENVIRONMENT
  3582.     { "new-environment", TELOPT_NEWENVIRON,  0 },
  3583. #else
  3584.     { "new-environment", TELOPT_NEWENVIRON,  CM_INV },
  3585. #endif /* CK_ENVIRONMENT */
  3586.     { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT,  CM_INV },
  3587.     { "pragma-logon",    TELOPT_PRAGMA_LOGON,  CM_INV },
  3588.     { "pragma-sspi",     TELOPT_SSPI_LOGON,  CM_INV },
  3589.     { "sak",   TELOPT_IBM_SAK, CM_INV },
  3590. #ifdef CK_SNDLOC
  3591.     { "send-location",   TELOPT_SNDLOC,  0 },
  3592. #else
  3593.     { "send-location",   TELOPT_SNDLOC,  CM_INV },
  3594. #endif /* CK_SNDLOC */
  3595.     { "sga", TELOPT_SGA, 0 },
  3596. #ifdef CK_SSL
  3597.     { "start-tls",       TELOPT_START_TLS,  0 },
  3598. #else
  3599.     { "start-tls",       TELOPT_START_TLS,  CM_INV },
  3600. #endif /* CK_SSL */
  3601.     { "ttype", TELOPT_TTYPE, 0 },
  3602. #ifdef CK_ENVIRONMENT
  3603.     { "xdisplay-location", TELOPT_XDISPLOC, 0 },
  3604. #else
  3605.     { "xdisplay-location", TELOPT_XDISPLOC, CM_INV },
  3606. #endif /* CK_ENVIRONMENT */
  3607.     { "", 0, 0 }
  3608. };
  3609. static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1;
  3610.  
  3611. static struct keytab tnsbopts[] = {
  3612. #ifdef CK_NAWS
  3613.     { "naws", TELOPT_NAWS, 0 },
  3614. #endif /* CK_NAWS */
  3615.     { "", 0, 0 }
  3616. };
  3617. static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1;
  3618. #endif /* TNCODE */
  3619.  
  3620. #ifdef TCPSOCKET
  3621. #ifndef NOPUSH
  3622. #ifdef SYSFTP
  3623. int
  3624. doftp() {                /* (External) FTP command */
  3625.     char *p, *f;            /* (See doxftp() for internal one) */
  3626.     int x;
  3627.  
  3628.     if (network)            /* If we have a current connection */
  3629.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3630.     else *line = '\0';            /* as default host */
  3631.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3632.       if (*p == ':') { *p = '\0'; break; }
  3633.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3634.       return(x);
  3635.     if (nopush) {
  3636.         printf("?Sorry, FTP command disabled\n");
  3637.         return(success = 0);
  3638.     }
  3639. /* Construct FTP command */
  3640. #ifdef VMS
  3641. #ifdef MULTINET                /* TGV MultiNet */
  3642.     ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL);
  3643. #else
  3644.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3645. #endif /* MULTINET */
  3646. #else                    /* Not VMS */
  3647. #ifdef OS2ORUNIX
  3648. #ifndef NOFTP
  3649.     f = ftpapp;
  3650.     if (!f) f = "";
  3651.     if (!f[0]) f = "ftp";
  3652.     ckmakmsg(line,LINBUFSIZ,f," ",s,NULL);
  3653. #ifdef OS2
  3654.     p = line + strlen(ftpapp);
  3655.     while (p != line) {
  3656.         if (*p == '/') *p = '\\';
  3657.         p--;
  3658.     }
  3659. #endif /* OS2 */
  3660. #else /* NOFTP */
  3661.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3662. #endif /* NOFTP */
  3663. #else /* OS2ORUNIX */
  3664.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3665. #endif /* OS2ORUNIX */
  3666. #endif /* VMS */
  3667.     conres();                /* Make console normal  */
  3668. #ifdef DEC_TCPIP
  3669.     printf("\n");            /* Prevent prompt-stomping */
  3670. #endif /* DEC_TCPIP */
  3671.     x = zshcmd(line);
  3672.     concb((char)escape);
  3673.     return(success = x);
  3674. }
  3675. #endif /* SYSFTP */
  3676.  
  3677. int
  3678. doping() {                /* PING command */
  3679.     char *p;                /* just runs ping program */
  3680.     int x;
  3681.  
  3682.     if (network)            /* If we have a current connection */
  3683.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3684.     else *line = '\0';            /* as default host to be pinged. */
  3685.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3686.       if (*p == ':') { *p = '\0'; break; }
  3687.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3688.       return(x);
  3689.     if (nopush) {
  3690.         printf("?Sorry, PING command disabled\n");
  3691.         return(success = 0);
  3692.     }
  3693.  
  3694.     /* Construct PING command */
  3695. #ifdef VMS
  3696. #ifdef MULTINET                /* TGV MultiNet */
  3697.     ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL);
  3698. #else
  3699.     ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */
  3700. #endif /* MULTINET */
  3701. #else                    /* Not VMS */
  3702.     ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL);
  3703. #endif /* VMS */
  3704.     conres();                /* Make console normal  */
  3705. #ifdef DEC_TCPIP
  3706.     printf("\n");            /* Prevent prompt-stomping */
  3707. #endif /* DEC_TCPIP */
  3708.     x = zshcmd(line);
  3709.     concb((char)escape);
  3710.     return(success = x);
  3711. }
  3712. #endif /* NOPUSH */
  3713. #endif /* TCPSOCKET */
  3714.  
  3715. static VOID
  3716. doend(x) int x; {
  3717. #ifndef NOSPL
  3718.     /* Pop from all FOR/WHILE/XIF/SWITCH's */
  3719.     debug(F101,"doend maclvl 1","",maclvl);
  3720.     while ((maclvl > 0) &&
  3721.        (m_arg[maclvl-1][0]) &&
  3722.        (cmdstk[cmdlvl].src == CMD_MD) &&
  3723.        (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  3724.         !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  3725.         !strncmp(m_arg[maclvl-1][0],"_whi",4) ||
  3726.         !strncmp(m_arg[maclvl-1][0],"_swi",4))) {
  3727.     debug(F110,"END popping",m_arg[maclvl-1][0],0);
  3728.     dogta(XXPTA);            /* Put args back */
  3729.     popclvl();            /* Pop up two levels */
  3730.     popclvl();
  3731.     debug(F101,"doend maclvl 2","",maclvl);
  3732.     }
  3733.     if (maclvl > -1) {
  3734.     if (mrval[maclvl])        /* Free previous retval if any */
  3735.       free(mrval[maclvl]);
  3736.     mrval[maclvl] = malloc(16);    /* Room for up to 15 digits */
  3737.     if (mrval[maclvl])        /* Record current retval */
  3738.       ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL);
  3739.     }
  3740. #endif /* NOSPL */
  3741.     popclvl();                /* Now pop out of macro or TAKE file */
  3742. #ifndef NOSPL
  3743. #ifdef DEBUG
  3744.     if (deblog) {
  3745.     debug(F101,"END maclvl 3","",maclvl);
  3746.     debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl);
  3747.     debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1);
  3748.     }
  3749. #endif /* DEBUG */
  3750. #endif /* NOSPL */
  3751. }
  3752.  
  3753. #ifdef CKROOT
  3754. int
  3755. dochroot() {
  3756.     if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) {
  3757.     if (x == -3) {
  3758.         printf("?Directory name required\n");
  3759.         return(-9);
  3760.     }
  3761.     return(x);
  3762.     }
  3763.     ckstrncpy(line,s,LINBUFSIZ);
  3764.     s = line;
  3765.     if ((x = cmcfm()) < 0) return(x);
  3766.     s = brstrip(s);
  3767.     x = zsetroot(s);
  3768.     if (x < 0) {
  3769.     char * m = NULL;
  3770.     switch (x) {
  3771.       case -1:
  3772.       case -2: m = "Not a directory"; break;
  3773.       case -3: m = "Internal error"; break;
  3774.       case -4: m = "Access denied"; break;
  3775.       case -5: m = "Off limits"; break;
  3776.     }
  3777.     if (m) printf("%s: \"%s\"\n", m, s);
  3778.     return(m ? -9 : -2);
  3779.     } else {
  3780.     nopush = 1;
  3781.     return(success = 1);
  3782.     }
  3783. }
  3784. #endif /* CKROOT */
  3785.  
  3786. #ifndef NOXFER
  3787. static char * asnbuf = NULL;        /* As-name buffer pointer */
  3788.  
  3789. char sndxnam[] = { "_array_x_" };    /* (with replaceable x!) */
  3790.  
  3791. /*
  3792.   The new SEND command, replacing BSEND, CSEND, PSEND, etc etc.
  3793.   Call with cx = top-level keyword value.  Returns:
  3794.     < 0  On parse error.
  3795.     0    On other type of failure (e.g. requested operation not allowed).
  3796.     1    On success with sstate set to 's' so protocol will begin.
  3797. */
  3798.  
  3799. /*  D O X S E N D  --  Parse SEND and related commands with switches  */
  3800.  
  3801. int
  3802. doxsend(cx) int cx; {
  3803.     int c, i, n, wild, confirmed = 0;    /* Workers */
  3804.     int x, y;                /* of the world... */
  3805.     int getval = 0;            /* Whether to get switch value */
  3806.     extern char * snd_move;        /* Directory to move sent files to */
  3807.     extern char * snd_rename;        /* What to rename sent files to */
  3808.     extern char * filefile;        /* File containing filenames to send */
  3809.     extern int xfiletype;        /* Send only text (or binary) files */
  3810.     extern struct keytab pathtab[];    /* PATHNAMES option keywords */
  3811.     extern int npathtab;        /* How many of them */
  3812.     extern int recursive;        /* Recursive directory traversal */
  3813.     extern int rprintf;            /* REMOTE PRINT flag */
  3814.     extern int fdispla;            /* TRANSFER DISPLAY setting */
  3815.     extern int skipbup;            /* Skip backup files when sending */
  3816.     struct stringint {            /* Temporary array for switch values */
  3817.     char * sval;
  3818.     int ival;
  3819.     } pv[SND_MAX+1];
  3820.     struct FDB sf, sw, fl, cm;        /* FDBs for each parse function */
  3821.     int mlist = 0;            /* Flag for MSEND or MMOVE */
  3822.     char * m;                /* For making help messages */
  3823.     extern struct keytab protos[];    /* File transfer protocols */
  3824.     extern int xfrxla, g_xfrxla, nprotos;
  3825.     extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */
  3826.     extern char sndnbefore[], sndnafter[];
  3827.     extern long sndsmaller, sndlarger, calibrate;
  3828. #ifndef NOSPL
  3829.     int range[2];            /* Array range */
  3830.     char ** ap = NULL;            /* Array pointer */
  3831.     int arrayx = -1;            /* Array index */
  3832. #endif /* NOSPL */
  3833.  
  3834. #ifdef NEWFTP
  3835.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  3836.     if (cx == XXMAI) {
  3837.         printf("?Sorry, No MAIL with FTP\n");
  3838.         return(-9);
  3839.     }
  3840.     return(doftpput(cx,0));
  3841.     }
  3842. #endif /* NEWFTP */
  3843.  
  3844.     for (i = 0; i <= SND_MAX; i++) {    /* Initialize switch values */
  3845.     pv[i].sval = NULL;        /* to null pointers */
  3846.     pv[i].ival = -1;        /* and -1 int values */
  3847.     }
  3848. #ifndef NOSPL
  3849.     range[0] = -1;
  3850.     range[1] = -1;
  3851.     sndxin = -1;            /* Array index */
  3852. #endif /* NOSPL */
  3853.     sndarray = NULL;            /* Array pointer */
  3854.  
  3855. #ifdef UNIXOROSK
  3856.     g_matchdot = matchdot;        /* Match dot files */
  3857. #endif /* UNIXOROSK */
  3858.     g_recursive = recursive;        /* Recursive sending */
  3859.     recursive = 0;            /* Save global value, set local */
  3860.     debug(F101,"xsend entry fncnv","",fncnv);
  3861.  
  3862.     /* Preset switch values based on top-level command that called us */
  3863.  
  3864.     switch (cx) {
  3865.       case XXMSE:            /* MSEND */
  3866.     mlist = 1; break;
  3867.       case XXCSEN:            /* CSEND */
  3868.     pv[SND_CMD].ival = 1; break;
  3869.       case XXMMOVE:            /* MMOVE */
  3870.     mlist = 1;
  3871.       case XXMOVE:            /* MOVE */
  3872.     pv[SND_DEL].ival = 1; break;
  3873.       case XXRSEN:            /* RESEND */
  3874.     pv[SND_BIN].ival = 1;        /* Implies /BINARY */
  3875.     pv[SND_RES].ival = 1; break;
  3876.       case XXMAI:            /* MAIL */
  3877.     pv[SND_MAI].ival = 1; break;
  3878.     }
  3879.  
  3880.     /* Set up chained parse functions... */
  3881.  
  3882.     cmfdbi(&sw,                /* First FDB - command switches */
  3883.        _CMKEY,            /* fcode */
  3884.        "Filename, or switch",    /* hlpmsg */
  3885.        "",                /* default */
  3886.        "",                /* addtl string data */
  3887. #ifdef NOMSEND
  3888.        nsndtab,            /* addtl numeric data 1: tbl size */
  3889. #else
  3890.        mlist ? nmsndtab : nsndtab,    /* addtl numeric data 1: tbl size */
  3891. #endif /* NOMSEND */
  3892.        4,                /* addtl numeric data 2: 4 = cmswi */
  3893.        xxstring,            /* Processing function */
  3894. #ifdef NOMSEND
  3895.        sndtab,            /* Keyword table */
  3896. #else
  3897.        mlist ? msndtab : sndtab,
  3898. #endif /* NOMSEND */
  3899.        &sf                /* Pointer to next FDB */
  3900.        );
  3901.     cmfdbi(&sf,                /* 2nd FDB - file to send */
  3902.        _CMIFI,            /* fcode */
  3903.        "File(s) to send",        /* hlpmsg */
  3904.        "",                /* default */
  3905.        "",                /* addtl string data */
  3906.        nolinks,            /* addtl numeric data 1 */
  3907.        0,                /* addtl numeric data 2 */
  3908.        xxstring,
  3909.        NULL,
  3910.        mlist ? &cm : &fl
  3911.        );
  3912.     cmfdbi(&fl,                /* 3rd FDB - command to send from */
  3913.        _CMFLD,            /* fcode */
  3914.        "Command",            /* hlpmsg */
  3915.        "",                /* default */
  3916.        "",                /* addtl string data */
  3917.        0,                /* addtl numeric data 1 */
  3918.        0,                /* addtl numeric data 2 */
  3919.        xxstring,
  3920.        NULL,
  3921.        &cm
  3922.        );
  3923.     cmfdbi(&cm,                /* 4th FDB - Confirmation */
  3924.        _CMCFM,            /* fcode */
  3925.        "",                /* hlpmsg */
  3926.        "",                /* default */
  3927.        "",                /* addtl string data */
  3928.        0,                /* addtl numeric data 1 */
  3929.        0,                /* addtl numeric data 2 */
  3930.        NULL,
  3931.        NULL,
  3932.        NULL
  3933.        );
  3934.  
  3935.     while (1) {                /* Parse 0 or more switches */
  3936.     x = cmfdb(&sw);            /* Parse something */
  3937.     debug(F101,"xsend cmfdb","",x);
  3938.     if (x < 0)            /* Error */
  3939.       goto xsendx;            /* or reparse needed */
  3940.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  3941.       break;
  3942. /*
  3943.   They gave a switch, but let's see how they terminated it.
  3944.   If they ended it with : or =, then we must parse a value.
  3945.   If they ended it with anything else, then we must NOT parse a value.
  3946. */
  3947.     c = cmgbrk();            /* Get break character */
  3948.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  3949.     if (getval && !(cmresult.kflags & CM_ARG)) {
  3950.         printf("?This switch does not take arguments\n");
  3951.         x = -9;
  3952.         goto xsendx;
  3953.     }
  3954.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  3955.         printf("?This switch requires an argument\n");
  3956.         x = -9;
  3957.         goto xsendx;
  3958.     }
  3959.     n = cmresult.nresult;        /* Numeric result = switch value */
  3960.     debug(F101,"xsend switch","",n);
  3961.  
  3962.     switch (n) {            /* Process the switch */
  3963.       case SND_CMD:            /* These take no args */
  3964.         if (nopush) {
  3965.         printf("?Sorry, system command access is disabled\n");
  3966.         x = -9;
  3967.         goto xsendx;
  3968.         }
  3969. #ifdef PIPESEND
  3970.         else if (sndfilter) {
  3971.         printf(
  3972. "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n");
  3973.         x = -9;
  3974.         goto xsendx;
  3975.         }
  3976. #endif /* PIPESEND */
  3977.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  3978.         pv[n].ival = 1;        /* Just set the flag */
  3979.         pv[SND_ARR].ival = 0;
  3980.         break;
  3981.  
  3982.       case SND_REC:            /* /RECURSIVE */
  3983.         recursive = 2;        /* Set the real variable */
  3984.         pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */
  3985.         pv[n].ival = 1;        /* Just set the flag */
  3986.         break;
  3987.  
  3988.       case SND_RES:            /* /RECOVER (resend) */
  3989.         pv[SND_ARR].ival = 0;
  3990.         pv[SND_BIN].ival = 1;    /* Implies /BINARY */
  3991.       case SND_NOB:            /* /NOBACKUP */
  3992.       case SND_DEL:            /* /DELETE */
  3993.       case SND_SHH:            /* /QUIET */
  3994.         pv[n].ival = 1;        /* Just set the flag */
  3995.         break;
  3996.  
  3997. #ifdef UNIXOROSK
  3998. /* Like recursive, these are set immediately because they affect cmifi() */
  3999.       case SND_DOT:            /* /DOTFILES */
  4000.         matchdot = 1;
  4001.         break;
  4002.       case SND_NOD:            /* /NODOTFILES */
  4003.         matchdot = 0;
  4004.         break;
  4005. #endif /* UNIXOROSK */
  4006.  
  4007.       /* File transfer modes - each undoes the others */
  4008.  
  4009.       case SND_BIN:            /* Binary */
  4010.       case SND_TXT:            /* Text */
  4011.       case SND_IMG:            /* Image */
  4012.       case SND_LBL:            /* Labeled */
  4013.         pv[SND_BIN].ival = 0;
  4014.         pv[SND_TXT].ival = 0;
  4015.         pv[SND_IMG].ival = 0;
  4016.         pv[SND_LBL].ival = 0;
  4017.         pv[n].ival = 1;
  4018.         break;
  4019.  
  4020. #ifdef CKSYMLINK
  4021.       case SND_LNK:
  4022.       case SND_NLK:
  4023.         nolinks = (n == SND_NLK) ? 2 : 0;
  4024.         cmfdbi(&sf,            /* Redo cmifi() */
  4025.            _CMIFI,        /* fcode */
  4026.            "File(s) to send",    /* hlpmsg */
  4027.            "",            /* default */
  4028.            "",            /* addtl string data */
  4029.            nolinks,        /* addtl numeric data 1 */
  4030.            0,            /* addtl numeric data 2 */
  4031.            xxstring,
  4032.            NULL,
  4033.            mlist ? &cm : &fl
  4034.            );
  4035.         break;
  4036. #endif /* CKSYMLINK */
  4037.  
  4038.       case SND_EXC:            /* Excludes */
  4039.         if (!getval) break;
  4040.         if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
  4041.         if (x == -3) {
  4042.             printf("?Pattern required\n");
  4043.             x = -9;
  4044.         }
  4045.         goto xsendx;
  4046.         }
  4047.         if (pv[n].sval) free(pv[n].sval);
  4048.         y = strlen(s);
  4049.         if (y > 256) {
  4050.         printf("?Pattern too long - 256 max\n");
  4051.         x = -9;
  4052.         goto xsendx;
  4053.         }
  4054.         pv[n].sval = malloc(y+1);
  4055.         if (pv[n].sval) {
  4056.         strcpy(pv[n].sval,s);    /* safe */
  4057.         pv[n].ival = 1;
  4058.         }
  4059.         break;
  4060.  
  4061.       case SND_MOV:            /* MOVE after */
  4062.       case SND_REN:            /* RENAME after */
  4063.         if (!getval) break;
  4064.         if ((x = cmfld(n == SND_MOV ?
  4065.        "device and/or directory for source file after sending" :
  4066.        "new name for source file after sending",
  4067.                "",
  4068.                &s,
  4069.                n == SND_MOV ? xxstring : NULL
  4070.                )) < 0) {
  4071.         if (x == -3) {
  4072.             printf("%s\n", n == SND_MOV ?
  4073.                "?Destination required" :
  4074.                "?New name required"
  4075.                );
  4076.             x = -9;
  4077.         }
  4078.         goto xsendx;
  4079.         }
  4080.         if (pv[n].sval) free(pv[n].sval);
  4081.         s = brstrip(s);
  4082.         y = strlen(s);
  4083.         if (y > 0) {
  4084.         pv[n].sval = malloc(y+1);
  4085.         if (pv[n].sval) {
  4086.             strcpy(pv[n].sval,s); /* safe */
  4087.             pv[n].ival = 1;
  4088.         }
  4089.         }
  4090.         break;
  4091.  
  4092.       case SND_SMA:            /* Smaller / larger than */
  4093.       case SND_LAR:
  4094.         if (!getval) break;
  4095.         if ((x = cmnum("Size in bytes","0",10,&y,xxstring)) < 0)
  4096.           goto xsendx;
  4097.         pv[n].ival = y;
  4098.         break;
  4099.  
  4100.       case SND_AFT:            /* Send /AFTER:date-time */
  4101.       case SND_BEF:            /* Send /BEFORE:date-time */
  4102.       case SND_NAF:            /* Send /NOT-AFTER:date-time */
  4103.       case SND_NBE:            /* Send /NOT-BEFORE:date-time */
  4104.         if (!getval) break;
  4105.         if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) {
  4106.         if (x == -3) {
  4107.             printf("?Date-time required\n");
  4108.             x = -9;
  4109.         }
  4110.         goto xsendx;
  4111.         }
  4112.         if (pv[n].sval) free(pv[n].sval);
  4113.         pv[n].sval = malloc((int)strlen(s)+1);
  4114.         if (pv[n].sval) {
  4115.         strcpy(pv[n].sval,s);    /* safe */
  4116.         pv[n].ival = 1;
  4117.         }
  4118.         break;
  4119.  
  4120.       case SND_MAI:            /* Send as mail (= MAIL) */
  4121. #ifdef IKSD
  4122.         if (inserver && !ENABLED(en_mai)) {
  4123.         printf("?Sorry, sending files as mail is disabled\n");
  4124.         return(-9);
  4125.         }
  4126. #endif /* IKSD */
  4127.         pv[n].ival = 1;
  4128.         if (!getval) break;
  4129.         if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) {
  4130.         if (x == -3) {
  4131.             printf("?address required\n");
  4132.             x = -9;
  4133.         }
  4134.         goto xsendx;
  4135.         }
  4136.         s = brstrip(s);
  4137.         if (pv[n].sval) free(pv[n].sval);
  4138.         pv[n].sval = malloc((int)strlen(s)+1);
  4139.         if (pv[n].sval)
  4140.           strcpy(pv[n].sval,s);    /* safe */
  4141.         break;
  4142.  
  4143.       case SND_PRI:            /* Send to be printed (REMOTE PRINT) */
  4144. #ifdef IKSD
  4145.         if (inserver && !ENABLED(en_mai)) {
  4146.         printf("?Sorry, sending files for printing is disabled\n");
  4147.         return(-9);
  4148.         }
  4149. #endif /* IKSD */
  4150.         pv[n].ival = 1;
  4151.         if (!getval) break;
  4152.         if ((x = cmfld("Print options","",&s,xxstring)) < 0)
  4153.           if (x != -3) goto xsendx;
  4154.         s = brstrip(s);
  4155.         if (pv[n].sval) free(pv[n].sval);
  4156.         pv[n].sval = malloc((int)strlen(s)+1);
  4157.         if (pv[n].sval)
  4158.           strcpy(pv[n].sval,s);    /* safe */
  4159.         break;
  4160.  
  4161.       case SND_ASN:            /* As-name */
  4162.         debug(F101,"xsend /as-name getval","",getval);
  4163.         if (!getval) break;
  4164.         if ((x = cmfld("Name to send under","",&s,NULL)) < 0) {
  4165.         if (x == -3) {
  4166.             printf("?name required\n");
  4167.             x = -9;
  4168.         }
  4169.         goto xsendx;
  4170.         }
  4171.         s = brstrip(s);
  4172.         if ((y = strlen(s)) > 0) {
  4173.         if (pv[n].sval) free(pv[n].sval);
  4174.         pv[n].sval = malloc(y+1);
  4175.         if (pv[n].sval) {
  4176.             strcpy(pv[n].sval,s); /* safe */
  4177.             pv[n].ival = 1;
  4178.         }
  4179.         }
  4180.         break;
  4181.  
  4182.       case SND_STA:            /* Starting position (= PSEND) */
  4183.         if (!getval) break;
  4184.         if ((x = cmnum("0-based position","0",10,&y,xxstring)) < 0)
  4185.           goto xsendx;
  4186.         pv[n].ival = y;
  4187.         break;
  4188.  
  4189.       case SND_PRO:            /* Protocol to use */
  4190.         if (!getval) break;
  4191.         if ((x = cmkey(protos,nprotos,"File-transfer protocol","",
  4192.                xxstring)) < 0) {
  4193.         if (x == -3) {
  4194.             printf("?name of protocol required\n");
  4195.             x = -9;
  4196.         }
  4197.         goto xsendx;
  4198.         }
  4199.         pv[n].ival = x;
  4200.         break;
  4201.  
  4202. #ifdef PIPESEND
  4203.       case SND_FLT:            /* Filter */
  4204.         debug(F101,"xsend /filter getval","",getval);
  4205.         if (!getval) break;
  4206.         if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) {
  4207.         if (x == -3)
  4208.           s = "";
  4209.         else
  4210.           goto xsendx;
  4211.         }
  4212.         if (*s) s = brstrip(s);
  4213.         y = strlen(s);
  4214.         for (x = 0; x < y; x++) {    /* Make sure they included "\v(...)" */
  4215.         if (s[x] != '\\') continue;
  4216.         if (s[x+1] == 'v') break;
  4217.         }
  4218.         if (x == y) {
  4219.         printf(
  4220.         "?Filter must contain a replacement variable for filename.\n"
  4221.                );
  4222.         x = -9;
  4223.         goto xsendx;
  4224.         }
  4225.         pv[n].ival = 1;
  4226.         if (pv[n].sval) {
  4227.         free(pv[n].sval);
  4228.         pv[n].sval = NULL;
  4229.         }
  4230.         if ((y = strlen(s)) > 0) {
  4231.         if ((pv[n].sval = malloc(y+1)))
  4232.           strcpy(pv[n].sval,s);    /* safe */
  4233.         }
  4234.         break;
  4235. #endif /* PIPESEND */
  4236.  
  4237.       case SND_PTH:            /* Pathnames */
  4238.         if (!getval) {
  4239.         pv[n].ival = PATH_REL;
  4240.         break;
  4241.         }
  4242.         if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0)
  4243.           goto xsendx;
  4244.         pv[n].ival = x;
  4245.         break;
  4246.  
  4247.       case SND_NAM:            /* Filenames */
  4248.         if (!getval) break;
  4249.         if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0)
  4250.           goto xsendx;
  4251.         debug(F101,"xsend /filenames","",x);
  4252.         pv[n].ival = x;
  4253.         break;
  4254.  
  4255. #ifdef CALIBRATE
  4256.           case SND_CAL:            /* /CALIBRATE */
  4257.         if (getval) {
  4258.         if ((x = cmnum("number of Kbytes to send",
  4259.                "1024",10,&y,xxstring)) < 0)
  4260.           goto xsendx;
  4261.         } else
  4262.           y = 1024;
  4263.         pv[n].ival = y;
  4264.         pv[SND_ARR].ival = 0;
  4265.         break;
  4266. #endif /* CALIBRATE */
  4267.  
  4268.       case SND_FIL:            /* Name of file containing filnames */
  4269.         if (!getval) break;
  4270.         if ((x = cmifi("Name of file containing list of filenames",
  4271.                    "",&s,&y,xxstring)) < 0) {
  4272.         if (x == -3) {
  4273.             printf("?Filename required\n");
  4274.             x = -9;
  4275.         }
  4276.         goto xsendx;
  4277.         } else if (y) {
  4278.         printf("?Wildcards not allowed\n");
  4279.         x = -9;
  4280.         goto xsendx;
  4281.         }
  4282.         if (pv[n].sval)
  4283.           free(pv[n].sval);
  4284.         if (s) if (*s) {
  4285.         if ((pv[n].sval = malloc((int)strlen(s)+1))) {
  4286.             strcpy(pv[n].sval,s);
  4287.             pv[n].ival = 1;
  4288.             pv[SND_ARR].ival = 0;
  4289.         }
  4290.         }
  4291.         break;
  4292.  
  4293. #ifndef NOSPL
  4294.       case SND_ARR:            /* SEND /ARRAY: */
  4295.         if (!getval) break;
  4296.         ap = NULL;
  4297.         if ((x = cmfld("Array name (a single letter will do)",
  4298.                "",
  4299.                &s,
  4300.                NULL
  4301.                )) < 0) {
  4302.         if (x == -3)
  4303.           break;
  4304.         else
  4305.           return(x);
  4306.         }
  4307.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  4308.         printf("?Bad array: %s\n",s);
  4309.         return(-9);
  4310.         }
  4311.         if (!(ap = a_ptr[x])) {
  4312.         printf("?No such array: %s\n",s);
  4313.         return(-9);
  4314.         }
  4315.         pv[n].ival = 1;
  4316.         pv[SND_CMD].ival = 0;    /* Undo any conflicting ones... */
  4317.         pv[SND_RES].ival = 0;
  4318.         pv[SND_CAL].ival = 0;
  4319.         pv[SND_FIL].ival = 0;
  4320.         arrayx = x;
  4321.         break;
  4322. #endif /* NOSPL */
  4323.  
  4324.       case SND_XPA:            /* /TRANSPARENT */
  4325.         pv[n].ival = 1;
  4326.         break;
  4327.  
  4328.       case SND_TYP:            /* Only files of given type */
  4329.         if (!getval) break;
  4330.         if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0)
  4331.           goto xsendx;
  4332.         pv[n].ival = (x == 2) ? -1 : x;
  4333.         break;
  4334.  
  4335.       default:
  4336.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  4337.         x = -9;
  4338.         goto xsendx;
  4339.     }
  4340.     }
  4341.     debug(F101,"xsend cmresult fcode","",cmresult.fcode);
  4342.  
  4343. #ifdef COMMENT
  4344.     /* List switch parsing results in debug log */
  4345.     for (i = 0; i <= SND_MAX; i++) {
  4346.     ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL);
  4347.     debug(F111,line, pv[i].sval, pv[i].ival);
  4348.     }
  4349. #endif /* COMMENT */
  4350.  
  4351. /* Now we have all switches, plus maybe a filename or command, or nothing */
  4352.  
  4353. #ifdef PIPESEND
  4354.     if (protocol != PROTO_K && pv[SND_CMD].ival > 0) {
  4355.     printf("?Sorry, %s works only with Kermit protocol\n",
  4356.            (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND");
  4357.     x = -9;
  4358.     goto xsendx;
  4359.     }
  4360.     if (pv[SND_RES].ival > 0 ||    /* /RECOVER */
  4361.     pv[SND_STA].ival > 0) {    /* or /STARTING */
  4362.     if (sndfilter || pv[SND_FLT].ival > 0) {
  4363.         printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n");
  4364.         x = -9;
  4365.         goto xsendx;
  4366.     }
  4367.     }
  4368. #endif /* PIPESEND */
  4369.  
  4370.     cmarg = "";
  4371.     cmarg2 = "";
  4372.     line[0] = NUL;
  4373.     s = line;
  4374.     wild = 0;
  4375.  
  4376.     switch (cmresult.fcode) {        /* How did we get out of switch loop */
  4377.       case _CMIFI:            /* Input filename */
  4378.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
  4379.     if (pv[SND_ARR].ival > 0)
  4380.       cmarg2 = line;
  4381.     else
  4382.       wild = cmresult.nresult;    /* Wild flag */
  4383.     if (!recursive && !wild)
  4384.       nolinks = 0;
  4385.     break;
  4386.       case _CMFLD:            /* Field */
  4387.     /* Only allowed with /COMMAND and /ARRAY */
  4388.     if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) {
  4389. #ifdef CKROOT
  4390.         if (ckrooterr)
  4391.           printf("?Off limits: %s\n",cmresult.sresult);
  4392.         else
  4393. #endif /* CKROOT */
  4394.           printf("?%s - \"%s\"\n",
  4395.            iswild(cmresult.sresult) ?
  4396.            "No files match" : "File not found",
  4397.            cmresult.sresult
  4398.            );
  4399.         x = -9;
  4400.         goto xsendx;
  4401.     }
  4402.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  4403.     if (pv[SND_ARR].ival > 0)
  4404.       cmarg2 = line;
  4405.     break;
  4406.       case _CMCFM:            /* Confirmation */
  4407.     /* s = ""; */
  4408.     confirmed = 1;
  4409.     break;
  4410.       default:
  4411.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  4412.     x = -9;
  4413.     goto xsendx;
  4414.     }
  4415.     debug(F110,"xsend string",s,0);
  4416.     debug(F101,"xsend confirmed","",confirmed);
  4417.  
  4418.     /* Save and change protocol and transfer mode */
  4419.     /* Global values are restored in main parse loop */
  4420.  
  4421.     g_proto = protocol;            /* Save current global protocol */
  4422.     g_urpsiz = urpsiz;
  4423.     g_spsizf = spsizf;
  4424.     g_spsiz = spsiz;
  4425.     g_spsizr = spsizr;
  4426.     g_spmax = spmax;
  4427.     g_wslotr = wslotr;
  4428.     g_prefixing = prefixing;
  4429.     g_fncact = fncact;
  4430.     g_fncnv = fncnv;
  4431.     g_fnspath = fnspath;
  4432.     g_fnrpath = fnrpath;
  4433.     g_xfrxla = xfrxla;
  4434.  
  4435.     if (pv[SND_PRO].ival > -1) {    /* Change according to switch */
  4436.     protocol = pv[SND_PRO].ival;
  4437.         if (ptab[protocol].rpktlen > -1) /* copied from initproto() */
  4438.             urpsiz = ptab[protocol].rpktlen;
  4439.         if (ptab[protocol].spktflg > -1)
  4440.             spsizf = ptab[protocol].spktflg;
  4441.         if (ptab[protocol].spktlen > -1) {
  4442.             spsiz = ptab[protocol].spktlen;
  4443.             if (spsizf)
  4444.           spsizr = spmax = spsiz;
  4445.         }
  4446.         if (ptab[protocol].winsize > -1)
  4447.             wslotr = ptab[protocol].winsize;
  4448.         if (ptab[protocol].prefix > -1)
  4449.             prefixing = ptab[protocol].prefix;
  4450.         if (ptab[protocol].fnca > -1)
  4451.             fncact  = ptab[protocol].fnca;
  4452.         if (ptab[protocol].fncn > -1)
  4453.             fncnv   = ptab[protocol].fncn;
  4454.         if (ptab[protocol].fnsp > -1)
  4455.             fnspath = ptab[protocol].fnsp;
  4456.         if (ptab[protocol].fnrp > -1)
  4457.             fnrpath = ptab[protocol].fnrp;
  4458.     }
  4459.     debug(F101,"xsend protocol","",protocol);
  4460.  
  4461.     if (pv[SND_NOB].ival > -1) {    /* /NOBACKUP (skip backup file) */
  4462.     g_skipbup = skipbup;
  4463.     skipbup = 1;
  4464.     }
  4465.     if (pv[SND_REC].ival > 0)        /* /RECURSIVE */
  4466.       recursive = 2;
  4467.  
  4468.     if (pv[SND_TYP].ival > -1) {    /* /TYPE */
  4469.     xfiletype = pv[SND_TYP].ival;
  4470.     if (xfiletype == 2)
  4471.       xfiletype = -1;
  4472.     }
  4473.     g_binary = binary;            /* Save global transfer mode */
  4474. #ifdef PATTERNS
  4475.     g_patterns = patterns;        /* Save FILE PATTERNS setting */
  4476. #endif /* PATTERNS */
  4477.     if (pv[SND_BIN].ival > 0) {        /* Change according to switch */
  4478.     /* If they said /BINARY they mean /BINARY */
  4479.     patterns = 0;            /* So no pattern-based switching */
  4480.     g_xfermode = xfermode;        /* or automatic transfer mode */
  4481.     xfermode = XMODE_M;
  4482.     binary = XYFT_B;
  4483.     debug(F101,"doxsend /BINARY xfermode","",xfermode);
  4484.     } else if (pv[SND_TXT].ival > 0) {    /* Ditto for /TEXT */
  4485.     patterns = 0;
  4486.     g_xfermode = xfermode;
  4487.     xfermode = XMODE_M;
  4488.     binary = XYFT_T;
  4489.     debug(F101,"doxsend /TEXT xfermode","",xfermode);
  4490.     } else if (pv[SND_IMG].ival > 0) {
  4491. #ifdef VMS
  4492.     binary = XYFT_I;
  4493. #else
  4494.     binary = XYFT_B;
  4495. #endif /* VMS */
  4496.     }
  4497. #ifdef CK_LABELED
  4498.     else if (pv[SND_LBL].ival > 0) {
  4499.     binary = XYFT_L;
  4500.     }
  4501. #endif /* CK_LABELED */
  4502.     debug(F101,"xsend binary","",binary);
  4503.  
  4504.     if (pv[SND_XPA].ival > 0)        /* /TRANSPARENT */
  4505.       xfrxla = 0;            /* Don't translate character sets */
  4506.  
  4507.     /* Check for legal combinations of switches, filenames, etc */
  4508.  
  4509. #ifdef PIPESEND
  4510.     if (pv[SND_CMD].ival > 0) {    /* COMMAND - strip any braces */
  4511.     debug(F110,"SEND /COMMAND before stripping",s,0);
  4512.     s = brstrip(s);
  4513.     debug(F110,"SEND /COMMAND after stripping",s,0);
  4514.     if (!*s) {
  4515.         printf("?Sorry, a command to send from is required\n");
  4516.         x = -9;
  4517.         goto xsendx;
  4518.     }
  4519.     cmarg = s;
  4520.     }
  4521. #endif /* PIPESEND */
  4522.  
  4523. /* Set up /MOVE and /RENAME */
  4524.  
  4525.     if (pv[SND_DEL].ival > 0 &&
  4526.     (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) {
  4527.     printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n");
  4528.     x = -9;
  4529.     goto xsendx;
  4530.     }
  4531. #ifdef CK_TMPDIR
  4532.     if (pv[SND_MOV].ival > 0) {
  4533.     int len;
  4534.     char * p = pv[SND_MOV].sval;
  4535. #ifdef CK_LOGIN
  4536.     if (isguest) {
  4537.         printf("?Sorry, /MOVE-TO not available to guests\n");
  4538.         x = -9;
  4539.         goto xsendx;
  4540.     }
  4541. #endif /* CK_LOGIN */
  4542.     len = strlen(p);
  4543.     if (!isdir(p)) {        /* Check directory */
  4544. #ifdef CK_MKDIR
  4545.         char * s = NULL;
  4546.         s = (char *)malloc(len + 4);
  4547.         if (s) {
  4548.         strcpy(s,p);        /* safe */
  4549. #ifdef datageneral
  4550.         if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; }
  4551. #else
  4552.         if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; }
  4553. #endif /* datageneral */
  4554.         s[len++] = 'X';
  4555.         s[len] = NUL;
  4556.         x = zmkdir(s);
  4557.         free(s);
  4558.         if (x < 0) {
  4559.             printf("?Can't create \"%s\"\n",p);
  4560.             x = -9;
  4561.             goto xsendx;
  4562.         }
  4563.         }
  4564. #else
  4565.         printf("?Directory \"%s\" not found\n",p);
  4566.         x = -9;
  4567.         goto xsendx;
  4568. #endif /* CK_MKDIR */
  4569.     }
  4570.     makestr(&snd_move,p);
  4571.     }
  4572. #endif /* CK_TMPDIR */
  4573.  
  4574.     if (pv[SND_REN].ival > 0) {        /* /RENAME */
  4575.     char * p = pv[SND_REN].sval;
  4576. #ifdef CK_LOGIN
  4577.     if (isguest) {
  4578.         printf("?Sorry, /RENAME-TO not available to guests\n");
  4579.         x = -9;
  4580.         goto xsendx;
  4581.     }
  4582. #endif /* CK_LOGIN */
  4583.     if (!p) p = "";
  4584.     if (!*p) {
  4585.         printf("?New name required for /RENAME\n");
  4586.         x = -9;
  4587.         goto xsendx;
  4588.     }
  4589.     p = brstrip(p);
  4590. #ifndef NOSPL
  4591.     /* If name given is wild, rename string must contain variables */
  4592.     if (wild) {
  4593.         char * s = tmpbuf;
  4594.         x = TMPBUFSIZ;
  4595.         zzstring(p,&s,&x);
  4596.         if (!strcmp(tmpbuf,p)) {
  4597.         printf(
  4598.     "?/RENAME for file group must contain variables such as \\v(filename)\n"
  4599.                );
  4600.         x = -9;
  4601.         goto xsendx;
  4602.         }
  4603.     }
  4604. #endif /* NOSPL */
  4605.     makestr(&snd_rename,p);
  4606.     }
  4607.  
  4608. /* Handle /RECOVER and /START */
  4609.  
  4610. #ifdef CK_RESEND
  4611.     if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek
  4612. #ifdef PATTERNS
  4613.     && !patterns
  4614. #else
  4615. #ifdef VMS
  4616. /* VMS sets text/binary automatically later when it opens the file */
  4617.     && 0
  4618. #endif /* VMS */
  4619. #endif /* PATTERNS */
  4620.     ) {
  4621.     printf("?Sorry, /BINARY required\n");
  4622.     x = -9;
  4623.     goto xsendx;
  4624.     }
  4625.     if (pv[SND_STA].ival > 0) {        /* /START */
  4626.     if (wild) {
  4627.         printf("?Sorry, wildcards not permitted with /START\n");
  4628.         x = -9;
  4629.         goto xsendx;
  4630.     }
  4631.     if (sizeof(int) < 4) {
  4632.         printf("?Sorry, this command needs 32-bit integers\n");
  4633.         x = -9;
  4634.         goto xsendx;
  4635.     }
  4636. #ifdef CK_XYZ
  4637.     if (protocol != PROTO_K) {
  4638.         printf("?Sorry, SEND /START works only with Kermit protocol\n");
  4639.         x = -9;
  4640.         goto xsendx;
  4641.     }
  4642. #endif /* CK_XYZ */
  4643.     }
  4644. #ifdef CK_XYZ
  4645.     if (pv[SND_RES].ival > 0) {
  4646.     if (protocol != PROTO_K && protocol != PROTO_Z) {
  4647.         printf(
  4648.     "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n"
  4649.            );
  4650.         x = -9;
  4651.         goto xsendx;
  4652.     }
  4653.     }
  4654. #endif /* CK_XYZ */
  4655. #endif /* CK_RESEND */
  4656.  
  4657.     if (protocol == PROTO_K) {
  4658.     if ((pv[SND_MAI].ival > 0 ||    /* MAIL */
  4659.          pv[SND_PRI].ival > 0 ||    /* PRINT */
  4660.          pv[SND_RES].ival > 0    /* RESEND */
  4661.          ) &&
  4662.         (!atdiso || !atcapr)) {    /* Disposition attribute off? */
  4663.         printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n");
  4664.         x = -9;
  4665.         goto xsendx;
  4666.     }
  4667.     }
  4668.  
  4669. #ifdef CK_XYZ
  4670.     if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) {
  4671.     printf(
  4672. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  4673.            );
  4674.     x = -9;
  4675.     goto xsendx;
  4676.     }
  4677. #endif /* CK_XYZ */
  4678.  
  4679.     if (!confirmed) {            /* CR not typed yet, get more fields */
  4680.     char *m;
  4681.     if (mlist) {            /* MSEND or MMOVE */
  4682.         nfils = 0;            /* We already have the first one */
  4683. #ifndef NOMSEND
  4684.         msfiles[nfils++] = line;    /* Store pointer */
  4685.         lp = line + (int)strlen(line) + 1; /* Point past it */
  4686.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4687.         while (1) {            /* Get more filenames */
  4688.         char *p;
  4689.         if ((x = cmifi("Names of files to send, separated by spaces",
  4690.                    "", &s,&y,xxstring)) < 0) {
  4691.             if (x != -3)
  4692.               goto xsendx;
  4693.             if ((x = cmcfm()) < 0)
  4694.               goto xsendx;
  4695.             break;
  4696.         }
  4697.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  4698.         p = lp;            /* remember pointer, */
  4699.         while ((*lp++ = *s++))    /* and copy it into buffer */
  4700.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  4701.               printf("?MSEND list too long\n");
  4702.               line[0] = NUL;
  4703.               x = -9;
  4704.               goto xsendx;
  4705.           }
  4706.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4707.         if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */
  4708. #ifdef ZFNQFP
  4709.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  4710.         p = tmpbuf;
  4711. #endif /* ZFNQFP */
  4712.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  4713.             strcat(fspec,p);    /* safe */
  4714.             strcat(fspec," ");    /* safe */
  4715.         } else
  4716. #ifdef COMMENT
  4717.           printf("WARNING - \\v(filespec) buffer overflow\n");
  4718. #else
  4719.           debug(F101,"doxsend filespec buffer overflow","",0);
  4720. #endif /* COMMENT */
  4721.         }
  4722. #endif /* NOMSEND */
  4723.     } else {            /* Regular SEND */
  4724.         char *p; int y;
  4725.         nfils = -1;
  4726.         if (pv[SND_MAI].ival > 0)
  4727.           m = (pv[SND_MAI].sval) ?
  4728.         "e-mail address (optional)" :
  4729.           "e-mail address (required)";
  4730.         else if (pv[SND_PRI].ival > 0)
  4731.           m = "printer options (optional)";
  4732.         else if (wild)
  4733.           m =
  4734. "\nOptional as-name template containing replacement variables \
  4735. like \\v(filename)";
  4736.         else
  4737.           m = "Optional name to send it with";
  4738.         if ((x = cmtxt(m,"",&p,NULL)) < 0)
  4739.           goto xsendx;
  4740.         if (!p) p = "";
  4741.         if (*p) {            /* If some text was given... */
  4742.         p = brstrip(p);        /* Replace /AS-NAME: value if any */
  4743.         if ((y = strlen(p)) > 0) {
  4744.                     if (pv[SND_MAI].ival > 0) {
  4745.                         makestr(&pv[SND_MAI].sval, p);
  4746.                     } else {
  4747.             if (pv[SND_ASN].sval) free(pv[SND_ASN].sval);
  4748.             pv[SND_ASN].sval = malloc(y+1);
  4749.             if (pv[SND_ASN].sval) {
  4750.                 strcpy(pv[SND_ASN].sval,p);    /* safe */
  4751.                 pv[SND_ASN].ival = 1;
  4752.             }
  4753.             }
  4754.         }
  4755.         }
  4756.     }
  4757.     }
  4758.     /* Set cmarg2 from as-name, however we got it. */
  4759.  
  4760.     if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) {
  4761.     int x;
  4762.     x = strlen(line);
  4763.     ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1);
  4764.     cmarg2 = line+x+2;
  4765.     debug(F110,"doxsend cmarg2",cmarg2,0);
  4766.     }
  4767.  
  4768. #ifndef NOFRILLS
  4769.     if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) {
  4770.     printf("Sorry, /MAIL and /PRINT are conflicting options\n");
  4771.     x = -9;
  4772.     goto xsendx;
  4773.     }
  4774.     n = 0;                /* /MAIL or /PRINT? */
  4775.     if (pv[SND_MAI].ival > 0)
  4776.       n = SND_MAI;
  4777.     else if (pv[SND_PRI].ival > 0)
  4778.       n = SND_PRI;
  4779.     if (n) {                /* Yes... */
  4780. #ifdef DEBUG
  4781.     char * p;
  4782.     if (n == SND_MAI)
  4783.       p = "/MAIL";
  4784.     else
  4785.       p = "/PRINT";
  4786.     debug(F111,"xsend",p,n);
  4787. #endif /* DEBUG */
  4788. #ifdef CK_XYZ
  4789.     if (protocol != PROTO_K) {
  4790.         printf("Sorry, %s available only with Kermit protocol\n",
  4791.            (n == SND_MAI) ? "/MAIL" : "/PRINT"
  4792.            );
  4793.         x = -9;
  4794.         goto xsendx;
  4795.     }
  4796. #endif /* CK_XYZ */
  4797.     debug(F101,"xsend print/mail wild","",wild);
  4798.     *optbuf = NUL;            /* Wipe out any old options */
  4799.     s = pv[n].sval;            /* mail address or print switch val */
  4800.     if (!s) s = "";
  4801.     debug(F110,"doxsend mail address or printer options",s,0);
  4802.     if (n == SND_MAI && !*s) {
  4803.         printf("?E-mail address required\n");
  4804.         x = -9;
  4805.         goto xsendx;
  4806.     } else if ((int)strlen(s) > 94) { /* Ensure legal size */
  4807.         printf("?%s too long\n",
  4808.            (n == SND_MAI) ?
  4809.            "E-mail address" :
  4810.            "Print option string"
  4811.            );
  4812.         x = -9;
  4813.         goto xsendx;
  4814.     }
  4815.     ckstrncpy(optbuf,s,OPTBUFLEN);    /* OK, copy to option buffer */
  4816.     cmarg = line;            /* File to send */
  4817.     if (n == SND_MAI) {
  4818.         debug(F110,"xsend mailing",cmarg,0);
  4819.         debug(F110,"xsend address:",optbuf,0);
  4820.         rmailf = 1;
  4821.     } else {
  4822.         debug(F110,"xsend printing",cmarg,0);
  4823.         debug(F110,"xsend options",optbuf,0);
  4824.         rprintf = 1;
  4825.     }
  4826.     }
  4827. #endif /* NOFRILLS */
  4828.  
  4829. #ifdef CALIBRATE
  4830.     if (pv[SND_CAL].ival > 0) {        /* Handle /CALIBRATE */
  4831.     if (confirmed) {
  4832.         calibrate = pv[SND_CAL].ival * 1024L;
  4833.         sndsrc = -9;
  4834.         nfils = 1;
  4835.         wild = 0;
  4836. #ifndef NOMSEND
  4837.         addlist = 0;
  4838. #endif /* NOMSEND */
  4839.         ckstrncpy(line,"CALIBRATION",LINBUFSIZ);
  4840.         s = cmarg = line;
  4841.         if (!cmarg2) cmarg2 = "";
  4842.         debug(F110,"doxsend cmarg2 calibrate",cmarg2,0);
  4843.     } else if (line[0]) {
  4844.         calibrate = 0L;
  4845.         pv[SND_CAL].ival = 0L;
  4846.     }
  4847.     }
  4848. #endif /* CALIBRATE */
  4849.  
  4850.     if (pv[SND_FIL].ival > 0) {
  4851.     if (confirmed && !calibrate) {
  4852.         if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) {
  4853.         debug(F110,"xsend can't open",pv[SND_FIL].sval,0);
  4854.         printf("?Failure to open %s\n",filefile);
  4855.         x = -9;
  4856.         goto xsendx;
  4857.         }
  4858.         makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */
  4859.         debug(F110,"xsend opened",filefile,0);
  4860.         wild = 1;
  4861.     }
  4862.     }
  4863.  
  4864.     /* SEND alone... */
  4865.  
  4866. #ifndef NOSPL
  4867.     if (confirmed && pv[SND_ARR].ival > 0) {
  4868.     if (!*cmarg2) {
  4869.         sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE);
  4870.         cmarg2 = sndxnam;
  4871.     }
  4872.     cmarg = "";
  4873.     goto sendend;
  4874.     }
  4875. #endif /* NOSPL */
  4876.  
  4877.     if (confirmed && !line[0] && !filefile && !calibrate) {
  4878. #ifndef NOMSEND
  4879.     if (filehead) {            /* OK if we have a SEND-LIST */
  4880.         nfils = filesinlist;
  4881.         sndsrc = nfils;        /* Like MSEND */
  4882.         addlist = 1;        /* But using a different list... */
  4883.         filenext = filehead;
  4884.         goto sendend;
  4885.     }
  4886. #endif /* NOMSEND */
  4887.     printf("?Filename required but not given\n");
  4888.     x = -9;
  4889.     goto xsendx;
  4890.     }
  4891.  
  4892.     /* Not send-list or array */
  4893.  
  4894. #ifndef NOMSEND
  4895.     addlist = 0;            /* Don't use SEND-LIST. */
  4896.     filenext = NULL;
  4897. #endif /* NOMSEND */
  4898.  
  4899.     if (mlist) {            /* MSEND or MMOVE */
  4900. #ifndef NOMSEND
  4901.     cmlist = msfiles;        /* List of files to send */
  4902.     sndsrc = nfils;
  4903.     cmarg2 = "";
  4904.     sendstart = 0L;
  4905. #endif /* NOMSEND */
  4906. #ifdef PIPESEND
  4907.     pipesend = 0;
  4908. #endif /* PIPESEND */
  4909.     } else if (filefile) {        /* File contains list of filenames */
  4910.     s = "";
  4911.     cmarg = "";
  4912.     cmarg2 = "";
  4913.     line[0] = NUL;
  4914.     nfils = 1;
  4915.     sndsrc = 1;
  4916.  
  4917.     } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) {
  4918.  
  4919.     nfils = sndsrc = -1;    /* Not MSEND, MMOVE, /LIST, or /ARRAY */
  4920.     if (                /* or /COMMAND */
  4921.  
  4922. #ifndef NOFRILLS
  4923.         !rmailf && !rprintf        /* Not MAIL or PRINT */
  4924. #else
  4925.         1
  4926. #endif /* NOFRILLS */
  4927.         ) {
  4928.         int y = 1;
  4929.         if (!wild)
  4930.           y = zchki(s);
  4931.         if (y < 0) {
  4932.         printf("?Read access denied - \"%s\"\n", s);
  4933.         x = -9;
  4934.         goto xsendx;
  4935.         }
  4936.         if (s != line)        /* We might already have done this. */
  4937.           ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */
  4938.         else
  4939.           debug(F110,"doxsend line=s",line,0);
  4940.         cmarg = line;        /* File to send */
  4941.     }
  4942.     zfnqfp(cmarg,fspeclen,fspec);
  4943.     }
  4944.     if (!mlist) {            /* For all but MSEND... */
  4945. #ifdef PIPESEND
  4946.     if (pv[SND_CMD].ival > 0)    /* /COMMAND sets pipesend flag */
  4947.       pipesend = 1;
  4948.     debug(F101,"xsend /COMMAND pipesend","",pipesend);
  4949.     if (pipesend && filefile) {
  4950.         printf("?Invalid switch combination\n");
  4951.         x = -9;
  4952.         goto xsendx;
  4953.     }
  4954. #endif /* PIPESEND */
  4955.  
  4956. #ifndef NOSPL
  4957.     /* If as-name given and filespec is wild, as-name must contain variables */
  4958.     debug(F111,"doxsend cmarg2 wild",cmarg2,wild);
  4959.     if (wild && *cmarg2) {
  4960.         char * s = tmpbuf;
  4961.         x = TMPBUFSIZ;
  4962.         zzstring(cmarg2,&s,&x);
  4963.         if (!strcmp(tmpbuf,cmarg2)) {
  4964.         printf(
  4965.     "?As-name for file group must contain variables such as \\v(filename)\n"
  4966.                );
  4967.         x = -9;
  4968.         goto xsendx;
  4969.         }
  4970.     }
  4971. #endif /* NOSPL */
  4972.  
  4973.     /* Strip braces from as-name */
  4974.     debug(F110,"xsend cmarg2 before stripping",cmarg2,0);
  4975.     cmarg2 = brstrip(cmarg2);
  4976.     debug(F110,"xsend filename",cmarg,0);
  4977.     debug(F110,"xsend as-name",cmarg2,0);
  4978.  
  4979.     /* Copy as-name to a safe place */
  4980.  
  4981.     if (asnbuf) {
  4982.         free(asnbuf);
  4983.         asnbuf = NULL;
  4984.     }
  4985.     if ((y = strlen(cmarg2)) > 0) {
  4986.         asnbuf = (char *) malloc(y + 1);
  4987.         if (asnbuf) {
  4988.         strcpy(asnbuf,cmarg2);    /* safe */
  4989.         cmarg2 = asnbuf;
  4990.         } else cmarg2 = "";
  4991.     }
  4992.  
  4993. #ifdef CK_RESEND
  4994.     debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival);
  4995.     if (pv[SND_STA].ival > -1) {    /* /START position */
  4996.         if (wild) {
  4997.         printf("?/STARTING-AT may not be used with multiple files.\n");
  4998.         x = -9;
  4999.         goto xsendx;
  5000.         } else
  5001.           sendstart = pv[SND_STA].ival;
  5002.     } else
  5003.       sendstart = 0L;
  5004.     debug(F101,"xsend /STARTING","",sendstart);
  5005. #endif /* CK_RESEND */
  5006.     }
  5007.  
  5008. sendend:                /* Common successful exit */
  5009.     moving = 0;
  5010.     if (pv[SND_SHH].ival > 0) {        /* SEND /QUIET... */
  5011.     g_displa = fdispla;
  5012.     fdispla = 0;
  5013.     debug(F101,"xsend display","",fdispla);
  5014.     }
  5015.  
  5016. #ifndef NOSPL                /* SEND /ARRAY... */
  5017.     if (pv[SND_ARR].ival > 0) {
  5018.     if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */
  5019.     if (range[0] == -1)        /* If low end of range not specified */
  5020.       range[0] = 1;            /* default to 1 */
  5021.     if (range[1] == -1)        /* If high not specified */
  5022.       range[1] = a_dim[arrayx];    /* default to size of array */
  5023.     if ((range[0] < 0) ||        /* Check range */
  5024.         (range[0] > a_dim[arrayx]) ||
  5025.         (range[1] < range[0]) ||
  5026.         (range[1] > a_dim[arrayx])) {
  5027.         printf("?Bad array range - [%d:%d]\n",range[0],range[1]);
  5028.         x = -9;
  5029.         goto xsendx;
  5030.     }
  5031.     sndarray = ap;            /* Array pointer */
  5032.     sndxin = arrayx;        /* Array index */
  5033.     sndxlo = range[0];        /* Array range */
  5034.     sndxhi = range[1];
  5035.     sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  5036.  
  5037. #ifdef COMMENT
  5038.     printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */
  5039.            (sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  5040.     printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi);
  5041.     printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2);
  5042.     while ((x = agnbyte()) > -1) {
  5043.         putchar((char)x);
  5044.     }
  5045.     return(1);
  5046. #endif /* COMMENT */
  5047.     }
  5048. #endif /* NOSPL */
  5049.  
  5050.     if (pv[SND_ARR].ival < 1) {        /* File selection & disposition... */
  5051.  
  5052.     if (pv[SND_DEL].ival > 0)    /* /DELETE was specified */
  5053.       moving = 1;
  5054.     debug(F101,"xsend /DELETE","",moving);
  5055.     if (pv[SND_AFT].ival > 0)    /* Copy SEND criteria */
  5056.       ckstrncpy(sndafter,pv[SND_AFT].sval,19);
  5057.     if (pv[SND_BEF].ival > 0)
  5058.       ckstrncpy(sndbefore,pv[SND_BEF].sval,19);
  5059.     if (pv[SND_NAF].ival > 0)
  5060.       ckstrncpy(sndnafter,pv[SND_NAF].sval,19);
  5061.     if (pv[SND_NBE].ival > 0)
  5062.       ckstrncpy(sndnbefore,pv[SND_NBE].sval,19);
  5063.     if (pv[SND_EXC].ival > 0)
  5064.       makelist(pv[SND_EXC].sval,sndexcept,NSNDEXCEPT);
  5065.     if (pv[SND_SMA].ival > -1)
  5066.       sndsmaller = pv[SND_SMA].ival;
  5067.     if (pv[SND_LAR].ival > -1)
  5068.       sndlarger = pv[SND_LAR].ival;
  5069.     if (pv[SND_NAM].ival > -1) {
  5070.         g_fncnv = fncnv;        /* Save global value */
  5071.         fncnv = pv[SND_NAM].ival;
  5072.         debug(F101,"xsend fncnv","",fncnv);
  5073.     }
  5074.     if (pv[SND_PTH].ival > -1) {
  5075.         g_spath = fnspath;        /* Save global values */
  5076.         fnspath = pv[SND_PTH].ival;
  5077. #ifndef NZLTOR
  5078.         if (fnspath != PATH_OFF) {
  5079.         g_fncnv = fncnv;    /* Bad bad... */
  5080.         fncnv = XYFN_C;
  5081.         }
  5082. #endif /* NZLTOR */
  5083.         debug(F101,"xsend fnspath","",fnspath);
  5084.         debug(F101,"xsend fncnv","",fncnv);
  5085.     }
  5086.     }
  5087.  
  5088. #ifdef PIPESEND
  5089.     if (pv[SND_FLT].ival > 0) {
  5090.     makestr(&sndfilter,pv[SND_FLT].sval);
  5091.     debug(F110,"xsend /FILTER", sndfilter, 0);
  5092.     }
  5093. #endif /* PIPESEND */
  5094.  
  5095. #ifdef CK_APC
  5096. /* MOVE not allowed in APCs */
  5097.     if (moving &&
  5098.     (apcactive == APC_LOCAL || apcactive == APC_REMOTE)
  5099.     && !(apcstatus & APC_UNCH))
  5100.       return(success = 0);
  5101. #endif /* CK_APC */
  5102. #ifdef IKS_OPTION
  5103.     if (
  5104. #ifdef CK_XYZ
  5105.         protocol == PROTO_K &&
  5106. #endif /* CK_XYZ */
  5107.         !iks_wait(KERMIT_REQ_START,1)) {
  5108.         printf("?A Kermit Server is not available to process this command.\n");
  5109.         printf("?Start a RECEIVE command to complement this command.\n");
  5110.     }
  5111. #endif /* IKS_OPTION */
  5112.  
  5113. #ifdef IKSD
  5114. #ifdef CK_LOGIN
  5115.     if (moving && inserver && isguest) {
  5116.         printf("?File deletion not allowed for guests.\n");
  5117.     return(-9);
  5118.     }
  5119. #endif /* CK_LOGIN */
  5120. #endif /* IKSD */
  5121.  
  5122.     sstate = 's';            /* Set start state to SEND */
  5123.     sndcmd = 1;
  5124. #ifdef CK_RESEND
  5125.     if (pv[SND_RES].ival > 0)        /* Send sendmode appropriately */
  5126.       sendmode = SM_RESEND;
  5127.     else if (pv[SND_STA].ival > 0)
  5128.       sendmode = SM_PSEND;
  5129.     else
  5130. #endif /* CK_RESEND */
  5131.     if (mlist)
  5132.       sendmode = SM_MSEND;
  5133.     else
  5134.       sendmode = SM_SEND;
  5135. #ifdef MAC
  5136.     what = W_SEND;
  5137.     scrcreate();
  5138. #endif /* MAC */
  5139.     if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */
  5140.     displa = 1;            /* turn on file transfer display */
  5141.     }
  5142.     x = 0;
  5143.  
  5144.   xsendx:                /* Common exit, including failure */
  5145.     debug(F101,"doxsend sndsrc","",sndsrc);
  5146.     for (i = 0; i <= SND_MAX; i++) {    /* Free malloc'd memory */
  5147.     if (pv[i].sval)
  5148.       free(pv[i].sval);
  5149.     }
  5150.     return(x);
  5151. }
  5152. #endif /* NOXFER */
  5153.  
  5154. #ifndef NOLOCAL
  5155. /*  D O X C O N N  --  CONNECT command parsing with switches */
  5156.  
  5157. #ifdef XLIMITS
  5158. #define XLIMORTRIGGER
  5159. #else
  5160. #ifdef CK_TRIGGER
  5161. #define XLIMORTRIGGER
  5162. #endif /* CK_TRIGGER */
  5163. #endif /*  XLIMITS */
  5164.  
  5165. #ifdef CKTIDLE
  5166. int tt_idlelimit = 0;            /* Terminal idle limit */
  5167. int tt_idleact = IDLE_RET;        /* Terminal idle action */
  5168. #endif /* CKTIDLE */
  5169.  
  5170. #ifdef OS2                /* K95 only: */
  5171. extern int
  5172.   tt_idlesnd_tmo;            /*   Idle interval */
  5173. int tt_timelimit = 0;            /*   Time limit, 0 = none */
  5174. extern char *                /* Parse results - strings: */
  5175.   tt_idlesnd_str;            /*   Idle string */
  5176. #endif /* OS2 */
  5177.  
  5178. #ifdef CK_TRIGGER
  5179. extern char *tt_trigger[];
  5180. extern CHAR *tt_trmatch[];
  5181. extern char *triggerval;
  5182. static char *g_tt_trigger[TRIGGERS];
  5183. #endif /* CK_TRIGGER */
  5184.  
  5185. #ifdef OS2
  5186. static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */
  5187. static int g_tt_idlelimit, g_tt_saved = 0;
  5188. static char * g_tt_idlesnd_str;        /* global settings */
  5189. #endif /* OS2 */
  5190.  
  5191. static struct stringint {        /* Temporary array for switch values */
  5192.     char * sval;
  5193.     int ival;
  5194. } pv[CONN_MAX+1];
  5195.  
  5196. VOID
  5197. resconn() {
  5198.     int i;
  5199.  
  5200. #ifdef OS2
  5201.     if ( g_tt_saved ) {
  5202.         tt_idlelimit   = g_tt_idlelimit;
  5203.         tt_idlesnd_tmo = g_tt_idlesnd_tmo;
  5204.         tt_timelimit   = g_tt_timelimit;
  5205.         tt_idlesnd_str = g_tt_idlesnd_str;
  5206.         g_tt_saved = 0;
  5207.     }
  5208. #endif /* OS2 */
  5209.  
  5210. #ifdef CK_TRIGGER
  5211.     for (i = 0; i < TRIGGERS; i++)
  5212.       tt_trigger[i] = g_tt_trigger[i];
  5213. #endif /* CK_TRIGGER */
  5214.  
  5215.     for (i = 0; i <= CONN_MAX; i++) {    /* Free malloc'd memory */
  5216.     if (pv[i].sval)
  5217.       free(pv[i].sval);
  5218.         pv[i].sval = NULL;
  5219.     }
  5220. }
  5221.  
  5222. int
  5223. doxconn(cx) int cx; {
  5224.     int c, i, n;            /* Workers */
  5225.     int x, y;
  5226.     int getval = 0;            /* Whether to get switch value */
  5227.     int async = 0;                      /* Make an async connect */
  5228.     struct FDB sw, cm;            /* FDBs for each parse function */
  5229.     extern FILE * tfile[];
  5230.     extern char * macp[];
  5231.  
  5232. #ifdef OS2
  5233.     g_tt_idlesnd_tmo = tt_idlesnd_tmo;    /* Save global settings */
  5234.     g_tt_timelimit   = tt_timelimit;
  5235.     g_tt_idlelimit   = tt_idlelimit;
  5236.     g_tt_idlesnd_str = tt_idlesnd_str;
  5237.     g_tt_saved = 1;
  5238. #endif /* OS2 */
  5239.  
  5240. #ifdef CK_TRIGGER
  5241.     if (!tt_trigger[0]) {        /* First initialization */
  5242.     for (i = 1; i < TRIGGERS; i++)
  5243.       tt_trigger[i] = NULL;
  5244.     }
  5245.     for (i = 0; i < TRIGGERS; i++)
  5246.       g_tt_trigger[i] = tt_trigger[i];
  5247.     if (triggerval) {
  5248.     free(triggerval);
  5249.     triggerval = NULL;
  5250.     }
  5251. #endif /* CK_TRIGGER */
  5252.  
  5253.     for (i = 0; i <= CONN_MAX; i++) {    /* Initialize switch values */
  5254.     pv[i].sval = NULL;        /* to null pointers */
  5255.     pv[i].ival = -1;        /* and -1 int values */
  5256.     }
  5257.     if (cx == XXCQ)            /* CQ == CONNECT /QUIETLY */
  5258.       pv[CONN_NV].ival = 1;
  5259.  
  5260.     /* Set up chained parse functions... */
  5261.  
  5262.     cmfdbi(&sw,                /* First FDB - command switches */
  5263.        _CMKEY,            /* fcode */
  5264.        "Switch",            /* hlpmsg */
  5265.        "",                /* default */
  5266.        "",                /* addtl string data */
  5267.        nconntab,            /* addtl numeric data 1: tbl size */
  5268.        4,                /* addtl numeric data 2: 4 = cmswi */
  5269.        xxstring,            /* Processing function */
  5270.        conntab,            /* Keyword table */
  5271.        &cm                /* Pointer to next FDB */
  5272.        );
  5273.     cmfdbi(&cm,                /* 2nd FDB - Confirmation */
  5274.        _CMCFM,            /* fcode */
  5275.        "",                /* hlpmsg */
  5276.        "",                /* default */
  5277.        "",                /* addtl string data */
  5278.        0,                /* addtl numeric data 1 */
  5279.        0,                /* addtl numeric data 2 */
  5280.        NULL,
  5281.        NULL,
  5282.        NULL
  5283.        );
  5284.  
  5285.     while (1) {                /* Parse 0 or more switches */
  5286.     x = cmfdb(&sw);            /* Parse switch or confirmation */
  5287.     debug(F101,"doxconn cmfdb","",x);
  5288.     if (x < 0) {            /* Error */
  5289.         if (x == -9 || x == -2)
  5290.           printf("?No switches match - \"%s\"\n",atmbuf);
  5291.         goto xconnx;        /* or reparse needed */
  5292.     }
  5293.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  5294.       break;
  5295.     c = cmgbrk();            /* Get break character */
  5296.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  5297.     if (getval && !(cmresult.kflags & CM_ARG)) {
  5298.         printf("?This switch does not take arguments\n");
  5299.         x = -9;
  5300.         goto xconnx;
  5301.     }
  5302.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  5303.         printf("?This switch requires an argument\n");
  5304.         return(-9);
  5305.     }
  5306.     n = cmresult.nresult;        /* Numeric result = switch value */
  5307.     debug(F101,"doxconn switch","",n);
  5308.  
  5309.     switch (n) {            /* Process the switch */
  5310. #ifdef OS2
  5311.       case CONN_AS:            /* Asynchronous */
  5312.             pv[CONN_AS].ival = 1;
  5313.             pv[CONN_SY].ival = 0;
  5314.             break;
  5315.           case CONN_SY:                 /* Synchronous */
  5316.             pv[CONN_SY].ival = 1;
  5317.             pv[CONN_AS].ival = 0;
  5318.             break;
  5319. #endif /* OS2 */
  5320.       case CONN_NV:            /* Non-verbal */
  5321.         pv[n].ival = 1;
  5322.         break;
  5323. #ifdef XLIMITS
  5324.       case CONN_II:            /* Idle-interval */
  5325.       case CONN_IL:            /* Idle-limit */
  5326.       case CONN_TL:            /* Time-limit */
  5327.         if (!getval) break;
  5328.         if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
  5329.           goto xconnx;
  5330.         pv[n].ival = y;
  5331.         break;
  5332.       case CONN_IS:            /* Idle-string */
  5333. #endif /* XLIMITS */
  5334. #ifdef CK_TRIGGER
  5335.       case CONN_TS:            /* Trigger-string */
  5336. #endif /* CK_TRIGGER */
  5337. #ifdef XLIMORTRIGGER
  5338.         if (!getval) break;
  5339.         if ((x = cmfld("String (enclose in braces if it contains spaces)",
  5340.                "",&s,xxstring)) < 0) {
  5341.         if (x == -3) {
  5342.             printf("?String required\n");
  5343.             x = -9;
  5344.         }
  5345.         goto xconnx;
  5346.         }
  5347.         if (n != CONN_TS)
  5348.           s = brstrip(s);
  5349.         if ((y = strlen(s)) > 0) {
  5350.         if (pv[n].sval) free(pv[n].sval);
  5351.         pv[n].sval = malloc(y+1);
  5352.         if (pv[n].sval) {
  5353.             strcpy(pv[n].sval,s); /* safe */
  5354.             pv[n].ival = 1;
  5355.         }
  5356.         }
  5357.         break;
  5358. #endif /* XLIMORTRIGGER */
  5359.       default:
  5360.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  5361.         x = -9;
  5362.         goto xconnx;
  5363.     }
  5364.     }
  5365.     debug(F101,"doxconn cmresult.fcode","",cmresult.fcode);
  5366.     if (cmresult.fcode != _CMCFM) {
  5367.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  5368.     x = -9;
  5369.     goto xconnx;
  5370.     }
  5371.  
  5372.     /* Command was confirmed so we can pre-pop command level. */
  5373.     /* This is so CONNECT module won't think we're executing a script */
  5374.     /* if CONNECT was the final command in the script. */
  5375.  
  5376.     if (cmdlvl > 0)
  5377.       prepop();
  5378.  
  5379. #ifdef OS2                /* Make results available globally */
  5380.     if (pv[CONN_IL].ival > -1)        /* Idle limit */
  5381.       tt_idlelimit = pv[CONN_IL].ival;
  5382.     if (pv[CONN_II].ival > -1)        /* Idle limit */
  5383.       tt_idlesnd_tmo = pv[CONN_II].ival;
  5384.     if (pv[CONN_IS].sval)        /* Idle string */
  5385.       if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1))
  5386.     strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */
  5387.     if (pv[CONN_TL].ival > -1)        /* Session limit */
  5388.       tt_timelimit = pv[CONN_TL].ival;
  5389.     async = (pv[CONN_AS].ival > 0 ||
  5390.              pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0;
  5391. #endif /* OS2 */
  5392.  
  5393. #ifdef CK_TRIGGER
  5394.     if (pv[CONN_TS].sval)        /* Trigger strings */
  5395.       makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS);
  5396.     for (i = 0; i < TRIGGERS; i++)    /* Trigger match pointers */
  5397.       tt_trmatch[i] = NULL;
  5398.     if (triggerval) {            /* Reset trigger value */
  5399.     free(triggerval);
  5400.     triggerval = NULL;
  5401.     }
  5402. #endif /* CK_TRIGGER */
  5403.  
  5404.     x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async);
  5405.     {
  5406.     int xx;
  5407.     debug(F101,"doxconn doconect returns","",x);
  5408.     if ((xx = ttchk()) < 0) dologend();
  5409.     debug(F101,"doxconn ttchk returns","",xx);
  5410.     }
  5411.  
  5412. #ifdef CK_TRIGGER
  5413.     debug(F111,"doxconn doconect triggerval",triggerval,x);
  5414. #endif /* CK_TRIGGER */
  5415.  
  5416.   xconnx:
  5417.     /* Back from CONNECT -- Restore global settings */
  5418.  
  5419.     if (!async)
  5420.       resconn();
  5421.  
  5422.     success = (x > 0) ? 1 : 0;
  5423.     return(x);
  5424. }
  5425. #endif /* NOLOCAL */
  5426.  
  5427. #ifdef ADDCMD
  5428. /* cx == XXADD or XXREMV */
  5429. /* fc == ADD_BIN or ADD_TXT */
  5430. static int
  5431. doadd(cx,fc) int cx, fc; {
  5432. #ifdef PATTERNS
  5433.     char * tmp[FTPATTERNS];
  5434.     char **p = NULL;
  5435.     int i, j, k, n = 0, x = 0, last;
  5436.  
  5437. #endif /* PATTERNS */
  5438.     if (cx != XXADD && cx != XXREMV) {
  5439.     printf("?Unexpected function code: %d\n",cx);
  5440.     return(-9);
  5441.     }
  5442. #ifdef PATTERNS
  5443.     while (n < FTPATTERNS) {        /* Collect new patterns */
  5444.     tmp[n] = NULL;
  5445.     if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
  5446.       break;
  5447.     ckstrncpy(line,s,LINBUFSIZ);
  5448.     s = brstrip(line);
  5449.     makestr(&(tmp[n++]),s);
  5450.     }
  5451.     if (x == -3)
  5452.       x = cmcfm();
  5453.     if (x < 0)
  5454.       goto xdoadd;
  5455.     p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */
  5456.     last = 0;
  5457.     for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */
  5458.     if (!p[i]) {
  5459.         last = i;
  5460.         break;
  5461.     }
  5462.     }
  5463.     if (cx == XXADD) {            /* Adding */
  5464.     if (last + n > FTPATTERNS) {    /* Check if too many */
  5465.         printf("?Too many patterns - %d is the maximum\n", FTPATTERNS);
  5466.         goto xdoadd;
  5467.     }
  5468.         for (i = 0; i < n; i++) {        /* Copy in the new ones. */
  5469.           for (j = 0, x = 0; x == 0 && j < last ; j++ )
  5470.             x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5471.           if (x == 0)
  5472.             makestr(&(p[last++]),tmp[i]);
  5473.         }
  5474.         makestr(&(p[last]),NULL);    /* Null-terminate the list */
  5475.         x = 1;
  5476.         goto xdoadd;                    /* Done */
  5477.     } else if (cx == XXREMV) {        /* Remove something(s) */
  5478.     int j, k;
  5479.     if (last == 0)                    /* List is empty */
  5480.       goto xdoadd;                    /* Nothing to remove */
  5481.     for (i = 0; i < n; i++) {            /* i = Patterns they typed */
  5482.         for (j = 0; j < last; j++) {        /* j = Patterns in list */
  5483.         /* Change this to ckstrcmp()... */
  5484.         if (filecase)
  5485.                   x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5486.         else
  5487.           x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */
  5488.         if (x) {                    /* This one matches */
  5489.             makestr(&(p[j]),NULL);      /* Free it */
  5490.             for (k = j; k < last; k++)  /* Move the rest up */
  5491.               p[k] = p[k+1];
  5492.             p[k] = NULL;            /* Erase last one */
  5493.             if (!p[k])
  5494.               break;
  5495.         }
  5496.         }
  5497.     }
  5498.     }
  5499.   xdoadd:                /* Common exit */
  5500.     for (i = 0; i < n; i++)
  5501.       if (tmp[i])
  5502.     free(tmp[i]);
  5503.     return(x);
  5504. #endif /* PATTERNS */
  5505. }
  5506.  
  5507. /* ADD SEND-LIST */
  5508.  
  5509. static int
  5510. addsend(cx) int cx; {
  5511. #ifndef NOMSEND
  5512.     extern struct keytab fttab[];
  5513.     extern int nfttyp;
  5514.     struct filelist * flp;
  5515.     char * fmode = "";
  5516.     int xmode = 0;
  5517.     int xbinary = 0;
  5518. #endif /* NOMSEND */
  5519.  
  5520. #ifdef NOMSEND
  5521.     printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n");
  5522.     return(-9);
  5523. #endif /* NOMSEND */
  5524.     if (cx == XXREMV) {
  5525.     printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n");
  5526.     return(-9);
  5527.     }
  5528. #ifndef NOMSEND
  5529. #ifndef XYZ_INTERNAL
  5530.     if (protocol != PROTO_K) {
  5531.        printf("?Sorry, ADD SEND-LIST does not work with external protocols\n");
  5532.        return(-9);
  5533.     }
  5534. #endif /* XYZ_INTERNAL */
  5535.  
  5536.     x = cmifi("File specification to add","", &s,&y,xxstring);
  5537.     if (x < 0) {
  5538.     if (x == -3) {
  5539.         printf("?A file specification is required\n");
  5540.         return(-9);
  5541.     } else
  5542.       return(x);
  5543.     }
  5544.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5545.     s = tmpbuf;
  5546.     if (filesinlist == 0)        /* Take care of \v(filespec) */
  5547.       fspec[0] = NUL;
  5548.     zfnqfp(s,LINBUFSIZ,line);
  5549.     s = line;
  5550.     if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) {
  5551.     strcat(fspec,s);        /* safe */
  5552.     strcat(fspec," ");        /* safe */
  5553.     } else
  5554.       printf("WARNING - \\v(filespec) buffer overflow\n");
  5555.  
  5556.  
  5557.     xbinary = binary;
  5558.     if ((patterns || filepeek)        /* FILE PATTERNS or SCAN is ON */
  5559. #ifdef CK_LABELED
  5560.     && binary != XYFT_L        /* And not if FILE TYPE LABELED */
  5561. #endif /* CK_LABELED */
  5562. #ifdef VMS
  5563.     && binary != XYFT_I        /* or FILE TYPE IMAGE */
  5564. #endif /* VMS */
  5565.     ) {
  5566.     int k, x;
  5567.     x = -1;
  5568.     k = scanfile(line,&x,nscanfile);
  5569.     if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  5570.     }
  5571.     fmode = gfmode(xbinary,0);
  5572.     if ((x = cmkey(fttab,nfttyp,
  5573.            "type of file transfer", fmode, xxstring)) < 0)
  5574.       return(x);
  5575.     xmode = x;
  5576.  
  5577.     cmarg2 = "";
  5578.     if ((x = cmfld(y ?
  5579.   "\nAs-name template containing replacement variables such as \\v(filename)" :
  5580.   "Name to send it with", "",&s,NULL)) < 0)
  5581.       if (x != -3)
  5582.     return(x);
  5583. #ifndef NOSPL
  5584.     if (y && *s) {
  5585.     char * p = tmpbuf;
  5586.     x = TMPBUFSIZ;
  5587.     zzstring(s,&p,&x);
  5588.     if (!strcmp(tmpbuf,s)) {
  5589.         printf(
  5590.   "?As-name for file group must contain variables such as \\v(filename)\n"
  5591.            );
  5592.         return(-9);
  5593.     }
  5594.     }
  5595. #endif /* NOSPL */
  5596.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5597.     cmarg2 = tmpbuf;
  5598.  
  5599.     if ((x = cmcfm()) < 0)
  5600.       return(x);
  5601.     flp = (struct filelist *) malloc(sizeof(struct filelist));
  5602.     if (flp) {
  5603.     if (filetail)
  5604.       filetail->fl_next = flp;
  5605.     filetail = flp;
  5606.     if (!filehead)
  5607.       filehead = flp;
  5608.     x = (int) strlen(line);    /* Length of filename */
  5609.     s = (char *) malloc(x + 1);
  5610.     if (s) {
  5611.         strcpy(s,line);        /* safe */
  5612.         flp->fl_name = s;
  5613.         flp->fl_mode = xmode;
  5614.         x = (int) strlen(cmarg2);    /* Length of as-name */
  5615.         if (x < 1) {
  5616.         flp->fl_alias = NULL;
  5617.         } else {
  5618.         s = (char *) malloc(x + 1);
  5619.         if (s) {
  5620.             strcpy(s,cmarg2);    /* safe */
  5621.             flp->fl_alias = s;
  5622.         } else {
  5623.             printf("Sorry, can't allocate space for as-name");
  5624.             return(-9);
  5625.         }
  5626.         }
  5627.         flp->fl_next = NULL;
  5628.         filesinlist++;        /* Count this node */
  5629.         return(success = 1);    /* Finished adding this node */
  5630.     } else {
  5631.         printf("Sorry, can't allocate space for name");
  5632.         return(-9);
  5633.     }
  5634.     } else {
  5635.     printf("Sorry, can't allocate file list node");
  5636.     return(-9);
  5637.     }
  5638. #endif /* NOMSEND */
  5639. }
  5640. #endif /* ADDCMD */
  5641.  
  5642. #ifndef NOHTTP                /* HTTP ops... */
  5643. #ifdef TCPSOCKET
  5644. #define HTTP_GET 0            /* GET */
  5645. #define HTTP_PUT 1            /* PUT */
  5646. #define HTTP_POS 2            /* POST */
  5647. #define HTTP_IDX 3            /* INDEX */
  5648. #define HTTP_HED 4                      /* HEAD */
  5649. #define HTTP_DEL 5                      /* DELETE */
  5650. #define HTTP_CON 6                      /* CONNECT */
  5651. #define HTTP_OPN 7                      /* OPEN */
  5652. #define HTTP_CLS 8                      /* CLOSE */
  5653.  
  5654. static struct keytab httptab[] = {
  5655.     { "close",   HTTP_CLS, 0 },
  5656.     { "connect", HTTP_CON, 0 },
  5657.     { "delete",  HTTP_DEL, 0 },
  5658.     { "get",     HTTP_GET, 0 },
  5659.     { "head",    HTTP_HED, 0 },
  5660.     { "index",   HTTP_IDX, 0 },
  5661.     { "open",    HTTP_OPN, 0 },
  5662.     { "put",     HTTP_PUT, 0 },
  5663.     { "post",    HTTP_POS, 0 }
  5664. };
  5665. static int nhttptab = sizeof(httptab)/sizeof(struct keytab);
  5666.  
  5667. /* HTTP switches */
  5668. #define HT_SW_AG 0            /* /AGENT */
  5669. #define HT_SW_HD 1            /* /HEADER */
  5670. #define HT_SW_US 2            /* /USER */
  5671. #define HT_SW_PW 3            /* /PASSWORD */
  5672. #define HT_SW_AR 4                      /* /ARRAY */
  5673. #define HT_SW_TP 5                      /* /TOSCREEN */
  5674.  
  5675. static struct keytab httpswtab[] = {
  5676.     { "/agent",    HT_SW_AG, CM_ARG },
  5677. #ifndef NOSPL
  5678.     { "/array",    HT_SW_AR, CM_ARG },
  5679. #endif /* NOSPL */
  5680.     { "/header",   HT_SW_HD, CM_ARG },
  5681.     { "/password", HT_SW_PW, CM_ARG },
  5682.     { "/toscreen", HT_SW_TP, 0 },
  5683.     { "/user",     HT_SW_US, CM_ARG },
  5684.     { "", 0, 0 }
  5685. };
  5686. static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1;
  5687.  
  5688. /* HTTP PUT/POST switches */
  5689. #define HT_PP_MT 0            /* /MIME-TYPE */
  5690.  
  5691. static struct keytab httpptab[] = {
  5692.     { "/mime-type", HT_PP_MT, CM_ARG },
  5693.     { "", 0, 0 }
  5694. };
  5695. static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1;
  5696.  
  5697. #define HTTP_MAXHDR 8
  5698.  
  5699. static int
  5700. xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type)
  5701.     int action;
  5702.     char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array;
  5703.     int type;
  5704. /* xdohttp */ {
  5705.     int i, rc = 0;
  5706.     char * hdrlist[HTTP_MAXHDR];
  5707.     char rfile[CKMAXPATH+1];
  5708.     extern int httpfd;
  5709.  
  5710.     /* Check for a valid state to execute the command */
  5711.     if (inserver) {
  5712.         printf("?The HTTP command may not be used from the IKS\r\n");
  5713.     } else if (httpfd == -1) {
  5714.         if (http_reopen() < 0)
  5715.       printf("?No connection\n");
  5716.         else
  5717.       rc = 1;
  5718.     } else {
  5719.     rc = 1;
  5720.     }
  5721.  
  5722.     /* If the command is not valid, exit with failure */
  5723.     if (rc == 0)
  5724.         return(success = 0);
  5725.  
  5726.     if (action != HTTP_CON && rf[0] != '/') {
  5727.         rfile[0] = '/';
  5728.         ckstrncpy(&rfile[1],rf,CKMAXPATH);
  5729.     } else {
  5730.         ckstrncpy(rfile,rf,CKMAXPATH);
  5731.     }
  5732.     for (i = 0; i < HTTP_MAXHDR; i++)    /* Initialize header list */
  5733.       hdrlist[i] = NULL;
  5734.     makelist(hdr,hdrlist,HTTP_MAXHDR);    /* Make header list */
  5735.  
  5736. #ifdef BETADEBUG
  5737.     for (i = 0; i < nhttptab; i++)    /* Find action keyword */
  5738.       if (httptab[i].kwval == action)
  5739.     break;
  5740.     if (i == nhttptab) {        /* Shouldn't happen... */
  5741.     printf("?Invalid action - %d\n",action);
  5742.     return(0);            /* Failure */
  5743.     }
  5744.  
  5745.     printf("HTTP action:  %s\n",httptab[i].kwd);
  5746.     printf(" Agent:       %s\n",agent ? agent : "(null)");
  5747.  
  5748.     if (hdrlist[1]) {
  5749.     printf(" Header list: 1. %s\n",hdrlist[0]);
  5750.     for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++)
  5751.       printf("%15d. %s\n",i+1,hdrlist[i]);
  5752.     } else
  5753.       printf(" Header:      %s\n",hdrlist[0] ? hdrlist[0] : "(null)");
  5754.  
  5755.     printf(" User:        %s\n",user ? user : "(null)");
  5756. #ifdef COMMENT
  5757.     printf(" Password:    %s\n",pass ? pass : "(null)");
  5758. #endif /* COMMENT */
  5759.  
  5760. #ifndef NOSPL
  5761.     if (array)
  5762.       printf(" Array:       \\%%%c[]\n", array);
  5763.     else
  5764.       printf(" Array:       (none)\n");
  5765. #endif /* NOSPL */
  5766.  
  5767.     if (action == HTTP_PUT || action == HTTP_POS)
  5768.       printf(" Mime-type:   %s\n",mime ? mime : "(null)");
  5769.  
  5770.     printf(" Local file:  %s\n",lfile ? lfile : "(null)");
  5771.     printf(" Remote file: %s\n",rfile ? rfile : "(null)");
  5772.     printf(" Destination file: %s\n",dfile ? dfile : "(null)");
  5773. #endif /* BETADEBUG */
  5774.  
  5775.     /* The http_xxxx() functions return 0 on success, -1 on failure */
  5776.     switch (action) {
  5777.       case HTTP_CON: {
  5778.       extern int ttyfd;
  5779.       rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile);
  5780.       break;
  5781.       }
  5782.       case HTTP_DEL:
  5783.         rc = http_delete(agent,hdrlist,user,pass,array,rfile);
  5784.         break;
  5785.       case HTTP_GET:
  5786.         rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5787.         break;
  5788.       case HTTP_HED:
  5789.         rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5790.         break;
  5791.       case HTTP_PUT:
  5792.         rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5793.               type);
  5794.         break;
  5795.       case HTTP_POS:
  5796.         rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5797.                type);
  5798.         break;
  5799.       case HTTP_IDX:
  5800.         rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5801.         break;
  5802.       default:
  5803.         rc = -1;
  5804.     }
  5805.     return(rc == 0 ? 1 : 0);            /* Success is set by caller */
  5806. }
  5807. #endif /* TCPSOCKET */
  5808. #endif /* NOHTTP */
  5809.  
  5810. #ifndef NOSPL                /* ARRAY ops... */
  5811. static struct keytab arraytab[] = {
  5812.     { "clear",     ARR_CLR, 0 },
  5813.     { "copy",      ARR_CPY, 0 },
  5814.     { "dcl",       ARR_DCL, CM_INV },
  5815.     { "declare",   ARR_DCL, 0 },
  5816.     { "destroy",   ARR_DST, CM_INV },
  5817.     { "equate",    ARR_EQU, CM_INV },
  5818.     { "link",      ARR_EQU, 0 },
  5819.     { "resize",    ARR_RSZ, 0 },
  5820.     { "set",       ARR_SET, 0 },
  5821. #ifndef NOSHOW
  5822.     { "show",      ARR_SHO, 0 },
  5823. #endif /* NOSHOW */
  5824.     { "sort",      ARR_SRT, 0 },
  5825.     { "undeclare", ARR_DST, 0 },
  5826.     { "", 0, 0 }
  5827. };
  5828. static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1;
  5829.  
  5830. #ifdef CKLEARN
  5831. static struct keytab learnswi[] = {
  5832.     { "/close",    2, 0 },
  5833.     { "/off",      0, 0 },
  5834.     { "/on",       1, 0 }
  5835. };
  5836. #endif /* CKLEARN */
  5837.  
  5838. int
  5839. arrayitoa(x) int x; {            /* Array index to array letter */
  5840.     if (x == 1)
  5841.       return(64);
  5842.     else if (x < 0 || x > (122 - ARRAYBASE))
  5843.       return(-1);
  5844.     else
  5845.       return(x + ARRAYBASE);
  5846. }
  5847.  
  5848. int
  5849. arrayatoi(c) int c; {            /* Array letter to array index */
  5850.     if (c == 64)
  5851.       c = 96;
  5852.     if (c > 63 && c < 91)
  5853.       c += 32;
  5854.     if (c < ARRAYBASE || c > 122)
  5855.       return(-1);
  5856.     return(c - ARRAYBASE);
  5857. }
  5858.  
  5859. static int                /* Declare an array */
  5860. dodcl(cx) int cx; {
  5861.     int i, n, v, lo, hi, rc = 0;
  5862.     int isdynamic = 0;
  5863.     char tmpbuf[64];
  5864.     char ** p = NULL;
  5865.     char tmp[64];            /* Local temporary string buffer */
  5866.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5867.     if (y == -3) {
  5868.         printf("?Array name required\n");
  5869.         return(-9);
  5870.     } else return(y);
  5871.     }
  5872.     ckstrncpy(line,s,LINBUFSIZ);
  5873.     s = line;
  5874.     x = arraybounds(s,&lo,&hi);        /* Check syntax and get bounds */
  5875.     debug(F111,"XXX dodcl arraybounds",s,x);
  5876.     if (x < 0) {            /* Error - Maybe it's a variable */
  5877.     char * p;            /* whose value is an array name */
  5878.     int n;
  5879.     p = tmpbuf;
  5880.     n = 63;
  5881.     p[0] = NUL;
  5882.     if (s[0] == CMDQ && s[1] == '&')
  5883.       s++;
  5884.     if (zzstring(s,&p,&n) > -1) {
  5885.         s = tmpbuf;
  5886.         x = arraybounds(s,&lo,&hi);
  5887.         debug(F111,"XXX dodcl arraybounds 2",s,x);
  5888.     }
  5889.     if (x < 0) {
  5890.         printf("?Bad array name - \"%s\"\n",s);
  5891.         return(-9);
  5892.     }
  5893.     }
  5894.     debug(F101,"XXX dodcl lo","",lo);
  5895.     debug(F101,"XXX dodcl hi","",hi);
  5896.  
  5897.     if (lo < 0 && hi < 0) {        /* Have good array name and bounds */
  5898.     isdynamic = 1;
  5899.     n = CMDBL / 5;
  5900.     } else if (hi > -1) {
  5901.     printf("?Segment notation not allowed in array declarations\n");
  5902.     return(-9);
  5903.     } else
  5904.       n = lo;
  5905.     x = arrayitoa(x);
  5906.     if (cx == XXUNDCL) {
  5907.     n = 0;
  5908.     v = 0;
  5909.     if ((y = cmcfm()) < 0)
  5910.       return(y);
  5911.     } else {
  5912.     p = (char **)malloc(sizeof(char **)*(n+1));
  5913.     if (!p) {
  5914.         printf("?Memory allocation error\n");
  5915.         return(-9);
  5916.     }
  5917.     v = 0;                /* Highest initialized member */
  5918.     p[0] = NULL;            /* Element 0 */
  5919.     while (n > 0 && v < n) {    /* Parse initializers */
  5920.         p[v+1] = NULL;
  5921.         ckmakxmsg(tmp,
  5922.               64,
  5923.               "Initial value for \\&",
  5924.               ckctoa((char)x),
  5925.               "[",
  5926.               ckitoa(v+1),
  5927.               "]",
  5928.               NULL,NULL,NULL,NULL,NULL,NULL,NULL
  5929.               );
  5930.         if ((rc = cmfld((char *)tmp,"",&s,xxstring)) < 0) { /* Get field */
  5931.         if (rc == -3)        /* If answer is empty, we're done */
  5932.           break;
  5933.         else            /* Parse error, free temp pointers */
  5934.           goto dclx;
  5935.         }
  5936.         rc = 1;
  5937.         if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */
  5938.           continue;
  5939.         s = brstrip(s);        /* Strip any braces */
  5940.         makestr(&(p[++v]),s);
  5941.     }
  5942.     if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0)
  5943.       return(y);
  5944.     if (isdynamic)
  5945.       n = v;
  5946.     }
  5947.     if (dclarray((char)x,n) < 0) {    /* Declare the array */
  5948.     printf("?Declare failed\n");
  5949.     goto dclx;
  5950.     }
  5951.     for (i = 1; i <= v; i++) {        /* Add any initial values */
  5952.     tmp[0] = '&';
  5953.     ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]");
  5954.     if (addmac(tmp,p[i]) < 0) {
  5955.         printf("Array initialization error: %s %s\n",tmp,p[i]);
  5956.         rc = -9;
  5957.         goto dclx;
  5958.     }
  5959.     }
  5960.   dclx:
  5961.     if (p) {
  5962.     for (i = 1; i <= v; i++)
  5963.       if (p[i]) free(p[i]);
  5964.     free((char *)p);
  5965.     }
  5966.     debug(F101,"DCL rc","",rc);
  5967.     return(success = rc);
  5968. }
  5969.  
  5970. static int
  5971. rszarray() {
  5972.     int i, x, y, n, lo, hi, islink = -1;
  5973.     char c, * s, ** ap = NULL;
  5974.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5975.     if (x == -3) {
  5976.         printf("?Array name required\n");
  5977.         return(-9);
  5978.     } else return(x);
  5979.     }
  5980.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  5981.     s = line;
  5982.     x = arraybounds(s,&lo,&hi);
  5983.     if (x < 0) {            /* Parse the name, get index */
  5984.     printf("?Bad array reference - \"%s\"\n", s);
  5985.     return(-9);
  5986.     }
  5987.     if (lo < 0 && hi < 0) {
  5988.     y = cmnum("New size","",10,&lo,xxstring);
  5989.     if (y < 0) {
  5990.         if (y == -3)
  5991.           printf("?New size required\n");
  5992.         return(y);
  5993.     }
  5994.     }
  5995.     if ((y = cmcfm()) < 0)
  5996.       return(y);
  5997.     if (a_link[x] > -1) {        /* Link? */
  5998.     islink = x;            /* Yes follow it */
  5999.     x = a_link[x];            /* and remember */
  6000.     }
  6001.     if (!a_ptr[x]) {
  6002.     printf("?Array not declared - \"%s\"\n", s);
  6003.     return(-9);
  6004.     }
  6005.     if (lo < 0) {
  6006.     printf("?New size required\n");
  6007.     return(-9);
  6008.     }
  6009.     if (hi > -1) {
  6010.     printf("?Array segments not allowed for this operation\n");
  6011.     return(-9);
  6012.     }
  6013.     c = arrayitoa(x);            /* Get array letter */
  6014.     if (c == '@') {            /* Argument vector array off limits */
  6015.     printf("?Sorry, \\&@[] is read-only\n");
  6016.     return(-9);
  6017.     }
  6018.     if (lo == 0) {            /* If new size is 0... */
  6019.     dclarray(c,0);            /* Undeclare the array */
  6020.     return(success = 1);
  6021.     }
  6022.     n = a_dim[x];            /* Current size */
  6023.     ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */
  6024.     y = (n < lo) ? n : lo;
  6025.     for (i = 0; i <= y; i++)        /* Copy the part that fits */
  6026.       ap[i] = a_ptr[x][i];
  6027.     if (n < lo) {            /* If original array smaller */
  6028.     for (; i <= lo; i++)        /* initialize extra elements in */
  6029.       ap[i] = NULL;            /* new array to NULL. */
  6030.     } else if (n > lo) {        /* If new array smaller */
  6031.     for (; i <= lo; i++)        /* deallocate leftover elements */
  6032.       makestr(&(a_ptr[x][i]),NULL);    /* from original array. */
  6033.     }
  6034.     free((char *)a_ptr[x]);        /* Free original array list */
  6035.     a_ptr[x] = ap;            /* Replace with new one */
  6036.     a_dim[x] = lo;            /* Record the new dimension */
  6037.     if (islink > -1) {            /* Was this a link? */
  6038.     a_ptr[islink] = ap;        /* If so point to the resized array */
  6039.     a_dim[islink] = lo;
  6040.     } else {                /* If not are there links to here? */
  6041.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  6042.         if (i != x && a_link[i] == x) {     /* Find and update them */
  6043.         a_ptr[i] = ap;
  6044.         a_dim[i] = lo;
  6045.         }
  6046.     }
  6047.     }
  6048.     return(success = 1);
  6049. }
  6050.  
  6051. static int
  6052. copyarray() {
  6053.     int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0;
  6054.     char c1, c2, * a1, * a2;
  6055.     if ((y = cmfld("Name of source array","",&s,NULL)) < 0)
  6056.       return(y);
  6057.     ckstrncpy(line,s,LINBUFSIZ);
  6058.     a1 = line;
  6059.     if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) {
  6060.     printf("?Bad array reference - \"%s\"\n", a1);
  6061.     return(-9);
  6062.     } else if (!a_ptr[x1]) {
  6063.     printf("?Array not declared - \"%s\"\n", a1);
  6064.     return(-9);
  6065.     }
  6066.     c1 = arrayitoa(x1);
  6067.  
  6068.     if ((y = cmfld("Name of destination array","",&s,NULL)) < 0)
  6069.       return(y);
  6070.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6071.     a2 = tmpbuf;
  6072.     if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) {
  6073.     printf("?Bad array reference - \"%s\"\n", a2);
  6074.     return(-9);
  6075.     }
  6076.     c2 = arrayitoa(x2);
  6077.  
  6078.     if ((x = cmcfm()) < 0)
  6079.       return(x);
  6080.  
  6081.     if (c2 == '@') {            /* Argument vector array off limits */
  6082.     printf("?Sorry, \\&@[] is read-only\n");
  6083.     return(-9);
  6084.     }
  6085.     if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */
  6086.       whole = 1;                      /* whole array... */
  6087.  
  6088.     if (lo1 < 0) lo1 = whole ? 0 : 1;    /* Supply lower bound of source */
  6089.     if (hi1 < 0) hi1 = a_dim[x1];    /* Supply upper bound of source */
  6090.     if (lo2 < 0) lo2 = whole ? 0 : 1;    /* Lower bound of target */
  6091.     if (hi2 < 0) hi2 = lo2 + hi1 - lo1;    /* Upper bound of target */
  6092.     if (a_ptr[x2]) {            /* Target array is already declared? */
  6093.     if (hi2 > a_dim[x2])        /* If upper bound out of range */
  6094.       hi2 = a_dim[x2];        /* shrink to fit */
  6095.     } else {                /* Otherwise... */
  6096.     x2 = dclarray(c2, hi2);        /* declare the target array */
  6097.     }
  6098.     for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */
  6099.     makestr(&(a_ptr[x2][j]),a_ptr[x1][i]);
  6100.     }
  6101.     return(success = 1);
  6102. }
  6103.  
  6104. static int                /* Undeclare an array */
  6105. unarray() {
  6106.     int x, y, n, rc = 0;
  6107.     char c, * s;
  6108.  
  6109.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6110.     if (y == -3) {
  6111.         printf("?Array name required\n");
  6112.         return(-9);
  6113.     } else return(y);
  6114.     }
  6115.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6116.     s = line;
  6117.     if ((y = cmcfm()) < 0)
  6118.       return(y);
  6119.     if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */
  6120.     printf("?Bad array reference - \"%s\"\n", s);
  6121.     return(-9);
  6122.     }
  6123.     if (y > 0 || n > 0) {
  6124.     printf("?Partial arrays can not be destroyed\n");
  6125.     return(-9);
  6126.     }
  6127.     c = arrayitoa(x);            /* Get array letter */
  6128.     if (a_ptr[x]) {            /* If array is declared */
  6129.     if (c == '@') {            /* Argument vector array off limits */
  6130.         printf("?Sorry, \\&@[] is read-only\n");
  6131.         return(-9);
  6132.     }
  6133.     rc = dclarray(c,0);        /* Undeclare the array */
  6134.     } else                /* It wasn't declared */
  6135.       rc = 1;
  6136.     if (rc > -1) {            /* Set return code and success */
  6137.     success = 1;
  6138.     rc = 1;
  6139.     } else {
  6140.     success = 0;
  6141.     printf("?Failed - destroy \"\\&%c[]\"\n", c);
  6142.     rc = -9;
  6143.     }
  6144.     return(rc);
  6145. }
  6146.  
  6147. static int
  6148. clrarray(cx) int cx; {
  6149.     int i, x, lo, hi;
  6150.     char c, * s, * val = NULL;
  6151.  
  6152.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6153.     if (x == -3) {
  6154.         printf("?Array name required\n");
  6155.         return(-9);
  6156.     } else return(x);
  6157.     }
  6158.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6159.     s = line;
  6160.     if (cx == ARR_SET) {        /* SET */
  6161.     if ((x = cmtxt("Value","",&val,xxstring)) < 0)
  6162.       return(x);
  6163.     ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */
  6164.     val = tmpbuf;
  6165.     if (!*val) val = NULL;
  6166.     } else if ((x = cmcfm()) < 0)    /* CLEAR */
  6167.       return(x);
  6168.  
  6169.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */
  6170.     printf("?Bad array reference - \"%s\"\n", s);
  6171.     return(-9);
  6172.     }
  6173.     c = arrayitoa(x);            /* Get array letter */
  6174.     if (!a_ptr[x]) {            /* If array is declared */
  6175.     printf("?Array %s is not declared\n", s);
  6176.     return(-9);
  6177.     } else if (c == '@') {        /* Argument vector array off limits */
  6178.     printf("?Sorry, \\&@[] is read-only\n");
  6179.     return(-9);
  6180.     }
  6181.     if (lo < 0) lo = 0;
  6182.     if (hi < 0) hi = a_dim[x];
  6183.     for (i = lo; i <= hi; i++)        /* Clear/Set selected range */
  6184.       makestr(&(a_ptr[x][i]),val);
  6185.  
  6186.     return(success = 1);
  6187. }
  6188.  
  6189. extern char **aa_ptr[CMDSTKL][28];
  6190. extern int aa_dim[CMDSTKL][28];
  6191.  
  6192. static int                /* Create symbolic link to an array */
  6193. linkarray() {
  6194.     int i = 0, x, y, lo, hi, flag = 0;
  6195.     char c, * s, * p;
  6196.  
  6197.     if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) {
  6198.     if (x == -3) {
  6199.         printf("?Array name required\n");
  6200.         return(-9);
  6201.     } else return(x);
  6202.     }
  6203.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of link name */
  6204.     s = line;
  6205.     if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) {
  6206.     if (x == -3) {
  6207.         printf("?Array name required\n");
  6208.         return(-9);
  6209.     } else return(x);
  6210.     }
  6211.     ckstrncpy(tmpbuf,p,TMPBUFSIZ);    /* Make safe copy of array name */
  6212.     p = tmpbuf;
  6213.     if ((x = cmcfm()) < 0)
  6214.       return(x);
  6215.  
  6216.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */
  6217.     printf("?Bad array reference - \"%s\"\n", s);
  6218.     return(-9);
  6219.     }
  6220.     if (a_ptr[x]) {            /* Must not already exist */
  6221.     c = arrayitoa(x);
  6222.     printf("?Array already exists: \\&%c[]\n", c);
  6223.     return(-9);
  6224.     }
  6225.     if (lo > -1 || hi > -1) {
  6226.     printf("?Sorry, whole arrays only: %s\n",s);
  6227.     return(-9);
  6228.     }
  6229.     if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */
  6230.     printf("?Bad array reference - \"%s\"\n", s);
  6231.     return(-9);
  6232.     }
  6233.     if (lo > -1 || hi > -1) {
  6234.     printf("?Sorry, whole arrays only: %s\n",p);
  6235.     return(-9);
  6236.     }
  6237.     if (x == y) {
  6238.     for (i = cmdlvl; i >= 0; i--)
  6239.       if (aa_ptr[i][x]) {
  6240.           flag++;
  6241.           break;
  6242.       }
  6243.     }
  6244.     if (flag) {
  6245.     a_ptr[x] = aa_ptr[i][y];    /* Link to saved copy */
  6246.     a_dim[x] = aa_dim[i][y];
  6247.     } else {                /* Otherwise... */
  6248.     c = arrayitoa(y);        /* Check if it's declared */
  6249.     if (!a_ptr[y]) {
  6250.         printf("?Array is not declared: \\&%c[]\n", c);
  6251.         return(-9);
  6252.     }
  6253.     if (a_link[y] > -1) {        /* And if it's a link itself */
  6254.         printf("?Links to links not allowed: \\&%c[]\n", c);
  6255.         return(-9);
  6256.     }
  6257.     a_ptr[x] = a_ptr[y];        /* All OK, make the link */
  6258.     a_dim[x] = a_dim[y];
  6259.     }
  6260.     a_link[x] = y;
  6261.     return(success = 1);
  6262. }
  6263. #endif /* NOSPL */
  6264.  
  6265. #ifndef NOCSETS
  6266. static char * dcsetname = NULL;
  6267.  
  6268. /* Get Display Character-Set Name */
  6269.  
  6270. char *
  6271. getdcset() {
  6272.     char * s;
  6273.     int y;
  6274. #ifdef PCFONTS
  6275.     extern int tt_font, ntermfont;
  6276.     extern struct keytab term_font[];
  6277. #endif /* PCFONTS */
  6278.  
  6279.     s = "";
  6280. #ifdef OS2
  6281.     y = os2getcp();            /* Default is current code page */
  6282.     switch (y) {
  6283.       case 437: s = "cp437"; break;
  6284.       case 850: s = "cp850"; break;
  6285.       case 852: s = "cp852"; break;
  6286.       case 857: s = "cp857"; break;
  6287.       case 858: s = "cp858"; break;
  6288.       case 862: s = "cp862"; break;
  6289.       case 866: s = "cp866"; break;
  6290.       case 869: s = "cp869"; break;
  6291.       case 1250: s = "cp1250"; break;
  6292.       case 1251: s = "cp1251"; break;
  6293.       case 1252: s = "cp1252"; break;
  6294.       case 1253: s = "cp1253"; break;
  6295.       case 1254: s = "cp1254"; break;
  6296.       case 1255: s = "cp1255"; break;
  6297.       case 1256: s = "cp1256"; break;
  6298.       case 1257: s = "cp1257"; break;
  6299.       case 1258: s = "cp1258"; break;
  6300.     }
  6301. #ifdef PCFONTS
  6302. /*
  6303.    If the user has loaded a font with SET TERMINAL FONT then we want
  6304.    to change the default code page to the font that was loaded.
  6305. */
  6306.     if (tt_font != TTF_ROM) {
  6307.     for (y = 0; y < ntermfont; y++ ) {
  6308.         if (term_font[y].kwval == tt_font) {
  6309.         s = term_font[y].kwd;
  6310.         break;
  6311.         }
  6312.     }
  6313.     }
  6314. #endif /* PCFONTS */
  6315. #else /* OS2 */
  6316. #ifdef COMMENT
  6317.     /* Hack not needed as of C-Kermit 7.1 */
  6318.     if (fcharset == FC_1LATIN) {
  6319.     s = "latin1-iso";        /* Hack to avoid reporting "cp1252" */
  6320.     } else {                /* Report current file character set */
  6321. #endif /* COMMENT */
  6322.     for (y = 0; y <= nfilc; y++)
  6323.       if (fcstab[y].kwval == fcharset) {
  6324.           s = fcstab[y].kwd;
  6325.           break;
  6326.       }
  6327. #ifdef COMMENT
  6328.     }
  6329. #endif /* COMMENT */
  6330. #endif /* OS2 */
  6331.     makestr(&dcsetname,s);        /* Return stable pointer */
  6332.     return((char *)dcsetname);
  6333. }
  6334. #endif /* NOCSETS */
  6335.  
  6336. #ifndef NOFRILLS
  6337. static int
  6338. doclear() {
  6339.     if ((x = cmkey(clrtab,nclear,"item to clear",
  6340. #ifdef NOSPL
  6341.            "device-buffer"
  6342. #else
  6343.            "device-and-input"
  6344. #endif /* NOSPL */
  6345.            ,xxstring)) < 0) return(x);
  6346. #ifndef NOSPL
  6347. #ifdef OS2
  6348.     if (x == CLR_CMD || x == CLR_TRM) {
  6349.     if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n",
  6350.                "all",xxstring)) < 0)
  6351.       return(z);
  6352.     }
  6353. #endif /* OS2 */
  6354. #endif /* NOSPL */
  6355.     if ((y = cmcfm()) < 0)
  6356.       return(y);
  6357.  
  6358.     /* Clear device input buffer if requested */
  6359.     y = (x & CLR_DEV) ? ttflui() : 0;
  6360.  
  6361.     if (x & CLR_SCR)            /* CLEAR SCREEN */
  6362.       y = ck_cls();            /* (= SCREEN CLEAR = CLS) */
  6363.  
  6364.     if (x & CLR_KBD) {            /* CLEAR KEYBOARD */
  6365.     int n;
  6366.     n = conchk();
  6367.     y = 0;
  6368.     while (n-- > 0 && (y = coninc(0) > -1))
  6369.       ;
  6370.     y = (y > -1) ? 0 : -1;
  6371.     }
  6372.  
  6373. #ifndef NOSPL
  6374.     /* Clear INPUT command buffer if requested */
  6375.     if (x & CLR_INP) {
  6376.     for (z = 0; z < inbufsize; z++)
  6377.       inpbuf[z] = NUL;
  6378.     inpbp = inpbuf;
  6379.     y = 0;
  6380.     }
  6381. #ifdef CK_APC
  6382.     if (x & CLR_APC) {
  6383.     debug(F101,"Executing CLEAR APC","",apcactive);
  6384.     apcactive = 0;
  6385.     y = 0;
  6386.     }
  6387. #endif /* CK_APC */
  6388.     if (x & CLR_ALR) {
  6389.     setalarm(0L);
  6390.     y = 0;
  6391.     }
  6392. #endif /* NOSPL */
  6393.  
  6394. #ifdef PATTERNS
  6395.     if (x & (CLR_TXT|CLR_BIN)) {
  6396.     int i;
  6397.     for (i = 0; i < FTPATTERNS; i++) {
  6398.         if (x & CLR_TXT)
  6399.           makestr(&txtpatterns[i],NULL);
  6400.         if (x & CLR_BIN)
  6401.           makestr(&binpatterns[i],NULL);
  6402.     }
  6403.     y = 0;
  6404.     }
  6405. #endif /* PATTERNS */
  6406.  
  6407. #ifndef NODIAL
  6408.     if (x & CLR_DIA) {
  6409.     dialsta = DIA_UNK;
  6410.     y = 0;
  6411.     }
  6412. #endif /* NODIAL */
  6413.  
  6414. #ifndef NOMSEND
  6415.     if (x & CLR_SFL) {            /* CLEAR SEND-LIST */
  6416.     if (filehead) {
  6417.         struct filelist * flp, * next;
  6418.         flp = filehead;
  6419.         while (flp) {
  6420.         if (flp->fl_name)
  6421.           free(flp->fl_name);
  6422.         if (flp->fl_alias)
  6423.           free(flp->fl_alias);
  6424.         next = flp->fl_next;
  6425.         free((char *)flp);
  6426.         flp = next;
  6427.         }
  6428.     }
  6429.     filesinlist = 0;
  6430.     filehead = NULL;
  6431.     filetail = NULL;
  6432.     addlist = 0;
  6433.     y = 0;
  6434.     }
  6435. #endif /* NOMSEND */
  6436.  
  6437. #ifdef OS2
  6438. #ifndef NOLOCAL
  6439.     switch (x) {
  6440.       case CLR_SCL:
  6441.     clearscrollback(VTERM);
  6442.     break;
  6443.       case CLR_CMD:
  6444.     switch ( z ) {
  6445.       case CLR_C_ALL:
  6446.         clear();
  6447.         break;
  6448.       case CLR_C_BOS:
  6449.         clrboscr_escape(VCMD,SP);
  6450.         break;
  6451.       case CLR_C_BOL:
  6452.         clrbol_escape(VCMD,SP);
  6453.         break;
  6454.       case CLR_C_EOL:
  6455.         clrtoeoln(VCMD,SP);
  6456.         break;
  6457.       case CLR_C_EOS:
  6458.         clreoscr_escape(VCMD,SP);
  6459.         break;
  6460.       case CLR_C_LIN:
  6461.         clrline_escape(VCMD,SP);
  6462.         break;
  6463.       case CLR_C_SCR:
  6464.         clearscrollback(VCMD);
  6465.         break;
  6466.     default:
  6467.         printf("Not implemented yet, sorry.\n");
  6468.         break;
  6469.     }
  6470.     break;
  6471.  
  6472. #ifndef NOTERM
  6473.       case CLR_TRM:
  6474.      switch ( z ) {
  6475.       case CLR_C_ALL:
  6476.          if (VscrnGetBufferSize(VTERM) > 0 ) {
  6477.          VscrnScroll(VTERM, UPWARD, 0,
  6478.                  VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1),
  6479.                  VscrnGetHeight(VTERM) -
  6480.                  (tt_status[VTERM]?1:0), TRUE, SP
  6481.                  );
  6482.          cleartermscreen(VTERM);
  6483.          }
  6484.          break;
  6485.       case CLR_C_BOS:
  6486.         clrboscr_escape(VTERM,SP);
  6487.         break;
  6488.       case CLR_C_BOL:
  6489.         clrbol_escape(VTERM,SP);
  6490.         break;
  6491.       case CLR_C_EOL:
  6492.         clrtoeoln(VTERM,SP);
  6493.         break;
  6494.       case CLR_C_EOS:
  6495.         clreoscr_escape(VTERM,SP);
  6496.         break;
  6497.       case CLR_C_LIN:
  6498.         clrline_escape(VTERM,SP);
  6499.         break;
  6500.      case CLR_C_SCR:
  6501.          clearscrollback(VTERM);
  6502.          break;
  6503.      default:
  6504.          printf("Not implemented yet, sorry.\n");
  6505.          break;
  6506.     }
  6507.     break;
  6508. #endif /* NOTERM */
  6509.     }
  6510.     y = 0;
  6511. #endif /* NOLOCAL */
  6512. #endif /* OS2 */
  6513.     return(success = (y == 0));
  6514. }
  6515. #endif /* NOFRILLS */
  6516.  
  6517. #ifndef NOSPL
  6518. static int
  6519. doeval(cx) int cx; {
  6520.     char *p;
  6521.     char vnambuf[VNAML], * vnp = NULL;    /* These must be on the stack */
  6522.     if (!oldeval) {
  6523.     if ((y = cmfld("Variable name","",&s,
  6524.                ((cx == XX_EVAL) ? xxstring : NULL))) < 0) {
  6525.         if (y == -3) {
  6526.         printf("?Variable name required\n");
  6527.         return(-9);
  6528.         } else return(y);
  6529.     }
  6530.     ckstrncpy(vnambuf,s,VNAML);    /* Make a copy. */
  6531.     vnp = vnambuf;
  6532.     if (vnambuf[0] == CMDQ &&
  6533.         (vnambuf[1] == '%' || vnambuf[1] == '&'))
  6534.       vnp++;
  6535.     y = 0;
  6536.     if (*vnp == '%' || *vnp == '&') {
  6537.         if ((y = parsevar(vnp,&x,&z)) < 0)
  6538.           return(y);
  6539.     }
  6540.     }
  6541.     if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0)
  6542.       return(x);
  6543.     p = evala(s);
  6544.     if (!p) p = "";
  6545.     if (oldeval && *p)
  6546.       printf("%s\n", p);
  6547.     ckstrncpy(evalbuf,p,32);
  6548.     if (!oldeval)
  6549.       return(success = addmac(vnambuf,p));
  6550.     else
  6551.       return(success = *p ? 1 : 0);
  6552. }
  6553. #endif /* NOSPL */
  6554.  
  6555. #ifdef TNCODE
  6556. static int
  6557. dotelopt() {
  6558.     if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 )
  6559.       return(x);
  6560.     switch (x) {
  6561.       case WILL:
  6562.       case WONT:
  6563.       case DO:
  6564.       case DONT:
  6565.     if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0)
  6566.       return(y);
  6567.     if ((z = cmcfm()) < 0) return(z);
  6568.  
  6569.     switch (x) {
  6570.       case WILL:
  6571.         if (TELOPT_UNANSWERED_WILL(y))
  6572.           return(success = 0);
  6573.         break;
  6574.       case WONT:
  6575.         if (TELOPT_UNANSWERED_WONT(y))
  6576.           return(success = 0);
  6577.         break;
  6578.       case DO:
  6579.         if (TELOPT_UNANSWERED_DO(y))
  6580.           return(success = 0);
  6581.         break;
  6582.       case DONT:
  6583.         if (TELOPT_UNANSWERED_DONT(y))
  6584.           return(success = 0);
  6585.         break;
  6586.     }
  6587.     if (local) {
  6588.         success = ((tn_sopt(x,y) > -1) ? 1 : 0);
  6589.     } else {
  6590.         printf("ff%02x%02x\n",x,y);
  6591.         success = 1;
  6592.     }
  6593.     if (success) {
  6594.         switch (x) {
  6595.           case WILL:
  6596.         TELOPT_UNANSWERED_WILL(y) = 1;
  6597.         break;
  6598.           case WONT:
  6599.         if ( TELOPT_ME(y) )
  6600.           TELOPT_UNANSWERED_WONT(y) = 1;
  6601.         break;
  6602.           case DO:
  6603.         TELOPT_UNANSWERED_DO(y) = 1;
  6604.         break;
  6605.           case DONT:
  6606.         if ( TELOPT_ME(y) )
  6607.           TELOPT_UNANSWERED_DONT(y) = 1;
  6608.         break;
  6609.         }
  6610.         if (tn_wait("XXTELOP") < 0) {
  6611.         tn_push();
  6612.         success = 0;
  6613.         }
  6614.     }
  6615.     return(success);
  6616.       case SB:
  6617.     if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0)
  6618.       return(y);
  6619.     switch (y) {
  6620.       case TELOPT_NAWS:
  6621.         /* Some compilers require switch() to have at least 1 case */
  6622. #ifdef CK_NAWS
  6623.         TELOPT_SB(TELOPT_NAWS).naws.x = 0;
  6624.         TELOPT_SB(TELOPT_NAWS).naws.y = 0;
  6625.         if (local)
  6626.           return(success = ((tn_snaws() > -1) ? 1 : 0));
  6627.         else
  6628.           return(success = 0);
  6629. #else
  6630.         return(success = 0);
  6631. #endif /* CK_NAWS */
  6632.     }
  6633.         return(success = 0);
  6634.  
  6635. #ifdef CK_KERBEROS
  6636. #ifdef KRB5
  6637.       case TN_FWD:
  6638.         success = (kerberos5_forward() == AUTH_SUCCESS);
  6639.         return(success);
  6640. #endif /* KRB5 */
  6641. #endif /* CK_KERBEROS */
  6642.  
  6643.       default:
  6644.     if ((z = cmcfm()) < 0) return(z);
  6645. #ifndef NOLOCAL
  6646.     if (local) {
  6647.         CHAR temp[3];
  6648.         if (network && IS_TELNET()) { /* TELNET */
  6649.         temp[0] = (CHAR) IAC;
  6650.         temp[1] = x;
  6651.         temp[2] = NUL;
  6652.         success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0);
  6653.         if (tn_deb || debses || deblog) {
  6654.             /* TN_MSG_LEN is in ckctel.h */
  6655.             ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL);
  6656.             debug(F101,tn_msg,"",x);
  6657.             if (debses || tn_deb) tn_debug(tn_msg);
  6658.         }
  6659.         return(success);
  6660.         }
  6661.             return(success = 0);
  6662.     } else {
  6663. #endif /* NOLOCAL */
  6664.         printf("ff%02x\n",x);
  6665.         return(success = 1);
  6666. #ifndef NOLOCAL
  6667.     }
  6668. #endif /* NOLOCAL */
  6669.     }
  6670. }
  6671. #endif /* TNCODE */
  6672.  
  6673.  
  6674. #ifndef NOPUSH
  6675. #ifndef NOFRILLS
  6676. static int
  6677. doedit() {
  6678. #ifdef OS2
  6679.     char * p = NULL;
  6680. #endif /* OS2 */
  6681.     if (!editor[0]) {
  6682.     s = getenv("EDITOR");
  6683.     if (s) ckstrncpy(editor,s,CKMAXPATH);
  6684.     editor[CKMAXPATH] = NUL;
  6685.     if (!editor[0]) {
  6686.         printf("?Editor not defined - use SET EDITOR to define\n");
  6687.         return(-9);
  6688.     }
  6689.     }
  6690.     ckstrncpy(tmpbuf,editfile,TMPBUFSIZ);
  6691. /*
  6692.   cmiofi() lets us parse the name of an existing file, or the name of
  6693.   a nonexistent file to be created.
  6694. */
  6695.     x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring);
  6696.     if (x < 0) {
  6697.     if (x == -9) {
  6698.         if (zchko(s) < 0) {
  6699.         printf("Can't create \"%s\"\n",s);
  6700.         return(x);
  6701.         }
  6702.     } else if (x != -3)
  6703.       return(x);
  6704.     }
  6705.     if (x == -3)
  6706.       tmpbuf[0] = NUL;
  6707.     else {
  6708.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6709.     if (iswild((char *)tmpbuf)) {
  6710.         printf("?A single file please\n");
  6711.         return(-9);
  6712.     }
  6713.     }
  6714.     if ((z = cmcfm()) < 0) return(z);
  6715.     if (nopush) {
  6716.     printf("?Sorry, editing not allowed\n");
  6717.     return(success = 0);
  6718.     }
  6719.     if (tmpbuf[0]) {
  6720.     /* Get full path in case we change directories between EDIT commands */
  6721.     zfnqfp(tmpbuf, CKMAXPATH, editfile);
  6722.     editfile[CKMAXPATH] = NUL;
  6723. #ifdef OS2
  6724.     p = editfile;            /* Flip the stupid slashes */
  6725.     while (*p) {
  6726.         if (*p == '/') *p = '\\';
  6727.         p++;
  6728.     }
  6729. #endif /* OS2 */
  6730.     } else
  6731.       editfile[0] = NUL;
  6732.     x = 0;
  6733.     if (editopts[0]) {
  6734. #ifdef OS2
  6735.     x = ckindex("%1",(char *)editopts,0,0,1);
  6736.     if (x > 0)
  6737.       editopts[x] = 's';
  6738.     else
  6739. #endif /* OS2 */
  6740.       x = ckindex("%s",(char *)editopts,0,0,1);
  6741.     }
  6742.     if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) {
  6743.     if (x)
  6744.       sprintf(tmpbuf,editopts,editfile);
  6745.     else
  6746.       sprintf(tmpbuf,"%s %s",editopts,editfile);
  6747.     }
  6748.     s = line;
  6749.     ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL);
  6750. #ifdef OS2
  6751.     p = s + strlen(editor);        /* And again with the slashes */
  6752.     while (p != s) {
  6753.     if (*p == '/') *p = '\\';
  6754.     p--;
  6755.     }
  6756. #endif /* OS2 */
  6757.     conres();
  6758.     x = zshcmd(s);
  6759.     concb((char)escape);
  6760.     return(x);
  6761. }
  6762. #endif /* NOFRILLS */
  6763. #endif /* NOPUSH */
  6764.  
  6765. #ifdef BROWSER
  6766. static int
  6767. dobrowse() {
  6768. #ifdef OS2
  6769.     char * p = NULL;
  6770. #endif /* OS2 */
  6771.     if (nopush) {
  6772.     printf("?Sorry, browsing not allowed\n");
  6773.     return(success = 0);
  6774.     }
  6775. #ifndef NT
  6776.     /* Windows lets the Shell Execute the URL if no Browser is defined */
  6777.     if (!browser[0]) {
  6778.     s = getenv("BROWSER");
  6779.     if (s) ckstrncpy(browser,s,CKMAXPATH);
  6780.     browser[CKMAXPATH] = NUL;
  6781.     if (!browser[0]) {
  6782.         printf("?Browser not defined - use SET BROWSER to define\n");
  6783.         return(-9);
  6784.     }
  6785.     }
  6786. #endif /* NT */
  6787.     ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ);
  6788.     if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0)
  6789.       return(x);
  6790.     ckstrncpy(browsurl,s,4096);
  6791.     x = 0;
  6792.     if (browsopts[0]) {
  6793. #ifdef OS2
  6794.     x = ckindex("%1",(char *)browsopts,0,0,1);
  6795.     if (x > 0)
  6796.       browsopts[x] = 's';
  6797.     else
  6798. #endif /* OS2 */
  6799.       x = ckindex("%s",(char *)browsopts,0,0,1);
  6800.     }
  6801.     if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) {
  6802.     if (x)
  6803.       sprintf(tmpbuf,browsopts,browsurl);
  6804.     else
  6805.       sprintf(tmpbuf,"%s %s",browsopts,browsurl);
  6806.     }
  6807. #ifdef NT
  6808.     if (!browser[0])
  6809.       return(success = Win32ShellExecute(browsurl));
  6810. #endif /* NT */
  6811.     s = line;
  6812.     ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL);
  6813. #ifdef OS2
  6814.     p = line + strlen(browser);        /* Flip slashes */
  6815.     while (p != line) {
  6816.     if (*p == '/') *p = '\\';
  6817.     p--;
  6818.     }
  6819. #endif /* OS2 */
  6820.     conres();
  6821.     x = zshcmd(s);
  6822.     concb((char)escape);
  6823.     return(x);
  6824. }
  6825. #endif /* BROWSER */
  6826.  
  6827. #ifdef CK_RECALL
  6828. static int
  6829. doredo() {            /* Find a previous cmd and redo it */
  6830.     extern int on_recall, in_recall;
  6831.     int x;
  6832.     char * p;
  6833.  
  6834.     if ((x = cmtxt(
  6835. "pattern, or first few characters of a previous command",
  6836.            "*",&s,xxstring)) < 0)
  6837.       return(x);
  6838.     ckstrncpy(line,s,LINBUFSIZ);
  6839.     x = strlen(s);
  6840.     s = line;
  6841.     if (*s == '{') {            /* Braces disable adding * to end */
  6842.     if (s[x-1] == '}') {
  6843.         s[x-1] = NUL;
  6844.         s++;
  6845.         x--;
  6846.     }
  6847.     } else {                /* No braces, add * to end. */
  6848.     s[x] = '*';
  6849.     s[x+1] = NUL;
  6850.     }
  6851.  
  6852.     while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL;
  6853.  
  6854.     if (!on_recall || !in_recall) {
  6855.     printf("?Sorry, command recall can't be used now.\n");
  6856.     return(-9);
  6857.     }
  6858.     if ((p = cmgetcmd(s))) {        /* Look for it history buffer */
  6859.     ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */
  6860.     if (!quiet)            /* Echo it */
  6861.       printf("%s\n",cmdbuf);
  6862.     cmaddnext();            /* Force re-add to history buffer */
  6863.     return(cmflgs = -1);        /* Force reparse */
  6864.     } else {
  6865.     printf("?Sorry - \"%s\" not found\n", s);
  6866.     return(-9);
  6867.     }
  6868. }
  6869. #endif /* CK_RECALL */
  6870.  
  6871. #ifndef NOXFER
  6872. #ifndef NOCSETS
  6873. static int
  6874. doassoc()  {                /* ASSOCIATE */
  6875.     extern struct keytab tcstab[];
  6876.     extern int ntcs;
  6877.     if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 )
  6878.       return(x);
  6879.  
  6880.     switch (x) {            /* Associate what? */
  6881.  
  6882.       case ASSOC_TC:            /* Transfer character-set... */
  6883.     if ((x = cmkey(tcstab, ntcs,
  6884.                "transfer character-set name","",xxstring)) < 0)
  6885.       return(x);
  6886.     if ((y = cmkey(fcstab, nfilc,
  6887.                "with file character-set","", xxstring)) < 0)
  6888.       if (y != -3)
  6889.         return(y);
  6890.     if ((z = cmcfm()) < 0)
  6891.       return(z);
  6892.     axcset[x] = y;
  6893.     return(success = 1);
  6894.  
  6895.       case ASSOC_FC:            /* File character-set... */
  6896.     if ((x = cmkey(fcstab, nfilc,
  6897.                "file character-set name","",xxstring)) < 0)
  6898.       return(x);
  6899.     if ((y = cmkey(tcstab, ntcs,
  6900.                "with transfer character-set","", xxstring)) < 0)
  6901.       if (y != -3)
  6902.         return(y);
  6903.     if ((z = cmcfm()) < 0)
  6904.       return(z);
  6905.     afcset[x] = y;
  6906.     return(success = 1);
  6907.  
  6908.       default:
  6909.     return(-2);
  6910.     }
  6911. }
  6912. #endif /* NOCSETS */
  6913. #endif /* NOXFER */
  6914.  
  6915. #ifndef NOHELP
  6916. static int
  6917. domanual() {
  6918. #ifdef OS2
  6919.     if ((x = cmcfm()) < 0)
  6920.       return(x);
  6921.     if (nopush) {
  6922.     printf("?Sorry, access to system commands is disabled.\n");
  6923.     return(-9);
  6924.     }
  6925.     y = mxlook(mactab,"manual",nmac);
  6926.     if (y > -1) {
  6927.     z = maclvl;            /* Save the current maclvl */
  6928.     dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  6929.     while (maclvl > z) {
  6930.         debug(F101,"XXMAN loop maclvl 1","",maclvl);
  6931.         sstate = (CHAR) parser(1);
  6932.         debug(F101,"XXMAN loop maclvl 2","",maclvl);
  6933.         if (sstate) proto();
  6934.     }
  6935.     debug(F101,"XXMAN loop exit maclvl","",maclvl);
  6936.     return(success);
  6937.     }
  6938.     return(success = 0);
  6939. #else
  6940.     if ((x = cmtxt(
  6941. #ifdef UNIX
  6942.            "Carriage return to confirm the command, or manual topic",
  6943. #else
  6944.            "Carriage return to confirm the command, or help topic",
  6945. #endif /* UNIX */
  6946.            "kermit",
  6947.            &s,
  6948.            xxstring
  6949.            )
  6950.      ) < 0)
  6951.       return(x);
  6952. #endif /* OS2 */
  6953.  
  6954. #ifdef UNIX
  6955.     ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL);
  6956. #else
  6957.     ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL);
  6958. #endif /* UNIX */
  6959.     debug(F110,"MANUAL",tmpbuf,0);
  6960.     if (nopush) {
  6961.     printf("?Sorry, access to system commands is disabled.\n");
  6962.     return(-9);
  6963.     } else {
  6964.     conres();            /* Restore the console */
  6965.     success = zshcmd(tmpbuf);
  6966.     concb((char)escape);        /* Restore CBREAK mode */
  6967.     return(success);
  6968.     }
  6969. }
  6970. #endif /* NOHELP */
  6971.  
  6972. #ifndef NOHTTP
  6973. #ifdef TCPSOCKET
  6974. static struct keytab sslswtab[] = {
  6975.     { "/ssl", 1, 0 },
  6976.     { "/tls", 1, 0 }
  6977. };
  6978.  
  6979. #ifndef NOURL
  6980. struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  6981. #endif /* NOURL */
  6982.  
  6983. static int
  6984. dohttp() {                /* HTTP */
  6985.     struct FDB sw, kw, fi;
  6986.     int n, getval, allinone = 0;
  6987.     char c, * p;
  6988.     char rdns[128];
  6989.  
  6990.     char * http_agent = NULL;        /* Parse results */
  6991.     char * http_hdr   = NULL;
  6992.     char * http_user  = NULL;
  6993.     char * http_pass  = NULL;
  6994.     char * http_mime  = NULL;
  6995.     char * http_lfile = NULL;
  6996.     char * http_rfile = NULL;
  6997.     char * http_dfile = NULL;
  6998.     char   http_array = NUL;
  6999.     int    http_action = -1;
  7000.  
  7001.     char * http_host = NULL;
  7002.     char * http_srv  = NULL;
  7003.     int    http_ssl  = 0;
  7004.  
  7005.     static char * http_d_agent = NULL;
  7006.     static char * http_d_user = NULL;
  7007.     static char * http_d_pass = NULL;
  7008.  
  7009.     static int    http_d_type = 0;
  7010.     int           http_type = http_d_type;
  7011.  
  7012. #ifdef OS2
  7013.     p = "Kermit 95";            /* Default user agent */
  7014. #else
  7015.     p = "C-Kermit";
  7016. #endif /* OS2 */
  7017.     makestr(&http_agent,p);
  7018.     makestr(&http_mime,"text/HTML");    /* MIME type default */
  7019.     rdns[0] = '\0';
  7020.  
  7021.     cmfdbi(&sw,                /* 1st FDB - general switches */
  7022.        _CMKEY,                /* fcode */
  7023.        "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */
  7024.        "",                /* default */
  7025.        "",                /* addtl string data */
  7026.        nhttpswtab,            /* addtl numeric data 1: tbl size */
  7027.        4,                /* addtl numeric data 2: 4 = cmswi */
  7028.        xxstring,            /* Processing function */
  7029.        httpswtab,            /* Keyword table */
  7030.        &kw                /* Pointer to next FDB */
  7031.        );
  7032.     cmfdbi(&kw,                /* 2nd FDB - commands */
  7033.        _CMKEY,                /* fcode */
  7034.        "Command",            /* hlpmsg */
  7035.        "",                /* default */
  7036.        "",                /* addtl string data */
  7037.        nhttptab,            /* addtl numeric data 1: tbl size */
  7038.        0,                /* addtl numeric data 2: 0 = keyword */
  7039.        xxstring,            /* Processing function */
  7040.        httptab,                /* Keyword table */
  7041.        NULL                /* Pointer to next FDB */
  7042.        );
  7043.  
  7044.     while (1) {
  7045.     x = cmfdb(&sw);            /* Parse something */
  7046.     if (x < 0)            /* Error */
  7047.       goto xhttp;
  7048.     n = cmresult.nresult;
  7049.     if (cmresult.fdbaddr == &kw)    /* Command - exit this loop */
  7050.       break;
  7051.     c = cmgbrk();            /* Switch... */
  7052.     getval = (c == ':' || c == '=');
  7053.     x = -9;
  7054.     if (getval && !(cmgkwflgs() & CM_ARG)) {
  7055.         printf("?This switch does not take an argument\n");
  7056.         goto xhttp;
  7057.     }
  7058.     switch (cmresult.nresult) {    /* Handle each switch */
  7059.           case HT_SW_TP:                /* /TOSCREEN */
  7060.             http_type = 1;
  7061.             break;
  7062.       case HT_SW_AG:        /* /AGENT */
  7063.         if (getval) {
  7064.         if ((x = cmfld("User agent",p,&s,xxstring)) < 0)
  7065.           goto xhttp;
  7066.         } else {
  7067.         s = p;
  7068.         }
  7069.         makestr(&http_agent,s);
  7070.         break;
  7071.       case HT_SW_HD:        /* /HEADER */
  7072.         s = NULL;
  7073.         if (getval) {
  7074.         if ((x = cmfld("Header line","",&s,xxstring)) < 0) {
  7075.             if (x == -3)
  7076.               s = NULL;
  7077.             else
  7078.               goto xhttp;
  7079.         }
  7080.         }
  7081.         makestr(&http_hdr,s);
  7082.         break;
  7083.       case HT_SW_US:        /* /USER */
  7084.         s = NULL;
  7085.         if (getval) {
  7086.         if ((x = cmfld("User ID","",&s,xxstring)) < 0) {
  7087.                   if (x == -3)
  7088.                     s = "";
  7089.                   else
  7090.             goto xhttp;
  7091.                 }
  7092.         }
  7093.         makestr(&http_user,s);
  7094.         break;
  7095.       case HT_SW_PW:        /* /PASSWORD */
  7096.         debok = 0;
  7097.         s = NULL;
  7098.         if (getval) {
  7099.         if ((x = cmfld("Password","",&s,xxstring)) < 0)
  7100.           goto xhttp;
  7101.         }
  7102.         makestr(&http_pass,s);
  7103.         break;
  7104. #ifndef NOSPL
  7105.       case HT_SW_AR: {        /* /ARRAY: */
  7106.           char * s2, array = NUL;
  7107.           if (!getval) {
  7108.           printf("?This switch requires an argument\n");
  7109.           x = -9;
  7110.           goto xhttp;
  7111.           }
  7112.           if ((x = cmfld("Array name (a single letter will do)",
  7113.                  "",
  7114.                  &s,
  7115.                  NULL
  7116.                  )) < 0) {
  7117.           if (x == -3) {
  7118.               printf("?Array name required\n");
  7119.               x = -9;
  7120.               goto xhttp;
  7121.           } else
  7122.             goto xhttp;
  7123.           }
  7124.           if (!*s) {
  7125.           printf("?Array name required\n");
  7126.           x = -9;
  7127.           goto xhttp;
  7128.           }
  7129.           s2 = s;
  7130.           if (*s == CMDQ) s++;
  7131.           if (*s == '&') s++;
  7132.           if (!isalpha(*s)) {
  7133.           printf("?Bad array name - \"%s\"\n",s2);
  7134.           x = -9;
  7135.           goto xhttp;
  7136.           }
  7137.           array = *s++;
  7138.           if (isupper(array))
  7139.         array = tolower(array);
  7140.           if (*s && (*s != '[' || *(s+1) != ']')) {
  7141.           printf("?Bad array name - \"%s\"\n",s2);
  7142.           http_array = NUL;
  7143.           x = -9;
  7144.           goto xhttp;
  7145.           }
  7146.           http_array = array;
  7147.           break;
  7148.       }
  7149. #endif /* NOSPL */
  7150.       default:
  7151.         x = -2;
  7152.         goto xhttp;
  7153.     }
  7154.     }
  7155.     http_action = n;            /* Save the action */
  7156.     if (http_action == HTTP_PUT || http_action == HTTP_POS) {
  7157.     cmfdbi(&sw,            /* 1st FDB - switch */
  7158.            _CMKEY,            /* fcode */
  7159.            "Local filename\n Or switch", /* help */
  7160.            "",            /* default */
  7161.            "",            /* addtl string data */
  7162.            nhttpptab,        /* keyword table size */
  7163.            4,            /* addtl numeric data 2: 4 = cmswi */
  7164.            xxstring,        /* Processing function */
  7165.            httpptab,        /* Keyword table */
  7166.            &fi            /* Pointer to next FDB */
  7167.            );
  7168.     cmfdbi(&fi,            /* 2nd FDB - filename */
  7169.            _CMIFI,            /* fcode */
  7170.            "Local filename",    /* hlpmsg */
  7171.            "",            /* default */
  7172.            "",            /* addtl string data */
  7173.            0,            /* addtl numeric data 1 */
  7174.            0,            /* addtl numeric data 2 */
  7175.            xxstring,
  7176.            NULL,
  7177.            NULL
  7178.            );
  7179.     while (1) {
  7180.         x = cmfdb(&sw);
  7181.         if (x < 0)
  7182.           goto xhttp;        /* Free any malloc'd temp strings */
  7183.         n = cmresult.nresult;
  7184.         if (cmresult.fcode != _CMKEY)
  7185.           break;
  7186.         c = cmgbrk();        /* Switch... */
  7187.         getval = (c == ':' || c == '=');
  7188.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  7189.         printf("?This switch does not take an argument\n");
  7190.         x = -9;
  7191.         goto xhttp;
  7192.         }
  7193.         switch (n) {
  7194.           case HT_PP_MT:
  7195.         s = "text/HTML";
  7196.         if (getval) {
  7197.             if ((x = cmfld("MIME type",
  7198.                    "text/HTML",&s,xxstring)) < 0)
  7199.               goto xhttp;
  7200.         }
  7201.         makestr(&http_mime,s);
  7202.         break;
  7203.           default:
  7204.         x = -2;
  7205.         goto xhttp;
  7206.         }
  7207.     }
  7208.     makestr(&http_lfile,cmresult.sresult);
  7209.     n = ckindex("/",http_lfile,-1,1,0);
  7210.     if (n)
  7211.       p = &http_lfile[n];
  7212.     else
  7213.       p = http_lfile;
  7214.     if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) {
  7215.           if (x == -3) {
  7216.             printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post");
  7217.             x = -9;
  7218.           }
  7219.           goto xhttp;
  7220.         }
  7221.     if (!*s) s = NULL;
  7222.     makestr(&http_rfile,s);
  7223.  
  7224.     if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) {
  7225.           if (x != -3)
  7226.             goto xhttp;
  7227.         }
  7228.         if (*s)
  7229.           makestr(&http_dfile,s);
  7230.     }
  7231.     switch (http_action) {
  7232.       case HTTP_DEL:            /* DELETE */
  7233.     if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7234.           if (x == -3) {
  7235.             printf("?Delete what?\n");
  7236.             x = -9;
  7237.           }
  7238.           goto xhttp;
  7239.         }
  7240.     makestr(&http_rfile,s);
  7241.     break;
  7242.       case HTTP_CON:            /* CONNECT */
  7243.         if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) {
  7244.           if (x == -3) {
  7245.             printf("?Remote host[:port] is required\n");
  7246.             x = -9;
  7247.           }
  7248.           goto xhttp;
  7249.         }
  7250.     makestr(&http_rfile,s);
  7251.     break;
  7252.       case HTTP_HED: {            /* HEAD */
  7253.       char buf[CKMAXPATH+1];
  7254.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7255.           if (x == -3) {
  7256.           printf("?Head of what?\n");
  7257.           x = -9;
  7258.           }
  7259.           goto xhttp;
  7260.       }
  7261.       makestr(&http_rfile,s);
  7262.  
  7263.       if (http_array || http_type) { /* Default result filename */
  7264.           p = "";             /* None if /ARRAY or /TOSCREEN */
  7265.       } else {
  7266.           n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */
  7267.           if (n)                          /* and add ".head" */
  7268.         p = &http_rfile[n];
  7269.           else
  7270.         p = http_rfile;
  7271.           ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL);
  7272.           p = buf;
  7273.       }
  7274.       if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) {
  7275.           if (x != -3)
  7276.         goto xhttp;
  7277.       }
  7278.       makestr(&http_lfile,s);
  7279.       break;
  7280.       }
  7281.       case HTTP_GET:            /* GET */
  7282.       case HTTP_IDX: {            /* INDEX */
  7283.       char * lfile = "";
  7284.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7285.           if (x == -3) {
  7286.           printf("?Get what?\n");
  7287.           x = -9;
  7288.           }
  7289.           goto xhttp;
  7290.       }
  7291.       makestr(&http_rfile,s);
  7292.       if (http_action == HTTP_GET && !http_type)
  7293.         zstrip(http_rfile,&lfile);
  7294.       if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0)
  7295.         if (x != -3)
  7296.           goto xhttp;
  7297.       makestr(&http_lfile,s);
  7298.       break;
  7299.       }
  7300.       case HTTP_OPN: {
  7301.       int sslswitch = 0;
  7302. #ifdef CK_SSL
  7303.       struct FDB sw, fl;
  7304.       cmfdbi(&sw,
  7305.          _CMKEY,        /* fcode */
  7306.          "IP host name or address, or switch", /* hlpmsg */
  7307.          "",            /* default */
  7308.          "",            /* addtl string data */
  7309.          2,            /* addtl numeric data 1: tbl size */
  7310.          4,            /* addtl numeric data 2: 4 = cmswi */
  7311.          xxstring,        /* Processing function */
  7312.          sslswtab,        /* Keyword table */
  7313.          &fl            /* Pointer to next FDB */
  7314.          );
  7315.       cmfdbi(&fl,            /* 2nd FDB - host */
  7316.          _CMFLD,        /* fcode */
  7317.          "",            /* hlpmsg */
  7318.          "",            /* default */
  7319.          "",            /* addtl string data */
  7320.          0,            /* addtl numeric data 1 */
  7321.          0,            /* addtl numeric data 2 */
  7322.          xxstring,
  7323.          NULL,
  7324.          NULL
  7325.          );
  7326.       x = cmfdb(&sw);        /* Parse switch or host */
  7327.       if (x < 0)            /* Error */
  7328.         goto xhttp;
  7329.       if (cmresult.fcode == _CMFLD) { /* Host */
  7330.           s = cmresult.sresult;      /* Set up expected pointer */
  7331.           goto havehost;              /* Go parse rest of command */
  7332.       }
  7333.       sslswitch = 1;        /* /SSL or /TLS switch - set flag */
  7334. #endif /* CK_SSL */
  7335.  
  7336.       /* Parse host */
  7337.  
  7338.       if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) {
  7339.           if (x == -3) {
  7340.           printf("?Open what?\n");
  7341.           x = -9;
  7342.           }
  7343.           goto xhttp;
  7344.       }
  7345.  
  7346.     havehost:            /* Come here with s -> host */
  7347. #ifdef CK_URL
  7348.       x = urlparse(s,&http_url);    /* Was a URL given? */
  7349.       if (x < 1) {            /* Not a URL */
  7350. #endif /* CK_URL */
  7351.           makestr(&http_host,s);
  7352.           if ((x =
  7353.            cmfld("Service name or port number",
  7354.              "http",&s,xxstring)) < 0)
  7355.         goto xhttp;
  7356.           else
  7357.         makestr(&http_srv,s);
  7358. #ifdef CK_URL
  7359.       } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */
  7360.              ckstrcmp(http_url.svc,"https",-1,0)) {
  7361.           printf("?Non-HTTP URL\n");
  7362.           x = -9;
  7363.           goto xhttp;
  7364.       } else {            /* Have HTTP URL */
  7365.           makestr(&http_srv, http_url.svc);
  7366.           makestr(&http_user,http_url.usr);
  7367.           makestr(&http_pass,http_url.psw);
  7368.           makestr(&http_host,http_url.hos);
  7369.           if (http_url.por)
  7370.         makestr(&http_srv,http_url.por);
  7371.           makestr(&http_rfile,http_url.pth);
  7372.       }
  7373.       if (http_rfile) {        /* Open, GET, and Close */
  7374.           printf("?Directory/file path not allowed in HTTP OPEN URL\n");
  7375.           x = -9;
  7376.           goto xhttp;
  7377.       }
  7378.       if (!ckstrcmp("https",http_srv,-1,0) || sslswitch ||
  7379.           !ckstrcmp("443",http_srv,-1,0))
  7380.         http_ssl = 1;
  7381. #endif /* CK_URL */
  7382.       break;
  7383.       }
  7384.       case HTTP_CLS:
  7385.         break;
  7386.     }
  7387.     if ((x = cmcfm()) < 0)
  7388.       goto xhttp;
  7389.  
  7390.     if (http_action == HTTP_OPN) {
  7391.         x = (http_open(http_host,http_srv,http_ssl,rdns,128) == 0);
  7392.         if (x) {
  7393.             if (!quiet) {
  7394.               if (rdns[0])
  7395.                 printf("Connected to %s [%s]\r\n",http_host,rdns);
  7396.               else
  7397.                 printf("Connected to %s\r\n",http_host);
  7398.             }
  7399.             if (http_agent) {
  7400.                 if (http_d_agent)
  7401.           free(http_d_agent);
  7402.                 http_d_agent = http_agent;
  7403.                 http_agent = NULL;
  7404.             }
  7405.             if (http_user) {
  7406.                 if (http_d_user)
  7407.           free(http_d_user);
  7408.                 http_d_user = http_user;
  7409.                 http_user = NULL;
  7410.             }
  7411.             if (http_pass) {
  7412.                 if (http_d_pass) {
  7413.                     memset(http_d_pass,0,strlen(http_d_pass));
  7414.                     free(http_d_pass);
  7415.                 }
  7416.                 http_d_pass = http_pass;
  7417.                 http_pass = NULL;
  7418.             }
  7419.             http_d_type = http_type;
  7420.         } else {
  7421.             if (!quiet)
  7422.           printf("?HTTP Connection failed.\r\n");
  7423.         }
  7424.     } else if (http_action == HTTP_CLS) {
  7425.         if (http_d_agent) {
  7426.             free(http_d_agent);
  7427.             http_d_agent = NULL;
  7428.         }
  7429.         if (http_d_user) {
  7430.             free(http_d_user);
  7431.             http_d_user = NULL;
  7432.         }
  7433.         if (http_d_pass) {
  7434.             memset(http_d_pass,0,strlen(http_d_pass));
  7435.             free(http_d_pass);
  7436.             http_d_pass = NULL;
  7437.         }
  7438.         http_d_type = 0;
  7439.         x = (http_close() == 0);
  7440.     }
  7441.     if ((http_action != HTTP_CLS) &&
  7442.     (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */
  7443.  
  7444.     /* All-in-one actions when a URL is given... */
  7445.  
  7446. #ifdef CK_URL
  7447.     if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */
  7448.         if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */
  7449.         ckstrcmp(http_url.svc,"https",-1,0)) {
  7450.         printf("?Non-HTTP URL\n");
  7451.         x = -9;
  7452.         goto xhttp;
  7453.         } else {            /* Yes, collect the pieces */
  7454.         makestr(&http_srv, http_url.svc);
  7455.         makestr(&http_user,http_url.usr);
  7456.         makestr(&http_pass,http_url.psw);
  7457.         makestr(&http_host,http_url.hos);
  7458.         if (http_url.por)
  7459.           makestr(&http_srv,http_url.por);
  7460.         makestr(&http_rfile,http_url.pth);
  7461.         }
  7462.         if (!http_rfile) {        /* Still have a path? */
  7463.                 makestr(&http_rfile,"/");
  7464.         }
  7465.         if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */
  7466.         !ckstrcmp("443",http_srv,-1,0))
  7467.           http_ssl = 1;
  7468.         if (http_isconnected())    /* Close any open HTTP connection */
  7469.           http_close();
  7470.         if (http_pass == NULL && http_d_pass != NULL)
  7471.           makestr(&http_pass,http_d_pass);
  7472.         x = (http_open(http_host,http_srv,http_ssl,rdns,128) == 0);
  7473.         if (x < 0) {
  7474.         x = 0;
  7475.         goto xhttp;
  7476.         }
  7477.         allinone = 1;
  7478.     }
  7479. #endif /* CK_URL */
  7480.         if (http_pass == NULL && http_d_pass != NULL)
  7481.       makestr(&http_pass,http_d_pass);
  7482.  
  7483.     if (http_action == HTTP_OPN && allinone) {
  7484.         http_action = HTTP_GET;
  7485.     }
  7486.         x = xdohttp(http_action,
  7487.                     http_lfile,
  7488.             http_rfile,
  7489.                     http_dfile,
  7490.             http_agent ? http_agent : http_d_agent,
  7491.             http_hdr,
  7492.             http_user  ? http_user  : http_d_user,
  7493.             http_pass  ? http_pass  : http_d_pass,
  7494.             http_mime,
  7495.             http_array,
  7496.             http_type
  7497.             );
  7498.     if (allinone)
  7499.       x = (http_close() == 0);
  7500.     }
  7501.  
  7502.   xhttp:
  7503.     if (http_agent) free(http_agent);
  7504.     if (http_hdr)   free(http_hdr);
  7505.     if (http_user)  free(http_user);
  7506.     if (http_pass) {
  7507.         memset(http_pass,0,strlen(http_pass));
  7508.         free(http_pass);
  7509.     }
  7510.     if (http_mime)  free(http_mime);
  7511.     if (http_lfile) free(http_lfile);
  7512.     if (http_rfile) free(http_rfile);
  7513.     if (http_dfile) free(http_dfile);
  7514.     if (http_host)  free(http_host);
  7515.     if (http_srv)   free(http_srv);
  7516.  
  7517.     if (x > -1)
  7518.       success = x;
  7519.     return(x);
  7520. }
  7521. #endif /* TCPSOCKET */
  7522. #endif /* NOHTTP */
  7523.  
  7524.  
  7525. #ifndef NOSPL
  7526. static int
  7527. dotrace() {
  7528.     int on = 1;
  7529.     struct FDB sw, kw;
  7530.     cmfdbi(&sw,                /* 1st FDB - switch */
  7531.        _CMKEY,            /* fcode */
  7532.        "Trace object;\n Or switch", /* help */
  7533.        "",                /* default */
  7534.        "",                /* addtl string data */
  7535.        2,                /* keyword table size */
  7536.        4,                /* addtl numeric data 2: 4 = cmswi */
  7537.        xxstring,            /* Processing function */
  7538.        onoffsw,            /* Keyword table */
  7539.        &kw                /* Pointer to next FDB */
  7540.        );
  7541.     cmfdbi(&kw,                /* 2nd FDB - Trace object */
  7542.        _CMKEY,            /* fcode */
  7543.        "Trace object",        /* help */
  7544.        "all",            /* default */
  7545.        "",                /* addtl string data */
  7546.        ntracetab,            /* keyword table size */
  7547.        0,                /* addtl numeric data 2: 0 = keyword */
  7548.        xxstring,            /* Processing function */
  7549.        tracetab,            /* Keyword table */
  7550.        NULL                /* Pointer to next FDB */
  7551.        );
  7552.     if ((x = cmfdb(&sw)) < 0)
  7553.       return(x);
  7554.     if (cmresult.fdbaddr == &sw) {
  7555.     on = cmresult.nresult;
  7556.     if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0)
  7557.       return(x);
  7558.     } else {
  7559.     x = cmresult.nresult;
  7560.     }
  7561.     if ((y = cmcfm()) < 0)
  7562.       return(y);
  7563.  
  7564.     switch (x) {
  7565.       case TRA_ASG:
  7566.     tra_asg = on;
  7567.     break;
  7568.       case TRA_CMD:
  7569.     tra_cmd = on;
  7570.     break;
  7571.       case TRA_ALL:
  7572.     tra_asg = on;
  7573.     tra_cmd = on;
  7574.     break;
  7575.       default:
  7576.     return(-2);
  7577.     }
  7578.     printf("TRACE %s\n", on ? "ON" : "OFF");
  7579.     return(success = 1);
  7580. }
  7581. #endif /* NOSPL */
  7582.  
  7583.  
  7584. static int
  7585. doprompt() {
  7586.     extern int xcmdsrc;
  7587.     if ((x = cmtxt("Optional message","",&s,xxstring)) < 0)
  7588.       return(x);
  7589. #ifdef NOSPL
  7590.     printf("?Sorry, PROMPT requires script programming language\n");
  7591.     return(-9);
  7592. #else
  7593.     debug(F101,"Prompt cmdlvl","",cmdlvl);
  7594.     cmdlvl++;
  7595.     if (cmdlvl > CMDSTKL) {
  7596.     printf("?Command stack overflow: %d\n",cmdlvl);
  7597.     cmdlvl--;
  7598.     return(-9);
  7599.     }
  7600.     xcmdsrc = CMD_KB;
  7601.     cmdstk[cmdlvl].src = CMD_KB;    /* Say we're at the prompt */
  7602.     cmdstk[cmdlvl].lvl = 0;
  7603.     cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs;
  7604.     if (tra_cmd)
  7605.       printf("[%d] +P: \"(prompt)\"\n",cmdlvl);
  7606.     concb((char)escape);
  7607.     if (!quiet)
  7608.       printf(
  7609. "(Recursive command prompt: Resume script with CONTINUE, STOP to stop...)\n"
  7610.             );
  7611.     if (*s) {                /* If prompt given */
  7612.     makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */
  7613.     cmsetp(s);            /* Set new one */
  7614.     }
  7615.     return(success = 1);
  7616. #endif /* NOSPL */
  7617. }
  7618.  
  7619. #ifdef CKLEARN
  7620. VOID
  7621. learncmd(s) char *s; {            /* Record commands in learned script */
  7622.     char buf[64];
  7623.     int i, k;
  7624.     if (learnfp && learning) {        /* Only if open and on */
  7625.     k = ckstrncpy(buf,s,64);
  7626.     for (i = 0; i < k; i++) {    /* Get top-level command keyword */
  7627.         if (buf[i] <= SP) {
  7628.         buf[i] = NUL;
  7629.         break;
  7630.         }
  7631.     }
  7632.     k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */
  7633.     if (k == XXCON || k == XXLEARN)      /* Don't record CONNECT or LEARN */
  7634.       return;
  7635.     if (k == XXTEL) {
  7636.         fputs("SET HOST /NETWORK:TCP",learnfp);
  7637.         fputs(&s[i],learnfp);
  7638.         fputs(" TELNET /TELNET",learnfp);
  7639.         fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp);
  7640.     } else {
  7641.         fputs(s,learnfp);
  7642.         fputs("\n",learnfp);
  7643.     }
  7644.     }
  7645. }
  7646. #endif /* CKLEARN */
  7647.  
  7648.  
  7649. /*  D O C M D  --  Do a command  */
  7650.  
  7651. /*
  7652.  Returns:
  7653.    -2: user typed an illegal command
  7654.    -1: reparse needed
  7655.     0: parse was successful (even tho command may have failed).
  7656. */
  7657. #ifdef DEBUG
  7658. int cmdstats[256] = { -1, -1 };
  7659. #endif /* DEBUG */
  7660.  
  7661. int
  7662. docmd(cx) int cx; {
  7663.     extern int nolocal, cmkwflgs;
  7664.  
  7665.     debug(F101,"docmd entry, cx","",cx);
  7666.     activecmd = cx;
  7667.     doconx = ((activecmd == XXCON)  || (activecmd == XXTEL) ||
  7668.           (activecmd == XXRLOG) || (activecmd == XXPIPE) ||
  7669.               (activecmd == XXIKSD) || (activecmd == XXPTY));
  7670. /*
  7671.   Originally all commands were handled with a big switch() statement,
  7672.   but eventually this started blowing up compilers.  Now we have a series
  7673.   of separate if statements and small switches, with the commands that are
  7674.   most commonly executed in scipts and loops coming first, to speed up
  7675.   compute-bound scripts.
  7676.   */
  7677.  
  7678. #ifdef DEBUG
  7679.     if (cmdstats[0] == -1) {        /* Count commands */
  7680.     int i;                /* for tuning... */
  7681.     for (i = 0; i < 256; i++)
  7682.       cmdstats[i] = 0;
  7683.     }
  7684. #endif /* DEBUG */
  7685.  
  7686.     switch (cx) {
  7687.       case -4:                /* EOF */
  7688. #ifdef OSK
  7689.     if (msgflg)  printf("\n");
  7690. #else
  7691.     if (msgflg)  printf("\r\n");
  7692. #endif /* OSK */
  7693.       doexit(GOOD_EXIT,xitsta);
  7694.       case -3:                /* Null command */
  7695.     return(0);
  7696.       case -9:                /* Like -2, but errmsg already done */
  7697.       case -1:                /* Reparse needed */
  7698.     return(cx);
  7699.       case -6:                /* Special */
  7700.       case -2:                /* Error, maybe */
  7701.  
  7702. #ifndef NOSPL
  7703. /*
  7704.   Maybe they typed a macro name.  Let's look it up and see.
  7705. */
  7706.     if (cx == -6)            /* If they typed CR */
  7707.       ckstrncat(cmdbuf,"\015",CMDBL); /*  add it back to command buffer. */
  7708.     if (ifcmd[cmdlvl] == 2)        /* Watch out for IF commands. */
  7709.       ifcmd[cmdlvl]--;
  7710.     repars = 1;            /* Force reparse */
  7711.     cmres();
  7712.     cx = XXDO;            /* Try DO command */
  7713. #else
  7714.     return(cx);
  7715. #endif /* NOSPL */
  7716.       default:
  7717.     if (cx < 0)
  7718.       return(cx);
  7719.     break;
  7720.     }
  7721. #ifdef DEBUG
  7722.     if (cx < 256)
  7723.       cmdstats[cx]++;
  7724. #endif /* DEBUG */
  7725.  
  7726.     if ((cmkwflgs & CM_PSH)
  7727. #ifndef NOPUSH
  7728.     && nopush
  7729. #endif /* NOPUSH */
  7730.     ) {
  7731.     printf("?Access to system disabled\n");
  7732.     return(-9);
  7733.     }
  7734.     if ((cmkwflgs & CM_LOC)
  7735. #ifndef NOLOCAL
  7736.     && nolocal
  7737. #endif /* NOLOCAL */
  7738.     ) {
  7739.     printf("?Connections disabled\n");
  7740.     return(-9);
  7741.     }
  7742.  
  7743. #ifndef NOSPL
  7744.     /* Used in FOR loops */
  7745.  
  7746.     if (cx == XX_INCR || cx == XXINC  || /* _INCREMENT, INCREMENT */
  7747.     cx == XX_DECR || cx == XXDEC)     /* _DECREMENT, DECREMENT */
  7748.       return(doincr(cx));
  7749.  
  7750.     /* Define (or change the definition of) a macro or variable */
  7751.  
  7752.     if (cx == XXUNDEF || cx == XXUNDFX) {
  7753. #ifdef IKSD
  7754.     if (inserver && !ENABLED(en_asg)) {
  7755.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7756.         return(-9);
  7757.     }
  7758. #endif /* IKSD */
  7759.     return(doundef(cx));        /* [_]UNDEFINE */
  7760.     }
  7761.     if (cx == XXDEF || cx == XXASS ||
  7762.     cx == XXDFX || cx == XXASX) {
  7763. #ifdef IKSD
  7764.     if (inserver && !ENABLED(en_asg)) {
  7765.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7766.         return(-9);
  7767.     }
  7768. #endif /* IKSD */
  7769.     if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */
  7770.       xxdot = 1;            /* i.e. with space after it... */
  7771.     return(dodef(cx));        /* DEFINE, ASSIGN, etc... */
  7772.     }
  7773.  
  7774.     /* IF, WHILE, and friends  */
  7775.  
  7776.     if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) {
  7777.     return(doif(cx));
  7778.     }
  7779.     if (cx == XXSWIT) {            /* SWITCH */
  7780.     return(doswitch());
  7781.     }
  7782.  
  7783.     /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */
  7784.  
  7785.     if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */
  7786.     /* Note, here we don't set SUCCESS/FAILURE flag */
  7787. #ifdef COMMENT
  7788.     if ((y = cmfld("label","",&s,xxstring)) < 0) {
  7789.         if (y == -3) {
  7790.         if (cx != XXXFWD) {
  7791.             printf("?Label name required\n");
  7792.             return(-9);
  7793.         }
  7794.         } else
  7795.           return(y);
  7796.     }
  7797.     ckstrncpy(lblbuf,s,LBLSIZ);
  7798.     if ((x = cmcfm()) < 0) return(x);
  7799. #else
  7800.     if ((y = cmtxt("label","",&s,xxstring)) < 0) {
  7801.         if (y == -3) {
  7802.         if (cx != XXXFWD) {
  7803.             printf("?GOTO: Label name required: \"%s\" \"%s\"\n",
  7804.                atmbuf,
  7805.                cmdbuf);
  7806.             return(-9);
  7807.         }
  7808.         } else
  7809.           return(y);
  7810.     }
  7811.     ckstrncpy(lblbuf,brstrip(s),LBLSIZ);
  7812. #endif /* COMMENT */
  7813.     s = lblbuf;
  7814.     return(dogoto(s,cx));
  7815.     }
  7816.     if (cx == XXDO || cx == XXMACRO) {    /* DO (a macro) */
  7817.     char mnamebuf[16];        /* (buffer for controlled temp name) */
  7818.     struct FDB kw, fl;
  7819.     int mx;                /* Macro index (on stack!) */
  7820.  
  7821.     debug(F101,"XXMACRO 0",line,cx);
  7822.     if (cx == XXDO) {
  7823.         if (nmac == 0) {
  7824.         printf("\n?No macros defined\n");
  7825.         return(-9);
  7826.         }
  7827.         for (y = 0; y < nmac; y++) { /* copy the macro table into a */
  7828.         mackey[y].kwd = mactab[y].kwd; /* regular keyword table */
  7829.         mackey[y].kwval = y;    /* with value = pointer to macro tbl */
  7830.         mackey[y].flgs = mactab[y].flgs;
  7831.         }
  7832.         cmfdbi(&kw,            /* First FDB - macro name */
  7833.            _CMKEY,        /* fcode */
  7834.            "Macro",        /* hlpmsg */
  7835.            "",            /* default */
  7836.            "",            /* addtl string data */
  7837.            nmac,        /* addtl numeric data 1: tbl size */
  7838.            0,            /* addtl numeric data 2: 0 = cmkey */
  7839.            xxstring,        /* Processing function */
  7840.            mackey,        /* Keyword table */
  7841.            &fl            /* Pointer to next FDB */
  7842.            );
  7843.         cmfdbi(&fl,            /* 2nd FDB - for "{" */
  7844.            _CMFLD,        /* fcode */
  7845.            "",            /* hlpmsg */
  7846.            "",
  7847.            "",            /* addtl string data */
  7848.            0,            /* addtl numeric data 1 */
  7849.            0,            /* addtl numeric data 2 */
  7850.            xxstring,
  7851.            NULL,
  7852.            NULL
  7853.            );
  7854.         x = cmfdb(&kw);        /* Parse something */
  7855.         if (x < 0) {        /* Error */
  7856.         if (x == -3) {
  7857.             printf("?Macro name required\n");
  7858.             return(-9);
  7859.         } else
  7860.           return(x);
  7861.         }
  7862.         if (cmresult.fcode == _CMKEY) {
  7863.         extern int mtchanged;
  7864.         char * macroname = NULL;
  7865.  
  7866.         /* In case args include an \fexec() that changes the macro table */
  7867.  
  7868.         mx = x;            /* Save macro index on stack */
  7869.         mtchanged = 0;        /* Mark state of macro table */
  7870.         makestr(¯oname,mactab[mx].kwd); /* Save name */
  7871.  
  7872.         if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0)
  7873.           return(y);        /* Get macro args */
  7874.  
  7875.         if (mtchanged) {    /* Macro table changed? */
  7876.             mx = mlook(mactab,macroname,nmac); /* Look up name again */
  7877.         }
  7878.         if (macroname)
  7879.           free(macroname);
  7880.  
  7881.         return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ?
  7882.                (success = 0) : 1);
  7883.         }
  7884.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);    /* _CMFLD */
  7885.         if (atmbuf[0] == '{') {
  7886.         if ((y = cmcfm()) < 0)
  7887.           return(y);
  7888.         }
  7889.     } else {            /* XXMACRO ("immediate macro") */
  7890.         int k = 0;
  7891.         line[k++] = '{';
  7892.         line[k++] = SP;
  7893.         line[k] = NUL;
  7894.         debug(F111,"XXMACRO A",line,k);
  7895.         /* Defer evaluation of variables until the commands are exec'd */
  7896.         if ((y = cmtxt("Braced list of commands","",&s,NULL)) < 0)
  7897.           return(y);
  7898.         k = ckstrncpy(line+k,s,LINBUFSIZ-k);
  7899.         debug(F111,"XXMACRO B",line,k);
  7900.     }
  7901.     x = strlen(line);
  7902.     if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
  7903.       return(-2);
  7904.     if (line[0] != '{' && line[x-1] != '}') {
  7905.         /* Unknown command.  If ON_UNKNOWN_COMMAND macro is defined, */
  7906.         /* parse args and then execute it, but only if it is not */
  7907.         /* already active. */
  7908.         int k = -1;
  7909.         if (!unkmacro) {
  7910.         k = mxlook(mactab,"on_unknown_command",nmac);
  7911.         }
  7912.         if (k > -1) {
  7913.         ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  7914.         z = maclvl;        /* Save the current maclvl */
  7915.         if ((y = cmtxt("text","",&s,xxstring)) < 0)
  7916.           return(y);
  7917.         ckstrncat(tmpbuf," ",TMPBUFSIZ);
  7918.         ckstrncat(tmpbuf,s,TMPBUFSIZ);
  7919.         unkmacro = 1;
  7920.         debug(F110,"ON_UNKNOWN_COMMAND",s,0);
  7921.         dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  7922.         while (maclvl > z) {
  7923.             sstate = (CHAR) parser(1);
  7924.             if (sstate) proto();
  7925.         }
  7926.         debug(F101,"UNKMAC loop exit maclvl","",maclvl);
  7927.         unkmacro = 0;
  7928.         return(success);
  7929.         }
  7930.             if (x > 0)
  7931.           printf("?Not a command or macro name: \"%s\"\n",line);
  7932.             else
  7933.           printf("?Not a command or macro name.\n");
  7934.         return(-9);
  7935.     }
  7936.     s = brstrip(line);
  7937.     sprintf(mnamebuf," ..tmp:%03d",cmdlvl);    /* safe (16) */
  7938.     x = addmac(mnamebuf,s);
  7939.     return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
  7940.     }
  7941.  
  7942.     if (cx == XXLBL) {            /* LABEL */
  7943.     if ((x = cmfld("label","",&s,xxstring)) < 0) {
  7944.         if (x == -3) {
  7945. #ifdef COMMENT
  7946.         printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
  7947.         return(-9);
  7948. #else
  7949.         s = "";
  7950. #endif /* COMMENT */
  7951.         } else return(x);
  7952.  
  7953.     }
  7954.     debug(F111,"LABEL",s,x);
  7955.     if ((x = cmcfm()) < 0) return(x);
  7956.     return(0);
  7957.     }
  7958.  
  7959.     if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE,  EVALUATE  */
  7960.       return(doeval(cx));
  7961.  
  7962. #ifndef NOSEXP
  7963.     if (cx == XXSEXP) {            /* Lisp-like S-Expression */
  7964.     struct stringarray * q;
  7965.     char /* *p, *r, */ *tmp, *m;
  7966.     int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
  7967.     extern int sexprc, sexppv;
  7968.  
  7969.     tmp = tmpbuf;            /* Buffer to collect SEXP */
  7970.     tmpbuf[0] = NUL;        /* Clear it */
  7971.     size = TMPBUFSIZ;        /* Capacity of buffer */
  7972.     sexprc = -1;            /* Assume bad input */
  7973.     n = 0;                /* Paren balance counter */
  7974.  
  7975.     while (1) {            /* Allow SEXP on multiple lines */
  7976.         m = contd ?
  7977.           "Continuation of S-Expression" :
  7978.         "S-Expression (\"help sexp\" for details)";
  7979.         x = cmtxt(m,"",&s,xxstring);
  7980.         if (x < 0)
  7981.           return(x);
  7982.         if (!*s)            /* Needed for (=) and (:) */
  7983.           s = atmbuf;
  7984.         k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
  7985.         if (k < 1) {
  7986.         printf("?SEXP too long - %d max\n",TMPBUFSIZ);
  7987.         return(-9);
  7988.         }
  7989.         debug(F111,contd ? "sexp contd" : "sexp",s,k);
  7990.  
  7991.         for (i = len; i < len+k; i++) { /* Check balance  */
  7992.         if (!quote && tmpbuf[i] == CMDQ) {
  7993.             quote = 1;
  7994.             continue;
  7995.         }
  7996.         if (quote) {
  7997.             quote = 0;
  7998.             continue;
  7999.         }
  8000.         if (tmpbuf[i] == '(')
  8001.           n++;
  8002.         else if (tmpbuf[i] == ')')
  8003.           n--;
  8004.         }
  8005.         if (n == 0) {        /* Break when balanced */
  8006.         break;
  8007.         }
  8008.         if (n < 0) {        /* Too many right parens */
  8009.         printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
  8010.         return(-9);
  8011.         }
  8012.         contd++;            /* Need more right parens */
  8013.         cmini(ckxech);        /* so keep parsing */
  8014.         tmp += k;            /* adjust buffer pointer */
  8015.         size -= k;            /* and capacity */
  8016.         len += k;            /* and length so far */
  8017.     }
  8018.     s = tmpbuf;
  8019.     makestr(&lastsexp,s);
  8020.     q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */
  8021.     debug(F101,"sexp split","",q->a_size);
  8022.  
  8023.     if (q->a_size == 1) {        /* We should get exactly one back */
  8024.         char * result, * dosexp();
  8025.         sexprc = 0;            /* Reset out-of-band return code */
  8026.         result = dosexp(s);        /* Get result */
  8027.         debug(F111,"sexp result",result,sexprc);
  8028.         if (sexprc == 0) {        /* Success */
  8029.         /* Echo the result if desired */
  8030.         if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
  8031.           printf(" %s\n",result ? result : "");
  8032.         makestr(&sexpval,result);
  8033.         success = sexppv > -1 ? sexppv : 1;
  8034.         return(success);
  8035.         }
  8036.     }
  8037.     if (sexprc < 0)
  8038.       printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
  8039.     return(-9);
  8040.     }
  8041. #endif /* NOSEXP */
  8042.  
  8043. #endif /* NOSPL */
  8044.  
  8045.     if (cx == XXECH || cx == XXXECH || cx == XXVOID
  8046. #ifndef NOSPL
  8047.     || cx == XXAPC
  8048. #endif /* NOSPL */
  8049.     ) {                /* ECHO or APC */
  8050.     if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
  8051.                "Text to be echoed" :
  8052.                ((cx == XXVOID) ? "Text" :
  8053.             "Application Program Command text"),
  8054.                "",
  8055.                &s,
  8056.                xxstring
  8057.                )
  8058.          ) < 0)
  8059.       return(x);
  8060.     if (!s) s = "";
  8061. #ifdef COMMENT
  8062. /* This is to preserver the pre-8.0 behavior but it's too confusing */
  8063.     x = strlen(s);
  8064.     x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
  8065. #endif /* COMMENT */
  8066.     s = brstrip(s);            /* Strip braces and doublequotes */
  8067.     if (cx == XXECH) {        /* ECHO */
  8068. #ifndef NOSPL
  8069.         if (!fndiags || fnsuccess) {
  8070. #endif /* NOSPL */
  8071. #ifdef COMMENT
  8072.         /* The "if (x)" business preserves previous behavior */
  8073.         /* by putting back the doublequotes if they were included. */
  8074.         if (x)
  8075.           printf("\"%s\"\n",s);
  8076.         else
  8077. #endif /* COMMENT */
  8078.           printf("%s\n",s);
  8079. #ifndef NOSPL
  8080.         }
  8081. #endif /* NOSPL */
  8082.     } else if (cx == XXXECH) {    /* XECHO */
  8083.         if (x)
  8084.           printf("\"%s\"",s);
  8085.         else
  8086.           printf("%s",s);
  8087. #ifdef UNIX
  8088.         fflush(stdout);
  8089. #endif /* UNIX */
  8090.     } else if (cx == XXAPC) {    /* APC */
  8091. #ifdef CK_APC
  8092.         if (apcactive == APC_LOCAL ||
  8093.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  8094.           return(success = 0);
  8095. #endif /* CK_APC */
  8096.         if (!local) {
  8097.         printf("%c_%s%c\\",ESC,s,ESC);
  8098. #ifdef UNIX
  8099.         fflush(stdout);
  8100. #endif /* UNIX */
  8101.  
  8102.         } else {            /* Local mode - have connection */
  8103. #ifndef NOSPL
  8104.         if (ckmakxmsg(tmpbuf,    /* Form APC string in buffer */
  8105.                   TMPBUFSIZ,
  8106.                   ckctoa((char)ESC),
  8107.                   ckctoa('_'),
  8108.                   s,
  8109.                   ckctoa((char)ESC),
  8110.                   ckctoa('\\'),
  8111.                   NULL,NULL,NULL,NULL,NULL,NULL,NULL
  8112.                   ) > 0)
  8113.           return(success = dooutput(tmpbuf, XXOUT));
  8114.         printf("?Too long\n");
  8115.         return(-9);
  8116. #else
  8117.         printf("%c_%s%c\\",ESC,s,ESC);
  8118. #endif /* NOSPL */
  8119.         }
  8120.     }
  8121.     return(success = 1);
  8122.     }
  8123.  
  8124. #ifndef NOSPL
  8125. /* Copy macro args from/to two levels up, used internally by _floop et al. */
  8126.     if (cx == XXGTA || cx == XXPTA) {    /* _GETARGS, _PUTARGS */
  8127.     int x;
  8128.     debug(F101,"docmd XXGTA","",XXGTA);
  8129.     debug(F101,"docmd cx","",cx);
  8130.     debug(F101,"docmd XXGTA maclvl","",maclvl);
  8131.     x = dogta(cx);
  8132.     debug(F101,"docmd dogta returns","",x);
  8133.     debug(F101,"docmd dogta maclvl","",maclvl);
  8134.     return(x);
  8135.     }
  8136. #endif /* NOSPL */
  8137.  
  8138. #ifndef NOSPL
  8139. #ifdef CKCHANNELIO
  8140.     if (cx == XXFILE)
  8141.       return(dofile(cx));
  8142.     else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
  8143.          cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
  8144.          cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
  8145.       return(dofile(cx));
  8146. #endif /* CKCHANNELIO */
  8147.  
  8148. /* ASK, ASKQ, READ */
  8149.     if (cx == XXASK  || cx == XXASKQ || cx == XXREA ||
  8150.     cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
  8151.     return(doask(cx));
  8152.     }
  8153. #endif /* NOSPL */
  8154.  
  8155. #ifndef NOFRILLS
  8156.     if (cx == XXBUG) {            /* BUG */
  8157.     if ((x = cmcfm()) < 0) return(x);
  8158.     return(dobug());
  8159.     }
  8160. #endif /* NOFRILLS */
  8161.  
  8162. #ifndef NOXFER
  8163.     if (cx == XXBYE) {            /* BYE */
  8164.     extern int ftp_cmdlin;
  8165.     if ((x = cmcfm()) < 0) return(x);
  8166.  
  8167. #ifdef NEWFTP
  8168.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  8169.         extern int stayflg, ftp_fai;
  8170.         success = ftpbye();
  8171.         if (ftp_cmdlin && !stayflg && !local)
  8172.           doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
  8173.         else
  8174.           return(success);
  8175.     }
  8176. #endif /* NEWFTP */
  8177.  
  8178.     if (!local) {
  8179.         printf("?No connection - use EXIT to quit.\n");
  8180.         return(-9);
  8181.     }
  8182.  
  8183. #ifdef CK_XYZ
  8184.     if (protocol != PROTO_K) {
  8185.         printf("?Sorry, BYE only works with Kermit protocol\n");
  8186.         return(-9);
  8187.     }
  8188. #endif /* CK_XYZ */
  8189.  
  8190. #ifdef IKS_OPTION
  8191.         if (
  8192. #ifdef CK_XYZ
  8193.             protocol == PROTO_K &&
  8194. #endif /* CK_XYZ */
  8195.             !iks_wait(KERMIT_REQ_START,1)) {
  8196.         printf(
  8197.          "?A Kermit Server is not available to process this command\n");
  8198.         return(-9);            /* Correct the return code */
  8199.         }
  8200. #endif /* IKS_OPTION */
  8201.  
  8202.     bye_active = 1;
  8203.     sstate = setgen('L',"","","");
  8204.     if (local) ttflui();        /* If local, flush tty input buffer */
  8205.     return(0);
  8206.     }
  8207. #endif /* NOXFER */
  8208.  
  8209.     if (cx == XXBEEP) {            /* BEEP */
  8210.         int x;
  8211. #ifdef OS2
  8212.     int y;
  8213.         if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
  8214.                xxstring)) < 0 )
  8215.       return (y);
  8216.         if ((x = cmcfm()) < 0) return(x);
  8217.         bleep((short)y);        /* y is one of the BP_ values */
  8218. #else  /* OS2 */
  8219.         if ((x = cmcfm()) < 0) return(x);
  8220. #ifndef NOSPL
  8221.         bleep(BP_NOTE);
  8222. #else
  8223.     putchar('\07');
  8224. #endif /* NOSPL */
  8225. #endif /* OS2 */
  8226.         return(0);
  8227.     }
  8228.  
  8229. #ifndef NOFRILLS
  8230.     if (cx == XXCLE)            /* CLEAR */
  8231.       return(success = doclear());
  8232. #endif /* NOFRILLS */
  8233.  
  8234.     if (cx == XXCOM) {            /* COMMENT */
  8235.     if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
  8236.       return(x);
  8237.     /* Don't change SUCCESS flag for this one */
  8238.     return(0);
  8239.     }
  8240.  
  8241. #ifndef NOLOCAL
  8242.     if (cx == XXCON || cx == XXCQ)    /* CONNECT or CONNECT /QUIETLY */
  8243.       return(doxconn(cx));
  8244. #endif /* NOLOCAL */
  8245.  
  8246. #ifndef NOFRILLS
  8247. #ifdef ZCOPY
  8248.     if (cx == XXCPY) {            /* COPY a file */
  8249. #ifdef IKSD
  8250.     if (inserver && !ENABLED(en_cpy)) {
  8251.         printf("?Sorry, COPY is disabled\n");
  8252.         return(-9);
  8253.     }
  8254. #endif /* IKSD */
  8255. #ifdef CK_APC
  8256.     if (apcactive == APC_LOCAL ||
  8257.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8258.         )
  8259.       return(success = 0);
  8260. #endif /* CK_APC */
  8261.     return(docopy());
  8262.     }
  8263. #endif /* ZCOPY */
  8264. #ifdef NT
  8265.     if ( cx == XXLINK ) {
  8266. #ifdef IKSD
  8267.         if (inserver && !ENABLED(en_cpy)) {
  8268.             printf("?Sorry, LINK (COPY) is disabled\n");
  8269.             return(-9);
  8270.         }
  8271. #endif /* IKSD */
  8272. #ifdef CK_APC
  8273.         if (apcactive == APC_LOCAL ||
  8274.             (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8275.             )
  8276.           return(success = 0);
  8277. #endif /* CK_APC */
  8278.         return(dolink());
  8279.     }
  8280. #endif /* NT */
  8281. #endif /* NOFRILLS */
  8282.  
  8283.     /* CD and friends */
  8284.     if (cx == XXCWD  || cx == XXCDUP || cx == XXBACK ||
  8285.     cx == XXLCWD || cx == XXLCDU || cx == XXKCD) {
  8286. #ifdef LOCUS
  8287.     if (!locus) {
  8288.         if (cx == XXCWD) {
  8289. #ifdef NOXFER
  8290.                 return(-2);
  8291. #else
  8292.                 return(dormt(XZCWD));
  8293. #endif /* NOXFER */
  8294.         } else if (cx == XXCDUP) {
  8295. #ifdef NOXFER
  8296.                 return(-2);
  8297. #else
  8298.                 return(dormt(XZCDU));
  8299. #endif /* NOXFER */
  8300.             }
  8301.     }
  8302. #endif /* LOCUS */
  8303. #ifdef IKSD
  8304.     if (inserver && !ENABLED(en_cwd)) {
  8305.         printf("?Sorry, changing directories is disabled\n");
  8306.         return(-9);
  8307.     }
  8308. #endif /* IKSD */
  8309.     return(success = docd(cx));
  8310.     }
  8311.  
  8312.     if (cx == XXCHK)            /* CHECK */
  8313.       return(success = dochk());
  8314.  
  8315.     if (cx == XXCLO) {            /* CLOSE */
  8316.     x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
  8317.           "connection",xxstring);
  8318.     if (x == -3) {
  8319.         printf("?You must say which file or log\n");
  8320.         return(-9);
  8321.     }
  8322.     if (x < 0) return(x);
  8323.     if ((y = cmcfm()) < 0) return(y);
  8324. #ifndef NOLOCAL
  8325.     if (x == 9999) {        /* CLOSE CONNECTION */
  8326.         x = clsconnx(0);
  8327.         switch (x) {
  8328.           case 0:
  8329.         if (msgflg) printf("?Connection was not open\n");
  8330.           case -1:
  8331.         return(0);
  8332.           case 1:
  8333.         whyclosed = WC_CLOS;
  8334.         return(1);
  8335.         }
  8336.         return(0);
  8337.     }
  8338. #endif /* NOLOCAL */
  8339.     y = doclslog(x);
  8340.     success = (y == 1);
  8341.     return(success);
  8342.     }
  8343.  
  8344. #ifndef NOSPL
  8345.     if (cx == XXDCL || cx == XXUNDCL) {    /* DECLARE an array */
  8346.     return(dodcl(cx));
  8347.     }
  8348. #endif /* NOSPL */
  8349.  
  8350. #ifndef NODIAL
  8351.     if (cx == XXRED  || cx == XXDIAL || cx == XXPDIA ||
  8352.     cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
  8353. #ifdef VMS
  8354.     extern int batch;
  8355. #else
  8356. #ifdef UNIXOROSK
  8357.     extern int backgrd;
  8358. #endif /* UNIXOROSK */
  8359. #endif /* VMS */
  8360.     x = dodial(cx);
  8361.     debug(F101,"dodial returns","",x);
  8362.     if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
  8363.         (x > 0) &&            /* If DIAL or REDIAL succeeded */
  8364.         (dialsta != DIA_PART) &&    /* and it wasn't partial */
  8365.         (dialcon > 0)) {
  8366.         if ((dialcon == 1 ||    /* And DIAL CONNECT is ON, */
  8367.         ((dialcon == 2) &&    /* or DIAL CONNECT is AUTO */
  8368.          !xcmdsrc        /* and we're at top level... */
  8369. #ifdef VMS
  8370.          && !batch        /* Not if running from batch */
  8371. #else
  8372. #ifdef UNIXOROSK
  8373.          && !backgrd        /* Not if running in background */
  8374. #endif /* UNIXOROSK */
  8375. #endif /* VMS */
  8376.          ))) /* Or AUTO */
  8377.           x = doconect(dialcq,    /* Then also CONNECT */
  8378.                            cmdlvl == 0 ? 1 : 0
  8379.                );
  8380.         if (ttchk() < 0)
  8381.           dologend();
  8382.     }
  8383.     return(success = x);
  8384.     }
  8385. #endif /* NODIAL */
  8386.  
  8387. #ifndef NOPUSH
  8388. #ifdef CK_REXX
  8389.     if (cx == XXREXX) {            /* REXX */
  8390.         extern int nopush;
  8391.         if ( nopush )
  8392.           return(success=0);
  8393.         return(dorexx());
  8394.     }
  8395. #endif /* CK_REXX */
  8396. #endif /* NOPUSH */
  8397.  
  8398. #ifndef NOFRILLS
  8399.     if (cx == XXDEL || cx == XXLDEL) {    /* DELETE */
  8400. #ifdef LOCUS
  8401.     if (!locus && cx != XXLDEL) {
  8402. #ifdef NOXFER
  8403.         return(-2);
  8404. #else
  8405.         return(dormt(XZDEL));
  8406. #endif /* NOXFER */
  8407.         }
  8408. #endif /* LOCUS */
  8409. #ifdef IKSD
  8410.     if (inserver && (!ENABLED(en_del)
  8411. #ifdef CK_LOGIN
  8412.              || isguest
  8413. #endif /* CK_LOGIN */
  8414.              )) {
  8415.         printf("?Sorry, DELETE is disabled\n");
  8416.         return(-9);
  8417.     }
  8418. #endif /* IKSD */
  8419. #ifdef CK_APC
  8420.     if ((apcactive == APC_LOCAL) ||
  8421.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8422.       return(success = 0);
  8423. #endif /* CK_APC */
  8424.     return(dodel());
  8425.     }
  8426. #endif /* NOFRILLS */
  8427.  
  8428.     if (cx == XXDIR || cx == XXLS || cx == XXLDIR) { /* DIRECTORY or LS */
  8429. #ifdef LOCUS
  8430.     if (!locus && cx != XXLDIR) {
  8431. #ifdef NOXFER
  8432.         return(-2);
  8433. #else
  8434.         return(dormt(XZDIR));
  8435. #endif /* NOXFER */
  8436.         }
  8437. #endif /* LOCUS */
  8438. #ifdef IKSD
  8439.     if (inserver && !ENABLED(en_dir)) {
  8440.         printf("?Sorry, DIRECTORY is disabled\n");
  8441.         return(-9);
  8442.     }
  8443. #endif /* IKSD */
  8444.     return(dodir(cx));
  8445.     }
  8446.  
  8447. #ifndef NOSPL
  8448.     if (cx == XXELS)            /* ELSE */
  8449.       return(doelse());
  8450. #endif /* NOSPL */
  8451.  
  8452. #ifndef NOSERVER
  8453. #ifndef NOFRILLS
  8454.     if (cx == XXENA || cx == XXDIS) {    /* ENABLE, DISABLE */
  8455.     s = (cx == XXENA) ?
  8456.       "Server function to enable" :
  8457.         "Server function to disable";
  8458.  
  8459.     if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
  8460.         if (x == -3) {
  8461.         printf("?Name of server function required\n");
  8462.         return(-9);
  8463.         } else return(x);
  8464.     }
  8465.     if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
  8466.         if (y == -3) {
  8467.         printf("?Please specify remote, local, or both\n");
  8468.         return(-9);
  8469.         } else return(y);
  8470.     }
  8471.     if (cx == XXDIS)        /* Disabling, not enabling */
  8472.       y = 3 - y;
  8473.     if ((z = cmcfm()) < 0) return(z);
  8474. #ifdef CK_APC
  8475.     if ((apcactive == APC_LOCAL) ||
  8476.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8477.       return(success = 0);
  8478. #endif /* CK_APC */
  8479. #ifdef IKSD
  8480.         /* This may seem like it duplicates the work in doenable()  */
  8481.         /* but this code returns failure whereas doenable() returns */
  8482.         /* success.                                                 */
  8483.         if (inserver &&
  8484. #ifdef IKSDCONF
  8485.             iksdcf &&
  8486. #endif /* IKSDCONF */
  8487.             (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
  8488.               isguest))
  8489.             return(success = 0);
  8490. #endif /* IKSD */
  8491.     return(doenable(y,x));
  8492.     }
  8493. #endif /* NOFRILLS */
  8494. #endif /* NOSERVER */
  8495.  
  8496. #ifndef NOSPL
  8497.     if (cx == XXRET) {            /* RETURN */
  8498.     if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
  8499.       return(x);
  8500.     s = brstrip(s);            /* Strip braces */
  8501.     if (cmdlvl == 0)        /* At top level, nothing happens... */
  8502.       return(success = 1);
  8503.     switch (cmdstk[cmdlvl].src) {    /* Action depends on command source */
  8504.       case CMD_TF:            /* Command file */
  8505.         popclvl();            /* Pop command level */
  8506.         return(success = 1);    /* always succeeds */
  8507.       case CMD_MD:            /* Macro */
  8508.       case CMD_KB:            /* Prompt */
  8509.         return(doreturn(s));    /* Trailing text is return value. */
  8510.       default:            /* Shouldn't happen */
  8511.         return(-2);
  8512.     }
  8513.     }
  8514. #endif /* NOSPL */
  8515.  
  8516. #ifndef NOSPL
  8517.     if (cx == XXOPE)            /* OPEN */
  8518.       return(doopen());
  8519. #endif /* NOSPL */
  8520.  
  8521. #ifndef NOSPL
  8522.     if (cx == XXOUT || cx == XXLNOUT) {    /* OUTPUT or LINEOUT */
  8523.     if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
  8524.       return(x);
  8525. #ifdef CK_APC
  8526.     if ((apcactive == APC_LOCAL) ||
  8527.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8528.       return(success = 0);
  8529. #endif /* CK_APC */
  8530.     debug(F110,"OUTPUT 1",s,0);
  8531.     s = brstrip(s);            /* Strip enclosing braces, */
  8532.     debug(F110,"OUTPUT 2",s,0);
  8533. /*
  8534.   I don't think I could ever fully explain this in a million years...
  8535.   We have read the user's string without calling the variable-expander
  8536.   function.  Now, before we call it, we have to double backslashes that
  8537.   appear before \N, \B, \L, and \ itself, so the expander function will
  8538.   reduce them back to single backslashes, so when we call dooutput()...
  8539.   But it's more complicated than that.
  8540. */
  8541.     if (cmdgquo()) {        /* Only if COMMAND QUOTING ON ... */
  8542.         for (x = 0, y = 0; s[x]; x++, y++) {
  8543.         if (s[x] == CMDQ) {
  8544.             char c = s[x+1];
  8545.             if (c == 'n' || c == 'N' ||
  8546.             c == 'b' || c == 'B' ||
  8547.             c == 'l' || c == 'L' ||
  8548.             c == CMDQ)
  8549.               line[y++] = CMDQ;
  8550.         }
  8551.         line[y] = s[x];
  8552.         }
  8553.         line[y++] = '\0';        /* Now expand variables, etc. */
  8554.         debug(F110,"OUTPUT 3",line,0);
  8555.         s = line+y+1;
  8556.         x = LINBUFSIZ - (int) strlen(line) - 1;
  8557.         debug(F101,"OUTPUT size","",x);
  8558.         if (zzstring(line,&s,&x) < 0)
  8559.           return(success = 0);
  8560.         s = line+y+1;
  8561.         debug(F110,"OUTPUT 4",s,0);
  8562.     }
  8563.     success = dooutput(s,cx);
  8564.     return(success);
  8565.     }
  8566. #endif /* NOSPL */
  8567.  
  8568. #ifdef ANYX25
  8569. #ifndef IBMX25
  8570.     if (cx == XXPAD) {            /* PAD commands */
  8571.     x = cmkey(padtab,npadc,"PAD command","",xxstring);
  8572.     if (x == -3) {
  8573.         printf("?You must specify a PAD command to execute\n");
  8574.         return(-9);
  8575.     }
  8576.     if (x < 0) return(x);
  8577.  
  8578.     switch (x) {
  8579.       case XYPADL:
  8580.         if (x25stat() < 0)
  8581.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8582.         else {
  8583.         x25clear();
  8584.         initpad();
  8585.         }
  8586.         break;
  8587.       case XYPADS:
  8588.         if (x25stat() < 0)
  8589.           printf("Not connected\r\n");
  8590.         else {
  8591.         extern int linkid, lcn;
  8592.         conol("Connected thru ");
  8593.         conol(ttname);
  8594.         printf(", Link id %d, Logical channel number %d\r\n",
  8595.                linkid,lcn);
  8596.         }
  8597.         break;
  8598.       case XYPADR:
  8599.         if (x25stat() < 0)
  8600.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8601.         else
  8602.           x25reset(0,0);
  8603.         break;
  8604.       case XYPADI:
  8605.         if (x25stat() < 0)
  8606.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8607.         else
  8608.           x25intr(0);
  8609.     }
  8610.     return(0);
  8611.     }
  8612. #endif /* IBMX25 */
  8613. #endif /* ANYX25 */
  8614.  
  8615. #ifndef NOSPL
  8616.     if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
  8617.       return(dopaus(cx));
  8618. #endif /* NOSPL */
  8619.  
  8620. #ifndef NOFRILLS
  8621.     if (cx == XXPRI) {
  8622. #ifdef IKSD
  8623. #ifdef CK_LOGIN
  8624.     if (inserver && (isguest || !ENABLED(en_pri))) {
  8625.         printf("?Sorry, printing is disabled\n");
  8626.         return(-9);
  8627.     }
  8628. #endif /* CK_LOGIN */
  8629. #endif /* IKSD */
  8630.     if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
  8631.         if (x == -3) {
  8632.         printf("?A file specification is required\n");
  8633.         return(-9);
  8634.         } else return(x);
  8635.     }
  8636.     if (y != 0) {
  8637.         printf("?Wildcards not allowed\n");
  8638.         return(-9);
  8639.     }
  8640.     ckstrncpy(line,s,LINBUFSIZ);
  8641.     s = "";
  8642. #ifndef NT
  8643.     if ((x = cmtxt("Local print command options, or carriage return","",&s,
  8644.                xxstring)) < 0)
  8645.       return(x);
  8646. #endif /* NT */
  8647.     if ((x = cmcfm()) < 0)
  8648.       return(x);
  8649.     return(success = (zprint(s,line) == 0) ? 1 : 0);
  8650.     }
  8651. #endif /* NOFRILLS */
  8652.  
  8653. #ifdef TCPSOCKET
  8654. #ifndef NOPUSH
  8655.     if (cx == XXPNG)             /* PING an IP host */
  8656.       return(doping());
  8657. #endif /* NOPUSH */
  8658.  
  8659. #ifndef NOFTP
  8660.     if (cx == XXFTP)            /* FTP */
  8661. #ifdef SYSFTP
  8662. #ifndef NOPUSH
  8663.       return(doftp());            /* Just runs system's ftp program */
  8664. #else
  8665.       return(-2);
  8666. #endif /* NOPUSH */
  8667. #else
  8668.     return(doxftp());
  8669. #endif /* SYSFTP */
  8670. #endif /* NOFTP */
  8671. #endif /* TCPSOCKET */
  8672.  
  8673.     if (cx == XXPWD || cx == XXLPWD) {    /* PWD */
  8674. #ifdef OS2
  8675.     char *pwp;
  8676. #endif /* OS2 */
  8677.     if ((x = cmcfm()) < 0)
  8678.       return(x);
  8679. #ifdef LOCUS
  8680.     if (!locus && cx != XXLPWD) {
  8681. #ifdef NOXFER
  8682.         return(-2);
  8683. #else
  8684.         return(dormt(XZPWD));
  8685. #endif /* NOXFER */
  8686.         }
  8687. #endif /* LOCUS */
  8688.  
  8689. #ifndef MAC
  8690. #ifndef OS2
  8691. #ifdef UNIX
  8692.     printf("%s\n",zgtdir());
  8693. #else
  8694.     xsystem(PWDCMD);
  8695. #endif /* UNIX */
  8696.     return(success = 1);        /* Blind faith */
  8697. #else  /* OS2 */
  8698.     if (pwp = zgtdir()) {
  8699.         if (*pwp) {
  8700. #ifdef NT
  8701.         line[0] = NUL;
  8702.         ckGetLongPathName(pwp,line,LINBUFSIZ);
  8703.         line[LINBUFSIZ-1] = NUL;
  8704.         tmpbuf[0] = NUL;
  8705.         GetShortPathName(pwp,tmpbuf,TMPBUFSIZ);
  8706.         tmpbuf[TMPBUFSIZ-1] = NUL;
  8707.         pwp = line;
  8708.         if (!strcmp(line,tmpbuf)) {
  8709. #endif /* NT */
  8710.             printf("%s\n",pwp);
  8711. #ifdef NT
  8712.         } else {
  8713.             printf("  Long name:  %s\n",line);
  8714.             printf("  Short name: %s\n",tmpbuf);
  8715.         }            
  8716. #endif /* NT */
  8717.         }
  8718.         return(success = ((int)strlen(pwp) > 0));
  8719.     } else return(success = 0);
  8720. #endif /* OS2 */
  8721. #else  /* MAC */
  8722.     if (pwp = zgtdir()) {
  8723.         printf("%s\n",pwp);
  8724.         return(success = ((int)strlen(pwp) > 0));
  8725.     } else return(success = 0);
  8726. #endif /* MAC */
  8727.     }
  8728.  
  8729.     if (cx == XXQUI || cx == XXEXI) {    /* EXIT, QUIT */
  8730.     extern int quitting;
  8731.  
  8732.     if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
  8733.       return(y);
  8734.     if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
  8735.       return(y);
  8736.     s = brstrip(s);
  8737.     ckstrncpy(line,s,LINBUFSIZ);
  8738.  
  8739.     if (!hupok(0))            /* Check if connection still open */
  8740.       return(success = 0);
  8741.  
  8742.     if (line[0])            /* Print EXIT message if given */
  8743.       printf("%s\n",(char *)line);
  8744.  
  8745.     quitting = 1;            /* Flag that we are quitting. */
  8746.  
  8747. #ifdef VMS
  8748.     doexit(GOOD_EXIT,x);
  8749. #else
  8750. #ifdef OSK
  8751. /* Returning any codes here makes the OS-9 shell print an error message. */
  8752.     doexit(GOOD_EXIT,-1);
  8753. #else
  8754. #ifdef datageneral
  8755.         doexit(GOOD_EXIT,x);
  8756. #else
  8757.     doexit(x,-1);
  8758. #endif /* datageneral */
  8759. #endif /* OSK */
  8760. #endif /* VMS */
  8761.     }
  8762.  
  8763. #ifndef NOXFER
  8764. #ifndef NOFRILLS
  8765.     if (cx == XXERR) {            /* ERROR */
  8766. #ifdef CK_XYZ
  8767.     if (protocol != PROTO_K) {
  8768.         printf("Sorry, E-PACKET only works with Kermit protocol\n");
  8769.         return(-9);
  8770.     }
  8771. #endif /* CK_XYZ */
  8772.     if ((x = cmcfm()) < 0) return(x);
  8773.     ttflui();
  8774.     epktflg = 1;
  8775.     sstate = 'a';
  8776.     return(0);
  8777.     }
  8778. #endif /* NOFRILLS */
  8779.  
  8780.     if (cx == XXFIN) {            /* FINISH */
  8781. #ifdef NEWFTP
  8782.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8783.       return(ftpbye());
  8784. #endif /* NEWFTP */
  8785. #ifdef CK_XYZ
  8786.     if (protocol != PROTO_K) {
  8787.         printf("Sorry, FINISH only works with Kermit protocol\n");
  8788.         return(-9);
  8789.     }
  8790. #endif /* CK_XYZ */
  8791.     if ((x = cmcfm()) < 0) return(x);
  8792.  
  8793. #ifdef IKS_OPTION
  8794.         if (
  8795. #ifdef CK_XYZ
  8796.             protocol == PROTO_K &&
  8797. #endif /* CK_XYZ */
  8798.             !iks_wait(KERMIT_REQ_START,1)) {
  8799.         printf(
  8800.               "?A Kermit Server is not available to process this command\n");
  8801.         return(-9);            /* Correct the return code */
  8802.         }
  8803. #endif /* IKS_OPTION */
  8804.  
  8805.     sstate = setgen('F',"","","");
  8806.     if (local) ttflui();        /* If local, flush tty input buffer */
  8807.     return(0);
  8808.     }
  8809. #endif /* NOXFER */
  8810.  
  8811. #ifndef NOSPL
  8812.     if (cx == XXFOR)            /* FOR loop */
  8813.       return(dofor());
  8814. #endif /* NOSPL */
  8815.  
  8816. #ifndef NOXFER
  8817.     /* GET MGET REGET RETRIEVE etc */
  8818.     if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
  8819. #ifdef IKSD
  8820.     if (inserver && !ENABLED(en_sen)) {
  8821.         printf("?Sorry, reception of files is disabled\n");
  8822.         return(-9);
  8823.     }
  8824. #endif /* IKSD */
  8825.     return(doxget(cx));
  8826.     }
  8827. #endif /* NOXFER */
  8828.  
  8829. #ifndef NOSPL
  8830. #ifndef NOFRILLS
  8831.     if (cx == XXGOK) {            /* GETOK */
  8832.     return(success = doask(cx));
  8833.     }
  8834. #endif /* NOFRILLS */
  8835. #endif /* NOSPL */
  8836.  
  8837.     if (cx == XXHLP) {            /* HELP */
  8838. #ifdef NOHELP
  8839.     return(dohlp(XXHLP));
  8840. #else
  8841.     x = cmkey2(cmdtab,ncmd,"\nCommand or topic","help",toktab,xxstring,3);
  8842.     debug(F101,"HELP command x","",x);
  8843.     if (x == -5) {
  8844.         y = chktok(toktab);
  8845.         debug(F101,"HELP cmkey token","",y);
  8846.         /* ungword(); */
  8847.         switch (y) {
  8848. #ifndef NOPUSH
  8849.           case '!': x = XXSHE; break;
  8850. #endif /* NOPUSH */
  8851.           case '#': x = XXCOM; break;
  8852.           case ';': x = XXCOM; break;
  8853. #ifndef NOSPL
  8854.               case '.': x = XXDEF; break;
  8855.           case ':': x = XXLBL; break;
  8856. #ifndef NOSEXP
  8857.           case '(': x = XXSEXP; break;
  8858. #endif /* NOSEXP */
  8859. #endif /* NOSPL */
  8860.           case '&': x = XXECH; break;
  8861.           default:
  8862.         printf("\n?Invalid - %s\n",cmdbuf);
  8863.         x = -2;
  8864.         }
  8865.     }
  8866.     makestr(&hlptok,atmbuf);
  8867.     debug(F111,"HELP token",hlptok,x);
  8868.     return(dohlp(x));
  8869. #endif /* NOHELP */
  8870.     }
  8871.  
  8872. #ifndef NOHELP
  8873.     if (cx == XXINT)            /* INTRO */
  8874.       return(hmsga(introtxt));
  8875.     if (cx == XXNEW) {            /* NEWS */
  8876.     int x;
  8877.     extern char * k_info_dir;
  8878.     x = hmsga(newstxt);
  8879.     return(x);
  8880.     }
  8881.  
  8882. #ifdef OS2ONLY
  8883.     if (cx == XXUPD) {            /* View UPDATE file */
  8884.         extern char exedir[];
  8885.         char * pTopic;
  8886.         char updstr[2048];
  8887.         if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
  8888.             return x;
  8889. #ifdef COMMENT
  8890.     sprintf(updstr,
  8891.         "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
  8892. %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
  8893.         exedir,exedir,exedir,exedir,pTopic
  8894.         );
  8895. #else
  8896.     if (ckmakxmsg(updstr,
  8897.              2048,
  8898.              "start view ",
  8899.              exedir,
  8900.              "\\docs\\k2.inf+",
  8901.              exedir,
  8902.              "\\docs\\using_ck.inf+",
  8903.              exedir,
  8904.              "\\docs\\dialing.inf+",
  8905.              exedir,
  8906.              "\\docs\\modems.inf ",
  8907.              pTopic,
  8908.              NULL,
  8909.              NULL
  8910.              ) > 0)
  8911. #endif /* COMMENT */
  8912.       system(updstr);
  8913.         return(success = 1);
  8914.     }
  8915. #endif /* OS2ONLY */
  8916. #endif /* NOHELP */
  8917.  
  8918. #ifndef NOLOCAL
  8919.     if (cx == XXHAN) {            /* HANGUP */
  8920.     if ((x = cmcfm()) < 0) return(x);
  8921. #ifdef NEWFTP
  8922.     if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
  8923.       return(success = ftpbye());
  8924. #endif /* NEWFTP */
  8925. #ifndef NODIAL
  8926.     if ((x = mdmhup()) < 1) {
  8927.         debug(F101,"HANGUP mdmup","",x);
  8928. #endif /* NODIAL */
  8929.         x = tthang();
  8930.         debug(F101,"HANGUP tthang","",x);
  8931.         x = (x > -1);
  8932. #ifndef NODIAL
  8933.     }
  8934.     dialsta = DIA_UNK;
  8935. #endif /* NODIAL */
  8936.     whyclosed = WC_CLOS;
  8937.     ttchk();            /* In case of CLOSE-ON-DISCONNECT */
  8938.     dologend();
  8939. #ifdef OS2
  8940.     if (x)
  8941.       DialerSend(OPT_KERMIT_HANGUP, 0);
  8942. #endif /* OS2 */
  8943.     if (x) haveline = 0;
  8944.     return(success = x);
  8945.     }
  8946. #endif /* NOLOCAL */
  8947.  
  8948. #ifndef NOSPL
  8949.     /* INPUT, REINPUT, and MINPUT */
  8950.  
  8951.     if (cx == XXINP || cx == XXREI || cx == XXMINP) {
  8952.     long zz;
  8953.     extern int x_ifnum, ispattern;
  8954.     zz = -1L;
  8955.     x_ifnum = 1;            /* Turn off internal complaints */
  8956.     y = cmnum("Seconds to wait for input,\n or time of day hh:mm:ss",
  8957.           ckitoa(indef), 10, &x, xxstring
  8958.           );
  8959.     x_ifnum = 0;
  8960.     if (y < 0) {
  8961.         if (y == -2) {        /* Invalid number or expression */
  8962.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  8963.         if (zz < 0L) {
  8964.             printf("?Number, expression, or time of day required\n");
  8965.             return(-9);
  8966.         } else {
  8967.             char now[32];    /* Current time */
  8968.             char *p;
  8969.             long tnow;
  8970.             p = now;
  8971.             ztime(&p);
  8972.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  8973.             if (zz < tnow)    /* User's time before now */
  8974.               zz += 86400L;    /* So make it tomorrow */
  8975.             zz -= tnow;        /* Seconds from now. */
  8976.         }
  8977.         } else
  8978.           return(y);
  8979.     }
  8980.     if (zz > -1L) {
  8981.         x = zz;
  8982.         if (zz != (long) x) {
  8983.         printf(
  8984. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  8985.                );
  8986.         return(-9);
  8987.         }
  8988.     }
  8989.  
  8990. #ifdef CK_MINPUT
  8991.     for (y = 0; y < MINPMAX; y++) {    /* Initialize strings */
  8992.         mp[y] = 0;            /* Assume it's not a pattern */
  8993.         if (ms[y]) {
  8994.         free(ms[y]);        /* Free old strings, if any */
  8995.         ms[y] = NULL;
  8996.         }
  8997.     }
  8998.     if (cx == XXMINP) {        /* MINPUT */
  8999.         int i, k, n = 0, rc = 0;
  9000.         struct stringarray * q;
  9001.         if ((y = cmtxt("List of targets","",&s,xxstring)) < 0)
  9002.           return(y);
  9003.         if ((q = cksplit(1,0,s," ",NULL,3,0,0))) {
  9004.         char ** ap = q->a_head;
  9005.  
  9006.         n = q->a_size;
  9007.         debug(F101,"minput cksplit size","",n);
  9008.  
  9009.         for (i = 1, k = 0; i <= n; i++) { /* Array is 1-based */
  9010.             if (!ap[i])                  /* Add non-empty elements */
  9011.               continue;
  9012.             if (!*(ap[i]))
  9013.               continue;
  9014.             makestr(&(ms[k++]),ap[i]);    /* Not empty - add it */
  9015.             debug(F111,"MINPUT",ms[k-1],k-1);
  9016.             if (k > MINPMAX)              /* Check for too many */
  9017.               break;
  9018.         }
  9019.         rc = (k > 0) ? 1 : 0;
  9020.         }
  9021.     } else {
  9022. #endif /* CK_MINPUT */
  9023.  
  9024.         /* INPUT or REINPUT */
  9025.  
  9026.         if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
  9027.           return(y);
  9028.         mp[0] = ispattern ? 1 : 0;
  9029.         makestr(&(ms[0]),brstrip(s));
  9030.         ms[1] = NULL;
  9031.  
  9032. #ifdef CK_MINPUT
  9033.     }
  9034. #endif /* CK_MINPUT */
  9035.  
  9036.     if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
  9037.         i_active = 1;
  9038.         success = doinput(x,ms,mp);    /* Go try to input the search string */
  9039.         i_active = 0;
  9040.     } else {            /* REINPUT */
  9041.         success = doreinp(x,ms[0],ispattern);
  9042.     }
  9043.     if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
  9044.         popclvl();            /* If so, pop command level. */
  9045.         if (pflag && cmdlvl == 0) {
  9046.         if (cx == XXINP)  printf("?INPUT timed out\n");
  9047.         if (cx == XXMINP) printf("?MINPUT timed out\n");
  9048.         if (cx == XXREI)  printf("?REINPUT failed\n");
  9049.         }
  9050.     }
  9051.     return(success);        /* Return do(re)input's return code */
  9052.     }
  9053.  
  9054. #endif /* NOSPL */
  9055.  
  9056.     if (cx == XXLOG) {            /* LOG */
  9057.     x = cmkey(logtab,nlog,"What to log","",xxstring);
  9058.     if (x == -3) {
  9059.         printf("?Type of log required\n");
  9060.         return(-9);
  9061.     }
  9062.     if (x < 0) return(x);
  9063.     x = dolog(x);
  9064.     if (x < 0)
  9065.       return(x);
  9066.     else
  9067.       return(success = x);
  9068.     }
  9069.  
  9070.     if (cx == XXLOGIN) {        /* (REMOTE) LOGIN */
  9071. #ifdef NEWFTP
  9072.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9073.       return(success = doftpusr());
  9074. #endif /* NEWFTP */
  9075. #ifdef IKSD
  9076.     if (inserver) {
  9077.         printf("?Already logged in\n");
  9078.         return(-9);
  9079.     } else
  9080. #endif /* IKSD */
  9081.     {
  9082. #ifdef NOXFER
  9083.         return(-2);
  9084. #else
  9085.         return(dormt(XZLGI));
  9086. #endif /* NOXFER */
  9087.     }
  9088.     }
  9089.     if (cx == XXLOGOUT) {        /* (REMOTE) LOGOUT */
  9090. #ifdef NEWFTP
  9091.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9092.       return(success = doftpres());
  9093. #endif /* NEWFTP */
  9094.  
  9095. #ifdef IKSD
  9096.         if (inserver) {
  9097.         if ((x = cmcfm()) < 0)
  9098.           return(x);
  9099.         doexit(GOOD_EXIT,xitsta);
  9100.     } else
  9101. #endif /* IKSD */
  9102.     if (!local || (network && ttchk() < 0)) {
  9103.         printf("?No connection.\n");
  9104.         return(-9);
  9105.     } else {
  9106. #ifdef NOXFER
  9107.         return(-2);
  9108. #else
  9109.         return(dormt(XZLGO));
  9110. #endif /* NOXFER */
  9111.     }
  9112.     }
  9113.  
  9114. #ifndef NOSCRIPT
  9115.     if (cx == XXLOGI) {            /* UUCP-style script */
  9116.     if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
  9117.       return(x);
  9118. #ifdef CK_APC
  9119.     if ((apcactive == APC_LOCAL) ||
  9120.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9121.       return(success = 0);
  9122. #endif /* CK_APC */
  9123. #ifdef VMS
  9124.     conres();            /* For Ctrl-C to work... */
  9125. #endif /* VMS */
  9126.     return(success = dologin(s));    /* Return 1=completed, 0=failed */
  9127.     }
  9128. #endif /* NOSCRIPT */
  9129.  
  9130. #ifndef NOXFER
  9131. #ifdef PIPESEND
  9132.     if (cx == XXCREC) {            /* CRECEIVE */
  9133.     if (protocol != PROTO_K) {
  9134.         printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
  9135.         return(-9);
  9136.     } else
  9137.       return(doxget(cx));
  9138.     }
  9139.     if (cx == XXCGET) {            /* CGET */
  9140.     return(doxget(cx));
  9141.     }
  9142. #endif /* PIPESEND */
  9143.  
  9144.     if (cx == XXREC)            /* RECEIVE */
  9145.       return(doxget(cx));
  9146. #endif /* NOXFER */
  9147.  
  9148. #ifndef NOXFER
  9149.     if (cx == XXREM) {            /* REMOTE */
  9150. #ifdef NEWFTP
  9151.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9152.       return(doftprmt(0,0));
  9153. #endif /* NEWFTP */
  9154. #ifdef CK_XYZ
  9155.     if (protocol != PROTO_K) {
  9156.         printf("Sorry, REMOTE commands only work with Kermit protocol\n");
  9157.         return(-9);
  9158.     }
  9159. #endif /* CK_XYZ */
  9160.     x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
  9161.     if (x == -3) {
  9162.         printf("?You must specify a command for the remote server\n");
  9163.         return(-9);
  9164.     }
  9165.     return(dormt(x));
  9166.     }
  9167. #endif /* NOXFER */
  9168.  
  9169. #ifndef NORENAME
  9170. #ifndef NOFRILLS
  9171.     if (cx == XXREN || cx == XXLREN) {    /* RENAME */
  9172. #ifdef LOCUS
  9173.     if (!locus && cx != XXLREN) {
  9174. #ifdef NOXFER
  9175.         return(-2);
  9176. #else
  9177.         return(dormt(XZREN));
  9178. #endif /* NOXFER */
  9179.         }
  9180. #endif /* LOCUS */
  9181. #ifdef IKSD
  9182.     if (inserver && (!ENABLED(en_ren)
  9183. #ifdef CK_LOGIN
  9184.              || isguest
  9185. #endif /* CK_LOGIN */
  9186.              )) {
  9187.         printf("?Sorry, renaming of files is disabled\n");
  9188.         return(-9);
  9189.     }
  9190. #endif /* IKSD */
  9191. #ifdef CK_APC
  9192.     if ((apcactive == APC_LOCAL) ||
  9193.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9194.       return(success = 0);
  9195. #endif /* CK_APC */
  9196.     return(dorenam());
  9197.     }
  9198. #endif /* NOFRILLS */
  9199. #endif /* NORENAME */
  9200.  
  9201.     if (cx == XXEIGHT) {        /* EIGHTBIT */
  9202.     extern int parity, cmask, cmdmsk;
  9203.     if ((x = cmcfm()) < 0)
  9204.       return(x);
  9205.     parity = 0;
  9206.     cmask = 0xff;
  9207.     cmdmsk = 0xff;
  9208.     return(success = 1);
  9209.     }
  9210.  
  9211. #ifndef NOXFER
  9212. /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
  9213.  
  9214.     if (cx == XXSEN            /* SEND */
  9215. #ifdef PIPESEND
  9216.     || cx == XXCSEN            /* CSEND */
  9217. #endif /* PIPESEND */
  9218.     || cx == XXMOVE            /* MOVE */
  9219.     || cx == XXMAI            /* MAIL */
  9220. #ifdef CK_RESEND
  9221.     || cx == XXRSEN            /* RESEND */
  9222. #endif /* CK_RESEND */
  9223.     ) {
  9224. #ifdef IKSD
  9225.     if (inserver && !ENABLED(en_get)) {
  9226.         printf("?Sorry, sending files is disabled\n");
  9227.         return(-9);
  9228.     }
  9229. #endif /* IKSD */
  9230.     return(doxsend(cx));
  9231.     }
  9232.  
  9233. /* PSEND, ADD, and REMOVE use special parsing */
  9234.  
  9235. #ifdef ADDCMD
  9236.     /* ADD and REMOVE */
  9237.     if (cx == XXADD || cx == XXREMV) {
  9238.     char * m;
  9239.     m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
  9240.     x = cmkey(addtab,naddtab,m,"",xxstring);
  9241.     if (x < 0)
  9242.       return(x);
  9243. #ifndef NOMSEND
  9244.     if (x == ADD_SND)
  9245.       return(addsend(cx));
  9246.     else
  9247. #endif /* NOMSEND */
  9248.       return(doadd(cx,x));
  9249.     }
  9250. #endif /* ADDCMD */
  9251.  
  9252. #ifdef CK_RESEND
  9253.     if (cx == XXPSEN) {            /* PSEND */
  9254.     int seekto = 0;
  9255.  
  9256.     cmarg = cmarg2 = "";
  9257.     x = cmifi("File to partially send", "", &s, &y, xxstring);
  9258.     if (x < 0) {
  9259.         if (x == -3) {
  9260.         printf("?A file specification is required\n");
  9261.         return(-9);
  9262.         } else return(x);
  9263.     }
  9264.     nfils = -1;            /* Files come from internal list. */
  9265. #ifndef NOMSEND
  9266.         addlist = 0;            /* Don't use SEND-LIST. */
  9267.         filenext = NULL;
  9268. #endif /* NOMSEND */
  9269.     ckstrncpy(line,s,LINBUFSIZ);    /* Save copy of string just parsed. */
  9270.     debug(F110,"PSEND line",line,0);
  9271.     if (y != 0) {
  9272.         printf("?Sorry, wildcards not permitted in this command\n");
  9273.         return(-9);
  9274.     }
  9275.     if (sizeof(int) < 4) {
  9276.         printf("?Sorry, this command needs 32-bit integers\n");
  9277.         return(-9);
  9278.     }
  9279.     x = cmnum("starting position (byte number)",
  9280.           "",10,&seekto,xxstring);
  9281.     if (x < 0)
  9282.       return(x);
  9283.     zfnqfp(s,fspeclen,fspec);    /* Get full path */
  9284.     if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
  9285.       return(x);
  9286.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9287.  
  9288. #ifdef IKSD
  9289.     if (inserver && !ENABLED(en_get)) {
  9290.         printf("?Sorry, sending files is disabled\n");
  9291.         return(-9);
  9292.     }
  9293. #endif /* IKSD */
  9294. #ifdef PIPESEND
  9295.     if (sndfilter) {
  9296.         printf("?Sorry, no PSEND while SEND FILTER selected\n");
  9297.         return(-9);
  9298.     }
  9299. #endif /* PIPESEND */
  9300. #ifdef CK_XYZ
  9301.     if ((protocol == PROTO_X || protocol == PROTO_XC)) {
  9302.         printf("Sorry, PSEND works only with Kermit protocol\n");
  9303.         return(-9);
  9304.     }
  9305. #endif /* CK_XYZ */
  9306.  
  9307.     cmarg2 = brstrip(tmpbuf);    /* Strip braces */
  9308.     cmarg = line;            /* File to send */
  9309.     debug(F110,"PSEND filename",cmarg,0);
  9310.     debug(F110,"PSEND as-name",cmarg2,0);
  9311.     sendstart = seekto;
  9312.     sstate = 's';            /* Set start state to SEND */
  9313. #ifndef NOMSEND
  9314.     addlist = 0;
  9315.     filenext = NULL;
  9316. #endif /* NOMSEND */
  9317.     sendmode = SM_PSEND;
  9318. #ifdef MAC
  9319.     what = W_SEND;
  9320.     scrcreate();
  9321. #endif /* MAC */
  9322.     if (local) {            /* If in local mode, */
  9323.         displa = 1;            /* enable file transfer display */
  9324.     }
  9325.     return(0);
  9326.     }
  9327. #endif /* CK_RESEND */
  9328. #endif /* NOXFER */
  9329.  
  9330. #ifndef NOXFER
  9331. #ifndef NOMSEND
  9332.     if (cx == XXMSE || cx == XXMMOVE) {
  9333. #ifdef NEWFTP
  9334.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9335.       return(doftpput(cx,0));
  9336. #endif /* NEWFTP */
  9337. #ifdef CK_XYZ
  9338.     if (protocol == PROTO_X || protocol == PROTO_XC) {
  9339.         printf(
  9340. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  9341.            );
  9342.         return(-9);
  9343.     }
  9344. #endif /* CK_XYZ */
  9345.         return(doxsend(cx));
  9346.     }
  9347.  
  9348. #ifdef COMMENT                /* (moved to doxsend) */
  9349.     if (cx == XXMSE || cx == XXMMOVE) {    /* MSEND and MMOVE commands */
  9350.     nfils = 0;            /* Like getting a list of */
  9351.     lp = line;            /* files on the command line */
  9352.     addlist = 0;            /* Do not use SEND-LIST */
  9353.     filenext = NULL;        /* Ditto ! */
  9354.  
  9355.     while (1) {
  9356.         char *p;
  9357.         if ((x = cmifi("Names of files to send, separated by spaces","",
  9358.                &s,&y,xxstring)) < 0) {
  9359.         if (x == -3) {
  9360.             if (nfils <= 0) {
  9361.             printf("?A file specification is required\n");
  9362.             return(-9);
  9363.             } else break;
  9364.         }
  9365.         return(x);
  9366.         }
  9367.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  9368.         p = lp;            /* remember pointer, */
  9369.         while (*lp++ = *s++)    /* and copy it into buffer */
  9370.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  9371.           printf("?MSEND list too long\n");
  9372.           line[0] = NUL;
  9373.           return(-9);
  9374.           }
  9375.         debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
  9376.         if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
  9377. #ifdef ZFNQFP
  9378.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  9379.         p = tmpbuf;
  9380. #endif /* ZFNQFP */
  9381.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  9382.         strcat(fspec,p);    /* safe */
  9383.         strcat(fspec," ");    /* safe */
  9384.         } else printf("WARNING - \\v(filespec) buffer overflow\n");
  9385.     }
  9386.     cmlist = msfiles;        /* Point cmlist to pointer array */
  9387.     cmarg2 = "";            /* No internal expansion list (yet) */
  9388.     sndsrc = nfils;            /* Filenames come from cmlist */
  9389.     sendmode = SM_MSEND;        /* Remember this kind of SENDing */
  9390.     sstate = 's';            /* Set start state for SEND */
  9391.     if (cx == XXMMOVE)        /* If MMOVE'ing, */
  9392.       moving = 1;            /*  set this flag. */
  9393. #ifdef MAC
  9394.     what = W_SEND;
  9395.     scrcreate();
  9396. #endif /* MAC */
  9397.     if (local) {            /* If in local mode, */
  9398.         displa = 1;            /* turn on file transfer display */
  9399.         ttflui();            /* and flush tty input buffer. */
  9400.     }
  9401.     return(0);
  9402.     }
  9403. #endif /* COMMENT */
  9404. #endif /* NOMSEND */
  9405. #endif /* NOXFER */
  9406.  
  9407. #ifndef NOSERVER
  9408.     if (cx == XXSER) {            /* SERVER */
  9409. #ifdef CK_XYZ
  9410.     if (protocol != PROTO_K) {
  9411.         printf("Sorry, SERVER only works with Kermit protocol\n");
  9412.         return(-9);
  9413.     }
  9414. #endif /* CK_XYZ */
  9415. #ifdef COMMENT
  9416. /*
  9417.   Parse for time limit, but since we don't use it yet,
  9418.   the parsing is commented out.
  9419. */
  9420.     x_ifnum = 1;            /* Turn off internal complaints */
  9421.     y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
  9422.           "0", 10, &x, xxstring
  9423.           );
  9424.     x_ifnum = 0;
  9425.     if (y < 0) {
  9426.         if (y == -2) {        /* Invalid number or expression */
  9427.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  9428.         if (zz < 0L) {
  9429.             printf("?Number, expression, or time of day required\n");
  9430.             return(-9);
  9431.         } else {
  9432.             char now[32];    /* Current time */
  9433.             char *p;
  9434.             long tnow;
  9435.             p = now;
  9436.             ztime(&p);
  9437.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  9438.             if (zz < tnow)    /* User's time before now */
  9439.               zz += 86400L;    /* So make it tomorrow */
  9440.             zz -= tnow;        /* Seconds from now. */
  9441.         }
  9442.         } else
  9443.           return(y);
  9444.     }
  9445.     if (zz > -1L) {
  9446.         x = zz;
  9447.         if (zz != (long) x) {
  9448.         printf(
  9449. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  9450.                );
  9451.         return(-9);
  9452.         }
  9453.     }
  9454.     if (x < 0)
  9455.       x = 0;
  9456. #endif /* COMMENT */
  9457.  
  9458.     if ((x = cmcfm()) < 0) return(x);
  9459.     sstate = 'x';
  9460. #ifdef MAC
  9461.     what = W_RECV;
  9462.     scrcreate();
  9463. #endif /* MAC */
  9464.     if (local) displa = 1;
  9465. #ifdef AMIGA
  9466.     reqoff();            /* No DOS requestors while server */
  9467. #endif /* AMIGA */
  9468.     return(0);
  9469.     }
  9470. #endif /* NOSERVER */
  9471.  
  9472.     if (cx == XXSAVE) {            /* SAVE command */
  9473.     x = cmkey(savtab,nsav,"option","keymap",xxstring);
  9474.     if (x == -3) {
  9475.         printf("?You must specify an option to save\n");
  9476.         return(-9);
  9477.     }
  9478.     if (x < 0) return(x);
  9479.     /* have to set success separately for each item in doprm()... */
  9480.     /* actually not really, could have just had doprm return 0 or 1 */
  9481.     /* and set success here... */
  9482.     y = dosave(x);
  9483.     if (y == -3) {
  9484.         printf("?More fields required\n");
  9485.         return(-9);
  9486.     } else return(y);
  9487.     }
  9488.  
  9489.     if (cx == XXSET) {            /* SET command */
  9490.     x = cmkey(prmtab,nprm,"Parameter","",xxstring);
  9491.     if (x == -3) {
  9492.         printf("?You must specify a parameter to set\n");
  9493.         return(-9);
  9494.     }
  9495.     if (x < 0) return(x);
  9496.     /* have to set success separately for each item in doprm()... */
  9497.     /* actually not really, could have just had doprm return 0 or 1 */
  9498.     /* and set success here... */
  9499.     y = doprm(x,0);
  9500.     if (y == -3) {
  9501.         printf("?More fields required\n");
  9502.         return(-9);
  9503.     } else return(y);
  9504.     }
  9505.  
  9506. #ifndef NOPUSH
  9507.     if (cx == XXSHE            /* SHELL (system) command */
  9508.     || cx == XXEXEC            /* exec() */
  9509.     ) {
  9510.     int rx = 0;
  9511.     char * p = NULL;
  9512.     int i /* ,n */ ;
  9513. #ifdef UNIXOROSK
  9514.     char * args[256];
  9515. #endif /* UNIXOROSK */
  9516.  
  9517. #ifdef IKSD
  9518.     if (inserver && (nopush || !ENABLED(en_hos))) {
  9519.         printf("?Sorry, host command access is disabled\n");
  9520.         return(-9);
  9521.     }
  9522. #endif /* IKSD */
  9523.  
  9524. #ifdef CKEXEC
  9525.     if (cx == XXEXEC) {        /* EXEC (overlay ourselves) */
  9526.         struct FDB sw, fl;
  9527.         cmfdbi(&sw,            /* First FDB - command switches */
  9528.            _CMKEY,        /* fcode */
  9529.            "Command to overlay C-Kermit\n or switch", /* hlpmsg */
  9530.            "",            /* default */
  9531.            "",            /* addtl string data */
  9532.            1,            /* addtl numeric data 1: tbl size */
  9533.            4,            /* addtl numeric data 2: 4 = cmswi */
  9534.            xxstring,        /* Processing function */
  9535.            redirsw,        /* Keyword table */
  9536.            &fl            /* Pointer to next FDB */
  9537.            );
  9538.         cmfdbi(&fl,            /* 2nd FDB - command to exec */
  9539.            _CMFLD,        /* fcode */
  9540.            "Command to overlay C-Kermit", /* hlpmsg */
  9541.            "",            /* default */
  9542.            "",            /* addtl string data */
  9543.            0,            /* addtl numeric data 1 */
  9544.            0,            /* addtl numeric data 2 */
  9545.            xxstring,
  9546.            NULL,
  9547.            NULL            /* No more after this */
  9548.            );
  9549.         while (1) {
  9550.         x = cmfdb(&sw);        /* Parse something */
  9551.         debug(F101,"exec cmfdb","",x);
  9552.         if (x < 0)
  9553.           return(x);
  9554.         /* Generalize this if we add more switches */
  9555.         if (cmresult.fcode == _CMKEY) {
  9556.             rx = 1;
  9557.             continue;
  9558.         }
  9559.         if (cmresult.fcode == _CMFLD)
  9560.           break;
  9561.         return(-2);
  9562.         }
  9563.         ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
  9564.         if (!tmpbuf[0]) {
  9565.         printf("?Command required\n");
  9566.         return(-9);
  9567.         }
  9568.         p = brstrip(tmpbuf);
  9569.         args[0] = NULL;        /* Set argv[0] to it */
  9570.         makestr(&args[0],p);
  9571.         for (i = 1; i < 255; i++) {    /* Get arguments for command */
  9572.         if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
  9573.             if (x == -3) {
  9574.             if ((x = cmcfm()) < 0)
  9575.               return(x);
  9576.             break;
  9577.             } else
  9578.               return(x);
  9579.         }
  9580.         args[i] = NULL;
  9581.         s = brstrip(s);
  9582.         makestr(&args[i],s);
  9583.         }
  9584.         args[i] = NULL;
  9585.     } else {
  9586. #endif /* CKEXEC */
  9587.         if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
  9588.           return(x);
  9589. #ifdef CKEXEC
  9590.     }
  9591. #endif /* CKEXEC */
  9592.         if (nopush)
  9593.           return(success = 0);
  9594. #ifdef CK_APC
  9595.     if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  9596.       return(success = 0);
  9597. #endif /* CK_APC */
  9598.     conres();            /* Make console normal  */
  9599. #ifdef OS2
  9600.     if (!(s && *s)) {
  9601.         os2push();
  9602.             return(success = 1);
  9603.     } else
  9604. #endif /* OS2 */
  9605.       if (cx == XXSHE) {
  9606.           x = zshcmd(s);
  9607.           debug(F101,"RUN zshcmd code","",x);
  9608.           concb((char)escape);
  9609.           return(success = x);
  9610. #ifdef CKEXEC
  9611.       } else {
  9612. #ifdef DEBUG
  9613.           if (deblog) {
  9614.           debug(F111,"EXEC cmd",p,0);
  9615.           for (i = 0; i < 256 && args[i]; i++)
  9616.             debug(F111,"EXEC arg",args[i],i);
  9617.           }
  9618. #endif /* DEBUG */
  9619.           if (p) {
  9620.           z_exec(p,args,rx);    /* Overlay ourself */
  9621.           debug(F100,"EXEC fails","",0);
  9622.           concb((char)escape);    /* In case it returns */
  9623.           }
  9624.           return(success = 0);
  9625. #endif /* CKEXEC */
  9626.       }
  9627.     }
  9628.  
  9629. #ifdef CK_REDIR
  9630.     if (cx == XXFUN) {            /* REDIRECT */
  9631. #ifdef CK_APC
  9632.     if ((apcactive == APC_LOCAL) ||
  9633.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9634.       return(success = 0);
  9635. #endif /* CK_APC */
  9636.     ckmakmsg(tmpbuf,
  9637.          TMPBUFSIZ,
  9638.          "Local command to run,\n",
  9639.          "with its standard input/output redirected to ",
  9640.          local ? ttname : "the communications connection",
  9641.          "\n"
  9642.          );
  9643.     if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
  9644.       return(x);
  9645.         if (nopush) {
  9646.             printf("?REDIRECT disabled\n");
  9647.             return(success=0);
  9648.         }
  9649.     if (!local) {
  9650.         printf("?SET LINE or SET HOST required first\n");
  9651.         return(-9);
  9652.     }
  9653.     if (!*s) {
  9654.         printf("?REDIRECT requires a command to redirect\n");
  9655.         return(-9);
  9656.     }
  9657.     return(success = ttruncmd(s));
  9658.     }
  9659. #endif /* CK_REDIR */
  9660. #endif /* NOPUSH */
  9661.  
  9662. #ifndef NOSHOW
  9663.     if (cx == XXSHO) {            /* SHOW */
  9664.     x = cmkey(shotab,nsho,"","parameters",xxstring);
  9665.     if (x < 0) return(x);
  9666.     return(doshow(x));
  9667.     }
  9668. #endif /* NOSHOW */
  9669.  
  9670. #ifndef MAC
  9671.     if (cx == XXSPA) {            /* SPACE */
  9672. #ifdef IKSD
  9673.     if (inserver && !ENABLED(en_spa)) {
  9674.         printf("?Sorry, SPACE command disabled\n");
  9675.         return(-9);
  9676.     }
  9677. #endif /* IKSD */
  9678. #ifdef datageneral
  9679.     /* AOS/VS can take an argument after its "space" command. */
  9680.     if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0)
  9681.       return(x);
  9682.     if (nopush) {
  9683.         printf("?Sorry, SPACE command disabled\n");
  9684.         return(-9);
  9685.     } else if (*s == NUL) {
  9686.         xsystem(SPACMD);
  9687.     } else {
  9688.         ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL);
  9689.         xsystem(line);
  9690.     }
  9691. #else
  9692. #ifdef OS2
  9693.     if ((x = cmtxt("Press Enter for current disk,\n\
  9694.  or specify a disk letter like A:","",&s,xxstring)) < 0)
  9695.       return(x);
  9696.     if (*s == NUL) {        /* Current disk */
  9697.             unsigned long space = zdskspace(0);
  9698.             if (space > 0 && space < 1024)
  9699.               printf(" Free space: unknown\n");
  9700.             else
  9701.           printf(" Free space: %ldK\n", space/1024L);
  9702.     } else {
  9703.         int drive = toupper(*s);
  9704.             unsigned long space = zdskspace(drive - 'A' + 1);
  9705.             if (space > 0 && space < 1024)
  9706.               printf(" Drive %c: unknown free\n");
  9707.             else
  9708.               printf(" Drive %c: %ldK free\n", drive,space / 1024L);
  9709.     }
  9710. #else
  9711. #ifdef UNIXOROSK
  9712.     x = cmdir("Confirm for current disk,\n\
  9713.  or specify a disk device or directory","",&s,xxstring);
  9714.     if (x == -3)
  9715.       s = "";
  9716.     else if (x < 0)
  9717.       return(x);
  9718.         ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9719.         s = tmpbuf;
  9720.     if ((x = cmcfm()) < 0) return(x);
  9721.     if (nopush) {
  9722.         printf("?Sorry, SPACE command disabled\n");
  9723.         return(-9);
  9724.     }
  9725.     if (!*s) {            /* Current disk */
  9726.         xsystem(SPACMD);
  9727.     } else {            /* Specified disk */
  9728.         ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL);
  9729.         xsystem(line);
  9730.     }
  9731. #else
  9732.     if ((x = cmcfm()) < 0) return(x);
  9733.     if (nopush) {
  9734.         printf("?Sorry, SPACE command disabled\n");
  9735.         return(-9);
  9736.     }
  9737.     xsystem(SPACMD);
  9738. #endif /* UNIXOROSK */
  9739. #endif /* OS2 */
  9740. #endif /* datageneral */
  9741.     return(success = 1);        /* Pretend it worked */
  9742.     }
  9743. #endif /* MAC */
  9744.  
  9745. #ifndef NOXFER
  9746.     if (cx == XXSTA) {            /* STATISTICS */
  9747.     if ((x = cmkey(stattab,2,"Carriage return, or option",
  9748.                "/brief",xxstring)) < 0)
  9749.       return(x);
  9750.     if ((y = cmcfm()) < 0) return(y);
  9751.     return(success = dostat(x));
  9752.     }
  9753. #endif /* NOXFER */
  9754.  
  9755.     if (cx == XXSTO || cx == XXEND) {    /* STOP, END, or POP */
  9756.     if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0)
  9757.       return(y);
  9758.     if ((y = cmtxt("Message to print","",&s,xxstring)) < 0)
  9759.       return(y);
  9760.     s = brstrip(s);
  9761.     if (*s) printf("%s\n",s);
  9762.     if (cx == XXSTO) {
  9763.         dostop();
  9764.     } else {
  9765.         doend(x);
  9766.     }
  9767.     return(success = (x == 0));
  9768.     }
  9769.     if (cx == XXSUS) {            /* SUSPEND */
  9770.     if ((y = cmcfm()) < 0) return(y);
  9771. #ifdef NOJC
  9772.     printf("Sorry, this version of Kermit cannot be suspended\n");
  9773. #else
  9774. #ifdef IKSD
  9775.     if (inserver) {
  9776.         printf("?Sorry, IKSD can not be suspended\n");
  9777.         return(-9);
  9778.     } else
  9779. #endif /* IKSD */
  9780.       if (nopush) {
  9781.         printf("?Sorry, access to system is disabled\n");
  9782.         return(-9);
  9783.     }
  9784.     stptrap(0);
  9785. #endif /* NOJC */
  9786.     return(0);
  9787.     }
  9788.  
  9789.     if (cx == XXTAK) {            /* TAKE */
  9790.     char * scriptenv = NULL;    
  9791. #ifdef OS2
  9792.         char * GetAppData(int);
  9793.     extern char startupdir[],exedir[],inidir[];
  9794.     char * keymapenv = NULL;
  9795.         char * appdata0 = NULL, *appdata1 = NULL;
  9796.     int xx;
  9797. #define TAKEPATHLEN 4096
  9798. #else /* OS2 */
  9799. #define TAKEPATHLEN 1024
  9800. #endif /* OS2 */
  9801.     char takepath[TAKEPATHLEN];
  9802.  
  9803.     if (tlevel >= MAXTAKE-1) {
  9804.         printf("?Take files nested too deeply\n");
  9805.         return(-9);
  9806.     }
  9807. #ifdef OS2
  9808. #ifdef NT
  9809.     scriptenv = getenv("K95SCRIPTS");
  9810.     keymapenv = getenv("K95KEYMAPS");
  9811.         makestr(&appdata0,(char *)GetAppData(0));
  9812.         makestr(&appdata1,(char *)GetAppData(1));
  9813. #else /* NT */
  9814.     scriptenv = getenv("K2SCRIPTS");
  9815.     keymapenv = getenv("K2KEYMAPS");
  9816. #endif /* NT */
  9817. #endif /* OS2 */
  9818.  
  9819.     if (!scriptenv)            /* Let this work for Unix etc too */
  9820.       scriptenv = getenv("CK_SCRIPTS"); /* Use this if defined */
  9821. #ifndef OS2
  9822.     if (!scriptenv)            /* Otherwise use home directory */
  9823.       scriptenv = homepath();
  9824. #endif /* OS2 */
  9825.     if (!scriptenv)
  9826.       scriptenv = "";
  9827.     ckstrncpy(takepath,scriptenv,TAKEPATHLEN);
  9828.     debug(F110,"TAKE initial takepath",takepath,0);
  9829.  
  9830. #ifdef OS2
  9831.     if (!keymapenv)
  9832.       keymapenv = getenv("CK_KEYMAPS");
  9833.     if (!keymapenv)
  9834.       keymapenv = "";
  9835.  
  9836.     ckstrncat(takepath,
  9837.           (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
  9838.           TAKEPATHLEN
  9839.           );
  9840.     ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN);
  9841.     ckstrncat(takepath,
  9842.           (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
  9843.           TAKEPATHLEN
  9844.           );
  9845.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9846.     ckstrncat(takepath,";",TAKEPATHLEN);
  9847.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9848.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  9849.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9850.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  9851.  
  9852.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  9853.     ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
  9854.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  9855.     ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
  9856.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  9857.     ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
  9858.  
  9859.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  9860.     ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
  9861.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  9862.     ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
  9863.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  9864.     ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
  9865.  
  9866.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9867.     ckstrncat(takepath,";",TAKEPATHLEN);
  9868.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9869.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  9870.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9871.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  9872.  
  9873.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9874.     ckstrncat(takepath,";",TAKEPATHLEN);
  9875.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9876.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  9877.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9878.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  9879.  
  9880.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9881.     ckstrncat(takepath,";",TAKEPATHLEN);
  9882.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9883.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  9884.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9885.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  9886. #endif /* OS2 */
  9887.     debug(F110,"TAKE final takepath",takepath,0);
  9888.  
  9889.     if ((y = cmifip("Commands from file",
  9890.             "",&s,&x,0,takepath,xxstring)) < 0) {
  9891.         if (y == -3) {
  9892.         printf("?A file name is required\n");
  9893.         return(-9);
  9894.         } else
  9895.           return(y);
  9896.     }
  9897.     if (x != 0) {
  9898.         printf("?Wildcards not allowed in command file name\n");
  9899.         return(-9);
  9900.     }
  9901.     ckstrncpy(line,s,LINBUFSIZ);
  9902.     debug(F110,"TAKE file",s,0);
  9903.     if (isdir(s)) {
  9904.         printf("?Can't execute a directory - \"%s\"\n", s);
  9905.         return(-9);
  9906.     }
  9907. #ifndef NOTAKEARGS
  9908.     {
  9909.         char * p;
  9910.         x = strlen(line);
  9911.         debug(F111,"TAKE args",line,x);
  9912.         p = line + x + 1;
  9913.         if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0)
  9914.           return(y);
  9915.         if (*s) {            /* Args given? */
  9916.         ckstrncpy(p,s,LINBUFSIZ-x-1);
  9917. #ifdef ZFNQFP
  9918.         zfnqfp(line,TMPBUFSIZ,tmpbuf);
  9919.         s = tmpbuf;
  9920. #else
  9921.         s = line;
  9922. #endif /* ZFNQFP */
  9923.         debug(F110,"TAKE filename",s,0);
  9924.         x = strlen(s);
  9925.         debug(F101,"TAKE new len",s,x);
  9926.  
  9927. #ifdef COMMENT
  9928. /*
  9929.   This was added in C-Kermit 7.0 to allow args to be passed from the TAKE
  9930.   command to the command file.  But it overwrites the current argument vector,
  9931.   which is at best surprising, and at worst unsafe.
  9932. */
  9933.         addmac("%0",s);        /* Define %0 = name of file */
  9934.         varnam[0] = '%';
  9935.         varnam[2] = '\0';
  9936.         debug(F110,"take arg 0",s,0);
  9937.         debug(F110,"take args",p,0);
  9938.         for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */
  9939.             varnam[1] = (char) (y + '0');
  9940.             delmac(varnam,0);
  9941.         }
  9942.         xwords(p,MAXARGLIST,NULL,0); /* Assign new args */
  9943.         debug(F110,"take args",p,0);
  9944. #else
  9945. /*
  9946.   This method is used in 8.0.  If the TAKE command includes arguments, we
  9947.   insert an intermediate temporary macro between the current level; we pass
  9948.   the arguments to the macro and then the macro TAKEs the command file.
  9949.   If the user Ctrl-C's out of the TAKE file, some temporary macro definitions
  9950.   and other small malloc'd bits might be left behind.
  9951. */
  9952.         {
  9953.             char * q = NULL;
  9954.             char * r = NULL;
  9955.             int k, m;
  9956.             m = maclvl;
  9957.             q = (char *)malloc(x+24);
  9958.             if (q) {
  9959.             r = (char *)malloc(x+24);
  9960.             if (r) {
  9961.                 sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */
  9962.                 sprintf(r,"take %s",s); /* safe */
  9963.                 k = addmac(q,r);
  9964.                 if (k > -1) {
  9965.                 dodo(k,p,0);
  9966.                 while (maclvl > m) {
  9967.                     sstate = (CHAR) parser(1);
  9968.                     if (sstate) proto();
  9969.                 }
  9970.                 }
  9971.                 k = delmac(q,0);
  9972.                 free(q);
  9973.                 free(r);
  9974.                 return(success);
  9975.             }
  9976.             }
  9977.         }
  9978.         return(success = 0);
  9979. #endif /* COMMENT */
  9980.         }
  9981.     }
  9982. #else
  9983.     if ((y = cmcfm()) < 0) return(y);
  9984. #endif /* NOTAKEARGS */
  9985.     return(success = dotake(line));
  9986.     }
  9987.  
  9988. #ifndef NOLOCAL
  9989. #ifdef OS2
  9990.     if (cx == XXVIEW) {            /* VIEW Only Terminal mode */
  9991.     viewonly = TRUE;
  9992.     success = doconect(0, 0);
  9993.     viewonly = FALSE;
  9994.     return success;
  9995.     }
  9996. #endif /* OS2 */
  9997.  
  9998. #ifdef NETCONN
  9999.     if (cx == XXTEL || cx == XXIKSD) {    /* TELNET */
  10000.     int x,z;
  10001. #ifdef OS2
  10002.     if (!tcp_avail) {
  10003.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  10004. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n");
  10005.         success = 0;
  10006.         return(-9);
  10007.     } else
  10008. #endif /* OS2 */
  10009.       {
  10010.       x = nettype;            /* Save net type in case of failure */
  10011.       z = ttnproto;            /* Save protocol in case of failure */
  10012.       nettype = NET_TCPB;
  10013.       ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT;
  10014.       if ((y = setlin(XYHOST,0,1)) <= 0) {
  10015.               nettype = x;        /* Failed, restore net type. */
  10016.               ttnproto = z;        /* and protocol */
  10017.               success = 0;
  10018.       }
  10019.       didsetlin++;
  10020.         }
  10021.     return(y);
  10022.     }
  10023.  
  10024. #ifndef PTYORPIPE
  10025. #ifdef NETCMD
  10026. #define PTYORPIPE
  10027. #else
  10028. #ifdef NETPTY
  10029. #define PTYORPIPE
  10030. #endif /* NETPTY */
  10031. #endif /* NETCMD */
  10032. #endif /* PTYORPIPE */
  10033.  
  10034. #ifdef PTYORPIPE
  10035.     if (cx == XXPIPE || cx == XXPTY) {    /* PIPE or PTY */
  10036.     int x;
  10037.     extern int netsave;
  10038.     x = nettype;            /* Save net type in case of failure */
  10039.     nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY;
  10040.     if ((y = setlin(XYHOST,0,1)) < 0) {
  10041.         nettype = x;        /* Failed, restore net type. */
  10042.         ttnproto = z;        /* and protocol */
  10043.         success = 0;
  10044.     }
  10045.     didsetlin++;
  10046.     netsave = x;
  10047.     return(y);
  10048.     }
  10049. #endif /* PTYORPIPE */
  10050.  
  10051. #ifdef ANYSSH
  10052.     if (cx == XXSSH) {            /* SSH (Secure Shell) */
  10053.     extern int netsave;
  10054. #ifdef SSHBUILTIN
  10055.     int k, x, havehost = 0, trips = 0;
  10056.         int    tmpver = -1, tmpxfw = -1;
  10057. #ifndef SSHTEST
  10058.         extern int sl_ssh_xfw, sl_ssh_xfw_saved;
  10059.         extern int sl_ssh_ver, sl_ssh_ver_saved;
  10060. #endif /* SSHTEST */
  10061.         extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
  10062.         extern char * slmsg;
  10063.     extern char uidbuf[], sl_uidbuf[];
  10064.         extern char pwbuf[], * g_pswd;
  10065.         extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
  10066.     struct FDB sw, kw, fl;
  10067.  
  10068.         if (ssh_tmpstr)
  10069.             memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  10070.         makestr(&ssh_tmpstr,NULL);
  10071.         makestr(&ssh_tmpuid,NULL);
  10072.         makestr(&ssh_tmpcmd,NULL);
  10073.         makestr(&ssh_tmpport,NULL);
  10074.  
  10075.     cmfdbi(&kw,            /* 1st FDB - commands */
  10076.            _CMKEY,            /* fcode */
  10077.            "host [ port ],\n or action",    /* hlpmsg */
  10078.            "",            /* default */
  10079.            "",            /* addtl string data */
  10080.            nsshcmd,            /* addtl numeric data 1: tbl size */
  10081.            0,            /* addtl numeric data 2: 0 = keyword */
  10082.            xxstring,        /* Processing function */
  10083.            sshkwtab,        /* Keyword table */
  10084.            &fl            /* Pointer to next FDB */
  10085.            );
  10086.     cmfdbi(&fl,            /* Host */
  10087.            _CMFLD,            /* fcode */
  10088.            "",            /* hlpmsg */
  10089.            "",            /* default */
  10090.            "",            /* addtl string data */
  10091.            0,            /* addtl numeric data 1 */
  10092.            0,            /* addtl numeric data 2 */
  10093.            xxstring,
  10094.            NULL,
  10095.            NULL
  10096.            );
  10097.  
  10098.     x = cmfdb(&kw);
  10099.     if (x == -3) {
  10100.         printf("?ssh what?\n");
  10101.         return(-9);
  10102.     }
  10103.     if (x < 0)
  10104.       return(x);
  10105.     havehost = 0;
  10106.     if (cmresult.fcode == _CMFLD) {
  10107.         havehost = 1;
  10108.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
  10109.         cmresult.nresult = XSSH_OPN;
  10110.     }
  10111.     switch (cmresult.nresult) {    /* SSH keyword */
  10112.       case XSSH_OPN:        /* SSH OPEN */
  10113.         if (!havehost) {
  10114.         if ((x = cmfld("Host","",&s,xxstring)) < 0)
  10115.           return(x);
  10116.         ckstrncpy(line,s,LINBUFSIZ);
  10117.         }
  10118.         /* Parse [ port ] [ switches ] */
  10119.         cmfdbi(&kw,            /* Switches */
  10120.            _CMKEY,
  10121.            "Port number or service name,\nor switch",
  10122.            "",
  10123.            "",
  10124.            nsshopnsw,
  10125.            4,
  10126.            xxstring,
  10127.            sshopnsw,
  10128.            &fl
  10129.            );
  10130.         cmfdbi(&fl,            /* Port number or service name */
  10131.            _CMFLD,
  10132.            "",
  10133.            "",
  10134.            "",
  10135.            0,
  10136.            0,
  10137.            xxstring,
  10138.            NULL,
  10139.            NULL
  10140.            );
  10141.         trips = 0;            /* Explained below */
  10142.         while (1) {            /* Parse port and switches */
  10143.         x = cmfdb(&kw);        /* Get a field */
  10144.         if (x == -3)        /* User typed CR so quit from loop */
  10145.           break;
  10146.         if (x < 0)        /* Other parse error, pass it back */
  10147.           return(x);
  10148.         switch (cmresult.fcode) { /* Field or Keyword? */
  10149.                   case _CMFLD:          /* Field */
  10150.                     makestr(&ssh_tmpport,cmresult.sresult);
  10151.             break;
  10152.           case _CMKEY:        /* Keyword */
  10153.             switch (cmresult.nresult) {    /* Which one? */
  10154.               case SSHSW_USR:            /* /USER: */
  10155.             if (!cmgbrk()) {
  10156.                 printf("?This switch requires an argument\n");
  10157.                 return(-9);
  10158.             }
  10159.             if ((y = cmfld("Username","",&s,xxstring)) < 0)
  10160.               return(y);
  10161.             s = brstrip(s);
  10162.             makestr(&ssh_tmpuid,s);
  10163.             break;
  10164.                       case SSHSW_PWD:
  10165.             if (!cmgbrk()) {
  10166.                 printf("?This switch requires an argument\n");
  10167.                 return(-9);
  10168.             }
  10169.             debok = 0;
  10170.             if ((x = cmfld("Password","",&s,xxstring)) < 0) {
  10171.                 if (x == -3) {
  10172.                 makestr(&ssh_tmpstr,"");
  10173.                 } else {
  10174.                 return(x);
  10175.                 }
  10176.             } else {
  10177.                 s = brstrip(s);
  10178.                 if ((x = (int)strlen(s)) > PWBUFL) {
  10179.                 makestr(&slmsg,"Internal error");
  10180.                 printf("?Sorry, too long - max = %d\n",PWBUFL);
  10181.                 return(-9);
  10182.                 }
  10183.                 makestr(&ssh_tmpstr,s);
  10184.             }
  10185.             break;
  10186.  
  10187.               case SSHSW_VER:
  10188.             if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
  10189.               return(x);
  10190.             if (z < 1 || z > 2) {
  10191.                 printf("?Out of range: %d\n",z);
  10192.                 return(-9);
  10193.             }
  10194.                         tmpver = z;
  10195.             break;
  10196.               case SSHSW_CMD:
  10197.               case SSHSW_SUB:
  10198.             if ((x = cmfld("Text","",&s,xxstring)) < 0)
  10199.               return(x);
  10200.                         makestr(&ssh_tmpcmd,s);
  10201.             ssh_cas = (cmresult.nresult == SSHSW_SUB);
  10202.             break;
  10203.               case SSHSW_X11:
  10204.             if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  10205.               return(x);
  10206.                         tmpxfw = x;
  10207.             break;
  10208.               default:
  10209.                 return(-2);
  10210.             }
  10211.         }
  10212.         if (trips++ == 0) {    /* After first time through */
  10213.             cmfdbi(&kw,        /* only parse switches, not port. */
  10214.                _CMKEY,
  10215.                "Switch",
  10216.                "",
  10217.                "",
  10218.                nsshopnsw,
  10219.                4,
  10220.                xxstring,
  10221.                sshopnsw,
  10222.                NULL
  10223.                );
  10224.         }
  10225.         }
  10226.         if ((x = cmcfm()) < 0)    /* Get confirmation */
  10227.           return(x);
  10228.             if (clskconnx(1) < 0) {    /* Close current Kermit connection */
  10229.               if ( ssh_tmpstr ) {
  10230.                   memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  10231.                   makestr(&ssh_tmpstr,NULL);
  10232.               }
  10233.               return(success = 0);
  10234.             }
  10235.         makestr(&ssh_hst,line);    /* Stash everything */
  10236.         if (ssh_tmpuid) {
  10237.                 if (!sl_uid_saved) {
  10238.                     ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
  10239.                     sl_uid_saved = 1;
  10240.                 }
  10241.         ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
  10242.         makestr(&ssh_tmpuid,NULL);
  10243.         }
  10244.             if (ssh_tmpport) {
  10245.                 makestr(&ssh_prt,ssh_tmpport);
  10246.                 makestr(&ssh_tmpport,NULL);
  10247.             } else
  10248.                 makestr(&ssh_prt,NULL);
  10249.  
  10250.             if (ssh_tmpcmd) {
  10251.                 makestr(&ssh_cmd,brstrip(ssh_tmpcmd));
  10252.                 makestr(&ssh_tmpcmd,NULL);
  10253.             } else
  10254.                 makestr(&ssh_cmd,NULL);
  10255.  
  10256.             if (tmpver > -1) {
  10257. #ifndef SSHTEST
  10258.                 if (!sl_ssh_ver_saved) {
  10259.                     sl_ssh_ver = ssh_ver;
  10260.                     sl_ssh_ver_saved = 1;
  10261.                 }
  10262. #endif /* SSHTEST */
  10263.                 ssh_ver = tmpver;
  10264.             }
  10265.             if (tmpxfw > -1) {
  10266. #ifndef SSHTEST
  10267.                 if (!sl_ssh_xfw_saved) {
  10268.                     sl_ssh_xfw = ssh_xfw;
  10269.                     sl_ssh_xfw_saved = 1;
  10270.                 }
  10271. #endif /* SSHTEST */
  10272.                 ssh_xfw = tmpxfw;
  10273.             }
  10274.         if (ssh_tmpstr) {
  10275.         if (ssh_tmpstr[0]) {
  10276.             ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
  10277.             pwflg = 1;
  10278.             pwcrypt = 0;
  10279.         } else
  10280.           pwflg = 0;
  10281.         makestr(&ssh_tmpstr,NULL);
  10282.         }
  10283.         nettype = NET_SSH;
  10284.         if (mdmsav < 0)
  10285.           mdmsav = mdmtyp;
  10286.         mdmtyp = -nettype;
  10287.         x = 1;
  10288.  
  10289. #ifndef NOSPL
  10290.             makestr(&g_pswd,pwbuf);             /* Save global pwbuf */
  10291.             g_pflg = pwflg;                     /* and flag */
  10292.             g_pcpt = pwcrypt;
  10293. #endif /* NOSPL */
  10294.  
  10295.         /* Line parameter to ttopen() is ignored */
  10296.         k = ttopen(line,&x,mdmtyp, 0);
  10297.         if (k < 0) {
  10298.         printf("?Unable to connect to %s\n",ssh_hst);
  10299.         mdmtyp = mdmsav;
  10300.                 slrestor();
  10301.         return(success = 0);
  10302.         }
  10303.         duplex = 0;             /* Remote echo */
  10304.         ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
  10305.         debug(F110,"ssh ttname",ttname,0);
  10306.         makestr(&slmsg,NULL);    /* No SET LINE error message */
  10307.         cxtype = CXT_SSH;
  10308. #ifndef NODIAL
  10309.         dialsta = DIA_UNK;
  10310. #endif /* NODIAL */
  10311.         success = 1;        /* SET LINE succeeded */
  10312.         network = 1;        /* Network connection (not serial) */
  10313.         local = 1;            /* Local mode (not remote) */
  10314.         if ((reliable != SET_OFF || !setreliable))
  10315.           reliable = SET_ON;    /* Transport is reliable end to end */
  10316. #ifdef OS2
  10317.             DialerSend(OPT_KERMIT_CONNECT, 0);
  10318. #endif /* OS2 */
  10319.         setflow();            /* Set appropriate flow control */
  10320.  
  10321.         haveline = 1;
  10322. #ifdef CKLOGDIAL
  10323. #ifdef NETCONN
  10324.         dolognet();
  10325. #endif /* NETCONN */
  10326. #endif /* CKLOGDIAL */
  10327.  
  10328. #ifndef NOSPL
  10329.         if (local) {
  10330.         if (nmac) {        /* Any macros defined? */
  10331.             int k;        /* Yes */
  10332.             k = mlook(mactab,"on_open",nmac); /* Look this up */
  10333.             if (k >= 0) {                  /* If found, */
  10334.             if (dodo(k,ssh_hst,0) > -1)   /* set it up, */
  10335.               parser(1);              /* and execute it */
  10336.             }
  10337.         }
  10338.         }
  10339. #endif /* NOSPL */
  10340. #ifdef LOCUS        
  10341.         if (autolocus)
  10342.         setlocus(1,1);
  10343. #endif /* LOCUS */
  10344.  
  10345.     /* Command was confirmed so we can pre-pop command level. */
  10346.     /* This is so CONNECT module won't think we're executing a */
  10347.     /* script if CONNECT was the final command in the script. */
  10348.         if (cmdlvl > 0)
  10349.           prepop();
  10350.         success = doconect(0,cmdlvl == 0 ? 1 : 0);
  10351.         if (ttchk() < 0)
  10352.           dologend();
  10353.         return(success);
  10354.  
  10355.       case XSSH_CLR:
  10356.         if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) {
  10357.             if (y == -3) {
  10358.             printf("?clear what?\n");
  10359.             return(-9);
  10360.         }
  10361.             return(y);
  10362.         }
  10363.         if ((x = cmcfm()) < 0)
  10364.           return(x);
  10365.         switch (y) {
  10366.           case SSHC_LPF:
  10367.                 ssh_pf_lcl_n = 0;
  10368.         break;
  10369.           case SSHC_RPF:
  10370.         ssh_pf_rmt_n = 0;
  10371.         break;
  10372.           default:
  10373.         return(-2);
  10374.         }
  10375.             return(success = 1);    /* or whatever */
  10376.  
  10377.       case XSSH_AGT: {        /* SSH AGENT */
  10378.           int doeach = 0;
  10379.           if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0)
  10380.         return(y);
  10381.           switch (y) {
  10382.         case SSHA_ADD:        /* SSH AGENT ADD ... */
  10383.           if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10384. #ifndef SSHTEST
  10385.               if (x == -3)    /* No name given */
  10386.             doeach = 1;    /* so do them all */
  10387.               else
  10388. #endif /* SSHTEST */
  10389.             return(x);
  10390.           }
  10391.           ckstrncpy(line,s,LINBUFSIZ);
  10392.           if ((x = cmcfm()) < 0)
  10393.             return(x);
  10394. #ifdef SSHTEST
  10395.           x = 0;
  10396. #else
  10397.           if (doeach) {
  10398.                       int i;
  10399.                       x = 0;
  10400.                       for (i = 0; i < ssh_idf_n; i++)
  10401.             x += ssh_agent_add_file(ssh_idf[i]);
  10402.           } else
  10403.             x = ssh_agent_add_file(line);
  10404. #endif /* SSHTEST */
  10405.           return(success = (x == 0));
  10406.  
  10407.         case SSHA_DEL: {    /* SSH AGENT DELETE ... */
  10408.             int doall = 0;
  10409.             if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10410. #ifndef SSHTEST
  10411.             if (x == -3)    /* No name given */
  10412.               doall = 1;    /* so do them all */
  10413.             else
  10414. #endif /* SSHTEST */
  10415.               return(x);
  10416.             }
  10417.             ckstrncpy(line,s,LINBUFSIZ);
  10418.             if ((x = cmcfm()) < 0)
  10419.               return(x);
  10420. #ifdef SSHTEST
  10421.             x = 0;
  10422. #else
  10423.             if (doall)
  10424.               x = ssh_agent_delete_all();
  10425.             else
  10426.               x = ssh_agent_delete_file(line);
  10427. #endif /* SSHTEST */
  10428.             return(success = (x == 0));
  10429.         }
  10430.         case SSHA_LST: {
  10431.             int fingerprint = 0;
  10432.             if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) {
  10433.             if (y != -3)
  10434.               return(y);
  10435.             } else if (cmgbrk() > SP) {
  10436.             printf("?This switch does not take an argument\n");
  10437.             return(-9);
  10438.             } else if (y == SSHASW_FP) {
  10439.             fingerprint = 1;
  10440.             }
  10441.             if ((x = cmcfm()) < 0)
  10442.               return(x);
  10443. #ifdef SSHTEST
  10444.             return(success = 1);
  10445. #else
  10446.             return(success =
  10447.                (ssh_agent_list_identities(fingerprint) == 0));
  10448. #endif /* SSHTEST */
  10449.         }
  10450.         default:
  10451.           return(-2);
  10452.           }
  10453.       }
  10454.       case XSSH_ADD: {        /* SSH ADD */
  10455.           /* ssh add { local, remote } port host port */
  10456.           int cx, i, j, k;
  10457.           char * h;
  10458.           if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0)
  10459.         return(cx);
  10460.           if ((x = cmnum((cx == SSHF_LCL) ?
  10461.                  "Local port number" : "Remote port number",
  10462.                  "",10,&j,xxstring)) < 0)
  10463.         return(x);
  10464.           if ((x = cmfld("Host","",&s,xxstring)) < 0)
  10465.         return(x);
  10466.           makestr(&h,s);
  10467.           if ((x = cmnum("Port","",10,&k,xxstring)) < 0)
  10468.         return(x);
  10469.           if ((x = cmcfm()) < 0)
  10470.         return(x);
  10471.  
  10472.           switch(cx) {
  10473.         case SSHF_LCL:
  10474.            if (ssh_pf_lcl_n == 32) {
  10475.                printf(
  10476. "?Maximum number of local port forwardings already specified\n"
  10477.                  );
  10478.                free(h);
  10479.                return(success = 0);
  10480.           }
  10481.           ssh_pf_lcl[ssh_pf_lcl_n].p1 = j;
  10482.           makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h);
  10483.           makestr(&h,NULL);
  10484.           ssh_pf_lcl[ssh_pf_lcl_n].p2 = k;
  10485.           ssh_pf_lcl_n++;
  10486.           break;
  10487.         case SSHF_RMT:
  10488.           if (ssh_pf_rmt_n == 32) {
  10489.               printf(
  10490. "?Maximum number of remote port forwardings already specified\n"
  10491.                 );
  10492.               free(h);
  10493.               return(success = 0);
  10494.           }
  10495.           ssh_pf_rmt[ssh_pf_rmt_n].p1 = j;
  10496.           makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h);
  10497.           makestr(&h,NULL);
  10498.           ssh_pf_rmt[ssh_pf_rmt_n].p2 = k;
  10499.           ssh_pf_rmt_n++;
  10500.           }
  10501.           return(success = 1);
  10502.       }
  10503.       /* Not supporting arbitrary forwarding yet */
  10504.       case XSSH_FLP:        /* SSH FORWARD-LOCAL-PORT */
  10505.       case XSSH_FRP: {        /* SSH FORWARD-REMOTE-PORT */
  10506.           int li_port = 0;
  10507.           int to_port = 0;
  10508.           char * fw_host = NULL;
  10509.           int n;
  10510.               if ((x = cmnum(cmresult.nresult == XSSH_FLP ?
  10511.                               "local-port":"remote-port",
  10512.                               "",10,&li_port,xxstring)) < 0)
  10513.                   return(x);
  10514.               if (li_port < 1 || li_port > 65535) {
  10515.                   printf("?Out range - min: 1, max: 65535\n");
  10516.                   return(-9);
  10517.               }
  10518.           if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0)
  10519.         return(x);
  10520.               n = ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  10521.               fw_host = tmpbuf;
  10522.               if ((x = cmnum("host-port",ckuitoa(li_port),10,
  10523.                               &to_port,xxstring)) < 0)
  10524.                   return(x);
  10525.               if (to_port < 1 || to_port > 65535) {
  10526.                   printf("?Out range - min: 1, max: 65535\n");
  10527.                   return(-9);
  10528.               }
  10529.           if ((x = cmcfm()) < 0)
  10530.         return(x);
  10531.           switch (cmresult.nresult) {
  10532.                 case XSSH_FLP:    /* SSH FORWARD-LOCAL-PORT */
  10533. #ifndef SSHTEST
  10534.                   ssh_fwd_local_port(li_port,fw_host,to_port);
  10535. #endif /* SSHTEST */
  10536.           return(success = 1);
  10537.         case XSSH_FRP:    /* SSH FORWARD-REMOTE-PORT */
  10538. #ifndef SSHTEST
  10539.                   ssh_fwd_remote_port(li_port,fw_host,to_port);
  10540. #endif /* SSHTEST */
  10541.           return(success = 1);
  10542.           }
  10543.           return(success = 1);
  10544.       }
  10545.     case XSSH_V2:        /* SSH V2 */
  10546.       if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0)
  10547.         return(cx);
  10548.       switch (cx) {
  10549.         case XSSH2_RKE:
  10550.           if ((x = cmcfm()) < 0)
  10551.         return(x);
  10552. #ifndef SSHTEST
  10553.           ssh_v2_rekey();
  10554. #endif /* SSHTEST */
  10555.           return(success = 1);
  10556.         default:
  10557.           return(-2);
  10558.       }
  10559.     case XSSH_KEY:
  10560.       if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0)
  10561.         return(cx);
  10562.       switch (cx) {
  10563.         case SSHK_PASS: {    /* Change passphrase */
  10564.           char * oldp = NULL, * newp = NULL;
  10565.           struct FDB df, sw;
  10566.           cmfdbi(&sw,
  10567.              _CMKEY,        /* fcode */
  10568.              "Filename, or switch", /* hlpmsg */
  10569.              "",        /* default */
  10570.              "",        /* addtl string data */
  10571.              2,            /* addtl numeric data 1: tbl size */
  10572.              4,            /* addtl numeric data 2: 4 = cmswi */
  10573.              xxstring,        /* Processing function */
  10574.              sshkpsw,        /* Keyword table */
  10575.              &df        /* Pointer to next FDB */
  10576.              );
  10577.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10578.              _CMIFI,        /* output file */
  10579.              "",        /* hlpmsg */
  10580.              "",        /* default */
  10581.              "",        /* addtl string data */
  10582.              0,            /* addtl numeric data 1 */
  10583.              0,            /* addtl numeric data 2 */
  10584.              xxstring,
  10585.              NULL,
  10586.              NULL
  10587.              );
  10588.           line[0] = NUL;
  10589.  
  10590.           while (1) {
  10591.           x = cmfdb(&sw);
  10592.           if (x == -3) break;
  10593.           if (x < 0)
  10594.             return(x);
  10595.           if (cmresult.fcode != _CMKEY)
  10596.             break;
  10597.           if (!cmgbrk()) {
  10598.               printf("?This switch requires an argument\n");
  10599.               return(-9);
  10600.           }
  10601.           if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10602.             return(y);
  10603.           switch (cmresult.nresult) {
  10604.             case 1:        /* Old */
  10605.               makestr(&oldp,s);
  10606.               break;
  10607.             case 2:        /* New */
  10608.               makestr(&newp,s);
  10609.           }
  10610.           }
  10611.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10612.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10613.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10614.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10615.           }
  10616.           if ((x = cmcfm()) < 0) return(x);
  10617.  
  10618. #ifndef SSHTEST
  10619.           x = sshkey_change_passphrase(line[0] ? line : NULL,
  10620.                          oldp, newp);
  10621. #endif /* SSHTEST */
  10622.           makestr(&oldp,NULL);
  10623.           makestr(&newp,NULL);
  10624.           success = (x == 0);
  10625.           return(success);
  10626.         }
  10627.         case SSHK_CREA: {    /* SSH KEY CREATE /switches... */
  10628.           int bits = 1024, keytype = SSHKT_2R;
  10629.           char * pass = NULL, * comment = NULL;
  10630.           struct FDB df, sw;
  10631.  
  10632.               /*
  10633.                * char * sshkey_default_file(int keytype) 
  10634.                * will provide the default filename for a given keytype
  10635.                * is it possible to have the default value for the 2nd
  10636.                * FDB set and changed when a /TYPE switch is provided?
  10637.                * Would this allow for tab completion of the filename?
  10638.                */
  10639.           cmfdbi(&sw,
  10640.              _CMKEY,        /* fcode */
  10641.              "Filename, or switch", /* hlpmsg */
  10642.              "",        /* default */
  10643.              "",        /* addtl string data */
  10644.              nsshkcrea,        /* addtl numeric data 1: tbl size */
  10645.              4,            /* addtl numeric data 2: 4 = cmswi */
  10646.              xxstring,        /* Processing function */
  10647.              sshkcrea,        /* Keyword table */
  10648.              &df        /* Pointer to next FDB */
  10649.              );
  10650.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10651.              _CMOFI,        /* output file */
  10652.              "",        /* hlpmsg */
  10653.              "",        /* default */
  10654.              "",        /* addtl string data */
  10655.              0,            /* addtl numeric data 1 */
  10656.              0,            /* addtl numeric data 2 */
  10657.              xxstring,
  10658.              NULL,
  10659.              NULL
  10660.              );
  10661.           line[0] = NUL;
  10662.  
  10663.           while (1) {
  10664.           x = cmfdb(&sw);
  10665.           if (x == -3) break;
  10666.           if (x < 0)
  10667.             return(x);
  10668.           if (cmresult.fcode != _CMKEY)
  10669.             break;
  10670.           if (!cmgbrk()) {
  10671.               printf("?This switch requires an argument\n");
  10672.               return(-9);
  10673.           }
  10674.           switch (cmresult.nresult) {
  10675.             case SSHKC_BI:    /* /BITS:n */
  10676.               if ((y = cmnum("","1024",10,&z,xxstring)) < 0)
  10677.             return(y);
  10678.               if (z < 512 || z > 4096) {
  10679.               printf("?Out range - min: 512, max: 4096\n");
  10680.               return(-9);
  10681.               }
  10682.               bits = z;
  10683.               break;
  10684.             case SSHKC_PP:    /* /PASSPHRASE:blah */
  10685.               if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10686.             return(y);
  10687.               makestr(&pass,s);
  10688.               break;
  10689.             case SSHKC_TY:    /* /TYPE:keyword */
  10690.               if ((y = cmkey(sshkcty,nsshkcty,"",
  10691.                      "v2-rsa",xxstring)) < 0)
  10692.             return(y);
  10693.               keytype = y;
  10694.               break;
  10695.             case SSHKC_1R:    /* /COMMENT */
  10696.               if ((y = cmfld("Text","",&s,xxstring)) < 0)
  10697.             return(y);
  10698.               makestr(&comment,s);
  10699.               break;
  10700.           }
  10701.           }
  10702.           if (cmresult.fcode == _CMOFI) { /* Filename */
  10703.                   if (cmresult.sresult) {
  10704.                       ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10705.                       if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10706.                           ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10707.           }
  10708.           }
  10709.           if ((y = cmcfm()) < 0) /* Confirm */
  10710.         return(y);
  10711. #ifndef SSHTEST
  10712.           x = sshkey_create(line[0] ? line : NULL,
  10713.                 bits, pass, keytype, comment);
  10714.           if (pass)
  10715.         memset(pass,0,strlen(pass));
  10716. #endif /* SSHTEST */
  10717.           makestr(&pass,NULL);
  10718.           makestr(&comment,NULL);
  10719.           return(success = (x == 0));
  10720.         }
  10721.         case SSHK_DISP: {    /* SSH KEY DISPLAY /switches... */
  10722.           char c;
  10723.           int infmt = 0, outfmt = 0;
  10724.           struct FDB df, sw;
  10725.           cmfdbi(&sw,
  10726.              _CMKEY,        /* fcode */
  10727.              "Filename, or switch", /* hlpmsg */
  10728.              "",        /* default */
  10729.              "",        /* addtl string data */
  10730.              nsshdswi,        /* addtl numeric data 1: tbl size */
  10731.              4,            /* addtl numeric data 2: 4 = cmswi */
  10732.              xxstring,        /* Processing function */
  10733.              sshdswi,        /* Keyword table */
  10734.              &df        /* Pointer to next FDB */
  10735.              );
  10736.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10737.              _CMIFI,        /* fcode */
  10738.              "",        /* hlpmsg */
  10739.              "",        /* default */
  10740.              "",        /* addtl string data */
  10741.              0,            /* addtl numeric data 1 */
  10742.              0,            /* addtl numeric data 2 */
  10743.              xxstring,
  10744.              NULL,
  10745.              NULL
  10746.              );
  10747.           line[0] = NUL;
  10748.  
  10749.           while (1) {
  10750.           x = cmfdb(&sw);
  10751.           if (x == -3) break;
  10752.           if (x < 0)
  10753.             return(x);
  10754.           if (cmresult.fcode != _CMKEY)
  10755.             break;
  10756.           if (!cmgbrk()) {
  10757.               printf("?This switch requires an argument\n");
  10758.               return(-9);
  10759.           }
  10760.           switch (cmresult.nresult) {
  10761. #ifdef COMMENT
  10762.             case SSHKD_IN:    /* /IN-FORMAT: */
  10763.               if ((y = cmkey(sshdifmt,nsshdifmt,
  10764.                      "","",xxstring)) < 0)
  10765.             return(y);
  10766.               infmt = y;
  10767.               break;
  10768. #endif /* COMMENT */
  10769.             case SSHKD_OUT:    /* /FORMAT: */
  10770.               if ((y = cmkey(sshdofmt,nsshdofmt,
  10771.                      "","",xxstring)) < 0)
  10772.             return(y);
  10773.               outfmt = y;
  10774.               break;
  10775.           }
  10776.           }
  10777.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10778.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10779.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10780.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10781.           }
  10782. #ifdef COMMENT
  10783.           if (!line[0]) {
  10784.           printf("?Key filename required\n");
  10785.           return(-9);
  10786.           }
  10787. #endif /* COMMENT */
  10788.           if ((y = cmcfm()) < 0) /* Confirm */
  10789.         return(y);
  10790. #ifndef SSHTEST
  10791.           switch (outfmt) {
  10792.         case SKDF_OSSH:
  10793.                   /* 2nd param is optional passphrase */
  10794.           x = sshkey_display_public(line[0] ? line : NULL, NULL);
  10795.           break;
  10796.         case SKDF_SSHC:
  10797.                   /* 2nd param is optional passphrase */
  10798.           x = sshkey_display_public_as_ssh2(line[0] ? line : NULL,
  10799.                             NULL);
  10800.           break;
  10801.         case SKDF_IETF:
  10802.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 1);
  10803.           break;
  10804.         case SKDF_FING:
  10805.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 0);
  10806.           break;
  10807.           }
  10808. #endif /* SSHTEST */
  10809.           return(success = (x == 0));
  10810.         }
  10811.         case SSHK_V1:        /* SSH KEY V1 SET-COMMENT */
  10812.           if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0)
  10813.         return(x);
  10814.           if (x != 1) return(-2);
  10815.           if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) {
  10816.           if (x == -3) {
  10817.               printf("?Name of key file required\n");
  10818.               return(-9);
  10819.           }
  10820.           }
  10821.           ckstrncpy(line,s,LINBUFSIZ);
  10822.           if ((x = cmtxt("Comment text","",&s,xxstring)) < 0)
  10823.         return(x);
  10824. #ifndef SSHTEST
  10825.           x = sshkey_v1_change_comment(line,  /* filename */
  10826.                        s,     /* new comment */
  10827.                        NULL   /* passphrase */
  10828.                        );
  10829. #endif /* SSHTEST */
  10830.           success = (x == 0);
  10831.           return(success);
  10832.       }
  10833.       default:
  10834.         return(-2);
  10835.     }
  10836. #else  /* SSHBUILTIN */
  10837. #ifdef SSHCMD
  10838.     x = nettype;
  10839.     if ((y = setlin(XXSSH,0,1)) < 0) {
  10840.         if (errno)
  10841.           printf("?%s\n",ck_errstr());
  10842.             else
  10843. #ifdef COMMENT
  10844.         /* This isn't right either because it catches command editing */
  10845.           printf("?Sorry, pseudoterminal open failed\n");
  10846.             if (hints)
  10847.           printf("Hint: Try \"ssh -t %s\"\n",line);
  10848. #else
  10849.           return(y);
  10850. #endif /* COMMENT */
  10851.         nettype = x;        /* Failed, restore net type. */
  10852.         ttnproto = z;        /* and protocol */
  10853.         success = 0;
  10854.     }
  10855.     didsetlin++;
  10856.     netsave = x;
  10857.     return(y);
  10858. #endif /* SSHCMD */
  10859. #endif /* SSHBUILTIN */
  10860.     }
  10861. #endif /* ANYSSH */
  10862.  
  10863.     if (cx == XXRLOG) {            /* RLOGIN */
  10864. #ifdef RLOGCODE
  10865.     int x,z;
  10866. #ifdef OS2
  10867.     if (!tcp_avail) {
  10868.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  10869. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n"
  10870.            );
  10871.         success = 0;
  10872.         return(-9);
  10873.     } else {
  10874. #endif /* OS2 */
  10875.         x = nettype;        /* Save net type in case of failure */
  10876.         z = ttnproto;        /* Save protocol in case of failure */
  10877.         nettype = NET_TCPB;
  10878.         ttnproto = NP_RLOGIN;
  10879.         if ((y = setlin(XYHOST,0,1)) <= 0) {
  10880.         nettype = x;        /* Failed, restore net type. */
  10881.         ttnproto = z;        /* and protocol */
  10882.         success = 0;
  10883.         }
  10884.         didsetlin++;
  10885. #ifdef OS2
  10886.     }
  10887. #endif /* OS2 */
  10888.     return(y);
  10889. #else
  10890.     printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n");
  10891.     return(-9);
  10892. #endif /* RLOGCODE */
  10893.     }
  10894. #endif /* NETCONN */
  10895. #endif /* NOLOCAL */
  10896.  
  10897. #ifndef NOXMIT
  10898.     if (cx == XXTRA) {            /* TRANSMIT */
  10899.     extern int xfrxla;
  10900.     int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval;
  10901.     int xxecho = 0;
  10902.     int scan = 1;
  10903.     char c;
  10904.     struct FDB sf, sw, tx;        /* FDBs for parse functions */
  10905. #ifndef NOCSETS
  10906.     extern int tcs_transp;        /* Term charset is transparent */
  10907. #else
  10908.     int tcs_transp = 1;
  10909. #endif /* NOCSETS */
  10910.  
  10911. #ifdef COMMENT
  10912.     xbinary = binary;        /* Default text/binary mode */
  10913. #else
  10914.     xbinary = 0;            /* Default is text */
  10915. #endif /* COMMENT */
  10916.     xxecho = xmitx;
  10917.  
  10918.     cmfdbi(&sw,            /* First FDB - command switches */
  10919.            _CMKEY,            /* fcode */
  10920.            "Filename, or switch",    /* hlpmsg */
  10921.            "",            /* default */
  10922.            "",            /* addtl string data */
  10923.            nxmitsw,            /* addtl numeric data 1: tbl size */
  10924.            4,            /* addtl numeric data 2: 4 = cmswi */
  10925.            xxstring,        /* Processing function */
  10926.            xmitsw,            /* Keyword table */
  10927.            &sf            /* Pointer to next FDB */
  10928.            );
  10929.     cmfdbi(&sf,            /* 2nd FDB - file to send */
  10930.            _CMIFI,            /* fcode */
  10931.            "File to transmit",    /* hlpmsg */
  10932.            "",            /* default */
  10933.            "",            /* addtl string data */
  10934.            0,            /* addtl numeric data 1 */
  10935.            0,            /* addtl numeric data 2 */
  10936.            xxstring,
  10937.            NULL,
  10938. #ifdef PIPESEND
  10939.            &tx
  10940. #else
  10941.            NULL
  10942. #endif /* PIPESEND */
  10943.            );
  10944. #ifdef PIPESEND
  10945.         cmfdbi(&tx,
  10946.            _CMTXT,            /* fcode */
  10947.            "Command",        /* hlpmsg */
  10948.            "",            /* default */
  10949.            "",            /* addtl string data */
  10950.            0,            /* addtl numeric data 1 */
  10951.            0,            /* addtl numeric data 2 */
  10952.            xxstring,
  10953.            NULL,
  10954.            NULL
  10955.            );
  10956. #endif /* PIPESEND */
  10957.  
  10958.     while (1) {
  10959.         x = cmfdb(&sw);
  10960.         if (x < 0)
  10961.           return(x);
  10962.         if (cmresult.fcode != _CMKEY)
  10963.           break;
  10964.         c = cmgbrk();        /* Have switch, get break character */
  10965.         if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  10966.         printf("?This switch does not take an argument\n");
  10967.         return(-9);
  10968.         }
  10969.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  10970.         printf("?This switch requires an argument\n");
  10971.         return(-9);
  10972.         }
  10973.         n = cmresult.nresult;    /* Numeric result = switch ID */
  10974.         switch (n) {        /* Process the switch */
  10975. #ifdef PIPESEND
  10976.           case XMI_CMD:        /* Transmit from a command */
  10977.         if (nopush) {
  10978.             printf("?Sorry, system command access is disabled\n");
  10979.             return(-9);
  10980.         }
  10981.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  10982.         xpipe = 1;        /* (No way to undo this one) */
  10983.         break;
  10984. #endif /* PIPESEND */
  10985.  
  10986.           case XMI_BIN:        /* Binary */
  10987.         xbinary = 1;
  10988.         xxlate = 0;        /* Don't translate charsets */
  10989.         scan = 0;
  10990.         break;
  10991.  
  10992.           case XMI_TXT:        /* Text */
  10993.         xbinary = 0;
  10994.         xxlate = !tcs_transp;    /* Translate if TERM CHAR not TRANSP */
  10995.         scan = 0;
  10996.         break;
  10997.  
  10998.           case XMI_TRA:        /* Transparent text */
  10999.         xbinary = 0;
  11000.         xxlate = 0;        /* But don't translate charsets */
  11001.         scan = 0;
  11002.         break;
  11003.  
  11004. #ifdef COMMENT
  11005.           case XMI_VRB:        /* /VERBOSE */
  11006.           case XMI_QUI:        /* /QUIET */
  11007.         break;            /* (not implemented yet) */
  11008. #endif /* COMMENT */
  11009.  
  11010.           case XMI_NOW:        /* /NOWAIT */
  11011.         xxnowait = 1;
  11012.         break;
  11013.  
  11014.           case XMI_NOE:        /* /NOWAIT */
  11015.         xxecho = 0;
  11016.         break;
  11017.  
  11018.           default:
  11019.         return(-2);
  11020.         }
  11021.  
  11022.     }
  11023.     if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT)
  11024.       return(-2);
  11025.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */
  11026.     if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  11027.       ckstrncpy(line,tmpbuf,LINBUFSIZ);
  11028.     s = line;
  11029.     if ((y = cmcfm()) < 0)        /* Confirm */
  11030.       return(y);
  11031. #ifdef CK_APC
  11032.     if ((apcactive == APC_LOCAL) ||
  11033.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  11034.       return(success = 0);
  11035. #endif /* CK_APC */
  11036.     if (cmresult.nresult != 0) {
  11037.         printf("?Only a single file may be transmitted\n");
  11038.         return(-9);
  11039.     }
  11040. #ifdef PIPESEND
  11041.     if (xpipe) {
  11042.         s = brstrip(s);
  11043.         if (!*s) {
  11044.         printf("?Sorry, a command to send from is required\n");
  11045.         return(-9);
  11046.         }
  11047.         pipesend = 1;
  11048.     }
  11049. #endif /* PIPESEND */
  11050.  
  11051.     if (scan && (filepeek
  11052. #ifndef NOXFER
  11053.              || patterns
  11054. #endif /* NOXFER */
  11055.              )) {        /* If user didn't specify type */
  11056.         int k, x;                  /* scan the file to see */
  11057.         x = -1;
  11058.         k = scanfile(s,&x,nscanfile);
  11059.         if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  11060.     }
  11061.     if (!xfrxla) xxlate = 0;
  11062.     success = transmit(s,
  11063.                (char) (xxnowait ? '\0' : (char)xmitp),
  11064.                xxlate,
  11065.                xbinary,
  11066.                xxecho
  11067.                );
  11068.     return(success);
  11069.     }
  11070. #endif /* NOXMIT */
  11071.  
  11072. #ifndef NOFRILLS
  11073.     if (cx == XXTYP  || cx == XXCAT || cx == XXMORE ||
  11074.     cx == XXHEAD || cx == XXTAIL) {
  11075.     int paging = 0, havename = 0, head = 0, width = 0, count = 0;
  11076.     char pfxbuf[64], * prefix = NULL;
  11077.     char outfile[CKMAXPATH+1];
  11078.     struct FDB sf, sw;
  11079.     char * pat = NULL;
  11080.     int incs = 0, outcs = 0, cset = -1, number = 0;
  11081. #ifdef UNICODE
  11082.         char * tocs = "";
  11083.     extern int fileorder;
  11084. #ifdef OS2
  11085. #ifndef NOCSETS
  11086.     extern int tcsr, tcsl;
  11087. #endif /* NOCSETS */
  11088. #endif /* OS2 */
  11089. #endif /* UNICODE */
  11090.  
  11091.     outfile[0] = NUL;
  11092.  
  11093.     if (cx == XXMORE)
  11094.       paging = 1;
  11095.     else if (cx == XXCAT)
  11096.       paging = 0;
  11097.     else
  11098.       paging = (typ_page < 0) ? xaskmore : typ_page;
  11099.     if (paging < 0)
  11100.       paging = saveask;
  11101.  
  11102.     if (cx == XXHEAD) {
  11103.         head = 10;
  11104.         cx = XXTYP;
  11105.     } else if (cx == XXTAIL) {
  11106.         head = -10;
  11107.         cx = XXTYP;
  11108.     }
  11109.  
  11110. #ifdef IKSD
  11111.     if (inserver && !ENABLED(en_typ)) {
  11112.         printf("?Sorry, TYPE command disabled\n");
  11113.         return(-9);
  11114.     }
  11115. #endif /* IKSD */
  11116.  
  11117.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  11118.            _CMKEY,            /* fcode */
  11119.            "Filename or switch",    /* hlpmsg */
  11120.            "",            /* default */
  11121.            "",            /* addtl string data */
  11122.            ntypetab,        /* addtl numeric data 1: tbl size */
  11123.            4,            /* addtl numeric data 2: 4 = cmswi */
  11124.            xxstring,        /* Processing function */
  11125.            typetab,            /* Keyword table */
  11126.            &sf            /* Pointer to next FDB */
  11127.            );
  11128.     cmfdbi(&sf,            /* 1st FDB - file to type */
  11129.            _CMIFI,            /* fcode */
  11130.            "",            /* hlpmsg */
  11131.            "",            /* default */
  11132.            "",            /* addtl string data */
  11133.            0,            /* addtl numeric data 1 */
  11134.            0,            /* addtl numeric data 2 */
  11135.            xxstring,
  11136.            NULL,
  11137.            NULL
  11138.            );
  11139.  
  11140.     while (!havename) {
  11141.         x = cmfdb(&sw);        /* Parse something */
  11142.         debug(F101,"type cmfdb","",x);
  11143.         debug(F101,"type cmresult.fcode","",cmresult.fcode);
  11144.         debug(F101,"type cmresult.nresult","",cmresult.nresult);
  11145.         if (x < 0) {            /* Error */
  11146.         if (x == -3) {
  11147.             x = -9;
  11148.             printf("?Filename required\n");
  11149.         }
  11150.         return(x);
  11151.         } else if (cmresult.fcode == _CMKEY) {
  11152.         char c; int getval;
  11153.         c = cmgbrk();
  11154.         getval = (c == ':' || c == '=');
  11155.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  11156.             printf("?This switch does not take an argument\n");
  11157.             return(-9);
  11158.         }
  11159. #ifdef COMMENT
  11160.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  11161.             printf("?This switch requires an argument\n");
  11162.             /* Not if it has a default! */
  11163.             return(-9);
  11164.         }
  11165. #endif /* COMMENT */
  11166.         switch (cmresult.nresult) {
  11167. #ifdef CK_TTGWSIZ
  11168.           case TYP_PAG:
  11169.             paging = 1;
  11170.             break;
  11171.  
  11172.           case TYP_NOP:
  11173.             paging = 0;
  11174.             break;
  11175. #endif /* CK_TTGWSIZ */
  11176.  
  11177.           case TYP_COU:
  11178.             paging = 0;
  11179.             count = 1;
  11180.             break;
  11181.  
  11182.           case TYP_HEA:
  11183.           case TYP_TAI:
  11184.             y = 10;
  11185.             if (getval)
  11186.               if ((x = cmnum("Number of lines",
  11187.                      "10",10,&y,xxstring)) < 0)
  11188.             return(x);
  11189.             head = (cmresult.nresult == TYP_TAI) ? -y : y;
  11190.             break;
  11191.  
  11192.           case TYP_WID:
  11193.             y = typ_wid > -1 ? typ_wid : cmd_cols;
  11194.             if (getval)
  11195.               if ((x = cmnum("Column at which to truncate",
  11196.                      ckitoa(y),10,&y,xxstring)) < 0)
  11197.             return(x);
  11198.             width = y;
  11199.             break;
  11200.  
  11201.           case TYP_PAT:
  11202.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11203.             printf("?This switch requires an argument\n");
  11204.             return(-9);
  11205.             }
  11206.             if ((x = cmfld("pattern","",&s,xxstring)) < 0)
  11207.               return(x);
  11208.             ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  11209.             pat = tmpbuf;
  11210.             break;
  11211.  
  11212.           case TYP_PFX:
  11213.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11214.             printf("?This switch requires an argument\n");
  11215.             return(-9);
  11216.             }
  11217.             if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0)
  11218.               return(x);
  11219.             if ((int)strlen(s) > 63) {
  11220.             printf("?Too long - 63 max\n");
  11221.             return(-9);
  11222.             }
  11223.             ckstrncpy(pfxbuf,s,64);
  11224.             prefix = brstrip(pfxbuf);
  11225.             number = 0;
  11226.             break;
  11227.  
  11228.           case TYP_NUM:        /* /NUMBER */
  11229.             number = 1;
  11230.             prefix = NULL;
  11231.             break;
  11232.  
  11233. #ifdef UNICODE
  11234.           case TYP_XPA:        /* /TRANSPARENT */
  11235.             incs = 0;
  11236.             cset = 0;
  11237.             outcs = -1;
  11238.             break;
  11239.  
  11240.           case TYP_XIN:        /* /CHARACTER-SET: */
  11241.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11242.             printf("?This switch requires an argument\n");
  11243.             return(-9);
  11244.             }
  11245.             if ((incs = cmkey(fcstab,nfilc,
  11246.                       "character-set name","",xxstring)) < 0) {
  11247.             if (incs == -3)    /* Note: No default */
  11248.               incs = -2;
  11249.             return(incs);
  11250.             }
  11251.             cset = incs;
  11252.             break;
  11253.  
  11254.           case TYP_XUT:        /* /TRANSLATE-TO: */
  11255.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11256.             printf("?This switch requires an argument\n");
  11257.             return(-9);
  11258.             }
  11259. #ifdef OS2
  11260.             if (!inserver && !k95stdout) {
  11261.             tocs = "ucs2";
  11262.             } else {
  11263. #ifdef CKOUNI
  11264.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  11265. #else /* CKOUNI */
  11266.             extern struct keytab ttcstab[];
  11267.             extern int ntxrtab;
  11268.             tocs = rlookup(ttcstab,ntermc,tocs);
  11269.             if (!tocs)
  11270.               tocs = getdcset();
  11271. #endif /* CKOUNI */
  11272.                     }
  11273. #else /* OS2 */
  11274.             tocs = getdcset();
  11275. #endif /* OS2 */
  11276.             if ((outcs = cmkey(fcstab,nfilc,
  11277.                        "character-set",tocs,xxstring)) < 0)
  11278.               return(outcs);
  11279.             break;
  11280. #endif /* UNICODE */
  11281.           case TYP_OUT:
  11282.             if ((x = cmofi("File for result lines","",
  11283.                    &s,xxstring)) < 0)
  11284.               return(x);
  11285.             ckstrncpy(outfile,s,CKMAXPATH);
  11286.             break;
  11287.         }
  11288.         } else if (cmresult.fcode == _CMIFI)
  11289.           havename = 1;
  11290.         else
  11291.           return(-2);
  11292.     }
  11293.     if (havename) {
  11294.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  11295.         y = cmresult.nresult;
  11296.     } else {
  11297.         if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
  11298.         if (x == -3) {
  11299.             printf("?Name of an existing file required\n");
  11300.             return(-9);
  11301.         } else return(x);
  11302.         }
  11303.         ckstrncpy(line,s,LINBUFSIZ);
  11304.     }
  11305.     if (y != 0) {
  11306.         printf("?A single file please\n");
  11307.         return(-9);
  11308.     }
  11309.     if ((y = cmcfm()) < 0)        /* Confirm the command */
  11310.       return(y);
  11311.  
  11312. #ifdef UNICODE
  11313.     fileorder = -1;
  11314.     if (cset < 0 && filepeek) {    /* If no charset switches given */
  11315.         int k, x = -1;
  11316.         k = scanfile(line,&x,nscanfile); /* Call file analyzer */
  11317.         debug(F111,"type scanfile",line,k);
  11318.         debug(F101,"type scanfile flag","",x);
  11319.         switch(k) {
  11320.           case FT_UTF8:        /* which can detect UTF-8... */
  11321.         cset = 0;
  11322.         incs = FC_UTF8;
  11323.         break;
  11324.           case FT_UCS2:        /* and UCS-2... */
  11325.         cset = 0;
  11326.         incs = FC_UCS2;
  11327.         fileorder = x;        /* even if there is no BOM. */
  11328.         debug(F101,"type fileorder","",fileorder);
  11329.         break;
  11330.         }
  11331.     }
  11332. #ifdef OS2
  11333.         if (cset < 0) {            /* If input charset still not known */
  11334. #ifdef CKOUNI
  11335.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  11336. #else /* CKOUNI */
  11337.             extern struct keytab ttcstab[];
  11338.             extern int ntxrtab;
  11339.             tocs = rlookup(ttcstab,ntermc,incs);
  11340.             if (!tocs)
  11341.           tocs = getdcset();
  11342. #endif /* CKOUNI */
  11343.             incs = lookup(fcstab,tocs,nfilc,&x);
  11344.         }
  11345. #endif /* OS2 */
  11346.  
  11347.         if (outcs == 0 && incs != 0) {    /* Supply default target charset */
  11348.         int x = 0;            /* if switch not given. */
  11349.         tocs = getdcset();
  11350.         outcs = lookup(fcstab,tocs,nfilc,&x);
  11351.     }
  11352. #else  /* !UNICODE */
  11353.     if (cset < 0) incs = outcs = 0;
  11354. #endif /* UNICODE */
  11355.  
  11356.     if (outfile[0] && paging)    /* This combination makes no sense */
  11357.       paging = 0;            /* so turn off paging */
  11358.  
  11359.     if (count) paging = -1;
  11360.     debug(F111,"type",line,paging);
  11361.     s = outfile;
  11362.     success =
  11363.       dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number);
  11364.     return(success);
  11365.     }
  11366. #endif /* NOFRILLS */
  11367.  
  11368. #ifndef NOCSETS
  11369.     if (cx == XXXLA) {            /* TRANSLATE file's charset */
  11370.     _PROTOTYP (int doxlate, ( void ) );
  11371.     return(doxlate());
  11372.     }
  11373. #endif /* NOCSETS */
  11374.  
  11375.     if (cx == XXVER) {            /* VERSION */
  11376.     int n = 0;
  11377.     extern char * ck_patch, * ck_s_test;
  11378. #ifdef COMMENT
  11379.     extern int hmtopline;
  11380. #endif /* COMMENT */
  11381.     if ((y = cmcfm()) < 0)
  11382.           return(y);
  11383.  
  11384.     printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum);
  11385.     printf("\n");
  11386.     n = 3;
  11387.     if (*ck_s_test) {
  11388.         printf("\n THIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n");
  11389.         n += 2;
  11390.     }
  11391.     if (*ck_patch) {
  11392.         printf(" Patches: %s\n", ck_patch);
  11393.         n++;
  11394.     }
  11395.     printf(" Type COPYRIGHT for copyright information.\n\n");
  11396. #ifdef OS2
  11397.     shoreg();
  11398. #else
  11399. #ifdef COMMENT
  11400.     hmtopline = n+1;
  11401.     hmsga(copyright);
  11402.     hmtopline = 0;
  11403. #endif /* COMMENT */
  11404. #endif /* OS2 */
  11405.     return(success = 1);
  11406.     }
  11407.  
  11408.     if (cx == XXCPR) {            /* COPYRIGHT or LICENSE */
  11409.     if ((y = cmcfm()) < 0)
  11410.           return(y);
  11411. #ifdef OS2
  11412.     if (inserver) {            /* Free WIKSD */
  11413.         extern char * wiksdcpr[];
  11414.         hmsga(wiksdcpr);
  11415.     } else
  11416. #endif /* OS2 */
  11417.       hmsga(copyright);
  11418.     return(success = 1);
  11419.     }
  11420.  
  11421. #ifndef MAC                /* Only for multiuser systems */
  11422. #ifndef OS2
  11423. #ifndef NOFRILLS
  11424.     if (cx == XXWHO) {            /* WHO */
  11425.     char *wc;
  11426. #ifdef IKSD
  11427.     if (inserver && !ENABLED(en_who)) {
  11428.         printf("?Sorry, WHO command disabled\n");
  11429.         return(-9);
  11430.     }
  11431. #endif /* IKSD */
  11432. #ifdef datageneral
  11433.     if ((z = cmcfm()) < 0) return(z);
  11434.     if (nopush) {
  11435.         printf("?Sorry, who not allowed\n");
  11436.         return(success = 0);
  11437.     }
  11438.         xsystem(WHOCMD);
  11439. #else
  11440.     if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y);
  11441.         if (nopush) {
  11442.         printf("?Sorry, WHO command disabled\n");
  11443.         return(success = 0);
  11444.     }
  11445.     if (!(wc = getenv("CK_WHO"))) wc = WHOCMD;
  11446.     if (wc)
  11447.       if ((int) strlen(wc) > 0) {
  11448.           ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL);
  11449.           xsystem(line);
  11450.       }
  11451. #endif /* datageneral */
  11452.     return(success = 1);
  11453.     }
  11454. #endif /* NOFRILLS */
  11455. #endif /* OS2 */
  11456. #endif /* MAC */
  11457.  
  11458. #ifndef NOFRILLS
  11459.     if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */
  11460.     int x,y;            /* On stack in case of \fexec() */
  11461.     if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) {
  11462.         if (x == -3) printf("?Write to what?\n");
  11463.         return(x);
  11464.     }
  11465.     if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y);
  11466.     s = brstrip(s);
  11467.     switch (x) {
  11468.       case LOGD: y = ZDFILE; break;
  11469.       case LOGP: y = ZPFILE; break;
  11470. #ifndef NOLOCAL
  11471.       case LOGS: y = ZSFILE; break;
  11472. #endif /* NOLOCAL */
  11473.       case LOGT: y = ZTFILE; break;
  11474. #ifndef NOSPL
  11475.       case LOGW: y = ZWFILE; break;
  11476. #endif /* NOSPL */
  11477.       case LOGX:            /* SCREEN (stdout) */
  11478.       case LOGE:            /* ERROR  (stderr) */
  11479.         if (x == LOGE) {
  11480.         debug(F110,
  11481.               (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0);
  11482.         fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : "");
  11483.         } else {
  11484.         debug(F110,
  11485.               (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0);
  11486.         printf("%s%s",s,(cx == XXWRL) ? "\n" : "");
  11487.         }
  11488.         return(success = 1);
  11489.       default: return(-2);
  11490.     }
  11491.     if (chkfn(y) > 0) {
  11492.         x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s);
  11493.         if (x < 0) printf("?Write error\n");
  11494.     } else {
  11495.         x = -1;
  11496.         printf("?File or log not open\n");
  11497.     }
  11498.     return(success = (x == 0) ? 1 : 0);
  11499.     }
  11500. #endif /* NOFRILLS */
  11501.  
  11502. #ifndef NOXFER
  11503.     if (cx == XXASC || cx == XXBIN) {
  11504.     if ((x = cmcfm()) < 0) return(x);
  11505. #ifdef NEWFTP
  11506.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  11507.       return(success = doftptyp((cx == XXASC) ? 0 : 1));
  11508. #endif /* NEWFTP */
  11509.     binary = (cx == XXASC) ? XYFT_T : XYFT_B;
  11510.     return(success = 1);
  11511.     }
  11512. #endif /* NOXFER */
  11513.  
  11514.     if (cx == XXCLS) {
  11515.     if ((x = cmcfm()) < 0) return(x);
  11516.     y = ck_cls();
  11517.     return(success = (y > -1) ? 1 : 0);
  11518.     }
  11519.  
  11520. #ifdef CK_MKDIR
  11521.     if (cx == XXMKDIR || cx == XXLMKD) {
  11522.     char *p;
  11523. #ifdef LOCUS
  11524.     if (!locus && cx != XXLMKD) {
  11525. #ifdef NOXFER
  11526.         return(-2);
  11527. #else
  11528.         return(dormt(XZMKD));
  11529. #endif /* NOXFER */
  11530.         }
  11531. #endif /* LOCUS */
  11532. #ifdef IKSD
  11533.     if (inserver && !ENABLED(en_mkd)) {
  11534.         printf("?Sorry, directory creation is disabled\n");
  11535.         return(-9);
  11536.     }
  11537. #endif /* IKSD */
  11538.     if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) {
  11539.         if (x != -3) {
  11540.         return(x);
  11541.         } else {
  11542.         printf("?Directory name required\n");
  11543.         return(-9);
  11544.         }
  11545.     }
  11546.     ckstrncpy(line,s,LINBUFSIZ);
  11547.     s = line;
  11548.     if ((x = cmcfm()) < 0) return(x);
  11549.     s = brstrip(s);
  11550.     bgchk();            /* Set msgflg */
  11551.     x = ckmkdir(0,s,&p,msgflg,0);
  11552. #ifdef COMMENT
  11553.     if (msgflg && x == 0)
  11554.       printf("?Directory already exists\n");
  11555. #endif /* COMMENT */
  11556.     return(success = (x < 0) ? 0 : 1);
  11557.     }
  11558.     if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */
  11559.     char *p;
  11560. #ifdef LOCUS
  11561.     if (!locus && cx != XXLRMD) {
  11562. #ifdef NOXFER
  11563.         return(-2);
  11564. #else
  11565.         return(dormt(XZRMD));
  11566. #endif /* NOXFER */
  11567.         }
  11568. #endif /* LOCUS */
  11569. #ifdef IKSD
  11570.     if (inserver && !ENABLED(en_rmd)) {
  11571.         printf("?Sorry, directory removal is disabled\n");
  11572.         return(-9);
  11573.     }
  11574. #endif /* IKSD */
  11575.     if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0)
  11576.       return(x);
  11577.     ckstrncpy(line,s,LINBUFSIZ);
  11578.     s = line;
  11579.     if ((x = cmcfm()) < 0) return(x);
  11580.     s = brstrip(s);
  11581.     x = ckmkdir(1,s,&p,msgflg,0);
  11582.     return(success = (x < 0) ? 0 : 1);
  11583.     }
  11584. #endif /* CK_MKDIR */
  11585.  
  11586. #ifdef TNCODE
  11587.     if (cx == XXTELOP)
  11588.       return(dotelopt());
  11589. #endif /* TNCODE */
  11590.  
  11591. #ifndef NOPUSH
  11592.     if (cx == XXNPSH) {
  11593.     if ((z = cmcfm()) < 0) return(z);
  11594.         nopush = 1;
  11595. #ifndef NOSERVER
  11596.         en_hos = 0;
  11597. #endif /* NOSERVER */
  11598. #ifdef PIPESEND
  11599.     usepipes = 0;
  11600. #endif /* PIPESEND */
  11601.         return(success = 1);
  11602.     }
  11603. #endif /* NOPUSH */
  11604.  
  11605. #ifndef NOSPL
  11606.     if (cx == XXLOCAL)            /* LOCAL variable declarations */
  11607.       return(success = dolocal());
  11608. #endif /* NOSPL */
  11609.  
  11610.     if (cx == XXKERMI) {        /* The KERMIT command */
  11611.     char * list[65];
  11612.     extern char **xargv;
  11613.     extern int xargc;
  11614.     int i;
  11615.     if ((y = cmtxt("kermit command-line arguments, -h for help",
  11616.                "",&s,xxstring)) < 0)
  11617.       return(y);
  11618.     ckstrncpy(line,"kermit ",LINBUFSIZ);
  11619.     ckstrncat(line,s,LINBUFSIZ-8);
  11620.     xwords(line,64,list,0);
  11621.     for (i = 1; i < 64; i++) {
  11622.         if (!list[i])
  11623.           break;
  11624.     }
  11625.     i--;
  11626.     xargc = i;
  11627.     xargv = list;
  11628.     xargv++;
  11629.     sstate = cmdlin();
  11630.     if (sstate) {
  11631.         extern int justone;
  11632.         debug(F000,"KERMIT sstate","",sstate);
  11633.         justone = 1;        /* Force return to command mode */
  11634.         proto();            /* after protocol */
  11635.         return(success);
  11636.     } else {
  11637.         debug(F101,"KERMIT sstate","",sstate);
  11638.         return(success = 1);    /* Not exactly right, but... */
  11639.     }
  11640.     }
  11641.     if (cx == XXDATE) {            /* DATE command */
  11642.     extern char cmdatebuf[], * cmdatemsg;
  11643.  
  11644. #ifndef COMMENT
  11645.     char * dp;
  11646.     if ((y = cmtxt("date and/or time, or carriage return for current",
  11647.                "",&s,xxstring)) < 0)
  11648.       return(y);
  11649.     s = brstrip(s);
  11650.     dp = cmcvtdate(s,1);
  11651.     if (!dp) {
  11652.         printf("?%s\n",cmdatemsg ? cmdatemsg : "Date conversion error");
  11653.         success = 0;
  11654.     } else {
  11655.         printf("%s\n",dp);
  11656.         success = 1;
  11657.     }
  11658. #else
  11659.     /* This works fine but messes up my "dates" torture-test script */
  11660.  
  11661.     if ((x = cmdate("Date and/or time, or carriage return for current",
  11662.             "",&s,0,xxstring)) < 0) {
  11663.         return(x);
  11664.     } else {
  11665.         printf("%s\n",cmdatebuf);
  11666.         success = 1;
  11667.     }
  11668. #endif /* COMMENT */
  11669.     return(success);
  11670.     }
  11671. #ifndef NOPUSH
  11672. #ifndef NOFRILLS
  11673.     if (cx == XXEDIT)
  11674.       return(doedit());
  11675. #endif /* NOFRILLS */
  11676. #endif /* NOPUSH */
  11677.  
  11678. #ifdef BROWSER                /* Defined only ifndef NOPUSH */
  11679.     if (cx == XXBROWS)
  11680.       return(dobrowse());
  11681. #endif /* BROWSER */
  11682.  
  11683. #ifdef CK_TAPI
  11684.     if (cx == XXTAPI) {            /* Microsoft TAPI */
  11685.     return (success = dotapi());
  11686.     }
  11687. #endif /* CK_TAPI */
  11688.  
  11689. #ifndef NOXFER
  11690.     if (cx == XXWHERE) {
  11691.     extern char * rfspec, * sfspec, * srfspec, * rrfspec;
  11692.     if ((x = cmcfm()) < 0) return(x);
  11693.     printf("\nFile most recently...\n\n");
  11694.     printf("  Sent:       %s\n",   sfspec ? sfspec : "(none)");
  11695.     if (sfspec && srfspec) {
  11696.         printf("  Stored as:  %s\n",   srfspec);
  11697.         printf("\n");
  11698.     }
  11699.     printf("  Received:   %s\n",   rrfspec ? rrfspec : "(none)");
  11700.     if (rfspec && rrfspec)
  11701.     printf("  Stored as:  %s\n",   rfspec);
  11702.     printf(
  11703. "\nIf the full path is not shown, then the file is probably in your current\n"
  11704.            );
  11705.     printf(
  11706. "directory or your download directory (if any - SHOW FILE to find out).\n\n"
  11707.            );
  11708.     return(success = 1);
  11709.     }
  11710. #endif /* NOXFER */
  11711.  
  11712. #ifdef CK_RECALL
  11713.     if (cx == XXREDO)
  11714.       return(doredo());
  11715. #endif /* CK_RECALL */
  11716.  
  11717. #ifdef CKROOT
  11718.     if (cx == XXCHRT)            /* Change Kermit's root directory */
  11719.       return(dochroot());
  11720. #endif /* CKROOT */
  11721.  
  11722. #ifdef CK_KERBEROS
  11723.     if (cx == XXAUTH) {            /* KERBEROS */
  11724.     x = cp_auth();            /* Parse it */
  11725. #ifdef IKSD
  11726.         if (inserver) {
  11727.             printf("?Command disabled in IKSD.\r\n");
  11728.             return(success = 0);
  11729.         }
  11730. #endif /* IKSD */
  11731.     if (x < 0)            /* Pass parse errors back */
  11732.       return(x);
  11733.     return(success = doauth(cx));
  11734.     }
  11735. #endif /* CK_KERBEROS */
  11736.  
  11737. #ifndef NOLOCAL
  11738.     if (cx == XXTERM) {
  11739.     return(settrmtyp());
  11740.     }
  11741. #endif /* NOLOCAL */
  11742.  
  11743.     if (cx == XXSTATUS) {
  11744.     if ((x = cmcfm()) < 0) return(x);
  11745.     printf( " %s\n", success ? "SUCCESS" : "FAILURE" );
  11746.     return(0);            /* Don't change it */
  11747.     }
  11748.  
  11749.     if (cx == XXFAIL) {
  11750.     if ((x = cmcfm()) < 0) return(x);
  11751.     return(success = 0);
  11752.     }
  11753.  
  11754.     if (cx == XXSUCC) {
  11755.     if ((x = cmcfm()) < 0) return(x);
  11756.     return(success = 1);
  11757.     }
  11758.  
  11759.     if (cx == XXNLCL) {
  11760.     extern int nolocal;
  11761.     if ((x = cmcfm()) < 0) return(x);
  11762.     nolocal = 1;
  11763.     return(success = 1);
  11764.     }
  11765.  
  11766. #ifndef NOXFER
  11767.     if (cx == XXRASG)            /* Shortcuts for REMOTE commands */
  11768.       return(dormt(XZASG));
  11769.     if (cx == XXRCWD)
  11770.       return(dormt(XZCWD));
  11771.     if (cx == XXRCPY)
  11772.       return(dormt(XZCPY));
  11773.     if (cx == XXRDEL)
  11774.       return(dormt(XZDEL));
  11775.     if (cx == XXRDIR)
  11776.       return(dormt(XZDIR));
  11777.     if (cx == XXRXIT)
  11778.       return(dormt(XZXIT));
  11779.     if (cx == XXRHLP)
  11780.       return(dormt(XZHLP));
  11781.     if (cx == XXRHOS)
  11782.       return(dormt(XZHOS));
  11783.     if (cx == XXRKER)
  11784.       return(dormt(XZKER));
  11785.     if (cx == XXRPWD)
  11786.       return(dormt(XZPWD));
  11787.     if (cx == XXRQUE)
  11788.       return(dormt(XZQUE));
  11789.     if (cx == XXRREN)
  11790.       return(dormt(XZREN));
  11791.     if (cx == XXRMKD)
  11792.       return(dormt(XZMKD));
  11793.     if (cx == XXRRMD)
  11794.       return(dormt(XZRMD));
  11795.     if (cx == XXRSET)
  11796.       return(dormt(XZSET));
  11797.     if (cx == XXRSPA)
  11798.       return(dormt(XZSPA));
  11799.     if (cx == XXRTYP)
  11800.       return(dormt(XZTYP));
  11801.     if (cx == XXRWHO)
  11802.       return(dormt(XZWHO));
  11803.     if (cx == XXRCDUP)
  11804.       return(dormt(XZCDU));
  11805.     if (cx == XXRPRI)
  11806.       return(dormt(XZPRI));
  11807. #endif /* NOXFER */
  11808.  
  11809.     if (cx == XXRESET) {        /* RESET */
  11810.     if ((x = cmcfm()) < 0)
  11811.       return(x);
  11812.     doclean(0);            /* Close all files */
  11813.     return(success = 1);
  11814.     }
  11815.  
  11816. #ifndef NOXFER
  11817. #ifndef NOCSETS
  11818.     if (cx == XXASSOC)            /* ASSOCIATE */
  11819.       return(doassoc());
  11820. #endif /* NOCSETS */
  11821. #endif /* NOXFER */
  11822.  
  11823. #ifndef NOSPL
  11824.     if (cx == XXSHIFT) {        /* SHIFT */
  11825.     if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0)
  11826.       return(y);
  11827.     if ((z = cmcfm()) < 0)
  11828.       return(z);
  11829.     return(success = doshift(x));
  11830.     }
  11831. #endif /* NOSPL */
  11832.  
  11833. #ifndef NOHELP
  11834.     if (cx == XXMAN)
  11835.       return(domanual());
  11836. #endif /* NOHELP */
  11837.  
  11838. #ifndef NOSPL
  11839.     if (cx == XXSORT)            /* SORT an array */
  11840.       return(dosort());
  11841. #endif /* NOSPL */
  11842.  
  11843.     if (cx == XXPURGE) {
  11844. #ifdef IKSD
  11845.     if (inserver && (!ENABLED(en_del)
  11846. #ifdef CK_LOGIN
  11847.                           || isguest
  11848. #endif /* CK_LOGIN */
  11849.              )) {
  11850.         printf("?Sorry, DELETE is disabled\n");
  11851.         return(-9);
  11852.     }
  11853. #endif /* IKSD */
  11854. #ifdef CK_APC
  11855.     if ((apcactive == APC_LOCAL) ||
  11856.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  11857.       return(success = 0);
  11858. #endif /* CK_APC */
  11859. #ifdef CKPURGE
  11860.         return(dopurge());
  11861. #else
  11862. #ifdef VMS
  11863.     if ((x = cmtxt("optional switches followed by filespec",
  11864.                "",&s,xxstring)) < 0)
  11865.       return(x);
  11866.     if (nopush) {
  11867.         printf("?Sorry, DCL access is disabled\n");
  11868.         return(-9);
  11869.     }
  11870.     ckstrncpy(line,s,LINBUFSIZ);
  11871.     s = line;
  11872.     x = mlook(mactab,"purge",nmac);
  11873.     return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs));
  11874. #else
  11875.     return(-2);
  11876. #endif /* VMS */
  11877. #endif /* CKPURGE */
  11878.     }
  11879.  
  11880. #ifndef NOSPL
  11881.     if (cx == XXFAST) {
  11882.     if ((x = cmcfm()) < 0) return(x);
  11883.     x = mlook(mactab,"fast",nmac);
  11884.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11885.     }
  11886.     if (cx == XXCAU) {
  11887.     if ((x = cmcfm()) < 0) return(x);
  11888.     x = mlook(mactab,"cautious",nmac);
  11889.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11890.     }
  11891.     if (cx == XXROB) {
  11892.     if ((x = cmcfm()) < 0) return(x);
  11893.     x = mlook(mactab,"robust",nmac);
  11894.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11895.     }
  11896. #endif /* NOSPL */
  11897.  
  11898.     if (cx == XXSCRN) {            /* SCREEN */
  11899.     int row, col;
  11900.     if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0)
  11901.       return(x);
  11902.     switch (x) {            /* MOVE-TO (cursor position) */
  11903.       case SCN_MOV:
  11904.         if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0)
  11905.           return(y);
  11906.         row = z;
  11907.         y = cmnum("Column (1-based)","1",10,&z,xxstring);
  11908.         if (y < 0)
  11909.           return(y);
  11910.         col = z;
  11911.         if ((y = cmcfm()) < 0)
  11912.           return(y);
  11913.         if (row < 0 || col < 0) {
  11914.         printf("?Row and Column must be 1 or greater\n");
  11915.         return(-9);
  11916.         }
  11917.         if (cmd_rows > 0 && row > cmd_rows)
  11918.           row = cmd_rows;
  11919.         if (cmd_cols > 0 && col > cmd_cols)
  11920.           col = cmd_cols;
  11921.         y = ck_curpos(row,col);
  11922.         return(success = (y > -1) ? 1 : 0);
  11923.  
  11924.       case SCN_CLR:            /* CLEAR */
  11925.         if ((y = cmcfm()) < 0)
  11926.           return(y);
  11927.         debug(F100,"screen calling ck_cls()","",0);
  11928.         y = ck_cls();
  11929.         return(success = (y > -1) ? 1 : 0);
  11930.  
  11931.       case SCN_CLE:            /* CLEOL */
  11932.         if ((y = cmcfm()) < 0)
  11933.           return(y);
  11934.         y = ck_cleol();
  11935.         return(success = (y > -1) ? 1 : 0);
  11936.     }
  11937.     }
  11938.  
  11939. #ifndef NOHTTP
  11940. #ifdef TCPSOCKET
  11941.     if (cx == XXHTTP)
  11942.       return(dohttp());
  11943. #endif /* TCPSOCKET */
  11944. #endif /* NOHTTP */
  11945.  
  11946. #ifndef NOSPL
  11947.     if (cx == XXARRAY) {        /* ARRAY */
  11948. #ifndef NOSHOW
  11949.     extern int showarray();
  11950. #endif /* NOSHOW */
  11951.     if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0)
  11952.       return(x);
  11953.     switch (x) {
  11954.       case ARR_DCL:
  11955.         return(dodcl(XXDCL));
  11956.       case ARR_SRT:
  11957.         return(dosort());
  11958. #ifndef NOSHOW
  11959.       case ARR_SHO:
  11960.         return(showarray());
  11961. #endif /* NOSHOW */
  11962.       case ARR_CPY:
  11963.         return(copyarray());
  11964.       case ARR_SET:
  11965.       case ARR_CLR:
  11966.         return(clrarray(x));
  11967.       case ARR_DST:
  11968.         return(unarray());
  11969.       case ARR_RSZ:
  11970.         return(rszarray());
  11971.       case ARR_EQU:
  11972.         return(linkarray());
  11973.  
  11974.       default:
  11975.         printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf);
  11976.         return(-9);
  11977.     }
  11978.     }
  11979.     if (cx == XXTRACE)
  11980.       return(dotrace());
  11981. #endif /* NOSPL */
  11982.  
  11983. #ifdef CK_PERMS
  11984. #ifdef UNIX
  11985.     if (cx == XXCHMOD)
  11986.       return(douchmod());        /* Do Unix chmod */
  11987. #endif /* UNIX */
  11988. #endif /* CK_PERMS */
  11989.  
  11990.     if (cx == XXPROMP)
  11991.       return(doprompt());
  11992.  
  11993.     if (cx == XXGREP)
  11994.       return(dogrep());
  11995.  
  11996.     if (cx == XXDEBUG) {        /* DEBUG */
  11997. #ifndef DEBUG
  11998.     int dummy = 0;
  11999.     return(seton(&dummy));
  12000. #else
  12001.     return(seton(&deblog));
  12002. #endif /* DEBUG */
  12003.     }
  12004.  
  12005. #ifdef CKLEARN
  12006.     if (cx == XXLEARN) {        /* LEARN */
  12007.     struct FDB of, sw, cm;
  12008.     int closing = 0, off = 0, on = 0, confirmed = 0;
  12009.     char c;
  12010.  
  12011.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  12012.            _CMKEY,            /* fcode */
  12013.            "Script file name, or switch", /* hlpmsg */
  12014.            "",            /* default */
  12015.            "",            /* addtl string data */
  12016.            3,            /* addtl numeric data 1: tbl size */
  12017.            4,            /* addtl numeric data 2: 4 = cmswi */
  12018.            xxstring,        /* Processing function */
  12019.            learnswi,        /* Keyword table */
  12020.            &of            /* Pointer to next FDB */
  12021.            );
  12022.     cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm);
  12023.     cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL);
  12024.     line[0] = NUL;
  12025.  
  12026.     while (!confirmed) {
  12027.         x = cmfdb(&sw);        /* Parse something */
  12028.         if (x < 0)
  12029.           return(x);
  12030.         switch (cmresult.fcode) {    /* What was it? */
  12031.           case _CMOFI:        /* Output file name */
  12032.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  12033.         break;
  12034.           case _CMKEY:        /* Switch */
  12035.         c = cmgbrk();
  12036.         if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) {
  12037.             printf("?This switch does not take an argument\n");
  12038.             return(-9);
  12039.         }
  12040.         switch (cmresult.nresult) {
  12041.           case 2:        /* /CLOSE */
  12042.             closing = 1;    /* Fall thru on purpose */
  12043.           case 0:        /* /OFF */
  12044.             off = 1;
  12045.             on = 0;
  12046.             break;
  12047.           case 1:        /* /ON */
  12048.             on = 1;
  12049.             off = 0;
  12050.             break;
  12051.         }
  12052.         break;
  12053.           case _CMCFM:        /* Confirmation */
  12054.         confirmed++;
  12055.         break;
  12056.         }
  12057.     }
  12058.     if (closing) {
  12059.         if (learnfp) {
  12060.         fclose(learnfp);
  12061.         learnfp = NULL;
  12062.         }
  12063.         makestr(&learnfile,NULL);
  12064.     }
  12065.     if (line[0]) {
  12066.         if (!on && !off)
  12067.           on = 1;
  12068.         if (learnfp) {
  12069.         fclose(learnfp);
  12070.         learnfp = NULL;
  12071.         }
  12072.         makestr(&learnfile,line);
  12073.         if (learnfile) {
  12074.         char * modes = "w";
  12075.         learnfp = fopen(learnfile,modes);
  12076.         if (!learnfp) {
  12077.             debug(F110,"LEARN file open error",learnfile,0);
  12078.             perror(learnfile);
  12079.             return(-9);
  12080.         } else {
  12081. #ifdef ZFNQFP
  12082.             if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf))
  12083.               makestr(&learnfile,tmpbuf);
  12084. #endif /* ZFNQFP */
  12085.             debug(F110,"LEARN file open ok",learnfile,0);
  12086.             if (!quiet) {
  12087.             printf("Recording to %s...\n\n",learnfile);
  12088.             printf(
  12089. " WARNING: If you type your password during script recording, it will appear\n\
  12090.  in the file.  Be sure to edit it or take other appropriate precautions.\n\n"
  12091.                    );
  12092.             }
  12093.             fputs(  "; Scriptfile: ",learnfp);
  12094.             fputs(learnfile,learnfp);
  12095.             fputs("\n; Directory:  ",learnfp);
  12096.             fputs(zgtdir(),learnfp);
  12097.             fputs("\n; Recorded:   ",learnfp);
  12098.             fputs(ckdate(),learnfp);
  12099.             fputs("\n",learnfp);
  12100.         }
  12101.         }
  12102.     }
  12103.     if (on) {
  12104.         learning = 1;
  12105.     } else if (off) {
  12106.         learning = 0;
  12107.     }
  12108.     debug(F101,"LEARN learning","",learning);
  12109.     return(success = 1);
  12110.     }
  12111. #endif /* CKLEARN */
  12112.  
  12113. #ifdef NEWFTP
  12114.     if (cx == XXUSER || cx == XXACCT) {
  12115.     if (!ftpisopen()) {
  12116.         printf("?FTP connection is not open\n");
  12117.         return(-9);
  12118.     }
  12119.     return(success = (cx == XXUSER) ? doftpusr() : doftpacct());
  12120.     }
  12121.     if (cx == XXSITE || cx == XXPASV) {
  12122.     if (!ftpisopen()) {
  12123.         printf("?FTP connection is not open\n");
  12124.         return(-9);
  12125.     }
  12126.     return(success = (cx == XXSITE) ? doftpsite() : dosetftppsv());
  12127.     }
  12128. #endif /* NEWFTP */
  12129.  
  12130.     if (cx == XXORIE) {            /* ORIENTATION */
  12131.     extern char * myname;
  12132.     int i, y, n = 0;
  12133.         char * s, *p, vbuf[32];
  12134.     char * vars[16];       char * legend[16];
  12135.  
  12136.     if ((y = cmcfm()) < 0)
  12137.       return(y);
  12138.  
  12139.     printf("\nProgram name:\n  %s\n\n",myname);
  12140.     n += 4;
  12141.  
  12142. #ifdef NT
  12143.     vars[0] = "home";      legend[0] = "Your home directory";
  12144.     vars[1] = "directory"; legend[1] = "K95's current directory";
  12145.     vars[2] = "exedir";    legend[2] = "K95 Program directory";
  12146.     vars[3] = "inidir";    legend[3] = "K95 Initialization file directory";
  12147.     vars[4] = "startup";   legend[4] = "Current directory when started";
  12148.     
  12149.         vars[5] = "common";
  12150.         legend[5] = "K95 data for all users and K95SITE.INI file";
  12151.     
  12152.         vars[6] = "personal";  legend[6] = "Your personal data directory tree";
  12153.         vars[7] = "desktop";   legend[7] = "Your deskop directory tree";
  12154.     
  12155.         vars[8] = "appdata";
  12156.         legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file";
  12157.     
  12158.         vars[9] = "download";  legend[9] = "Your K95 download directory";
  12159.         vars[10] = "tmpdir";   legend[10] = "Your TEMP directory";
  12160.     vars[11] = NULL;       legend[11] = NULL;
  12161.  
  12162.     for (i = 0; i < 16 && vars[i]; i++) {
  12163.         printf("%s:\n",legend[i]);
  12164.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12165.         ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
  12166.         printf("  Variable:   %s\n",vbuf);
  12167.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12168.         y = TMPBUFSIZ;
  12169.         s = tmpbuf;
  12170.         zzstring(vbuf,&s,&y);
  12171.         line[0] = NUL;
  12172.         ckGetLongPathName(tmpbuf,line,LINBUFSIZ);
  12173.         printf("  Long name:  %s\n",line);
  12174.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12175.         line[0] = NUL;
  12176.         GetShortPathName(tmpbuf,line,LINBUFSIZ);
  12177.         printf("  Short name: %s\n",line);
  12178.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12179.             printf("\n");
  12180.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12181.     }
  12182. #else  /* NT */
  12183.  
  12184.     vars[0] = "home";      legend[0] = "Your home directory";
  12185.     vars[1] = "directory"; legend[1] = "Kermit's current directory";
  12186.     vars[2] = "exedir";    legend[2] = "Kermit's program directory";
  12187.     vars[3] = "inidir";    legend[3] = "Initialization file directory";
  12188.     vars[4] = "startup";   legend[4] = "Current directory when started";
  12189.     vars[5] = "download";  legend[5] = "Kermit download directory";
  12190.     vars[6] = NULL;           legend[6] = NULL;
  12191.  
  12192.     for (i = 0; i < 16 && vars[i]; i++) {
  12193.         printf("%s:\n",legend[i]);
  12194.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12195.         ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
  12196.         printf("  Variable: %s\n",vbuf);
  12197.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12198.         y = TMPBUFSIZ;
  12199.         s = tmpbuf;
  12200.         zzstring(vbuf,&s,&y);
  12201.             printf("  Value:    %s\n",tmpbuf);
  12202.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12203.             printf("\n");
  12204.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  12205.     }
  12206. #endif /* NT */
  12207.     return(success = 1);
  12208.     }
  12209.  
  12210. #ifdef NT
  12211.     if (cx == XXDIALER) {
  12212.         StartDialer();
  12213.         return(success = 1);
  12214.     }
  12215. #endif /* NT */
  12216.  
  12217.     if (cx == XXCONT) {            /* CONTINUE */
  12218.     if ((x = cmcfm()) < 0)
  12219.       return(x);
  12220.     if (!xcmdsrc) {            /* At prompt: continue script */
  12221.         if (cmdlvl > 0)
  12222.           popclvl();        /* Pop command level */
  12223.         return(success = 1);    /* always succeeds */
  12224. #ifndef NOSPL
  12225.     } else {            /* In script: whatever... */
  12226.         x = mlook(mactab,"continue",nmac);
  12227.         return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  12228. #endif /* NOSPL */
  12229.     }
  12230.     }
  12231.  
  12232.     if (cx == XXNOTAV) {        /* Command in table not available */
  12233.     ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  12234.     if ((x = cmtxt("Rest of command","",&s,NULL)) < 0)
  12235.       return(x);
  12236.     printf("Sorry, \"%s\" not configured in this version of Kermit.\n",
  12237.            tmpbuf
  12238.            );
  12239.     return(success = 0);
  12240.     }
  12241.     return(-2);                /* None of the above */
  12242.  
  12243. } /* end of docmd() */
  12244.  
  12245. #endif /* NOICP */
  12246.