home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckuusr.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  350KB  |  13,128 lines

  1. #ifdef SSHTEST
  2. #define SSHBUILTIN
  3. #endif /* SSHTEST */
  4.  
  5. #include "ckcsym.h"
  6. char *userv = "User Interface 8.0.284, 29 Dec 2005";
  7.  
  8. /*  C K U U S R --  "User Interface" for C-Kermit (Part 1)  */
  9.  
  10. /*
  11.   Authors:
  12.     Frank da Cruz <fdc@columbia.edu>,
  13.       The Kermit Project, Columbia University, New York City
  14.     Jeffrey E Altman <jaltman@secure-endpoints.com>
  15.       Secure Endpoints Inc., New York City
  16.  
  17.   Copyright (C) 1985, 2005,
  18.     Trustees of Columbia University in the City of New York.
  19.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  20.     copyright text in the ckcmai.c module for disclaimer and permissions.
  21. */
  22.  
  23. /*
  24.   Originally the entire user interface was in one module, ckuusr.c.  Over
  25.   the years it has been split into many modules: ckuus2.c, ckuus3.c, ...,
  26.   ckuus7.c.  ckuus2.c contains the HELP command parser and help-text strings;
  27.   ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains
  28.   routines needed by both the command-line interface and the interactive
  29.   command parser.
  30. */
  31.  
  32. /*
  33.   The ckuus*.c modules depend on the existence of C library features like
  34.   fopen, fgets, feof, (f)printf, argv/argc, etc.  Other functions that are
  35.   likely to vary among different platforms -- like setting terminal modes or
  36.   interrupts -- are invoked via calls to functions that are defined in the
  37.   system- dependent modules, ck?[ft]io.c.  The command line parser processes
  38.   any arguments found on the command line, as passed to main() via argv/argc.
  39.   The interactive parser uses the facilities of the cmd package (developed for
  40.   this program, but usable by any program).  Any command parser may be
  41.   substituted for this one.  The only requirements for the Kermit command
  42.   parser are these:
  43.  
  44.   . Set parameters via global variables like duplex, speed, ttname, etc.  See
  45.     ckmain.c for the declarations and descriptions of these variables.
  46.  
  47.   . If a command can be executed without the use of Kermit protocol, then
  48.     execute the command directly and set the variable sstate to 0. Examples
  49.     include 'set' commands, local directory listings, the 'connect' command.
  50.  
  51.   . If a command requires the Kermit protocol, set the following variables:
  52.  
  53.      sstate                             string data
  54.        'x' (enter server mode)            (none)
  55.        'r' (send a 'get' command)         cmarg, cmarg2
  56.        'v' (enter receive mode)           cmarg2
  57.        'g' (send a generic command)       cmarg
  58.        's' (send files)                   nfils, cmarg & cmarg2 OR cmlist
  59.        'c' (send a remote host command)   cmarg
  60.  
  61.      cmlist is an array of pointers to strings.
  62.      cmarg, cmarg2 are pointers to strings.
  63.      nfils is an integer.
  64.  
  65.      cmarg can be a filename string (possibly wild), or
  66.     a pointer to a prefabricated generic command string, or
  67.     a pointer to a host command string.
  68.      cmarg2 is an "as-name" - the name to send file(s) under, or
  69.     the name under which to store incoming file(s); must not be wild.
  70.     A null or empty value means to use the file's own name.
  71.      cmlist is a list of filenames, such as passed via argv.
  72.      nfils is an integer, interpreted as follows:
  73.        -1: filespec (possibly wild) in cmarg, must be expanded internally.
  74.     0: send from stdin (standard input).
  75.        >0: number of files to send, from cmlist.
  76.  
  77.   The screen() function is used to update the screen during file transfer.
  78.   The tlog() function writes to a transaction log.
  79.   The debug() function writes to a debugging log.
  80.   The intmsg() and chkint() functions provide the user i/o for interrupting
  81.     file transfers.
  82. */
  83.  
  84. /* Includes */
  85.  
  86. #ifdef MULTINET
  87. #define MULTINET_OLD_STYLE        /* Leave select prototype undefined */
  88. #endif /* MULTINET */
  89.  
  90. #include "ckcdeb.h"
  91. #include "ckcasc.h"
  92. #include "ckcker.h"
  93. #include "ckcnet.h"            /* Network symbols */
  94. #include "ckuusr.h"
  95. #include "ckcxla.h"
  96.  
  97. int g_fncact = -1;            /* Needed for NOICP builds */
  98. int noinit = 0;                /* Flag for skipping init file */
  99. int nscanfile = SCANFILEBUF;
  100.  
  101. int rcdactive = 0;            /* RCD active */
  102. int keepallchars = 0;            /* See cmfld() */
  103.  
  104. int locus = 1;                /* Current LOCUS is LOCAL */
  105. #ifdef OS2
  106. int autolocus = 2;            /* Automatic LOCUS switching: ASK */
  107. #else /* OS2 */
  108. int autolocus = 1;            /* Automatic LOCUS switching enabled */
  109. #endif /* OS2 */
  110.  
  111. #ifndef NOICP
  112. #ifdef CKLEARN
  113. #ifdef VMS
  114. #include <time.h>            /* For CKLEARN */
  115. #endif /* VMS */
  116. #endif /* CKLEARN */
  117. #ifdef OS2
  118. #ifndef NT
  119. #define INCL_NOPM
  120. #define INCL_VIO            /* Needed for ckocon.h */
  121. #include <os2.h>
  122. #undef COMMENT
  123. #else
  124. #define APIRET ULONG
  125. #include <windows.h>
  126. #include <tapi.h>
  127. #include "cknwin.h"
  128. #include "ckntap.h"            /* CK_TAPI definition */
  129. #endif /* NT */
  130. #include "ckowin.h"
  131. #include "ckocon.h"
  132. extern int tcp_avail;
  133. extern bool viewonly;
  134. extern int k95stdout;
  135. extern int tt_scroll;
  136. #ifndef NOTERM
  137. extern tt_status[VNUM];
  138. #endif /* NOTERM */
  139. int display_demo = 1;
  140. #include "ckossh.h"
  141. #ifdef KUI
  142. #include "ikui.h"
  143. #endif /* KUI */
  144. #endif /* OS2 */
  145.  
  146. int optlines = 0;
  147. int didsetlin = 0;
  148.  
  149. #ifdef NEWFTP
  150. extern int ftpget, ftpisopen(), doftpres();
  151. _PROTOTYP(int doftptyp,(int));
  152. #endif /* NEWFTP */
  153.  
  154. #ifdef VMS
  155. extern int batch;
  156. #endif /* VMS */
  157.  
  158. #ifdef datageneral
  159. #include <packets:common.h>
  160. #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
  161. #endif /* datageneral */
  162.  
  163. extern int xcmdsrc, hints, cmflgs, whyclosed;
  164.  
  165. char * hlptok = NULL;
  166.  
  167. #ifdef CK_TTGWSIZ            /* Whether to use more-prompting */
  168. int xaskmore = 1;            /* Momentary setting */
  169. int saveask  = 1;            /* Permanent setting */
  170. #else
  171. int xaskmore = 0;
  172. int saveask  = 0;
  173. #endif /* CK_TTGWSIZ */
  174.  
  175. #ifndef NOCSETS
  176. extern int nfilc;
  177. extern struct keytab fcstab[];
  178. extern int fcharset;
  179. #endif /* NOCSETS */
  180.  
  181. char * g_pswd = NULL;
  182. int g_pcpt = -1;
  183. int g_pflg = -1;
  184.  
  185. extern int cmd_rows, cmd_cols;
  186.  
  187. #ifdef CKROOT
  188. extern int ckrooterr;
  189. #endif /* CKROOT */
  190.  
  191. extern int inserver, filepeek;
  192.  
  193. #ifdef CKLEARN
  194. FILE * learnfp = NULL;
  195. char * learnfile = NULL;
  196. int learning = 0;
  197. #endif /* CKLEARN */
  198.  
  199. #ifndef NOXFER
  200. extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size,
  201.   sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz,
  202.   spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable,
  203.   setreliable;
  204.  
  205. #ifdef IKSDCONF
  206. extern int iksdcf;
  207. #endif /* IKSDCONF */
  208.  
  209. #ifdef CK_LOGIN
  210. extern int isguest;
  211. #endif /* CK_LOGIN */
  212.  
  213. extern CK_OFF_T sendstart;
  214.  
  215. extern char *cmarg, *cmarg2, **cmlist, *dftty;
  216.  
  217. extern struct keytab fntab[]; extern int nfntab;
  218. extern struct ck_p ptab[NPROTOS];
  219.  
  220. int sndcmd = 0;        /* Last command was a SEND-class command. */
  221.  
  222. int g_xfermode = -1;
  223. int g_proto  = -1;
  224. int g_urpsiz = -1;
  225. int g_spsizf = -1;
  226. int g_spsiz  = -1;
  227. int g_spsizr = -1;
  228. int g_spmax  = -1;
  229. int g_wslotr = -1;
  230. int g_prefixing = -1;
  231. int g_fncnv  = -1;
  232. int g_fnspath = -1;
  233. int g_fnrpath = -1;
  234. int g_fnact  = -1;
  235. int g_displa = -1;
  236. int g_spath  = -1;
  237. int g_rpath  = -1;
  238. char * g_sfilter = NULL;
  239. char * g_rfilter = NULL;
  240.  
  241. extern int patterns;
  242. #ifdef PATTERNS
  243. extern char *txtpatterns[], *binpatterns[];
  244. int g_patterns = -1;
  245. #endif /* PATTERNS */
  246. int g_skipbup = -1;
  247.  
  248. #ifdef PIPESEND
  249. extern int usepipes, pipesend;
  250. extern char * sndfilter;
  251. #endif /* PIPESEND */
  252.  
  253. #ifndef NOSPL
  254. extern int sndxlo, sndxhi, sndxin;
  255. #endif /* NOSPL */
  256.  
  257. extern char fspec[];            /* Most recent filespec */
  258. extern int fspeclen;            /* Length of fspec[] buffer */
  259.  
  260. #ifndef NOFRILLS
  261. extern int rmailf;            /* MAIL command items */
  262. extern char optbuf[];
  263. #endif /* NOFRILLS */
  264.  
  265. extern int
  266.   en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri,
  267.   en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit,
  268.   en_mkd, en_rmd, en_asg;
  269.  
  270. #ifndef NOMSEND                /* Multiple SEND */
  271. extern char *msfiles[];
  272. int filesinlist = 0;            /* And ADD ... */
  273. extern struct filelist * filehead;
  274. extern struct filelist * filetail;
  275. extern struct filelist * filenext;
  276. extern int addlist;
  277. #endif /* NOMSEND */
  278.  
  279. static struct keytab addtab[] = {
  280. #ifdef PATTERNS
  281.     { "binary-patterns", ADD_BIN, 0 },
  282. #endif /* PATTERNS */
  283. #ifndef NOMSEND
  284.     { "send-list", ADD_SND, 0 },
  285. #endif /* NOMSEND */
  286. #ifdef PATTERNS
  287.     { "text-patterns", ADD_TXT, 0 },
  288. #endif /* PATTERNS */
  289.     { "", 0, 0 }
  290. };
  291. static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;
  292.  
  293. #ifndef NOCSETS
  294. struct keytab assoctab[] = {
  295.     { "file-character-set",     ASSOC_FC, 0 },
  296.     { "transfer-character-set", ASSOC_TC, 0 },
  297.     { "xfer-character-set",     ASSOC_TC, CM_INV }
  298. };
  299. static int nassoc = sizeof(assoctab)/sizeof(struct keytab);
  300. extern int afcset[MAXFCSETS+1];        /* Character-set associations */
  301. extern int axcset[MAXTCSETS+1];
  302. #endif /* NOCSETS */
  303.  
  304. #ifndef ADDCMD
  305. #ifndef NOMSEND
  306. #define ADDCMD
  307. #endif /* NOMSEND */
  308. #ifndef ADDCMD
  309. #ifdef PATTERNS
  310. #define ADDCMD
  311. #endif /* PATTERNS */
  312. #endif /* ADDCMD */
  313. #endif /* ADDCMD */
  314. #endif /* NOXFER */
  315.  
  316. /* External Kermit Variables, see ckmain.c for description. */
  317.  
  318. extern xx_strp xxstring;
  319. extern long xvernum;
  320.  
  321. extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel,
  322.   pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;
  323. #ifdef TNCODE
  324. extern int debses;
  325. extern char tn_msg[];
  326. #endif /* TNCODE */
  327.  
  328. int sleepcan = 1;
  329. int g_binary = -1;
  330. int g_recursive = -1;
  331. int g_matchdot = -1;
  332. extern int nolinks;
  333.  
  334. extern long vernum;
  335. extern char *versio, *copyright[];
  336. extern char *ckxsys;
  337. #ifndef NOHELP
  338. extern char *introtxt[];
  339. extern char *newstxt[];
  340. #endif /* NOHELP */
  341.  
  342. #ifndef OS2
  343. #ifndef UNIX
  344. extern char *PWDCMD;
  345. #endif /* UNIX */
  346. extern char *WHOCMD;
  347. #endif /* OS2 */
  348.  
  349. extern char ttname[];
  350.  
  351. extern CHAR sstate;
  352.  
  353. extern int network;            /* Have active network connection */
  354. extern int nettype;            /* Type of network */
  355. extern int ttnproto;                    /* NET_TCPB protocol */
  356.  
  357. #ifndef NODIAL
  358. extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */
  359. #endif /* NODIAL */
  360.  
  361. #ifdef CK_APC
  362. extern int apcactive, apcstatus;
  363. #endif /* CK_APC */
  364.  
  365. #ifndef NOPUSH
  366. #ifndef NOFRILLS
  367. extern char editor[];
  368. extern char editopts[];
  369. extern char editfile[];
  370. #endif /* NOFRILLS */
  371. #endif /* NOPUSH */
  372.  
  373. #ifdef BROWSER
  374. extern char browser[];            /* Web browser application */
  375. extern char browsopts[];        /* Web browser options */
  376. extern char browsurl[];            /* Most recent URL */
  377. #endif /* BROWSER */
  378. #ifndef NOFTP
  379. char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */
  380. char ftpopts[128] = { NUL, NUL };    /* ftp command-line options */
  381. #endif /* NOFTP */
  382. extern struct keytab onoff[];        /* On/Off keyword table */
  383.  
  384. #ifdef CK_TMPDIR
  385. int f_tmpdir = 0;            /* Directory changed temporarily */
  386. char savdir[TMPDIRLEN];            /* For saving current directory */
  387. #endif /* CK_TMPDIR */
  388.  
  389. int activecmd = -1;            /* Keyword index of active command */
  390. int doconx = -1;            /* CONNECT-class command active */
  391. int ooflag = 0;                /* User-settable on/off flag */
  392.  
  393. int rcflag = 0;                /* Pointer to home directory string */
  394. int repars,                /* Reparse needed */
  395.     techo = 0;                /* Take echo */
  396. int secho = 1;                /* SCRIPT echo */
  397.  
  398. int xitwarn =            /* Warn about open connection on exit */
  399. #ifdef NOWARN
  400. 0
  401. #else
  402. 1
  403. #endif /* NOWARN */
  404. ;
  405.  
  406. struct keytab onoffsw[] = {
  407.     { "/off", 0, 0 },
  408.     { "/on",  1, 0 }
  409. };
  410.  
  411. #ifdef CKEXEC
  412. struct keytab redirsw[] = {
  413.     { "/redirect", 1, 0 }
  414. };
  415. #endif /* CKEXEC */
  416.  
  417. #ifndef NOXMIT
  418. /* Variables for TRANSMIT command */
  419.  
  420. int xmitx = 1;            /* Whether to echo during TRANSMIT */
  421. int xmitf = 0;            /* Character to fill empty lines */
  422. int xmitl = 0;            /* 0 = Don't send linefeed too */
  423. int xmitp = LF;            /* Host line prompt */
  424. int xmits = 0;            /* Use shift-in/shift-out, 0 = no */
  425. int xmitw = 0;            /* Milliseconds to pause during TRANSMIT */
  426. int xmitt = 1;            /* Seconds to wait for each char to echo */
  427. int xmita = 1;            /* Action upon timeout */
  428.  
  429. #define XMI_BIN 1
  430. #define XMI_TXT 2
  431. #define XMI_CMD 3
  432. #define XMI_TRA 4
  433. #define XMI_VRB 5
  434. #define XMI_QUI 6
  435. #define XMI_NOW 7
  436. #define XMI_NOE 8
  437.  
  438. static struct keytab xmitsw[] = {    /* TRANSMIT command options */
  439.     { "/binary",          XMI_BIN, 0 },
  440. #ifdef PIPESEND
  441.     { "/command",         XMI_CMD, CM_INV|CM_PSH },
  442. #endif /* PIPESEND */
  443.     { "/noecho",          XMI_NOE, 0 },
  444.     { "/nowait",          XMI_NOW, 0 },
  445. #ifdef PIPESEND
  446.     { "/pipe",            XMI_CMD, 0 },
  447. #endif /* PIPESEND */
  448. #ifdef COMMENT
  449.     { "/quiet",           XMI_QUI, 0 },
  450. #endif /* COMMENT */
  451.     { "/text",            XMI_TXT, 0 },
  452.     { "/transparent",     XMI_TRA, 0 },
  453. #ifdef COMMENT
  454.     { "/verbose",         XMI_VRB, 0 },
  455. #endif /* COMMENT */
  456.     { "", 0, 0 }
  457. };
  458. #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1
  459. static int nxmitsw = NXMITSW;
  460.  
  461. #endif /* NOXMIT */
  462.  
  463. /* Declarations from ck?fio.c module */
  464.  
  465. extern char *SPACMD, *SPACM2;        /* SPACE commands */
  466.  
  467. /* Command-oriented items */
  468.  
  469. #ifdef DCMDBUF
  470. extern char *cmdbuf;            /* Command buffers */
  471. extern char *atmbuf;
  472. extern char *line;            /* Character buffer for anything */
  473. extern char *tmpbuf;            /* Short temporary string buffer */
  474. extern int *ifcmd;
  475. extern int *intime;
  476. extern int *inpcas;
  477. #else
  478. extern char cmdbuf[];            /* Command buffers */
  479. extern char atmbuf[];
  480. extern char line[];            /* Character buffer for anything */
  481. extern char tmpbuf[];            /* Temporary buffer */
  482. extern int ifcmd[];
  483. extern int intime[];
  484. extern int inpcas[];
  485. #endif /* DCMDBUF */
  486.  
  487. #ifndef NOSPL
  488. extern char * prstring[];
  489. #endif /* NOSPL */
  490.  
  491. char *lp;                /* Pointer to line buffer */
  492.  
  493. #ifndef NOSPL
  494. int unkmacro = 0;            /* Flag for in ON_UNKNOWN_COMMAND */
  495. int oldeval = 0;
  496. char evalbuf[33];            /* EVALUATE result */
  497. extern char * inpbuf;            /* Buffer for INPUT and REINPUT */
  498. char *inpbp;                /* And pointer to same */
  499. int m_found;                /* MINPUT result */
  500. int i_active = 0;            /* INPUT command is active */
  501. char *ms[MINPMAX];            /* Pointers to MINPUT strings */
  502. static int mp[MINPMAX];            /* and flags */
  503. extern int fndiags, fnerror, fnsuccess;    /* Function diagnostics */
  504. #ifndef NOSEXP
  505. char * lastsexp = NULL;            /* S-Expressions */
  506. char * sexpval = NULL;
  507. int sexpecho = SET_AUTO;
  508. #endif /* NOSEXP */
  509. #endif /* NOSPL */
  510.  
  511. char psave[PROMPTL] = { NUL };        /* For saving & restoring prompt */
  512.  
  513. extern int success;            /* Command success/failure flag */
  514. extern int cmdlvl;            /* Current position in command stack */
  515.  
  516. #ifndef NOSPL
  517. int                    /* SET INPUT parameters. */
  518. /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */
  519.   inbufsize = 0,            /* INPUT buffer size */
  520.   indef = 1,                /* default timeout, seconds */
  521.   inecho = 1,                /* 1 = echo on */
  522.   inautodl = 0,                /* INPUT autodownload */
  523.   inintr = 1,                /* INPUT interrupion allowed */
  524.   insilence = 0;            /* 0 = no silence constraint */
  525.  
  526. #ifdef CKFLOAT
  527. CKFLOAT inscale = 1.0;            /* Timeout scale factor */
  528. #endif    /* CKFLOAT */
  529.  
  530. #ifdef OS2
  531. int interm = 1;                /* Terminal emulator displays input */
  532. #endif /* OS2 */
  533. int maclvl = -1;            /* Macro nesting level */
  534. int mecho = 0;                /* Macro echo, 0 = don't */
  535. char varnam[6];                /* For variable names */
  536. extern int macargc[];            /* ARGC from macro invocation */
  537.  
  538. extern char *m_arg[MACLEVEL][NARGS];    /* Stack of macro arguments */
  539. extern char *mrval[];
  540.  
  541. extern char **a_ptr[];            /* Array pointers */
  542. extern int a_dim[];            /* Array dimensions */
  543. extern int a_link[];
  544.  
  545. #ifdef DCMDBUF
  546. extern struct cmdptr *cmdstk;        /* The command stack itself */
  547. #else
  548. extern struct cmdptr cmdstk[];        /* The command stack itself */
  549. #endif /* DCMDBUF */
  550.  
  551. long ck_alarm = 0;            /* SET ALARM value */
  552. char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  553. char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' };
  554.  
  555. struct keytab inputsw[] = {
  556.     { "/clear",   INPSW_CLR, 0 },
  557.     { "/nomatch", INPSW_NOM, 0 },
  558.     { "/nowrap",  INPSW_NOW, 0 }
  559. };
  560. static int ninputsw = sizeof(inputsw)/sizeof(struct keytab);
  561.  
  562. #endif /* NOSPL */
  563.  
  564. static int x, y, z = 0;            /* Local workers */
  565. static char *s;
  566.  
  567. #ifdef CK_MINPUT
  568. static char c1chars[] = {        /* C1 control chars escept NUL */
  569.     001,002,003,004,005,006,007,010,011,012,013,014,015,016,017,020,
  570.     021,022,023,024,025,026,027,030,031,032,033,034,035,036,037
  571. };
  572. #endif /* CK_MINPUT */
  573.  
  574. #define xsystem(s) zsyscmd(s)
  575.  
  576. /* Top-Level Interactive Command Keyword Table */
  577. /* Keywords must be in lowercase and in alphabetical order. */
  578.  
  579. struct keytab cmdtab[] = {
  580. #ifndef NOPUSH
  581.     { "!",       XXSHE, CM_INV|CM_PSH }, /* Shell escape */
  582. #else
  583.     { "!",       XXNOTAV, CM_INV|CM_PSH },
  584. #endif /* NOPUSH */
  585.     { "#",           XXCOM, CM_INV },    /* Comment */
  586. #ifndef NOSPL
  587.     { "(",           XXSEXP,CM_INV },    /* S-Expression */
  588.     { ".",           XXDEF, CM_INV },    /* Assignment */
  589.     { ":",           XXLBL, CM_INV },    /* Label */
  590. #endif /* NOSPL */
  591. #ifdef CK_REDIR
  592. #ifndef NOPUSH
  593.     { "<",           XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  594. #else
  595.     { "<",           XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */
  596. #endif /* NOPUSH */
  597. #endif /* CK_REDIR */
  598. #ifndef NOPUSH
  599.     { "@",           XXSHE, CM_INV|CM_PSH }, /* DCL escape */
  600. #else
  601.     { "@",           XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */
  602. #endif /* NOPUSH */
  603.  
  604. #ifdef CK_RECALL
  605.     { "^",           XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */
  606. #endif /* CK_RECALL */
  607. #ifndef NOSPL
  608.     { "_asg",        XXASX,   CM_INV },    /* Used internally by FOR, etc */
  609.     { "_assign",     XXASX,   CM_INV },    /* Used internally by FOR, etc */
  610.     { "_decrement",  XX_DECR, CM_INV },
  611.     { "_define",     XXDFX,   CM_INV },    /* Used internally by FOR, etc */
  612.     { "_evaluate",   XX_EVAL, CM_INV },
  613.     { "_forward",    XXXFWD,  CM_INV },    /* Used internally by SWITCH   */
  614.     { "_getargs",    XXGTA,   CM_INV },    /* Used internally by FOR, etc */
  615.     { "_increment",  XX_INCR, CM_INV },
  616.     { "_putargs",    XXPTA,   CM_INV },    /* Used internally by FOR, etc */
  617.     { "_undefine",   XXUNDFX, CM_INV },
  618. #endif /* NOSPL */
  619.  
  620.     { "about",       XXVER,   CM_INV },    /* Synonym for VERSION */
  621. #ifndef NOSPL
  622. #ifdef NEWFTP
  623.     { "account",     XXACCT,  CM_INV }, /* (FTP) Account */
  624. #endif /* NEWFTP */
  625. #ifdef ADDCMD
  626.     { "add",         XXADD, 0 },    /* ADD */
  627. #endif /* ADDCMD */
  628. #ifndef NODIAL
  629.     { "answer",      XXANSW, CM_LOC },    /* ANSWER the phone */
  630. #else
  631.     { "answer",      XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */
  632. #endif /* NODIAL */
  633.     { "apc",         XXAPC, 0 },    /* Application Program Command */
  634. #ifndef NOSPL
  635.     { "array",       XXARRAY, 0 },    /* Array operations */
  636. #endif /* NOSPL */
  637.     { "ascii",       XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  638.     { "asg",         XXASS, CM_INV },    /* Invisible synonym for ASSIGN */
  639.     { "ask",         XXASK, 0 },    /* ASK for text, assign to variable */
  640.     { "askq",        XXASKQ,0 },    /* ASK quietly (no echo) */
  641. #ifndef NOSPL
  642.     { "ass",         XXASS, CM_INV|CM_ABR }, /* ASSIGN */
  643.     { "assert",      XXASSER, CM_INV },    /* ASSERT */
  644.     { "assign",      XXASS, 0 },    /* ASSIGN */
  645. #endif /* NOSPL */
  646. #ifndef NOXFER
  647. #ifndef NOCSETS
  648.     { "associate",   XXASSOC, 0 },    /* ASSOCIATE */
  649. #else
  650.     { "associate",   XXNOTAV, CM_INV },    /* ASSOCIATE */
  651. #endif /* NOCSETS */
  652. #endif /* NOXFER */
  653. #ifdef CK_KERBEROS
  654. #ifdef CK_AUTHENTICATION
  655.     { "authenticate",XXAUTH, 0 },    /* Authentication */
  656. #else
  657.     { "authenticate",XXAUTH, CM_INV },
  658. #endif /* CK_AUTHENTICATION */
  659. #endif /* CK_KERBEROS */
  660. #endif /* NOSPL */
  661. #ifndef NOFRILLS
  662.     { "back",        XXBACK, 0 },    /* BACK to previous directory */
  663. #else
  664.     { "back",        XXNOTAV,CM_INV },
  665. #endif /* NOFRILLS */
  666.     { "beep",        XXBEEP,CM_INV },    /* BEEP */
  667. #ifndef NOXFER
  668.     { "binary",      XXBIN, CM_INV },    /* == SET FILE TYPE BINARY */
  669. #endif /* NOXFER */
  670. #ifndef NOFRILLS
  671.     { "bug",         XXBUG, CM_INV },    /* BUG report instructions */
  672. #else
  673.     { "bug",         XXNOTAV, CM_INV },
  674. #endif /* NOFRILLS */
  675. #ifdef BROWSER
  676.     { "browse",      XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */
  677. #else
  678.     { "browse",      XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  679. #endif /* BROWSER */
  680. #ifndef NOXFER
  681.     { "bye",         XXBYE, 0 },    /* BYE to remote server */
  682. #endif /* NOXFER */
  683. #ifndef NOLOCAL
  684.     { "c",           XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */
  685. #endif /* NOLOCAL */
  686. #ifndef NOFRILLS
  687.     { "cat",         XXCAT, CM_INV },    /* Invisible synonym for TYPE */
  688. #endif /* NOFRILLS */
  689. #ifndef NOSPL
  690.  
  691. #ifndef NOXFER
  692.     { "cautious",    XXCAU, CM_INV },
  693. #endif /* NOXFER */
  694.  
  695. #endif /* NOSPL */
  696.  
  697.     { "cd",          XXCWD, 0 },    /* Change Directory */
  698.     { "cdup",        XXCDUP, CM_INV },    /* Change Directory Up */
  699.  
  700. #ifndef NOXFER
  701. #ifdef PIPESEND
  702.     { "cget",        XXCGET, CM_INV|CM_PSH }, /* CGET */
  703. #else
  704.     { "cget",        XXNOTAV, CM_INV|CM_PSH }, /* CGET */
  705. #endif /* PIPESEND */
  706. #endif /* NOXFER */
  707.     { "ch",          XXCHK,   CM_INV|CM_ABR },
  708.     { "check",       XXCHK,   0 },    /* CHECK for a feature */
  709. #ifdef CK_PERMS
  710. #ifdef UNIX
  711.     { "chmod",       XXCHMOD, 0 },    /* CHMOD */
  712. #else
  713.     { "chmod",       XXNOTAV, CM_INV },
  714. #endif /* UNIX */
  715. #else
  716.     { "chmod",       XXNOTAV, CM_INV },
  717. #endif /* CK_PERMS */
  718. #ifdef CKROOT
  719.     { "chroot",      XXCHRT,  CM_INV },    /* CHROOT */
  720. #endif /* CKROOT */
  721.     { "ckermit",     XXKERMI, CM_INV },    /* CKERMIT (like KERMIT) */
  722.     { "cl",          XXCLO,   CM_ABR|CM_INV },
  723. #ifndef NOFRILLS
  724.     { "clear",       XXCLE, 0 },    /* CLEAR input and/or device buffer */
  725. #else
  726.     { "clear",       XXNOTAV, CM_INV },
  727. #endif /* NOFRILLS */
  728.     { "close",         XXCLO, 0 },    /* CLOSE a log or other file */
  729.     { "cls",         XXCLS, CM_INV },    /* Clear Screen (CLS) */
  730.     { "comment",     XXCOM, CM_INV },    /* Introduce a comment */
  731. #ifndef NOLOCAL
  732.     { "connect",     XXCON, CM_LOC },    /* Begin terminal connection */
  733. #else
  734.     { "connect",     XXNOTAV, CM_LOC },
  735. #endif /* NOLOCAL */
  736.     { "continue",    XXCONT,  CM_INV },    /* CONTINUE */
  737. #ifndef NOFRILLS
  738. #ifdef ZCOPY
  739.     { "co",          XXCPY, CM_INV|CM_ABR },
  740.     { "cop",         XXCPY, CM_INV|CM_ABR },
  741.     { "copy",        XXCPY, 0 },    /* COPY a file */
  742. #else
  743.     { "copy",        XXNOTAV, CM_INV },
  744. #endif /* ZCOPY */
  745.     { "copyright",   XXCPR, CM_INV },    /* COPYRIGHT */
  746. #ifdef ZCOPY
  747.     { "cp",          XXCPY, CM_INV },    /* COPY a file */
  748. #endif /* ZCOPY */
  749. #ifndef NOLOCAL
  750. #ifndef OS2
  751.     { "cq",          XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */
  752. #endif /* OS2 */
  753. #endif /* NOLOCAL */
  754. #ifndef NOXFER
  755. #ifdef PIPESEND
  756.     { "creceive",    XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */
  757.     { "csend",       XXCSEN,CM_INV|CM_PSH }, /* SEND from command */
  758. #else
  759.     { "creceive",    XXNOTAV,CM_INV|CM_PSH },
  760.     { "csend",       XXNOTAV,CM_INV|CM_PSH },
  761. #endif /* PIPESEND */
  762. #endif /* NOXFER */
  763. #endif /* NOFRILLS */
  764.  
  765.     { "cwd",         XXCWD,   CM_INV },    /* Traditional synonym for cd */
  766.  
  767. #ifndef NOSPL
  768.     { "date",        XXDATE,  0 },    /* DATE */
  769.     { "dcl",         XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  770.     { "debug",       XXDEBUG, CM_INV },
  771.     { "declare",     XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  772.     { "decrement",   XXDEC,   0 },    /* DECREMENT a numeric variable */
  773.     { "define",      XXDEF,   0 },    /* DEFINE a macro or variable */
  774. #else
  775.     { "date",        XXNOTAV, CM_INV },
  776.     { "dcl",         XXNOTAV, CM_INV },
  777.     { "declare",     XXNOTAV, CM_INV },
  778.     { "decrement",   XXNOTAV, CM_INV },
  779.     { "define",      XXNOTAV, CM_INV },
  780. #endif /* NOSPL */
  781.  
  782. #ifndef NOFRILLS
  783.     { "delete",      XXDEL, 0 },    /* DELETE a file */
  784. #else
  785.     { "delete",      XXNOTAV, CM_INV },
  786. #endif /* NOFRILLS */
  787.  
  788. #ifndef NODIAL
  789.     { "dial",        XXDIAL,  CM_LOC },    /* DIAL a phone number */
  790. #else
  791.     { "dial",        XXNOTAV, CM_INV|CM_LOC },
  792. #endif /* NODIAL */
  793.  
  794. #ifdef NT
  795.     { "dialer",      XXDIALER, CM_INV }, /* K95 Dialer */
  796. #endif /* NT */
  797.  
  798.     { "directory",   XXDIR, 0 },    /* DIRECTORY of files */
  799.  
  800. #ifndef NOFRILLS
  801. #ifndef NOSERVER
  802.     { "disable",     XXDIS, 0 },    /* DISABLE a server function */
  803. #else
  804.     { "disable",     XXNOTAV, CM_INV },
  805. #endif /* NOSERVER */
  806. #endif /* NOFRILLS */
  807.  
  808. #ifndef NOSPL
  809.     { "do",          XXDO,  0 },    /* DO (execute) a macro */
  810. #else
  811.     { "do",          XXNOTAV, CM_INV },
  812. #endif /* NOSPL */
  813.  
  814.     { "e",           XXEXI, CM_INV|CM_ABR },
  815.  
  816. #ifndef NOFRILLS
  817. #ifndef NOXFER
  818.     { "e-packet",    XXERR, CM_INV },    /* Send an Error-Packet */
  819. #endif /* NOXFER */
  820. #endif /* NOFRILLS */
  821.  
  822.     { "echo",        XXECH, 0 },    /* ECHO text */
  823.  
  824. #ifndef NOFRILLS
  825. #ifndef NOPUSH
  826.     { "edit",        XXEDIT, CM_PSH },    /* EDIT */
  827. #else
  828.     { "edit",        XXNOTAV, CM_INV|CM_PSH }, /* EDIT */
  829. #endif /* NOPUSH */
  830. #endif /* NOFRILLS */
  831.  
  832.     { "eightbit",    XXEIGHT, CM_INV },    /* EIGHTBIT */
  833.  
  834. #ifndef NOSPL
  835.     { "else",        XXELS, CM_INV },    /* ELSE part of IF statement */
  836. #else
  837.     { "else",        XXNOTAV, CM_INV },    /* ELSE part of IF statement */
  838. #endif /* NOSPL */
  839.  
  840. #ifndef NOSERVER
  841. #ifndef NOFRILLS
  842.     { "enable",      XXENA,  0 },    /* ENABLE a server function */
  843. #else
  844.     { "enable",      XXNOTAV, CM_INV },
  845. #endif /* NOFRILLS */
  846. #endif /* NOSERVER */
  847.  
  848. #ifndef NOSPL
  849.     { "end",         XXEND,  0 },    /* END command file or macro */
  850. #else
  851.     { "end",         XXNOTAV, CM_INV },
  852. #endif /* NOSPL */
  853.  
  854.     { "erase",       XXDEL, CM_INV },    /* Synonym for DELETE */
  855.  
  856. #ifndef NOSPL
  857.     { "evaluate",    XXEVAL, 0 },    /* EVALUATE */
  858. #else
  859.     { "evaluate",    XXNOTAV, CM_INV },
  860. #endif /* NOSPL */
  861.  
  862.     { "ex",          XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */
  863.  
  864. #ifdef CKEXEC
  865.     { "exec",        XXEXEC, CM_INV|CM_LOC }, /* exec() */
  866. #else
  867.     { "exec",        XXNOTAV, CM_INV|CM_LOC },
  868. #endif /* CKEXEC */
  869.  
  870.     { "exit",       XXEXI, 0 },        /* EXIT from C-Kermit */
  871.     { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */
  872.  
  873. #ifdef OS2
  874.     { "extproc",     XXCOM, CM_INV },    /* Dummy command for OS/2 */
  875. #endif /* OS2 */
  876.  
  877. #ifndef NOXFER
  878.     { "f",           XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */
  879. #endif /* NOXFER */
  880.  
  881. #ifndef NOSPL
  882.     { "fail",        XXFAIL, CM_INV },    /* FAIL */
  883.  
  884. #ifndef NOXFER
  885.     { "fast",        XXFAST, CM_INV },
  886. #endif /* NOXFER */
  887.  
  888. #ifdef CKCHANNELIO
  889.     { "fclose",      XXF_CL, CM_INV },    /* FCLOSE */
  890.     { "fcount",      XXF_CO, CM_INV },    /* FCOUNT */
  891.     { "fflush",      XXF_FL, CM_INV },    /* FFLUSH */
  892. #endif /* CKCHANNELIO */
  893.  
  894. #ifndef NOXFER
  895.     { "fi",          XXFIN, CM_INV|CM_ABR }, /* FINISH */
  896. #endif /* NOXFER */
  897.  
  898. #ifdef CKCHANNELIO
  899.     { "file",        XXFILE, 0 },    /* FILE */
  900. #endif /* CKCHANNELIO */
  901. #endif /* NOSPL */
  902.  
  903. #ifndef NOXFER
  904.     { "fin",         XXFIN, CM_INV|CM_ABR }, /* FINISH */
  905. #endif /* NOXFER */
  906.  
  907. #ifndef UNIXOROSK
  908.     { "find",        XXGREP, 0 },    /* FIND (grep) */
  909. #else
  910.     { "find",        XXGREP,CM_INV },
  911. #endif /* UNIXOROSK */
  912.  
  913. #ifndef NOXFER
  914.     { "finish",      XXFIN, 0 },    /* FINISH */
  915. #endif /* NOXFER */
  916.  
  917. #ifdef TCPSOCKET
  918.     { "firewall",    XXFIREW, CM_INV|CM_HLP },
  919. #endif /* TCPSOCKET */
  920.  
  921. #ifdef CKCHANNELIO
  922.     { "flist",       XXF_LI, CM_INV },    /* FLIST */
  923.     { "fopen",       XXF_OP, CM_INV },    /* FOPEN */
  924. #endif /* CKCHANNELIO */
  925.  
  926. #ifndef NOSPL
  927.     { "fo",          XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */
  928.     { "for",         XXFOR, 0 },    /* FOR loop */
  929.     { "forward",     XXFWD, CM_INV },    /* FORWARD */
  930. #endif /* NOSPL */
  931. #ifndef NOFRILLS
  932.     { "fot",       XXDIR, CM_INV },    /* "fot" = "dir" (for Chris) */
  933. #endif /* NOFRILLS */
  934.  
  935. #ifdef CKCHANNELIO
  936.     { "fread",      XXF_RE, CM_INV },    /* FREAD */
  937.     { "frewind",    XXF_RW, CM_INV },    /* FREWIND */
  938.     { "fseek",      XXF_SE, CM_INV },    /* FSEEK */
  939.     { "fstatus",    XXF_ST, CM_INV },    /* FSTATUS */
  940. #endif /* CKCHANNELIO */
  941.  
  942. #ifdef TCPSOCKET
  943. #ifndef NOFTP
  944. #ifdef SYSFTP
  945. #ifndef NOPUSH
  946.     { "ftp",       XXFTP,   CM_INV|CM_PSH|CM_LOC }, /* System FTP */
  947. #else
  948.     { "ftp",       XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  949. #endif /* NOPUSH */
  950. #else  /* SYSFTP */
  951.     { "ftp",       XXFTP,   0 },    /* Built-in FTP */
  952. #endif /* SYSFTP */
  953. #else  /* NOFTP */
  954.     { "ftp",       XXNOTAV, CM_INV },    /* No FTP */
  955. #endif /* NOFTP */
  956. #endif /* TCPSOCKET */
  957.  
  958. #ifndef NOSPL
  959.     { "function",    XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */
  960. #endif /* NOSPL */
  961.  
  962. #ifdef CKCHANNELIO
  963.     { "fwrite",      XXF_WR, CM_INV },    /* FWRITE */
  964. #endif /* CKCHANNELIO */
  965.  
  966. #ifndef NOXFER
  967.     { "g",           XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */
  968. #ifndef NOSPL
  969.     { "ge",          XXGET, CM_INV|CM_ABR }, /* Ditto */
  970. #endif /* NOSPL */
  971.     { "get",         XXGET, 0 },    /* GET */
  972. #endif /* NOXFER */
  973. #ifndef NOSPL
  974.     { "getc",        XXGETC, 0 },    /* GETC */
  975. #ifdef OS2
  976.     { "getkeycode",  XXGETK, 0 },    /* GETKEYCODE */
  977. #endif /* OS2 */
  978. #ifndef NOFRILLS
  979.     { "getok",       XXGOK, 0 },    /* GETOK (ask for Yes/No/OK) */
  980. #endif /* NOFRILLS */
  981. #endif /* NOSPL */
  982. #ifndef NOSPL
  983.     { "goto",        XXGOTO,0 },    /* GOTO label in take file or macro */
  984. #endif /* NOSPL */
  985. #ifdef UNIXOROSK
  986.     { "grep",        XXGREP,0 },    /* GREP (find) */
  987. #else
  988.     { "grep",        XXGREP,CM_INV },    /* GREP (find) */
  989. #endif /* UNIXOROSK */
  990.     { "h",           XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  991.     { "he",          XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  992. #ifndef NOFRILLS
  993.     { "head",        XXHEAD, 0 },
  994. #endif /* NOFRILLS */
  995. #ifndef NOLOCAL
  996.     { "hangup",      XXHAN, CM_LOC },    /* HANGUP the connection */
  997. #endif /* NOLOCAL */
  998.     { "HELP",        XXHLP, 0 },    /* Display HELP text */
  999. #ifndef NOHTTP
  1000. #ifdef TCPSOCKET
  1001.     { "http",        XXHTTP, 0 },    /* HTTP operations */
  1002. #endif /* TCPSOCKET */
  1003. #endif /* NOHTTP */
  1004. #ifndef NOSPL
  1005.     { "i",           XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  1006.     { "if",          XXIF,  0 },         /* IF ( condition ) command */
  1007. #ifdef TCPSOCKET
  1008.     { "iksd",        XXIKSD, CM_INV },         /* Make connection to IKSD */
  1009. #else
  1010.     { "iksd",        XXNOTAV, CM_INV },
  1011. #endif /* TCPSOCKET */
  1012.     { "in",          XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  1013.     { "increment",   XXINC, 0 },    /* Increment a numeric variable */
  1014.     { "input",       XXINP, 0 },    /* INPUT text from comm device */
  1015. #endif /* NOSPL */
  1016.  
  1017. #ifndef NOHELP
  1018.     { "int",         XXINT, CM_INV|CM_ABR },
  1019.     { "intr",        XXINT, CM_INV|CM_ABR },
  1020.     { "INTRO",       XXINT, 0 },
  1021.     { "introduction",XXINT, CM_INV },    /* Print introductory text */
  1022. #else
  1023.     { "intro",       XXNOTAV, CM_INV },
  1024.     { "introduction",XXNOTAV, CM_INV },
  1025. #endif /* NOHELP */
  1026.  
  1027. #ifdef OS2
  1028.     { "k95",         XXKERMI, CM_INV },    /* Hmmm what's this... */
  1029. #endif /* OS2 */
  1030.  
  1031. #ifndef NOSPL
  1032.     { "kcd",         XXKCD,   0      },
  1033. #endif /* NOSPL */
  1034.  
  1035.     { "kermit",      XXKERMI, CM_INV },
  1036.  
  1037. #ifdef OS2
  1038. #ifndef NOKVERBS
  1039.     { "kverb",       XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */
  1040. #endif /* NOKVERBS */
  1041. #endif /* OS2 */
  1042.  
  1043. #ifndef NOFRILLS
  1044.     { "l",           XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
  1045. #endif /* NOFRILLS */
  1046.  
  1047.     { "lcd",         XXLCWD, CM_INV },
  1048.     { "lcdup",       XXLCDU, CM_INV },
  1049.     { "lcwd",        XXLCWD, CM_INV },
  1050.     { "ldelete",     XXLDEL, CM_INV },
  1051.     { "ldirectory",  XXLDIR, CM_INV },
  1052.  
  1053. #ifdef CKLEARN
  1054.     { "learn",       XXLEARN, 0 },    /* LEARN - automatic script writing */
  1055. #else
  1056.     { "learn",       XXNOTAV, CM_INV },
  1057. #endif /* CKLEARN */
  1058.  
  1059.     { "li",          XXLNOUT, CM_INV|CM_ABR },
  1060.     { "LICENSE",     XXCPR, 0 },    /* LICENSE */
  1061.  
  1062. #ifndef NOSPL
  1063.     { "lineout",     XXLNOUT, 0 },    /* LINEOUT = OUTPUT + eol */
  1064. #endif /* NOSPL */
  1065.  
  1066. #ifdef NT
  1067.     { "link",        XXLINK, 0 },       /* LINK source destination */
  1068. #endif /* NT */
  1069.  
  1070.     { "lmkdir",      XXLMKD, CM_INV },
  1071.     { "lmv",         XXLREN, CM_INV },
  1072.  
  1073. #ifndef NOFRILLS
  1074.     { "lo",          XXLOG,  CM_INV|CM_ABR }, /* Invisible synonym for log */
  1075. #endif /* NOFRILLS */
  1076.  
  1077. #ifndef NOSPL
  1078.     { "local",       XXLOCAL, CM_INV },    /* LOCAL variable declaration */
  1079. #else
  1080.     { "local",       XXNOTAV, CM_INV },
  1081. #endif /* NOSPL */
  1082.  
  1083.     { "log",           XXLOG, 0 },    /* Open a log file */
  1084.  
  1085.     { "login",       XXLOGIN,  0 },    /* (REMOTE) LOGIN to server or IKSD */
  1086.     { "logout",      XXLOGOUT, 0 },    /* LOGOUT from server or IKSD */
  1087.  
  1088. #ifndef NOFRILLS
  1089. #ifndef NODIAL
  1090.     { "lookup",      XXLOOK,  0 },    /* LOOKUP */
  1091. #else
  1092.     { "lookup",      XXNOTAV, CM_INV },
  1093. #endif /* NODIAL */
  1094.  
  1095.     { "lpwd",        XXLPWD, CM_INV },
  1096.     { "lrename",     XXLREN, CM_INV },
  1097.     { "lrmdir",      XXLRMD, CM_INV },
  1098.  
  1099. #ifdef UNIXOROSK
  1100.     { "ls",          XXLS,  CM_INV|CM_PSH }, /* UNIX ls command */
  1101. #else
  1102.     { "ls",          XXDIR, CM_INV },    /* Invisible synonym for DIR */
  1103. #endif /* UNIXOROSK */
  1104. #ifndef NOXFER
  1105.     { "mail",        XXMAI, 0 },    /* Send a file as e-mail */
  1106. #endif /* NOXFER */
  1107. #ifndef NOHELP
  1108.     { "manual",      XXMAN, CM_PSH },    /* MAN(UAL) */
  1109. #else
  1110.     { "manual",      XXNOTAV, CM_INV|CM_PSH },
  1111. #endif /* NOHELP */
  1112. #endif /* NOFRILLS */
  1113. #ifdef CK_MKDIR
  1114.     { "md",          XXMKDIR, CM_INV },    /* Synonym for MKDIR */
  1115. #endif /* CK_MKDIR */
  1116. #ifdef CK_MINPUT
  1117.     { "minput",      XXMINP, 0 },    /* MINPUT */
  1118. #else
  1119.     { "minput",      XXNOTAV, CM_INV },
  1120. #endif /* CK_MINPUT */
  1121. #ifndef NOMSEND
  1122.     { "mget",        XXMGET, 0 },    /* MGET */
  1123. #else
  1124.     { "mget",        XXNOTAV, CM_INV },
  1125. #endif /* NOMSEND */
  1126. #ifdef CK_MKDIR
  1127.     { "mkdir",       XXMKDIR, 0 },    /* MKDIR */
  1128. #else
  1129.     { "mkdir",       XXNOTAV, CM_INV },
  1130. #endif /* CK_MKDIR */
  1131.  
  1132. #ifndef NOXFER
  1133. #ifndef NOMSEND
  1134.     { "mmove",       XXMMOVE, 0 },    /* MMOVE */
  1135. #else
  1136.     { "mmove",       XXNOTAV, CM_INV },
  1137. #endif /* NOMSEND */
  1138. #endif /* NOXFER */
  1139.  
  1140. #ifndef NOFRILLS
  1141.     { "more",        XXMORE, CM_INV },    /* MORE */
  1142. #endif /* NOFRILLS */
  1143.  
  1144. #ifndef NOXFER
  1145.     { "move",        XXMOVE, 0 },    /* MOVE  */
  1146. #endif /* NOXFER */
  1147.  
  1148. #ifndef NOSPL
  1149.     { "mpause",      XXMSL, CM_INV },    /* Millisecond sleep */
  1150. #else
  1151.     { "mpause",      XXNOTAV, CM_INV },
  1152. #endif /* NOSPL */
  1153.  
  1154. #ifndef NOXFER
  1155. #ifndef NOMSEND
  1156.     { "mput",        XXMSE, CM_INV },    /* MPUT = MSEND */
  1157.     { "ms",          XXMSE, CM_INV|CM_ABR },
  1158.     { "msend",       XXMSE, 0 },    /* Multiple SEND */
  1159. #else
  1160.     { "mput",        XXNOTAV, CM_INV },
  1161.     { "msend",       XXNOTAV, CM_INV },
  1162. #endif /* NOMSEND */
  1163. #endif /* NOXFER */
  1164. #ifndef NOSPL
  1165.     { "msleep",      XXMSL, 0 },    /* Millisecond sleep */
  1166. #else
  1167.     { "msleep",      XXNOTAV, CM_INV },
  1168. #endif /* NOSPL */
  1169. #ifndef NOFRILLS
  1170.     { "mv",          XXREN, CM_INV },    /* Synonym for rename */
  1171. #endif /* NOFRILLS */
  1172. #ifndef NOHELP
  1173.     { "news",        XXNEW, CM_INV },    /* Display NEWS of new features */
  1174. #else
  1175.     { "news",        XXNOTAV, CM_INV },
  1176. #endif /* NOHELP */
  1177.     { "nolocal",     XXNLCL, CM_INV },    /* Disable SET LINE / SET HOST */
  1178.     { "nopush",      XXNPSH, CM_INV },    /* Disable PUSH command/features */
  1179. #ifdef OS2
  1180.     { "noscroll",    XXNSCR, CM_INV },  /* Disable scroll operations */
  1181. #endif /* OS2 */
  1182. #ifndef NOSPL
  1183.     { "o",           XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */
  1184.     { "open",        XXOPE, 0 },    /* OPEN file for reading or writing */
  1185. #else
  1186.     { "open",        XXOPE, CM_INV },    /* OPEN */
  1187. #endif /* NOSPL */
  1188. #ifndef NOHELP
  1189.     { "options",     XXOPTS,CM_INV|CM_HLP }, /* Options */
  1190. #endif /* NOHELP */
  1191.     { "orientation", XXORIE, 0 },
  1192. #ifndef NOSPL
  1193.     { "output",      XXOUT, 0 },    /* OUTPUT text to comm device */
  1194. #else
  1195.     { "output",      XXNOTAV, CM_INV },
  1196. #endif /* NOSPL */
  1197. #ifdef ANYX25
  1198. #ifndef IBMX25
  1199.     { "pad",         XXPAD, CM_LOC },    /* X.3 PAD commands */
  1200. #endif /* IBMX25 */
  1201. #endif /* ANYX25 */
  1202.  
  1203. #ifdef NEWFTP
  1204.     { "passive",     XXPASV, CM_INV },    /* (FTP) PASSIVE */
  1205. #endif /* NEWFTP */
  1206.  
  1207. #ifndef NOHELP
  1208.     { "patterns",    XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */
  1209. #endif /* NOHELP */
  1210.  
  1211. #ifndef NOSPL
  1212.     { "pause",       XXPAU, 0 },    /* Sleep for specified interval */
  1213. #else
  1214.     { "pause",       XXNOTAV, CM_INV },
  1215. #endif /* NOSPL */
  1216. #ifndef NODIAL
  1217.     { "pdial",       XXPDIA,  CM_LOC },    /* PDIAL (partial dial) */
  1218. #else
  1219.     { "pdial",       XXNOTAV, CM_INV|CM_LOC },
  1220. #endif /* NODIAL */
  1221. #ifdef TCPSOCKET
  1222. #ifndef NOPUSH
  1223.     { "ping",        XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */
  1224. #else
  1225.     { "ping",        XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  1226. #endif /* NOPUSH */
  1227. #endif /* TCPSOCKET */
  1228. #ifdef NETCMD
  1229. #ifndef NOPUSH
  1230.     { "pipe",        XXPIPE, CM_PSH },    /* PIPE */
  1231. #else
  1232.     { "pipe",        XXNOTAV, CM_INV|CM_PSH }, /* PIPE */
  1233. #endif /* NOPUSH */
  1234. #endif /* NETCMD */
  1235.  
  1236. #ifndef NOSPL
  1237.     { "pop",         XXEND, CM_INV },    /* Invisible synonym for END */
  1238. #endif /* NOSPL */
  1239. #ifndef NOFRILLS
  1240.     { "print",       XXPRI, 0 },    /* PRINT a file locally */
  1241. #endif /* NOFRILLS */
  1242.  
  1243.     { "prompt",      XXPROMP, CM_INV },    /* Go interactive (from script) */
  1244.  
  1245. #ifndef NOXFER
  1246. #ifdef CK_RESEND
  1247.     { "psend",       XXPSEN, CM_INV },    /* PSEND */
  1248. #else
  1249.     { "psend",       XXNOTAV, CM_INV },
  1250. #endif /* CK_RESEND */
  1251. #endif /* NOXFER */
  1252.  
  1253. #ifdef NETPTY
  1254.     { "pty",         XXPTY, CM_PSH },    /* PTY */
  1255. #else
  1256.     { "pty",         XXNOTAV, CM_INV|CM_PSH },
  1257. #endif /* NETPTY */
  1258.  
  1259. #ifndef NOPUSH
  1260.     { "pu",          XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */
  1261. #endif /* NOPUSH */
  1262.  
  1263. #ifdef CKPURGE
  1264.     { "purge",       XXPURGE, 0 },    /* PURGE (real) */
  1265. #else
  1266. #ifdef VMS
  1267.     { "purge",       XXPURGE, 0 },    /* PURGE (fake) */
  1268. #else
  1269.     { "purge",       XXNOTAV, CM_INV },
  1270. #endif /* VMS */
  1271. #endif /* CKPURGE */
  1272.  
  1273. #ifndef NOPUSH
  1274.     { "push",        XXSHE, CM_PSH },    /* PUSH command (like RUN, !) */
  1275. #else
  1276.     { "push",        XXNOTAV, CM_INV|CM_PSH },
  1277. #endif /* NOPUSH */
  1278.  
  1279. #ifndef NOXFER
  1280.     { "put",         XXSEN, CM_INV },    /* PUT = SEND */
  1281. #endif /* NOXFER */
  1282.  
  1283.     { "pwd",         XXPWD, 0 },    /* Print Working Directory */
  1284.     { "q",           XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */
  1285.  
  1286. #ifndef NOXFER
  1287.     { "query",       XXRQUE,CM_INV },    /* (= REMOTE QUERY) */
  1288. #endif /* NOXFER */
  1289.  
  1290.     { "quit",        XXQUI, 0 },    /* QUIT from program = EXIT */
  1291.  
  1292. #ifndef NOXFER
  1293.     { "r",           XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */
  1294. #endif /* NOXFER */
  1295.  
  1296. #ifndef NOXFER
  1297.     { "rasg",        XXRASG, CM_INV },    /* REMOTE ASSIGN */
  1298.     { "rassign",     XXRASG, CM_INV },    /* ditto */
  1299.     { "rcd",         XXRCWD, CM_INV },    /* REMOTE CD */
  1300.     { "rcdup",       XXRCDUP,CM_INV },    /* REMOTE CD */
  1301.     { "rcopy",       XXRCPY, CM_INV },    /* REMOTE COPY */
  1302.     { "rcwd",        XXRCWD, CM_INV },    /* REMOTE CWD */
  1303.     { "rdelete",     XXRDEL, CM_INV },    /* REMOTE DELETE */
  1304.     { "rdirectory",  XXRDIR, CM_INV },    /* REMODE DIRECTORY */
  1305. #endif /* NOXFER */
  1306.  
  1307. #ifndef NOSPL
  1308.     { "read",        XXREA, 0 },    /* READ a line from a file */
  1309. #else
  1310.     { "read",        XXNOTAV, CM_INV },
  1311. #endif /* NOSPL */
  1312.  
  1313. #ifndef NOXFER
  1314.     { "receive",     XXREC, 0 },    /* RECEIVE files */
  1315. #endif /* NOXFER */
  1316.  
  1317. #ifndef NODIAL
  1318.     { "red",         XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */
  1319.     { "redi",        XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */
  1320.     { "redial",      XXRED, CM_LOC },    /* REDIAL last DIAL number */
  1321. #else
  1322.     { "red",         XXNOTAV, CM_INV|CM_LOC },
  1323.     { "redi",        XXNOTAV, CM_INV|CM_LOC },
  1324.     { "redial",      XXNOTAV, CM_INV|CM_LOC },
  1325. #endif /* NODIAL */
  1326.  
  1327. #ifdef CK_REDIR
  1328. #ifdef OS2
  1329. #ifndef NOPUSH
  1330.     { "redirect",    XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  1331. #else
  1332.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1333. #endif /* NOPUSH */
  1334. #else /* OS2 */
  1335. #ifndef NOPUSH
  1336.     { "redirect",    XXFUN, CM_PSH },    /* REDIRECT */
  1337. #else
  1338.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1339. #endif /* NOPUSH */
  1340. #endif /* OS2 */
  1341. #endif /* CK_REDIR */
  1342.  
  1343. #ifdef CK_RECALL
  1344.     { "redo",        XXREDO,  CM_NOR },    /* REDO */
  1345. #else
  1346.     { "redo",        XXNOTAV, CM_INV },
  1347. #endif /* CK_RECALL */
  1348.  
  1349. #ifndef NOXFER
  1350. #ifdef CK_RESEND
  1351.     { "reget",       XXREGET, 0 },    /* REGET */
  1352. #else
  1353.     { "reget",       XXNOTAV, CM_INV },
  1354. #endif /* CK_RESEND */
  1355. #endif /* NOXFER */
  1356.  
  1357. #ifndef NOSPL
  1358.     { "reinput",     XXREI, CM_INV },    /* REINPUT (from INPUT buffer) */
  1359. #else
  1360.     { "reinput",     XXNOTAV, CM_INV },
  1361. #endif /* NOSPL */
  1362.  
  1363. #ifndef NOXFER
  1364. #ifdef ADDCMD
  1365.     { "rem",         XXREM, CM_INV|CM_ABR },
  1366.     { "remo",        XXREM, CM_INV|CM_ABR },
  1367. #endif /* ADDCMD */
  1368.     { "remote",         XXREM, 0 },    /* Send REMOTE command to server */
  1369. #endif /* NOXFER */
  1370.  
  1371. #ifdef ADDCMD
  1372.     { "remove",      XXREMV,0 },    /* REMOVE (something from a list) */
  1373. #else
  1374.     { "remove",      XXNOTAV, CM_INV },
  1375. #endif /* ADDCMD */
  1376.  
  1377. #ifndef NOFRILLS
  1378. #ifndef NORENAME
  1379.     { "rename",      XXREN, 0 },    /* RENAME a local file */
  1380. #else
  1381.     { "rename",      XXNOTAV, CM_INV },
  1382. #endif /* NORENAME */
  1383.     { "replay",      XXTYP, CM_INV },    /* REPLAY (for now, just type) */
  1384. #endif /* NOFRILLS */
  1385.  
  1386. #ifndef NOXFER
  1387. #ifdef CK_RESEND
  1388.     { "res",         XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1389.     { "rese",        XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1390.     { "resend",      XXRSEN, 0 },    /* RESEND */
  1391. #else
  1392.     { "res",         XXNOTAV, CM_INV },
  1393.     { "rese",        XXNOTAV, CM_INV },
  1394.     { "resend",      XXNOTAV, CM_INV },
  1395. #endif /* CK_RESEND */
  1396. #endif /* NOXFER */
  1397.  
  1398.     { "reset",       XXRESET, CM_INV },    /* RESET */
  1399.  
  1400. #ifdef CK_RESEND
  1401. #ifndef NOSPL
  1402.     { "ret",         XXRET, CM_INV|CM_ABR },
  1403. #endif /* NOSPL */
  1404. #endif /* CK_RESEND */
  1405.  
  1406. #ifndef NOXFER
  1407.     { "retrieve",    XXRETR, CM_INV },    /* RETRIEVE */
  1408. #endif /* NOXFER */
  1409.  
  1410. #ifndef NOSPL
  1411.     { "return",      XXRET, 0 },    /* RETURN from a function */
  1412. #else
  1413.     { "return",      XXNOTAV, CM_INV },
  1414. #endif /* NOSPL */
  1415.  
  1416. #ifndef NOXFER
  1417.     { "rexit",       XXRXIT, CM_INV },    /* REMOTE EXIT */
  1418. #endif /* NOXFER */
  1419.  
  1420. #ifdef CK_REXX
  1421. #ifndef NOPUSH
  1422.     { "rexx",        XXREXX, CM_PSH },    /* Execute a Rexx command */
  1423. #else
  1424.     { "rexx",        XXNOTAV, CM_INV|CM_PSH },
  1425. #endif /* NOPUSH */
  1426. #endif /* CK_REXX */
  1427.  
  1428. #ifndef NOXFER
  1429.     { "rhelp",       XXRHLP, CM_INV },    /* REMOTE HELP */
  1430.     { "rhost",       XXRHOS, CM_INV },    /* REMOTE HOST */
  1431.     { "rkermit",     XXRKER, CM_INV },    /* REMOTE KERMIT */
  1432. #endif /* NOXFER */
  1433.  
  1434. #ifdef TCPSOCKET
  1435.     { "rlogin",      XXRLOG, CM_LOC },    /* Make an Rlogin connection */
  1436. #else
  1437.     { "rlogin",      XXNOTAV, CM_INV|CM_LOC },
  1438. #endif /* TCPSOCKET */
  1439.  
  1440. #ifndef NOFRILLS
  1441.     { "rm",          XXDEL, CM_INV },    /* Invisible synonym for delete */
  1442. #endif /* NOFRILLS */
  1443.  
  1444. #ifdef CK_MKDIR
  1445.     { "rmdir",       XXRMDIR, 0 },    /* RMDIR */
  1446. #else
  1447.     { "rmdir",       XXNOTAV, CM_INV },
  1448. #endif /* CK_MKDIR */
  1449.  
  1450. #ifndef NOXFER
  1451.     { "rmessage",    XXRMSG, CM_INV },    /* REMOTE MESSAGE */
  1452.     { "rmkdir",      XXRMKD, CM_INV },    /* REMOTE MKDIR */
  1453.     { "rmsg",        XXRMSG, CM_INV },    /* REMOTE MESSAGE */
  1454. #ifndef NOSPL
  1455.     { "robust",      XXROB,  CM_INV },
  1456. #else
  1457.     { "robust",      XXNOTAV, CM_INV },
  1458. #endif /* NOSPL */
  1459.     { "rprint",      XXRPRI, CM_INV },  /* REMOTE PRINT */
  1460.     { "rpwd",        XXRPWD, CM_INV },    /* REMOTE PWD */
  1461.     { "rquery",      XXRQUE, CM_INV },    /* REMOTE QUERY */
  1462. #endif /* NOXFER */
  1463.  
  1464. #ifdef CK_RECALL
  1465.     { "rr",          XXREDO, CM_INV|CM_NOR },
  1466. #endif /* CK_RECALL */
  1467.  
  1468. #ifndef NOXFER
  1469.     { "rrename",    XXRREN, CM_INV },    /* REMOTE RENAME */
  1470.     { "rrmdir",     XXRRMD, CM_INV },    /* REMOTE REMDIR */
  1471.     { "rset",       XXRSET, CM_INV },    /* REMOTE SET */
  1472.     { "rspace",     XXRSPA, CM_INV },    /* REMOTE SPACE */
  1473.     { "rtype",      XXRTYP, CM_INV },    /* REMOTE TYPE */
  1474. #endif /* NOXFER */
  1475.  
  1476. #ifndef NOPUSH
  1477.     { "run",         XXSHE, CM_PSH },    /* RUN a program or command */
  1478. #else
  1479.     { "run",         XXNOTAV, CM_INV|CM_PSH },
  1480. #endif /* NOPUSH */
  1481.  
  1482. #ifndef NOXFER
  1483.     { "rwho",        XXRWHO, CM_INV },    /* REMOTE WHO */
  1484.     { "s",           XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */
  1485. #endif /* NOXFER */
  1486.  
  1487. #ifndef NOSETKEY
  1488. #ifdef OS2
  1489.     { "save",       XXSAVE, 0 },        /* SAVE something */
  1490. #else
  1491.     { "save",       XXSAVE, CM_INV },
  1492. #endif /* OS2 */
  1493. #else
  1494.     { "save",       XXNOTAV, CM_INV },
  1495. #endif /* NOSETKEY */
  1496.  
  1497. #ifndef NOSCRIPT
  1498.     { "sc",        XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1499.     { "scr",       XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1500. #endif /* NOSCRIPT */
  1501.     { "screen",      XXSCRN, 0 },    /* SCREEN actions */
  1502. #ifndef NOSCRIPT
  1503.     { "script",       XXLOGI, CM_LOC },    /* Expect-Send-style script line */
  1504. #else
  1505.     { "script",       XXNOTAV, CM_INV|CM_LOC },
  1506. #endif /* NOSCRIPT */
  1507.  
  1508.     { "search",    XXGREP,CM_INV },    /* Synonym for GREP and FIND */
  1509.  
  1510. #ifndef NOXFER
  1511.     { "send",       XXSEN, 0 },        /* Send (a) file(s) */
  1512. #ifndef NOSERVER
  1513.     { "server",       XXSER, 0 },        /* Be a SERVER */
  1514. #else
  1515.     { "server",       XXNOTAV, CM_INV },
  1516. #endif /* NOSERVER */
  1517. #endif /* NOXFER */
  1518.  
  1519.     { "set",       XXSET, 0 },        /* SET parameters */
  1520.  
  1521. #ifndef NOSPL
  1522. #ifndef NOSEXP
  1523.     { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */
  1524. #endif /* NOSEXP */
  1525.  
  1526. #ifdef SFTP_BUILTIN
  1527.     { "sftp",        XXSFTP, 0 },   /* SFTP */
  1528. #endif /* SFTP_BUILTIN */
  1529.  
  1530. #ifndef NOSHOW
  1531.     { "sh",          XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */
  1532. #endif /* NOSHOW */
  1533.     { "shift",       XXSHIFT, 0 },    /* SHIFT args */
  1534. #else
  1535.     { "shift",       XXNOTAV, CM_INV },
  1536. #endif /* NOSPL */
  1537.  
  1538. #ifndef NOSHOW
  1539.     { "show",        XXSHO, 0 },        /* SHOW parameters */
  1540. #else
  1541.     { "show",        XXNOTAV, CM_INV },
  1542. #endif /* NOSHOW */
  1543.  
  1544. #ifdef NEWFTP
  1545.     { "site",        XXSITE, CM_INV },    /* (FTP) SITE */
  1546. #endif /* NEWFTP */
  1547.  
  1548. #ifdef SSHBUILTIN
  1549.     { "skermit",   XXSKRM, 0 },     /* SKERMIT */
  1550. #endif /* SSHBUILTIN */
  1551.  
  1552. #ifndef NOSPL
  1553. #ifndef NOFRILLS
  1554.     { "sleep",       XXPAU, CM_INV },    /* SLEEP for specified interval */
  1555. #endif /* NOFRILLS */
  1556. #endif /* NOSPL */
  1557.  
  1558. #ifndef NOSPL
  1559.     { "sort",        XXSORT, CM_INV },    /* (see ARRAY) */
  1560. #else
  1561.     { "sort",        XXNOTAV, CM_INV },
  1562. #endif /* NOSPL */
  1563.  
  1564. #ifndef MAC
  1565. #ifndef NOFRILLS
  1566.     { "sp",          XXSPA, CM_INV|CM_ABR },
  1567.     { "spa",         XXSPA, CM_INV|CM_ABR },
  1568. #endif /* NOFRILLS */
  1569.     { "space",       XXSPA, 0 },    /* Show available disk SPACE */
  1570. #endif /* MAC */
  1571.  
  1572. #ifndef NOFRILLS
  1573. #ifndef NOPUSH
  1574.     { "spawn",       XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1575. #else
  1576.     { "spawn",       XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1577. #endif /* NOPUSH */
  1578. #endif /* NOFRILLS */
  1579.  
  1580. #ifdef ANYSSH
  1581.     { "ssh",         XXSSH, 0 },
  1582. #endif /* ANYSSH */
  1583.  
  1584. #ifndef NOXFER
  1585.     { "sta",         XXSTA, CM_INV|CM_ABR },
  1586.     { "stat",        XXSTA, CM_INV|CM_ABR },
  1587.     { "statistics",  XXSTA, 0 },    /* Display file transfer stats */
  1588. #endif /* NOXFER */
  1589.  
  1590.     { "status",      XXSTATUS,0 },    /* Show status of previous command */
  1591.  
  1592. #ifndef NOSPL
  1593.     { "stop",        XXSTO,   0 },    /* STOP all take files and macros */
  1594.     { "succeed",     XXSUCC,  CM_INV },    /* SUCCEED */
  1595. #else
  1596.     { "stop",        XXNOTAV, CM_INV },
  1597.     { "succeed",     XXNOTAV, CM_INV },
  1598. #endif /* NOSPL */
  1599.  
  1600. #ifndef NOFRILLS
  1601.     { "SUPPORT",     XXBUG, 0 },    /* Tech support instructions */
  1602. #else
  1603.     { "support",     XXNOTAV, CM_INV },
  1604. #endif /* NOFRILLS */
  1605.  
  1606. #ifndef NOJC
  1607.     { "suspend",     XXSUS, CM_PSH },    /* SUSPEND C-Kermit (UNIX only) */
  1608. #else
  1609.     { "suspend",     XXNOTAV, CM_INV|CM_PSH },
  1610. #endif /* NOJC */
  1611.  
  1612. #ifndef NOSPL
  1613.     { "switch",      XXSWIT, 0 },    /* SWITCH */
  1614. #else
  1615.     { "switch",      XXNOTAV, CM_INV },
  1616. #endif /* NOSPL */
  1617.  
  1618. #ifdef CK_TAPI
  1619.     { "ta",       XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */
  1620. #endif /* CK_TAPI */
  1621.  
  1622. #ifndef NOFRILLS
  1623.     { "tail",        XXTAIL, 0 },    /* Display end of a local file */
  1624. #endif /* NOFRILLS */
  1625.  
  1626.     { "take",       XXTAK, 0 },        /* TAKE commands from a file */
  1627.  
  1628. #ifdef CK_TAPI
  1629.     { "tapi",       XXTAPI, CM_LOC },    /* Microsoft TAPI commands */
  1630. #else
  1631.     { "tapi",       XXNOTAV, CM_INV|CM_LOC },
  1632. #endif /* CK_TAPI */
  1633.  
  1634. #ifndef NOFRILLS
  1635. #ifdef TCPSOCKET
  1636.     { "tel",         XXTEL, CM_INV|CM_ABR|CM_LOC },
  1637.     { "telnet",      XXTEL, CM_LOC },    /* TELNET (TCP/IP only) */
  1638.     { "telopt",      XXTELOP, CM_INV },    /* TELOPT (ditto) */
  1639. #else
  1640.     { "tel",         XXNOTAV, CM_INV|CM_LOC },
  1641.     { "telnet",      XXNOTAV, CM_INV|CM_LOC },
  1642.     { "telopt",      XXNOTAV, CM_INV },
  1643. #endif /* TCPSOCKET */
  1644. #ifdef OS2
  1645.     { "terminal",    XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */
  1646. #else
  1647.     { "terminal",    XXTERM, CM_INV },
  1648. #endif /* OS2 */
  1649. #endif /* NOFRILLS */
  1650. #ifndef NOXFER
  1651.     { "text",        XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  1652. #endif /* NOXFER */
  1653.  
  1654. #ifndef NOSPL
  1655.     { "trace",       XXTRACE, 0 },    /* TRACE */
  1656. #else
  1657.     { "trace",       XXNOTAV, CM_INV },
  1658. #endif /* NOSPL */
  1659.  
  1660. #ifndef NOCSETS
  1661.     { "translate",   XXXLA, 0 },    /* TRANSLATE local file char sets */
  1662. #else
  1663.     { "translate",   XXNOTAV, CM_INV },
  1664. #endif /* NOCSETS */
  1665.  
  1666. #ifndef NOXMIT
  1667.     { "transmit",    XXTRA, 0 },    /* Send (upload) a file, no protocol */
  1668. #else
  1669.     { "transmit",    XXNOTAV, CM_INV },
  1670. #endif /* NOXMIT */
  1671.  
  1672. #ifndef NOFRILLS
  1673.     { "type",        XXTYP, 0 },    /* Display a local file */
  1674. #endif /* NOFRILLS */
  1675.  
  1676. #ifndef NOSPL
  1677.     { "undcl",       XXUNDCL, CM_INV },
  1678.     { "undeclare",   XXUNDCL, 0 },    /* UNDECLARE an array */
  1679.     { "undefine",    XXUNDEF, 0 },    /* UNDEFINE a variable or macro */
  1680. #else
  1681.     { "undcl",       XXNOTAV, CM_INV },
  1682.     { "undeclare",   XXNOTAV, CM_INV },
  1683.     { "undefine",    XXNOTAV, CM_INV },
  1684. #endif /* NOSPL */
  1685.  
  1686. #ifdef NEWFTP
  1687.     { "user",        XXUSER,  CM_INV }, /* (FTP) USER */
  1688. #endif /* NEWFTP */
  1689.  
  1690.     { "version",     XXVER, 0 },    /* VERSION-number display */
  1691.  
  1692. #ifdef OS2
  1693.     { "viewonly",    XXVIEW, CM_LOC },    /* VIEWONLY Terminal Mode */
  1694. #endif /* OS2 */
  1695.  
  1696.     { "void",        XXVOID, 0 },    /* VOID */
  1697.  
  1698. #ifndef NOSPL
  1699.     { "wait",        XXWAI, 0 },    /* WAIT */
  1700. #else
  1701.     { "wait",        XXNOTAV, CM_INV },
  1702. #endif /* NOSPL */
  1703.  
  1704.     { "wermit",      XXKERMI, CM_INV },
  1705.  
  1706. #ifndef NOXFER
  1707.     { "where",       XXWHERE, 0 },    /* WHERE (did my file go?) */
  1708. #endif /* NOXFER */
  1709.  
  1710. #ifndef NOSPL
  1711.     { "while",       XXWHI, 0 },    /* WHILE loop */
  1712. #else
  1713.     { "while",       XXNOTAV, CM_INV },
  1714. #endif /* NOSPL */
  1715.  
  1716. #ifndef OS2
  1717. #ifndef MAC
  1718. #ifndef NOFRILLS
  1719.     { "who",         XXWHO, CM_PSH },    /* WHO's logged in? */
  1720. #endif /* NOFRILLS */
  1721. #endif /* MAC */
  1722. #endif /* OS2 */
  1723.  
  1724. #ifndef NOHELP
  1725.     { "wildcards",   XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */
  1726. #endif /* NOHELP */
  1727.  
  1728. #ifndef NOSPL
  1729.     { "wr",          XXWRI, CM_INV|CM_ABR },
  1730.     { "wri",         XXWRI, CM_INV|CM_ABR },
  1731.     { "writ",        XXWRI, CM_INV|CM_ABR },
  1732.     { "write",       XXWRI, 0 },    /* WRITE characters to a file */
  1733.     { "write-line",  XXWRL, CM_INV },    /* WRITE a line to a file */
  1734.     { "writeln",     XXWRL, CM_INV },    /* Pascalisch synonym for write-line */
  1735. #else
  1736.     { "wr",          XXNOTAV, CM_INV },
  1737.     { "wri",         XXNOTAV, CM_INV },
  1738.     { "writ",        XXNOTAV, CM_INV },
  1739.     { "write",       XXNOTAV, CM_INV },
  1740.     { "write-line",  XXNOTAV, CM_INV },
  1741.     { "writeln",     XXNOTAV, CM_INV },
  1742. #endif /* NOSPL */
  1743.  
  1744. #ifndef NOFRILLS
  1745.     { "xecho",       XXXECH,0 },    /* XECHO */
  1746. #endif /* NOFRILLS */
  1747.  
  1748. #ifndef NOSPL
  1749.     { "xif",         XXIFX, CM_INV },    /* Extended IF command (obsolete) */
  1750. #else
  1751.     { "xif",         XXNOTAV, CM_INV },
  1752. #endif /* NOSPL */
  1753.  
  1754. #ifndef NOCSETS
  1755.     { "xlate",       XXXLA, CM_INV },    /* Synonym for TRANSLATE */
  1756. #else
  1757.     { "xlate",       XXNOTAV, CM_INV },
  1758. #endif /* NOCSETS */
  1759.  
  1760. #ifndef NOXMIT
  1761.     { "xmit",        XXTRA, CM_INV },    /* Synonym for TRANSMIT */
  1762. #else
  1763.     { "xmit",        XXNOTAV, CM_INV },
  1764. #endif /* NOXMIT */
  1765.  
  1766. #ifndef OS2
  1767. #ifndef NOJC
  1768.     { "z",           XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */
  1769. #else
  1770.     { "z",           XXNOTAV, CM_INV|CM_PSH },
  1771. #endif /* NOJC */
  1772. #endif /* OS2 */
  1773.  
  1774. #ifndef NOSPL
  1775.     { "{",           XXMACRO, CM_INV },    /* Immediate macro */
  1776. #endif /* NOSPL */
  1777.     { "", 0, 0 }
  1778. };
  1779. int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1;
  1780.  
  1781. /* NOTE: Tokens must also be entered above into cmdtab[]. */
  1782.  
  1783. char toktab[] = {
  1784. #ifndef NOPUSH
  1785.     '!',                /* Shell escape */
  1786. #endif /* NOPUSH */
  1787.     '#',                /* Comment */
  1788. #ifndef NOSPL
  1789.     '(',                /* S-Expression */
  1790.     '.',                /* Assignment */
  1791. #endif /* NOSPL */
  1792.     ';',                /* Comment */
  1793. #ifndef NOSPL
  1794.     ':',                /* Label */
  1795. #endif /* NOSPL */
  1796. #ifndef NOPUSH
  1797. #ifdef CK_REDIR
  1798.     '<',                /* REDIRECT */
  1799. #endif /* CK_REDIR */
  1800.     '@',                /* DCL escape */
  1801. #endif /* NOPUSH */
  1802. #ifdef CK_RECALL
  1803.     '^',                /* Command recall */
  1804. #endif /* CK_RECALL */
  1805. #ifndef NOSPL
  1806.     '{',                /* Immediate macro */
  1807. #endif /* NOSPL */
  1808.     '\0'                /* End of this string */
  1809. };
  1810. int xxdot = 0;                /* Used with "." token */
  1811.  
  1812. struct keytab yesno[] = {        /* Yes/No keyword table */
  1813.     { "no",    0, 0 },
  1814.     { "ok",    1, 0 },
  1815.     { "yes",   1, 0 }
  1816. };
  1817. int nyesno = (sizeof(yesno) / sizeof(struct keytab));
  1818.  
  1819. /* Save keyword table */
  1820.  
  1821. struct keytab savtab[] = {
  1822. #ifdef OS2
  1823.     { "command",  XSCMD, 0 },
  1824. #else
  1825. #ifdef CK_RECALL
  1826.     { "command",  XSCMD, 0 },
  1827. #endif /* CK_RECALL */
  1828. #endif /* OS2 */
  1829. #ifndef NOSETKEY
  1830.     { "keymap",   XSKEY, 0 },
  1831. #endif /* NOSETKEY */
  1832. #ifdef OS2
  1833.     { "terminal", XSTERM, 0 },
  1834. #endif /* OS2 */
  1835.     { "", 0, 0 }
  1836. };
  1837. int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1;
  1838.  
  1839. /* Parameter keyword table */
  1840.  
  1841. struct keytab prmtab[] = {
  1842.     { "alarm",            XYALRM,  0 },
  1843. #ifdef COMMENT                /* SET ANSWER not implemented yet */
  1844. #ifndef NODIAL
  1845.     { "answer",           XYANSWER,0 },
  1846. #endif /* NODIAL */
  1847. #endif /* COMMENT */
  1848.     { "ask-timer",        XYTIMER, 0 },
  1849. #ifndef NOXFER
  1850.     { "attributes",       XYATTR,  0 },
  1851. #endif /* NOXFER */
  1852. #ifdef CK_AUTHENTICATION
  1853.     { "authentication",   XYAUTH,  0 },
  1854. #else  /* CK_AUTHENTICATION */
  1855. #ifdef CK_SSL
  1856.     { "authentication",   XYAUTH,  0 },
  1857. #endif /* CK_SSL */
  1858. #endif /* CK_AUTHENTICATION */
  1859.     { "b",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1860.     { "ba",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1861. #ifdef VMS
  1862.     { "background",       XYBACK,  CM_INV|CM_PSH },
  1863.     { "batch",            XYBACK,  CM_PSH },
  1864. #else
  1865.     { "background",       XYBACK,  CM_PSH },
  1866.     { "batch",            XYBACK,  CM_INV|CM_PSH },
  1867. #endif /* VMS */
  1868. #ifndef NOLOCAL
  1869.     { "baud",              XYSPEE,  CM_INV|CM_LOC },
  1870. #endif /* NOLOCAL */
  1871.     { "bell",             XYBELL,  0 },
  1872. #ifndef NOXFER
  1873.     { "block-check",        XYCHKT,  0 },
  1874. #endif /* NOXFER */
  1875. #ifdef OS2
  1876. #ifdef BPRINT
  1877.     { "bprinter",         XYBDCP,  CM_INV },
  1878. #endif /* BPRINT */
  1879. #endif /*  OS2 */
  1880. #ifdef BROWSER
  1881.     { "browser",          XYBROWSE,CM_PSH|CM_LOC },
  1882. #endif /* BROWSER */
  1883. #ifndef NOXFER
  1884. #ifdef DYNAMIC
  1885.     { "buffers",          XYBUF,   0 },
  1886. #endif /* DYNAMIC */
  1887. #endif /* NOXFER */
  1888. #ifndef NOLOCAL
  1889. #ifndef MAC
  1890.     { "carrier-watch",    XYCARR,  CM_LOC },
  1891. #endif /* MAC */
  1892. #endif /* NOLOCAL */
  1893. #ifndef NOSPL
  1894.     { "case",             XYCASE,  0 },
  1895. #endif /* NOSPL */
  1896.     { "cd",               XYCD,    0 },
  1897. #ifndef NOXFER
  1898.     { "cl",               XYCLEAR, CM_INV|CM_ABR },
  1899.     { "cle",              XYCLEAR, CM_INV|CM_ABR },
  1900.     { "clea",             XYCLEAR, CM_INV|CM_ABR },
  1901.     { "clear",            XYCLEAR, CM_INV|CM_ABR },
  1902.     { "clear-channel",    XYCLEAR, 0 },
  1903.     { "clearchannel",     XYCLEAR, CM_INV },
  1904. #endif /* NOXFER */
  1905. #ifndef NOLOCAL
  1906.     { "close-on-disconnect", XYDISC, CM_INV|CM_LOC },
  1907. #endif /* NOLOCAL */
  1908.     { "cmd",              XYCMD,   CM_INV },
  1909.     { "command",          XYCMD,   0 },
  1910. #ifdef CK_SPEED
  1911.     { "con",              XYQCTL,  CM_INV|CM_ABR },
  1912. #endif /* CK_SPEED */
  1913.     { "console",          XYCMD,   CM_INV },
  1914. #ifdef CK_SPEED
  1915.     { "control-character",XYQCTL,  0 },
  1916. #endif /* CK_SPEED */
  1917. #ifndef NOSPL
  1918.     { "count",            XYCOUN,  0 },
  1919. #endif /* NOSPL */
  1920. #ifndef NOXFER
  1921.     { "d",          XYDELA,  CM_INV|CM_ABR },
  1922.     { "de",          XYDELA,  CM_INV|CM_ABR },
  1923. #endif /* NOXFER */
  1924.     { "debug",            XYDEBU,  0 },
  1925. #ifdef VMS
  1926.     { "default",          XYDFLT,  0 },
  1927. #else
  1928. #ifndef MAC
  1929.     { "default",          XYDFLT,  CM_INV },
  1930. #endif /* MAC */
  1931. #endif /* VMS */
  1932. #ifndef NOXFER
  1933.     { "delay",              XYDELA,  0 },
  1934.     { "destination",      XYDEST,  0 },
  1935. #endif /* NOXFER */
  1936. #ifndef NODIAL
  1937.     { "di",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1938.     { "dia",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1939.     { "dial",             XYDIAL,  CM_LOC },
  1940. #endif /* NODIAL */
  1941. #ifdef OS2
  1942.     { "dialer",          XYDLR,   CM_INV },
  1943. #endif /* OS2 */
  1944. #ifndef NOLOCAL
  1945.     { "disconnect",       XYDISC,  CM_LOC },
  1946.     { "duplex",              XYDUPL,  CM_LOC },
  1947. #endif /* NOLOCAL */
  1948. #ifndef NOPUSH
  1949. #ifndef NOFRILLS
  1950.     { "editor",           XYEDIT,  CM_PSH },
  1951. #endif /*  NOFRILLS */
  1952. #endif /* NOPUSH */
  1953. #ifdef CK_CTRLZ
  1954.     { "eof",              XYEOF,   CM_INV },
  1955. #endif /* CK_CTRLZ */
  1956. #ifndef NOLOCAL
  1957.     { "escape-character", XYESC,   CM_LOC },
  1958. #endif /* NOLOCAL */
  1959. #ifndef NOSPL
  1960.     { "evaluate",         XYEVAL,  CM_INV },
  1961. #endif /* NOSPL */
  1962.     { "exit",          XYEXIT,  0 },
  1963. #ifndef NOXFER
  1964.     { "f-ack-bug",        XYFACKB, CM_INV },
  1965.     { "f-ack-path",       XYFACKP, CM_INV },
  1966. #endif /* NOXFER */
  1967.     { "file",             XYFILE,  0 },
  1968.     { "fl",                 XYFLOW,  CM_INV|CM_ABR },
  1969. #ifndef NOSPL
  1970.     { "flag",             XYFLAG,  0 },
  1971. #endif /* NOSPL */
  1972. #ifdef TCPSOCKET
  1973. #ifndef SYSFTP
  1974. #ifndef NOFTP
  1975.     { "ft",                 XYFTPX,  CM_INV|CM_ABR },
  1976.     { "ftp",                XYFTPX,  0 },
  1977. #endif /* NOFTP */
  1978. #endif /* SYSFTP */
  1979. #endif /* TCPSOCKET */
  1980. #ifdef BROWSER
  1981.     { "ftp-client",       XYFTP,   CM_PSH },
  1982. #endif /* BROWSER */
  1983.     { "flow-control",       XYFLOW,  0 },
  1984. #ifndef NOSPL
  1985.     { "function",         XYFUNC,  0 },
  1986. #endif /* NOSPL */
  1987. #ifdef NEWFTP
  1988.     { "get-put-remote",   XYGPR,   0 },
  1989. #endif /* NEWFTP */
  1990. #ifdef KUI
  1991.     { "gui",              XYGUI,   0 },
  1992. #endif /* KUI */
  1993.     { "handshake",          XYHAND,  0 },
  1994.     { "hints",            XYHINTS, 0 },
  1995. #ifdef NETCONN
  1996.     { "host",             XYHOST,  CM_LOC },
  1997. #endif /* NETCONN */
  1998. #ifndef NOSPL
  1999.     { "i",          XYINPU,  CM_INV|CM_ABR },
  2000. #endif /* NOSPL */
  2001. #ifdef IKSD
  2002.     { "iks",              XYIKS,   0 },
  2003. #else
  2004.     { "iks",              XYIKS,   CM_INV },
  2005. #endif /* IKSD */
  2006. #ifndef NOSPL
  2007.     { "in",          XYINPU,  CM_INV|CM_ABR },
  2008. #endif /* NOSPL */
  2009. #ifndef NOXFER
  2010.     { "incomplete",         XYIFD,   CM_INV },
  2011. #endif /* NOXFER */
  2012. #ifndef NOSPL
  2013.     { "input",            XYINPU,  0 },
  2014. #endif /* NOSPL */
  2015. #ifndef NOSETKEY
  2016.     { "key",          XYKEY,   0 },
  2017. #endif /* NOSETKEY */
  2018.     { "l",                XYLINE,  CM_INV|CM_ABR },
  2019. #ifndef NOCSETS
  2020.     { "language",         XYLANG,  0 },
  2021. #endif /* NOCSETS */
  2022. #ifndef NOLOCAL
  2023.     { "line",             XYLINE,  CM_LOC },
  2024.     { "local-echo",      XYLCLE,  CM_INV|CM_LOC },
  2025. #endif /* NOLOCAL */
  2026. #ifdef LOCUS
  2027.     { "locus",            XYLOCUS, 0 },
  2028. #endif /* LOCUS */
  2029. #ifndef NOSPL
  2030.     { "login",          XYLOGIN, CM_LOC },
  2031. #endif /* NOSPL */
  2032. #ifndef NOSPL
  2033.     { "macro",            XYMACR,  0 },
  2034. #endif /* NOSPL */
  2035.     { "match",            XYMATCH, 0 },
  2036. #ifdef COMMENT
  2037. #ifdef VMS
  2038.     { "messages",         XYMSGS,  0 },
  2039. #endif /* VMS */
  2040. #endif /* COMMENT */
  2041. #ifndef NODIAL
  2042.     { "modem",          XYMODM,  CM_LOC },
  2043. #endif /* NODIAL */
  2044. #ifndef NOLOCAL
  2045. #ifdef OS2MOUSE
  2046.     { "mouse",          XYMOUSE, 0 },
  2047. #endif /* OS2MOUSE */
  2048. #endif /* NOLOCAL */
  2049. #ifdef OS2
  2050.     { "mskermit",         XYMSK,   0 },
  2051. #endif /* OS2 */
  2052. #ifdef NETCONN
  2053.     { "network",          XYNET,   CM_LOC },
  2054. #endif /* NETCONN */
  2055. #ifndef NOSPL
  2056.     { "output",           XYOUTP,  0 },
  2057. #endif /* NOSPL */
  2058.     { "options",          XYOPTS,  0 },
  2059.     { "pause",            XYSLEEP, CM_INV },
  2060. #ifdef ANYX25
  2061. #ifndef IBMX25
  2062.     { "pad",              XYPAD,   CM_LOC },
  2063. #endif /* IBMX25 */
  2064. #endif /* ANYX25 */
  2065.     { "parity",              XYPARI,  0 },
  2066. #ifndef NOLOCAL
  2067. #ifdef OS2
  2068.     { "port",             XYLINE,  CM_LOC },
  2069. #else
  2070.     { "port",             XYLINE,  CM_INV|CM_LOC },
  2071. #endif /* OS2 */
  2072. #endif /* NOLOCAL */
  2073. #ifndef NOFRILLS
  2074.     { "pr",                 XYPROM,  CM_INV|CM_ABR },
  2075.     { "printer",          XYPRTR,  0 },
  2076. #endif /* NOFRILLS */
  2077. #ifdef OS2
  2078.     { "priority",         XYPRTY,  0 },
  2079. #endif /* OS2 */
  2080. #ifdef CK_SPEED
  2081.     { "prefixing",        XYPREFIX, 0 },
  2082. #endif /* CK_SPEED */
  2083. #ifndef NOFRILLS
  2084.     { "prompt",              XYPROM,  0 },
  2085. #endif /* NOFRILLS */
  2086. #ifndef NOXFER
  2087.     { "protocol",      XYPROTO, 0 },
  2088. #endif /* NOXFER */
  2089.     { "q",          XYQUIE,  CM_INV|CM_ABR },
  2090. #ifndef NOXFER
  2091.     { "q8flag",           XYQ8FLG, CM_INV },
  2092. #endif /* NOXFER */
  2093. #ifdef QNX
  2094.     { "qnx-port-lock",    XYQNXPL, 0 },
  2095. #else
  2096.     { "qnx-port-lock",    XYQNXPL, CM_INV },
  2097. #endif /* QNX */
  2098.     { "quiet",          XYQUIE,  0 },
  2099. #ifndef NOXFER
  2100.     { "rec",              XYRECV,  CM_INV|CM_ABR },
  2101.     { "receive",          XYRECV,  0 },
  2102.     { "recv",             XYRECV,  CM_INV },
  2103. #endif /* NOXFER */
  2104.     { "reliable",         XYRELY,  0 },
  2105. #ifndef NOXFER
  2106.     { "repeat",           XYREPT,  0 },
  2107.     { "retry-limit",      XYRETR,  0 },
  2108. #endif /* NOXFER */
  2109. #ifdef CKROOT
  2110.     { "root",             XYROOT,  0 },
  2111. #endif /* CKROOT */
  2112. #ifndef NOSCRIPT
  2113.     { "script",          XYSCRI,  CM_LOC },
  2114. #endif /* NOSCRIPT */
  2115. #ifndef NOXFER
  2116.     { "send",             XYSEND,  0 },
  2117. #ifndef NOLOCAL
  2118. #ifndef NOSERVER
  2119.     { "ser",              XYSERV,  CM_INV|CM_ABR },
  2120. #endif /* NOSERVER */
  2121. #endif /* NOXFER */
  2122.     { "serial",           XYSERIAL,CM_LOC },
  2123. #endif /* NOLOCAL */
  2124. #ifndef NOSERVER
  2125.     { "server",           XYSERV,  0 },
  2126. #endif /* NOSERVER */
  2127. #ifdef SESLIMIT
  2128. #ifndef NOLOCAL
  2129.     { "session-l",        XYSESS,  CM_INV|CM_ABR },
  2130. #endif /* NOLOCAL */
  2131.     { "session-limit",    XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */
  2132. #endif /* SESLIMIT */
  2133.  
  2134. #ifndef NOLOCAL
  2135.     { "session-log",      XYSESS,  CM_LOC },
  2136. #endif /* NOLOCAL */
  2137.  
  2138. #ifndef NOSPL
  2139. #ifndef NOSEXP
  2140.     { "sexpression",      XYSEXP,  CM_INV },
  2141. #endif /* NOSEXP */
  2142. #endif /* NOSPL */
  2143.  
  2144.     { "sleep",            XYSLEEP, 0 },
  2145.  
  2146. #ifndef NOLOCAL
  2147.     { "speed",              XYSPEE,  CM_LOC },
  2148. #endif /* NOLOCAL */
  2149.  
  2150. #ifdef ANYSSH
  2151.     { "ssh",              XYSSH,   0 },
  2152. #endif /* ANYSSH */
  2153.  
  2154. #ifndef NOSPL
  2155.     { "startup-file",     XYSTARTUP, CM_INV },
  2156. #endif /* NOSPL */
  2157.  
  2158. #ifndef NOLOCAL
  2159. #ifdef HWPARITY
  2160.     { "stop-bits",        XYSTOP, CM_LOC },
  2161. #else
  2162. #ifdef TN_COMPORT
  2163.     { "stop-bits",        XYSTOP, CM_LOC },
  2164. #endif /* TN_COMPORT */
  2165. #endif /* HWPARITY */
  2166. #endif /* NOLOCAL */
  2167.  
  2168. #ifndef NOXFER
  2169. #ifdef STREAMING
  2170.     { "streaming",        XYSTREAM, 0 },
  2171. #endif /* STREAMING */
  2172. #endif /* NOXFER */
  2173.  
  2174. #ifndef NOJC
  2175.     { "suspend",          XYSUSP,  CM_PSH },
  2176. #endif /* NOJC */
  2177. #ifdef CKSYSLOG
  2178.     { "syslog",           XYSYSL,  CM_INV },
  2179. #endif /* CKSYSLOG */
  2180.     { "take",             XYTAKE,  0 },
  2181.  
  2182. #ifdef CK_TAPI
  2183.     { "tapi",             XYTAPI,  CM_LOC },
  2184. #endif /* CK_TAPI */
  2185.  
  2186. #ifndef NOTCPOPTS
  2187. #ifdef TCPSOCKET
  2188.     { "tcp",              XYTCP,   CM_LOC },
  2189. #endif /* TCPSOCKET */
  2190. #endif /* NOTCPOPTS */
  2191.  
  2192. #ifdef TNCODE
  2193.     { "tel",              XYTEL,   CM_INV|CM_ABR },
  2194.     { "telnet",           XYTEL,   0 },
  2195.     { "telopt",           XYTELOP, 0 },
  2196. #endif /* TNCODE */
  2197.  
  2198. #ifndef NOSPL
  2199.     { "temp-directory",   XYTMPDIR,0 },
  2200. #endif /* NOSPL */
  2201.  
  2202. #ifndef NOLOCAL
  2203.     { "terminal",         XYTERM,  CM_LOC },
  2204. #endif /* NOLOCAL */
  2205.  
  2206. #ifdef OS2
  2207.     { "title",          XYTITLE, CM_LOC },
  2208. #endif /* OS2 */
  2209. #ifdef TLOG
  2210.     { "transaction-log",  XYTLOG,  0 },
  2211. #endif /* TLOG */
  2212. #ifndef NOXFER
  2213.     { "transfer",         XYXFER,  0 },
  2214. #endif /* NOXFER */
  2215. #ifndef NOXMIT
  2216.     { "transmit",         XYXMIT,  0 },
  2217. #endif /* NOXMIT */
  2218. #ifndef NOXFER
  2219. #ifndef NOCSETS
  2220.     { "unknown-char-set", XYUNCS,  0 },
  2221. #endif /* NOCSETS */
  2222. #endif /* NOXFER */
  2223.     { "wait",             XYSLEEP, CM_INV },
  2224. #ifndef NOPUSH
  2225. #ifdef UNIX
  2226.     { "wildcard-expansion", XYWILD, 0 },
  2227. #endif /* UNIX */
  2228. #endif /* NOPUSH */
  2229. #ifdef NT
  2230.     { "w",                XYWIND,  CM_INV|CM_ABR },
  2231.     { "wi",               XYWIND,  CM_INV|CM_ABR },
  2232.     { "win",              XYWIND,  CM_INV|CM_ABR },
  2233. #endif /* NT */
  2234.     { "window-size",      XYWIND,  0 },
  2235. #ifdef NT
  2236.     { "win95",            XYWIN95, 0 },
  2237. #endif /* NT */
  2238. #ifdef ANYX25
  2239.     { "x.25",             XYX25,   CM_LOC },
  2240.     { "x25",              XYX25,   CM_INV|CM_LOC },
  2241. #endif /* ANYX25 */
  2242.     { "xfer",             XYXFER,  CM_INV },
  2243. #ifndef NOXMIT
  2244.     { "xmit",             XYXMIT,  CM_INV },
  2245. #endif /* NOXMIT */
  2246.     { "", 0, 0 }
  2247. };
  2248. int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */
  2249.  
  2250. struct keytab scntab[] = {        /* Screen commands */
  2251.     { "clear",   SCN_CLR, 0 },
  2252.     { "cleol",   SCN_CLE, 0 },
  2253.     { "move-to", SCN_MOV, 0 }
  2254. };
  2255. int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */
  2256.  
  2257. #ifdef ANYSSH                /* SSH command table */
  2258. #ifdef SSHBUILTIN
  2259. int    ssh_pf_lcl_n = 0,
  2260.        ssh_pf_rmt_n = 0;
  2261. struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */
  2262. struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */
  2263. extern char * ssh_hst, * ssh_cmd, * ssh_prt;
  2264. extern int    ssh_ver,   ssh_xfw;
  2265. char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL,
  2266.      * ssh_tmpstr = NULL;
  2267.  
  2268. int
  2269.  sshk_type = SSHKT_2D,            /* SSH KEY CREATE /TYPE:x */
  2270.  sshk_bits = 1024,            /* SSH KEY CREATE /BITS:n */
  2271.  sshk_din  = SKDF_OSSH,            /* SSH KEY DISPLAY /IN-FORMAT: */
  2272.  sshk_dout = SKDF_OSSH;            /* SSH KEY DISPLAY /OUT-FORMAT: */
  2273.  
  2274. char
  2275.  * sshk1_comment = NULL,        /* SSH V1 COMMENT */
  2276.  * sshkp_old = NULL,            /* Old key passphrase */
  2277.  * sshkp_new = NULL,            /* New key passphrase */
  2278.  * sshkc_pass = NULL,            /* KEY CREATE /PASS:xxx */
  2279.  * sshkc_comm = NULL,            /* KEY CREATE /V1-RSA-COMMENT:xxx */
  2280.  * sshd_file = NULL,            /* DISPLAY file */
  2281.  * sshk_file = NULL;            /* SSH CREATE KEY file */
  2282.  
  2283. static struct keytab sshclr[] = {
  2284.     { "local-port-forward",  SSHC_LPF, 0 },
  2285.     { "remote-port-forward", SSHC_RPF, 0 },
  2286.     { "", 0, 0 }
  2287. };
  2288. static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1;
  2289.  
  2290. struct keytab sshopnsw[] = {
  2291.     { "/command",        SSHSW_CMD, CM_ARG },
  2292.     { "/password",       SSHSW_PWD, CM_ARG },
  2293.     { "/subsystem",      SSHSW_SUB, CM_ARG },
  2294.     { "/user",           SSHSW_USR, CM_ARG },
  2295.     { "/version",        SSHSW_VER, CM_ARG },
  2296.     { "/x11-forwarding", SSHSW_X11, CM_ARG },
  2297.     { "", 0, 0 }
  2298. };
  2299. int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1;
  2300.  
  2301. static struct keytab sshkwtab[] = {
  2302.     { "add",                 XSSH_ADD, 0 },
  2303.     { "agent",               XSSH_AGT, 0 },
  2304.     { "clear",               XSSH_CLR, 0 },
  2305.     { "forward-local-port",  XSSH_FLP, CM_INV },
  2306.     { "forward-remote-port", XSSH_FRP, CM_INV },
  2307.     { "key",                 XSSH_KEY, 0 },
  2308.     { "open",                XSSH_OPN, 0 },
  2309.     { "v2",                  XSSH_V2,  0 },
  2310.     { "", 0, 0 }
  2311. };
  2312. static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1;
  2313.  
  2314. static struct keytab ssh2tab[] = {
  2315.     { "rekey", XSSH2_RKE, 0 },
  2316.     { "", 0, 0 }
  2317. };
  2318. static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab));
  2319.  
  2320. static struct keytab addfwd[] = {    /* SET SSH ADD command table */
  2321.     { "local-port-forward",  SSHF_LCL, 0 },
  2322.     { "remote-port-forward", SSHF_RMT, 0 },
  2323.     { "", 0, 0 }
  2324. };
  2325. static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
  2326.  
  2327. static struct keytab sshagent[] = {    /* SET SSH AGENT command table */
  2328.     { "add",    SSHA_ADD, 0 },
  2329.     { "delete", SSHA_DEL, 0 },
  2330.     { "list",   SSHA_LST, 0 },
  2331.     { "", 0, 0 }
  2332. };
  2333. static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1;
  2334.  
  2335. static struct keytab sshagtsw[] = {    /* SET SSH AGENT LIST switch table */
  2336.     { "/fingerprint", SSHASW_FP, 0 },
  2337.     { "", 0, 0 }
  2338. };
  2339. static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1;
  2340.  
  2341. static struct keytab sshkey[] = {    /* SET SSH KEY command table */
  2342.     { "change-passphrase",  SSHK_PASS, 0 },
  2343.     { "create",             SSHK_CREA, 0 },
  2344.     { "display",            SSHK_DISP, 0 },
  2345.     { "v1",                 SSHK_V1,   0 },
  2346.     { "", 0, 0 }
  2347. };
  2348. static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1;
  2349.  
  2350. static struct keytab sshkv1[] = {    /* SET SSH KEY V1 command table */
  2351.     { "set-comment",  1, 0 }
  2352. };
  2353.  
  2354. static struct keytab sshkpsw[] = {    /* SET SSH KEY PASSPHRASE table */
  2355.     { "/new-passphrase",  2, CM_ARG },
  2356.     { "/old-passphrase",  1, CM_ARG }
  2357. };
  2358.  
  2359. static struct keytab sshkcrea[] = {    /* SSH KEY CREATE table */
  2360.     { "/bits",           SSHKC_BI, CM_ARG },
  2361.     { "/passphrase",     SSHKC_PP, CM_ARG },
  2362.     { "/type",           SSHKC_TY, CM_ARG },
  2363.     { "/v1-rsa-comment", SSHKC_1R, CM_ARG }
  2364. };
  2365. static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab));
  2366.  
  2367. static struct keytab sshkcty[] = {    /* SSH KEY CREATE /TYPE:xxx */
  2368.     { "srp",    SSHKT_SRP, 0 },
  2369.     { "v1-rsa", SSHKT_1R, 0 },
  2370.     { "v2-dsa", SSHKT_2D, 0 },
  2371.     { "v2-rsa", SSHKT_2R, 0 }
  2372. };
  2373. static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab));
  2374.  
  2375. static struct keytab sshdswi[] = {    /* SET SSH KEY DISPLAY /switches */
  2376.     { "/format", SSHKD_OUT, CM_ARG }
  2377. };
  2378. static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab));
  2379.  
  2380. #ifdef COMMENT
  2381. static struct keytab sshdifmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2382.     { "openssh", SKDF_OSSH, 0 },
  2383.     { "ssh.com", SKDF_SSHC, 0 }
  2384. };
  2385. static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab));
  2386. #endif /* COMMENT */
  2387.  
  2388. static struct keytab sshdofmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2389.     { "fingerprint", SKDF_FING, 0 },
  2390.     { "ietf",        SKDF_IETF, 0 },
  2391.     { "openssh",     SKDF_OSSH, 0 },
  2392.     { "ssh.com",     SKDF_SSHC, 0 }
  2393. };
  2394. static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab));
  2395.  
  2396. static struct keytab sshkermit[] = { /* SKERMIT */
  2397.     { "open",       SKRM_OPN, 0 }
  2398. };
  2399. static int nsshkermit = (sizeof(sshkermit) / sizeof(struct keytab));
  2400.  
  2401. struct keytab sshkrmopnsw[] = {
  2402.     { "/password",       SSHSW_PWD, CM_ARG },
  2403.     { "/user",           SSHSW_USR, CM_ARG },
  2404.     { "/version",        SSHSW_VER, CM_ARG },
  2405.     { "", 0, 0 }
  2406. };
  2407. int nsshkrmopnsw = (sizeof(sshkrmopnsw) / sizeof(struct keytab)) - 1;
  2408. #endif /* SSHBUILTIN */
  2409.  
  2410. #ifdef SFTP_BUILTIN
  2411. static struct keytab sftpkwtab[] = {    /* SFTP */
  2412.     {  "cd",        SFTP_CD,    0 },
  2413.     {  "chgrp",     SFTP_CHGRP, 0 },
  2414.     {  "chmod",     SFTP_CHMOD, 0 },
  2415.     {  "chown",     SFTP_CHOWN, 0 },
  2416.     {  "delete",    SFTP_RM,    0 },
  2417.     {  "dir",       SFTP_DIR,   0 },
  2418.     {  "get",       SFTP_GET,   0 },
  2419.     {  "mkdir",     SFTP_MKDIR, 0 },
  2420.     {  "open",      SFTP_OPN,   0 },
  2421.     {  "put",       SFTP_PUT,   0 },
  2422.     {  "pwd",       SFTP_PWD,   0 },
  2423.     {  "rename",    SFTP_REN,   0 },
  2424.     {  "rm",        SFTP_RM,    CM_INV },
  2425.     {  "rmdir",     SFTP_RMDIR, 0 },
  2426.     {  "symlink",   SFTP_LINK,  0 },
  2427.     {  "version",   SFTP_VER,   0 }
  2428. };
  2429. static int nsftpkwtab = (sizeof(sftpkwtab) / sizeof(struct keytab));
  2430. #endif /* SFTP_BUILTIN */
  2431. #endif /* ANYSSH */
  2432.  
  2433. #ifdef NETCONN
  2434. struct keytab netkey[] = {        /* SET NETWORK table */
  2435.     { "directory", XYNET_D,  0 },
  2436.     { "type",      XYNET_T,  0 }
  2437. };
  2438. int nnetkey = (sizeof(netkey) / sizeof(struct keytab));
  2439.  
  2440. struct keytab netcmd[] = {
  2441. /*
  2442.   These are the network types.
  2443. */
  2444. #ifdef NETCMD
  2445.     { "command",       NET_CMD,  CM_INV }, /* Command */
  2446. #endif /* NETCMD */
  2447.  
  2448. #ifdef DECNET                /* DECnet / PATHWORKS */
  2449.     { "decnet",        NET_DEC,  0 },
  2450. #endif /* DECNET */
  2451.  
  2452. #ifdef NETDLL
  2453.     { "dll",           NET_DLL,  CM_INV }, /* DLL to be loaded */
  2454. #endif /* NETDLL */
  2455.  
  2456. #ifdef NETFILE
  2457.     { "file",           NET_FILE, CM_INV }, /* FILE (real crude) */
  2458. #endif /* NETFILE */
  2459.  
  2460. #ifdef NPIPE                /* Named Pipes */
  2461.     { "named-pipe",     NET_PIPE,  0 },
  2462. #endif /* NPIPE */
  2463.  
  2464. #ifdef CK_NETBIOS
  2465.     { "netbios",        NET_BIOS,  0 },    /* NETBIOS */
  2466. #endif /* CK_NETBIOS */
  2467.  
  2468. #ifdef DECNET                /* DECnet / PATHWORKS (alias) */
  2469.     { "pathworks",     NET_DEC,  CM_INV },
  2470. #endif /* DECNET */
  2471.  
  2472. #ifdef NETCMD
  2473.     { "pipe",          NET_CMD,  0 },    /* Pipe */
  2474. #endif /* NETCMD */
  2475.  
  2476. #ifdef NETPTY
  2477.     { "pseudoterminal",NET_PTY, 0 },    /* Pseudoterminal */
  2478. #endif /* NETPTY */
  2479.  
  2480. #ifdef NETPTY
  2481.     { "pty",          NET_PTY,  CM_INV }, /* Inv syn for pseudoterm */
  2482. #endif /* NETPTY */
  2483.  
  2484. #ifdef SSHBUILTIN
  2485.     { "ssh",          NET_SSH,  0 },
  2486. #endif /* SSHBUILTIN */
  2487.  
  2488. #ifdef SUPERLAT
  2489.     { "superlat",     NET_SLAT, 0 },    /* Meridian Technologies' SuperLAT */
  2490. #endif /* SUPERLAT */
  2491.  
  2492. #ifdef TCPSOCKET            /* TCP/IP sockets library */
  2493.     { "tcp/ip",       NET_TCPB, 0 },
  2494. #endif /* TCPSOCKET */
  2495. #ifdef SUPERLAT
  2496.     { "tes32",        NET_SLAT, 0 },    /* Emulux TES32 */
  2497. #endif /* SUPERLAT */
  2498. #ifdef ANYX25                /* X.25 */
  2499. #ifdef SUNX25
  2500.     { "x",            NET_SX25, CM_INV|CM_ABR },
  2501.     { "x.25",         NET_SX25, 0 },
  2502.     { "x25",          NET_SX25, CM_INV },
  2503. #else
  2504. #ifdef STRATUSX25
  2505.     { "x",            NET_VX25, CM_INV|CM_ABR },
  2506.     { "x.25",         NET_VX25, 0 },
  2507.     { "x25",          NET_VX25, CM_INV },
  2508. #endif /* STRATUSX25 */
  2509. #endif /* SUNX25 */
  2510. #ifdef IBMX25
  2511.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2512.     { "x.25",         NET_IX25, CM_INV },
  2513.     { "x25",          NET_IX25, CM_INV },
  2514. #endif /* IBMX25 */
  2515. #ifdef HPX25
  2516.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2517.     { "x.25",         NET_IX25, 0 },
  2518.     { "x25",          NET_IX25, CM_INV },
  2519. #endif /* HPX25 */
  2520. #endif /* ANYX25 */
  2521.     { "", 0, 0 }
  2522. };
  2523. int nnets = (sizeof(netcmd) / sizeof(struct keytab));
  2524.  
  2525. #ifndef NOTCPOPTS
  2526. #ifdef TCPSOCKET
  2527.  
  2528. /* TCP options */
  2529.  
  2530. struct keytab tcpopt[] = {
  2531.     { "address",   XYTCP_ADDRESS, 0 },
  2532. #ifdef CK_DNS_SRV
  2533.     { "dns-service-records", XYTCP_DNS_SRV, 0 },
  2534. #endif /* CK_DNS_SRV */
  2535. #ifdef SO_DONTROUTE
  2536.     { "dontroute",   XYTCP_DONTROUTE, 0 },
  2537. #endif /* SO_DONTROUTE */
  2538. #ifndef NOHTTP
  2539.     { "http-proxy", XYTCP_HTTP_PROXY, 0 },
  2540. #endif /* NOHTTP */
  2541. #ifdef SO_KEEPALIVE
  2542.     { "keepalive", XYTCP_KEEPALIVE, 0 },
  2543. #endif /* SO_KEEPALIVE */
  2544. #ifdef SO_LINGER
  2545.     { "linger", XYTCP_LINGER, 0 },
  2546. #endif /* SO_LINGER */
  2547. #ifdef TCP_NODELAY
  2548.     { "nagle",  XYTCP_NAGLE,    CM_INV },
  2549.     { "nodelay", XYTCP_NODELAY, 0 },
  2550. #endif /* TCP_NODELAY */
  2551.     { "reverse-dns-lookup", XYTCP_RDNS, 0 },
  2552. #ifdef SO_RCVBUF
  2553.     { "recvbuf", XYTCP_RECVBUF, 0 },
  2554. #endif /* SO_RCVBUF */
  2555. #ifdef SO_SNDBUF
  2556.     { "sendbuf", XYTCP_SENDBUF, 0 },
  2557. #endif /* SO_SNDBUF */
  2558. #ifdef NT
  2559. #ifdef CK_SOCKS
  2560.     { "socks-server", XYTCP_SOCKS_SVR, 0 },
  2561. #endif /* CK_SOCKS */
  2562. #endif /* NT */
  2563. #ifdef VMS
  2564. #ifdef DEC_TCPIP
  2565.     { "ucx-port-bug", XYTCP_UCX, 0 },
  2566. #endif /* DEC_TCPIP */
  2567. #endif /* VMS */
  2568.     { "",0,0 }
  2569. };
  2570. int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab));
  2571. #endif /* TCPSOCKET */
  2572. #endif /* NOTCPOPTS */
  2573. #endif /* NETCONN */
  2574.  
  2575. #ifdef OS2
  2576. /* K95 Manual Chapter Table -- Keep these two tables in sync! */
  2577.  
  2578. static char * linktbl[] = {        /* Internal links in k95.htm */
  2579.     "#top",                /* 00 */
  2580.     "#what",                /* 01 */
  2581.     "#install",                /* 02 */
  2582.     "#start",                /* 03 */
  2583.     "#dialer",                /* 04 */
  2584.     "#entries",                /* 05 */
  2585.     "#command",                /* 06 */
  2586.     "#terminal",            /* 07 */
  2587.     "#transfer",            /* 08 */
  2588.     "#hostmode"                /* 09 */
  2589. };
  2590.  
  2591. static struct keytab chaptbl[] = {
  2592.     { "Command-Screen",     6, 0 },
  2593.     { "Contents",           0, 0 },
  2594.     { "Dialer-Entries",     5, 0 },
  2595.     { "File-Transfer",      8, 0 },
  2596.     { "Getting-Started",    3, 0 },
  2597.     { "Host-Mode",          9, 0 },
  2598.     { "Installation",       2, 0 },
  2599.     { "Terminal-Emulation", 7, 0 },
  2600.     { "Using-The-Dialer",   4, 0 },
  2601.     { "What-Is-K95",        1, 0 },
  2602.     { "",                   0, 0 }
  2603. };
  2604. static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1);
  2605. #endif /* OS2 */
  2606.  
  2607. #ifndef NOXFER
  2608. /* Remote Command Table */
  2609.  
  2610. struct keytab remcmd[] = {
  2611. #ifndef NOSPL
  2612.     { "as",        XZASG, CM_INV|CM_ABR },
  2613.     { "asg",       XZASG, CM_INV },
  2614.     { "assign",    XZASG, 0 },
  2615. #endif /* NOSPL */
  2616.     { "cd",        XZCWD, 0 },
  2617.     { "cdup",      XZCDU, CM_INV },
  2618.     { "copy",      XZCPY, 0 },
  2619.     { "cwd",       XZCWD, CM_INV },
  2620.     { "delete",    XZDEL, 0 },
  2621.     { "directory", XZDIR, 0 },
  2622.     { "e",         XZXIT, CM_ABR|CM_INV },
  2623.     { "erase",     XZDEL, CM_INV },
  2624.     { "exit",      XZXIT, 0 },
  2625.     { "help",      XZHLP, 0 },
  2626. #ifndef NOPUSH
  2627.     { "host",      XZHOS, 0 },
  2628. #endif /* NOPUSH */
  2629. #ifndef NOFRILLS
  2630.     { "kermit",    XZKER, 0 },
  2631.     { "l",         XZLGI, CM_ABR|CM_INV },
  2632.     { "lo",        XZLGI, CM_ABR|CM_INV },
  2633.     { "log",       XZLGI, CM_ABR|CM_INV },
  2634.     { "login",     XZLGI, 0 },
  2635.     { "logout",    XZLGO, 0 },
  2636.     { "message",   XZMSG, 0 },
  2637.     { "mkdir",     XZMKD, 0 },
  2638.     { "print",     XZPRI, 0 },
  2639. #endif /* NOFRILLS */
  2640.     { "pwd",       XZPWD, 0 },
  2641. #ifndef NOSPL
  2642.     { "query",       XZQUE, 0 },
  2643. #endif /* NOSPL */
  2644.     { "rename",    XZREN, 0 },
  2645.     { "rmdir",     XZRMD, 0 },
  2646.     { "set",       XZSET, 0 },
  2647.     { "space",       XZSPA, 0 },
  2648. #ifndef NOFRILLS
  2649.     { "type",      XZTYP, 0 },
  2650.     { "who",       XZWHO, 0 },
  2651. #endif /* NOFRILLS */
  2652.     { "", 0, 0}
  2653. };
  2654. int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1;
  2655. #endif /* NOXFER */
  2656.  
  2657. struct keytab logtab[] = {
  2658. #ifdef CKLOGDIAL
  2659.     { "connections",  LOGM, CM_INV },
  2660.     { "cx",           LOGM, 0 },
  2661. #endif /* CKLOGDIAL */
  2662. #ifdef DEBUG
  2663.     { "debugging",    LOGD, 0 },
  2664. #endif /* DEBUG */
  2665.     { "packets",      LOGP, 0 },
  2666. #ifndef NOLOCAL
  2667.     { "session",      LOGS, 0 },
  2668. #endif /* NOLOCAL */
  2669. #ifdef TLOG
  2670.     { "transactions", LOGT, 0 },
  2671. #endif /* TLOG */
  2672.     { "", 0, 0 }
  2673. };
  2674. int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1;
  2675.  
  2676. struct keytab writab[] = {
  2677. #ifndef NOSPL
  2678.     { "append-file",     LOGW, CM_INV },
  2679. #endif /* NOSPL */
  2680.     { "debug-log",       LOGD, 0 },
  2681.     { "error",           LOGE, 0 },
  2682. #ifndef NOSPL
  2683.     { "file",            LOGW, 0 },
  2684. #endif /* NOSPL */
  2685.     { "packet-log",      LOGP, 0 },
  2686.     { "screen",          LOGX, 0 },
  2687. #ifndef NOLOCAL
  2688.     { "session-log",     LOGS, 0 },
  2689. #endif /* NOLOCAL */
  2690.     { "sys$output",      LOGX, CM_INV },
  2691.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2692.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2693.     { "tra",             LOGT, CM_ABR|CM_INV },
  2694.     { "tran",            LOGT, CM_ABR|CM_INV },
  2695.     { "trans",           LOGT, CM_ABR|CM_INV },
  2696.     { "transa",          LOGT, CM_ABR|CM_INV },
  2697.     { "transac",         LOGT, CM_ABR|CM_INV },
  2698.     { "transact",        LOGT, CM_ABR|CM_INV },
  2699.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2700.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2701.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2702.     { "transaction-log", LOGT, 0 },
  2703.     { "transactions",    LOGT, CM_INV }
  2704. };
  2705. int nwri = (sizeof(writab) / sizeof(struct keytab));
  2706.  
  2707. #ifdef COMMENT                /* INPUT switches not used yet... */
  2708. static struct keytab inswtab[] = {
  2709. #ifdef COMMENT
  2710.     { "/assign",       IN_ASG, CM_ARG },
  2711. #endif /* COMMENT */
  2712.     { "/autodownload", IN_ADL, CM_ARG },
  2713.     { "/case",         IN_CAS, CM_ARG },
  2714.     { "/echo",         IN_ECH, CM_ARG },
  2715.     { "/interrupts",   IN_NOI, CM_ARG },
  2716.     { "/silence",      IN_SIL, CM_ARG },
  2717. #ifdef COMMENT
  2718.     { "/pattern",      IN_PAT, CM_ARG },
  2719. #endif /* COMMENT */
  2720.     { "", 0, 0 }
  2721. };
  2722. static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1;
  2723. #endif /* COMMENT */
  2724.  
  2725. static struct keytab clrtab[] = {    /* Keywords for CLEAR command */
  2726. #ifndef NOSPL
  2727.     { "alarm",            CLR_ALR,         0 },
  2728. #ifdef CK_APC
  2729.     { "apc",              CLR_APC,         0 },
  2730. #endif /* CK_APC */
  2731. #ifdef PATTERNS
  2732.     { "binary-patterns",  CLR_BIN,         0 },
  2733. #endif /* PATTERNS */
  2734.     { "both",             CLR_DEV|CLR_INP, CM_INV },
  2735. #endif /* NOSPL */
  2736. #ifdef OS2
  2737.     { "command-screen",   CLR_CMD,         0 },
  2738. #endif /* OS2 */
  2739. #ifndef NOSPL
  2740.     { "device",           CLR_DEV,         CM_INV|CM_ABR },
  2741.     { "device-and-input", CLR_DEV|CLR_INP, 0 },
  2742. #endif /* NOSPL */
  2743.     { "device-buffer",    CLR_DEV,         0 },
  2744. #ifndef NODIAL
  2745.     { "dial-status",      CLR_DIA,     0 },
  2746. #endif /* NODIAL */
  2747. #ifndef NOSPL
  2748.     { "input-buffer",     CLR_INP,         0 },
  2749. #endif /* NOSPL */
  2750.     { "keyboard-buffer",  CLR_KBD,         0 },
  2751.     { "send-list",        CLR_SFL,         0 },
  2752. #ifdef OS2
  2753.     { "scr",              CLR_SCL,         CM_INV|CM_ABR },
  2754. #endif /* OS2 */
  2755.     { "screen",           CLR_SCR,         0 },
  2756. #ifdef OS2
  2757.     { "scrollback",       CLR_SCL,         CM_INV },
  2758.     { "terminal-screen",  CLR_TRM,         0 },
  2759. #endif /* OS2 */
  2760. #ifdef PATTERNS
  2761.     { "text-patterns",    CLR_TXT,         0 },
  2762. #endif /* PATTERNS */
  2763.     { "", 0, 0 }
  2764. };
  2765. int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1;
  2766.  
  2767. struct keytab clstab[] = {        /* Keywords for CLOSE command */
  2768. #ifndef NOSPL
  2769.     { "!read",           LOGR, CM_INV },
  2770.     { "!write",          LOGW, CM_INV },
  2771. #ifndef NOPUSH
  2772. #endif /* NOPUSH */
  2773. #endif /* NOSPL */
  2774. #ifndef NOSPL
  2775.     { "append-file",     LOGW, CM_INV },
  2776. #endif /* NOSPL */
  2777. #ifndef NOLOCAL
  2778.     { "connection",      9999, 0 },
  2779. #endif /* NOLOCAL */
  2780. #ifdef CKLOGDIAL
  2781.     { "cx-log",          LOGM, 0 },
  2782. #endif /* CKLOGDIAL */
  2783. #ifdef DEBUG
  2784.     { "debug-log",       LOGD, 0 },
  2785. #endif /* DEBUG */
  2786.     { "host",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2787.     { "line",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2788.     { "p",               LOGP, CM_INV|CM_ABR },
  2789.     { "packet-log",      LOGP, 0 },
  2790.     { "port",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2791. #ifndef NOSPL
  2792.     { "read-file",       LOGR, 0 },
  2793. #endif /* NOSPL */
  2794. #ifndef NOLOCAL
  2795.     { "session-log",     LOGS, 0 },
  2796. #endif /* NOLOCAL */
  2797. #ifdef TLOG
  2798.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2799.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2800.     { "tra",             LOGT, CM_ABR|CM_INV },
  2801.     { "tran",            LOGT, CM_ABR|CM_INV },
  2802.     { "trans",           LOGT, CM_ABR|CM_INV },
  2803.     { "transa",          LOGT, CM_ABR|CM_INV },
  2804.     { "transac",         LOGT, CM_ABR|CM_INV },
  2805.     { "transact",        LOGT, CM_ABR|CM_INV },
  2806.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2807.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2808.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2809.     { "transaction-log", LOGT, 0 },
  2810.     { "transactions",    LOGT, CM_INV },
  2811. #endif /* TLOG */
  2812. #ifndef NOSPL
  2813.     { "write-file",      LOGW, 0 },
  2814. #endif /* NOSPL */
  2815.     { "", 0, 0 }
  2816. };
  2817. int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1;
  2818.  
  2819. /* SHOW command arguments */
  2820.  
  2821. #ifndef NOSHOW
  2822. struct keytab shotab[] = {
  2823. #ifndef NOSPL
  2824.     { "alarm",        SHALRM, 0 },
  2825.     { "arg",          SHARG, CM_INV|CM_ABR },
  2826.     { "arguments",    SHARG, 0 },
  2827.     { "args",         SHARG, CM_INV },
  2828.     { "arrays",       SHARR, 0 },
  2829. #endif /* NOSPL */
  2830.  
  2831. #ifndef NOCSETS
  2832.     { "associations", SHASSOC, 0 },
  2833. #endif /* NOCSETS */
  2834.  
  2835. #ifndef NOXFER
  2836.     { "attributes",   SHATT, 0 },
  2837. #endif /* NOXFER */
  2838.  
  2839. #ifdef CK_AUTHENTICATION
  2840.     { "authentication", SHOAUTH, CM_INV },
  2841. #endif /* CK_AUTHENTICATION */
  2842.  
  2843. #ifndef NOPUSH
  2844. #ifdef BROWSER
  2845.     { "browser",      SHBROWSE, CM_PSH|CM_LOC },
  2846. #endif /*  BROWSER */
  2847. #endif /* NOPUSH */
  2848.     { "cd",           SHCD, 0 },
  2849.     { "character-sets", SHCSE, 0 },
  2850.     { "cmd",          SHCMD, CM_INV },
  2851. #ifndef NOLOCAL
  2852.     { "com",          SHCOM, CM_INV|CM_ABR },
  2853.     { "comm",         SHCOM, CM_INV|CM_ABR },
  2854.     { "communications", SHCOM, 0 },
  2855. #endif /* NOLOCAL */
  2856.     { "command",      SHCMD, 0 },
  2857.     { "connection",   SHCONNX, 0 },
  2858. #ifdef CK_SPEED
  2859.     { "control-prefixing", SHCTL, 0 },
  2860. #endif /* CK_SPEED */
  2861. #ifdef CKLOGDIAL
  2862.     { "cx",           SHCONNX, CM_INV },
  2863. #endif /* CKLOGDIAL */
  2864. #ifndef NOSPL
  2865.     { "count",        SHCOU, 0 },
  2866. #endif /* NOSPL */
  2867.     { "d",            SHDIA, CM_INV|CM_ABR },
  2868. #ifdef VMS
  2869.     { "default",      SHDFLT, 0 },
  2870. #else
  2871.     { "default",      SHDFLT, CM_INV },
  2872. #endif /* VMS */
  2873. #ifndef NODIAL
  2874.     { "dial",         SHDIA, CM_LOC },
  2875. #endif /* NODIAL */
  2876.     { "double/ignore",SHDBL, 0 },
  2877. #ifndef NOPUSH
  2878. #ifndef NOFRILLS
  2879.     { "editor",       SHEDIT, CM_PSH },
  2880. #endif /*  NOFRILLS */
  2881. #endif /* NOPUSH */
  2882. #ifndef NOLOCAL
  2883.     { "escape",       SHESC, CM_LOC },
  2884. #endif /* NOLOCAL */
  2885.     { "exit",         SHEXI, 0 },
  2886.     { "extended-options", SHXOPT, CM_INV },
  2887.     { "features",     SHFEA, 0 },
  2888.     { "file",         SHFIL, 0 },
  2889. #ifndef NOLOCAL
  2890.     { "flow-control", SHOFLO, 0 },
  2891. #endif /* NOLOCAL */
  2892. #ifdef BROWSER
  2893.     { "ftp",          SHOFTP, CM_PSH|CM_LOC },
  2894. #else
  2895. #ifndef NOFTP
  2896. #ifndef SYSFTP
  2897. #ifdef TCPSOCKET
  2898.     { "ftp",          SHOFTP, 0 },    /* (built-in ftp) */
  2899. #endif /* TCPSOCKET */
  2900. #endif /* SYSFTP */
  2901. #endif /* NOFTP */
  2902. #endif /* BROWSER */
  2903. #ifndef NOSPL
  2904.     { "functions",    SHFUN, 0 },
  2905.     { "globals",      SHVAR, 0 },
  2906. #endif /* NOSPL */
  2907. #ifdef KUI
  2908.     { "gui",          SHOGUI, 0 },
  2909. #endif /* KUI */
  2910. #ifdef CK_RECALL
  2911.     { "history",      SHHISTORY, 0 },
  2912. #endif /* CK_RECALL */
  2913.     { "ignore/double",SHDBL, CM_INV },
  2914.     { "iksd",         SHOIKS, CM_INV },
  2915. #ifndef NOSPL
  2916.     { "input",        SHINP, 0 },
  2917. #endif /* NOSPL */
  2918. #ifndef NOSETKEY
  2919.     { "k",            SHKEY, CM_INV|CM_ABR },
  2920.     { "key",          SHKEY, 0 },
  2921. #ifndef NOKVERBS
  2922.     { "kverbs",       SHKVB, 0 },
  2923. #endif /* NOKVERBS */
  2924. #endif /* NOSETKEY */
  2925. #ifdef CK_LABELED
  2926.     { "labeled-file-info", SHLBL, 0 },
  2927. #endif /* CK_LABELED */
  2928. #ifndef NOCSETS
  2929.     { "languages",    SHLNG, 0 },
  2930. #endif /* NOCSETS */
  2931.     { "logs",         SHLOG, 0 },
  2932. #ifndef NOSPL
  2933.     { "macros",       SHMAC, 0 },
  2934. #endif /* NOSPL */
  2935. #ifndef NODIAL
  2936.     { "modem",        SHMOD, CM_LOC },
  2937. #else
  2938.     { "modem-signals",SHCOM, CM_INV|CM_LOC },
  2939. #endif /* NODIAL */
  2940. #ifndef NOLOCAL
  2941. #ifdef OS2MOUSE
  2942.     { "mouse",        SHMOU, CM_LOC },
  2943. #endif /* OS2MOUSE */
  2944. #endif /* NOLOCAL */
  2945. #ifdef NETCONN
  2946.     { "network",      SHNET, CM_LOC },
  2947. #else
  2948.     { "network",      SHNET, CM_INV|CM_LOC },
  2949. #endif /* NETCONN */
  2950.     { "options",      SHOPTS, 0 },
  2951. #ifndef NOSPL
  2952.     { "output",       SHOUTP, CM_INV },
  2953. #endif /* NOSPL */
  2954. #ifdef ANYX25
  2955. #ifndef IBMX25
  2956.     { "pad",          SHPAD,  CM_LOC },
  2957. #endif /* IBMX25 */
  2958. #endif /* ANYX25 */
  2959.     { "parameters",   SHPAR,  CM_INV },
  2960. #ifdef PATTERNS
  2961.     { "patterns",     SHOPAT, 0 },
  2962. #endif /* PATTERNS */
  2963.     { "printer",      SHPRT,  0 },
  2964. #ifdef CK_SPEED
  2965.     { "prefixing",    SHCTL,  CM_INV },
  2966. #endif /* CK_SPEED */
  2967. #ifndef NOXFER
  2968.     { "protocol",     SHPRO,  0 },
  2969. #endif /* NOXFER */
  2970. #ifndef NOSPL
  2971.     { "scripts",      SHSCR,  CM_LOC },
  2972. #endif /* NOSPL */
  2973.     { "send-list",    SHSFL,  0 },
  2974. #ifndef NOSERVER
  2975.     { "server",       SHSER,  0 },
  2976. #endif /* NOSERVER */
  2977. #ifndef NOSEXP
  2978.     { "sexpression",  SHSEXP, 0 },
  2979. #endif /* NOSEXP */
  2980. #ifdef ANYSSH
  2981.     { "ssh",          SHOSSH, 0 },
  2982. #endif /* ANYSSH */
  2983.     { "stack",        SHSTK,  0 },
  2984.     { "status",       SHSTA,  0 },
  2985. #ifdef STREAMING
  2986.     { "streaming",    SHOSTR, 0 },
  2987. #endif /* STREAMING */
  2988. #ifndef NOLOCAL
  2989. #ifdef OS2
  2990.     { "tabs",          SHTAB, CM_INV|CM_LOC },
  2991. #endif /* OS2 */
  2992. #ifdef CK_TAPI
  2993.     { "tapi",          SHTAPI, CM_LOC },
  2994.     { "tapi-comm",     SHTAPI_C, CM_INV|CM_LOC },
  2995.     { "tapi-location", SHTAPI_L, CM_INV|CM_LOC },
  2996.     { "tapi-modem",    SHTAPI_M, CM_INV|CM_LOC },
  2997. #endif /* CK_TAPI */
  2998.     { "tcp",           SHTCP,  CM_LOC },
  2999. #ifdef TNCODE
  3000.     { "tel",           SHTEL,  CM_INV|CM_ABR },
  3001.     { "telnet",        SHTEL,  0 },
  3002.     { "telopt",        SHTOPT, 0 },
  3003. #endif /* TNCODE */
  3004.     { "terminal",      SHTER,  CM_LOC },
  3005. #endif /* NOLOCAL */
  3006. #ifndef NOXMIT
  3007.     { "tr",            SHXMI, CM_INV|CM_ABR },
  3008.     { "tra",           SHXMI, CM_INV|CM_ABR },
  3009.     { "tran",          SHXMI, CM_INV|CM_ABR },
  3010.     { "trans",         SHXMI, CM_INV|CM_ABR },
  3011. #endif /* NOXMIT */
  3012. #ifndef NOXFER
  3013.     { "transfer",      SHOXFER, 0 },
  3014. #endif /* NOXFER */
  3015. #ifndef NOXMIT
  3016.     { "transmit",      SHXMI, 0 },
  3017. #endif /* NOXMIT */
  3018. #ifdef CK_TRIGGER
  3019.     { "trigger",       SHTRIG, CM_LOC },
  3020. #endif /* CK_TRIGGER */
  3021. #ifndef NOSETKEY
  3022. #ifndef NOKVERBS
  3023. #ifdef OS2
  3024.     { "udk",           SHUDK, CM_LOC },
  3025. #endif /* OS2 */
  3026. #endif /* NOKVERBS */
  3027. #endif /* NOSETKEY */
  3028. #ifndef NOSPL
  3029.     { "variables",     SHBUI, 0 },
  3030. #endif /* NOSPL */
  3031. #ifndef NOFRILLS
  3032.     { "versions",      SHVER, 0 },
  3033. #endif /* NOFRILLS */
  3034. #ifdef OS2
  3035.     { "vscrn",         SHVSCRN, CM_INV|CM_LOC },
  3036. #endif /* OS2 */
  3037.     { "xfer",          SHOXFER,  CM_INV },
  3038. #ifndef NOXMIT
  3039.     { "xmit",          SHXMI,    CM_INV },
  3040. #endif /* NOXMIT */
  3041.     { "", 0, 0 }
  3042. };
  3043. int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1;
  3044. #endif /* NOSHOW */
  3045.  
  3046. #ifdef ANYX25
  3047. #ifndef IBMX25
  3048. struct keytab padtab[] = {              /* PAD commands */
  3049.     { "clear",      XYPADL, 0 },
  3050.     { "interrupt",  XYPADI, 0 },
  3051.     { "reset",      XYPADR, 0 },
  3052.     { "status",     XYPADS, 0 }
  3053. };
  3054. int npadc = (sizeof(padtab) / sizeof(struct keytab));
  3055. #endif /* IBMX25 */
  3056. #endif /* ANYX25 */
  3057.  
  3058. #ifndef NOSERVER
  3059. static struct keytab kmstab[] = {
  3060.     { "both",    3, 0 },
  3061.     { "local",   1, 0 },
  3062.     { "remote",  2, 0 }
  3063. };
  3064.  
  3065. static struct keytab enatab[] = {    /* ENABLE commands */
  3066.     { "all",        EN_ALL,  0 },
  3067. #ifndef NOSPL
  3068.     { "as",         EN_ASG,  CM_INV|CM_ABR },
  3069.     { "asg",        EN_ASG,  CM_INV },
  3070.     { "assign",     EN_ASG,  0 },
  3071. #endif /* NOSPL */
  3072. #ifndef datageneral
  3073.     { "bye",        EN_BYE,  0 },
  3074. #endif /* datageneral */
  3075.     { "cd",         EN_CWD,  0 },
  3076. #ifdef ZCOPY
  3077.     { "copy",       EN_CPY,  0 },
  3078. #endif /* ZCOPY */
  3079.     { "cwd",        EN_CWD,  CM_INV },
  3080.     { "delete",     EN_DEL,  0 },
  3081.     { "directory",  EN_DIR,  0 },
  3082.     { "enable",     EN_ENA,  CM_INV },
  3083.     { "exit",       EN_XIT,  0 },
  3084.     { "finish",     EN_FIN,  0 },
  3085.     { "get",        EN_GET,  0 },
  3086.     { "host",       EN_HOS,  0 },
  3087.     { "mail",       EN_MAI,  0 },
  3088.     { "mkdir",      EN_MKD,  0 },
  3089.     { "print",      EN_PRI,  0 },
  3090. #ifndef NOSPL
  3091.     { "query",      EN_QUE,  0 },
  3092. #endif /* NOSPL */
  3093.     { "rename",     EN_REN,  0 },
  3094.     { "retrieve",   EN_RET,  CM_INV },
  3095.     { "rmdir",      EN_RMD,  0 },
  3096.     { "send",       EN_SEN,  0 },
  3097.     { "set",        EN_SET,  0 },
  3098.     { "space",      EN_SPA,  0 },
  3099.     { "type",       EN_TYP,  0 },
  3100.     { "who",        EN_WHO,  0 }
  3101. };
  3102. static int nena = (sizeof(enatab) / sizeof(struct keytab));
  3103. #endif /* NOSERVER */
  3104.  
  3105. struct keytab txtbin[] = {
  3106.     { "all",        2, 0 },
  3107.     { "binary",     1, 0 },
  3108.     { "text",       0, 0 }
  3109. };
  3110.  
  3111. #ifndef NOXFER
  3112. static struct keytab sndtab[] = {    /* SEND command options */
  3113.     { "/after",           SND_AFT, CM_ARG },
  3114. #ifndef NOSPL
  3115.     { "/array",           SND_ARR, CM_ARG },
  3116. #endif /* NOSPL */
  3117.     { "/as-name",         SND_ASN, CM_ARG },
  3118.     { "/b",               SND_BIN, CM_INV|CM_ABR },
  3119.     { "/before",          SND_BEF, CM_ARG },
  3120.     { "/binary",          SND_BIN, 0 },
  3121. #ifdef CALIBRATE
  3122.     { "/c",               SND_CMD, CM_INV|CM_ABR },
  3123.     { "/calibrate",       SND_CAL, CM_INV|CM_ARG },
  3124. #endif /* CALIBRATE */
  3125.     { "/command",         SND_CMD, CM_PSH },
  3126.     { "/delete",          SND_DEL, 0 },
  3127. #ifdef UNIXOROSK
  3128.     { "/dotfiles",        SND_DOT, 0 },
  3129. #endif /* UNIXOROSK */
  3130.     { "/except",          SND_EXC, CM_ARG },
  3131. #ifdef PIPESEND
  3132.     { "/filter",          SND_FLT, CM_ARG|CM_PSH },
  3133. #endif /* PIPESEND */
  3134.     { "/filenames",       SND_NAM, CM_ARG },
  3135. #ifdef CKSYMLINK
  3136.     { "/followlinks",      SND_LNK, 0 },
  3137. #endif /* CKSYMLINK */
  3138. #ifdef VMS
  3139.     { "/image",           SND_IMG, 0 },
  3140. #else
  3141.     { "/image",           SND_BIN, CM_INV },
  3142. #endif /* VMS */
  3143. #ifdef CK_LABELED
  3144.     { "/labeled",         SND_LBL, 0 },
  3145. #endif /* CK_LABELED */
  3146.     { "/larger-than",     SND_LAR, CM_ARG },
  3147.     { "/listfile",        SND_FIL, CM_ARG },
  3148. #ifndef NOFRILLS
  3149.     { "/mail",            SND_MAI, CM_ARG },
  3150. #endif /* NOFRILLS */
  3151. #ifdef CK_TMPDIR
  3152.     { "/move-to",         SND_MOV, CM_ARG },
  3153. #endif /* CK_TMPDIR */
  3154.     { "/nobackupfiles",   SND_NOB, 0 },
  3155. #ifdef UNIXOROSK
  3156.     { "/nodotfiles",      SND_NOD, 0 },
  3157. #endif /* UNIXOROSK */
  3158. #ifdef CKSYMLINK
  3159.     { "/nofollowlinks",      SND_NLK, 0 },
  3160. #endif /* CKSYMLINK */
  3161.     { "/not-after",       SND_NAF, CM_ARG },
  3162.     { "/not-before",      SND_NBE, CM_ARG },
  3163.     { "/pathnames",       SND_PTH, CM_ARG },
  3164.     { "/print",           SND_PRI, CM_ARG },
  3165. #ifdef CK_XYZ
  3166.     { "/protocol",        SND_PRO, CM_ARG },
  3167. #else
  3168.     { "/protocol",        SND_PRO, CM_ARG|CM_INV },
  3169. #endif /* CK_XYZ */
  3170.     { "/quiet",           SND_SHH, 0 },
  3171.     { "/recover",         SND_RES, 0 },
  3172. #ifdef RECURSIVE
  3173. /* Systems where we do recursion */
  3174.     { "/recursive",       SND_REC, 0 },
  3175. #else
  3176. #ifdef VMS
  3177. /* Systems that do recursion themselves without our assistance */
  3178. /* if we give them the right kind of wildcard */
  3179.     { "/recursive",       SND_REC, 0 },
  3180. #else
  3181. #ifdef datageneral
  3182.     { "/recursive",       SND_REC, 0 },
  3183. #else
  3184.     { "/recursive",       SND_REC, CM_INV },
  3185. #endif /* datageneral */
  3186. #endif /* VMS */
  3187. #endif /* RECURSIVE */
  3188.     { "/rename-to",       SND_REN, CM_ARG },
  3189.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3190.     { "/smaller-than",    SND_SMA, CM_ARG },
  3191.     { "/starting-at",     SND_STA, CM_ARG },
  3192. #ifndef NOFRILLS
  3193.     { "/su",              SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3194.     { "/sub",             SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3195.     { "/subject",         SND_ASN, CM_ARG },
  3196. #endif /* NOFRILLS */
  3197. #ifdef RECURSIVE
  3198.     { "/subdirectories",  SND_REC, CM_INV },
  3199. #endif /* RECURSIVE */
  3200.     { "/text",            SND_TXT, 0 },
  3201.     { "/transparent",     SND_XPA, 0 },
  3202.     { "/type",            SND_TYP, CM_ARG }
  3203. };
  3204. #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab)
  3205. static int nsndtab = NSNDTAB;
  3206.  
  3207. #ifndef NOMSEND
  3208. static struct keytab msndtab[] = {    /* MSEND options */
  3209.     { "/after",           SND_AFT, CM_ARG },
  3210.     { "/before",          SND_BEF, CM_ARG },
  3211.     { "/binary",          SND_BIN, 0 },
  3212.     { "/delete",          SND_DEL, 0 },
  3213.     { "/except",          SND_EXC, CM_ARG },
  3214.     { "/filenames",       SND_NAM, CM_ARG },
  3215. #ifdef CKSYMLINK
  3216.     { "/followlinks",      SND_LNK, 0 },
  3217. #endif /* CKSYMLINK */
  3218. #ifdef VMS
  3219.     { "/image",           SND_IMG, 0 },
  3220. #else
  3221.     { "/image",           SND_BIN, CM_INV },
  3222. #endif /* VMS */
  3223. #ifdef CK_LABELED
  3224.     { "/labeled",         SND_LBL, 0 },
  3225. #endif /* CK_LABELED */
  3226.     { "/larger-than",     SND_LAR, CM_ARG },
  3227.     { "/list",            SND_FIL, CM_ARG },
  3228. #ifndef NOFRILLS
  3229.     { "/mail",            SND_MAI, CM_ARG },
  3230. #endif /* NOFRILLS */
  3231. #ifdef CK_TMPDIR
  3232.     { "/move-to",         SND_MOV, CM_ARG },
  3233. #endif /* CK_TMPDIR */
  3234. #ifdef CKSYMLINK
  3235.     { "/nofollowlinks",    SND_NLK, 0 },
  3236. #endif /* CKSYMLINK */
  3237.     { "/not-after",       SND_NAF, CM_ARG },
  3238.     { "/not-before",      SND_NBE, CM_ARG },
  3239.     { "/pathnames",       SND_PTH, CM_ARG },
  3240.     { "/print",           SND_PRI, CM_ARG },
  3241. #ifdef CK_XYZ
  3242.     { "/protocol",        SND_PRO, CM_ARG },
  3243. #endif /* CK_XYZ */
  3244.     { "/quiet",           SND_SHH, 0 },
  3245.     { "/recover",         SND_RES, 0 },
  3246.     { "/rename-to",       SND_REN, CM_ARG },
  3247.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3248.     { "/smaller-than",    SND_SMA, CM_ARG },
  3249.     { "/starting-at",     SND_STA, CM_ARG },
  3250. #ifndef NOFRILLS
  3251.     { "/subject",         SND_ASN, CM_ARG },
  3252. #endif /* NOFRILLS */
  3253.     { "/text",            SND_TXT, 0 },
  3254.     { "/transparent",     SND_XPA, 0 },
  3255.     { "/type",            SND_TYP, CM_ARG }
  3256. };
  3257. #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab)
  3258. static int nmsndtab = NMSNDTAB;
  3259. #endif /* NOMSEND */
  3260. #endif /* NOXFER */
  3261.  
  3262. /* CONNECT command switches */
  3263.  
  3264. #define CONN_II  0    /* Idle interval */
  3265. #define CONN_IS  1    /* Idle string */
  3266. #define CONN_IL  2    /* Idle limit */
  3267. #define CONN_NV  3    /* Non-Verbose */
  3268. #define CONN_TL  4    /* Time limit */
  3269. #define CONN_TS  5    /* Trigger string */
  3270. #define CONN_AS  6    /* Asynchronous */
  3271. #define CONN_SY  7    /* Synchronous */
  3272. #define CONN_MAX 7    /* Number of CONNECT switches */
  3273.  
  3274. #ifndef NOLOCAL
  3275. static struct keytab conntab[] = {
  3276. #ifdef OS2
  3277.     { "/asynchronous",    CONN_AS, CM_INV },
  3278. #endif /* OS2 */
  3279. #ifdef XLIMITS
  3280.     { "/idle-interval",   CONN_II, CM_ARG },
  3281.     { "/idle-limit",      CONN_IL, CM_ARG },
  3282.     { "/idle-string",     CONN_IS, CM_ARG },
  3283.     { "/quietly",         CONN_NV, CM_INV },
  3284. #else
  3285.     { "/quietly",         CONN_NV, 0 },
  3286. #endif /* XLIMITS */
  3287. #ifdef OS2
  3288.     { "/synchronous",     CONN_SY, CM_INV },
  3289. #endif /* OS2 */
  3290. #ifdef XLIMITS
  3291.     { "/time-limit",      CONN_TL, CM_ARG },
  3292. #endif /* XLIMITS */
  3293. #ifdef CK_TRIGGER
  3294.     { "/trigger",         CONN_TS, CM_ARG },
  3295. #endif /* CK_TRIGGER */
  3296.     { "",0,0 }
  3297. };
  3298. #define NCONNTAB sizeof(conntab)/sizeof(struct keytab)
  3299. static int nconntab = NCONNTAB;
  3300. #endif /* NOLOCAL */
  3301.  
  3302. #ifndef NOXFER
  3303. static struct keytab stattab[] = {    /* STATISTICS command switches */
  3304.     { "/brief",   1, 0 },
  3305.     { "/verbose", 0, 0 }
  3306. };
  3307. #endif /* NOXFER */
  3308.  
  3309. #ifndef NOSPL
  3310. #ifdef COMMENT
  3311. struct mtab mactab[MAC_MAX] = {        /* Preinitialized macro table */
  3312.     { NULL, NULL, 0 }
  3313. };
  3314. #else
  3315. struct mtab *mactab;            /* Dynamically allocated macro table */
  3316. #endif /* COMMENT */
  3317. int nmac = 0;
  3318.  
  3319. struct keytab mackey[MAC_MAX];        /* Macro names as command keywords */
  3320. #endif /* NOSPL */
  3321.  
  3322. #ifndef NOSPL
  3323. #ifdef  OS2
  3324. struct keytab beeptab[] = {        /* Beep options */
  3325.     { "error", BP_FAIL, 0 },
  3326.     { "information", BP_NOTE, 0 },
  3327.     { "warning", BP_WARN, 0 }
  3328. };
  3329. int nbeeptab = sizeof(beeptab)/sizeof(struct keytab);
  3330.  
  3331. /* CLEAR COMMMAND-SCREEN options */
  3332.  
  3333. #define CLR_C_ALL 0
  3334. #define CLR_C_BOL 1
  3335. #define CLR_C_BOS 2
  3336. #define CLR_C_EOL 3
  3337. #define CLR_C_EOS 4
  3338. #define CLR_C_LIN 5
  3339. #define CLR_C_SCR 6
  3340.  
  3341. struct keytab clrcmdtab[] = {
  3342.     { "all",        CLR_C_ALL, 0 },
  3343.     { "bol",        CLR_C_BOL, 0 },
  3344.     { "bos",        CLR_C_BOS, 0 },
  3345.     { "eol",        CLR_C_EOL, 0 },
  3346.     { "eos",        CLR_C_EOS, 0 },
  3347.     { "line",       CLR_C_LIN, 0 },
  3348.     { "scrollback", CLR_C_SCR, 0 }
  3349. };
  3350. int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab);
  3351. #endif /* OS2 */
  3352. #endif /* NOSPL */
  3353.  
  3354. #ifdef COMMENT
  3355. /* Not used at present */
  3356. static struct keytab pagetab[] = {
  3357.     { "/more",   1, CM_INV },
  3358.     { "/nopage", 0, 0 },
  3359.     { "/page",   1, 0 }
  3360. };
  3361. int npagetab = sizeof(pagetab)/sizeof(struct keytab);
  3362. #endif /* COMMENT */
  3363.  
  3364. #define TYP_NOP  0            /* /NOPAGE */
  3365. #define TYP_PAG  1            /* /PAGE */
  3366. #define TYP_HEA  2            /* /HEAD:n */
  3367. #define TYP_TAI  3            /* /TAIL:n */
  3368. #define TYP_PAT  4            /* /MATCH:pattern */
  3369. #define TYP_WID  5            /* /WIDTH:cols */
  3370. #define TYP_COU  6            /* /COUNT */
  3371. #define TYP_OUT  7            /* /OUTPUT:file */
  3372. #define TYP_PFX  8            /* /PREFIX:string */
  3373. #ifdef UNICODE
  3374. #define TYP_XIN  9            /* /TRANSLATE-FROM:charset */
  3375. #define TYP_XUT 10            /* /TRANSLATE-TO:charset */
  3376. #define TYP_XPA 11            /* /TRANSPARENT */
  3377. #endif /* UNICODE */
  3378. #ifdef KUI
  3379. #define TYP_GUI 12            /* /GUI:title */
  3380. #define TYP_HIG 13            /* /HEIGHT:rows */
  3381. #endif /* KUI */
  3382. #define TYP_NUM 14            /* /NUMBER */
  3383.  
  3384. static struct keytab typetab[] = {    /* TYPE command switches */
  3385.     { "/count",          TYP_COU, 0 },
  3386. #ifdef UNICODE
  3387.     { "/character-set",  TYP_XIN, CM_ARG },
  3388. #endif /* UNICODE */
  3389. #ifdef KUI
  3390.     { "/gui",            TYP_GUI, CM_ARG },
  3391. #endif /* KUI */
  3392.     { "/head",           TYP_HEA, CM_ARG },
  3393. #ifdef KUI
  3394.     { "/height",         TYP_HIG, CM_ARG },
  3395. #endif /* KUI */
  3396.     { "/match",          TYP_PAT, CM_ARG },
  3397. #ifdef CK_TTGWSIZ
  3398.     { "/more",           TYP_PAG, CM_INV },
  3399.     { "/nopage",         TYP_NOP, 0 },
  3400.     { "/number",         TYP_NUM, 0 },
  3401.     { "/output",         TYP_OUT, CM_ARG },
  3402.     { "/page",           TYP_PAG, 0 },
  3403. #endif /* CK_TTGWSIZ */
  3404.     { "/prefix",         TYP_PFX, CM_ARG },
  3405.     { "/tail",           TYP_TAI, CM_ARG },
  3406. #ifdef UNICODE
  3407.     { "/translate-to",   TYP_XUT, CM_ARG },
  3408.     { "/transparent",    TYP_XPA, 0 },
  3409. #endif /* UNICODE */
  3410.     { "/width",          TYP_WID, CM_ARG },
  3411. #ifdef UNICODE
  3412.     { "/xlate-to",       TYP_XUT, CM_INV|CM_ARG },
  3413. #endif /* UNICODE */
  3414.     { "", 0, 0 }
  3415. };
  3416. int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1;
  3417.  
  3418. int typ_page = -1;            /* TYPE /[NO]PAGE default */
  3419. int typ_wid  = -1;
  3420.  
  3421. #ifndef NOSPL
  3422. #define TRA_ALL 999            /* TRACE command */
  3423. #define TRA_ASG 0
  3424. #define TRA_CMD 1
  3425.  
  3426. int tra_asg = 0;
  3427. int tra_cmd = 0;
  3428.  
  3429. static struct keytab tracetab[] = {    /* TRACE options */
  3430.     { "all",            TRA_ALL, 0 },
  3431.     { "assignments",    TRA_ASG, 0 },
  3432.     { "command-level",  TRA_CMD, 0 }
  3433. };
  3434. static int ntracetab = sizeof(tracetab)/sizeof(struct keytab);
  3435. #endif /* NOSPL */
  3436.  
  3437. #ifndef NOSHOW
  3438. VOID
  3439. showtypopts() {
  3440.     printf(" TYPE ");
  3441.     if (typ_page > -1) {
  3442.     prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE");
  3443.     } else
  3444.       prtopt(&optlines,"(no options set)");
  3445.     if (typ_wid > -1) {
  3446.     ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL);
  3447.     prtopt(&optlines,tmpbuf);
  3448.     }
  3449.     prtopt(&optlines,"");
  3450. }
  3451. #endif /* NOSHOW */
  3452.  
  3453. #ifdef LOCUS
  3454. /* isauto == 1 if locus is being switched automatically */
  3455.  
  3456. VOID
  3457. setlocus(x, isauto) int x, isauto; {
  3458.     extern int quitting;
  3459.     if (x) x = 1;
  3460.     if (x && locus) return;
  3461.     if (!x && !locus) return;
  3462.     /* Get here if it actually needs to be changed */
  3463. #ifdef OS2
  3464.     if (isauto &&            /* Automatically switching */
  3465.     !quitting &&            /* not exiting */
  3466.     autolocus == 2) {        /* and AUTOLOCUS is set to ASK */
  3467.     char locmsg[300];
  3468.     ckmakmsg(locmsg,300,
  3469.          "Switching Locus to ",
  3470.          x ? "LOCAL" : "REMOTE",
  3471.          " for file management commands\n"
  3472.                  "such as CD, DIRECTORY, DELETE, RENAME.  Type HELP SET\n"
  3473.                  "LOCUS at the K-95> prompt for further info.  Use the\n"
  3474. #ifdef KUI
  3475.                   "Actions menu or SET LOCUS command to disable automatic\n"
  3476.                   "Locus switching or to disable these queries.",
  3477. #else /* KUI */
  3478.                   "SET LOCUS command to disable automatic locus switching\n"
  3479.                   "or to disable these queries.",
  3480. #endif /* KUI */
  3481.                   NULL);
  3482.     if (uq_ok(locmsg,"OK to switch Locus?",3,NULL,1)) {
  3483.         locus = x;
  3484. #ifdef KUI
  3485.         KuiSetProperty(KUI_LOCUS,x,0);
  3486. #endif /* KUI */
  3487.         return;
  3488.     }
  3489.     } else {
  3490. #endif /* OS2 */
  3491.         if (isauto && msgflg && !quitting)
  3492.           printf("Switching LOCUS for file-management commands to %s.\n",
  3493.          x ? "LOCAL" : "REMOTE"
  3494.          );
  3495.     locus = x;
  3496. #ifdef OS2
  3497. #ifdef KUI
  3498.     KuiSetProperty(KUI_LOCUS,x,0);
  3499. #endif /* KUI */
  3500.     }
  3501. #endif /* OS2 */
  3502. }
  3503.  
  3504. VOID
  3505. setautolocus(x) int x; {
  3506.     autolocus = x;
  3507. #ifdef KUI
  3508.     KuiSetProperty(KUI_AUTO_LOCUS,x,0);
  3509. #endif /* KUI */
  3510. }
  3511. #endif /* LOCUS */
  3512.  
  3513. int
  3514. settypopts() {                /* Set TYPE option defaults */
  3515.     int xp = -1;
  3516.     int c, getval;
  3517.     while (1) {
  3518.     if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) {
  3519.         if (y == -3)
  3520.           break;
  3521.         else
  3522.           return(y);
  3523.     }
  3524.     c = cmgbrk();
  3525.     if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  3526.         printf("?This switch does not take an argument\n");
  3527.         return(-9);
  3528.     }
  3529.     switch (y) {
  3530.       case TYP_NOP: xp = 0; break;
  3531.       case TYP_PAG: xp = 1; break;
  3532.       case TYP_WID:
  3533.         if (getval)
  3534.           if ((x = cmnum("Column at which to truncate",
  3535.                  ckitoa(cmd_cols),10,&y,xxstring)) < 0)
  3536.         return(x);
  3537.         typ_wid = y;
  3538.         break;
  3539.  
  3540.           default:
  3541.         printf("?Sorry, this option can not be set\n");
  3542.         return(-9);
  3543.     }
  3544.     }
  3545.     if ((x = cmcfm()) < 0)        /* Get confirmation */
  3546.       return(x);
  3547.     if (xp > -1) typ_page = xp;        /* Confirmed, save defaults */
  3548.     return(success = 1);
  3549. }
  3550.  
  3551. /* Forward declarations of functions local to this module */
  3552.  
  3553. #ifdef UNIX
  3554. _PROTOTYP (int douchmod, ( void ) );
  3555. #endif /* UNIX */
  3556. #ifdef CKPURGE
  3557. _PROTOTYP (int dopurge,  ( void ) );
  3558. #endif /* CKPURGE */
  3559. #ifndef NOSPL
  3560. _PROTOTYP (int doundef,  ( int  ) );
  3561. _PROTOTYP (int doask,    ( int  ) );
  3562. _PROTOTYP (int dodef,    ( int  ) );
  3563. _PROTOTYP (int doelse,   ( void ) );
  3564. _PROTOTYP (int dofor,    ( void ) );
  3565. #endif /* NOSPL  */
  3566. #ifndef NODIAL
  3567. _PROTOTYP (int dodial,   ( int  ) );
  3568. #endif /* NODIAL */
  3569. _PROTOTYP (int dodel,    ( void ) );
  3570. _PROTOTYP (int dopaus,   ( int  ) );
  3571. #ifndef NOPUSH
  3572. #ifdef TCPSOCKET
  3573. _PROTOTYP (int doping,   ( void ) );
  3574. _PROTOTYP (int doftp,    ( void ) );
  3575. #endif /* TCPSOCKET */
  3576. #endif /* NOPUSH */
  3577. #ifndef NORENAME
  3578. #ifndef NOFRILLS
  3579. _PROTOTYP (int dorenam,  ( void ) );
  3580. #endif /* NOFRILLS */
  3581. #endif /* NORENAME */
  3582. #ifdef ZCOPY
  3583. _PROTOTYP (int docopy,   ( void ) );
  3584. #endif /* ZCOPY */
  3585. #ifdef NT
  3586. _PROTOTYP (int dolink,   ( void ));
  3587. #endif /* NT */
  3588. #ifdef CK_REXX
  3589. _PROTOTYP (int dorexx,   ( void ) );
  3590. #endif /* CK_REXX */
  3591.  
  3592. #ifdef TNCODE
  3593. static struct keytab telcmd[] = {
  3594.     { "abort", TN_ABORT, CM_INV },    /* Emotionally toned - don't show */
  3595.     { "ao",    TN_AO,    0 },
  3596.     { "ayt",   TN_AYT,   0 },
  3597.     { "break", BREAK,    0 },
  3598.     { "cancel",TN_ABORT, 0 },
  3599.     { "dmark", TN_DM,    0 },
  3600.     { "do",    DO,       0 },
  3601.     { "dont",  DONT,     0 },
  3602.     { "ec",    TN_EC,    0 },
  3603.     { "el",    TN_EL,    0 },
  3604.     { "eof",   TN_EOF,   0 },
  3605.     { "eor",   TN_EOR,   0 },
  3606. #ifdef CK_KERBEROS
  3607. #ifdef KRB5
  3608. #define TN_FWD 1
  3609.     { "forward", TN_FWD, CM_INV },
  3610. #endif /* KRB5 */
  3611. #endif /* CK_KERBEROS */
  3612.     { "ga",    TN_GA,    0 },
  3613.     { "ip",    TN_IP,    0 },
  3614.     { "nop",   TN_NOP,   0 },
  3615.     { "sak",   TN_SAK,   CM_INV },
  3616.     { "sb",    SB,       0 },
  3617.     { "se",    SE,       0 },
  3618.     { "susp",  TN_SUSP,  0 },
  3619.     { "will",  WILL,     0 },
  3620.     { "wont",  WONT,     0 }
  3621. };
  3622. static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab));
  3623.  
  3624. static struct keytab tnopts[] = {
  3625. #ifdef CK_AUTHENTICATION
  3626.     { "auth",   TELOPT_AUTHENTICATION,   0 },
  3627. #else
  3628.     { "auth",   TELOPT_AUTHENTICATION,   CM_INV },
  3629. #endif /* CK_AUTHENTICATION */
  3630.     { "binary", TELOPT_BINARY, 0 },
  3631. #ifdef TN_COMPORT
  3632.     { "c",      TELOPT_COMPORT, CM_INV|CM_ABR},
  3633.     { "co",     TELOPT_COMPORT, CM_INV|CM_ABR},
  3634.     { "com",    TELOPT_COMPORT, CM_INV|CM_ABR},
  3635.     { "com-port-control", TELOPT_COMPORT, 0 },
  3636.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3637. #else  /* TN_COMPORT */
  3638.     { "com-port-control", TELOPT_COMPORT, CM_INV },
  3639.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3640. #endif /* TN_COMPORT */
  3641.     { "echo", TELOPT_ECHO, 0 },
  3642. #ifdef CK_ENCRYPTION
  3643.     { "encrypt", TELOPT_ENCRYPTION, 0 },
  3644. #else
  3645.     { "encrypt", TELOPT_ENCRYPTION, CM_INV },
  3646. #endif /* CK_ENCRYPTION */
  3647. #ifdef CK_FORWARD_X
  3648.     { "forward-x", TELOPT_FORWARD_X, 0 },
  3649. #else
  3650.     { "forward-x", TELOPT_FORWARD_X, CM_INV },
  3651. #endif /* CK_FORWARD_X */
  3652. #ifdef IKS_OPTION
  3653.     { "kermit", TELOPT_KERMIT, 0 },
  3654. #else
  3655.     { "kermit", TELOPT_KERMIT, CM_INV },
  3656. #endif /* IKS_OPTION */
  3657.     { "lflow",  TELOPT_LFLOW, CM_INV },
  3658.     { "logout", TELOPT_LOGOUT, CM_INV },
  3659. #ifdef CK_NAWS
  3660.     { "naws", TELOPT_NAWS, 0 },
  3661. #else
  3662.     { "naws", TELOPT_NAWS, CM_INV },
  3663. #endif /* CK_NAWS */
  3664. #ifdef CK_ENVIRONMENT
  3665.     { "new-environment", TELOPT_NEWENVIRON,  0 },
  3666. #else
  3667.     { "new-environment", TELOPT_NEWENVIRON,  CM_INV },
  3668. #endif /* CK_ENVIRONMENT */
  3669.     { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT,  CM_INV },
  3670.     { "pragma-logon",    TELOPT_PRAGMA_LOGON,  CM_INV },
  3671.     { "pragma-sspi",     TELOPT_SSPI_LOGON,  CM_INV },
  3672.     { "sak",   TELOPT_IBM_SAK, CM_INV },
  3673. #ifdef CK_SNDLOC
  3674.     { "send-location",   TELOPT_SNDLOC,  0 },
  3675. #else
  3676.     { "send-location",   TELOPT_SNDLOC,  CM_INV },
  3677. #endif /* CK_SNDLOC */
  3678.     { "sga", TELOPT_SGA, 0 },
  3679. #ifdef CK_SSL
  3680.     { "start-tls",       TELOPT_START_TLS,  0 },
  3681. #else
  3682.     { "start-tls",       TELOPT_START_TLS,  CM_INV },
  3683. #endif /* CK_SSL */
  3684.     { "ttype", TELOPT_TTYPE, 0 },
  3685. #ifdef CK_ENVIRONMENT
  3686.     { "xdisplay-location", TELOPT_XDISPLOC, 0 },
  3687. #else
  3688.     { "xdisplay-location", TELOPT_XDISPLOC, CM_INV },
  3689. #endif /* CK_ENVIRONMENT */
  3690.     { "", 0, 0 }
  3691. };
  3692. static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1;
  3693.  
  3694. static struct keytab tnsbopts[] = {
  3695. #ifdef CK_NAWS
  3696.     { "naws", TELOPT_NAWS, 0 },
  3697. #endif /* CK_NAWS */
  3698.     { "", 0, 0 }
  3699. };
  3700. static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1;
  3701. #endif /* TNCODE */
  3702.  
  3703. #ifdef TCPSOCKET
  3704. #ifndef NOPUSH
  3705. #ifdef SYSFTP
  3706. int
  3707. doftp() {                /* (External) FTP command */
  3708.     char *p, *f;            /* (See doxftp() for internal one) */
  3709.     int x;
  3710.  
  3711.     if (network)            /* If we have a current connection */
  3712.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3713.     else *line = '\0';            /* as default host */
  3714.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3715.       if (*p == ':') { *p = '\0'; break; }
  3716.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3717.       return(x);
  3718.     if (nopush) {
  3719.         printf("?Sorry, FTP command disabled\n");
  3720.         return(success = 0);
  3721.     }
  3722. /* Construct FTP command */
  3723. #ifdef VMS
  3724. #ifdef MULTINET                /* TGV MultiNet */
  3725.     ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL);
  3726. #else
  3727.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3728. #endif /* MULTINET */
  3729. #else                    /* Not VMS */
  3730. #ifdef OS2ORUNIX
  3731. #ifndef NOFTP
  3732.     f = ftpapp;
  3733.     if (!f) f = "";
  3734.     if (!f[0]) f = "ftp";
  3735.     ckmakmsg(line,LINBUFSIZ,f," ",s,NULL);
  3736. #ifdef OS2
  3737.     p = line + strlen(ftpapp);
  3738.     while (p != line) {
  3739.         if (*p == '/') *p = '\\';
  3740.         p--;
  3741.     }
  3742. #endif /* OS2 */
  3743. #else /* NOFTP */
  3744.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3745. #endif /* NOFTP */
  3746. #else /* OS2ORUNIX */
  3747.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3748. #endif /* OS2ORUNIX */
  3749. #endif /* VMS */
  3750.     conres();                /* Make console normal  */
  3751. #ifdef DEC_TCPIP
  3752.     printf("\n");            /* Prevent prompt-stomping */
  3753. #endif /* DEC_TCPIP */
  3754.     x = zshcmd(line);
  3755.     concb((char)escape);
  3756.     return(success = x);
  3757. }
  3758. #endif /* SYSFTP */
  3759.  
  3760. int
  3761. doping() {                /* PING command */
  3762.     char *p;                /* just runs ping program */
  3763.     int x;
  3764.  
  3765.     if (network)            /* If we have a current connection */
  3766.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3767.     else *line = '\0';            /* as default host to be pinged. */
  3768.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3769.       if (*p == ':') { *p = '\0'; break; }
  3770.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3771.       return(x);
  3772.     if (nopush) {
  3773.         printf("?Sorry, PING command disabled\n");
  3774.         return(success = 0);
  3775.     }
  3776.  
  3777.     /* Construct PING command */
  3778. #ifdef VMS
  3779. #ifdef MULTINET                /* TGV MultiNet */
  3780.     ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL);
  3781. #else
  3782.     ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */
  3783. #endif /* MULTINET */
  3784. #else                    /* Not VMS */
  3785.     ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL);
  3786. #endif /* VMS */
  3787.     conres();                /* Make console normal  */
  3788. #ifdef DEC_TCPIP
  3789.     printf("\n");            /* Prevent prompt-stomping */
  3790. #endif /* DEC_TCPIP */
  3791.     x = zshcmd(line);
  3792.     concb((char)escape);
  3793.     return(success = x);
  3794. }
  3795. #endif /* NOPUSH */
  3796. #endif /* TCPSOCKET */
  3797.  
  3798. static VOID
  3799. doend(x) int x; {
  3800. #ifndef NOSPL
  3801.     /* Pop from all FOR/WHILE/XIF/SWITCH's */
  3802.     debug(F101,"doend maclvl 1","",maclvl);
  3803.     while ((maclvl > 0) &&
  3804.        (m_arg[maclvl-1][0]) &&
  3805.        (cmdstk[cmdlvl].src == CMD_MD) &&
  3806.        (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  3807.         !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  3808.         !strncmp(m_arg[maclvl-1][0],"_whi",4) ||
  3809.         !strncmp(m_arg[maclvl-1][0],"_swi",4))) {
  3810.     debug(F110,"END popping",m_arg[maclvl-1][0],0);
  3811.     dogta(XXPTA);            /* Put args back */
  3812.     popclvl();            /* Pop up two levels */
  3813.     popclvl();
  3814.     debug(F101,"doend maclvl 2","",maclvl);
  3815.     }
  3816.     if (maclvl > -1) {
  3817.     if (mrval[maclvl])        /* Free previous retval if any */
  3818.       free(mrval[maclvl]);
  3819.     mrval[maclvl] = malloc(16);    /* Room for up to 15 digits */
  3820.     if (mrval[maclvl])        /* Record current retval */
  3821.       ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL);
  3822.     }
  3823. #endif /* NOSPL */
  3824.     popclvl();                /* Now pop out of macro or TAKE file */
  3825. #ifndef NOSPL
  3826. #ifdef DEBUG
  3827.     if (deblog) {
  3828.     debug(F101,"END maclvl 3","",maclvl);
  3829.     debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl);
  3830.     debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1);
  3831.     }
  3832. #endif /* DEBUG */
  3833. #endif /* NOSPL */
  3834. }
  3835.  
  3836. #ifdef CKROOT
  3837. int
  3838. dochroot() {
  3839.     if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) {
  3840.     if (x == -3) {
  3841.         printf("?Directory name required\n");
  3842.         return(-9);
  3843.     }
  3844.     return(x);
  3845.     }
  3846.     ckstrncpy(line,s,LINBUFSIZ);
  3847.     s = line;
  3848.     if ((x = cmcfm()) < 0) return(x);
  3849.     s = brstrip(s);
  3850.     x = zsetroot(s);
  3851.     if (x < 0) {
  3852.     char * m = NULL;
  3853.     switch (x) {
  3854.       case -1:
  3855.       case -2: m = "Not a directory"; break;
  3856.       case -3: m = "Internal error"; break;
  3857.       case -4: m = "Access denied"; break;
  3858.       case -5: m = "Off limits"; break;
  3859.     }
  3860.     if (m) printf("%s: \"%s\"\n", m, s);
  3861.     return(m ? -9 : -2);
  3862.     } else {
  3863.     nopush = 1;
  3864.     return(success = 1);
  3865.     }
  3866. }
  3867. #endif /* CKROOT */
  3868.  
  3869. #ifndef NOXFER
  3870. static char * asnbuf = NULL;        /* As-name buffer pointer */
  3871.  
  3872. char sndxnam[] = { "_array_x_" };    /* (with replaceable x!) */
  3873.  
  3874. /*
  3875.   The new SEND command, replacing BSEND, CSEND, PSEND, etc etc.
  3876.   Call with cx = top-level keyword value.  Returns:
  3877.     < 0  On parse error.
  3878.     0    On other type of failure (e.g. requested operation not allowed).
  3879.     1    On success with sstate set to 's' so protocol will begin.
  3880. */
  3881.  
  3882. /*  D O X S E N D  --  Parse SEND and related commands with switches  */
  3883.  
  3884. int
  3885. doxsend(cx) int cx; {
  3886.     int c, i, n, wild, confirmed = 0;    /* Workers */
  3887.     int x, y;                /* of the world... */
  3888.     int getval = 0;            /* Whether to get switch value */
  3889.     extern char * snd_move;        /* Directory to move sent files to */
  3890.     extern char * snd_rename;        /* What to rename sent files to */
  3891.     extern char * filefile;        /* File containing filenames to send */
  3892.     extern int xfiletype;        /* Send only text (or binary) files */
  3893.     extern struct keytab pathtab[];    /* PATHNAMES option keywords */
  3894.     extern int npathtab;        /* How many of them */
  3895.     extern int recursive;        /* Recursive directory traversal */
  3896.     extern int rprintf;            /* REMOTE PRINT flag */
  3897.     extern int fdispla;            /* TRANSFER DISPLAY setting */
  3898.     extern int skipbup;            /* Skip backup files when sending */
  3899.     struct stringint pv[SND_MAX+1];    /* Temporary array for switch values */
  3900.     struct FDB sf, sw, fl, cm;        /* FDBs for each parse function */
  3901.     int mlist = 0;            /* Flag for MSEND or MMOVE */
  3902.     char * m;                /* For making help messages */
  3903.     extern struct keytab protos[];    /* File transfer protocols */
  3904.     extern int xfrxla, g_xfrxla, nprotos;
  3905.     extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */
  3906.     extern char sndnbefore[], sndnafter[];
  3907.     extern CK_OFF_T sndsmaller, sndlarger, calibrate;
  3908. #ifndef NOSPL
  3909.     int range[2];            /* Array range */
  3910.     char ** ap = NULL;            /* Array pointer */
  3911.     int arrayx = -1;            /* Array index */
  3912. #endif /* NOSPL */
  3913.  
  3914. #ifdef NEWFTP
  3915.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  3916.     if (cx == XXMAI) {
  3917.         printf("?Sorry, No MAIL with FTP\n");
  3918.         return(-9);
  3919.     }
  3920.     return(doftpput(cx,0));
  3921.     }
  3922. #endif /* NEWFTP */
  3923.  
  3924.     for (i = 0; i <= SND_MAX; i++) {    /* Initialize switch values */
  3925.     pv[i].sval = NULL;        /* to null pointers */
  3926.     pv[i].ival = -1;        /* and -1 int values */
  3927.     pv[i].wval = (CK_OFF_T)-1;    /* and -1 wide values */
  3928.     }
  3929. #ifndef NOSPL
  3930.     range[0] = -1;
  3931.     range[1] = -1;
  3932.     sndxin = -1;            /* Array index */
  3933. #endif /* NOSPL */
  3934.     sndarray = NULL;            /* Array pointer */
  3935.  
  3936. #ifdef UNIXOROSK
  3937.     g_matchdot = matchdot;        /* Match dot files */
  3938. #endif /* UNIXOROSK */
  3939.     g_recursive = recursive;        /* Recursive sending */
  3940.     recursive = 0;            /* Save global value, set local */
  3941.     debug(F101,"xsend entry fncnv","",fncnv);
  3942.  
  3943.     /* Preset switch values based on top-level command that called us */
  3944.  
  3945.     switch (cx) {
  3946.       case XXMSE:            /* MSEND */
  3947.     mlist = 1; break;
  3948.       case XXCSEN:            /* CSEND */
  3949.     pv[SND_CMD].ival = 1; break;
  3950.       case XXMMOVE:            /* MMOVE */
  3951.     mlist = 1;
  3952.       case XXMOVE:            /* MOVE */
  3953.     pv[SND_DEL].ival = 1; break;
  3954.       case XXRSEN:            /* RESEND */
  3955.     pv[SND_BIN].ival = 1;        /* Implies /BINARY */
  3956.     pv[SND_RES].ival = 1; break;
  3957.       case XXMAI:            /* MAIL */
  3958.     pv[SND_MAI].ival = 1; break;
  3959.     }
  3960.  
  3961.     /* Set up chained parse functions... */
  3962.  
  3963.     cmfdbi(&sw,                /* First FDB - command switches */
  3964.        _CMKEY,            /* fcode */
  3965.        "Filename, or switch",    /* hlpmsg */
  3966.        "",                /* default */
  3967.        "",                /* addtl string data */
  3968. #ifdef NOMSEND
  3969.        nsndtab,            /* addtl numeric data 1: tbl size */
  3970. #else
  3971.        mlist ? nmsndtab : nsndtab,    /* addtl numeric data 1: tbl size */
  3972. #endif /* NOMSEND */
  3973.        4,                /* addtl numeric data 2: 4 = cmswi */
  3974.        xxstring,            /* Processing function */
  3975. #ifdef NOMSEND
  3976.        sndtab,            /* Keyword table */
  3977. #else
  3978.        mlist ? msndtab : sndtab,
  3979. #endif /* NOMSEND */
  3980.        &sf                /* Pointer to next FDB */
  3981.        );
  3982.     cmfdbi(&sf,                /* 2nd FDB - file to send */
  3983.        _CMIFI,            /* fcode */
  3984.        "File(s) to send",        /* hlpmsg */
  3985.        "",                /* default */
  3986.        "",                /* addtl string data */
  3987.        nolinks,            /* addtl numeric data 1 */
  3988.        0,                /* addtl numeric data 2 */
  3989.        xxstring,
  3990.        NULL,
  3991.        mlist ? &cm : &fl
  3992.        );
  3993.     cmfdbi(&fl,                /* 3rd FDB - command to send from */
  3994.        _CMFLD,            /* fcode */
  3995.        "Command",            /* hlpmsg */
  3996.        "",                /* default */
  3997.        "",                /* addtl string data */
  3998.        0,                /* addtl numeric data 1 */
  3999.        0,                /* addtl numeric data 2 */
  4000.        xxstring,
  4001.        NULL,
  4002.        &cm
  4003.        );
  4004.     cmfdbi(&cm,                /* 4th FDB - Confirmation */
  4005.        _CMCFM,            /* fcode */
  4006.        "",                /* hlpmsg */
  4007.        "",                /* default */
  4008.        "",                /* addtl string data */
  4009.        0,                /* addtl numeric data 1 */
  4010.        0,                /* addtl numeric data 2 */
  4011.        NULL,
  4012.        NULL,
  4013.        NULL
  4014.        );
  4015.  
  4016.     while (1) {                /* Parse 0 or more switches */
  4017.     x = cmfdb(&sw);            /* Parse something */
  4018.     debug(F101,"xsend cmfdb","",x);
  4019.     if (x < 0)            /* Error */
  4020.       goto xsendx;            /* or reparse needed */
  4021.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  4022.       break;
  4023. /*
  4024.   They gave a switch, but let's see how they terminated it.
  4025.   If they ended it with : or =, then we must parse a value.
  4026.   If they ended it with anything else, then we must NOT parse a value.
  4027. */
  4028.     c = cmgbrk();            /* Get break character */
  4029.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  4030.     if (getval && !(cmresult.kflags & CM_ARG)) {
  4031.         printf("?This switch does not take arguments\n");
  4032.         x = -9;
  4033.         goto xsendx;
  4034.     }
  4035.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  4036.         printf("?This switch requires an argument\n");
  4037.         x = -9;
  4038.         goto xsendx;
  4039.     }
  4040.     n = cmresult.nresult;        /* Numeric result = switch value */
  4041.     debug(F101,"xsend switch","",n);
  4042.  
  4043.     switch (n) {            /* Process the switch */
  4044.       case SND_CMD:            /* These take no args */
  4045.         if (nopush) {
  4046.         printf("?Sorry, system command access is disabled\n");
  4047.         x = -9;
  4048.         goto xsendx;
  4049.         }
  4050. #ifdef PIPESEND
  4051.         else if (sndfilter) {
  4052.         printf(
  4053. "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n");
  4054.         x = -9;
  4055.         goto xsendx;
  4056.         }
  4057. #endif /* PIPESEND */
  4058.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  4059.         pv[n].ival = 1;        /* Just set the flag */
  4060.         pv[SND_ARR].ival = 0;
  4061.         break;
  4062.  
  4063.       case SND_REC:            /* /RECURSIVE */
  4064.         recursive = 2;        /* Set the real variable */
  4065.         pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */
  4066.         pv[n].ival = 1;        /* Just set the flag */
  4067.         break;
  4068.  
  4069.       case SND_RES:            /* /RECOVER (resend) */
  4070.         pv[SND_ARR].ival = 0;
  4071.         pv[SND_BIN].ival = 1;    /* Implies /BINARY */
  4072.       case SND_NOB:            /* /NOBACKUP */
  4073.       case SND_DEL:            /* /DELETE */
  4074.       case SND_SHH:            /* /QUIET */
  4075.         pv[n].ival = 1;        /* Just set the flag */
  4076.         break;
  4077.  
  4078. #ifdef UNIXOROSK
  4079. /* Like recursive, these are set immediately because they affect cmifi() */
  4080.       case SND_DOT:            /* /DOTFILES */
  4081.         matchdot = 1;
  4082.         break;
  4083.       case SND_NOD:            /* /NODOTFILES */
  4084.         matchdot = 0;
  4085.         break;
  4086. #endif /* UNIXOROSK */
  4087.  
  4088.       /* File transfer modes - each undoes the others */
  4089.  
  4090.       case SND_BIN:            /* Binary */
  4091.       case SND_TXT:            /* Text */
  4092.       case SND_IMG:            /* Image */
  4093.       case SND_LBL:            /* Labeled */
  4094.         pv[SND_BIN].ival = 0;
  4095.         pv[SND_TXT].ival = 0;
  4096.         pv[SND_IMG].ival = 0;
  4097.         pv[SND_LBL].ival = 0;
  4098.         pv[n].ival = 1;
  4099.         break;
  4100.  
  4101. #ifdef CKSYMLINK
  4102.       case SND_LNK:
  4103.       case SND_NLK:
  4104.         nolinks = (n == SND_NLK) ? 2 : 0;
  4105.         cmfdbi(&sf,            /* Redo cmifi() */
  4106.            _CMIFI,        /* fcode */
  4107.            "File(s) to send",    /* hlpmsg */
  4108.            "",            /* default */
  4109.            "",            /* addtl string data */
  4110.            nolinks,        /* addtl numeric data 1 */
  4111.            0,            /* addtl numeric data 2 */
  4112.            xxstring,
  4113.            NULL,
  4114.            mlist ? &cm : &fl
  4115.            );
  4116.         break;
  4117. #endif /* CKSYMLINK */
  4118.  
  4119.       case SND_EXC:            /* Excludes */
  4120.         if (!getval) break;
  4121.         if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
  4122.         if (x == -3) {
  4123.             printf("?Pattern required\n");
  4124.             x = -9;
  4125.         }
  4126.         goto xsendx;
  4127.         }
  4128.         if (pv[n].sval) free(pv[n].sval);
  4129.         y = strlen(s);
  4130.         if (y > 256) {
  4131.         printf("?Pattern too long - 256 max\n");
  4132.         x = -9;
  4133.         goto xsendx;
  4134.         }
  4135.         pv[n].sval = malloc(y+1);
  4136.         if (pv[n].sval) {
  4137.         strcpy(pv[n].sval,s);    /* safe */
  4138.         pv[n].ival = 1;
  4139.         }
  4140.         break;
  4141.  
  4142.       case SND_MOV:            /* MOVE after */
  4143.       case SND_REN:            /* RENAME after */
  4144.         if (!getval) break;
  4145.         if ((x = cmfld(n == SND_MOV ?
  4146.        "device and/or directory for source file after sending" :
  4147.        "new name for source file after sending",
  4148.                "",
  4149.                &s,
  4150.                n == SND_MOV ? xxstring : NULL
  4151.                )) < 0) {
  4152.         if (x == -3) {
  4153.             printf("%s\n", n == SND_MOV ?
  4154.                "?Destination required" :
  4155.                "?New name required"
  4156.                );
  4157.             x = -9;
  4158.         }
  4159.         goto xsendx;
  4160.         }
  4161.         if (pv[n].sval) free(pv[n].sval);
  4162.         s = brstrip(s);
  4163.         y = strlen(s);
  4164.         if (y > 0) {
  4165.         pv[n].sval = malloc(y+1);
  4166.         if (pv[n].sval) {
  4167.             strcpy(pv[n].sval,s); /* safe */
  4168.             pv[n].ival = 1;
  4169.         }
  4170.         }
  4171.         break;
  4172.  
  4173.       case SND_SMA:            /* Smaller / larger than */
  4174.       case SND_LAR: {
  4175.           CK_OFF_T w;
  4176.           if (!getval) break;
  4177.           if ((x = cmnumw("Size in bytes","0",10,&w,xxstring)) < 0)
  4178.         goto xsendx;
  4179.           pv[n].wval = w;
  4180.           break;
  4181.       }
  4182.       case SND_AFT:            /* Send /AFTER:date-time */
  4183.       case SND_BEF:            /* Send /BEFORE:date-time */
  4184.       case SND_NAF:            /* Send /NOT-AFTER:date-time */
  4185.       case SND_NBE:            /* Send /NOT-BEFORE:date-time */
  4186.         if (!getval) break;
  4187.         if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) {
  4188.         if (x == -3) {
  4189.             printf("?Date-time required\n");
  4190.             x = -9;
  4191.         }
  4192.         goto xsendx;
  4193.         }
  4194.         if (pv[n].sval) free(pv[n].sval);
  4195.         pv[n].sval = malloc((int)strlen(s)+1);
  4196.         if (pv[n].sval) {
  4197.         strcpy(pv[n].sval,s);    /* safe */
  4198.         pv[n].ival = 1;
  4199.         }
  4200.         break;
  4201.  
  4202.       case SND_MAI:            /* Send as mail (= MAIL) */
  4203. #ifdef IKSD
  4204.         if (inserver && !ENABLED(en_mai)) {
  4205.         printf("?Sorry, sending files as mail is disabled\n");
  4206.         return(-9);
  4207.         }
  4208. #endif /* IKSD */
  4209.         pv[n].ival = 1;
  4210.         if (!getval) break;
  4211.         if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) {
  4212.         if (x == -3) {
  4213.             printf("?address required\n");
  4214.             x = -9;
  4215.         }
  4216.         goto xsendx;
  4217.         }
  4218.         s = brstrip(s);
  4219.         if (pv[n].sval) free(pv[n].sval);
  4220.         pv[n].sval = malloc((int)strlen(s)+1);
  4221.         if (pv[n].sval)
  4222.           strcpy(pv[n].sval,s);    /* safe */
  4223.         break;
  4224.  
  4225.       case SND_PRI:            /* Send to be printed (REMOTE PRINT) */
  4226. #ifdef IKSD
  4227.         if (inserver && !ENABLED(en_mai)) {
  4228.         printf("?Sorry, sending files for printing is disabled\n");
  4229.         return(-9);
  4230.         }
  4231. #endif /* IKSD */
  4232.         pv[n].ival = 1;
  4233.         if (!getval) break;
  4234.         if ((x = cmfld("Print options","",&s,xxstring)) < 0)
  4235.           if (x != -3) goto xsendx;
  4236.         s = brstrip(s);
  4237.         if (pv[n].sval) free(pv[n].sval);
  4238.         pv[n].sval = malloc((int)strlen(s)+1);
  4239.         if (pv[n].sval)
  4240.           strcpy(pv[n].sval,s);    /* safe */
  4241.         break;
  4242.  
  4243.       case SND_ASN:            /* As-name */
  4244.         debug(F101,"xsend /as-name getval","",getval);
  4245.         if (!getval) break;
  4246.         if ((x = cmfld("Name to send under","",&s,NULL)) < 0) {
  4247.         if (x == -3) {
  4248.             printf("?name required\n");
  4249.             x = -9;
  4250.         }
  4251.         goto xsendx;
  4252.         }
  4253.         s = brstrip(s);
  4254.         if ((y = strlen(s)) > 0) {
  4255.         if (pv[n].sval) free(pv[n].sval);
  4256.         pv[n].sval = malloc(y+1);
  4257.         if (pv[n].sval) {
  4258.             strcpy(pv[n].sval,s); /* safe */
  4259.             pv[n].ival = 1;
  4260.         }
  4261.         }
  4262.         break;
  4263.  
  4264.       case SND_STA: {        /* Starting position (= PSEND) */
  4265.           CK_OFF_T w;
  4266.           if (!getval) break;
  4267.           if ((x = cmnumw("0-based position","0",10,&w,xxstring)) < 0)
  4268.         goto xsendx;
  4269.           pv[n].wval = w;
  4270.           break;
  4271.       }
  4272.       case SND_PRO:            /* Protocol to use */
  4273.         if (!getval) break;
  4274.         if ((x = cmkey(protos,nprotos,"File-transfer protocol","",
  4275.                xxstring)) < 0) {
  4276.         if (x == -3) {
  4277.             printf("?name of protocol required\n");
  4278.             x = -9;
  4279.         }
  4280.         goto xsendx;
  4281.         }
  4282.         pv[n].ival = x;
  4283.         break;
  4284.  
  4285. #ifdef PIPESEND
  4286.       case SND_FLT:            /* Filter */
  4287.         debug(F101,"xsend /filter getval","",getval);
  4288.         if (!getval) break;
  4289.         if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) {
  4290.         if (x == -3)
  4291.           s = "";
  4292.         else
  4293.           goto xsendx;
  4294.         }
  4295.         if (*s) s = brstrip(s);
  4296.         y = strlen(s);
  4297.         for (x = 0; x < y; x++) {    /* Make sure they included "\v(...)" */
  4298.         if (s[x] != '\\') continue;
  4299.         if (s[x+1] == 'v') break;
  4300.         }
  4301.         if (x == y) {
  4302.         printf(
  4303.         "?Filter must contain a replacement variable for filename.\n"
  4304.                );
  4305.         x = -9;
  4306.         goto xsendx;
  4307.         }
  4308.         pv[n].ival = 1;
  4309.         if (pv[n].sval) {
  4310.         free(pv[n].sval);
  4311.         pv[n].sval = NULL;
  4312.         }
  4313.         if ((y = strlen(s)) > 0) {
  4314.         if ((pv[n].sval = malloc(y+1)))
  4315.           strcpy(pv[n].sval,s);    /* safe */
  4316.         }
  4317.         break;
  4318. #endif /* PIPESEND */
  4319.  
  4320.       case SND_PTH:            /* Pathnames */
  4321.         if (!getval) {
  4322.         pv[n].ival = PATH_REL;
  4323.         break;
  4324.         }
  4325.         if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0)
  4326.           goto xsendx;
  4327.         pv[n].ival = x;
  4328.         break;
  4329.  
  4330.       case SND_NAM:            /* Filenames */
  4331.         if (!getval) break;
  4332.         if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0)
  4333.           goto xsendx;
  4334.         debug(F101,"xsend /filenames","",x);
  4335.         pv[n].ival = x;
  4336.         break;
  4337.  
  4338. #ifdef CALIBRATE
  4339.           case SND_CAL: {        /* /CALIBRATE */
  4340.           CK_OFF_T w;
  4341.           if (getval) {
  4342.           if ((x = cmnumw("number of Kbytes to send",
  4343.                   "1024",10,&w,xxstring)) < 0)
  4344.             goto xsendx;
  4345.           } else
  4346.         w = (CK_OFF_T)1024;
  4347.           pv[n].wval = w;
  4348.           pv[SND_ARR].ival = 0;
  4349.           break;
  4350.       }
  4351. #endif /* CALIBRATE */
  4352.  
  4353.       case SND_FIL:            /* Name of file containing filnames */
  4354.         if (!getval) break;
  4355.         if ((x = cmifi("Name of file containing list of filenames",
  4356.                    "",&s,&y,xxstring)) < 0) {
  4357.         if (x == -3) {
  4358.             printf("?Filename required\n");
  4359.             x = -9;
  4360.         }
  4361.         goto xsendx;
  4362.         } else if (y) {
  4363.         printf("?Wildcards not allowed\n");
  4364.         x = -9;
  4365.         goto xsendx;
  4366.         }
  4367.         if (pv[n].sval)
  4368.           free(pv[n].sval);
  4369.         if (s) if (*s) {
  4370.         if ((pv[n].sval = malloc((int)strlen(s)+1))) {
  4371.             strcpy(pv[n].sval,s);
  4372.             pv[n].ival = 1;
  4373.             pv[SND_ARR].ival = 0;
  4374.         }
  4375.         }
  4376.         break;
  4377.  
  4378. #ifndef NOSPL
  4379.       case SND_ARR:            /* SEND /ARRAY: */
  4380.         if (!getval) break;
  4381.         ap = NULL;
  4382.         if ((x = cmfld("Array name (a single letter will do)",
  4383.                "",
  4384.                &s,
  4385.                NULL
  4386.                )) < 0) {
  4387.         if (x == -3)
  4388.           break;
  4389.         else
  4390.           return(x);
  4391.         }
  4392.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  4393.         printf("?Bad array: %s\n",s);
  4394.         return(-9);
  4395.         }
  4396.         if (!(ap = a_ptr[x])) {
  4397.         printf("?No such array: %s\n",s);
  4398.         return(-9);
  4399.         }
  4400.         pv[n].ival = 1;
  4401.         pv[SND_CMD].ival = 0;    /* Undo any conflicting ones... */
  4402.         pv[SND_RES].ival = 0;
  4403.         pv[SND_CAL].ival = 0;
  4404.         pv[SND_FIL].ival = 0;
  4405.         arrayx = x;
  4406.         break;
  4407. #endif /* NOSPL */
  4408.  
  4409.       case SND_XPA:            /* /TRANSPARENT */
  4410.         pv[n].ival = 1;
  4411.         break;
  4412.  
  4413.       case SND_TYP:            /* Only files of given type */
  4414.         if (!getval) break;
  4415.         if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0)
  4416.           goto xsendx;
  4417.         pv[n].ival = (x == 2) ? -1 : x;
  4418.         break;
  4419.  
  4420.       default:
  4421.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  4422.         x = -9;
  4423.         goto xsendx;
  4424.     }
  4425.     }
  4426.     debug(F101,"xsend cmresult fcode","",cmresult.fcode);
  4427.  
  4428. #ifdef COMMENT
  4429.     /* List switch parsing results in debug log */
  4430.     for (i = 0; i <= SND_MAX; i++) {
  4431.     ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL);
  4432.     debug(F111,line, pv[i].sval, pv[i].ival);
  4433.     }
  4434. #endif /* COMMENT */
  4435.  
  4436. /* Now we have all switches, plus maybe a filename or command, or nothing */
  4437.  
  4438. #ifdef PIPESEND
  4439.     if (protocol != PROTO_K && pv[SND_CMD].ival > 0) {
  4440.     printf("?Sorry, %s works only with Kermit protocol\n",
  4441.            (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND");
  4442.     x = -9;
  4443.     goto xsendx;
  4444.     }
  4445.     if (pv[SND_RES].ival > 0 ||    /* /RECOVER */
  4446.     pv[SND_STA].wval > 0) {    /* or /STARTING */
  4447.     if (sndfilter || pv[SND_FLT].ival > 0) {
  4448.         printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n");
  4449.         x = -9;
  4450.         goto xsendx;
  4451.     }
  4452.     }
  4453. #endif /* PIPESEND */
  4454.  
  4455.     cmarg = "";
  4456.     cmarg2 = "";
  4457.     line[0] = NUL;
  4458.     s = line;
  4459.     wild = 0;
  4460.  
  4461.     switch (cmresult.fcode) {        /* How did we get out of switch loop */
  4462.       case _CMIFI:            /* Input filename */
  4463.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
  4464.     if (pv[SND_ARR].ival > 0)
  4465.       cmarg2 = line;
  4466.     else
  4467.       wild = cmresult.nresult;    /* Wild flag */
  4468.     if (!recursive && !wild)
  4469.       nolinks = 0;
  4470.     break;
  4471.       case _CMFLD:            /* Field */
  4472.     /* Only allowed with /COMMAND and /ARRAY */
  4473.     if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) {
  4474. #ifdef CKROOT
  4475.         if (ckrooterr)
  4476.           printf("?Off limits: %s\n",cmresult.sresult);
  4477.         else
  4478. #endif /* CKROOT */
  4479.           printf("?%s - \"%s\"\n",
  4480.            iswild(cmresult.sresult) ?
  4481.            "No files match" : "File not found",
  4482.            cmresult.sresult
  4483.            );
  4484.         x = -9;
  4485.         goto xsendx;
  4486.     }
  4487.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  4488.     if (pv[SND_ARR].ival > 0)
  4489.       cmarg2 = line;
  4490.     break;
  4491.       case _CMCFM:            /* Confirmation */
  4492.     /* s = ""; */
  4493.     confirmed = 1;
  4494.     break;
  4495.       default:
  4496.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  4497.     x = -9;
  4498.     goto xsendx;
  4499.     }
  4500.     debug(F110,"xsend string",s,0);
  4501.     debug(F101,"xsend confirmed","",confirmed);
  4502.  
  4503.     /* Save and change protocol and transfer mode */
  4504.     /* Global values are restored in main parse loop */
  4505.  
  4506.     g_proto = protocol;            /* Save current global protocol */
  4507.     g_urpsiz = urpsiz;
  4508.     g_spsizf = spsizf;
  4509.     g_spsiz = spsiz;
  4510.     g_spsizr = spsizr;
  4511.     g_spmax = spmax;
  4512.     g_wslotr = wslotr;
  4513.     g_prefixing = prefixing;
  4514.     g_fncact = fncact;
  4515.     g_fncnv = fncnv;
  4516.     g_fnspath = fnspath;
  4517.     g_fnrpath = fnrpath;
  4518.     g_xfrxla = xfrxla;
  4519.  
  4520.     if (pv[SND_PRO].ival > -1) {    /* Change according to switch */
  4521.     protocol = pv[SND_PRO].ival;
  4522.         if (ptab[protocol].rpktlen > -1) /* copied from initproto() */
  4523.             urpsiz = ptab[protocol].rpktlen;
  4524.         if (ptab[protocol].spktflg > -1)
  4525.             spsizf = ptab[protocol].spktflg;
  4526.         if (ptab[protocol].spktlen > -1) {
  4527.             spsiz = ptab[protocol].spktlen;
  4528.             if (spsizf)
  4529.           spsizr = spmax = spsiz;
  4530.         }
  4531.         if (ptab[protocol].winsize > -1)
  4532.             wslotr = ptab[protocol].winsize;
  4533.         if (ptab[protocol].prefix > -1)
  4534.             prefixing = ptab[protocol].prefix;
  4535.         if (ptab[protocol].fnca > -1)
  4536.             fncact  = ptab[protocol].fnca;
  4537.         if (ptab[protocol].fncn > -1)
  4538.             fncnv   = ptab[protocol].fncn;
  4539.         if (ptab[protocol].fnsp > -1)
  4540.             fnspath = ptab[protocol].fnsp;
  4541.         if (ptab[protocol].fnrp > -1)
  4542.             fnrpath = ptab[protocol].fnrp;
  4543.     }
  4544.     debug(F101,"xsend protocol","",protocol);
  4545.  
  4546.     if (pv[SND_NOB].ival > -1) {    /* /NOBACKUP (skip backup file) */
  4547.     g_skipbup = skipbup;
  4548.     skipbup = 1;
  4549.     }
  4550.     if (pv[SND_REC].ival > 0)        /* /RECURSIVE */
  4551.       recursive = 2;
  4552.  
  4553.     if (pv[SND_TYP].ival > -1) {    /* /TYPE */
  4554.     xfiletype = pv[SND_TYP].ival;
  4555.     if (xfiletype == 2)
  4556.       xfiletype = -1;
  4557.     }
  4558.     g_binary = binary;            /* Save global transfer mode */
  4559. #ifdef PATTERNS
  4560.     g_patterns = patterns;        /* Save FILE PATTERNS setting */
  4561. #endif /* PATTERNS */
  4562.     if (pv[SND_BIN].ival > 0) {        /* Change according to switch */
  4563.     /* If they said /BINARY they mean /BINARY */
  4564.     patterns = 0;            /* So no pattern-based switching */
  4565.     g_xfermode = xfermode;        /* or automatic transfer mode */
  4566.     xfermode = XMODE_M;
  4567.     binary = XYFT_B;
  4568.     debug(F101,"doxsend /BINARY xfermode","",xfermode);
  4569.     } else if (pv[SND_TXT].ival > 0) {    /* Ditto for /TEXT */
  4570.     patterns = 0;
  4571.     g_xfermode = xfermode;
  4572.     xfermode = XMODE_M;
  4573.     binary = XYFT_T;
  4574.     debug(F101,"doxsend /TEXT xfermode","",xfermode);
  4575.     } else if (pv[SND_IMG].ival > 0) {
  4576. #ifdef VMS
  4577.     binary = XYFT_I;
  4578. #else
  4579.     binary = XYFT_B;
  4580. #endif /* VMS */
  4581.     }
  4582. #ifdef CK_LABELED
  4583.     else if (pv[SND_LBL].ival > 0) {
  4584.     binary = XYFT_L;
  4585.     }
  4586. #endif /* CK_LABELED */
  4587.     debug(F101,"xsend binary","",binary);
  4588.  
  4589.     if (pv[SND_XPA].ival > 0)        /* /TRANSPARENT */
  4590.       xfrxla = 0;            /* Don't translate character sets */
  4591.  
  4592.     /* Check for legal combinations of switches, filenames, etc */
  4593.  
  4594. #ifdef PIPESEND
  4595.     if (pv[SND_CMD].ival > 0) {    /* COMMAND - strip any braces */
  4596.     debug(F110,"SEND /COMMAND before stripping",s,0);
  4597.     s = brstrip(s);
  4598.     debug(F110,"SEND /COMMAND after stripping",s,0);
  4599.     if (!*s) {
  4600.         printf("?Sorry, a command to send from is required\n");
  4601.         x = -9;
  4602.         goto xsendx;
  4603.     }
  4604.     cmarg = s;
  4605.     }
  4606. #endif /* PIPESEND */
  4607.  
  4608. /* Set up /MOVE and /RENAME */
  4609.  
  4610.     if (pv[SND_DEL].ival > 0 &&
  4611.     (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) {
  4612.     printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n");
  4613.     x = -9;
  4614.     goto xsendx;
  4615.     }
  4616. #ifdef CK_TMPDIR
  4617.     if (pv[SND_MOV].ival > 0) {
  4618.     int len;
  4619.     char * p = pv[SND_MOV].sval;
  4620. #ifdef CK_LOGIN
  4621.     if (isguest) {
  4622.         printf("?Sorry, /MOVE-TO not available to guests\n");
  4623.         x = -9;
  4624.         goto xsendx;
  4625.     }
  4626. #endif /* CK_LOGIN */
  4627.     len = strlen(p);
  4628.     if (!isdir(p)) {        /* Check directory */
  4629. #ifdef CK_MKDIR
  4630.         char * s = NULL;
  4631.         s = (char *)malloc(len + 4);
  4632.         if (s) {
  4633.         strcpy(s,p);        /* safe */
  4634. #ifdef datageneral
  4635.         if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; }
  4636. #else
  4637.         if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; }
  4638. #endif /* datageneral */
  4639.         s[len++] = 'X';
  4640.         s[len] = NUL;
  4641.         x = zmkdir(s);
  4642.         free(s);
  4643.         if (x < 0) {
  4644.             printf("?Can't create \"%s\"\n",p);
  4645.             x = -9;
  4646.             goto xsendx;
  4647.         }
  4648.         }
  4649. #else
  4650.         printf("?Directory \"%s\" not found\n",p);
  4651.         x = -9;
  4652.         goto xsendx;
  4653. #endif /* CK_MKDIR */
  4654.     }
  4655.         zfnqfp(p,LINBUFSIZ,tmpbuf);
  4656.     makestr(&snd_move,tmpbuf);
  4657.     }
  4658. #endif /* CK_TMPDIR */
  4659.  
  4660.     if (pv[SND_REN].ival > 0) {        /* /RENAME */
  4661.     char * p = pv[SND_REN].sval;
  4662. #ifdef CK_LOGIN
  4663.     if (isguest) {
  4664.         printf("?Sorry, /RENAME-TO not available to guests\n");
  4665.         x = -9;
  4666.         goto xsendx;
  4667.     }
  4668. #endif /* CK_LOGIN */
  4669.     if (!p) p = "";
  4670.     if (!*p) {
  4671.         printf("?New name required for /RENAME\n");
  4672.         x = -9;
  4673.         goto xsendx;
  4674.     }
  4675.     p = brstrip(p);
  4676. #ifndef NOSPL
  4677.     /* If name given is wild, rename string must contain variables */
  4678.     if (wild) {
  4679.         char * s = tmpbuf;
  4680.         x = TMPBUFSIZ;
  4681.         zzstring(p,&s,&x);
  4682.         if (!strcmp(tmpbuf,p)) {
  4683.         printf(
  4684.     "?/RENAME for file group must contain variables such as \\v(filename)\n"
  4685.                );
  4686.         x = -9;
  4687.         goto xsendx;
  4688.         }
  4689.     }
  4690. #endif /* NOSPL */
  4691.     makestr(&snd_rename,p);
  4692.     }
  4693.  
  4694. /* Handle /RECOVER and /START */
  4695.  
  4696. #ifdef CK_RESEND
  4697.     if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek
  4698. #ifdef PATTERNS
  4699.     && !patterns
  4700. #else
  4701. #ifdef VMS
  4702. /* VMS sets text/binary automatically later when it opens the file */
  4703.     && 0
  4704. #endif /* VMS */
  4705. #endif /* PATTERNS */
  4706.     ) {
  4707.     printf("?Sorry, /BINARY required\n");
  4708.     x = -9;
  4709.     goto xsendx;
  4710.     }
  4711.     if (pv[SND_STA].wval > 0) {        /* /START */
  4712.     if (wild) {
  4713.         printf("?Sorry, wildcards not permitted with /START\n");
  4714.         x = -9;
  4715.         goto xsendx;
  4716.     }
  4717.     if (sizeof(int) < 4) {
  4718.         printf("?Sorry, this command needs at least 32-bit integers\n");
  4719.         x = -9;
  4720.         goto xsendx;
  4721.     }
  4722. #ifdef CK_XYZ
  4723.     if (protocol != PROTO_K) {
  4724.         printf("?Sorry, SEND /START works only with Kermit protocol\n");
  4725.         x = -9;
  4726.         goto xsendx;
  4727.     }
  4728. #endif /* CK_XYZ */
  4729.     }
  4730. #ifdef CK_XYZ
  4731.     if (pv[SND_RES].ival > 0) {
  4732.     if (protocol != PROTO_K && protocol != PROTO_Z) {
  4733.         printf(
  4734.     "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n"
  4735.            );
  4736.         x = -9;
  4737.         goto xsendx;
  4738.     }
  4739.     }
  4740. #endif /* CK_XYZ */
  4741. #endif /* CK_RESEND */
  4742.  
  4743.     if (protocol == PROTO_K) {
  4744.     if ((pv[SND_MAI].ival > 0 ||    /* MAIL */
  4745.          pv[SND_PRI].ival > 0 ||    /* PRINT */
  4746.          pv[SND_RES].ival > 0    /* RESEND */
  4747.          ) &&
  4748.         (!atdiso || !atcapr)) {    /* Disposition attribute off? */
  4749.         printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n");
  4750.         x = -9;
  4751.         goto xsendx;
  4752.     }
  4753.     }
  4754.  
  4755. #ifdef CK_XYZ
  4756.     if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) {
  4757.     printf(
  4758. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  4759.            );
  4760.     x = -9;
  4761.     goto xsendx;
  4762.     }
  4763. #endif /* CK_XYZ */
  4764.  
  4765.     if (!confirmed) {            /* CR not typed yet, get more fields */
  4766.     char *m;
  4767.     if (mlist) {            /* MSEND or MMOVE */
  4768.         nfils = 0;            /* We already have the first one */
  4769. #ifndef NOMSEND
  4770.         msfiles[nfils++] = line;    /* Store pointer */
  4771.         lp = line + (int)strlen(line) + 1; /* Point past it */
  4772.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4773.         while (1) {            /* Get more filenames */
  4774.         char *p;
  4775.         if ((x = cmifi("Names of files to send, separated by spaces",
  4776.                    "", &s,&y,xxstring)) < 0) {
  4777.             if (x != -3)
  4778.               goto xsendx;
  4779.             if ((x = cmcfm()) < 0)
  4780.               goto xsendx;
  4781.             break;
  4782.         }
  4783.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  4784.         p = lp;            /* remember pointer, */
  4785.         while ((*lp++ = *s++))    /* and copy it into buffer */
  4786.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  4787.               printf("?MSEND list too long\n");
  4788.               line[0] = NUL;
  4789.               x = -9;
  4790.               goto xsendx;
  4791.           }
  4792.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4793.         if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */
  4794. #ifdef ZFNQFP
  4795.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  4796.         p = tmpbuf;
  4797. #endif /* ZFNQFP */
  4798.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  4799.             strcat(fspec,p);    /* safe */
  4800.             strcat(fspec," ");    /* safe */
  4801.         } else
  4802. #ifdef COMMENT
  4803.           printf("WARNING - \\v(filespec) buffer overflow\n");
  4804. #else
  4805.           debug(F101,"doxsend filespec buffer overflow","",0);
  4806. #endif /* COMMENT */
  4807.         }
  4808. #endif /* NOMSEND */
  4809.     } else {            /* Regular SEND */
  4810.         char *p; int y;
  4811.         nfils = -1;
  4812.         if (pv[SND_MAI].ival > 0)
  4813.           m = (pv[SND_MAI].sval) ?
  4814.         "e-mail address (optional)" :
  4815.           "e-mail address (required)";
  4816.         else if (pv[SND_PRI].ival > 0)
  4817.           m = "printer options (optional)";
  4818.         else if (wild)
  4819.           m =
  4820. "\nOptional as-name template containing replacement variables \
  4821. like \\v(filename)";
  4822.         else
  4823.           m = "Optional name to send it with";
  4824.         if ((x = cmtxt(m,"",&p,NULL)) < 0)
  4825.           goto xsendx;
  4826.         if (!p) p = "";
  4827.         if (*p) {            /* If some text was given... */
  4828.         p = brstrip(p);        /* Replace /AS-NAME: value if any */
  4829.         if ((y = strlen(p)) > 0) {
  4830.                     if (pv[SND_MAI].ival > 0) {
  4831.                         makestr(&pv[SND_MAI].sval, p);
  4832.                     } else {
  4833.             if (pv[SND_ASN].sval) free(pv[SND_ASN].sval);
  4834.             pv[SND_ASN].sval = malloc(y+1);
  4835.             if (pv[SND_ASN].sval) {
  4836.                 strcpy(pv[SND_ASN].sval,p);    /* safe */
  4837.                 pv[SND_ASN].ival = 1;
  4838.             }
  4839.             }
  4840.         }
  4841.         }
  4842.     }
  4843.     }
  4844.     /* Set cmarg2 from as-name, however we got it. */
  4845.  
  4846.     if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) {
  4847.     int x;
  4848.     x = strlen(line);
  4849.     ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1);
  4850.     cmarg2 = line+x+2;
  4851.     debug(F110,"doxsend cmarg2",cmarg2,0);
  4852.     }
  4853.  
  4854. #ifndef NOFRILLS
  4855.     if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) {
  4856.     printf("Sorry, /MAIL and /PRINT are conflicting options\n");
  4857.     x = -9;
  4858.     goto xsendx;
  4859.     }
  4860.     n = 0;                /* /MAIL or /PRINT? */
  4861.     if (pv[SND_MAI].ival > 0)
  4862.       n = SND_MAI;
  4863.     else if (pv[SND_PRI].ival > 0)
  4864.       n = SND_PRI;
  4865.     if (n) {                /* Yes... */
  4866. #ifdef DEBUG
  4867.     char * p;
  4868.     if (n == SND_MAI)
  4869.       p = "/MAIL";
  4870.     else
  4871.       p = "/PRINT";
  4872.     debug(F111,"xsend",p,n);
  4873. #endif /* DEBUG */
  4874. #ifdef CK_XYZ
  4875.     if (protocol != PROTO_K) {
  4876.         printf("Sorry, %s available only with Kermit protocol\n",
  4877.            (n == SND_MAI) ? "/MAIL" : "/PRINT"
  4878.            );
  4879.         x = -9;
  4880.         goto xsendx;
  4881.     }
  4882. #endif /* CK_XYZ */
  4883.     debug(F101,"xsend print/mail wild","",wild);
  4884.     *optbuf = NUL;            /* Wipe out any old options */
  4885.     s = pv[n].sval;            /* mail address or print switch val */
  4886.     if (!s) s = "";
  4887.     debug(F110,"doxsend mail address or printer options",s,0);
  4888.     if (n == SND_MAI && !*s) {
  4889.         printf("?E-mail address required\n");
  4890.         x = -9;
  4891.         goto xsendx;
  4892.     } else if ((int)strlen(s) > 94) { /* Ensure legal size */
  4893.         printf("?%s too long\n",
  4894.            (n == SND_MAI) ?
  4895.            "E-mail address" :
  4896.            "Print option string"
  4897.            );
  4898.         x = -9;
  4899.         goto xsendx;
  4900.     }
  4901.     ckstrncpy(optbuf,s,OPTBUFLEN);    /* OK, copy to option buffer */
  4902.     cmarg = line;            /* File to send */
  4903.     if (n == SND_MAI) {
  4904.         debug(F110,"xsend mailing",cmarg,0);
  4905.         debug(F110,"xsend address:",optbuf,0);
  4906.         rmailf = 1;
  4907.     } else {
  4908.         debug(F110,"xsend printing",cmarg,0);
  4909.         debug(F110,"xsend options",optbuf,0);
  4910.         rprintf = 1;
  4911.     }
  4912.     }
  4913. #endif /* NOFRILLS */
  4914.  
  4915. #ifdef CALIBRATE
  4916.     if (pv[SND_CAL].wval > 0) {        /* Handle /CALIBRATE */
  4917.     if (confirmed) {
  4918.         calibrate = pv[SND_CAL].wval * (CK_OFF_T)1024;
  4919.         sndsrc = -9;
  4920.         nfils = 1;
  4921.         wild = 0;
  4922. #ifndef NOMSEND
  4923.         addlist = 0;
  4924. #endif /* NOMSEND */
  4925.         ckstrncpy(line,"CALIBRATION",LINBUFSIZ);
  4926.         s = cmarg = line;
  4927.         if (!cmarg2) cmarg2 = "";
  4928.         debug(F110,"doxsend cmarg2 calibrate",cmarg2,0);
  4929.     } else if (line[0]) {
  4930.         calibrate = 0;
  4931.         pv[SND_CAL].ival = 0;
  4932.         pv[SND_CAL].wval = 0;
  4933.     }
  4934.     }
  4935. #endif /* CALIBRATE */
  4936.  
  4937.     if (pv[SND_FIL].ival > 0) {
  4938.     if (confirmed && !calibrate) {
  4939.         if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) {
  4940.         debug(F110,"xsend can't open",pv[SND_FIL].sval,0);
  4941.         printf("?Failure to open %s\n",filefile);
  4942.         x = -9;
  4943.         goto xsendx;
  4944.         }
  4945.         makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */
  4946.         debug(F110,"xsend opened",filefile,0);
  4947.         wild = 1;
  4948.     }
  4949.     }
  4950.  
  4951.     /* SEND alone... */
  4952.  
  4953. #ifndef NOSPL
  4954.     if (confirmed && pv[SND_ARR].ival > 0) {
  4955.     if (!*cmarg2) {
  4956.         sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE);
  4957.         cmarg2 = sndxnam;
  4958.     }
  4959.     cmarg = "";
  4960.     goto sendend;
  4961.     }
  4962. #endif /* NOSPL */
  4963.  
  4964.     if (confirmed && !line[0] && !filefile && !calibrate) {
  4965. #ifndef NOMSEND
  4966.     if (filehead) {            /* OK if we have a SEND-LIST */
  4967.         nfils = filesinlist;
  4968.         sndsrc = nfils;        /* Like MSEND */
  4969.         addlist = 1;        /* But using a different list... */
  4970.         filenext = filehead;
  4971.         goto sendend;
  4972.     }
  4973. #endif /* NOMSEND */
  4974.     printf("?Filename required but not given\n");
  4975.     x = -9;
  4976.     goto xsendx;
  4977.     }
  4978.  
  4979.     /* Not send-list or array */
  4980.  
  4981. #ifndef NOMSEND
  4982.     addlist = 0;            /* Don't use SEND-LIST. */
  4983.     filenext = NULL;
  4984. #endif /* NOMSEND */
  4985.  
  4986.     if (mlist) {            /* MSEND or MMOVE */
  4987. #ifndef NOMSEND
  4988.     cmlist = msfiles;        /* List of files to send */
  4989.     sndsrc = nfils;
  4990.     cmarg2 = "";
  4991.     sendstart = (CK_OFF_T)0;
  4992. #endif /* NOMSEND */
  4993. #ifdef PIPESEND
  4994.     pipesend = 0;
  4995. #endif /* PIPESEND */
  4996.     } else if (filefile) {        /* File contains list of filenames */
  4997.     s = "";
  4998.     cmarg = "";
  4999.     cmarg2 = "";
  5000.     line[0] = NUL;
  5001.     nfils = 1;
  5002.     sndsrc = 1;
  5003.  
  5004.     } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) {
  5005.  
  5006.     nfils = sndsrc = -1;    /* Not MSEND, MMOVE, /LIST, or /ARRAY */
  5007.     if (                /* or /COMMAND */
  5008.  
  5009. #ifndef NOFRILLS
  5010.         !rmailf && !rprintf        /* Not MAIL or PRINT */
  5011. #else
  5012.         1
  5013. #endif /* NOFRILLS */
  5014.         ) {
  5015.         CK_OFF_T y = (CK_OFF_T)1;
  5016.         if (!wild)
  5017.           y = zchki(s);
  5018.         if (y < (CK_OFF_T)0) {
  5019.         printf("?Read access denied - \"%s\"\n", s);
  5020.         x = -9;
  5021.         goto xsendx;
  5022.         }
  5023.         if (s != line)        /* We might already have done this. */
  5024.           ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */
  5025.         else
  5026.           debug(F110,"doxsend line=s",line,0);
  5027.         cmarg = line;        /* File to send */
  5028.     }
  5029.     zfnqfp(cmarg,fspeclen,fspec);
  5030.     }
  5031.     if (!mlist) {            /* For all but MSEND... */
  5032. #ifdef PIPESEND
  5033.     if (pv[SND_CMD].ival > 0)    /* /COMMAND sets pipesend flag */
  5034.       pipesend = 1;
  5035.     debug(F101,"xsend /COMMAND pipesend","",pipesend);
  5036.     if (pipesend && filefile) {
  5037.         printf("?Invalid switch combination\n");
  5038.         x = -9;
  5039.         goto xsendx;
  5040.     }
  5041. #endif /* PIPESEND */
  5042.  
  5043. #ifndef NOSPL
  5044.     /* If as-name given and filespec is wild, as-name must contain variables */
  5045.     debug(F111,"doxsend cmarg2 wild",cmarg2,wild);
  5046.     if (wild && *cmarg2) {
  5047.         char * s = tmpbuf;
  5048.         x = TMPBUFSIZ;
  5049.         zzstring(cmarg2,&s,&x);
  5050.         if (!strcmp(tmpbuf,cmarg2)) {
  5051.         printf(
  5052.     "?As-name for file group must contain variables such as \\v(filename)\n"
  5053.                );
  5054.         x = -9;
  5055.         goto xsendx;
  5056.         }
  5057.     }
  5058. #endif /* NOSPL */
  5059.  
  5060.     /* Strip braces from as-name */
  5061.     debug(F110,"xsend cmarg2 before stripping",cmarg2,0);
  5062.     cmarg2 = brstrip(cmarg2);
  5063.     debug(F110,"xsend filename",cmarg,0);
  5064.     debug(F110,"xsend as-name",cmarg2,0);
  5065.  
  5066.     /* Copy as-name to a safe place */
  5067.  
  5068.     if (asnbuf) {
  5069.         free(asnbuf);
  5070.         asnbuf = NULL;
  5071.     }
  5072.     if ((y = strlen(cmarg2)) > 0) {
  5073.         asnbuf = (char *) malloc(y + 1);
  5074.         if (asnbuf) {
  5075.         strcpy(asnbuf,cmarg2);    /* safe */
  5076.         cmarg2 = asnbuf;
  5077.         } else cmarg2 = "";
  5078.     }
  5079.  
  5080. #ifdef CK_RESEND
  5081.     debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival);
  5082.     if (pv[SND_STA].wval > (CK_OFF_T)-1) { /* /START position */
  5083.         if (wild) {
  5084.         printf("?/STARTING-AT may not be used with multiple files.\n");
  5085.         x = -9;
  5086.         goto xsendx;
  5087.         } else
  5088.           sendstart = pv[SND_STA].wval;
  5089.     } else
  5090.       sendstart = (CK_OFF_T)0;
  5091.     debug(F101,"xsend /STARTING","",sendstart);
  5092. #endif /* CK_RESEND */
  5093.     }
  5094.  
  5095. sendend:                /* Common successful exit */
  5096.     moving = 0;
  5097.     if (pv[SND_SHH].ival > 0) {        /* SEND /QUIET... */
  5098.     g_displa = fdispla;
  5099.     fdispla = 0;
  5100.     debug(F101,"xsend display","",fdispla);
  5101.     }
  5102.  
  5103. #ifndef NOSPL                /* SEND /ARRAY... */
  5104.     if (pv[SND_ARR].ival > 0) {
  5105.     if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */
  5106.     if (range[0] == -1)        /* If low end of range not specified */
  5107.       range[0] = 1;            /* default to 1 */
  5108.     if (range[1] == -1)        /* If high not specified */
  5109.       range[1] = a_dim[arrayx];    /* default to size of array */
  5110.     if ((range[0] < 0) ||        /* Check range */
  5111.         (range[0] > a_dim[arrayx]) ||
  5112.         (range[1] < range[0]) ||
  5113.         (range[1] > a_dim[arrayx])) {
  5114.         printf("?Bad array range - [%d:%d]\n",range[0],range[1]);
  5115.         x = -9;
  5116.         goto xsendx;
  5117.     }
  5118.     sndarray = ap;            /* Array pointer */
  5119.     sndxin = arrayx;        /* Array index */
  5120.     sndxlo = range[0];        /* Array range */
  5121.     sndxhi = range[1];
  5122.     sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  5123.  
  5124. #ifdef COMMENT
  5125.     printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */
  5126.            (sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  5127.     printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi);
  5128.     printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2);
  5129.     while ((x = agnbyte()) > -1) {
  5130.         putchar((char)x);
  5131.     }
  5132.     return(1);
  5133. #endif /* COMMENT */
  5134.     }
  5135. #endif /* NOSPL */
  5136.  
  5137.     if (pv[SND_ARR].ival < 1) {        /* File selection & disposition... */
  5138.  
  5139.     if (pv[SND_DEL].ival > 0)    /* /DELETE was specified */
  5140.       moving = 1;
  5141.     debug(F101,"xsend /DELETE","",moving);
  5142.     if (pv[SND_AFT].ival > 0)    /* Copy SEND criteria */
  5143.       ckstrncpy(sndafter,pv[SND_AFT].sval,19);
  5144.     if (pv[SND_BEF].ival > 0)
  5145.       ckstrncpy(sndbefore,pv[SND_BEF].sval,19);
  5146.     if (pv[SND_NAF].ival > 0)
  5147.       ckstrncpy(sndnafter,pv[SND_NAF].sval,19);
  5148.     if (pv[SND_NBE].ival > 0)
  5149.       ckstrncpy(sndnbefore,pv[SND_NBE].sval,19);
  5150.     if (pv[SND_EXC].ival > 0)
  5151.       makelist(pv[SND_EXC].sval,sndexcept,NSNDEXCEPT);
  5152.     if (pv[SND_SMA].wval > (CK_OFF_T)-1)
  5153.       sndsmaller = pv[SND_SMA].wval;
  5154.     if (pv[SND_LAR].wval > (CK_OFF_T)-1)
  5155.       sndlarger = pv[SND_LAR].wval;
  5156.     if (pv[SND_NAM].ival > -1) {
  5157.         g_fncnv = fncnv;        /* Save global value */
  5158.         fncnv = pv[SND_NAM].ival;
  5159.         debug(F101,"xsend fncnv","",fncnv);
  5160.     }
  5161.     if (pv[SND_PTH].ival > -1) {
  5162.         g_spath = fnspath;        /* Save global values */
  5163.         fnspath = pv[SND_PTH].ival;
  5164. #ifndef NZLTOR
  5165.         if (fnspath != PATH_OFF) {
  5166.         g_fncnv = fncnv;    /* Bad bad... */
  5167.         fncnv = XYFN_C;
  5168.         }
  5169. #endif /* NZLTOR */
  5170.         debug(F101,"xsend fnspath","",fnspath);
  5171.         debug(F101,"xsend fncnv","",fncnv);
  5172.     }
  5173.     }
  5174.  
  5175. #ifdef PIPESEND
  5176.     if (pv[SND_FLT].ival > 0) {
  5177.     makestr(&sndfilter,pv[SND_FLT].sval);
  5178.     debug(F110,"xsend /FILTER", sndfilter, 0);
  5179.     }
  5180. #endif /* PIPESEND */
  5181.  
  5182. #ifdef CK_APC
  5183. /* MOVE not allowed in APCs */
  5184.     if (moving &&
  5185.     (apcactive == APC_LOCAL || apcactive == APC_REMOTE)
  5186.     && !(apcstatus & APC_UNCH))
  5187.       return(success = 0);
  5188. #endif /* CK_APC */
  5189. #ifdef IKS_OPTION
  5190.     if (
  5191. #ifdef CK_XYZ
  5192.         protocol == PROTO_K &&
  5193. #endif /* CK_XYZ */
  5194.         !iks_wait(KERMIT_REQ_START,1)) {
  5195.         printf("?A Kermit Server is not available to process this command.\n");
  5196.         printf("?Start a RECEIVE command to complement this command.\n");
  5197.     }
  5198. #endif /* IKS_OPTION */
  5199.  
  5200. #ifdef IKSD
  5201. #ifdef CK_LOGIN
  5202.     if (moving && inserver && isguest) {
  5203.         printf("?File deletion not allowed for guests.\n");
  5204.     return(-9);
  5205.     }
  5206. #endif /* CK_LOGIN */
  5207. #endif /* IKSD */
  5208.  
  5209.     sstate = 's';            /* Set start state to SEND */
  5210.     sndcmd = 1;
  5211. #ifdef CK_RESEND
  5212.     if (pv[SND_RES].ival > 0)        /* Send sendmode appropriately */
  5213.       sendmode = SM_RESEND;
  5214.     else if (pv[SND_STA].ival > 0)
  5215.       sendmode = SM_PSEND;
  5216.     else
  5217. #endif /* CK_RESEND */
  5218.     if (mlist)
  5219.       sendmode = SM_MSEND;
  5220.     else
  5221.       sendmode = SM_SEND;
  5222. #ifdef MAC
  5223.     what = W_SEND;
  5224.     scrcreate();
  5225. #endif /* MAC */
  5226.     if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */
  5227.     displa = 1;            /* turn on file transfer display */
  5228.     }
  5229.     x = 0;
  5230.  
  5231.   xsendx:                /* Common exit, including failure */
  5232.     debug(F101,"doxsend sndsrc","",sndsrc);
  5233.     for (i = 0; i <= SND_MAX; i++) {    /* Free malloc'd memory */
  5234.     if (pv[i].sval)
  5235.       free(pv[i].sval);
  5236.     }
  5237.     return(x);
  5238. }
  5239. #endif /* NOXFER */
  5240.  
  5241. #ifndef NOLOCAL
  5242. /*  D O X C O N N  --  CONNECT command parsing with switches */
  5243.  
  5244. #ifdef XLIMITS
  5245. #define XLIMORTRIGGER
  5246. #else
  5247. #ifdef CK_TRIGGER
  5248. #define XLIMORTRIGGER
  5249. #endif /* CK_TRIGGER */
  5250. #endif /*  XLIMITS */
  5251.  
  5252. #ifdef CKTIDLE
  5253. int tt_idlelimit = 0;            /* Terminal idle limit */
  5254. int tt_idleact = IDLE_RET;        /* Terminal idle action */
  5255. #endif /* CKTIDLE */
  5256.  
  5257. #ifdef OS2                /* K95 only: */
  5258. extern int
  5259.   tt_idlesnd_tmo;            /*   Idle interval */
  5260. int tt_timelimit = 0;            /*   Time limit, 0 = none */
  5261. extern char *                /* Parse results - strings: */
  5262.   tt_idlesnd_str;            /*   Idle string */
  5263. #endif /* OS2 */
  5264.  
  5265. #ifdef CK_TRIGGER
  5266. extern char *tt_trigger[];
  5267. extern CHAR *tt_trmatch[];
  5268. extern char *triggerval;
  5269. static char *g_tt_trigger[TRIGGERS];
  5270. #endif /* CK_TRIGGER */
  5271.  
  5272. #ifdef OS2
  5273. static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */
  5274. static int g_tt_idlelimit, g_tt_saved = 0;
  5275. static char * g_tt_idlesnd_str;        /* global settings */
  5276. #endif /* OS2 */
  5277.  
  5278. static struct stringint pv[CONN_MAX+1];
  5279.  
  5280. VOID
  5281. resconn() {
  5282.     int i;
  5283.  
  5284. #ifdef OS2
  5285.     if ( g_tt_saved ) {
  5286.         tt_idlelimit   = g_tt_idlelimit;
  5287.         tt_idlesnd_tmo = g_tt_idlesnd_tmo;
  5288.         tt_timelimit   = g_tt_timelimit;
  5289.         tt_idlesnd_str = g_tt_idlesnd_str;
  5290.         g_tt_saved = 0;
  5291.     }
  5292. #endif /* OS2 */
  5293.  
  5294. #ifdef CK_TRIGGER
  5295.     for (i = 0; i < TRIGGERS; i++)
  5296.       tt_trigger[i] = g_tt_trigger[i];
  5297. #endif /* CK_TRIGGER */
  5298.  
  5299.     for (i = 0; i <= CONN_MAX; i++) {    /* Free malloc'd memory */
  5300.     if (pv[i].sval)
  5301.       free(pv[i].sval);
  5302.         pv[i].sval = NULL;
  5303.     }
  5304. }
  5305.  
  5306. int
  5307. doxconn(cx) int cx; {
  5308.     int c, i, n;            /* Workers */
  5309.     int x, y;
  5310.     int getval = 0;            /* Whether to get switch value */
  5311.     int async = 0;                      /* Make an async connect */
  5312.     struct FDB sw, cm;            /* FDBs for each parse function */
  5313.     extern FILE * tfile[];
  5314.     extern char * macp[];
  5315.  
  5316. #ifdef OS2
  5317.     g_tt_idlesnd_tmo = tt_idlesnd_tmo;    /* Save global settings */
  5318.     g_tt_timelimit   = tt_timelimit;
  5319.     g_tt_idlelimit   = tt_idlelimit;
  5320.     g_tt_idlesnd_str = tt_idlesnd_str;
  5321.     g_tt_saved = 1;
  5322. #endif /* OS2 */
  5323.  
  5324. #ifdef CK_TRIGGER
  5325.     if (!tt_trigger[0]) {        /* First initialization */
  5326.     for (i = 1; i < TRIGGERS; i++)
  5327.       tt_trigger[i] = NULL;
  5328.     }
  5329.     for (i = 0; i < TRIGGERS; i++)
  5330.       g_tt_trigger[i] = tt_trigger[i];
  5331.     if (triggerval) {
  5332.     free(triggerval);
  5333.     triggerval = NULL;
  5334.     }
  5335. #endif /* CK_TRIGGER */
  5336.  
  5337.     for (i = 0; i <= CONN_MAX; i++) {    /* Initialize switch values */
  5338.     pv[i].sval = NULL;        /* to null pointers */
  5339.     pv[i].ival = -1;        /* and -1 int values */
  5340.     pv[i].wval = (CK_OFF_T)-1;
  5341.     }
  5342.     if (cx == XXCQ)            /* CQ == CONNECT /QUIETLY */
  5343.       pv[CONN_NV].ival = 1;
  5344.  
  5345.     /* Set up chained parse functions... */
  5346.  
  5347.     cmfdbi(&sw,                /* First FDB - command switches */
  5348.        _CMKEY,            /* fcode */
  5349.        "Switch",            /* hlpmsg */
  5350.        "",                /* default */
  5351.        "",                /* addtl string data */
  5352.        nconntab,            /* addtl numeric data 1: tbl size */
  5353.        4,                /* addtl numeric data 2: 4 = cmswi */
  5354.        xxstring,            /* Processing function */
  5355.        conntab,            /* Keyword table */
  5356.        &cm                /* Pointer to next FDB */
  5357.        );
  5358.     cmfdbi(&cm,                /* 2nd FDB - Confirmation */
  5359.        _CMCFM,            /* fcode */
  5360.        "",                /* hlpmsg */
  5361.        "",                /* default */
  5362.        "",                /* addtl string data */
  5363.        0,                /* addtl numeric data 1 */
  5364.        0,                /* addtl numeric data 2 */
  5365.        NULL,
  5366.        NULL,
  5367.        NULL
  5368.        );
  5369.  
  5370.     while (1) {                /* Parse 0 or more switches */
  5371.     x = cmfdb(&sw);            /* Parse switch or confirmation */
  5372.     debug(F101,"doxconn cmfdb","",x);
  5373.     if (x < 0) {            /* Error */
  5374.         if (x == -9 || x == -2)
  5375.           printf("?No switches match - \"%s\"\n",atmbuf);
  5376.         goto xconnx;        /* or reparse needed */
  5377.     }
  5378.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  5379.       break;
  5380.     c = cmgbrk();            /* Get break character */
  5381.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  5382.     if (getval && !(cmresult.kflags & CM_ARG)) {
  5383.         printf("?This switch does not take arguments\n");
  5384.         x = -9;
  5385.         goto xconnx;
  5386.     }
  5387.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  5388.         printf("?This switch requires an argument\n");
  5389.         return(-9);
  5390.     }
  5391.     n = cmresult.nresult;        /* Numeric result = switch value */
  5392.     debug(F101,"doxconn switch","",n);
  5393.  
  5394.     switch (n) {            /* Process the switch */
  5395. #ifdef OS2
  5396.       case CONN_AS:            /* Asynchronous */
  5397.             pv[CONN_AS].ival = 1;
  5398.             pv[CONN_SY].ival = 0;
  5399.             break;
  5400.           case CONN_SY:                 /* Synchronous */
  5401.             pv[CONN_SY].ival = 1;
  5402.             pv[CONN_AS].ival = 0;
  5403.             break;
  5404. #endif /* OS2 */
  5405.       case CONN_NV:            /* Non-verbal */
  5406.         pv[n].ival = 1;
  5407.         break;
  5408. #ifdef XLIMITS
  5409.       case CONN_II:            /* Idle-interval */
  5410.       case CONN_IL:            /* Idle-limit */
  5411.       case CONN_TL:            /* Time-limit */
  5412.         if (!getval) break;
  5413.         if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
  5414.           goto xconnx;
  5415.         pv[n].ival = y;
  5416.         break;
  5417.       case CONN_IS:            /* Idle-string */
  5418. #endif /* XLIMITS */
  5419. #ifdef CK_TRIGGER
  5420.       case CONN_TS:            /* Trigger-string */
  5421. #endif /* CK_TRIGGER */
  5422. #ifdef XLIMORTRIGGER
  5423.         if (!getval) break;
  5424.         if ((x = cmfld("String (enclose in braces if it contains spaces)",
  5425.                "",&s,xxstring)) < 0) {
  5426.         if (x == -3) {
  5427.             printf("?String required\n");
  5428.             x = -9;
  5429.         }
  5430.         goto xconnx;
  5431.         }
  5432.         if (n != CONN_TS)
  5433.           s = brstrip(s);
  5434.         if ((y = strlen(s)) > 0) {
  5435.         if (pv[n].sval) free(pv[n].sval);
  5436.         pv[n].sval = malloc(y+1);
  5437.         if (pv[n].sval) {
  5438.             strcpy(pv[n].sval,s); /* safe */
  5439.             pv[n].ival = 1;
  5440.         }
  5441.         }
  5442.         break;
  5443. #endif /* XLIMORTRIGGER */
  5444.       default:
  5445.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  5446.         x = -9;
  5447.         goto xconnx;
  5448.     }
  5449.     }
  5450.     debug(F101,"doxconn cmresult.fcode","",cmresult.fcode);
  5451.     if (cmresult.fcode != _CMCFM) {
  5452.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  5453.     x = -9;
  5454.     goto xconnx;
  5455.     }
  5456.  
  5457.     /* Command was confirmed so we can pre-pop command level. */
  5458.     /* This is so CONNECT module won't think we're executing a script */
  5459.     /* if CONNECT was the final command in the script. */
  5460.  
  5461.     if (cmdlvl > 0)
  5462.       prepop();
  5463.  
  5464. #ifdef OS2                /* Make results available globally */
  5465.     if (pv[CONN_IL].ival > -1)        /* Idle limit */
  5466.       tt_idlelimit = pv[CONN_IL].ival;
  5467.     if (pv[CONN_II].ival > -1)        /* Idle limit */
  5468.       tt_idlesnd_tmo = pv[CONN_II].ival;
  5469.     if (pv[CONN_IS].sval)        /* Idle string */
  5470.       if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1))
  5471.     strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */
  5472.     if (pv[CONN_TL].ival > -1)        /* Session limit */
  5473.       tt_timelimit = pv[CONN_TL].ival;
  5474.     async = (pv[CONN_AS].ival > 0 ||
  5475.              pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0;
  5476. #endif /* OS2 */
  5477.  
  5478. #ifdef CK_TRIGGER
  5479.     if (pv[CONN_TS].sval)        /* Trigger strings */
  5480.       makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS);
  5481.     for (i = 0; i < TRIGGERS; i++)    /* Trigger match pointers */
  5482.       tt_trmatch[i] = NULL;
  5483.     if (triggerval) {            /* Reset trigger value */
  5484.     free(triggerval);
  5485.     triggerval = NULL;
  5486.     }
  5487. #endif /* CK_TRIGGER */
  5488.  
  5489.     x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async);
  5490.     {
  5491.     int xx;
  5492.     debug(F101,"doxconn doconect returns","",x);
  5493.     if ((xx = ttchk()) < 0) dologend();
  5494.     debug(F101,"doxconn ttchk returns","",xx);
  5495.     }
  5496.  
  5497. #ifdef CK_TRIGGER
  5498.     debug(F111,"doxconn doconect triggerval",triggerval,x);
  5499. #endif /* CK_TRIGGER */
  5500.  
  5501.   xconnx:
  5502.     /* Back from CONNECT -- Restore global settings */
  5503.  
  5504.     if (!async)
  5505.       resconn();
  5506.  
  5507.     success = (x > 0) ? 1 : 0;
  5508.     return(x);
  5509. }
  5510. #endif /* NOLOCAL */
  5511.  
  5512. #ifdef ADDCMD
  5513. /* cx == XXADD or XXREMV */
  5514. /* fc == ADD_BIN or ADD_TXT */
  5515. static int
  5516. doadd(cx,fc) int cx, fc; {
  5517. #ifdef PATTERNS
  5518.     char * tmp[FTPATTERNS];
  5519.     char **p = NULL;
  5520.     int i, j, k, n = 0, x = 0, last;
  5521.  
  5522. #endif /* PATTERNS */
  5523.     if (cx != XXADD && cx != XXREMV) {
  5524.     printf("?Unexpected function code: %d\n",cx);
  5525.     return(-9);
  5526.     }
  5527. #ifdef PATTERNS
  5528.     while (n < FTPATTERNS) {        /* Collect new patterns */
  5529.     tmp[n] = NULL;
  5530.     if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
  5531.       break;
  5532.     ckstrncpy(line,s,LINBUFSIZ);
  5533.     s = brstrip(line);
  5534.     makestr(&(tmp[n++]),s);
  5535.     }
  5536.     if (x == -3)
  5537.       x = cmcfm();
  5538.     if (x < 0)
  5539.       goto xdoadd;
  5540.     p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */
  5541.     last = 0;
  5542.     for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */
  5543.     if (!p[i]) {
  5544.         last = i;
  5545.         break;
  5546.     }
  5547.     }
  5548.     if (cx == XXADD) {            /* Adding */
  5549.     if (last + n > FTPATTERNS) {    /* Check if too many */
  5550.         printf("?Too many patterns - %d is the maximum\n", FTPATTERNS);
  5551.         goto xdoadd;
  5552.     }
  5553.         for (i = 0; i < n; i++) {        /* Copy in the new ones. */
  5554.           for (j = 0, x = 0; x == 0 && j < last ; j++ )
  5555.             x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5556.           if (x == 0)
  5557.             makestr(&(p[last++]),tmp[i]);
  5558.         }
  5559.         makestr(&(p[last]),NULL);    /* Null-terminate the list */
  5560.         x = 1;
  5561.         goto xdoadd;                    /* Done */
  5562.     } else if (cx == XXREMV) {        /* Remove something(s) */
  5563.     int j, k;
  5564.     if (last == 0)                    /* List is empty */
  5565.       goto xdoadd;                    /* Nothing to remove */
  5566.     for (i = 0; i < n; i++) {            /* i = Patterns they typed */
  5567.         for (j = 0; j < last; j++) {        /* j = Patterns in list */
  5568.         /* Change this to ckstrcmp()... */
  5569.         if (filecase)
  5570.                   x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5571.         else
  5572.           x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */
  5573.         if (x) {                    /* This one matches */
  5574.             makestr(&(p[j]),NULL);      /* Free it */
  5575.             for (k = j; k < last; k++)  /* Move the rest up */
  5576.               p[k] = p[k+1];
  5577.             p[k] = NULL;            /* Erase last one */
  5578.             if (!p[k])
  5579.               break;
  5580.         }
  5581.         }
  5582.     }
  5583.     }
  5584.   xdoadd:                /* Common exit */
  5585.     for (i = 0; i < n; i++)
  5586.       if (tmp[i])
  5587.     free(tmp[i]);
  5588.     return(x);
  5589. #endif /* PATTERNS */
  5590. }
  5591.  
  5592. /* ADD SEND-LIST */
  5593.  
  5594. static int
  5595. addsend(cx) int cx; {
  5596. #ifndef NOMSEND
  5597.     extern struct keytab fttab[];
  5598.     extern int nfttyp;
  5599.     struct filelist * flp;
  5600.     char * fmode = "";
  5601.     int xmode = 0;
  5602.     int xbinary = 0;
  5603. #endif /* NOMSEND */
  5604.  
  5605. #ifdef NOMSEND
  5606.     printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n");
  5607.     return(-9);
  5608. #endif /* NOMSEND */
  5609.     if (cx == XXREMV) {
  5610.     printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n");
  5611.     return(-9);
  5612.     }
  5613. #ifndef NOMSEND
  5614. #ifndef XYZ_INTERNAL
  5615.     if (protocol != PROTO_K) {
  5616.        printf("?Sorry, ADD SEND-LIST does not work with external protocols\n");
  5617.        return(-9);
  5618.     }
  5619. #endif /* XYZ_INTERNAL */
  5620.  
  5621.     x = cmifi("File specification to add","", &s,&y,xxstring);
  5622.     if (x < 0) {
  5623.     if (x == -3) {
  5624.         printf("?A file specification is required\n");
  5625.         return(-9);
  5626.     } else
  5627.       return(x);
  5628.     }
  5629.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5630.     s = tmpbuf;
  5631.     if (filesinlist == 0)        /* Take care of \v(filespec) */
  5632.       fspec[0] = NUL;
  5633.     zfnqfp(s,LINBUFSIZ,line);
  5634.     s = line;
  5635.     if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) {
  5636.     strcat(fspec,s);        /* safe */
  5637.     strcat(fspec," ");        /* safe */
  5638.     } else
  5639.       printf("WARNING - \\v(filespec) buffer overflow\n");
  5640.  
  5641.  
  5642.     xbinary = binary;
  5643.     if ((patterns || filepeek)        /* FILE PATTERNS or SCAN is ON */
  5644. #ifdef CK_LABELED
  5645.     && binary != XYFT_L        /* And not if FILE TYPE LABELED */
  5646. #endif /* CK_LABELED */
  5647. #ifdef VMS
  5648.     && binary != XYFT_I        /* or FILE TYPE IMAGE */
  5649. #endif /* VMS */
  5650.     ) {
  5651.     int k, x;
  5652.     x = -1;
  5653.     k = scanfile(line,&x,nscanfile);
  5654.     if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  5655.     }
  5656.     fmode = gfmode(xbinary,0);
  5657.     if ((x = cmkey(fttab,nfttyp,
  5658.            "type of file transfer", fmode, xxstring)) < 0)
  5659.       return(x);
  5660.     xmode = x;
  5661.  
  5662.     cmarg2 = "";
  5663.     if ((x = cmfld(y ?
  5664.   "\nAs-name template containing replacement variables such as \\v(filename)" :
  5665.   "Name to send it with", "",&s,NULL)) < 0)
  5666.       if (x != -3)
  5667.     return(x);
  5668. #ifndef NOSPL
  5669.     if (y && *s) {
  5670.     char * p = tmpbuf;
  5671.     x = TMPBUFSIZ;
  5672.     zzstring(s,&p,&x);
  5673.     if (!strcmp(tmpbuf,s)) {
  5674.         printf(
  5675.   "?As-name for file group must contain variables such as \\v(filename)\n"
  5676.            );
  5677.         return(-9);
  5678.     }
  5679.     }
  5680. #endif /* NOSPL */
  5681.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5682.     cmarg2 = tmpbuf;
  5683.  
  5684.     if ((x = cmcfm()) < 0)
  5685.       return(x);
  5686.     flp = (struct filelist *) malloc(sizeof(struct filelist));
  5687.     if (flp) {
  5688.     if (filetail)
  5689.       filetail->fl_next = flp;
  5690.     filetail = flp;
  5691.     if (!filehead)
  5692.       filehead = flp;
  5693.     x = (int) strlen(line);    /* Length of filename */
  5694.     s = (char *) malloc(x + 1);
  5695.     if (s) {
  5696.         strcpy(s,line);        /* safe */
  5697.         flp->fl_name = s;
  5698.         flp->fl_mode = xmode;
  5699.         x = (int) strlen(cmarg2);    /* Length of as-name */
  5700.         if (x < 1) {
  5701.         flp->fl_alias = NULL;
  5702.         } else {
  5703.         s = (char *) malloc(x + 1);
  5704.         if (s) {
  5705.             strcpy(s,cmarg2);    /* safe */
  5706.             flp->fl_alias = s;
  5707.         } else {
  5708.             printf("Sorry, can't allocate space for as-name");
  5709.             return(-9);
  5710.         }
  5711.         }
  5712.         flp->fl_next = NULL;
  5713.         filesinlist++;        /* Count this node */
  5714.         return(success = 1);    /* Finished adding this node */
  5715.     } else {
  5716.         printf("Sorry, can't allocate space for name");
  5717.         return(-9);
  5718.     }
  5719.     } else {
  5720.     printf("Sorry, can't allocate file list node");
  5721.     return(-9);
  5722.     }
  5723. #endif /* NOMSEND */
  5724. }
  5725. #endif /* ADDCMD */
  5726.  
  5727. #ifndef NOHTTP                /* HTTP ops... */
  5728. #ifdef TCPSOCKET
  5729. #define HTTP_GET 0            /* GET */
  5730. #define HTTP_PUT 1            /* PUT */
  5731. #define HTTP_POS 2            /* POST */
  5732. #define HTTP_IDX 3            /* INDEX */
  5733. #define HTTP_HED 4                      /* HEAD */
  5734. #define HTTP_DEL 5                      /* DELETE */
  5735. #define HTTP_CON 6                      /* CONNECT */
  5736. #define HTTP_OPN 7                      /* OPEN */
  5737. #define HTTP_CLS 8                      /* CLOSE */
  5738.  
  5739. static struct keytab httptab[] = {
  5740.     { "close",   HTTP_CLS, 0 },
  5741.     { "connect", HTTP_CON, 0 },
  5742.     { "delete",  HTTP_DEL, 0 },
  5743.     { "get",     HTTP_GET, 0 },
  5744.     { "head",    HTTP_HED, 0 },
  5745.     { "index",   HTTP_IDX, 0 },
  5746.     { "open",    HTTP_OPN, 0 },
  5747.     { "put",     HTTP_PUT, 0 },
  5748.     { "post",    HTTP_POS, 0 }
  5749. };
  5750. static int nhttptab = sizeof(httptab)/sizeof(struct keytab);
  5751.  
  5752. /* HTTP switches */
  5753. #define HT_SW_AG 0            /* /AGENT */
  5754. #define HT_SW_HD 1            /* /HEADER */
  5755. #define HT_SW_US 2            /* /USER */
  5756. #define HT_SW_PW 3            /* /PASSWORD */
  5757. #define HT_SW_AR 4                      /* /ARRAY */
  5758. #define HT_SW_TP 5                      /* /TOSCREEN */
  5759.  
  5760. static struct keytab httpswtab[] = {
  5761.     { "/agent",    HT_SW_AG, CM_ARG },
  5762. #ifndef NOSPL
  5763.     { "/array",    HT_SW_AR, CM_ARG },
  5764. #endif /* NOSPL */
  5765.     { "/header",   HT_SW_HD, CM_ARG },
  5766.     { "/password", HT_SW_PW, CM_ARG },
  5767.     { "/toscreen", HT_SW_TP, 0 },
  5768.     { "/user",     HT_SW_US, CM_ARG },
  5769.     { "", 0, 0 }
  5770. };
  5771. static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1;
  5772.  
  5773. /* HTTP PUT/POST switches */
  5774. #define HT_PP_MT 0            /* /MIME-TYPE */
  5775.  
  5776. static struct keytab httpptab[] = {
  5777.     { "/mime-type", HT_PP_MT, CM_ARG },
  5778.     { "", 0, 0 }
  5779. };
  5780. static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1;
  5781.  
  5782. #define HTTP_MAXHDR 8
  5783.  
  5784. static int
  5785. xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type)
  5786.     int action;
  5787.     char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array;
  5788.     int type;
  5789. /* xdohttp */ {
  5790.     int i, rc = 0;
  5791.     char * hdrlist[HTTP_MAXHDR];
  5792.     char rfile[CKMAXPATH+1];
  5793.     extern int httpfd;
  5794.  
  5795.     /* Check for a valid state to execute the command */
  5796.     if (inserver) {
  5797.         printf("?The HTTP command may not be used from the IKS\r\n");
  5798.     } else if (httpfd == -1) {
  5799.         if (http_reopen() < 0)
  5800.       printf("?No connection\n");
  5801.         else
  5802.       rc = 1;
  5803.     } else {
  5804.     rc = 1;
  5805.     }
  5806.  
  5807.     /* If the command is not valid, exit with failure */
  5808.     if (rc == 0)
  5809.         return(success = 0);
  5810.  
  5811.     if (action != HTTP_CON && rf[0] != '/') {
  5812.         rfile[0] = '/';
  5813.         ckstrncpy(&rfile[1],rf,CKMAXPATH);
  5814.     } else {
  5815.         ckstrncpy(rfile,rf,CKMAXPATH);
  5816.     }
  5817.     for (i = 0; i < HTTP_MAXHDR; i++)    /* Initialize header list */
  5818.       hdrlist[i] = NULL;
  5819.     makelist(hdr,hdrlist,HTTP_MAXHDR);    /* Make header list */
  5820.  
  5821. #ifdef BETADEBUG
  5822.     for (i = 0; i < nhttptab; i++)    /* Find action keyword */
  5823.       if (httptab[i].kwval == action)
  5824.     break;
  5825.     if (i == nhttptab) {        /* Shouldn't happen... */
  5826.     printf("?Invalid action - %d\n",action);
  5827.     return(0);            /* Failure */
  5828.     }
  5829.  
  5830.     printf("HTTP action:  %s\n",httptab[i].kwd);
  5831.     printf(" Agent:       %s\n",agent ? agent : "(null)");
  5832.  
  5833.     if (hdrlist[1]) {
  5834.     printf(" Header list: 1. %s\n",hdrlist[0]);
  5835.     for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++)
  5836.       printf("%15d. %s\n",i+1,hdrlist[i]);
  5837.     } else
  5838.       printf(" Header:      %s\n",hdrlist[0] ? hdrlist[0] : "(null)");
  5839.  
  5840.     printf(" User:        %s\n",user ? user : "(null)");
  5841. #ifdef COMMENT
  5842.     printf(" Password:    %s\n",pass ? pass : "(null)");
  5843. #endif /* COMMENT */
  5844.  
  5845. #ifndef NOSPL
  5846.     if (array)
  5847.       printf(" Array:       \\%%%c[]\n", array);
  5848.     else
  5849.       printf(" Array:       (none)\n");
  5850. #endif /* NOSPL */
  5851.  
  5852.     if (action == HTTP_PUT || action == HTTP_POS)
  5853.       printf(" Mime-type:   %s\n",mime ? mime : "(null)");
  5854.  
  5855.     printf(" Local file:  %s\n",lfile ? lfile : "(null)");
  5856.     printf(" Remote file: %s\n",rfile ? rfile : "(null)");
  5857.     printf(" Destination file: %s\n",dfile ? dfile : "(null)");
  5858. #endif /* BETADEBUG */
  5859.  
  5860.     /* The http_xxxx() functions return 0 on success, -1 on failure */
  5861.     switch (action) {
  5862.       case HTTP_CON: {
  5863.       extern int ttyfd;
  5864.       rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile);
  5865.       break;
  5866.       }
  5867.       case HTTP_DEL:
  5868.         rc = http_delete(agent,hdrlist,user,pass,array,rfile);
  5869.         break;
  5870.       case HTTP_GET:
  5871.         rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5872.         break;
  5873.       case HTTP_HED:
  5874.         rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5875.         break;
  5876.       case HTTP_PUT:
  5877.         rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5878.               type);
  5879.         break;
  5880.       case HTTP_POS:
  5881.         rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5882.                type);
  5883.         break;
  5884.       case HTTP_IDX:
  5885.         rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5886.         break;
  5887.       default:
  5888.         rc = -1;
  5889.     }
  5890.     return(rc == 0 ? 1 : 0);            /* Success is set by caller */
  5891. }
  5892. #endif /* TCPSOCKET */
  5893. #endif /* NOHTTP */
  5894.  
  5895. #ifndef NOSPL                /* ARRAY ops... */
  5896. static struct keytab arraytab[] = {
  5897.     { "clear",     ARR_CLR, 0 },
  5898.     { "copy",      ARR_CPY, 0 },
  5899.     { "dcl",       ARR_DCL, CM_INV },
  5900.     { "declare",   ARR_DCL, 0 },
  5901.     { "destroy",   ARR_DST, CM_INV },
  5902.     { "equate",    ARR_EQU, CM_INV },
  5903.     { "link",      ARR_EQU, 0 },
  5904.     { "resize",    ARR_RSZ, 0 },
  5905.     { "set",       ARR_SET, 0 },
  5906. #ifndef NOSHOW
  5907.     { "show",      ARR_SHO, 0 },
  5908. #endif /* NOSHOW */
  5909.     { "sort",      ARR_SRT, 0 },
  5910.     { "undeclare", ARR_DST, 0 },
  5911.     { "", 0, 0 }
  5912. };
  5913. static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1;
  5914.  
  5915. #ifdef CKLEARN
  5916. static struct keytab learnswi[] = {
  5917.     { "/close",    2, 0 },
  5918.     { "/off",      0, 0 },
  5919.     { "/on",       1, 0 }
  5920. };
  5921. #endif /* CKLEARN */
  5922.  
  5923. int
  5924. arrayitoa(x) int x; {            /* Array index to array letter */
  5925.     if (x == 1)
  5926.       return(64);
  5927.     else if (x < 0 || x > (122 - ARRAYBASE))
  5928.       return(-1);
  5929.     else
  5930.       return(x + ARRAYBASE);
  5931. }
  5932.  
  5933. int
  5934. arrayatoi(c) int c; {            /* Array letter to array index */
  5935.     if (c == 64)
  5936.       c = 96;
  5937.     if (c > 63 && c < 91)
  5938.       c += 32;
  5939.     if (c < ARRAYBASE || c > 122)
  5940.       return(-1);
  5941.     return(c - ARRAYBASE);
  5942. }
  5943.  
  5944. static int                /* Declare an array */
  5945. dodcl(cx) int cx; {
  5946.     int i, n, v, lo, hi, rc = 0;
  5947.     int isdynamic = 0;
  5948.     char tmpbuf[64];
  5949.     char ** p = NULL;
  5950.     char tmp[64];            /* Local temporary string buffer */
  5951.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5952.     if (y == -3) {
  5953.         printf("?Array name required\n");
  5954.         return(-9);
  5955.     } else return(y);
  5956.     }
  5957.     ckstrncpy(line,s,LINBUFSIZ);
  5958.     s = line;
  5959.     x = arraybounds(s,&lo,&hi);        /* Check syntax and get bounds */
  5960.     debug(F111,"dodcl arraybounds",s,x);
  5961.     if (x < 0) {            /* Error - Maybe it's a variable */
  5962.     char * p;            /* whose value is an array name */
  5963.     int n;
  5964.     p = tmpbuf;
  5965.     n = 63;
  5966.     p[0] = NUL;
  5967.     if (s[0] == CMDQ && s[1] == '&')
  5968.       s++;
  5969.     if (zzstring(s,&p,&n) > -1) {
  5970.         s = tmpbuf;
  5971.         x = arraybounds(s,&lo,&hi);
  5972.         debug(F111,"dodcl arraybounds 2",s,x);
  5973.     }
  5974.     if (x < 0) {
  5975.         printf("?Bad array name - \"%s\"\n",s);
  5976.         return(-9);
  5977.     }
  5978.     }
  5979.     debug(F101,"dodcl hi","",hi);
  5980.     debug(F101,"dodcl lo","",lo);
  5981.     debug(F101,"dodcl lo+1","",lo+1);
  5982.  
  5983.     if (lo == -1 && hi == -1) {        /* Have good array name and bounds */
  5984.     isdynamic = 1;
  5985.     n = CMDBL / 5;
  5986.     } else if (hi > -1) {
  5987.     printf("?Segment notation not allowed in array declarations\n");
  5988.     return(-9);
  5989.     } else if ((lo+1) < 0) {
  5990.     debug(F101,"dodcl underflow","",lo+1);
  5991.         printf("?Dimension underflow\n");
  5992.         return(-9);
  5993.     } else
  5994.       n = lo;
  5995.     x = arrayitoa(x);
  5996.     if (cx == XXUNDCL) {
  5997.     n = 0;
  5998.     v = 0;
  5999.     if ((y = cmcfm()) < 0)
  6000.       return(y);
  6001.     } else {
  6002.     p = (char **)malloc(sizeof(char **)*(n+1));
  6003.     if (!p) {
  6004.         printf("?Memory allocation error\n");
  6005.         return(-9);
  6006.     }
  6007.     v = 0;                /* Highest initialized member */
  6008.     p[0] = NULL;            /* Element 0 */
  6009.     keepallchars = 1;
  6010.     while (n > 0 && v < n) {    /* Parse initializers */
  6011.         p[v+1] = NULL;
  6012.         ckmakxmsg(tmp,
  6013.               64,
  6014.               "Initial value for \\&",
  6015.               ckctoa((char)x),
  6016.               "[",
  6017.               ckitoa(v+1),
  6018.               "]",
  6019.               NULL,NULL,NULL,NULL,NULL,NULL,NULL
  6020.               );
  6021.         if ((rc = cmfld((char *)tmp,"",&s,xxstring)) < 0) { /* Get field */
  6022.         if (rc == -3)        /* If answer is empty, we're done */
  6023.           break;
  6024.         else            /* Parse error, free temp pointers */
  6025.           goto dclx;
  6026.         }
  6027.         rc = 1;
  6028.         if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */
  6029.           continue;
  6030.         s = brstrip(s);        /* Strip any braces */
  6031.         makestr(&(p[++v]),s);
  6032.     }
  6033.     keepallchars = 0;
  6034.     if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0)
  6035.       return(y);
  6036.     if (isdynamic)
  6037.       n = v;
  6038.     }
  6039.     if (dclarray((char)x,n) < 0) {    /* Declare the array */
  6040.     printf("?Declare failed\n");
  6041.     goto dclx;
  6042.     }
  6043.     for (i = 1; i <= v; i++) {        /* Add any initial values */
  6044.     tmp[0] = '&';
  6045.     ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]");
  6046.     if (addmac(tmp,p[i]) < 0) {
  6047.         printf("Array initialization error: %s %s\n",tmp,p[i]);
  6048.         rc = -9;
  6049.         goto dclx;
  6050.     }
  6051.     }
  6052.   dclx:
  6053.     if (p) {
  6054.     for (i = 1; i <= v; i++)
  6055.       if (p[i]) free(p[i]);
  6056.     free((char *)p);
  6057.     }
  6058.     debug(F101,"DCL rc","",rc);
  6059.     return(success = rc);
  6060. }
  6061.  
  6062. static int
  6063. rszarray() {
  6064.     int i, x, y, n, lo, hi, islink = -1;
  6065.     char c, * s, ** ap = NULL;
  6066.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6067.     if (x == -3) {
  6068.         printf("?Array name required\n");
  6069.         return(-9);
  6070.     } else return(x);
  6071.     }
  6072.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6073.     s = line;
  6074.     x = arraybounds(s,&lo,&hi);
  6075.     if (x < 0) {            /* Parse the name, get index */
  6076.     printf("?Bad array reference - \"%s\"\n", s);
  6077.     return(-9);
  6078.     }
  6079.     if (lo < 0 && hi < 0) {
  6080.     y = cmnum("New size","",10,&lo,xxstring);
  6081.     if (y < 0) {
  6082.         if (y == -3)
  6083.           printf("?New size required\n");
  6084.         return(y);
  6085.     }
  6086.     }
  6087.     if ((y = cmcfm()) < 0)
  6088.       return(y);
  6089.     if (a_link[x] > -1) {        /* Link? */
  6090.     islink = x;            /* Yes follow it */
  6091.     x = a_link[x];            /* and remember */
  6092.     }
  6093.     if (!a_ptr[x]) {
  6094.     printf("?Array not declared - \"%s\"\n", s);
  6095.     return(-9);
  6096.     }
  6097.     if (lo < 0) {
  6098.     printf("?New size required\n");
  6099.     return(-9);
  6100.     }
  6101.     if (hi > -1) {
  6102.     printf("?Array segments not allowed for this operation\n");
  6103.     return(-9);
  6104.     }
  6105.     c = arrayitoa(x);            /* Get array letter */
  6106.     if (c == '@') {            /* Argument vector array off limits */
  6107.     printf("?Sorry, \\&@[] is read-only\n");
  6108.     return(-9);
  6109.     }
  6110.     if (lo == 0) {            /* If new size is 0... */
  6111.     dclarray(c,0);            /* Undeclare the array */
  6112.     return(success = 1);
  6113.     }
  6114.     n = a_dim[x];            /* Current size */
  6115.     ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */
  6116.     y = (n < lo) ? n : lo;
  6117.     for (i = 0; i <= y; i++)        /* Copy the part that fits */
  6118.       ap[i] = a_ptr[x][i];
  6119.     if (n < lo) {            /* If original array smaller */
  6120.     for (; i <= lo; i++)        /* initialize extra elements in */
  6121.       ap[i] = NULL;            /* new array to NULL. */
  6122.     } else if (n > lo) {        /* If new array smaller */
  6123.     for (; i <= lo; i++)        /* deallocate leftover elements */
  6124.       makestr(&(a_ptr[x][i]),NULL);    /* from original array. */
  6125.     }
  6126.     free((char *)a_ptr[x]);        /* Free original array list */
  6127.     a_ptr[x] = ap;            /* Replace with new one */
  6128.     a_dim[x] = lo;            /* Record the new dimension */
  6129.     if (islink > -1) {            /* Was this a link? */
  6130.     a_ptr[islink] = ap;        /* If so point to the resized array */
  6131.     a_dim[islink] = lo;
  6132.     } else {                /* If not are there links to here? */
  6133.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  6134.         if (i != x && a_link[i] == x) {     /* Find and update them */
  6135.         a_ptr[i] = ap;
  6136.         a_dim[i] = lo;
  6137.         }
  6138.     }
  6139.     }
  6140.     return(success = 1);
  6141. }
  6142.  
  6143. static int
  6144. copyarray() {
  6145.     int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0;
  6146.     char c1, c2, * a1, * a2;
  6147.     if ((y = cmfld("Name of source array","",&s,NULL)) < 0)
  6148.       return(y);
  6149.     ckstrncpy(line,s,LINBUFSIZ);
  6150.     a1 = line;
  6151.     if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) {
  6152.     printf("?Bad array reference - \"%s\"\n", a1);
  6153.     return(-9);
  6154.     } else if (!a_ptr[x1]) {
  6155.     printf("?Array not declared - \"%s\"\n", a1);
  6156.     return(-9);
  6157.     }
  6158.     c1 = arrayitoa(x1);
  6159.  
  6160.     if ((y = cmfld("Name of destination array","",&s,NULL)) < 0)
  6161.       return(y);
  6162.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6163.     a2 = tmpbuf;
  6164.     if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) {
  6165.     printf("?Bad array reference - \"%s\"\n", a2);
  6166.     return(-9);
  6167.     }
  6168.     c2 = arrayitoa(x2);
  6169.  
  6170.     if ((x = cmcfm()) < 0)
  6171.       return(x);
  6172.  
  6173.     if (c2 == '@') {            /* Argument vector array off limits */
  6174.     printf("?Sorry, \\&@[] is read-only\n");
  6175.     return(-9);
  6176.     }
  6177.     if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */
  6178.       whole = 1;                      /* whole array... */
  6179.  
  6180.     if (lo1 < 0) lo1 = whole ? 0 : 1;    /* Supply lower bound of source */
  6181.     if (hi1 < 0) hi1 = a_dim[x1];    /* Supply upper bound of source */
  6182.     if (lo2 < 0) lo2 = whole ? 0 : 1;    /* Lower bound of target */
  6183.     if (hi2 < 0) hi2 = lo2 + hi1 - lo1;    /* Upper bound of target */
  6184.     if (a_ptr[x2]) {            /* Target array is already declared? */
  6185.     if (hi2 > a_dim[x2])        /* If upper bound out of range */
  6186.       hi2 = a_dim[x2];        /* shrink to fit */
  6187.     } else {                /* Otherwise... */
  6188.     x2 = dclarray(c2, hi2);        /* declare the target array */
  6189.     }
  6190.     for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */
  6191.     makestr(&(a_ptr[x2][j]),a_ptr[x1][i]);
  6192.     }
  6193.     return(success = 1);
  6194. }
  6195.  
  6196. static int                /* Undeclare an array */
  6197. unarray() {
  6198.     int x, y, n, rc = 0;
  6199.     char c, * s;
  6200.  
  6201.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6202.     if (y == -3) {
  6203.         printf("?Array name required\n");
  6204.         return(-9);
  6205.     } else return(y);
  6206.     }
  6207.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6208.     s = line;
  6209.     if ((y = cmcfm()) < 0)
  6210.       return(y);
  6211.     if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */
  6212.     printf("?Bad array reference - \"%s\"\n", s);
  6213.     return(-9);
  6214.     }
  6215.     if (y > 0 || n > 0) {
  6216.     printf("?Partial arrays can not be destroyed\n");
  6217.     return(-9);
  6218.     }
  6219.     c = arrayitoa(x);            /* Get array letter */
  6220.     if (a_ptr[x]) {            /* If array is declared */
  6221.     if (c == '@') {            /* Argument vector array off limits */
  6222.         printf("?Sorry, \\&@[] is read-only\n");
  6223.         return(-9);
  6224.     }
  6225.     rc = dclarray(c,0);        /* Undeclare the array */
  6226.     } else                /* It wasn't declared */
  6227.       rc = 1;
  6228.     if (rc > -1) {            /* Set return code and success */
  6229.     success = 1;
  6230.     rc = 1;
  6231.     } else {
  6232.     success = 0;
  6233.     printf("?Failed - destroy \"\\&%c[]\"\n", c);
  6234.     rc = -9;
  6235.     }
  6236.     return(rc);
  6237. }
  6238.  
  6239. static int
  6240. clrarray(cx) int cx; {
  6241.     int i, x, lo, hi;
  6242.     char c, * s, * val = NULL;
  6243.  
  6244.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6245.     if (x == -3) {
  6246.         printf("?Array name required\n");
  6247.         return(-9);
  6248.     } else return(x);
  6249.     }
  6250.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6251.     s = line;
  6252.     if (cx == ARR_SET) {        /* SET */
  6253.     if ((x = cmtxt("Value","",&val,xxstring)) < 0)
  6254.       return(x);
  6255.     ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */
  6256.     val = tmpbuf;
  6257.     if (!*val) val = NULL;
  6258.     } else if ((x = cmcfm()) < 0)    /* CLEAR */
  6259.       return(x);
  6260.  
  6261.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */
  6262.     printf("?Bad array reference - \"%s\"\n", s);
  6263.     return(-9);
  6264.     }
  6265.     c = arrayitoa(x);            /* Get array letter */
  6266.     if (!a_ptr[x]) {            /* If array is declared */
  6267.     printf("?Array %s is not declared\n", s);
  6268.     return(-9);
  6269.     } else if (c == '@') {        /* Argument vector array off limits */
  6270.     printf("?Sorry, \\&@[] is read-only\n");
  6271.     return(-9);
  6272.     }
  6273.     if (lo < 0) lo = 0;
  6274.     if (hi < 0) hi = a_dim[x];
  6275.     for (i = lo; i <= hi; i++)        /* Clear/Set selected range */
  6276.       makestr(&(a_ptr[x][i]),val);
  6277.  
  6278.     return(success = 1);
  6279. }
  6280.  
  6281. extern char **aa_ptr[CMDSTKL][28];
  6282. extern int aa_dim[CMDSTKL][28];
  6283.  
  6284. static int                /* Create symbolic link to an array */
  6285. linkarray() {
  6286.     int i = 0, x, y, lo, hi, flag = 0;
  6287.     char c, * s, * p;
  6288.  
  6289.     if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) {
  6290.     if (x == -3) {
  6291.         printf("?Array name required\n");
  6292.         return(-9);
  6293.     } else return(x);
  6294.     }
  6295.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of link name */
  6296.     s = line;
  6297.     if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) {
  6298.     if (x == -3) {
  6299.         printf("?Array name required\n");
  6300.         return(-9);
  6301.     } else return(x);
  6302.     }
  6303.     ckstrncpy(tmpbuf,p,TMPBUFSIZ);    /* Make safe copy of array name */
  6304.     p = tmpbuf;
  6305.     if ((x = cmcfm()) < 0)
  6306.       return(x);
  6307.  
  6308.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */
  6309.     printf("?Bad array reference - \"%s\"\n", s);
  6310.     return(-9);
  6311.     }
  6312.     if (a_ptr[x]) {            /* Must not already exist */
  6313.     c = arrayitoa(x);
  6314.     printf("?Array already exists: \\&%c[]\n", c);
  6315.     return(-9);
  6316.     }
  6317.     if (lo > -1 || hi > -1) {
  6318.     printf("?Sorry, whole arrays only: %s\n",s);
  6319.     return(-9);
  6320.     }
  6321.     if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */
  6322.     printf("?Bad array reference - \"%s\"\n", s);
  6323.     return(-9);
  6324.     }
  6325.     if (lo > -1 || hi > -1) {
  6326.     printf("?Sorry, whole arrays only: %s\n",p);
  6327.     return(-9);
  6328.     }
  6329.     if (x == y) {
  6330.     for (i = cmdlvl; i >= 0; i--)
  6331.       if (aa_ptr[i][x]) {
  6332.           flag++;
  6333.           break;
  6334.       }
  6335.     }
  6336.     if (flag) {
  6337.     a_ptr[x] = aa_ptr[i][y];    /* Link to saved copy */
  6338.     a_dim[x] = aa_dim[i][y];
  6339.     } else {                /* Otherwise... */
  6340.     c = arrayitoa(y);        /* Check if it's declared */
  6341.     if (!a_ptr[y]) {
  6342.         printf("?Array is not declared: \\&%c[]\n", c);
  6343.         return(-9);
  6344.     }
  6345.     if (a_link[y] > -1) {        /* And if it's a link itself */
  6346.         printf("?Links to links not allowed: \\&%c[]\n", c);
  6347.         return(-9);
  6348.     }
  6349.     a_ptr[x] = a_ptr[y];        /* All OK, make the link */
  6350.     a_dim[x] = a_dim[y];
  6351.     }
  6352.     a_link[x] = y;
  6353.     return(success = 1);
  6354. }
  6355. #endif /* NOSPL */
  6356.  
  6357. #ifndef NOCSETS
  6358. static char * dcsetname = NULL;
  6359.  
  6360. /* Get Display Character-Set Name */
  6361.  
  6362. char *
  6363. getdcset() {
  6364.     char * s;
  6365.     int y;
  6366. #ifdef PCFONTS
  6367.     extern int tt_font, ntermfont;
  6368.     extern struct keytab term_font[];
  6369. #endif /* PCFONTS */
  6370.  
  6371.     s = "";
  6372. #ifdef OS2
  6373.     y = os2getcp();            /* Default is current code page */
  6374.     switch (y) {
  6375.       case 437: s = "cp437"; break;
  6376.       case 850: s = "cp850"; break;
  6377.       case 852: s = "cp852"; break;
  6378.       case 857: s = "cp857"; break;
  6379.       case 858: s = "cp858"; break;
  6380.       case 862: s = "cp862"; break;
  6381.       case 866: s = "cp866"; break;
  6382.       case 869: s = "cp869"; break;
  6383.       case 1250: s = "cp1250"; break;
  6384.       case 1251: s = "cp1251"; break;
  6385.       case 1252: s = "cp1252"; break;
  6386.       case 1253: s = "cp1253"; break;
  6387.       case 1254: s = "cp1254"; break;
  6388.       case 1255: s = "cp1255"; break;
  6389.       case 1256: s = "cp1256"; break;
  6390.       case 1257: s = "cp1257"; break;
  6391.       case 1258: s = "cp1258"; break;
  6392.     }
  6393. #ifdef PCFONTS
  6394. /*
  6395.    If the user has loaded a font with SET TERMINAL FONT then we want
  6396.    to change the default code page to the font that was loaded.
  6397. */
  6398.     if (tt_font != TTF_ROM) {
  6399.     for (y = 0; y < ntermfont; y++ ) {
  6400.         if (term_font[y].kwval == tt_font) {
  6401.         s = term_font[y].kwd;
  6402.         break;
  6403.         }
  6404.     }
  6405.     }
  6406. #endif /* PCFONTS */
  6407. #else /* OS2 */
  6408. #ifdef COMMENT
  6409.     /* Hack not needed as of C-Kermit 7.1 */
  6410.     if (fcharset == FC_1LATIN) {
  6411.     s = "latin1-iso";        /* Hack to avoid reporting "cp1252" */
  6412.     } else {                /* Report current file character set */
  6413. #endif /* COMMENT */
  6414.     for (y = 0; y <= nfilc; y++)
  6415.       if (fcstab[y].kwval == fcharset) {
  6416.           s = fcstab[y].kwd;
  6417.           break;
  6418.       }
  6419. #ifdef COMMENT
  6420.     }
  6421. #endif /* COMMENT */
  6422. #endif /* OS2 */
  6423.     makestr(&dcsetname,s);        /* Return stable pointer */
  6424.     return((char *)dcsetname);
  6425. }
  6426. #endif /* NOCSETS */
  6427.  
  6428. #ifndef NOFRILLS
  6429. static int
  6430. doclear() {
  6431.     if ((x = cmkey(clrtab,nclear,"item to clear",
  6432. #ifdef NOSPL
  6433.            "device-buffer"
  6434. #else
  6435.            "device-and-input"
  6436. #endif /* NOSPL */
  6437.            ,xxstring)) < 0) return(x);
  6438. #ifndef NOSPL
  6439. #ifdef OS2
  6440.     if (x == CLR_CMD || x == CLR_TRM) {
  6441.     if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n",
  6442.                "all",xxstring)) < 0)
  6443.       return(z);
  6444.     }
  6445. #endif /* OS2 */
  6446. #endif /* NOSPL */
  6447.     if ((y = cmcfm()) < 0)
  6448.       return(y);
  6449.  
  6450.     /* Clear device input buffer if requested */
  6451.     y = (x & CLR_DEV) ? ttflui() : 0;
  6452.  
  6453.     if (x & CLR_SCR)            /* CLEAR SCREEN */
  6454.       y = ck_cls();            /* (= SCREEN CLEAR = CLS) */
  6455.  
  6456.     if (x & CLR_KBD) {            /* CLEAR KEYBOARD */
  6457.     int n;
  6458.     n = conchk();
  6459.     y = 0;
  6460.     while (n-- > 0 && (y = coninc(0) > -1))
  6461.       ;
  6462.     y = (y > -1) ? 0 : -1;
  6463.     }
  6464.  
  6465. #ifndef NOSPL
  6466.     /* Clear INPUT command buffer if requested */
  6467.     if (x & CLR_INP) {
  6468.     for (z = 0; z < inbufsize; z++)
  6469.       inpbuf[z] = NUL;
  6470.     inpbp = inpbuf;
  6471.     y = 0;
  6472.     }
  6473. #ifdef CK_APC
  6474.     if (x & CLR_APC) {
  6475.     debug(F101,"Executing CLEAR APC","",apcactive);
  6476.     apcactive = 0;
  6477.     y = 0;
  6478.     }
  6479. #endif /* CK_APC */
  6480.     if (x & CLR_ALR) {
  6481.     setalarm(0L);
  6482.     y = 0;
  6483.     }
  6484. #endif /* NOSPL */
  6485.  
  6486. #ifdef PATTERNS
  6487.     if (x & (CLR_TXT|CLR_BIN)) {
  6488.     int i;
  6489.     for (i = 0; i < FTPATTERNS; i++) {
  6490.         if (x & CLR_TXT)
  6491.           makestr(&txtpatterns[i],NULL);
  6492.         if (x & CLR_BIN)
  6493.           makestr(&binpatterns[i],NULL);
  6494.     }
  6495.     y = 0;
  6496.     }
  6497. #endif /* PATTERNS */
  6498.  
  6499. #ifndef NODIAL
  6500.     if (x & CLR_DIA) {
  6501.     dialsta = DIA_UNK;
  6502.     y = 0;
  6503.     }
  6504. #endif /* NODIAL */
  6505.  
  6506. #ifndef NOMSEND
  6507.     if (x & CLR_SFL) {            /* CLEAR SEND-LIST */
  6508.     if (filehead) {
  6509.         struct filelist * flp, * next;
  6510.         flp = filehead;
  6511.         while (flp) {
  6512.         if (flp->fl_name)
  6513.           free(flp->fl_name);
  6514.         if (flp->fl_alias)
  6515.           free(flp->fl_alias);
  6516.         next = flp->fl_next;
  6517.         free((char *)flp);
  6518.         flp = next;
  6519.         }
  6520.     }
  6521.     filesinlist = 0;
  6522.     filehead = NULL;
  6523.     filetail = NULL;
  6524.     addlist = 0;
  6525.     y = 0;
  6526.     }
  6527. #endif /* NOMSEND */
  6528.  
  6529. #ifdef OS2
  6530. #ifndef NOLOCAL
  6531.     switch (x) {
  6532.       case CLR_SCL:
  6533.     clearscrollback(VTERM);
  6534.     break;
  6535.       case CLR_CMD:
  6536.     switch ( z ) {
  6537.       case CLR_C_ALL:
  6538.         clear();
  6539.         break;
  6540.       case CLR_C_BOS:
  6541.         clrboscr_escape(VCMD,SP);
  6542.         break;
  6543.       case CLR_C_BOL:
  6544.         clrbol_escape(VCMD,SP);
  6545.         break;
  6546.       case CLR_C_EOL:
  6547.         clrtoeoln(VCMD,SP);
  6548.         break;
  6549.       case CLR_C_EOS:
  6550.         clreoscr_escape(VCMD,SP);
  6551.         break;
  6552.       case CLR_C_LIN:
  6553.         clrline_escape(VCMD,SP);
  6554.         break;
  6555.       case CLR_C_SCR:
  6556.         clearscrollback(VCMD);
  6557.         break;
  6558.     default:
  6559.         printf("Not implemented yet, sorry.\n");
  6560.         break;
  6561.     }
  6562.     break;
  6563.  
  6564. #ifndef NOTERM
  6565.       case CLR_TRM:
  6566.      switch ( z ) {
  6567.       case CLR_C_ALL:
  6568.          if (VscrnGetBufferSize(VTERM) > 0 ) {
  6569.          VscrnScroll(VTERM, UPWARD, 0,
  6570.                  VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1),
  6571.                  VscrnGetHeight(VTERM) -
  6572.                  (tt_status[VTERM]?1:0), TRUE, SP
  6573.                  );
  6574.          cleartermscreen(VTERM);
  6575.          }
  6576.          break;
  6577.       case CLR_C_BOS:
  6578.         clrboscr_escape(VTERM,SP);
  6579.         break;
  6580.       case CLR_C_BOL:
  6581.         clrbol_escape(VTERM,SP);
  6582.         break;
  6583.       case CLR_C_EOL:
  6584.         clrtoeoln(VTERM,SP);
  6585.         break;
  6586.       case CLR_C_EOS:
  6587.         clreoscr_escape(VTERM,SP);
  6588.         break;
  6589.       case CLR_C_LIN:
  6590.         clrline_escape(VTERM,SP);
  6591.         break;
  6592.      case CLR_C_SCR:
  6593.          clearscrollback(VTERM);
  6594.          break;
  6595.      default:
  6596.          printf("Not implemented yet, sorry.\n");
  6597.          break;
  6598.     }
  6599.     break;
  6600. #endif /* NOTERM */
  6601.     }
  6602.     y = 0;
  6603. #endif /* NOLOCAL */
  6604. #endif /* OS2 */
  6605.     return(success = (y == 0));
  6606. }
  6607. #endif /* NOFRILLS */
  6608.  
  6609. #ifndef NOSPL
  6610. static int
  6611. doeval(cx) int cx; {
  6612.     char *p;
  6613.     char vnambuf[VNAML], * vnp = NULL;    /* These must be on the stack */
  6614.     if (!oldeval) {
  6615.     if ((y = cmfld("Variable name","",&s,
  6616.                ((cx == XX_EVAL) ? xxstring : NULL))) < 0) {
  6617.         if (y == -3) {
  6618.         printf("?Variable name required\n");
  6619.         return(-9);
  6620.         } else return(y);
  6621.     }
  6622.     ckstrncpy(vnambuf,s,VNAML);    /* Make a copy. */
  6623.     vnp = vnambuf;
  6624.     if (vnambuf[0] == CMDQ &&
  6625.         (vnambuf[1] == '%' || vnambuf[1] == '&'))
  6626.       vnp++;
  6627.     y = 0;
  6628.     if (*vnp == '%' || *vnp == '&') {
  6629.         if ((y = parsevar(vnp,&x,&z)) < 0)
  6630.           return(y);
  6631.     }
  6632.     }
  6633.     if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0)
  6634.       return(x);
  6635.     p = evala(s);
  6636.     if (!p) p = "";
  6637.     if (oldeval && *p)
  6638.       printf("%s\n", p);
  6639.     ckstrncpy(evalbuf,p,32);
  6640.     if (!oldeval)
  6641.       return(success = addmac(vnambuf,p));
  6642.     else
  6643.       return(success = *p ? 1 : 0);
  6644. }
  6645. #endif /* NOSPL */
  6646.  
  6647. #ifdef TNCODE
  6648. static int
  6649. dotelopt() {
  6650.     if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 )
  6651.       return(x);
  6652.     switch (x) {
  6653.       case WILL:
  6654.       case WONT:
  6655.       case DO:
  6656.       case DONT:
  6657.     if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0)
  6658.       return(y);
  6659.     if ((z = cmcfm()) < 0) return(z);
  6660.  
  6661.     switch (x) {
  6662.       case WILL:
  6663.         if (TELOPT_UNANSWERED_WILL(y))
  6664.           return(success = 0);
  6665.         break;
  6666.       case WONT:
  6667.         if (TELOPT_UNANSWERED_WONT(y))
  6668.           return(success = 0);
  6669.         break;
  6670.       case DO:
  6671.         if (TELOPT_UNANSWERED_DO(y))
  6672.           return(success = 0);
  6673.         break;
  6674.       case DONT:
  6675.         if (TELOPT_UNANSWERED_DONT(y))
  6676.           return(success = 0);
  6677.         break;
  6678.     }
  6679.     if (local) {
  6680.         success = ((tn_sopt(x,y) > -1) ? 1 : 0);
  6681.     } else {
  6682.         printf("ff%02x%02x\n",x,y);
  6683.         success = 1;
  6684.     }
  6685.     if (success) {
  6686.         switch (x) {
  6687.           case WILL:
  6688.         TELOPT_UNANSWERED_WILL(y) = 1;
  6689.         break;
  6690.           case WONT:
  6691.         if ( TELOPT_ME(y) )
  6692.           TELOPT_UNANSWERED_WONT(y) = 1;
  6693.         break;
  6694.           case DO:
  6695.         TELOPT_UNANSWERED_DO(y) = 1;
  6696.         break;
  6697.           case DONT:
  6698.         if ( TELOPT_ME(y) )
  6699.           TELOPT_UNANSWERED_DONT(y) = 1;
  6700.         break;
  6701.         }
  6702.         if (tn_wait("XXTELOP") < 0) {
  6703.         tn_push();
  6704.         success = 0;
  6705.         }
  6706.     }
  6707.     return(success);
  6708.       case SB:
  6709.     if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0)
  6710.       return(y);
  6711.     switch (y) {
  6712.       case TELOPT_NAWS:
  6713.         /* Some compilers require switch() to have at least 1 case */
  6714. #ifdef CK_NAWS
  6715.         TELOPT_SB(TELOPT_NAWS).naws.x = 0;
  6716.         TELOPT_SB(TELOPT_NAWS).naws.y = 0;
  6717.         if (local)
  6718.           return(success = ((tn_snaws() > -1) ? 1 : 0));
  6719.         else
  6720.           return(success = 0);
  6721. #else
  6722.         return(success = 0);
  6723. #endif /* CK_NAWS */
  6724.     }
  6725.         return(success = 0);
  6726.  
  6727. #ifdef CK_KERBEROS
  6728. #ifdef KRB5
  6729.       case TN_FWD:
  6730.         success = (kerberos5_forward() == AUTH_SUCCESS);
  6731.         return(success);
  6732. #endif /* KRB5 */
  6733. #endif /* CK_KERBEROS */
  6734.  
  6735.       default:
  6736.     if ((z = cmcfm()) < 0) return(z);
  6737. #ifndef NOLOCAL
  6738.     if (local) {
  6739.         CHAR temp[3];
  6740.         if (network && IS_TELNET()) { /* TELNET */
  6741.         temp[0] = (CHAR) IAC;
  6742.         temp[1] = x;
  6743.         temp[2] = NUL;
  6744.         success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0);
  6745.         if (tn_deb || debses || deblog) {
  6746.             /* TN_MSG_LEN is in ckctel.h */
  6747.             ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL);
  6748.             debug(F101,tn_msg,"",x);
  6749.             if (debses || tn_deb) tn_debug(tn_msg);
  6750.         }
  6751.         return(success);
  6752.         }
  6753.             return(success = 0);
  6754.     } else {
  6755. #endif /* NOLOCAL */
  6756.         printf("ff%02x\n",x);
  6757.         return(success = 1);
  6758. #ifndef NOLOCAL
  6759.     }
  6760. #endif /* NOLOCAL */
  6761.     }
  6762. }
  6763. #endif /* TNCODE */
  6764.  
  6765.  
  6766. #ifndef NOPUSH
  6767. #ifndef NOFRILLS
  6768. static int
  6769. doedit() {
  6770. #ifdef OS2
  6771.     char * p = NULL;
  6772. #endif /* OS2 */
  6773.     if (!editor[0]) {
  6774.     s = getenv("EDITOR");
  6775.     if (s) ckstrncpy(editor,s,CKMAXPATH);
  6776.     editor[CKMAXPATH] = NUL;
  6777.     if (!editor[0]) {
  6778.         printf("?Editor not defined - use SET EDITOR to define\n");
  6779.         return(-9);
  6780.     }
  6781.     }
  6782.     ckstrncpy(tmpbuf,editfile,TMPBUFSIZ);
  6783. /*
  6784.   cmiofi() lets us parse the name of an existing file, or the name of
  6785.   a nonexistent file to be created.
  6786. */
  6787.     x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring);
  6788.     debug(F111,"edit",s,x);
  6789.     if (x < 0 && x != -3)
  6790.       return(x);
  6791.     if (x == -3) {
  6792.     tmpbuf[0] = NUL;
  6793.     } else {
  6794.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6795.     }
  6796.     if ((z = cmcfm()) < 0) return(z);
  6797.     if (y) {
  6798.     printf("?A single file please\n");
  6799.     return(-9);
  6800.     }
  6801.     if (nopush) {
  6802.     printf("?Sorry, editing not allowed\n");
  6803.     return(success = 0);
  6804.     }
  6805.     if (tmpbuf[0]) {
  6806.     /* Get full path in case we change directories between EDIT commands */
  6807.     zfnqfp(tmpbuf, CKMAXPATH, editfile);
  6808.     editfile[CKMAXPATH] = NUL;
  6809. #ifdef OS2
  6810.     p = editfile;            /* Flip the stupid slashes */
  6811.     while (*p) {
  6812.         if (*p == '/') *p = '\\';
  6813.         p++;
  6814.     }
  6815. #endif /* OS2 */
  6816.     } else
  6817.       editfile[0] = NUL;
  6818.     if (editfile[0]) {
  6819.     if (zchki(editfile) < (CK_OFF_T)0 && zchko(editfile) < 0) {
  6820.         printf("?Access denied: %s\n",editfile);
  6821.         return(-9);
  6822.     }
  6823.     }
  6824.     x = 0;
  6825.     if (editopts[0]) {
  6826. #ifdef OS2
  6827.     x = ckindex("%1",(char *)editopts,0,0,1);
  6828.     if (x > 0)
  6829.       editopts[x] = 's';
  6830.     else
  6831. #endif /* OS2 */
  6832.       x = ckindex("%s",(char *)editopts,0,0,1);
  6833.     }
  6834.     if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) {
  6835.     if (x)
  6836.       sprintf(tmpbuf,editopts,editfile);
  6837.     else
  6838.       sprintf(tmpbuf,"%s %s",editopts,editfile);
  6839.     }
  6840.     s = line;
  6841.     ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL);
  6842. #ifdef OS2
  6843.     p = s + strlen(editor);        /* And again with the slashes */
  6844.     while (p != s) {
  6845.     if (*p == '/') *p = '\\';
  6846.     p--;
  6847.     }
  6848. #endif /* OS2 */
  6849.     conres();
  6850.     x = zshcmd(s);
  6851.     concb((char)escape);
  6852.     return(x);
  6853. }
  6854. #endif /* NOFRILLS */
  6855. #endif /* NOPUSH */
  6856.  
  6857. #ifdef BROWSER
  6858. static int
  6859. dobrowse() {
  6860. #ifdef OS2
  6861.     char * p = NULL;
  6862. #endif /* OS2 */
  6863.     if (nopush) {
  6864.     printf("?Sorry, browsing not allowed\n");
  6865.     return(success = 0);
  6866.     }
  6867. #ifndef NT
  6868.     /* Windows lets the Shell Execute the URL if no Browser is defined */
  6869.     if (!browser[0]) {
  6870.     s = getenv("BROWSER");
  6871.     if (s) ckstrncpy(browser,s,CKMAXPATH);
  6872.     browser[CKMAXPATH] = NUL;
  6873.     if (!browser[0]) {
  6874.         printf("?Browser not defined - use SET BROWSER to define\n");
  6875.         return(-9);
  6876.     }
  6877.     }
  6878. #endif /* NT */
  6879.     ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ);
  6880.     if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0)
  6881.       return(x);
  6882.     ckstrncpy(browsurl,s,4096);
  6883.     x = 0;
  6884.     if (browsopts[0]) {
  6885. #ifdef OS2
  6886.     x = ckindex("%1",(char *)browsopts,0,0,1);
  6887.     if (x > 0)
  6888.       browsopts[x] = 's';
  6889.     else
  6890. #endif /* OS2 */
  6891.       x = ckindex("%s",(char *)browsopts,0,0,1);
  6892.     }
  6893.     if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) {
  6894.     if (x)
  6895.       sprintf(tmpbuf,browsopts,browsurl);
  6896.     else
  6897.       sprintf(tmpbuf,"%s %s",browsopts,browsurl);
  6898.     }
  6899. #ifdef NT
  6900.     if (!browser[0])
  6901.       return(success = Win32ShellExecute(browsurl));
  6902. #endif /* NT */
  6903.     s = line;
  6904.     ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL);
  6905. #ifdef OS2
  6906.     p = line + strlen(browser);        /* Flip slashes */
  6907.     while (p != line) {
  6908.     if (*p == '/') *p = '\\';
  6909.     p--;
  6910.     }
  6911. #endif /* OS2 */
  6912.     conres();
  6913.     x = zshcmd(s);
  6914.     concb((char)escape);
  6915.     return(x);
  6916. }
  6917. #endif /* BROWSER */
  6918.  
  6919. #ifdef CK_RECALL
  6920. static int
  6921. doredo() {            /* Find a previous cmd and redo it */
  6922.     extern int on_recall, in_recall;
  6923.     int x;
  6924.     char * p;
  6925.  
  6926.     if ((x = cmtxt(
  6927. "pattern, or first few characters of a previous command",
  6928.            "*",&s,xxstring)) < 0)
  6929.       return(x);
  6930.     ckstrncpy(line,s,LINBUFSIZ);
  6931.     x = strlen(s);
  6932.     s = line;
  6933.     if (*s == '{') {            /* Braces disable adding * to end */
  6934.     if (s[x-1] == '}') {
  6935.         s[x-1] = NUL;
  6936.         s++;
  6937.         x--;
  6938.     }
  6939.     } else {                /* No braces, add * to end. */
  6940.     s[x] = '*';
  6941.     s[x+1] = NUL;
  6942.     }
  6943.  
  6944.     while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL;
  6945.  
  6946.     if (!on_recall || !in_recall) {
  6947.     printf("?Sorry, command recall can't be used now.\n");
  6948.     return(-9);
  6949.     }
  6950.     if ((p = cmgetcmd(s))) {        /* Look for it history buffer */
  6951.     ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */
  6952.     if (!quiet)            /* Echo it */
  6953.       printf("%s\n",cmdbuf);
  6954.     cmaddnext();            /* Force re-add to history buffer */
  6955.     return(cmflgs = -1);        /* Force reparse */
  6956.     } else {
  6957.     printf("?Sorry - \"%s\" not found\n", s);
  6958.     return(-9);
  6959.     }
  6960. }
  6961. #endif /* CK_RECALL */
  6962.  
  6963. #ifndef NOXFER
  6964. #ifndef NOCSETS
  6965. static int
  6966. doassoc()  {                /* ASSOCIATE */
  6967.     extern struct keytab tcstab[];
  6968.     extern int ntcs;
  6969.     if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 )
  6970.       return(x);
  6971.  
  6972.     switch (x) {            /* Associate what? */
  6973.  
  6974.       case ASSOC_TC:            /* Transfer character-set... */
  6975.     if ((x = cmkey(tcstab, ntcs,
  6976.                "transfer character-set name","",xxstring)) < 0)
  6977.       return(x);
  6978.     if ((y = cmkey(fcstab, nfilc,
  6979.                "with file character-set","", xxstring)) < 0)
  6980.       if (y != -3)
  6981.         return(y);
  6982.     if ((z = cmcfm()) < 0)
  6983.       return(z);
  6984.     axcset[x] = y;
  6985.     return(success = 1);
  6986.  
  6987.       case ASSOC_FC:            /* File character-set... */
  6988.     if ((x = cmkey(fcstab, nfilc,
  6989.                "file character-set name","",xxstring)) < 0)
  6990.       return(x);
  6991.     if ((y = cmkey(tcstab, ntcs,
  6992.                "with transfer character-set","", xxstring)) < 0)
  6993.       if (y != -3)
  6994.         return(y);
  6995.     if ((z = cmcfm()) < 0)
  6996.       return(z);
  6997.     afcset[x] = y;
  6998.     return(success = 1);
  6999.  
  7000.       default:
  7001.     return(-2);
  7002.     }
  7003. }
  7004. #endif /* NOCSETS */
  7005. #endif /* NOXFER */
  7006.  
  7007. #ifndef NOHELP
  7008. static int
  7009. domanual() {
  7010. #ifdef OS2
  7011.     if ((x = cmcfm()) < 0)
  7012.       return(x);
  7013.     if (nopush) {
  7014.     printf("?Sorry, access to system commands is disabled.\n");
  7015.     return(-9);
  7016.     }
  7017.     y = mxlook(mactab,"manual",nmac);
  7018.     if (y > -1) {
  7019.     z = maclvl;            /* Save the current maclvl */
  7020.     dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  7021.     while (maclvl > z) {
  7022.         debug(F101,"XXMAN loop maclvl 1","",maclvl);
  7023.         sstate = (CHAR) parser(1);
  7024.         debug(F101,"XXMAN loop maclvl 2","",maclvl);
  7025.         if (sstate) proto();
  7026.     }
  7027.     debug(F101,"XXMAN loop exit maclvl","",maclvl);
  7028.     return(success);
  7029.     }
  7030.     return(success = 0);
  7031. #else
  7032.     if ((x = cmtxt(
  7033. #ifdef UNIX
  7034.            "Carriage return to confirm the command, or manual topic",
  7035. #else
  7036.            "Carriage return to confirm the command, or help topic",
  7037. #endif /* UNIX */
  7038.            "kermit",
  7039.            &s,
  7040.            xxstring
  7041.            )
  7042.      ) < 0)
  7043.       return(x);
  7044. #endif /* OS2 */
  7045.  
  7046. #ifdef UNIX
  7047.     ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL);
  7048. #else
  7049.     ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL);
  7050. #endif /* UNIX */
  7051.     debug(F110,"MANUAL",tmpbuf,0);
  7052.     if (nopush) {
  7053.     printf("?Sorry, access to system commands is disabled.\n");
  7054.     return(-9);
  7055.     } else {
  7056.     conres();            /* Restore the console */
  7057.     success = zshcmd(tmpbuf);
  7058.     concb((char)escape);        /* Restore CBREAK mode */
  7059.     return(success);
  7060.     }
  7061. }
  7062. #endif /* NOHELP */
  7063.  
  7064. #ifndef NOHTTP
  7065. #ifdef TCPSOCKET
  7066. static struct keytab sslswtab[] = {
  7067.     { "/ssl", 1, 0 },
  7068.     { "/tls", 1, 0 }
  7069. };
  7070.  
  7071. #ifndef NOURL
  7072. struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  7073. #endif /* NOURL */
  7074.  
  7075. static int
  7076. dohttp() {                /* HTTP */
  7077.     struct FDB sw, kw, fi;
  7078.     int n, getval, allinone = 0;
  7079.     char c, * p;
  7080.     char rdns[128];
  7081.  
  7082.     char * http_agent = NULL;        /* Parse results */
  7083.     char * http_hdr   = NULL;
  7084.     char * http_user  = NULL;
  7085.     char * http_pass  = NULL;
  7086.     char * http_mime  = NULL;
  7087.     char * http_lfile = NULL;
  7088.     char * http_rfile = NULL;
  7089.     char * http_dfile = NULL;
  7090.     char   http_array = NUL;
  7091.     int    http_action = -1;
  7092.  
  7093.     char * http_host = NULL;
  7094.     char * http_srv  = NULL;
  7095.     int    http_ssl  = 0;
  7096.  
  7097.     static char * http_d_agent = NULL;
  7098.     static char * http_d_user = NULL;
  7099.     static char * http_d_pass = NULL;
  7100.  
  7101.     static int    http_d_type = 0;
  7102.     int           http_type = http_d_type;
  7103.  
  7104. #ifdef OS2
  7105.     p = "Kermit 95";            /* Default user agent */
  7106. #else
  7107.     p = "C-Kermit";
  7108. #endif /* OS2 */
  7109.     makestr(&http_agent,p);
  7110.     makestr(&http_mime,"text/HTML");    /* MIME type default */
  7111.     rdns[0] = '\0';
  7112.  
  7113.     cmfdbi(&sw,                /* 1st FDB - general switches */
  7114.        _CMKEY,                /* fcode */
  7115.        "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */
  7116.        "",                /* default */
  7117.        "",                /* addtl string data */
  7118.        nhttpswtab,            /* addtl numeric data 1: tbl size */
  7119.        4,                /* addtl numeric data 2: 4 = cmswi */
  7120.        xxstring,            /* Processing function */
  7121.        httpswtab,            /* Keyword table */
  7122.        &kw                /* Pointer to next FDB */
  7123.        );
  7124.     cmfdbi(&kw,                /* 2nd FDB - commands */
  7125.        _CMKEY,                /* fcode */
  7126.        "Command",            /* hlpmsg */
  7127.        "",                /* default */
  7128.        "",                /* addtl string data */
  7129.        nhttptab,            /* addtl numeric data 1: tbl size */
  7130.        0,                /* addtl numeric data 2: 0 = keyword */
  7131.        xxstring,            /* Processing function */
  7132.        httptab,                /* Keyword table */
  7133.        NULL                /* Pointer to next FDB */
  7134.        );
  7135.  
  7136.     while (1) {
  7137.     x = cmfdb(&sw);            /* Parse something */
  7138.     if (x < 0)            /* Error */
  7139.       goto xhttp;
  7140.     n = cmresult.nresult;
  7141.     if (cmresult.fdbaddr == &kw)    /* Command - exit this loop */
  7142.       break;
  7143.     c = cmgbrk();            /* Switch... */
  7144.     getval = (c == ':' || c == '=');
  7145.     x = -9;
  7146.     if (getval && !(cmgkwflgs() & CM_ARG)) {
  7147.         printf("?This switch does not take an argument\n");
  7148.         goto xhttp;
  7149.     }
  7150.     switch (cmresult.nresult) {    /* Handle each switch */
  7151.           case HT_SW_TP:                /* /TOSCREEN */
  7152.             http_type = 1;
  7153.             break;
  7154.       case HT_SW_AG:        /* /AGENT */
  7155.         if (getval) {
  7156.         if ((x = cmfld("User agent",p,&s,xxstring)) < 0)
  7157.           goto xhttp;
  7158.         } else {
  7159.         s = p;
  7160.         }
  7161.         makestr(&http_agent,s);
  7162.         break;
  7163.       case HT_SW_HD:        /* /HEADER */
  7164.         s = NULL;
  7165.         if (getval) {
  7166.         if ((x = cmfld("Header line","",&s,xxstring)) < 0) {
  7167.             if (x == -3)
  7168.               s = NULL;
  7169.             else
  7170.               goto xhttp;
  7171.         }
  7172.         }
  7173.         makestr(&http_hdr,s);
  7174.         break;
  7175.       case HT_SW_US:        /* /USER */
  7176.         s = NULL;
  7177.         if (getval) {
  7178.         if ((x = cmfld("User ID","",&s,xxstring)) < 0) {
  7179.                   if (x == -3)
  7180.                     s = "";
  7181.                   else
  7182.             goto xhttp;
  7183.                 }
  7184.         }
  7185.         makestr(&http_user,s);
  7186.         break;
  7187.       case HT_SW_PW:        /* /PASSWORD */
  7188.         debok = 0;
  7189.         s = NULL;
  7190.         if (getval) {
  7191.         if ((x = cmfld("Password","",&s,xxstring)) < 0)
  7192.           goto xhttp;
  7193.         }
  7194.         makestr(&http_pass,s);
  7195.         break;
  7196. #ifndef NOSPL
  7197.       case HT_SW_AR: {        /* /ARRAY: */
  7198.           char * s2, array = NUL;
  7199.           if (!getval) {
  7200.           printf("?This switch requires an argument\n");
  7201.           x = -9;
  7202.           goto xhttp;
  7203.           }
  7204.           if ((x = cmfld("Array name (a single letter will do)",
  7205.                  "",
  7206.                  &s,
  7207.                  NULL
  7208.                  )) < 0) {
  7209.           if (x == -3) {
  7210.               printf("?Array name required\n");
  7211.               x = -9;
  7212.               goto xhttp;
  7213.           } else
  7214.             goto xhttp;
  7215.           }
  7216.           if (!*s) {
  7217.           printf("?Array name required\n");
  7218.           x = -9;
  7219.           goto xhttp;
  7220.           }
  7221.           s2 = s;
  7222.           if (*s == CMDQ) s++;
  7223.           if (*s == '&') s++;
  7224.           if (!isalpha(*s)) {
  7225.           printf("?Bad array name - \"%s\"\n",s2);
  7226.           x = -9;
  7227.           goto xhttp;
  7228.           }
  7229.           array = *s++;
  7230.           if (isupper(array))
  7231.         array = tolower(array);
  7232.           if (*s && (*s != '[' || *(s+1) != ']')) {
  7233.           printf("?Bad array name - \"%s\"\n",s2);
  7234.           http_array = NUL;
  7235.           x = -9;
  7236.           goto xhttp;
  7237.           }
  7238.           http_array = array;
  7239.           break;
  7240.       }
  7241. #endif /* NOSPL */
  7242.       default:
  7243.         x = -2;
  7244.         goto xhttp;
  7245.     }
  7246.     }
  7247.     http_action = n;            /* Save the action */
  7248.     if (http_action == HTTP_PUT || http_action == HTTP_POS) {
  7249.     cmfdbi(&sw,            /* 1st FDB - switch */
  7250.            _CMKEY,            /* fcode */
  7251.            "Local filename\n Or switch", /* help */
  7252.            "",            /* default */
  7253.            "",            /* addtl string data */
  7254.            nhttpptab,        /* keyword table size */
  7255.            4,            /* addtl numeric data 2: 4 = cmswi */
  7256.            xxstring,        /* Processing function */
  7257.            httpptab,        /* Keyword table */
  7258.            &fi            /* Pointer to next FDB */
  7259.            );
  7260.     cmfdbi(&fi,            /* 2nd FDB - filename */
  7261.            _CMIFI,            /* fcode */
  7262.            "Local filename",    /* hlpmsg */
  7263.            "",            /* default */
  7264.            "",            /* addtl string data */
  7265.            0,            /* addtl numeric data 1 */
  7266.            0,            /* addtl numeric data 2 */
  7267.            xxstring,
  7268.            NULL,
  7269.            NULL
  7270.            );
  7271.     while (1) {
  7272.         x = cmfdb(&sw);
  7273.         if (x < 0)
  7274.           goto xhttp;        /* Free any malloc'd temp strings */
  7275.         n = cmresult.nresult;
  7276.         if (cmresult.fcode != _CMKEY)
  7277.           break;
  7278.         c = cmgbrk();        /* Switch... */
  7279.         getval = (c == ':' || c == '=');
  7280.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  7281.         printf("?This switch does not take an argument\n");
  7282.         x = -9;
  7283.         goto xhttp;
  7284.         }
  7285.         switch (n) {
  7286.           case HT_PP_MT:
  7287.         s = "text/HTML";
  7288.         if (getval) {
  7289.             if ((x = cmfld("MIME type",
  7290.                    "text/HTML",&s,xxstring)) < 0)
  7291.               goto xhttp;
  7292.         }
  7293.         makestr(&http_mime,s);
  7294.         break;
  7295.           default:
  7296.         x = -2;
  7297.         goto xhttp;
  7298.         }
  7299.     }
  7300.     makestr(&http_lfile,cmresult.sresult);
  7301.     n = ckindex("/",http_lfile,-1,1,0);
  7302.     if (n)
  7303.       p = &http_lfile[n];
  7304.     else
  7305.       p = http_lfile;
  7306.     if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) {
  7307.           if (x == -3) {
  7308.             printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post");
  7309.             x = -9;
  7310.           }
  7311.           goto xhttp;
  7312.         }
  7313.     if (!*s) s = NULL;
  7314.     makestr(&http_rfile,s);
  7315.  
  7316.     if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) {
  7317.           if (x != -3)
  7318.             goto xhttp;
  7319.         }
  7320.         if (*s)
  7321.           makestr(&http_dfile,s);
  7322.     }
  7323.     switch (http_action) {
  7324.       case HTTP_DEL:            /* DELETE */
  7325.     if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7326.           if (x == -3) {
  7327.             printf("?Delete what?\n");
  7328.             x = -9;
  7329.           }
  7330.           goto xhttp;
  7331.         }
  7332.     makestr(&http_rfile,s);
  7333.     break;
  7334.       case HTTP_CON:            /* CONNECT */
  7335.         if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) {
  7336.           if (x == -3) {
  7337.             printf("?Remote host[:port] is required\n");
  7338.             x = -9;
  7339.           }
  7340.           goto xhttp;
  7341.         }
  7342.     makestr(&http_rfile,s);
  7343.     break;
  7344.       case HTTP_HED: {            /* HEAD */
  7345.       char buf[CKMAXPATH+1];
  7346.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7347.           if (x == -3) {
  7348.           printf("?Head of what?\n");
  7349.           x = -9;
  7350.           }
  7351.           goto xhttp;
  7352.       }
  7353.       makestr(&http_rfile,s);
  7354.  
  7355.       if (http_array || http_type) { /* Default result filename */
  7356.           p = "";             /* None if /ARRAY or /TOSCREEN */
  7357.       } else {
  7358.           n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */
  7359.           if (n)                          /* and add ".head" */
  7360.         p = &http_rfile[n];
  7361.           else
  7362.         p = http_rfile;
  7363.           ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL);
  7364.           p = buf;
  7365.       }
  7366.       if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) {
  7367.           if (x != -3)
  7368.         goto xhttp;
  7369.       }
  7370.       makestr(&http_lfile,s);
  7371.       break;
  7372.       }
  7373.       case HTTP_GET:            /* GET */
  7374.       case HTTP_IDX: {            /* INDEX */
  7375.       extern int wildena;
  7376.       int tmp;
  7377.       char * lfile = "";
  7378.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7379.           if (x == -3) {
  7380.           printf("?Get what?\n");
  7381.           x = -9;
  7382.           }
  7383.           goto xhttp;
  7384.       }
  7385.       makestr(&http_rfile,s);
  7386.       if (http_action == HTTP_GET && !http_type)
  7387.         zstrip(http_rfile,&lfile);
  7388.       /* URLs often contain question marks or other metacharacters */
  7389.       /* cmofi() doesn't like them */
  7390.       tmp = wildena;
  7391.       wildena = 0;
  7392.       if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0) {
  7393.           wildena = tmp;
  7394.           if (x != -3)
  7395.         goto xhttp;
  7396.       }
  7397.       wildena = tmp;
  7398.       makestr(&http_lfile,s);
  7399.       break;
  7400.       }
  7401.       case HTTP_OPN: {
  7402.       int sslswitch = 0;
  7403. #ifdef CK_SSL
  7404.       struct FDB sw, fl;
  7405.       cmfdbi(&sw,
  7406.          _CMKEY,        /* fcode */
  7407.          "IP host name or address, or switch", /* hlpmsg */
  7408.          "",            /* default */
  7409.          "",            /* addtl string data */
  7410.          2,            /* addtl numeric data 1: tbl size */
  7411.          4,            /* addtl numeric data 2: 4 = cmswi */
  7412.          xxstring,        /* Processing function */
  7413.          sslswtab,        /* Keyword table */
  7414.          &fl            /* Pointer to next FDB */
  7415.          );
  7416.       cmfdbi(&fl,            /* 2nd FDB - host */
  7417.          _CMFLD,        /* fcode */
  7418.          "",            /* hlpmsg */
  7419.          "",            /* default */
  7420.          "",            /* addtl string data */
  7421.          0,            /* addtl numeric data 1 */
  7422.          0,            /* addtl numeric data 2 */
  7423.          xxstring,
  7424.          NULL,
  7425.          NULL
  7426.          );
  7427.       x = cmfdb(&sw);        /* Parse switch or host */
  7428.       if (x < 0)            /* Error */
  7429.         goto xhttp;
  7430.       if (cmresult.fcode == _CMFLD) { /* Host */
  7431.           s = cmresult.sresult;      /* Set up expected pointer */
  7432.           goto havehost;              /* Go parse rest of command */
  7433.       }
  7434.       sslswitch = 1;        /* /SSL or /TLS switch - set flag */
  7435. #endif /* CK_SSL */
  7436.  
  7437.       /* Parse host */
  7438.  
  7439.       if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) {
  7440.           if (x == -3) {
  7441.           printf("?Open what?\n");
  7442.           x = -9;
  7443.           }
  7444.           goto xhttp;
  7445.       }
  7446.  
  7447.     havehost:            /* Come here with s -> host */
  7448. #ifdef CK_URL
  7449.       x = urlparse(s,&http_url);    /* Was a URL given? */
  7450.       if (x < 1) {            /* Not a URL */
  7451. #endif /* CK_URL */
  7452.           makestr(&http_host,s);
  7453.           if ((x =
  7454.            cmfld("Service name or port number",
  7455.              sslswitch ? "https" : "http",&s,xxstring)) < 0)
  7456.         goto xhttp;
  7457.           else
  7458.         makestr(&http_srv,s);
  7459. #ifdef CK_URL
  7460.       } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */
  7461.              ckstrcmp(http_url.svc,"https",-1,0)) {
  7462.           printf("?Non-HTTP URL\n");
  7463.           x = -9;
  7464.           goto xhttp;
  7465.       } else {            /* Have HTTP URL */
  7466.           makestr(&http_srv, http_url.svc);
  7467.           makestr(&http_user,http_url.usr);
  7468.           makestr(&http_pass,http_url.psw);
  7469.           makestr(&http_host,http_url.hos);
  7470.           if (http_url.por)
  7471.         makestr(&http_srv,http_url.por);
  7472.           makestr(&http_rfile,http_url.pth);
  7473.       }
  7474.       if (http_rfile) {        /* Open, GET, and Close */
  7475.           printf("?Directory/file path not allowed in HTTP OPEN URL\n");
  7476.           x = -9;
  7477.           goto xhttp;
  7478.       }
  7479.       if (!ckstrcmp("https",http_srv,-1,0) || sslswitch ||
  7480.           !ckstrcmp("443",http_srv,-1,0))
  7481.         http_ssl = 1;
  7482. #endif /* CK_URL */
  7483.       break;
  7484.       }
  7485.       case HTTP_CLS:
  7486.         break;
  7487.     }
  7488.     if ((x = cmcfm()) < 0)
  7489.       goto xhttp;
  7490.  
  7491.     if (http_action == HTTP_OPN) {
  7492.         x = (http_open(http_host,http_srv,http_ssl,rdns,128,http_agent) == 0);
  7493.         if (x) {
  7494.             if (!quiet) {
  7495.               if (rdns[0])
  7496.                 printf("Connected to %s [%s]\r\n",http_host,rdns);
  7497.               else
  7498.                 printf("Connected to %s\r\n",http_host);
  7499.             }
  7500.             if (http_agent) {
  7501.                 if (http_d_agent)
  7502.           free(http_d_agent);
  7503.                 http_d_agent = http_agent;
  7504.                 http_agent = NULL;
  7505.             }
  7506.             if (http_user) {
  7507.                 if (http_d_user)
  7508.           free(http_d_user);
  7509.                 http_d_user = http_user;
  7510.                 http_user = NULL;
  7511.             }
  7512.             if (http_pass) {
  7513.                 if (http_d_pass) {
  7514.                     memset(http_d_pass,0,strlen(http_d_pass));
  7515.                     free(http_d_pass);
  7516.                 }
  7517.                 http_d_pass = http_pass;
  7518.                 http_pass = NULL;
  7519.             }
  7520.             http_d_type = http_type;
  7521.         } else {
  7522.             if (!quiet)
  7523.           printf("?HTTP Connection failed.\r\n");
  7524.         }
  7525.     } else if (http_action == HTTP_CLS) {
  7526.         if (http_d_agent) {
  7527.             free(http_d_agent);
  7528.             http_d_agent = NULL;
  7529.         }
  7530.         if (http_d_user) {
  7531.             free(http_d_user);
  7532.             http_d_user = NULL;
  7533.         }
  7534.         if (http_d_pass) {
  7535.             memset(http_d_pass,0,strlen(http_d_pass));
  7536.             free(http_d_pass);
  7537.             http_d_pass = NULL;
  7538.         }
  7539.         http_d_type = 0;
  7540.         x = (http_close() == 0);
  7541.     }
  7542.     if ((http_action != HTTP_CLS) &&
  7543.     (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */
  7544.  
  7545.     /* All-in-one actions when a URL is given... */
  7546.  
  7547. #ifdef CK_URL
  7548.     if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */
  7549.         if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */
  7550.         ckstrcmp(http_url.svc,"https",-1,0)) {
  7551.         printf("?Non-HTTP URL\n");
  7552.         x = -9;
  7553.         goto xhttp;
  7554.         } else {            /* Yes, collect the pieces */
  7555.         makestr(&http_srv, http_url.svc);
  7556.         makestr(&http_user,http_url.usr);
  7557.         makestr(&http_pass,http_url.psw);
  7558.         makestr(&http_host,http_url.hos);
  7559.         if (http_url.por)
  7560.           makestr(&http_srv,http_url.por);
  7561.         makestr(&http_rfile,http_url.pth);
  7562.         }
  7563.         if (!http_rfile) {        /* Still have a path? */
  7564.                 makestr(&http_rfile,"/");
  7565.         }
  7566.         if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */
  7567.         !ckstrcmp("443",http_srv,-1,0))
  7568.           http_ssl = 1;
  7569.         if (http_isconnected())    /* Close any open HTTP connection */
  7570.           http_close();
  7571.         if (http_pass == NULL && http_d_pass != NULL)
  7572.           makestr(&http_pass,http_d_pass);
  7573.         x = (http_open(http_host,
  7574.                http_srv,http_ssl,rdns,128,http_d_agent) == 0);
  7575.         if (x < 0) {
  7576.         x = 0;
  7577.         goto xhttp;
  7578.         }
  7579.         allinone = 1;
  7580.     }
  7581. #endif /* CK_URL */
  7582.         if (http_pass == NULL && http_d_pass != NULL)
  7583.       makestr(&http_pass,http_d_pass);
  7584.  
  7585.     if (http_action == HTTP_OPN && allinone) {
  7586.         http_action = HTTP_GET;
  7587.     }
  7588.         x = xdohttp(http_action,
  7589.                     http_lfile,
  7590.             http_rfile,
  7591.                     http_dfile,
  7592.             http_agent ? http_agent : http_d_agent,
  7593.             http_hdr,
  7594.             http_user  ? http_user  : http_d_user,
  7595.             http_pass  ? http_pass  : http_d_pass,
  7596.             http_mime,
  7597.             http_array,
  7598.             http_type
  7599.             );
  7600.     if (allinone)
  7601.       x = (http_close() == 0);
  7602.     }
  7603.  
  7604.   xhttp:
  7605.     if (http_agent) free(http_agent);
  7606.     if (http_hdr)   free(http_hdr);
  7607.     if (http_user)  free(http_user);
  7608.     if (http_pass) {
  7609.         memset(http_pass,0,strlen(http_pass));
  7610.         free(http_pass);
  7611.     }
  7612.     if (http_mime)  free(http_mime);
  7613.     if (http_lfile) free(http_lfile);
  7614.     if (http_rfile) free(http_rfile);
  7615.     if (http_dfile) free(http_dfile);
  7616.     if (http_host)  free(http_host);
  7617.     if (http_srv)   free(http_srv);
  7618.  
  7619.     if (x > -1)
  7620.       success = x;
  7621.     return(x);
  7622. }
  7623. #endif /* TCPSOCKET */
  7624. #endif /* NOHTTP */
  7625.  
  7626.  
  7627. #ifndef NOSPL
  7628. static int
  7629. dotrace() {
  7630.     int on = 1;
  7631.     struct FDB sw, kw;
  7632.     cmfdbi(&sw,                /* 1st FDB - switch */
  7633.        _CMKEY,            /* fcode */
  7634.        "Trace object;\n Or switch", /* help */
  7635.        "",                /* default */
  7636.        "",                /* addtl string data */
  7637.        2,                /* keyword table size */
  7638.        4,                /* addtl numeric data 2: 4 = cmswi */
  7639.        xxstring,            /* Processing function */
  7640.        onoffsw,            /* Keyword table */
  7641.        &kw                /* Pointer to next FDB */
  7642.        );
  7643.     cmfdbi(&kw,                /* 2nd FDB - Trace object */
  7644.        _CMKEY,            /* fcode */
  7645.        "Trace object",        /* help */
  7646.        "all",            /* default */
  7647.        "",                /* addtl string data */
  7648.        ntracetab,            /* keyword table size */
  7649.        0,                /* addtl numeric data 2: 0 = keyword */
  7650.        xxstring,            /* Processing function */
  7651.        tracetab,            /* Keyword table */
  7652.        NULL                /* Pointer to next FDB */
  7653.        );
  7654.     if ((x = cmfdb(&sw)) < 0)
  7655.       return(x);
  7656.     if (cmresult.fdbaddr == &sw) {
  7657.     on = cmresult.nresult;
  7658.     if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0)
  7659.       return(x);
  7660.     } else {
  7661.     x = cmresult.nresult;
  7662.     }
  7663.     if ((y = cmcfm()) < 0)
  7664.       return(y);
  7665.  
  7666.     switch (x) {
  7667.       case TRA_ASG:
  7668.     tra_asg = on;
  7669.     break;
  7670.       case TRA_CMD:
  7671.     tra_cmd = on;
  7672.     break;
  7673.       case TRA_ALL:
  7674.     tra_asg = on;
  7675.     tra_cmd = on;
  7676.     break;
  7677.       default:
  7678.     return(-2);
  7679.     }
  7680.     printf("TRACE %s\n", on ? "ON" : "OFF");
  7681.     return(success = 1);
  7682. }
  7683. #endif /* NOSPL */
  7684.  
  7685.  
  7686. static int
  7687. doprompt() {
  7688.     extern int xcmdsrc;
  7689.     if ((x = cmtxt("Optional message","",&s,xxstring)) < 0)
  7690.       return(x);
  7691. #ifdef NOSPL
  7692.     printf("?Sorry, PROMPT requires script programming language\n");
  7693.     return(-9);
  7694. #else
  7695.     debug(F101,"Prompt cmdlvl","",cmdlvl);
  7696.     cmdlvl++;
  7697.     if (cmdlvl > CMDSTKL) {
  7698.     printf("?Command stack overflow: %d\n",cmdlvl);
  7699.     cmdlvl--;
  7700.     return(-9);
  7701.     }
  7702.     xcmdsrc = CMD_KB;
  7703.     cmdstk[cmdlvl].src = CMD_KB;    /* Say we're at the prompt */
  7704.     cmdstk[cmdlvl].lvl = 0;
  7705.     cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs;
  7706.     if (tra_cmd)
  7707.       printf("[%d] +P: \"(prompt)\"\n",cmdlvl);
  7708.     concb((char)escape);
  7709.     if (!quiet)
  7710.       printf(
  7711. "(Recursive command prompt: Resume script with CONTINUE, STOP to stop...)\n"
  7712.             );
  7713.     if (*s) {                /* If prompt given */
  7714.     makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */
  7715.     cmsetp(s);            /* Set new one */
  7716.     }
  7717.     return(success = 1);
  7718. #endif /* NOSPL */
  7719. }
  7720.  
  7721. #ifdef CKLEARN
  7722. VOID
  7723. learncmd(s) char *s; {            /* Record commands in learned script */
  7724.     char buf[64];
  7725.     int i, k;
  7726.     if (learnfp && learning) {        /* Only if open and on */
  7727.     k = ckstrncpy(buf,s,64);
  7728.     for (i = 0; i < k; i++) {    /* Get top-level command keyword */
  7729.         if (buf[i] <= SP) {
  7730.         buf[i] = NUL;
  7731.         break;
  7732.         }
  7733.     }
  7734.     k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */
  7735.     if (k == XXCON || k == XXLEARN)      /* Don't record CONNECT or LEARN */
  7736.       return;
  7737.     if (k == XXTEL) {
  7738.         fputs("SET HOST /NETWORK:TCP",learnfp);
  7739.         fputs(&s[i],learnfp);
  7740.         fputs(" TELNET /TELNET",learnfp);
  7741.         fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp);
  7742.     } else {
  7743.         fputs(s,learnfp);
  7744.         fputs("\n",learnfp);
  7745.     }
  7746.     }
  7747. }
  7748. #endif /* CKLEARN */
  7749.  
  7750.  
  7751. /*  D O C M D  --  Do a command  */
  7752.  
  7753. /*
  7754.  Returns:
  7755.    -2: user typed an illegal command
  7756.    -1: reparse needed
  7757.     0: parse was successful (even tho command may have failed).
  7758. */
  7759. #ifdef DEBUG
  7760. int cmdstats[256] = { -1, -1 };
  7761. #endif /* DEBUG */
  7762.  
  7763. int
  7764. docmd(cx) int cx; {
  7765.     extern int nolocal, cmkwflgs;
  7766.  
  7767.     debug(F101,"docmd entry, cx","",cx);
  7768.     activecmd = cx;
  7769.     doconx = ((activecmd == XXCON)  || (activecmd == XXTEL) ||
  7770.           (activecmd == XXRLOG) || (activecmd == XXPIPE) ||
  7771.               (activecmd == XXIKSD) || (activecmd == XXPTY));
  7772. /*
  7773.   Originally all commands were handled with a big switch() statement,
  7774.   but eventually this started blowing up compilers.  Now we have a series
  7775.   of separate if statements and small switches, with the commands that are
  7776.   most commonly executed in scipts and loops coming first, to speed up
  7777.   compute-bound scripts.
  7778.   */
  7779.  
  7780. #ifdef DEBUG
  7781.     if (cmdstats[0] == -1) {        /* Count commands */
  7782.     int i;                /* for tuning... */
  7783.     for (i = 0; i < 256; i++)
  7784.       cmdstats[i] = 0;
  7785.     }
  7786. #endif /* DEBUG */
  7787.  
  7788.     switch (cx) {
  7789.       case -4:                /* EOF */
  7790. #ifdef OSK
  7791.     if (msgflg)  printf("\n");
  7792. #else
  7793.     if (msgflg)  printf("\r\n");
  7794. #endif /* OSK */
  7795.       doexit(GOOD_EXIT,xitsta);
  7796.       case -3:                /* Null command */
  7797.     return(0);
  7798.       case -9:                /* Like -2, but errmsg already done */
  7799.       case -1:                /* Reparse needed */
  7800.     return(cx);
  7801.       case -6:                /* Special */
  7802.       case -2:                /* Error, maybe */
  7803.  
  7804. #ifndef NOSPL
  7805. /*
  7806.   Maybe they typed a macro name.  Let's look it up and see.
  7807. */
  7808.     if (cx == -6)            /* If they typed CR */
  7809.       ckstrncat(cmdbuf,"\015",CMDBL); /*  add it back to command buffer. */
  7810.     if (ifcmd[cmdlvl] == 2)        /* Watch out for IF commands. */
  7811.       ifcmd[cmdlvl]--;
  7812.     repars = 1;            /* Force reparse */
  7813.     cmres();
  7814.     cx = XXDO;            /* Try DO command */
  7815. #else
  7816.     return(cx);
  7817. #endif /* NOSPL */
  7818.       default:
  7819.     if (cx < 0)
  7820.       return(cx);
  7821.     break;
  7822.     }
  7823. #ifdef DEBUG
  7824.     if (cx < 256)
  7825.       cmdstats[cx]++;
  7826. #endif /* DEBUG */
  7827.  
  7828.     if ((cmkwflgs & CM_PSH)
  7829. #ifndef NOPUSH
  7830.     && nopush
  7831. #endif /* NOPUSH */
  7832.     ) {
  7833.     printf("?Access to system disabled\n");
  7834.     return(-9);
  7835.     }
  7836.     if ((cmkwflgs & CM_LOC)
  7837. #ifndef NOLOCAL
  7838.     && nolocal
  7839. #endif /* NOLOCAL */
  7840.     ) {
  7841.     printf("?Connections disabled\n");
  7842.     return(-9);
  7843.     }
  7844.  
  7845. #ifndef NOSPL
  7846.     /* Used in FOR loops */
  7847.  
  7848.     if (cx == XX_INCR || cx == XXINC  || /* _INCREMENT, INCREMENT */
  7849.     cx == XX_DECR || cx == XXDEC)     /* _DECREMENT, DECREMENT */
  7850.       return(doincr(cx));
  7851.  
  7852.     /* Define (or change the definition of) a macro or variable */
  7853.  
  7854.     if (cx == XXUNDEF || cx == XXUNDFX) {
  7855. #ifdef IKSD
  7856.     if (inserver && !ENABLED(en_asg)) {
  7857.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7858.         return(-9);
  7859.     }
  7860. #endif /* IKSD */
  7861.     return(doundef(cx));        /* [_]UNDEFINE */
  7862.     }
  7863.     if (cx == XXDEF || cx == XXASS ||
  7864.     cx == XXDFX || cx == XXASX) {
  7865. #ifdef IKSD
  7866.     if (inserver && !ENABLED(en_asg)) {
  7867.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7868.         return(-9);
  7869.     }
  7870. #endif /* IKSD */
  7871.     if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */
  7872.       xxdot = 1;            /* i.e. with space after it... */
  7873.     return(dodef(cx));        /* DEFINE, ASSIGN, etc... */
  7874.     }
  7875.  
  7876.     /* IF, WHILE, and friends  */
  7877.  
  7878.     if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) {
  7879.     return(doif(cx));
  7880.     }
  7881.     if (cx == XXSWIT) {            /* SWITCH */
  7882.     return(doswitch());
  7883.     }
  7884.  
  7885.     /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */
  7886.  
  7887.     if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */
  7888.     /* Note, here we don't set SUCCESS/FAILURE flag */
  7889. #ifdef COMMENT
  7890.     if ((y = cmfld("label","",&s,xxstring)) < 0) {
  7891.         if (y == -3) {
  7892.         if (cx != XXXFWD) {
  7893.             printf("?Label name required\n");
  7894.             return(-9);
  7895.         }
  7896.         } else
  7897.           return(y);
  7898.     }
  7899.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  7900.     if ((x = cmcfm()) < 0) return(x);
  7901. #else
  7902.     if ((y = cmtxt("label","",&s,xxstring)) < 0) {
  7903.         if (y == -3) {
  7904.         if (cx != XXXFWD) {
  7905.             printf("?GOTO: Label name required: \"%s\" \"%s\"\n",
  7906.                atmbuf,
  7907.                cmdbuf);
  7908.             return(-9);
  7909.         }
  7910.         } else
  7911.           return(y);
  7912.     }
  7913.     ckstrncpy(tmpbuf,brstrip(s),TMPBUFSIZ);
  7914. #endif /* COMMENT */
  7915.     s = tmpbuf;
  7916.     debug(F111,"GOTO target",s,cx);
  7917.     return(dogoto(s,cx));
  7918.     }
  7919.     if (cx == XXDO || cx == XXMACRO) {    /* DO (a macro) */
  7920.     char mnamebuf[16];        /* (buffer for controlled temp name) */
  7921.     struct FDB kw, fl;
  7922.     int mx;                /* Macro index (on stack!) */
  7923.  
  7924.     debug(F101,"XXMACRO 0",line,cx);
  7925.     if (cx == XXDO) {
  7926.         if (nmac == 0) {
  7927.         printf("\n?No macros defined\n");
  7928.         return(-9);
  7929.         }
  7930.         for (y = 0; y < nmac; y++) { /* copy the macro table into a */
  7931.         mackey[y].kwd = mactab[y].kwd; /* regular keyword table */
  7932.         mackey[y].kwval = y;    /* with value = pointer to macro tbl */
  7933.         mackey[y].flgs = mactab[y].flgs;
  7934.         }
  7935.         cmfdbi(&kw,            /* First FDB - macro name */
  7936.            _CMKEY,        /* fcode */
  7937.            "Macro",        /* hlpmsg */
  7938.            "",            /* default */
  7939.            "",            /* addtl string data */
  7940.            nmac,        /* addtl numeric data 1: tbl size */
  7941.            0,            /* addtl numeric data 2: 0 = cmkey */
  7942.            xxstring,        /* Processing function */
  7943.            mackey,        /* Keyword table */
  7944.            &fl            /* Pointer to next FDB */
  7945.            );
  7946.         cmfdbi(&fl,            /* 2nd FDB - for "{" */
  7947.            _CMFLD,        /* fcode */
  7948.            "",            /* hlpmsg */
  7949.            "",
  7950.            "",            /* addtl string data */
  7951.            0,            /* addtl numeric data 1 */
  7952.            0,            /* addtl numeric data 2 */
  7953.            xxstring,
  7954.            NULL,
  7955.            NULL
  7956.            );
  7957.         x = cmfdb(&kw);        /* Parse something */
  7958.         if (x < 0) {        /* Error */
  7959.         if (x == -3) {
  7960.             printf("?Macro name required\n");
  7961.             return(-9);
  7962.         } else
  7963.           return(x);
  7964.         }
  7965.         if (cmresult.fcode == _CMKEY) {
  7966.         extern int mtchanged;
  7967.         char * macroname = NULL;
  7968.  
  7969.         /* In case args include an \fexec() that changes the macro table */
  7970.  
  7971.         mx = x;            /* Save macro index on stack */
  7972.         mtchanged = 0;        /* Mark state of macro table */
  7973.         makestr(¯oname,mactab[mx].kwd); /* Save name */
  7974.  
  7975.         if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0)
  7976.           return(y);        /* Get macro args */
  7977.  
  7978.         if (mtchanged) {    /* Macro table changed? */
  7979.             mx = mlook(mactab,macroname,nmac); /* Look up name again */
  7980.         }
  7981.         if (macroname)
  7982.           free(macroname);
  7983.  
  7984.         return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ?
  7985.                (success = 0) : 1);
  7986.         }
  7987.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);    /* _CMFLD */
  7988.         if (atmbuf[0] == '{') {
  7989.         if ((y = cmcfm()) < 0)
  7990.           return(y);
  7991.         }
  7992.     } else {            /* XXMACRO ("immediate macro") */
  7993.         int k = 0;
  7994.         line[k++] = '{';
  7995.         line[k++] = SP;
  7996.         line[k] = NUL;
  7997.         debug(F111,"XXMACRO A",line,k);
  7998.         if ((y = cmtxt("Braced list of commands","",&s,xxstring)) < 0)
  7999.           return(y);
  8000.         k = ckstrncpy(line+k,s,LINBUFSIZ-k);
  8001.         debug(F111,"XXMACRO B",line,k);
  8002.     }
  8003.     x = strlen(line);
  8004.     if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
  8005.       return(-2);
  8006.     if (line[0] != '{' && line[x-1] != '}') {
  8007.         /* Unknown command.  If ON_UNKNOWN_COMMAND macro is defined, */
  8008.         /* parse args and then execute it, but only if it is not */
  8009.         /* already active. */
  8010.         int k = -1;
  8011.         if (!unkmacro) {
  8012.         k = mxlook(mactab,"on_unknown_command",nmac);
  8013.         }
  8014.         if (k > -1) {
  8015.         ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  8016.         z = maclvl;        /* Save the current maclvl */
  8017.         if ((y = cmtxt("text","",&s,xxstring)) < 0)
  8018.           return(y);
  8019.         ckstrncat(tmpbuf," ",TMPBUFSIZ);
  8020.         ckstrncat(tmpbuf,s,TMPBUFSIZ);
  8021.         unkmacro = 1;
  8022.         debug(F110,"ON_UNKNOWN_COMMAND",s,0);
  8023.         dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  8024.         while (maclvl > z) {
  8025.             sstate = (CHAR) parser(1);
  8026.             if (sstate) proto();
  8027.         }
  8028.         debug(F101,"UNKMAC loop exit maclvl","",maclvl);
  8029.         unkmacro = 0;
  8030.         return(success);
  8031.         }
  8032.             if (x > 0)
  8033.           printf("?Not a command or macro name: \"%s\"\n",line);
  8034.             else
  8035.           printf("?Not a command or macro name.\n");
  8036.         return(-9);
  8037.     }
  8038.     s = brstrip(line);
  8039.     sprintf(mnamebuf," ..tmp:%03d",cmdlvl);    /* safe (16) */
  8040.     x = addmac(mnamebuf,s);
  8041.     return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
  8042.     }
  8043.  
  8044.     if (cx == XXLBL) {            /* LABEL */
  8045.     if ((x = cmfld("label","",&s,xxstring)) < 0) {
  8046.         if (x == -3) {
  8047. #ifdef COMMENT
  8048.         printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
  8049.         return(-9);
  8050. #else
  8051.         s = "";
  8052. #endif /* COMMENT */
  8053.         } else return(x);
  8054.  
  8055.     }
  8056.     debug(F111,"LABEL",s,x);
  8057.     if ((x = cmcfm()) < 0) return(x);
  8058.     return(0);
  8059.     }
  8060.  
  8061.     if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE,  EVALUATE  */
  8062.       return(doeval(cx));
  8063.  
  8064. #ifndef NOSEXP
  8065.     if (cx == XXSEXP) {            /* Lisp-like S-Expression */
  8066.     struct stringarray * q;
  8067.     char /* *p, *r, */ *tmp, *m;
  8068.     int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
  8069.     extern int sexprc, sexppv;
  8070.  
  8071.     tmp = tmpbuf;            /* Buffer to collect SEXP */
  8072.     tmpbuf[0] = NUL;        /* Clear it */
  8073.     size = TMPBUFSIZ;        /* Capacity of buffer */
  8074.     sexprc = -1;            /* Assume bad input */
  8075.     n = 0;                /* Paren balance counter */
  8076.  
  8077.     while (1) {            /* Allow SEXP on multiple lines */
  8078.         m = contd ?
  8079.           "Continuation of S-Expression" :
  8080.         "S-Expression (\"help sexp\" for details)";
  8081.         x = cmtxt(m,"",&s,xxstring);
  8082.         if (x < 0)
  8083.           return(x);
  8084.         if (!*s)            /* Needed for (=) and (:) */
  8085.           s = atmbuf;
  8086.         k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
  8087.         if (k < 1) {
  8088.         printf("?SEXP too long - %d max\n",TMPBUFSIZ);
  8089.         return(-9);
  8090.         }
  8091.         debug(F111,contd ? "sexp contd" : "sexp",s,k);
  8092.  
  8093.         for (i = len; i < len+k; i++) { /* Check balance  */
  8094.         if (!quote && tmpbuf[i] == CMDQ) {
  8095.             quote = 1;
  8096.             continue;
  8097.         }
  8098.         if (quote) {
  8099.             quote = 0;
  8100.             continue;
  8101.         }
  8102.         if (tmpbuf[i] == '(')
  8103.           n++;
  8104.         else if (tmpbuf[i] == ')')
  8105.           n--;
  8106.         }
  8107.         if (n == 0) {        /* Break when balanced */
  8108.         break;
  8109.         }
  8110.         if (n < 0) {        /* Too many right parens */
  8111.         printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
  8112.         return(-9);
  8113.         }
  8114.         contd++;            /* Need more right parens */
  8115.         cmini(ckxech);        /* so keep parsing */
  8116.         tmp += k;            /* adjust buffer pointer */
  8117.         size -= k;            /* and capacity */
  8118.         len += k;            /* and length so far */
  8119.     }
  8120.     s = tmpbuf;
  8121.     makestr(&lastsexp,s);
  8122.     q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */
  8123.     debug(F101,"sexp split","",q->a_size);
  8124.  
  8125.     if (q->a_size == 1) {        /* We should get exactly one back */
  8126.         char * result, * dosexp();
  8127.         sexprc = 0;            /* Reset out-of-band return code */
  8128.         result = dosexp(s);        /* Get result */
  8129.         debug(F111,"sexp result",result,sexprc);
  8130.         if (sexprc == 0) {        /* Success */
  8131.         /* Echo the result if desired */
  8132.         if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
  8133.           printf(" %s\n",result ? result : "");
  8134.         makestr(&sexpval,result);
  8135.         success = sexppv > -1 ? sexppv : 1;
  8136.         return(success);
  8137.         }
  8138.     }
  8139.     if (sexprc < 0)
  8140.       printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
  8141.     return(-9);
  8142.     }
  8143. #endif /* NOSEXP */
  8144.  
  8145. #endif /* NOSPL */
  8146.  
  8147.     if (cx == XXECH || cx == XXXECH || cx == XXVOID
  8148. #ifndef NOSPL
  8149.     || cx == XXAPC
  8150. #endif /* NOSPL */
  8151.     ) {                /* ECHO or APC */
  8152.     if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
  8153.                "Text to be echoed" :
  8154.                ((cx == XXVOID) ? "Text" :
  8155.             "Application Program Command text"),
  8156.                "",
  8157.                &s,
  8158.                xxstring
  8159.                )
  8160.          ) < 0)
  8161.       return(x);
  8162.     if (!s) s = "";
  8163. #ifdef COMMENT
  8164. /* This is to preserver the pre-8.0 behavior but it's too confusing */
  8165.     x = strlen(s);
  8166.     x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
  8167. #endif /* COMMENT */
  8168.     s = brstrip(s);            /* Strip braces and doublequotes */
  8169.     if (cx == XXECH) {        /* ECHO */
  8170. #ifndef NOSPL
  8171.         if (!fndiags || fnsuccess) {
  8172. #endif /* NOSPL */
  8173. #ifdef COMMENT
  8174.         /* The "if (x)" business preserves previous behavior */
  8175.         /* by putting back the doublequotes if they were included. */
  8176.         if (x)
  8177.           printf("\"%s\"\n",s);
  8178.         else
  8179. #endif /* COMMENT */
  8180.           printf("%s\n",s);
  8181. #ifndef NOSPL
  8182.         }
  8183. #endif /* NOSPL */
  8184.     } else if (cx == XXXECH) {    /* XECHO */
  8185.         if (x)
  8186.           printf("\"%s\"",s);
  8187.         else
  8188.           printf("%s",s);
  8189. #ifdef UNIX
  8190.         fflush(stdout);
  8191. #endif /* UNIX */
  8192.     } else if (cx == XXAPC) {    /* APC */
  8193. #ifdef CK_APC
  8194.         if (apcactive == APC_LOCAL ||
  8195.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  8196.           return(success = 0);
  8197. #endif /* CK_APC */
  8198.         if (!local) {
  8199.         printf("%c_%s%c\\",ESC,s,ESC);
  8200. #ifdef UNIX
  8201.         fflush(stdout);
  8202. #endif /* UNIX */
  8203.  
  8204.         } else {            /* Local mode - have connection */
  8205. #ifndef NOSPL
  8206.         if (ckmakxmsg(tmpbuf,    /* Form APC string in buffer */
  8207.                   TMPBUFSIZ,
  8208.                   ckctoa((char)ESC),
  8209.                   ckctoa('_'),
  8210.                   s,
  8211.                   ckctoa((char)ESC),
  8212.                   ckctoa('\\'),
  8213.                   NULL,NULL,NULL,NULL,NULL,NULL,NULL
  8214.                   ) > 0)
  8215.           return(success = dooutput(tmpbuf, XXOUT));
  8216.         printf("?Too long\n");
  8217.         return(-9);
  8218. #else
  8219.         printf("%c_%s%c\\",ESC,s,ESC);
  8220. #endif /* NOSPL */
  8221.         }
  8222.     }
  8223.     return(success = 1);
  8224.     }
  8225.  
  8226. #ifndef NOSPL
  8227. /* Copy macro args from/to two levels up, used internally by _floop et al. */
  8228.     if (cx == XXGTA || cx == XXPTA) {    /* _GETARGS, _PUTARGS */
  8229.     int x;
  8230.     debug(F101,"docmd XXGTA","",XXGTA);
  8231.     debug(F101,"docmd cx","",cx);
  8232.     debug(F101,"docmd XXGTA maclvl","",maclvl);
  8233.     x = dogta(cx);
  8234.     debug(F101,"docmd dogta returns","",x);
  8235.     debug(F101,"docmd dogta maclvl","",maclvl);
  8236.     return(x);
  8237.     }
  8238. #endif /* NOSPL */
  8239.  
  8240. #ifndef NOSPL
  8241. #ifdef CKCHANNELIO
  8242.     if (cx == XXFILE)
  8243.       return(dofile(cx));
  8244.     else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
  8245.          cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
  8246.          cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
  8247.       return(dofile(cx));
  8248. #endif /* CKCHANNELIO */
  8249.  
  8250. /* ASK, ASKQ, READ */
  8251.     if (cx == XXASK  || cx == XXASKQ || cx == XXREA ||
  8252.     cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
  8253.     return(doask(cx));
  8254.     }
  8255. #endif /* NOSPL */
  8256.  
  8257. #ifndef NOFRILLS
  8258.     if (cx == XXBUG) {            /* BUG */
  8259.     if ((x = cmcfm()) < 0) return(x);
  8260.     return(dobug());
  8261.     }
  8262. #endif /* NOFRILLS */
  8263.  
  8264. #ifndef NOXFER
  8265.     if (cx == XXBYE) {            /* BYE */
  8266.     extern int ftp_cmdlin;
  8267.     if ((x = cmcfm()) < 0) return(x);
  8268.  
  8269. #ifdef NEWFTP
  8270.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  8271.         extern int stayflg, ftp_fai;
  8272.         success = ftpbye();
  8273.         if (ftp_cmdlin && !stayflg && !local)
  8274.           doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
  8275.         else
  8276.           return(success);
  8277.     }
  8278. #endif /* NEWFTP */
  8279.  
  8280.     if (!local) {
  8281.         printf("?No connection - use EXIT to quit.\n");
  8282.         return(-9);
  8283.     }
  8284.  
  8285. #ifdef CK_XYZ
  8286.     if (protocol != PROTO_K) {
  8287.         printf("?Sorry, BYE only works with Kermit protocol\n");
  8288.         return(-9);
  8289.     }
  8290. #endif /* CK_XYZ */
  8291.  
  8292. #ifdef IKS_OPTION
  8293.         if (
  8294. #ifdef CK_XYZ
  8295.             protocol == PROTO_K &&
  8296. #endif /* CK_XYZ */
  8297.             !iks_wait(KERMIT_REQ_START,1)) {
  8298.         printf(
  8299.          "?A Kermit Server is not available to process this command\n");
  8300.         return(-9);            /* Correct the return code */
  8301.         }
  8302. #endif /* IKS_OPTION */
  8303.  
  8304.     bye_active = 1;
  8305.     sstate = setgen('L',"","","");
  8306.     if (local) ttflui();        /* If local, flush tty input buffer */
  8307.     return(0);
  8308.     }
  8309. #endif /* NOXFER */
  8310.  
  8311.     if (cx == XXBEEP) {            /* BEEP */
  8312.         int x;
  8313. #ifdef OS2
  8314.     int y;
  8315.         if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
  8316.                xxstring)) < 0 )
  8317.       return (y);
  8318.         if ((x = cmcfm()) < 0) return(x);
  8319.         bleep((short)y);        /* y is one of the BP_ values */
  8320. #else  /* OS2 */
  8321.         if ((x = cmcfm()) < 0) return(x);
  8322. #ifndef NOSPL
  8323.         bleep(BP_NOTE);
  8324. #else
  8325.     putchar('\07');
  8326. #endif /* NOSPL */
  8327. #endif /* OS2 */
  8328.         return(0);
  8329.     }
  8330.  
  8331. #ifndef NOFRILLS
  8332.     if (cx == XXCLE)            /* CLEAR */
  8333.       return(success = doclear());
  8334. #endif /* NOFRILLS */
  8335.  
  8336.     if (cx == XXCOM) {            /* COMMENT */
  8337.     if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
  8338.       return(x);
  8339.     /* Don't change SUCCESS flag for this one */
  8340.     return(0);
  8341.     }
  8342.  
  8343. #ifndef NOLOCAL
  8344.     if (cx == XXCON || cx == XXCQ)    /* CONNECT or CONNECT /QUIETLY */
  8345.       return(doxconn(cx));
  8346. #endif /* NOLOCAL */
  8347.  
  8348. #ifndef NOFRILLS
  8349. #ifdef ZCOPY
  8350.     if (cx == XXCPY) {            /* COPY a file */
  8351. #ifdef IKSD
  8352.     if (inserver && !ENABLED(en_cpy)) {
  8353.         printf("?Sorry, COPY is disabled\n");
  8354.         return(-9);
  8355.     }
  8356. #endif /* IKSD */
  8357. #ifdef CK_APC
  8358.     if (apcactive == APC_LOCAL ||
  8359.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8360.         )
  8361.       return(success = 0);
  8362. #endif /* CK_APC */
  8363.     return(docopy());
  8364.     }
  8365. #endif /* ZCOPY */
  8366. #ifdef NT
  8367.     if ( cx == XXLINK ) {
  8368. #ifdef IKSD
  8369.         if (inserver && !ENABLED(en_cpy)) {
  8370.             printf("?Sorry, LINK (COPY) is disabled\n");
  8371.             return(-9);
  8372.         }
  8373. #endif /* IKSD */
  8374. #ifdef CK_APC
  8375.         if (apcactive == APC_LOCAL ||
  8376.             (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8377.             )
  8378.           return(success = 0);
  8379. #endif /* CK_APC */
  8380.         return(dolink());
  8381.     }
  8382. #endif /* NT */
  8383. #endif /* NOFRILLS */
  8384.  
  8385.     /* CD and friends */
  8386.     if (cx == XXCWD  || cx == XXCDUP || cx == XXBACK ||
  8387.     cx == XXLCWD || cx == XXLCDU || cx == XXKCD) {
  8388. #ifdef LOCUS
  8389.     if (!locus) {
  8390.         if (cx == XXCWD) {
  8391. #ifdef NOXFER
  8392.                 return(-2);
  8393. #else
  8394.                 return(dormt(XZCWD));
  8395. #endif /* NOXFER */
  8396.         } else if (cx == XXCDUP) {
  8397. #ifdef NOXFER
  8398.                 return(-2);
  8399. #else
  8400.                 return(dormt(XZCDU));
  8401. #endif /* NOXFER */
  8402.             }
  8403.     }
  8404. #endif /* LOCUS */
  8405. #ifdef IKSD
  8406.     if (inserver && !ENABLED(en_cwd)) {
  8407.         printf("?Sorry, changing directories is disabled\n");
  8408.         return(-9);
  8409.     }
  8410. #endif /* IKSD */
  8411.     return(success = docd(cx));
  8412.     }
  8413.  
  8414.     if (cx == XXCHK)            /* CHECK */
  8415.       return(success = dochk());
  8416.  
  8417.     if (cx == XXCLO) {            /* CLOSE */
  8418.     x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
  8419.           "connection",xxstring);
  8420.     if (x == -3) {
  8421.         printf("?You must say which file or log\n");
  8422.         return(-9);
  8423.     }
  8424.     if (x < 0) return(x);
  8425.     if ((y = cmcfm()) < 0) return(y);
  8426. #ifndef NOLOCAL
  8427.     if (x == 9999) {        /* CLOSE CONNECTION */
  8428.         x = clsconnx(0);
  8429.         switch (x) {
  8430.           case 0:
  8431.         if (msgflg) printf("?Connection was not open\n");
  8432.           case -1:
  8433.         return(0);
  8434.           case 1:
  8435.         whyclosed = WC_CLOS;
  8436.         return(1);
  8437.         }
  8438.         return(0);
  8439.     }
  8440. #endif /* NOLOCAL */
  8441.     y = doclslog(x);
  8442.     success = (y == 1);
  8443.     return(success);
  8444.     }
  8445.  
  8446. #ifndef NOSPL
  8447.     if (cx == XXDCL || cx == XXUNDCL) {    /* DECLARE an array */
  8448.     return(dodcl(cx));
  8449.     }
  8450. #endif /* NOSPL */
  8451.  
  8452. #ifndef NODIAL
  8453.     if (cx == XXRED  || cx == XXDIAL || cx == XXPDIA ||
  8454.     cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
  8455. #ifdef VMS
  8456.     extern int batch;
  8457. #else
  8458. #ifdef UNIXOROSK
  8459.     extern int backgrd;
  8460. #endif /* UNIXOROSK */
  8461. #endif /* VMS */
  8462.     x = dodial(cx);
  8463.     debug(F101,"dodial returns","",x);
  8464.     if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
  8465.         (x > 0) &&            /* If DIAL or REDIAL succeeded */
  8466.         (dialsta != DIA_PART) &&    /* and it wasn't partial */
  8467.         (dialcon > 0)) {
  8468.         if ((dialcon == 1 ||    /* And DIAL CONNECT is ON, */
  8469.         ((dialcon == 2) &&    /* or DIAL CONNECT is AUTO */
  8470.          !xcmdsrc        /* and we're at top level... */
  8471. #ifdef VMS
  8472.          && !batch        /* Not if running from batch */
  8473. #else
  8474. #ifdef UNIXOROSK
  8475.          && !backgrd        /* Not if running in background */
  8476. #endif /* UNIXOROSK */
  8477. #endif /* VMS */
  8478.          ))) /* Or AUTO */
  8479.           x = doconect(dialcq,    /* Then also CONNECT */
  8480.                            cmdlvl == 0 ? 1 : 0
  8481.                );
  8482.         if (ttchk() < 0)
  8483.           dologend();
  8484.     }
  8485.     return(success = x);
  8486.     }
  8487. #endif /* NODIAL */
  8488.  
  8489. #ifndef NOPUSH
  8490. #ifdef CK_REXX
  8491.     if (cx == XXREXX) {            /* REXX */
  8492.         extern int nopush;
  8493.         if ( nopush )
  8494.           return(success=0);
  8495.         return(dorexx());
  8496.     }
  8497. #endif /* CK_REXX */
  8498. #endif /* NOPUSH */
  8499.  
  8500. #ifndef NOFRILLS
  8501.     if (cx == XXDEL || cx == XXLDEL) {    /* DELETE */
  8502. #ifdef LOCUS
  8503.     if (!locus && cx != XXLDEL) {
  8504. #ifdef NOXFER
  8505.         return(-2);
  8506. #else
  8507.         return(dormt(XZDEL));
  8508. #endif /* NOXFER */
  8509.         }
  8510. #endif /* LOCUS */
  8511. #ifdef IKSD
  8512.     if (inserver && (!ENABLED(en_del)
  8513. #ifdef CK_LOGIN
  8514.              || isguest
  8515. #endif /* CK_LOGIN */
  8516.              )) {
  8517.         printf("?Sorry, DELETE is disabled\n");
  8518.         return(-9);
  8519.     }
  8520. #endif /* IKSD */
  8521. #ifdef CK_APC
  8522.     if ((apcactive == APC_LOCAL) ||
  8523.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8524.       return(success = 0);
  8525. #endif /* CK_APC */
  8526.     return(dodel());
  8527.     }
  8528. #endif /* NOFRILLS */
  8529.  
  8530.     if (cx == XXDIR || cx == XXLS || cx == XXLDIR) { /* DIRECTORY or LS */
  8531. #ifdef LOCUS
  8532.     if (!locus && cx != XXLDIR) {
  8533. #ifdef NOXFER
  8534.         return(-2);
  8535. #else
  8536.         return(dormt(XZDIR));
  8537. #endif /* NOXFER */
  8538.         }
  8539. #endif /* LOCUS */
  8540. #ifdef IKSD
  8541.     if (inserver && !ENABLED(en_dir)) {
  8542.         printf("?Sorry, DIRECTORY is disabled\n");
  8543.         return(-9);
  8544.     }
  8545. #endif /* IKSD */
  8546.     return(dodir(cx));
  8547.     }
  8548.  
  8549. #ifndef NOSPL
  8550.     if (cx == XXELS)            /* ELSE */
  8551.       return(doelse());
  8552. #endif /* NOSPL */
  8553.  
  8554. #ifndef NOSERVER
  8555. #ifndef NOFRILLS
  8556.     if (cx == XXENA || cx == XXDIS) {    /* ENABLE, DISABLE */
  8557.     s = (cx == XXENA) ?
  8558.       "Server function to enable" :
  8559.         "Server function to disable";
  8560.  
  8561.     if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
  8562.         if (x == -3) {
  8563.         printf("?Name of server function required\n");
  8564.         return(-9);
  8565.         } else return(x);
  8566.     }
  8567.     if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
  8568.         if (y == -3) {
  8569.         printf("?Please specify remote, local, or both\n");
  8570.         return(-9);
  8571.         } else return(y);
  8572.     }
  8573.     if (cx == XXDIS)        /* Disabling, not enabling */
  8574.       y = 3 - y;
  8575.     if ((z = cmcfm()) < 0) return(z);
  8576. #ifdef CK_APC
  8577.     if ((apcactive == APC_LOCAL) ||
  8578.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8579.       return(success = 0);
  8580. #endif /* CK_APC */
  8581. #ifdef IKSD
  8582.         /* This may seem like it duplicates the work in doenable()  */
  8583.         /* but this code returns failure whereas doenable() returns */
  8584.         /* success.                                                 */
  8585.         if (inserver &&
  8586. #ifdef IKSDCONF
  8587.             iksdcf &&
  8588. #endif /* IKSDCONF */
  8589.             (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
  8590.               isguest))
  8591.             return(success = 0);
  8592. #endif /* IKSD */
  8593.     return(doenable(y,x));
  8594.     }
  8595. #endif /* NOFRILLS */
  8596. #endif /* NOSERVER */
  8597.  
  8598. #ifndef NOSPL
  8599.     if (cx == XXRET) {            /* RETURN */
  8600.     if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
  8601.       return(x);
  8602.     s = brstrip(s);            /* Strip braces */
  8603.     if (cmdlvl == 0)        /* At top level, nothing happens... */
  8604.       return(success = 1);
  8605.     switch (cmdstk[cmdlvl].src) {    /* Action depends on command source */
  8606.       case CMD_TF:            /* Command file */
  8607.         popclvl();            /* Pop command level */
  8608.         return(success = 1);    /* always succeeds */
  8609.       case CMD_MD:            /* Macro */
  8610.       case CMD_KB:            /* Prompt */
  8611.         return(doreturn(s));    /* Trailing text is return value. */
  8612.       default:            /* Shouldn't happen */
  8613.         return(-2);
  8614.     }
  8615.     }
  8616. #endif /* NOSPL */
  8617.  
  8618. #ifndef NOSPL
  8619.     if (cx == XXOPE)            /* OPEN */
  8620.       return(doopen());
  8621. #endif /* NOSPL */
  8622.  
  8623. #ifndef NOSPL
  8624.     if (cx == XXOUT || cx == XXLNOUT) {    /* OUTPUT or LINEOUT */
  8625.     if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
  8626.       return(x);
  8627. #ifdef CK_APC
  8628.     if ((apcactive == APC_LOCAL) ||
  8629.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8630.       return(success = 0);
  8631. #endif /* CK_APC */
  8632.     debug(F110,"OUTPUT 1",s,0);
  8633.     s = brstrip(s);            /* Strip enclosing braces, */
  8634.     debug(F110,"OUTPUT 2",s,0);
  8635. /*
  8636.   I don't think I could ever fully explain this in a million years...
  8637.   We have read the user's string without calling the variable-expander
  8638.   function.  Now, before we call it, we have to double backslashes that
  8639.   appear before \N, \B, \L, and \ itself, so the expander function will
  8640.   reduce them back to single backslashes, so when we call dooutput()...
  8641.   But it's more complicated than that.
  8642. */
  8643.     if (cmdgquo()) {        /* Only if COMMAND QUOTING ON ... */
  8644.         for (x = 0, y = 0; s[x]; x++, y++) {
  8645.         if (s[x] == CMDQ) {
  8646.             char c = s[x+1];
  8647.             if (c == 'n' || c == 'N' ||
  8648.             c == 'b' || c == 'B' ||
  8649.             c == 'l' || c == 'L' ||
  8650.             c == CMDQ)
  8651.               line[y++] = CMDQ;
  8652.         }
  8653.         line[y] = s[x];
  8654.         }
  8655.         line[y++] = '\0';        /* Now expand variables, etc. */
  8656.         debug(F110,"OUTPUT 3",line,0);
  8657.         s = line+y+1;
  8658.         x = LINBUFSIZ - (int) strlen(line) - 1;
  8659.         debug(F101,"OUTPUT size","",x);
  8660.         if (zzstring(line,&s,&x) < 0)
  8661.           return(success = 0);
  8662.         s = line+y+1;
  8663.         debug(F110,"OUTPUT 4",s,0);
  8664.     }
  8665.     success = dooutput(s,cx);
  8666.     return(success);
  8667.     }
  8668. #endif /* NOSPL */
  8669.  
  8670. #ifdef ANYX25
  8671. #ifndef IBMX25
  8672.     if (cx == XXPAD) {            /* PAD commands */
  8673.     x = cmkey(padtab,npadc,"PAD command","",xxstring);
  8674.     if (x == -3) {
  8675.         printf("?You must specify a PAD command to execute\n");
  8676.         return(-9);
  8677.     }
  8678.     if (x < 0) return(x);
  8679.  
  8680.     switch (x) {
  8681.       case XYPADL:
  8682.         if (x25stat() < 0)
  8683.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8684.         else {
  8685.         x25clear();
  8686.         initpad();
  8687.         }
  8688.         break;
  8689.       case XYPADS:
  8690.         if (x25stat() < 0)
  8691.           printf("Not connected\r\n");
  8692.         else {
  8693.         extern int linkid, lcn;
  8694.         conol("Connected thru ");
  8695.         conol(ttname);
  8696.         printf(", Link id %d, Logical channel number %d\r\n",
  8697.                linkid,lcn);
  8698.         }
  8699.         break;
  8700.       case XYPADR:
  8701.         if (x25stat() < 0)
  8702.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8703.         else
  8704.           x25reset(0,0);
  8705.         break;
  8706.       case XYPADI:
  8707.         if (x25stat() < 0)
  8708.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8709.         else
  8710.           x25intr(0);
  8711.     }
  8712.     return(0);
  8713.     }
  8714. #endif /* IBMX25 */
  8715. #endif /* ANYX25 */
  8716.  
  8717. #ifndef NOSPL
  8718.     if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
  8719.       return(dopaus(cx));
  8720. #endif /* NOSPL */
  8721.  
  8722. #ifndef NOFRILLS
  8723.     if (cx == XXPRI) {
  8724. #ifdef IKSD
  8725. #ifdef CK_LOGIN
  8726.     if (inserver && (isguest || !ENABLED(en_pri))) {
  8727.         printf("?Sorry, printing is disabled\n");
  8728.         return(-9);
  8729.     }
  8730. #endif /* CK_LOGIN */
  8731. #endif /* IKSD */
  8732.     if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
  8733.         if (x == -3) {
  8734.         printf("?A file specification is required\n");
  8735.         return(-9);
  8736.         } else return(x);
  8737.     }
  8738.     if (y != 0) {
  8739.         printf("?Wildcards not allowed\n");
  8740.         return(-9);
  8741.     }
  8742.     ckstrncpy(line,s,LINBUFSIZ);
  8743.     s = "";
  8744. #ifndef NT
  8745.     if ((x = cmtxt("Local print command options, or carriage return","",&s,
  8746.                xxstring)) < 0)
  8747.       return(x);
  8748. #endif /* NT */
  8749.     if ((x = cmcfm()) < 0)
  8750.       return(x);
  8751.     return(success = (zprint(s,line) == 0) ? 1 : 0);
  8752.     }
  8753. #endif /* NOFRILLS */
  8754.  
  8755. #ifdef TCPSOCKET
  8756. #ifndef NOPUSH
  8757.     if (cx == XXPNG)             /* PING an IP host */
  8758.       return(doping());
  8759. #endif /* NOPUSH */
  8760.  
  8761. #ifndef NOFTP
  8762.     if (cx == XXFTP)            /* FTP */
  8763. #ifdef SYSFTP
  8764. #ifndef NOPUSH
  8765.       return(doftp());            /* Just runs system's ftp program */
  8766. #else
  8767.       return(-2);
  8768. #endif /* NOPUSH */
  8769. #else
  8770.     return(doxftp());
  8771. #endif /* SYSFTP */
  8772. #endif /* NOFTP */
  8773. #endif /* TCPSOCKET */
  8774.  
  8775.     if (cx == XXPWD || cx == XXLPWD) {    /* PWD */
  8776. #ifdef OS2
  8777.     char *pwp;
  8778. #endif /* OS2 */
  8779.     if ((x = cmcfm()) < 0)
  8780.       return(x);
  8781. #ifdef LOCUS
  8782.     if (!locus && cx != XXLPWD) {
  8783. #ifdef NOXFER
  8784.         return(-2);
  8785. #else
  8786.         return(dormt(XZPWD));
  8787. #endif /* NOXFER */
  8788.         }
  8789. #endif /* LOCUS */
  8790.  
  8791. #ifndef MAC
  8792. #ifndef OS2
  8793. #ifdef UNIX
  8794.     printf("%s\n",zgtdir());
  8795. #else
  8796.     xsystem(PWDCMD);
  8797. #endif /* UNIX */
  8798.     return(success = 1);        /* Blind faith */
  8799. #else  /* OS2 */
  8800.     if (pwp = zgtdir()) {
  8801.         if (*pwp) {
  8802. #ifdef NT
  8803.         line[0] = NUL;
  8804.         ckGetLongPathName(pwp,line,LINBUFSIZ);
  8805.         line[LINBUFSIZ-1] = NUL;
  8806.         tmpbuf[0] = NUL;
  8807.         GetShortPathName(pwp,tmpbuf,TMPBUFSIZ);
  8808.         tmpbuf[TMPBUFSIZ-1] = NUL;
  8809.         pwp = line;
  8810.         if (!strcmp(line,tmpbuf)) {
  8811. #endif /* NT */
  8812.             printf("%s\n",pwp);
  8813. #ifdef NT
  8814.         } else {
  8815.             printf("  Long name:  %s\n",line);
  8816.             printf("  Short name: %s\n",tmpbuf);
  8817.         }            
  8818. #endif /* NT */
  8819.         }
  8820.         return(success = ((int)strlen(pwp) > 0));
  8821.     } else return(success = 0);
  8822. #endif /* OS2 */
  8823. #else  /* MAC */
  8824.     if (pwp = zgtdir()) {
  8825.         printf("%s\n",pwp);
  8826.         return(success = ((int)strlen(pwp) > 0));
  8827.     } else return(success = 0);
  8828. #endif /* MAC */
  8829.     }
  8830.  
  8831.     if (cx == XXQUI || cx == XXEXI) {    /* EXIT, QUIT */
  8832.     extern int quitting;
  8833.  
  8834.     if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
  8835.       return(y);
  8836.     if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
  8837.       return(y);
  8838.     s = brstrip(s);
  8839.     ckstrncpy(line,s,LINBUFSIZ);
  8840.  
  8841.     if (!hupok(0))            /* Check if connection still open */
  8842.       return(success = 0);
  8843.  
  8844.     if (line[0])            /* Print EXIT message if given */
  8845.       printf("%s\n",(char *)line);
  8846.  
  8847.     quitting = 1;            /* Flag that we are quitting. */
  8848.  
  8849. #ifdef VMS
  8850.     doexit(GOOD_EXIT,x);
  8851. #else
  8852. #ifdef OSK
  8853. /* Returning any codes here makes the OS-9 shell print an error message. */
  8854.     doexit(GOOD_EXIT,-1);
  8855. #else
  8856. #ifdef datageneral
  8857.         doexit(GOOD_EXIT,x);
  8858. #else
  8859.     doexit(x,-1);
  8860. #endif /* datageneral */
  8861. #endif /* OSK */
  8862. #endif /* VMS */
  8863.     }
  8864.  
  8865. #ifndef NOXFER
  8866. #ifndef NOFRILLS
  8867.     if (cx == XXERR) {            /* ERROR */
  8868. #ifdef CK_XYZ
  8869.     if (protocol != PROTO_K) {
  8870.         printf("Sorry, E-PACKET only works with Kermit protocol\n");
  8871.         return(-9);
  8872.     }
  8873. #endif /* CK_XYZ */
  8874.     if ((x = cmcfm()) < 0) return(x);
  8875.     ttflui();
  8876.     epktflg = 1;
  8877.     sstate = 'a';
  8878.     return(0);
  8879.     }
  8880. #endif /* NOFRILLS */
  8881.  
  8882.     if (cx == XXFIN) {            /* FINISH */
  8883. #ifdef NEWFTP
  8884.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8885.       return(ftpbye());
  8886. #endif /* NEWFTP */
  8887. #ifdef CK_XYZ
  8888.     if (protocol != PROTO_K) {
  8889.         printf("Sorry, FINISH only works with Kermit protocol\n");
  8890.         return(-9);
  8891.     }
  8892. #endif /* CK_XYZ */
  8893.     if ((x = cmcfm()) < 0) return(x);
  8894.  
  8895. #ifdef IKS_OPTION
  8896.         if (
  8897. #ifdef CK_XYZ
  8898.             protocol == PROTO_K &&
  8899. #endif /* CK_XYZ */
  8900.             !iks_wait(KERMIT_REQ_START,1)) {
  8901.         printf(
  8902.               "?A Kermit Server is not available to process this command\n");
  8903.         return(-9);            /* Correct the return code */
  8904.         }
  8905. #endif /* IKS_OPTION */
  8906.  
  8907.     sstate = setgen('F',"","","");
  8908.     if (local) ttflui();        /* If local, flush tty input buffer */
  8909.     return(0);
  8910.     }
  8911. #endif /* NOXFER */
  8912.  
  8913. #ifndef NOSPL
  8914.     if (cx == XXFOR)            /* FOR loop */
  8915.       return(dofor());
  8916. #endif /* NOSPL */
  8917.  
  8918. #ifndef NOXFER
  8919.     /* GET MGET REGET RETRIEVE etc */
  8920.     if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
  8921. #ifdef IKSD
  8922.     if (inserver && !ENABLED(en_sen)) {
  8923.         printf("?Sorry, reception of files is disabled\n");
  8924.         return(-9);
  8925.     }
  8926. #endif /* IKSD */
  8927.     return(doxget(cx));
  8928.     }
  8929. #endif /* NOXFER */
  8930.  
  8931. #ifndef NOSPL
  8932. #ifndef NOFRILLS
  8933.     if (cx == XXGOK) {            /* GETOK */
  8934.     return(success = doask(cx));
  8935.     }
  8936. #endif /* NOFRILLS */
  8937. #endif /* NOSPL */
  8938.  
  8939.     if (cx == XXHLP) {            /* HELP */
  8940. #ifdef NOHELP
  8941.     return(dohlp(XXHLP));
  8942. #else
  8943.     x = cmkey2(cmdtab,ncmd,"\nCommand or topic","help",toktab,xxstring,3);
  8944.     debug(F101,"HELP command x","",x);
  8945.     if (x == -5) {
  8946.         y = chktok(toktab);
  8947.         debug(F101,"HELP cmkey token","",y);
  8948.         /* ungword(); */
  8949.         switch (y) {
  8950. #ifndef NOPUSH
  8951.           case '!': x = XXSHE; break;
  8952. #endif /* NOPUSH */
  8953.           case '#': x = XXCOM; break;
  8954.           case ';': x = XXCOM; break;
  8955. #ifndef NOSPL
  8956.               case '.': x = XXDEF; break;
  8957.           case ':': x = XXLBL; break;
  8958. #ifndef NOSEXP
  8959.           case '(': x = XXSEXP; break;
  8960. #endif /* NOSEXP */
  8961. #endif /* NOSPL */
  8962.           case '&': x = XXECH; break;
  8963.           default:
  8964.         printf("\n?Invalid - %s\n",cmdbuf);
  8965.         x = -2;
  8966.         }
  8967.     }
  8968.     makestr(&hlptok,atmbuf);
  8969.     debug(F111,"HELP token",hlptok,x);
  8970.     return(dohlp(x));
  8971. #endif /* NOHELP */
  8972.     }
  8973.  
  8974. #ifndef NOHELP
  8975.     if (cx == XXINT)            /* INTRO */
  8976.       return(hmsga(introtxt));
  8977.     if (cx == XXNEW) {            /* NEWS */
  8978.     int x;
  8979.     extern char * k_info_dir;
  8980.     x = hmsga(newstxt);
  8981.     return(x);
  8982.     }
  8983.  
  8984. #ifdef OS2ONLY
  8985.     if (cx == XXUPD) {            /* View UPDATE file */
  8986.         extern char exedir[];
  8987.         char * pTopic;
  8988.         char updstr[2048];
  8989.         if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
  8990.             return x;
  8991. #ifdef COMMENT
  8992.     sprintf(updstr,
  8993.         "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
  8994. %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
  8995.         exedir,exedir,exedir,exedir,pTopic
  8996.         );
  8997. #else
  8998.     if (ckmakxmsg(updstr,
  8999.              2048,
  9000.              "start view ",
  9001.              exedir,
  9002.              "\\docs\\k2.inf+",
  9003.              exedir,
  9004.              "\\docs\\using_ck.inf+",
  9005.              exedir,
  9006.              "\\docs\\dialing.inf+",
  9007.              exedir,
  9008.              "\\docs\\modems.inf ",
  9009.              pTopic,
  9010.              NULL,
  9011.              NULL
  9012.              ) > 0)
  9013. #endif /* COMMENT */
  9014.       system(updstr);
  9015.         return(success = 1);
  9016.     }
  9017. #endif /* OS2ONLY */
  9018. #endif /* NOHELP */
  9019.  
  9020. #ifndef NOLOCAL
  9021.     if (cx == XXHAN) {            /* HANGUP */
  9022.     if ((x = cmcfm()) < 0) return(x);
  9023. #ifdef NEWFTP
  9024.     if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
  9025.       return(success = ftpbye());
  9026. #endif /* NEWFTP */
  9027. #ifndef NODIAL
  9028.     if ((x = mdmhup()) < 1) {
  9029.         debug(F101,"HANGUP mdmup","",x);
  9030. #endif /* NODIAL */
  9031.         x = tthang();
  9032.         debug(F101,"HANGUP tthang","",x);
  9033.         x = (x > -1);
  9034. #ifndef NODIAL
  9035.     }
  9036.     dialsta = DIA_UNK;
  9037. #endif /* NODIAL */
  9038.     whyclosed = WC_CLOS;
  9039.     ttchk();            /* In case of CLOSE-ON-DISCONNECT */
  9040.     dologend();
  9041. #ifdef OS2
  9042.     if (x)
  9043.       DialerSend(OPT_KERMIT_HANGUP, 0);
  9044. #endif /* OS2 */
  9045.     if (x) haveline = 0;
  9046.     return(success = x);
  9047.     }
  9048. #endif /* NOLOCAL */
  9049.  
  9050. #ifndef NOSPL
  9051.     /* INPUT, REINPUT, and MINPUT */
  9052.  
  9053.     if (cx == XXINP || cx == XXREI || cx == XXMINP) {
  9054.     long zz;
  9055.     int flags = 0;
  9056.     extern int ispattern, isjoin, isinbuflen;
  9057.  
  9058.     struct FDB sw, nu, fl;
  9059.     int fc, havetime = 0;
  9060.     char * m;
  9061.  
  9062.     if (cx == XXREI) {
  9063.         m = "Timeout in seconds (ignored)";
  9064.     } else {
  9065.         m = "Seconds to wait for input,\n or time of day hh:mm:ss,\
  9066.  or switch";
  9067.     }
  9068.     cmfdbi(&sw,            /* First FDB - command switches */
  9069.            _CMKEY,            /* fcode */
  9070.            m,            /* helpmsg */
  9071.            ckitoa(indef),        /* default */
  9072.            "",            /* addtl string data */
  9073.            ninputsw,        /* addtl numeric data 1: tbl size */
  9074.            4,            /* addtl numeric data 2: 4 = cmswi */
  9075.            xxstring,        /* Processing function */
  9076.            inputsw,            /* Keyword table */
  9077.            &nu            /* Pointer to next FDB */
  9078.            );
  9079.     cmfdbi(&nu,
  9080.            _CMNUM,            /* Number */
  9081.            m,            /* Help message */
  9082.            ckitoa(indef),        /* default */
  9083.            "",            /* N/A */
  9084.            10,            /* Radix = 10 */
  9085.            0,            /* N/A */
  9086.            xxstring,        /* Processing function */
  9087.            NULL,            /* N/A */
  9088.            &fl            /* Next */
  9089.            );
  9090.     cmfdbi(&fl,            /* Time of day hh:mm:ss */
  9091.            _CMFLD,            /* fcode */
  9092.            "",            /* hlpmsg */
  9093.            "",
  9094.            "",            /* addtl string data */
  9095.            0,            /* addtl numeric data 1 */
  9096.            0,            /* addtl numeric data 2 */
  9097.            xxstring,
  9098.            NULL,
  9099.            NULL
  9100.            );
  9101.     fc = (cx == XXREI) ? cmfdb(&nu) : cmfdb(&sw); /* Parse something */
  9102.  
  9103.     while (!havetime) {
  9104.         if (fc < 0) {        /* Error */
  9105.         if (fc == -3) {
  9106.             printf("?Syntax error in INPUT-class command\n");
  9107.             return(-9);
  9108.         } else
  9109.           return(fc);
  9110.         }
  9111.         switch (cmresult.fcode) {
  9112.           case _CMKEY:        /* Switch */
  9113.         flags |= cmresult.nresult;
  9114.         fc = cmfdb(&sw);    /* Maybe parse more switches */
  9115.         continue;
  9116.  
  9117.           case _CMNUM:        /* Seconds to time out */
  9118.         x = cmresult.nresult;
  9119. #ifdef CKFLOAT
  9120.         if (inscale != 1.0)    /* Scale */
  9121.           x *= inscale;        
  9122. #endif    /* CKFLOAT */
  9123.         havetime++;
  9124.         break;
  9125.  
  9126.           case _CMFLD:
  9127.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  9128.         if (zz < 0L) {
  9129.             printf("?Number, expression, or time of day required\n");
  9130.             return(-9);
  9131.         } else {
  9132.             char now[32];    /* Current time */
  9133.             char *p;
  9134.             long tnow;
  9135.             p = now;
  9136.             ztime(&p);
  9137.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  9138.             if (zz < tnow)    /* User's time before now */
  9139.               zz += 86400L;    /* So make it tomorrow */
  9140.             zz -= tnow;        /* Seconds from now. */
  9141.             if (zz > -1L) {
  9142.             x = zz;
  9143.             if (zz != (long) x) {
  9144.                 printf(
  9145. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  9146. );
  9147.                 return(-9);
  9148.             }
  9149.             }
  9150.             havetime++;
  9151.         }
  9152.         break;
  9153.           default:        
  9154.         printf("?Internal error\n");
  9155.         return(-9);
  9156.         }
  9157.     }
  9158.     /* Now parse the search text */
  9159.  
  9160. #ifdef CK_MINPUT
  9161.     for (y = 0; y < MINPMAX; y++) {    /* Initialize strings */
  9162.         mp[y] = 0;            /* Assume it's not a pattern */
  9163.         if (ms[y]) {
  9164.         free(ms[y]);        /* Free old strings, if any */
  9165.         ms[y] = NULL;
  9166.         }
  9167.     }
  9168.     if (cx == XXMINP) {        /* MINPUT */
  9169.         int i, k = 0, n = 0;
  9170.         struct stringarray * q;
  9171.         keepallchars = 1;
  9172.         while (k < MINPMAX) {
  9173.         if ((y = cmfld("String or pattern","",&s,xxstring)) < 0) {
  9174.             if (y == -3) {
  9175.             if ((y = cmcfm()) < 0)
  9176.               return(y);
  9177.             break;
  9178.             } else {
  9179.             return(y);
  9180.             }
  9181.         }
  9182.         debug(F111,"MINPUT field",s,k);
  9183.         if (isjoin) {
  9184.             if ((q = cksplit(1,0,s," ",(char *)c1chars,3,0,0))) {
  9185.             char ** ap = q->a_head;
  9186.             n = q->a_size;
  9187.             debug(F101,"minput cksplit size","",n);
  9188.             for (i = 1; i <= n && k < MINPMAX; i++) {
  9189.                 if (!ap[i]) /* Add non-empty elements */
  9190.                   continue;
  9191.                 if (!*(ap[i]))
  9192.                   continue;
  9193.                 makestr(&(ms[k]),ap[i]);
  9194.                 debug(F111,"MINPUT JOIN",ms[k],k);
  9195.                 k++;
  9196.             }
  9197.             }
  9198.         } else {
  9199.             if (s) if (*s) {
  9200.             makestr(&(ms[k]),brstrip(s));
  9201.             if (ispattern) mp[k] = 1;
  9202.             debug(F111,"MINPUT",ms[k],ispattern);
  9203.             k++;
  9204.             }
  9205.         }
  9206.         }
  9207.         keepallchars = 0;
  9208.     } else {
  9209. #endif /* CK_MINPUT */
  9210.  
  9211.         /* INPUT or REINPUT */
  9212.  
  9213.         if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
  9214.           return(y);
  9215.         mp[0] = ispattern ? 1 : 0;
  9216.         makestr(&(ms[0]),brstrip(s));
  9217.         ms[1] = NULL;
  9218.  
  9219. #ifdef CK_MINPUT
  9220.     }
  9221. #endif /* CK_MINPUT */
  9222.  
  9223.     if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
  9224.         i_active = 1;
  9225.         /* Go try to input the search string */
  9226.         success = doinput(x,ms,mp,flags);
  9227.         i_active = 0;
  9228.     } else {            /* REINPUT */
  9229.         success = doreinp(x,ms[0],ispattern);
  9230.     }
  9231.     if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
  9232.         popclvl();            /* If so, pop command level. */
  9233.         if (pflag && cmdlvl == 0) {
  9234.         if (cx == XXINP)  printf("?INPUT timed out\n");
  9235.         if (cx == XXMINP) printf("?MINPUT timed out\n");
  9236.         if (cx == XXREI)  printf("?REINPUT failed\n");
  9237.         }
  9238.     }
  9239.     return(success);        /* Return do(re)input's return code */
  9240.     }
  9241.  
  9242. #endif /* NOSPL */
  9243.  
  9244.     if (cx == XXLOG) {            /* LOG */
  9245.     x = cmkey(logtab,nlog,"What to log","",xxstring);
  9246.     if (x == -3) {
  9247.         printf("?Type of log required\n");
  9248.         return(-9);
  9249.     }
  9250.     if (x < 0) return(x);
  9251.     x = dolog(x);
  9252.     if (x < 0)
  9253.       return(x);
  9254.     else
  9255.       return(success = x);
  9256.     }
  9257.  
  9258.     if (cx == XXLOGIN) {        /* (REMOTE) LOGIN */
  9259. #ifdef NEWFTP
  9260.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9261.       return(success = doftpusr());
  9262. #endif /* NEWFTP */
  9263. #ifdef IKSD
  9264.     if (inserver) {
  9265.         printf("?Already logged in\n");
  9266.         return(-9);
  9267.     } else
  9268. #endif /* IKSD */
  9269.     {
  9270. #ifdef NOXFER
  9271.         return(-2);
  9272. #else
  9273.         return(dormt(XZLGI));
  9274. #endif /* NOXFER */
  9275.     }
  9276.     }
  9277.     if (cx == XXLOGOUT) {        /* (REMOTE) LOGOUT */
  9278. #ifdef NEWFTP
  9279.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9280.       return(success = doftpres());
  9281. #endif /* NEWFTP */
  9282.  
  9283. #ifdef IKSD
  9284.         if (inserver) {
  9285.         if ((x = cmcfm()) < 0)
  9286.           return(x);
  9287.         doexit(GOOD_EXIT,xitsta);
  9288.     } else
  9289. #endif /* IKSD */
  9290.     if (!local || (network && ttchk() < 0)) {
  9291.         printf("?No connection.\n");
  9292.         return(-9);
  9293.     } else {
  9294. #ifdef NOXFER
  9295.         return(-2);
  9296. #else
  9297.         return(dormt(XZLGO));
  9298. #endif /* NOXFER */
  9299.     }
  9300.     }
  9301.  
  9302. #ifndef NOSCRIPT
  9303.     if (cx == XXLOGI) {            /* UUCP-style script */
  9304.     if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
  9305.       return(x);
  9306. #ifdef CK_APC
  9307.     if ((apcactive == APC_LOCAL) ||
  9308.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9309.       return(success = 0);
  9310. #endif /* CK_APC */
  9311. #ifdef VMS
  9312.     conres();            /* For Ctrl-C to work... */
  9313. #endif /* VMS */
  9314.     return(success = dologin(s));    /* Return 1=completed, 0=failed */
  9315.     }
  9316. #endif /* NOSCRIPT */
  9317.  
  9318. #ifndef NOXFER
  9319. #ifdef PIPESEND
  9320.     if (cx == XXCREC) {            /* CRECEIVE */
  9321.     if (protocol != PROTO_K) {
  9322.         printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
  9323.         return(-9);
  9324.     } else
  9325.       return(doxget(cx));
  9326.     }
  9327.     if (cx == XXCGET) {            /* CGET */
  9328.     return(doxget(cx));
  9329.     }
  9330. #endif /* PIPESEND */
  9331.  
  9332.     if (cx == XXREC)            /* RECEIVE */
  9333.       return(doxget(cx));
  9334. #endif /* NOXFER */
  9335.  
  9336. #ifndef NOXFER
  9337.     if (cx == XXREM) {            /* REMOTE */
  9338. #ifdef NEWFTP
  9339.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9340.       return(doftprmt(0,0));
  9341. #endif /* NEWFTP */
  9342. #ifdef CK_XYZ
  9343.     if (protocol != PROTO_K) {
  9344.         printf("Sorry, REMOTE commands only work with Kermit protocol\n");
  9345.         return(-9);
  9346.     }
  9347. #endif /* CK_XYZ */
  9348.     x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
  9349.     if (x == -3) {
  9350.         printf("?You must specify a command for the remote server\n");
  9351.         return(-9);
  9352.     }
  9353.     return(dormt(x));
  9354.     }
  9355. #endif /* NOXFER */
  9356.  
  9357. #ifndef NORENAME
  9358. #ifndef NOFRILLS
  9359.     if (cx == XXREN || cx == XXLREN) {    /* RENAME */
  9360. #ifdef LOCUS
  9361.     if (!locus && cx != XXLREN) {
  9362. #ifdef NOXFER
  9363.         return(-2);
  9364. #else
  9365.         return(dormt(XZREN));
  9366. #endif /* NOXFER */
  9367.         }
  9368. #endif /* LOCUS */
  9369. #ifdef IKSD
  9370.     if (inserver && (!ENABLED(en_ren)
  9371. #ifdef CK_LOGIN
  9372.              || isguest
  9373. #endif /* CK_LOGIN */
  9374.              )) {
  9375.         printf("?Sorry, renaming of files is disabled\n");
  9376.         return(-9);
  9377.     }
  9378. #endif /* IKSD */
  9379. #ifdef CK_APC
  9380.     if ((apcactive == APC_LOCAL) ||
  9381.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9382.       return(success = 0);
  9383. #endif /* CK_APC */
  9384.     return(dorenam());
  9385.     }
  9386. #endif /* NOFRILLS */
  9387. #endif /* NORENAME */
  9388.  
  9389.     if (cx == XXEIGHT) {        /* EIGHTBIT */
  9390.     extern int parity, cmask, cmdmsk;
  9391.     if ((x = cmcfm()) < 0)
  9392.       return(x);
  9393.     parity = 0;
  9394.     cmask = 0xff;
  9395.     cmdmsk = 0xff;
  9396.     return(success = 1);
  9397.     }
  9398.  
  9399. #ifndef NOXFER
  9400. /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
  9401.  
  9402.     if (cx == XXSEN            /* SEND */
  9403. #ifdef PIPESEND
  9404.     || cx == XXCSEN            /* CSEND */
  9405. #endif /* PIPESEND */
  9406.     || cx == XXMOVE            /* MOVE */
  9407.     || cx == XXMAI            /* MAIL */
  9408. #ifdef CK_RESEND
  9409.     || cx == XXRSEN            /* RESEND */
  9410. #endif /* CK_RESEND */
  9411.     ) {
  9412. #ifdef IKSD
  9413.     if (inserver && !ENABLED(en_get)) {
  9414.         printf("?Sorry, sending files is disabled\n");
  9415.         return(-9);
  9416.     }
  9417. #endif /* IKSD */
  9418.     return(doxsend(cx));
  9419.     }
  9420.  
  9421. /* PSEND, ADD, and REMOVE use special parsing */
  9422.  
  9423. #ifdef ADDCMD
  9424.     /* ADD and REMOVE */
  9425.     if (cx == XXADD || cx == XXREMV) {
  9426.     char * m;
  9427.     m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
  9428.     x = cmkey(addtab,naddtab,m,"",xxstring);
  9429.     if (x < 0)
  9430.       return(x);
  9431. #ifndef NOMSEND
  9432.     if (x == ADD_SND)
  9433.       return(addsend(cx));
  9434.     else
  9435. #endif /* NOMSEND */
  9436.       return(doadd(cx,x));
  9437.     }
  9438. #endif /* ADDCMD */
  9439.  
  9440. #ifdef CK_RESEND
  9441.     if (cx == XXPSEN) {            /* PSEND */
  9442.     int seekto = 0;            /* FIX THIS */
  9443.  
  9444.     cmarg = cmarg2 = "";
  9445.     x = cmifi("File to partially send", "", &s, &y, xxstring);
  9446.     if (x < 0) {
  9447.         if (x == -3) {
  9448.         printf("?A file specification is required\n");
  9449.         return(-9);
  9450.         } else return(x);
  9451.     }
  9452.     nfils = -1;            /* Files come from internal list. */
  9453. #ifndef NOMSEND
  9454.         addlist = 0;            /* Don't use SEND-LIST. */
  9455.         filenext = NULL;
  9456. #endif /* NOMSEND */
  9457.     ckstrncpy(line,s,LINBUFSIZ);    /* Save copy of string just parsed. */
  9458.     debug(F110,"PSEND line",line,0);
  9459.     if (y != 0) {
  9460.         printf("?Sorry, wildcards not permitted in this command\n");
  9461.         return(-9);
  9462.     }
  9463.     if (sizeof(int) < 4) {
  9464.         printf("?Sorry, this command needs 32-bit integers\n");
  9465.         return(-9);
  9466.     }
  9467.     x = cmnum("starting position (byte number)",
  9468.           "",10,&seekto,xxstring);
  9469.     if (x < 0)
  9470.       return(x);
  9471.     zfnqfp(s,fspeclen,fspec);    /* Get full path */
  9472.     if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
  9473.       return(x);
  9474.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9475.  
  9476. #ifdef IKSD
  9477.     if (inserver && !ENABLED(en_get)) {
  9478.         printf("?Sorry, sending files is disabled\n");
  9479.         return(-9);
  9480.     }
  9481. #endif /* IKSD */
  9482. #ifdef PIPESEND
  9483.     if (sndfilter) {
  9484.         printf("?Sorry, no PSEND while SEND FILTER selected\n");
  9485.         return(-9);
  9486.     }
  9487. #endif /* PIPESEND */
  9488. #ifdef CK_XYZ
  9489.     if ((protocol == PROTO_X || protocol == PROTO_XC)) {
  9490.         printf("Sorry, PSEND works only with Kermit protocol\n");
  9491.         return(-9);
  9492.     }
  9493. #endif /* CK_XYZ */
  9494.  
  9495.     cmarg2 = brstrip(tmpbuf);    /* Strip braces */
  9496.     cmarg = line;            /* File to send */
  9497.     debug(F110,"PSEND filename",cmarg,0);
  9498.     debug(F110,"PSEND as-name",cmarg2,0);
  9499.     sendstart = seekto;
  9500.     sstate = 's';            /* Set start state to SEND */
  9501. #ifndef NOMSEND
  9502.     addlist = 0;
  9503.     filenext = NULL;
  9504. #endif /* NOMSEND */
  9505.     sendmode = SM_PSEND;
  9506. #ifdef MAC
  9507.     what = W_SEND;
  9508.     scrcreate();
  9509. #endif /* MAC */
  9510.     if (local) {            /* If in local mode, */
  9511.         displa = 1;            /* enable file transfer display */
  9512.     }
  9513.     return(0);
  9514.     }
  9515. #endif /* CK_RESEND */
  9516. #endif /* NOXFER */
  9517.  
  9518. #ifndef NOXFER
  9519. #ifndef NOMSEND
  9520.     if (cx == XXMSE || cx == XXMMOVE) {
  9521. #ifdef NEWFTP
  9522.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9523.       return(doftpput(cx,0));
  9524. #endif /* NEWFTP */
  9525. #ifdef CK_XYZ
  9526.     if (protocol == PROTO_X || protocol == PROTO_XC) {
  9527.         printf(
  9528. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  9529.            );
  9530.         return(-9);
  9531.     }
  9532. #endif /* CK_XYZ */
  9533.         return(doxsend(cx));
  9534.     }
  9535.  
  9536. #ifdef COMMENT                /* (moved to doxsend) */
  9537.     if (cx == XXMSE || cx == XXMMOVE) {    /* MSEND and MMOVE commands */
  9538.     nfils = 0;            /* Like getting a list of */
  9539.     lp = line;            /* files on the command line */
  9540.     addlist = 0;            /* Do not use SEND-LIST */
  9541.     filenext = NULL;        /* Ditto ! */
  9542.  
  9543.     while (1) {
  9544.         char *p;
  9545.         if ((x = cmifi("Names of files to send, separated by spaces","",
  9546.                &s,&y,xxstring)) < 0) {
  9547.         if (x == -3) {
  9548.             if (nfils <= 0) {
  9549.             printf("?A file specification is required\n");
  9550.             return(-9);
  9551.             } else break;
  9552.         }
  9553.         return(x);
  9554.         }
  9555.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  9556.         p = lp;            /* remember pointer, */
  9557.         while (*lp++ = *s++)    /* and copy it into buffer */
  9558.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  9559.           printf("?MSEND list too long\n");
  9560.           line[0] = NUL;
  9561.           return(-9);
  9562.           }
  9563.         debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
  9564.         if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
  9565. #ifdef ZFNQFP
  9566.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  9567.         p = tmpbuf;
  9568. #endif /* ZFNQFP */
  9569.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  9570.         strcat(fspec,p);    /* safe */
  9571.         strcat(fspec," ");    /* safe */
  9572.         } else printf("WARNING - \\v(filespec) buffer overflow\n");
  9573.     }
  9574.     cmlist = msfiles;        /* Point cmlist to pointer array */
  9575.     cmarg2 = "";            /* No internal expansion list (yet) */
  9576.     sndsrc = nfils;            /* Filenames come from cmlist */
  9577.     sendmode = SM_MSEND;        /* Remember this kind of SENDing */
  9578.     sstate = 's';            /* Set start state for SEND */
  9579.     if (cx == XXMMOVE)        /* If MMOVE'ing, */
  9580.       moving = 1;            /*  set this flag. */
  9581. #ifdef MAC
  9582.     what = W_SEND;
  9583.     scrcreate();
  9584. #endif /* MAC */
  9585.     if (local) {            /* If in local mode, */
  9586.         displa = 1;            /* turn on file transfer display */
  9587.         ttflui();            /* and flush tty input buffer. */
  9588.     }
  9589.     return(0);
  9590.     }
  9591. #endif /* COMMENT */
  9592. #endif /* NOMSEND */
  9593. #endif /* NOXFER */
  9594.  
  9595. #ifndef NOSERVER
  9596.     if (cx == XXSER) {            /* SERVER */
  9597. #ifdef CK_XYZ
  9598.     if (protocol != PROTO_K) {
  9599.         printf("Sorry, SERVER only works with Kermit protocol\n");
  9600.         return(-9);
  9601.     }
  9602. #endif /* CK_XYZ */
  9603. #ifdef COMMENT
  9604. /*
  9605.   Parse for time limit, but since we don't use it yet,
  9606.   the parsing is commented out.
  9607. */
  9608.     x_ifnum = 1;            /* Turn off internal complaints */
  9609.     y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
  9610.           "0", 10, &x, xxstring
  9611.           );
  9612.     x_ifnum = 0;
  9613.     if (y < 0) {
  9614.         if (y == -2) {        /* Invalid number or expression */
  9615.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  9616.         if (zz < 0L) {
  9617.             printf("?Number, expression, or time of day required\n");
  9618.             return(-9);
  9619.         } else {
  9620.             char now[32];    /* Current time */
  9621.             char *p;
  9622.             long tnow;
  9623.             p = now;
  9624.             ztime(&p);
  9625.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  9626.             if (zz < tnow)    /* User's time before now */
  9627.               zz += 86400L;    /* So make it tomorrow */
  9628.             zz -= tnow;        /* Seconds from now. */
  9629.         }
  9630.         } else
  9631.           return(y);
  9632.     }
  9633.     if (zz > -1L) {
  9634.         x = zz;
  9635.         if (zz != (long) x) {
  9636.         printf(
  9637. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  9638.                );
  9639.         return(-9);
  9640.         }
  9641.     }
  9642.     if (x < 0)
  9643.       x = 0;
  9644. #endif /* COMMENT */
  9645.  
  9646.     if ((x = cmcfm()) < 0) return(x);
  9647.     sstate = 'x';
  9648. #ifdef MAC
  9649.     what = W_RECV;
  9650.     scrcreate();
  9651. #endif /* MAC */
  9652.     if (local) displa = 1;
  9653. #ifdef AMIGA
  9654.     reqoff();            /* No DOS requestors while server */
  9655. #endif /* AMIGA */
  9656.     return(0);
  9657.     }
  9658. #endif /* NOSERVER */
  9659.  
  9660.     if (cx == XXSAVE) {            /* SAVE command */
  9661.     x = cmkey(savtab,nsav,"option","keymap",xxstring);
  9662.     if (x == -3) {
  9663.         printf("?You must specify an option to save\n");
  9664.         return(-9);
  9665.     }
  9666.     if (x < 0) return(x);
  9667.     /* have to set success separately for each item in doprm()... */
  9668.     /* actually not really, could have just had doprm return 0 or 1 */
  9669.     /* and set success here... */
  9670.     y = dosave(x);
  9671.     if (y == -3) {
  9672.         printf("?More fields required\n");
  9673.         return(-9);
  9674.     } else return(y);
  9675.     }
  9676.  
  9677.     if (cx == XXSET) {            /* SET command */
  9678.     x = cmkey(prmtab,nprm,"Parameter","",xxstring);
  9679.     if (x == -3) {
  9680.         printf("?You must specify a parameter to set\n");
  9681.         return(-9);
  9682.     }
  9683.     if (x < 0) return(x);
  9684.     /* have to set success separately for each item in doprm()... */
  9685.     /* actually not really, could have just had doprm return 0 or 1 */
  9686.     /* and set success here... */
  9687.     y = doprm(x,0);
  9688.     if (y == -3) {
  9689.         printf("?More fields required\n");
  9690.         return(-9);
  9691.     } else return(y);
  9692.     }
  9693.  
  9694. #ifndef NOPUSH
  9695.     if (cx == XXSHE            /* SHELL (system) command */
  9696.     || cx == XXEXEC            /* exec() */
  9697.     ) {
  9698.     int rx = 0;
  9699.     char * p = NULL;
  9700.     int i /* ,n */ ;
  9701. #ifdef UNIXOROSK
  9702.     char * args[256];
  9703. #endif /* UNIXOROSK */
  9704.  
  9705. #ifdef IKSD
  9706.     if (inserver && (nopush || !ENABLED(en_hos))) {
  9707.         printf("?Sorry, host command access is disabled\n");
  9708.         return(-9);
  9709.     }
  9710. #endif /* IKSD */
  9711.  
  9712. #ifdef CKEXEC
  9713.     if (cx == XXEXEC) {        /* EXEC (overlay ourselves) */
  9714.         struct FDB sw, fl;
  9715.         cmfdbi(&sw,            /* First FDB - command switches */
  9716.            _CMKEY,        /* fcode */
  9717.            "Command to overlay C-Kermit\n or switch", /* hlpmsg */
  9718.            "",            /* default */
  9719.            "",            /* addtl string data */
  9720.            1,            /* addtl numeric data 1: tbl size */
  9721.            4,            /* addtl numeric data 2: 4 = cmswi */
  9722.            xxstring,        /* Processing function */
  9723.            redirsw,        /* Keyword table */
  9724.            &fl            /* Pointer to next FDB */
  9725.            );
  9726.         cmfdbi(&fl,            /* 2nd FDB - command to exec */
  9727.            _CMFLD,        /* fcode */
  9728.            "Command to overlay C-Kermit", /* hlpmsg */
  9729.            "",            /* default */
  9730.            "",            /* addtl string data */
  9731.            0,            /* addtl numeric data 1 */
  9732.            0,            /* addtl numeric data 2 */
  9733.            xxstring,
  9734.            NULL,
  9735.            NULL            /* No more after this */
  9736.            );
  9737.         while (1) {
  9738.         x = cmfdb(&sw);        /* Parse something */
  9739.         debug(F101,"exec cmfdb","",x);
  9740.         if (x < 0)
  9741.           return(x);
  9742.         /* Generalize this if we add more switches */
  9743.         if (cmresult.fcode == _CMKEY) {
  9744.             rx = 1;
  9745.             continue;
  9746.         }
  9747.         if (cmresult.fcode == _CMFLD)
  9748.           break;
  9749.         return(-2);
  9750.         }
  9751.         ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
  9752.         if (!tmpbuf[0]) {
  9753.         printf("?Command required\n");
  9754.         return(-9);
  9755.         }
  9756.         p = brstrip(tmpbuf);
  9757.         args[0] = NULL;        /* Set argv[0] to it */
  9758.         makestr(&args[0],p);
  9759.         for (i = 1; i < 255; i++) {    /* Get arguments for command */
  9760.         if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
  9761.             if (x == -3) {
  9762.             if ((x = cmcfm()) < 0)
  9763.               return(x);
  9764.             break;
  9765.             } else
  9766.               return(x);
  9767.         }
  9768.         args[i] = NULL;
  9769.         s = brstrip(s);
  9770.         makestr(&args[i],s);
  9771.         }
  9772.         args[i] = NULL;
  9773.     } else {
  9774. #endif /* CKEXEC */
  9775.         if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
  9776.           return(x);
  9777. #ifdef CKEXEC
  9778.     }
  9779. #endif /* CKEXEC */
  9780.         if (nopush)
  9781.           return(success = 0);
  9782. #ifdef CK_APC
  9783.     if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  9784.       return(success = 0);
  9785. #endif /* CK_APC */
  9786.     conres();            /* Make console normal  */
  9787. #ifdef OS2
  9788.     if (!(s && *s)) {
  9789.         os2push();
  9790.             return(success = 1);
  9791.     } else
  9792. #endif /* OS2 */
  9793.       if (cx == XXSHE) {
  9794.           x = zshcmd(s);
  9795.           debug(F101,"RUN zshcmd code","",x);
  9796.           concb((char)escape);
  9797.           return(success = x);
  9798. #ifdef CKEXEC
  9799.       } else {
  9800. #ifdef DEBUG
  9801.           if (deblog) {
  9802.           debug(F111,"EXEC cmd",p,0);
  9803.           for (i = 0; i < 256 && args[i]; i++)
  9804.             debug(F111,"EXEC arg",args[i],i);
  9805.           }
  9806. #endif /* DEBUG */
  9807.           if (p) {
  9808.           z_exec(p,args,rx);    /* Overlay ourself */
  9809.           debug(F100,"EXEC fails","",0);
  9810.           concb((char)escape);    /* In case it returns */
  9811.           }
  9812.           return(success = 0);
  9813. #endif /* CKEXEC */
  9814.       }
  9815.     }
  9816.  
  9817. #ifdef CK_REDIR
  9818.     if (cx == XXFUN) {            /* REDIRECT */
  9819. #ifdef CK_APC
  9820.     if ((apcactive == APC_LOCAL) ||
  9821.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9822.       return(success = 0);
  9823. #endif /* CK_APC */
  9824.     ckmakmsg(tmpbuf,
  9825.          TMPBUFSIZ,
  9826.          "Local command to run,\n",
  9827.          "with its standard input/output redirected to ",
  9828.          local ? ttname : "the communications connection",
  9829.          "\n"
  9830.          );
  9831.     if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
  9832.       return(x);
  9833.         if (nopush) {
  9834.             printf("?REDIRECT disabled\n");
  9835.             return(success=0);
  9836.         }
  9837.     if (!local) {
  9838.         printf("?SET LINE or SET HOST required first\n");
  9839.         return(-9);
  9840.     }
  9841.     if (!*s) {
  9842.         printf("?REDIRECT requires a command to redirect\n");
  9843.         return(-9);
  9844.     }
  9845.     return(success = ttruncmd(s));
  9846.     }
  9847. #endif /* CK_REDIR */
  9848. #endif /* NOPUSH */
  9849.  
  9850. #ifndef NOSHOW
  9851.     if (cx == XXSHO) {            /* SHOW */
  9852.     x = cmkey(shotab,nsho,"","parameters",xxstring);
  9853.     if (x < 0) return(x);
  9854.     return(doshow(x));
  9855.     }
  9856. #endif /* NOSHOW */
  9857.  
  9858. #ifndef MAC
  9859.     if (cx == XXSPA) {            /* SPACE */
  9860. #ifdef IKSD
  9861.     if (inserver && !ENABLED(en_spa)) {
  9862.         printf("?Sorry, SPACE command disabled\n");
  9863.         return(-9);
  9864.     }
  9865. #endif /* IKSD */
  9866. #ifdef datageneral
  9867.     /* AOS/VS can take an argument after its "space" command. */
  9868.     if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0)
  9869.       return(x);
  9870.     if (nopush) {
  9871.         printf("?Sorry, SPACE command disabled\n");
  9872.         return(-9);
  9873.     } else if (*s == NUL) {
  9874.         xsystem(SPACMD);
  9875.     } else {
  9876.         ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL);
  9877.         xsystem(line);
  9878.     }
  9879. #else
  9880. #ifdef OS2
  9881.     if ((x = cmtxt("Press Enter for current disk,\n\
  9882.  or specify a disk letter like A:","",&s,xxstring)) < 0)
  9883.       return(x);
  9884.     if (*s == NUL) {        /* Current disk */
  9885.             unsigned long space = zdskspace(0);
  9886.             if (space > 0 && space < 1024)
  9887.               printf(" Free space: unknown\n");
  9888.             else
  9889.           printf(" Free space: %ldK\n", space/1024L);
  9890.     } else {
  9891.         int drive = toupper(*s);
  9892.             unsigned long space = zdskspace(drive - 'A' + 1);
  9893.             if (space > 0 && space < 1024)
  9894.               printf(" Drive %c: unknown free\n");
  9895.             else
  9896.               printf(" Drive %c: %ldK free\n", drive,space / 1024L);
  9897.     }
  9898. #else
  9899. #ifdef UNIXOROSK
  9900.     x = cmdir("Confirm for current disk,\n\
  9901.  or specify a disk device or directory","",&s,xxstring);
  9902.     if (x == -3)
  9903.       s = "";
  9904.     else if (x < 0)
  9905.       return(x);
  9906.         ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9907.         s = tmpbuf;
  9908.     if ((x = cmcfm()) < 0) return(x);
  9909.     if (nopush) {
  9910.         printf("?Sorry, SPACE command disabled\n");
  9911.         return(-9);
  9912.     }
  9913.     if (!*s) {            /* Current disk */
  9914.         xsystem(SPACMD);
  9915.     } else {            /* Specified disk */
  9916.         ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL);
  9917.         xsystem(line);
  9918.     }
  9919. #else
  9920.     if ((x = cmcfm()) < 0) return(x);
  9921.     if (nopush) {
  9922.         printf("?Sorry, SPACE command disabled\n");
  9923.         return(-9);
  9924.     }
  9925.     xsystem(SPACMD);
  9926. #endif /* UNIXOROSK */
  9927. #endif /* OS2 */
  9928. #endif /* datageneral */
  9929.     return(success = 1);        /* Pretend it worked */
  9930.     }
  9931. #endif /* MAC */
  9932.  
  9933. #ifndef NOXFER
  9934.     if (cx == XXSTA) {            /* STATISTICS */
  9935.     if ((x = cmkey(stattab,2,"Carriage return, or option",
  9936.                "/brief",xxstring)) < 0)
  9937.       return(x);
  9938.     if ((y = cmcfm()) < 0) return(y);
  9939.     return(success = dostat(x));
  9940.     }
  9941. #endif /* NOXFER */
  9942.  
  9943.     if (cx == XXSTO || cx == XXEND) {    /* STOP, END, or POP */
  9944.     if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0)
  9945.       return(y);
  9946.     if ((y = cmtxt("Message to print","",&s,xxstring)) < 0)
  9947.       return(y);
  9948.     s = brstrip(s);
  9949.     if (*s) printf("%s\n",s);
  9950.     if (cx == XXSTO) {
  9951.         dostop();
  9952.     } else {
  9953.         doend(x);
  9954.     }
  9955.     return(success = (x == 0));
  9956.     }
  9957.     if (cx == XXSUS) {            /* SUSPEND */
  9958.     if ((y = cmcfm()) < 0) return(y);
  9959. #ifdef NOJC
  9960.     printf("Sorry, this version of Kermit cannot be suspended\n");
  9961. #else
  9962. #ifdef IKSD
  9963.     if (inserver) {
  9964.         printf("?Sorry, IKSD can not be suspended\n");
  9965.         return(-9);
  9966.     } else
  9967. #endif /* IKSD */
  9968.       if (nopush) {
  9969.         printf("?Sorry, access to system is disabled\n");
  9970.         return(-9);
  9971.     }
  9972.     stptrap(0);
  9973. #endif /* NOJC */
  9974.     return(0);
  9975.     }
  9976.  
  9977.     if (cx == XXTAK) {            /* TAKE */
  9978.     char * scriptenv = NULL;    
  9979. #ifdef OS2
  9980.         char * GetAppData(int);
  9981.     extern char startupdir[],exedir[],inidir[];
  9982.     char * keymapenv = NULL;
  9983.         char * appdata0 = NULL, *appdata1 = NULL;
  9984.     int xx;
  9985. #define TAKEPATHLEN 4096
  9986. #else /* OS2 */
  9987. #define TAKEPATHLEN 1024
  9988. #endif /* OS2 */
  9989.     char takepath[TAKEPATHLEN];
  9990.  
  9991.     if (tlevel >= MAXTAKE-1) {
  9992.         printf("?Take files nested too deeply\n");
  9993.         return(-9);
  9994.     }
  9995. #ifdef OS2
  9996. #ifdef NT
  9997.     scriptenv = getenv("K95SCRIPTS");
  9998.     keymapenv = getenv("K95KEYMAPS");
  9999.         makestr(&appdata0,(char *)GetAppData(0));
  10000.         makestr(&appdata1,(char *)GetAppData(1));
  10001. #else /* NT */
  10002.     scriptenv = getenv("K2SCRIPTS");
  10003.     keymapenv = getenv("K2KEYMAPS");
  10004. #endif /* NT */
  10005. #endif /* OS2 */
  10006.  
  10007.     if (!scriptenv)            /* Let this work for Unix etc too */
  10008.       scriptenv = getenv("CK_SCRIPTS"); /* Use this if defined */
  10009. #ifndef OS2
  10010.     if (!scriptenv)            /* Otherwise use home directory */
  10011.       scriptenv = homepath();
  10012. #endif /* OS2 */
  10013.     if (!scriptenv)
  10014.       scriptenv = "";
  10015.     ckstrncpy(takepath,scriptenv,TAKEPATHLEN);
  10016.     debug(F110,"TAKE initial takepath",takepath,0);
  10017.  
  10018. #ifdef OS2
  10019.     if (!keymapenv)
  10020.       keymapenv = getenv("CK_KEYMAPS");
  10021.     if (!keymapenv)
  10022.       keymapenv = "";
  10023.  
  10024.     ckstrncat(takepath,
  10025.           (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
  10026.           TAKEPATHLEN
  10027.           );
  10028.     ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN);
  10029.     ckstrncat(takepath,
  10030.           (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
  10031.           TAKEPATHLEN
  10032.           );
  10033.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  10034.     ckstrncat(takepath,";",TAKEPATHLEN);
  10035.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  10036.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  10037.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  10038.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  10039.  
  10040.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  10041.     ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
  10042.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  10043.     ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
  10044.     ckstrncat(takepath,appdata1,TAKEPATHLEN);
  10045.     ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
  10046.  
  10047.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  10048.     ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
  10049.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  10050.     ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
  10051.     ckstrncat(takepath,appdata0,TAKEPATHLEN);
  10052.     ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
  10053.  
  10054.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  10055.     ckstrncat(takepath,";",TAKEPATHLEN);
  10056.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  10057.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  10058.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  10059.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  10060.  
  10061.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  10062.     ckstrncat(takepath,";",TAKEPATHLEN);
  10063.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  10064.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  10065.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  10066.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  10067.  
  10068.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  10069.     ckstrncat(takepath,";",TAKEPATHLEN);
  10070.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  10071.     ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
  10072.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  10073.     ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
  10074. #endif /* OS2 */
  10075.     debug(F110,"TAKE final takepath",takepath,0);
  10076.  
  10077.     if ((y = cmifip("Commands from file",
  10078.             "",&s,&x,0,takepath,xxstring)) < 0) {
  10079.         if (y == -3) {
  10080.         printf("?A file name is required\n");
  10081.         return(-9);
  10082.         } else
  10083.           return(y);
  10084.     }
  10085.     if (x != 0) {
  10086.         printf("?Wildcards not allowed in command file name\n");
  10087.         return(-9);
  10088.     }
  10089.     ckstrncpy(line,s,LINBUFSIZ);
  10090.     debug(F110,"TAKE file",s,0);
  10091.     if (isdir(s)) {
  10092.         printf("?Can't execute a directory - \"%s\"\n", s);
  10093.         return(-9);
  10094.     }
  10095. #ifndef NOTAKEARGS
  10096.     {
  10097.         char * p;
  10098.         x = strlen(line);
  10099.         debug(F111,"TAKE args",line,x);
  10100.         p = line + x + 1;
  10101.         if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0)
  10102.           return(y);
  10103.         if (*s) {            /* Args given? */
  10104.         ckstrncpy(p,s,LINBUFSIZ-x-1);
  10105. #ifdef ZFNQFP
  10106.         zfnqfp(line,TMPBUFSIZ,tmpbuf);
  10107.         s = tmpbuf;
  10108. #else
  10109.         s = line;
  10110. #endif /* ZFNQFP */
  10111.         debug(F110,"TAKE filename",s,0);
  10112.         x = strlen(s);
  10113.         debug(F101,"TAKE new len",s,x);
  10114.  
  10115. #ifdef COMMENT
  10116. /*
  10117.   This was added in C-Kermit 7.0 to allow args to be passed from the TAKE
  10118.   command to the command file.  But it overwrites the current argument vector,
  10119.   which is at best surprising, and at worst unsafe.
  10120. */
  10121.         addmac("%0",s);        /* Define %0 = name of file */
  10122.         varnam[0] = '%';
  10123.         varnam[2] = '\0';
  10124.         debug(F110,"take arg 0",s,0);
  10125.         debug(F110,"take args",p,0);
  10126.         for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */
  10127.             varnam[1] = (char) (y + '0');
  10128.             delmac(varnam,0);
  10129.         }
  10130.         xwords(p,MAXARGLIST,NULL,0); /* Assign new args */
  10131.         debug(F110,"take args",p,0);
  10132. #else
  10133. /*
  10134.   This method is used in 8.0.  If the TAKE command includes arguments, we
  10135.   insert an intermediate temporary macro between the current level; we pass
  10136.   the arguments to the macro and then the macro TAKEs the command file.
  10137.   If the user Ctrl-C's out of the TAKE file, some temporary macro definitions
  10138.   and other small malloc'd bits might be left behind.
  10139. */
  10140.         {
  10141.             char * q = NULL;
  10142.             char * r = NULL;
  10143.             int k, m;
  10144.             m = maclvl;
  10145.             q = (char *)malloc(x+24);
  10146.             if (q) {
  10147.             r = (char *)malloc(x+24);
  10148.             if (r) {
  10149.                 sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */
  10150.                 sprintf(r,"take %s",s); /* safe */
  10151.                 k = addmac(q,r);
  10152.                 if (k > -1) {
  10153.                 dodo(k,p,0);
  10154.                 while (maclvl > m) {
  10155.                     sstate = (CHAR) parser(1);
  10156.                     if (sstate) proto();
  10157.                 }
  10158.                 }
  10159.                 k = delmac(q,0);
  10160.                 free(q);
  10161.                 free(r);
  10162.                 return(success);
  10163.             }
  10164.             }
  10165.         }
  10166.         return(success = 0);
  10167. #endif /* COMMENT */
  10168.         }
  10169.     }
  10170. #else
  10171.     if ((y = cmcfm()) < 0) return(y);
  10172. #endif /* NOTAKEARGS */
  10173.     return(success = dotake(line));
  10174.     }
  10175.  
  10176. #ifndef NOLOCAL
  10177. #ifdef OS2
  10178.     if (cx == XXVIEW) {            /* VIEW Only Terminal mode */
  10179.     viewonly = TRUE;
  10180.     success = doconect(0, 0);
  10181.     viewonly = FALSE;
  10182.     return success;
  10183.     }
  10184. #endif /* OS2 */
  10185.  
  10186. #ifdef NETCONN
  10187.     if (cx == XXTEL || cx == XXIKSD) {    /* TELNET */
  10188.     int x,z;
  10189. #ifdef OS2
  10190.     if (!tcp_avail) {
  10191.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  10192. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n");
  10193.         success = 0;
  10194.         return(-9);
  10195.     } else
  10196. #endif /* OS2 */
  10197.       {
  10198.       x = nettype;            /* Save net type in case of failure */
  10199.       z = ttnproto;            /* Save protocol in case of failure */
  10200.       nettype = NET_TCPB;
  10201.       ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT;
  10202.       if ((y = setlin(XYHOST,0,1)) <= 0) {
  10203.               nettype = x;        /* Failed, restore net type. */
  10204.               ttnproto = z;        /* and protocol */
  10205.               success = 0;
  10206.       }
  10207.       didsetlin++;
  10208.         }
  10209.     return(y);
  10210.     }
  10211.  
  10212. #ifndef PTYORPIPE
  10213. #ifdef NETCMD
  10214. #define PTYORPIPE
  10215. #else
  10216. #ifdef NETPTY
  10217. #define PTYORPIPE
  10218. #endif /* NETPTY */
  10219. #endif /* NETCMD */
  10220. #endif /* PTYORPIPE */
  10221.  
  10222. #ifdef PTYORPIPE
  10223.     if (cx == XXPIPE || cx == XXPTY) {    /* PIPE or PTY */
  10224.     int x;
  10225.     extern int netsave;
  10226.     x = nettype;            /* Save net type in case of failure */
  10227.     nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY;
  10228.     if ((y = setlin(XYHOST,0,1)) < 0) {
  10229.         nettype = x;        /* Failed, restore net type. */
  10230.         ttnproto = z;        /* and protocol */
  10231.         success = 0;
  10232.     }
  10233.     didsetlin++;
  10234.     netsave = x;
  10235.     return(y);
  10236.     }
  10237. #endif /* PTYORPIPE */
  10238.  
  10239. #ifdef ANYSSH
  10240.     if (cx == XXSSH) {            /* SSH (Secure Shell) */
  10241.     extern int netsave;
  10242. #ifdef SSHBUILTIN
  10243.     int k, x, havehost = 0, trips = 0;
  10244.         int    tmpver = -1, tmpxfw = -1;
  10245. #ifndef SSHTEST
  10246.         extern int sl_ssh_xfw, sl_ssh_xfw_saved;
  10247.         extern int sl_ssh_ver, sl_ssh_ver_saved;
  10248. #endif /* SSHTEST */
  10249.         extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
  10250.         extern char * slmsg;
  10251.     extern char uidbuf[], sl_uidbuf[];
  10252.         extern char pwbuf[], * g_pswd;
  10253.         extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
  10254.     struct FDB sw, kw, fl;
  10255.  
  10256.         if (ssh_tmpstr)
  10257.       memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  10258.         makestr(&ssh_tmpstr,NULL);
  10259.         makestr(&ssh_tmpuid,NULL);
  10260.         makestr(&ssh_tmpcmd,NULL);
  10261.         makestr(&ssh_tmpport,NULL);
  10262.  
  10263.     cmfdbi(&kw,            /* 1st FDB - commands */
  10264.            _CMKEY,            /* fcode */
  10265.            "host [ port ],\n or action",    /* hlpmsg */
  10266.            "",            /* default */
  10267.            "",            /* addtl string data */
  10268.            nsshcmd,            /* addtl numeric data 1: tbl size */
  10269.            0,            /* addtl numeric data 2: 0 = keyword */
  10270.            xxstring,        /* Processing function */
  10271.            sshkwtab,        /* Keyword table */
  10272.            &fl            /* Pointer to next FDB */
  10273.            );
  10274.     cmfdbi(&fl,            /* Host */
  10275.            _CMFLD,            /* fcode */
  10276.            "",            /* hlpmsg */
  10277.            "",            /* default */
  10278.            "",            /* addtl string data */
  10279.            0,            /* addtl numeric data 1 */
  10280.            0,            /* addtl numeric data 2 */
  10281.            xxstring,
  10282.            NULL,
  10283.            NULL
  10284.            );
  10285.  
  10286.     x = cmfdb(&kw);
  10287.     if (x == -3) {
  10288.         printf("?ssh what?\n");
  10289.         return(-9);
  10290.     }
  10291.     if (x < 0)
  10292.       return(x);
  10293.     havehost = 0;
  10294.     if (cmresult.fcode == _CMFLD) {
  10295.         havehost = 1;
  10296.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
  10297.         cmresult.nresult = XSSH_OPN;
  10298.     }
  10299.     switch (cmresult.nresult) {    /* SSH keyword */
  10300.       case XSSH_OPN:        /* SSH OPEN */
  10301.         if (!havehost) {
  10302.         if ((x = cmfld("Host","",&s,xxstring)) < 0)
  10303.           return(x);
  10304.         ckstrncpy(line,s,LINBUFSIZ);
  10305.         }
  10306.         /* Parse [ port ] [ switches ] */
  10307.         cmfdbi(&kw,            /* Switches */
  10308.            _CMKEY,
  10309.            "Port number or service name,\nor switch",
  10310.            "",
  10311.            "",
  10312.            nsshopnsw,
  10313.            4,
  10314.            xxstring,
  10315.            sshopnsw,
  10316.            &fl
  10317.            );
  10318.         cmfdbi(&fl,            /* Port number or service name */
  10319.            _CMFLD,
  10320.            "",
  10321.            "",
  10322.            "",
  10323.            0,
  10324.            0,
  10325.            xxstring,
  10326.            NULL,
  10327.            NULL
  10328.            );
  10329.         trips = 0;            /* Explained below */
  10330.         while (1) {            /* Parse port and switches */
  10331.         x = cmfdb(&kw);        /* Get a field */
  10332.         if (x == -3)        /* User typed CR so quit from loop */
  10333.           break;
  10334.         if (x < 0)        /* Other parse error, pass it back */
  10335.           return(x);
  10336.         switch (cmresult.fcode) { /* Field or Keyword? */
  10337.                   case _CMFLD:          /* Field */
  10338.                     makestr(&ssh_tmpport,cmresult.sresult);
  10339.             break;
  10340.           case _CMKEY:        /* Keyword */
  10341.             switch (cmresult.nresult) {    /* Which one? */
  10342.               case SSHSW_USR:            /* /USER: */
  10343.             if (!cmgbrk()) {
  10344.                 printf("?This switch requires an argument\n");
  10345.                 return(-9);
  10346.             }
  10347.             if ((y = cmfld("Username","",&s,xxstring)) < 0)
  10348.               return(y);
  10349.             s = brstrip(s);
  10350.             makestr(&ssh_tmpuid,s);
  10351.             break;
  10352.                       case SSHSW_PWD:
  10353.             if (!cmgbrk()) {
  10354.                 printf("?This switch requires an argument\n");
  10355.                 return(-9);
  10356.             }
  10357.             debok = 0;
  10358.             if ((x = cmfld("Password","",&s,xxstring)) < 0) {
  10359.                 if (x == -3) {
  10360.                 makestr(&ssh_tmpstr,"");
  10361.                 } else {
  10362.                 return(x);
  10363.                 }
  10364.             } else {
  10365.                 s = brstrip(s);
  10366.                 if ((x = (int)strlen(s)) > PWBUFL) {
  10367.                 makestr(&slmsg,"Internal error");
  10368.                 printf("?Sorry, too long - max = %d\n",PWBUFL);
  10369.                 return(-9);
  10370.                 }
  10371.                 makestr(&ssh_tmpstr,s);
  10372.             }
  10373.             break;
  10374.  
  10375.               case SSHSW_VER:
  10376.             if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
  10377.               return(x);
  10378.             if (z < 1 || z > 2) {
  10379.                 printf("?Out of range: %d\n",z);
  10380.                 return(-9);
  10381.             }
  10382.                         tmpver = z;
  10383.             break;
  10384.               case SSHSW_CMD:
  10385.               case SSHSW_SUB:
  10386.             if ((x = cmfld("Text","",&s,xxstring)) < 0)
  10387.               return(x);
  10388.                         makestr(&ssh_tmpcmd,s);
  10389.             ssh_cas = (cmresult.nresult == SSHSW_SUB);
  10390.             break;
  10391.               case SSHSW_X11:
  10392.             if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  10393.               return(x);
  10394.                         tmpxfw = x;
  10395.             break;
  10396.               default:
  10397.                 return(-2);
  10398.             }
  10399.         }
  10400.         if (trips++ == 0) {    /* After first time through */
  10401.             cmfdbi(&kw,        /* only parse switches, not port. */
  10402.                _CMKEY,
  10403.                "Switch",
  10404.                "",
  10405.                "",
  10406.                nsshopnsw,
  10407.                4,
  10408.                xxstring,
  10409.                sshopnsw,
  10410.                NULL
  10411.                );
  10412.         }
  10413.         }
  10414.         if ((x = cmcfm()) < 0)    /* Get confirmation */
  10415.           return(x);
  10416.             if (clskconnx(1) < 0) {    /* Close current Kermit connection */
  10417.               if ( ssh_tmpstr ) {
  10418.                   memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  10419.                   makestr(&ssh_tmpstr,NULL);
  10420.               }
  10421.               return(success = 0);
  10422.             }
  10423.         makestr(&ssh_hst,line);    /* Stash everything */
  10424.         if (ssh_tmpuid) {
  10425.                 if (!sl_uid_saved) {
  10426.                     ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
  10427.                     sl_uid_saved = 1;
  10428.                 }
  10429.         ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
  10430.         makestr(&ssh_tmpuid,NULL);
  10431.         }
  10432.             if (ssh_tmpport) {
  10433.                 makestr(&ssh_prt,ssh_tmpport);
  10434.                 makestr(&ssh_tmpport,NULL);
  10435.             } else
  10436.                 makestr(&ssh_prt,NULL);
  10437.  
  10438.             if (ssh_tmpcmd) {
  10439.                 makestr(&ssh_cmd,brstrip(ssh_tmpcmd));
  10440.                 makestr(&ssh_tmpcmd,NULL);
  10441.             } else
  10442.                 makestr(&ssh_cmd,NULL);
  10443.  
  10444.             if (tmpver > -1) {
  10445. #ifndef SSHTEST
  10446.                 if (!sl_ssh_ver_saved) {
  10447.                     sl_ssh_ver = ssh_ver;
  10448.                     sl_ssh_ver_saved = 1;
  10449.                 }
  10450. #endif /* SSHTEST */
  10451.                 ssh_ver = tmpver;
  10452.             }
  10453.             if (tmpxfw > -1) {
  10454. #ifndef SSHTEST
  10455.                 if (!sl_ssh_xfw_saved) {
  10456.                     sl_ssh_xfw = ssh_xfw;
  10457.                     sl_ssh_xfw_saved = 1;
  10458.                 }
  10459. #endif /* SSHTEST */
  10460.                 ssh_xfw = tmpxfw;
  10461.             }
  10462.         if (ssh_tmpstr) {
  10463.         if (ssh_tmpstr[0]) {
  10464.             ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
  10465.             pwflg = 1;
  10466.             pwcrypt = 0;
  10467.         } else
  10468.           pwflg = 0;
  10469.         makestr(&ssh_tmpstr,NULL);
  10470.         }
  10471.         nettype = NET_SSH;
  10472.         if (mdmsav < 0)
  10473.           mdmsav = mdmtyp;
  10474.         mdmtyp = -nettype;
  10475.         x = 1;
  10476.  
  10477. #ifndef NOSPL
  10478.             makestr(&g_pswd,pwbuf);             /* Save global pwbuf */
  10479.             g_pflg = pwflg;                     /* and flag */
  10480.             g_pcpt = pwcrypt;
  10481. #endif /* NOSPL */
  10482.  
  10483.         /* Line parameter to ttopen() is ignored */
  10484.         k = ttopen(line,&x,mdmtyp, 0);
  10485.         if (k < 0) {
  10486.         printf("?Unable to connect to %s\n",ssh_hst);
  10487.         mdmtyp = mdmsav;
  10488.                 slrestor();
  10489.         return(success = 0);
  10490.         }
  10491.         duplex = 0;             /* Remote echo */
  10492.         ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
  10493.         debug(F110,"ssh ttname",ttname,0);
  10494.         makestr(&slmsg,NULL);    /* No SET LINE error message */
  10495.         cxtype = CXT_SSH;
  10496. #ifndef NODIAL
  10497.         dialsta = DIA_UNK;
  10498. #endif /* NODIAL */
  10499.         success = 1;        /* SET LINE succeeded */
  10500.         network = 1;        /* Network connection (not serial) */
  10501.         local = 1;            /* Local mode (not remote) */
  10502.         if ((reliable != SET_OFF || !setreliable))
  10503.           reliable = SET_ON;    /* Transport is reliable end to end */
  10504. #ifdef OS2
  10505.             DialerSend(OPT_KERMIT_CONNECT, 0);
  10506. #endif /* OS2 */
  10507.         setflow();            /* Set appropriate flow control */
  10508.  
  10509.         haveline = 1;
  10510. #ifdef CKLOGDIAL
  10511. #ifdef NETCONN
  10512.         dolognet();
  10513. #endif /* NETCONN */
  10514. #endif /* CKLOGDIAL */
  10515.  
  10516. #ifndef NOSPL
  10517.         if (local) {
  10518.         if (nmac) {        /* Any macros defined? */
  10519.             int k;        /* Yes */
  10520.             k = mlook(mactab,"on_open",nmac); /* Look this up */
  10521.             if (k >= 0) {                  /* If found, */
  10522.             if (dodo(k,ssh_hst,0) > -1)   /* set it up, */
  10523.               parser(1);              /* and execute it */
  10524.             }
  10525.         }
  10526.         }
  10527. #endif /* NOSPL */
  10528. #ifdef LOCUS        
  10529.         if (autolocus)
  10530.         setlocus(1,1);
  10531. #endif /* LOCUS */
  10532.  
  10533.     /* Command was confirmed so we can pre-pop command level. */
  10534.     /* This is so CONNECT module won't think we're executing a */
  10535.     /* script if CONNECT was the final command in the script. */
  10536.         if (cmdlvl > 0)
  10537.           prepop();
  10538.         success = doconect(0,cmdlvl == 0 ? 1 : 0);
  10539.         if (ttchk() < 0)
  10540.           dologend();
  10541.         return(success);
  10542.  
  10543.       case XSSH_CLR:
  10544.         if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) {
  10545.             if (y == -3) {
  10546.             printf("?clear what?\n");
  10547.             return(-9);
  10548.         }
  10549.             return(y);
  10550.         }
  10551.         if ((x = cmcfm()) < 0)
  10552.           return(x);
  10553.         switch (y) {
  10554.           case SSHC_LPF:
  10555.                 ssh_pf_lcl_n = 0;
  10556.         break;
  10557.           case SSHC_RPF:
  10558.         ssh_pf_rmt_n = 0;
  10559.         break;
  10560.           default:
  10561.         return(-2);
  10562.         }
  10563.             return(success = 1);    /* or whatever */
  10564.  
  10565.       case XSSH_AGT: {        /* SSH AGENT */
  10566.           int doeach = 0;
  10567.           if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0)
  10568.         return(y);
  10569.           switch (y) {
  10570.         case SSHA_ADD:        /* SSH AGENT ADD ... */
  10571.           if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10572. #ifndef SSHTEST
  10573.               if (x == -3)    /* No name given */
  10574.             doeach = 1;    /* so do them all */
  10575.               else
  10576. #endif /* SSHTEST */
  10577.             return(x);
  10578.           }
  10579.           ckstrncpy(line,s,LINBUFSIZ);
  10580.           if ((x = cmcfm()) < 0)
  10581.             return(x);
  10582. #ifdef SSHTEST
  10583.           x = 0;
  10584. #else
  10585.           if (doeach) {
  10586.                       int i;
  10587.                       x = 0;
  10588.                       for (i = 0; i < ssh_idf_n; i++)
  10589.             x += ssh_agent_add_file(ssh_idf[i]);
  10590.           } else
  10591.             x = ssh_agent_add_file(line);
  10592. #endif /* SSHTEST */
  10593.           return(success = (x == 0));
  10594.  
  10595.         case SSHA_DEL: {    /* SSH AGENT DELETE ... */
  10596.             int doall = 0;
  10597.             if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10598. #ifndef SSHTEST
  10599.             if (x == -3)    /* No name given */
  10600.               doall = 1;    /* so do them all */
  10601.             else
  10602. #endif /* SSHTEST */
  10603.               return(x);
  10604.             }
  10605.             ckstrncpy(line,s,LINBUFSIZ);
  10606.             if ((x = cmcfm()) < 0)
  10607.               return(x);
  10608. #ifdef SSHTEST
  10609.             x = 0;
  10610. #else
  10611.             if (doall)
  10612.               x = ssh_agent_delete_all();
  10613.             else
  10614.               x = ssh_agent_delete_file(line);
  10615. #endif /* SSHTEST */
  10616.             return(success = (x == 0));
  10617.         }
  10618.         case SSHA_LST: {
  10619.             int fingerprint = 0;
  10620.             if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) {
  10621.             if (y != -3)
  10622.               return(y);
  10623.             } else if (cmgbrk() > SP) {
  10624.             printf("?This switch does not take an argument\n");
  10625.             return(-9);
  10626.             } else if (y == SSHASW_FP) {
  10627.             fingerprint = 1;
  10628.             }
  10629.             if ((x = cmcfm()) < 0)
  10630.               return(x);
  10631. #ifdef SSHTEST
  10632.             return(success = 1);
  10633. #else
  10634.             return(success =
  10635.                (ssh_agent_list_identities(fingerprint) == 0));
  10636. #endif /* SSHTEST */
  10637.         }
  10638.         default:
  10639.           return(-2);
  10640.           }
  10641.       }
  10642.       case XSSH_ADD: {        /* SSH ADD */
  10643.           /* ssh add { local, remote } port host port */
  10644.           int cx, i, j, k;
  10645.           char * h;
  10646.           if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0)
  10647.         return(cx);
  10648.           if ((x = cmnum((cx == SSHF_LCL) ?
  10649.                  "Local port number" : "Remote port number",
  10650.                  "",10,&j,xxstring)) < 0)
  10651.         return(x);
  10652.           if ((x = cmfld("Host","",&s,xxstring)) < 0)
  10653.         return(x);
  10654.           makestr(&h,s);
  10655.           if ((x = cmnum("Port","",10,&k,xxstring)) < 0)
  10656.         return(x);
  10657.           if ((x = cmcfm()) < 0)
  10658.         return(x);
  10659.  
  10660.           switch(cx) {
  10661.         case SSHF_LCL:
  10662.            if (ssh_pf_lcl_n == 32) {
  10663.                printf(
  10664. "?Maximum number of local port forwardings already specified\n"
  10665.                  );
  10666.                free(h);
  10667.                return(success = 0);
  10668.           }
  10669.           ssh_pf_lcl[ssh_pf_lcl_n].p1 = j;
  10670.           makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h);
  10671.           makestr(&h,NULL);
  10672.           ssh_pf_lcl[ssh_pf_lcl_n].p2 = k;
  10673.           ssh_pf_lcl_n++;
  10674.           break;
  10675.         case SSHF_RMT:
  10676.           if (ssh_pf_rmt_n == 32) {
  10677.               printf(
  10678. "?Maximum number of remote port forwardings already specified\n"
  10679.                 );
  10680.               free(h);
  10681.               return(success = 0);
  10682.           }
  10683.           ssh_pf_rmt[ssh_pf_rmt_n].p1 = j;
  10684.           makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h);
  10685.           makestr(&h,NULL);
  10686.           ssh_pf_rmt[ssh_pf_rmt_n].p2 = k;
  10687.           ssh_pf_rmt_n++;
  10688.           }
  10689.           return(success = 1);
  10690.       }
  10691.       /* Not supporting arbitrary forwarding yet */
  10692.       case XSSH_FLP:        /* SSH FORWARD-LOCAL-PORT */
  10693.       case XSSH_FRP: {        /* SSH FORWARD-REMOTE-PORT */
  10694.           int li_port = 0;
  10695.           int to_port = 0;
  10696.           char * fw_host = NULL;
  10697.           int n;
  10698.               if ((x = cmnum(cmresult.nresult == XSSH_FLP ?
  10699.                               "local-port":"remote-port",
  10700.                               "",10,&li_port,xxstring)) < 0)
  10701.                   return(x);
  10702.               if (li_port < 1 || li_port > 65535) {
  10703.                   printf("?Out range - min: 1, max: 65535\n");
  10704.                   return(-9);
  10705.               }
  10706.           if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0)
  10707.         return(x);
  10708.               n = ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  10709.               fw_host = tmpbuf;
  10710.               if ((x = cmnum("host-port",ckuitoa(li_port),10,
  10711.                               &to_port,xxstring)) < 0)
  10712.                   return(x);
  10713.               if (to_port < 1 || to_port > 65535) {
  10714.                   printf("?Out range - min: 1, max: 65535\n");
  10715.                   return(-9);
  10716.               }
  10717.           if ((x = cmcfm()) < 0)
  10718.         return(x);
  10719.           switch (cmresult.nresult) {
  10720.                 case XSSH_FLP:    /* SSH FORWARD-LOCAL-PORT */
  10721. #ifndef SSHTEST
  10722.                   ssh_fwd_local_port(li_port,fw_host,to_port);
  10723. #endif /* SSHTEST */
  10724.           return(success = 1);
  10725.         case XSSH_FRP:    /* SSH FORWARD-REMOTE-PORT */
  10726. #ifndef SSHTEST
  10727.                   ssh_fwd_remote_port(li_port,fw_host,to_port);
  10728. #endif /* SSHTEST */
  10729.           return(success = 1);
  10730.           }
  10731.           return(success = 1);
  10732.       }
  10733.     case XSSH_V2:        /* SSH V2 */
  10734.       if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0)
  10735.         return(cx);
  10736.       switch (cx) {
  10737.         case XSSH2_RKE:
  10738.           if ((x = cmcfm()) < 0)
  10739.         return(x);
  10740. #ifndef SSHTEST
  10741.           ssh_v2_rekey();
  10742. #endif /* SSHTEST */
  10743.           return(success = 1);
  10744.         default:
  10745.           return(-2);
  10746.       }
  10747.     case XSSH_KEY:
  10748.       if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0)
  10749.         return(cx);
  10750.       switch (cx) {
  10751.         case SSHK_PASS: {    /* Change passphrase */
  10752.           char * oldp = NULL, * newp = NULL;
  10753.           struct FDB df, sw;
  10754.           cmfdbi(&sw,
  10755.              _CMKEY,        /* fcode */
  10756.              "Filename, or switch", /* hlpmsg */
  10757.              "",        /* default */
  10758.              "",        /* addtl string data */
  10759.              2,            /* addtl numeric data 1: tbl size */
  10760.              4,            /* addtl numeric data 2: 4 = cmswi */
  10761.              xxstring,        /* Processing function */
  10762.              sshkpsw,        /* Keyword table */
  10763.              &df        /* Pointer to next FDB */
  10764.              );
  10765.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10766.              _CMIFI,        /* output file */
  10767.              "",        /* hlpmsg */
  10768.              "",        /* default */
  10769.              "",        /* addtl string data */
  10770.              0,            /* addtl numeric data 1 */
  10771.              0,            /* addtl numeric data 2 */
  10772.              xxstring,
  10773.              NULL,
  10774.              NULL
  10775.              );
  10776.           line[0] = NUL;
  10777.  
  10778.           while (1) {
  10779.           x = cmfdb(&sw);
  10780.           if (x == -3) break;
  10781.           if (x < 0)
  10782.             return(x);
  10783.           if (cmresult.fcode != _CMKEY)
  10784.             break;
  10785.           if (!cmgbrk()) {
  10786.               printf("?This switch requires an argument\n");
  10787.               return(-9);
  10788.           }
  10789.           if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10790.             return(y);
  10791.           switch (cmresult.nresult) {
  10792.             case 1:        /* Old */
  10793.               makestr(&oldp,s);
  10794.               break;
  10795.             case 2:        /* New */
  10796.               makestr(&newp,s);
  10797.           }
  10798.           }
  10799.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10800.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10801.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10802.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10803.           }
  10804.           if ((x = cmcfm()) < 0) return(x);
  10805.  
  10806. #ifndef SSHTEST
  10807.           x = sshkey_change_passphrase(line[0] ? line : NULL,
  10808.                          oldp, newp);
  10809. #endif /* SSHTEST */
  10810.           makestr(&oldp,NULL);
  10811.           makestr(&newp,NULL);
  10812.           success = (x == 0);
  10813.           return(success);
  10814.         }
  10815.         case SSHK_CREA: {    /* SSH KEY CREATE /switches... */
  10816.           int bits = 1024, keytype = SSHKT_2R;
  10817.           char * pass = NULL, * comment = NULL;
  10818.           struct FDB df, sw;
  10819.  
  10820.               /*
  10821.                * char * sshkey_default_file(int keytype) 
  10822.                * will provide the default filename for a given keytype
  10823.                * is it possible to have the default value for the 2nd
  10824.                * FDB set and changed when a /TYPE switch is provided?
  10825.                * Would this allow for tab completion of the filename?
  10826.                */
  10827.           cmfdbi(&sw,
  10828.              _CMKEY,        /* fcode */
  10829.              "Filename, or switch", /* hlpmsg */
  10830.              "",        /* default */
  10831.              "",        /* addtl string data */
  10832.              nsshkcrea,        /* addtl numeric data 1: tbl size */
  10833.              4,            /* addtl numeric data 2: 4 = cmswi */
  10834.              xxstring,        /* Processing function */
  10835.              sshkcrea,        /* Keyword table */
  10836.              &df        /* Pointer to next FDB */
  10837.              );
  10838.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10839.              _CMOFI,        /* output file */
  10840.              "",        /* hlpmsg */
  10841.              "",        /* default */
  10842.              "",        /* addtl string data */
  10843.              0,            /* addtl numeric data 1 */
  10844.              0,            /* addtl numeric data 2 */
  10845.              xxstring,
  10846.              NULL,
  10847.              NULL
  10848.              );
  10849.           line[0] = NUL;
  10850.  
  10851.           while (1) {
  10852.           x = cmfdb(&sw);
  10853.           if (x == -3) break;
  10854.           if (x < 0)
  10855.             return(x);
  10856.           if (cmresult.fcode != _CMKEY)
  10857.             break;
  10858.           if (!cmgbrk()) {
  10859.               printf("?This switch requires an argument\n");
  10860.               return(-9);
  10861.           }
  10862.           switch (cmresult.nresult) {
  10863.             case SSHKC_BI:    /* /BITS:n */
  10864.               if ((y = cmnum("","1024",10,&z,xxstring)) < 0)
  10865.             return(y);
  10866.               if (z < 512 || z > 4096) {
  10867.               printf("?Out range - min: 512, max: 4096\n");
  10868.               return(-9);
  10869.               }
  10870.               bits = z;
  10871.               break;
  10872.             case SSHKC_PP:    /* /PASSPHRASE:blah */
  10873.               if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10874.             return(y);
  10875.               makestr(&pass,s);
  10876.               break;
  10877.             case SSHKC_TY:    /* /TYPE:keyword */
  10878.               if ((y = cmkey(sshkcty,nsshkcty,"",
  10879.                      "v2-rsa",xxstring)) < 0)
  10880.             return(y);
  10881.               keytype = y;
  10882.               break;
  10883.             case SSHKC_1R:    /* /COMMENT */
  10884.               if ((y = cmfld("Text","",&s,xxstring)) < 0)
  10885.             return(y);
  10886.               makestr(&comment,s);
  10887.               break;
  10888.           }
  10889.           }
  10890.           if (cmresult.fcode == _CMOFI) { /* Filename */
  10891.                   if (cmresult.sresult) {
  10892.                       ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10893.                       if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10894.                           ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10895.           }
  10896.           }
  10897.           if ((y = cmcfm()) < 0) /* Confirm */
  10898.         return(y);
  10899. #ifndef SSHTEST
  10900.           x = sshkey_create(line[0] ? line : NULL,
  10901.                 bits, pass, keytype, comment);
  10902.           if (pass)
  10903.         memset(pass,0,strlen(pass));
  10904. #endif /* SSHTEST */
  10905.           makestr(&pass,NULL);
  10906.           makestr(&comment,NULL);
  10907.           return(success = (x == 0));
  10908.         }
  10909.         case SSHK_DISP: {    /* SSH KEY DISPLAY /switches... */
  10910.           char c;
  10911.           int infmt = 0, outfmt = 0;
  10912.           struct FDB df, sw;
  10913.           cmfdbi(&sw,
  10914.              _CMKEY,        /* fcode */
  10915.              "Filename, or switch", /* hlpmsg */
  10916.              "",        /* default */
  10917.              "",        /* addtl string data */
  10918.              nsshdswi,        /* addtl numeric data 1: tbl size */
  10919.              4,            /* addtl numeric data 2: 4 = cmswi */
  10920.              xxstring,        /* Processing function */
  10921.              sshdswi,        /* Keyword table */
  10922.              &df        /* Pointer to next FDB */
  10923.              );
  10924.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10925.              _CMIFI,        /* fcode */
  10926.              "",        /* hlpmsg */
  10927.              "",        /* default */
  10928.              "",        /* addtl string data */
  10929.              0,            /* addtl numeric data 1 */
  10930.              0,            /* addtl numeric data 2 */
  10931.              xxstring,
  10932.              NULL,
  10933.              NULL
  10934.              );
  10935.           line[0] = NUL;
  10936.  
  10937.           while (1) {
  10938.           x = cmfdb(&sw);
  10939.           if (x == -3) break;
  10940.           if (x < 0)
  10941.             return(x);
  10942.           if (cmresult.fcode != _CMKEY)
  10943.             break;
  10944.           if (!cmgbrk()) {
  10945.               printf("?This switch requires an argument\n");
  10946.               return(-9);
  10947.           }
  10948.           switch (cmresult.nresult) {
  10949. #ifdef COMMENT
  10950.             case SSHKD_IN:    /* /IN-FORMAT: */
  10951.               if ((y = cmkey(sshdifmt,nsshdifmt,
  10952.                      "","",xxstring)) < 0)
  10953.             return(y);
  10954.               infmt = y;
  10955.               break;
  10956. #endif /* COMMENT */
  10957.             case SSHKD_OUT:    /* /FORMAT: */
  10958.               if ((y = cmkey(sshdofmt,nsshdofmt,
  10959.                      "","",xxstring)) < 0)
  10960.             return(y);
  10961.               outfmt = y;
  10962.               break;
  10963.           }
  10964.           }
  10965.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10966.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10967.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10968.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10969.           }
  10970. #ifdef COMMENT
  10971.           if (!line[0]) {
  10972.           printf("?Key filename required\n");
  10973.           return(-9);
  10974.           }
  10975. #endif /* COMMENT */
  10976.           if ((y = cmcfm()) < 0) /* Confirm */
  10977.         return(y);
  10978. #ifndef SSHTEST
  10979.           switch (outfmt) {
  10980.         case SKDF_OSSH:
  10981.                   /* 2nd param is optional passphrase */
  10982.           x = sshkey_display_public(line[0] ? line : NULL, NULL);
  10983.           break;
  10984.         case SKDF_SSHC:
  10985.                   /* 2nd param is optional passphrase */
  10986.           x = sshkey_display_public_as_ssh2(line[0] ? line : NULL,
  10987.                             NULL);
  10988.           break;
  10989.         case SKDF_IETF:
  10990.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 1);
  10991.           break;
  10992.         case SKDF_FING:
  10993.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 0);
  10994.           break;
  10995.           }
  10996. #endif /* SSHTEST */
  10997.           return(success = (x == 0));
  10998.         }
  10999.         case SSHK_V1:        /* SSH KEY V1 SET-COMMENT */
  11000.           if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0)
  11001.         return(x);
  11002.           if (x != 1) return(-2);
  11003.           if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) {
  11004.           if (x == -3) {
  11005.               printf("?Name of key file required\n");
  11006.               return(-9);
  11007.           }
  11008.           }
  11009.           ckstrncpy(line,s,LINBUFSIZ);
  11010.           if ((x = cmtxt("Comment text","",&s,xxstring)) < 0)
  11011.         return(x);
  11012. #ifndef SSHTEST
  11013.           x = sshkey_v1_change_comment(line,  /* filename */
  11014.                        s,     /* new comment */
  11015.                        NULL   /* passphrase */
  11016.                        );
  11017. #endif /* SSHTEST */
  11018.           success = (x == 0);
  11019.           return(success);
  11020.       }
  11021.       default:
  11022.         return(-2);
  11023.     }
  11024. #else  /* SSHBUILTIN */
  11025. #ifdef SSHCMD
  11026.     x = nettype;
  11027.     if ((y = setlin(XXSSH,0,1)) < 0) {
  11028.         if (errno)
  11029.           printf("?%s\n",ck_errstr());
  11030.             else
  11031. #ifdef COMMENT
  11032.         /* This isn't right either because it catches command editing */
  11033.           printf("?Sorry, pseudoterminal open failed\n");
  11034.             if (hints)
  11035.           printf("Hint: Try \"ssh -t %s\"\n",line);
  11036. #else
  11037.           return(y);
  11038. #endif /* COMMENT */
  11039.         nettype = x;        /* Failed, restore net type. */
  11040.         ttnproto = z;        /* and protocol */
  11041.         success = 0;
  11042.     }
  11043.     didsetlin++;
  11044.     netsave = x;
  11045.     return(y);
  11046. #endif /* SSHCMD */
  11047. #endif /* SSHBUILTIN */
  11048.     }
  11049. #endif /* ANYSSH */
  11050.  
  11051. #ifdef SSHBUILTIN
  11052.     if (cx == XXSKRM) {            /* SKERMIT (Secure Shell Kermit) */
  11053.     extern int netsave;
  11054.     int k, x, havehost = 0, trips = 0;
  11055.         int    tmpver = -1, tmpxfw = -1;
  11056. #ifndef SSHTEST
  11057.         extern int sl_ssh_xfw, sl_ssh_xfw_saved;
  11058.         extern int sl_ssh_ver, sl_ssh_ver_saved;
  11059. #endif /* SSHTEST */
  11060.         extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
  11061.         extern char * slmsg;
  11062.     extern char uidbuf[], sl_uidbuf[];
  11063.         extern char pwbuf[], * g_pswd;
  11064.         extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
  11065.     struct FDB sw, kw, fl;
  11066.  
  11067.         if (ssh_tmpstr)
  11068.       memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  11069.         makestr(&ssh_tmpstr,NULL);
  11070.         makestr(&ssh_tmpuid,NULL);
  11071.         makestr(&ssh_tmpcmd,NULL);
  11072.         makestr(&ssh_tmpport,NULL);
  11073.  
  11074.     cmfdbi(&kw,            /* 1st FDB - commands */
  11075.            _CMKEY,            /* fcode */
  11076.            "host [ port ],\n or action", /* hlpmsg */
  11077.            "",            /* default */
  11078.            "",            /* addtl string data */
  11079.            nsshkermit,        /* addtl numeric data 1: tbl size */
  11080.            0,            /* addtl numeric data 2: 0 = keyword */
  11081.            xxstring,        /* Processing function */
  11082.            sshkermit,        /* Keyword table */
  11083.            &fl            /* Pointer to next FDB */
  11084.            );
  11085.     cmfdbi(&fl,            /* Host */
  11086.            _CMFLD,            /* fcode */
  11087.            "",            /* hlpmsg */
  11088.            "",            /* default */
  11089.            "",            /* addtl string data */
  11090.            0,            /* addtl numeric data 1 */
  11091.            0,            /* addtl numeric data 2 */
  11092.            xxstring,
  11093.            NULL,
  11094.            NULL
  11095.            );
  11096.  
  11097.     x = cmfdb(&kw);
  11098.     if (x == -3) {
  11099.         printf("?skermit what?\n");
  11100.         return(-9);
  11101.     }
  11102.     if (x < 0)
  11103.       return(x);
  11104.     havehost = 0;
  11105.     if (cmresult.fcode == _CMFLD) {
  11106.         havehost = 1;
  11107.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
  11108.         cmresult.nresult = SKRM_OPN;
  11109.     }
  11110.     switch (cmresult.nresult) {    /* SSH keyword */
  11111.       case SKRM_OPN:        /* SSH OPEN */
  11112.         if (!havehost) {
  11113.         if ((x = cmfld("Host","",&s,xxstring)) < 0)
  11114.           return(x);
  11115.         ckstrncpy(line,s,LINBUFSIZ);
  11116.         }
  11117.         /* Parse [ port ] [ switches ] */
  11118.         cmfdbi(&kw,            /* Switches */
  11119.            _CMKEY,
  11120.            "Port number or service name,\nor switch",
  11121.            "",
  11122.            "",
  11123.            nsshkrmopnsw,
  11124.            4,
  11125.            xxstring,
  11126.            sshkrmopnsw,
  11127.            &fl
  11128.            );
  11129.         cmfdbi(&fl,            /* Port number or service name */
  11130.            _CMFLD,
  11131.            "",
  11132.            "",
  11133.            "",
  11134.            0,
  11135.            0,
  11136.            xxstring,
  11137.            NULL,
  11138.            NULL
  11139.            );
  11140.         trips = 0;            /* Explained below */
  11141.         while (1) {            /* Parse port and switches */
  11142.         x = cmfdb(&kw);        /* Get a field */
  11143.         if (x == -3)        /* User typed CR so quit from loop */
  11144.           break;
  11145.         if (x < 0)        /* Other parse error, pass it back */
  11146.           return(x);
  11147.         switch (cmresult.fcode) { /* Field or Keyword? */
  11148.                   case _CMFLD:          /* Field */
  11149.                     makestr(&ssh_tmpport,cmresult.sresult);
  11150.             break;
  11151.           case _CMKEY:        /* Keyword */
  11152.             switch (cmresult.nresult) {    /* Which one? */
  11153.               case SSHSW_USR:            /* /USER: */
  11154.             if (!cmgbrk()) {
  11155.                 printf("?This switch requires an argument\n");
  11156.                 return(-9);
  11157.             }
  11158.             if ((y = cmfld("Username","",&s,xxstring)) < 0)
  11159.               return(y);
  11160.             s = brstrip(s);
  11161.             makestr(&ssh_tmpuid,s);
  11162.             break;
  11163.                       case SSHSW_PWD:
  11164.             if (!cmgbrk()) {
  11165.                 printf("?This switch requires an argument\n");
  11166.                 return(-9);
  11167.             }
  11168.             debok = 0;
  11169.             if ((x = cmfld("Password","",&s,xxstring)) < 0) {
  11170.                 if (x == -3) {
  11171.                 makestr(&ssh_tmpstr,"");
  11172.                 } else {
  11173.                 return(x);
  11174.                 }
  11175.             } else {
  11176.                 s = brstrip(s);
  11177.                 if ((x = (int)strlen(s)) > PWBUFL) {
  11178.                 makestr(&slmsg,"Internal error");
  11179.                 printf("?Sorry, too long - max = %d\n",PWBUFL);
  11180.                 return(-9);
  11181.                 }
  11182.                 makestr(&ssh_tmpstr,s);
  11183.             }
  11184.             break;
  11185.  
  11186.                     case SSHSW_VER:
  11187.             if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
  11188.               return(x);
  11189.             if (z < 1 || z > 2) {
  11190.                 printf("?Out of range: %d\n",z);
  11191.                 return(-9);
  11192.             }
  11193.                         tmpver = z;
  11194.             break;
  11195.                     default:
  11196.                         return(-2);
  11197.             }
  11198.                   }
  11199.         if (trips++ == 0) {    /* After first time through */
  11200.             cmfdbi(&kw,        /* only parse switches, not port. */
  11201.                _CMKEY,
  11202.                "Switch",
  11203.                "",
  11204.                "",
  11205.                nsshkrmopnsw,
  11206.                4,
  11207.                xxstring,
  11208.                sshkrmopnsw,
  11209.                NULL
  11210.                );
  11211.         }
  11212.         }
  11213.         if ((x = cmcfm()) < 0)    /* Get confirmation */
  11214.           return(x);
  11215.               if (clskconnx(1) < 0) {    /* Close current Kermit connection */
  11216.                   if ( ssh_tmpstr ) {
  11217.                       memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  11218.                       makestr(&ssh_tmpstr,NULL);
  11219.                   }
  11220.                   return(success = 0);
  11221.               }
  11222.               makestr(&ssh_hst,line);    /* Stash everything */
  11223.               if (ssh_tmpuid) {
  11224.                   if (!sl_uid_saved) {
  11225.                       ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
  11226.                       sl_uid_saved = 1;
  11227.                   }
  11228.                   ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
  11229.                   makestr(&ssh_tmpuid,NULL);
  11230.               }
  11231.               if (ssh_tmpport) {
  11232.                   makestr(&ssh_prt,ssh_tmpport);
  11233.                   makestr(&ssh_tmpport,NULL);
  11234.               } else
  11235.                   makestr(&ssh_prt,NULL);
  11236.  
  11237.               /* Set the Subsystem to Kermit */
  11238.               ssh_cas = 1;
  11239.               makestr(&ssh_cmd,"kermit");
  11240.  
  11241.               if (tmpver > -1) {
  11242. #ifndef SSHTEST
  11243.                   if (!sl_ssh_ver_saved) {
  11244.                       sl_ssh_ver = ssh_ver;
  11245.                       sl_ssh_ver_saved = 1;
  11246.                   }
  11247. #endif /* SSHTEST */
  11248.                   ssh_ver = tmpver;
  11249.               }
  11250.               /* Disable X11 Forwarding */
  11251. #ifndef SSHTEST
  11252.               if (!sl_ssh_xfw_saved) {
  11253.                   sl_ssh_xfw = ssh_xfw;
  11254.                   sl_ssh_xfw_saved = 1;
  11255.               }
  11256. #endif /* SSHTEST */
  11257.               ssh_xfw = 0;
  11258.  
  11259.               if (ssh_tmpstr) {
  11260.                   if (ssh_tmpstr[0]) {
  11261.                       ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
  11262.                       pwflg = 1;
  11263.                       pwcrypt = 0;
  11264.                   } else
  11265.                       pwflg = 0;
  11266.                   makestr(&ssh_tmpstr,NULL);
  11267.               }
  11268.               nettype = NET_SSH;
  11269.               if (mdmsav < 0)
  11270.                   mdmsav = mdmtyp;
  11271.               mdmtyp = -nettype;
  11272.               x = 1;
  11273.  
  11274. #ifndef NOSPL
  11275.             makestr(&g_pswd,pwbuf);    /* Save global pwbuf */
  11276.             g_pflg = pwflg;        /* and flag */
  11277.             g_pcpt = pwcrypt;
  11278. #endif /* NOSPL */
  11279.  
  11280.         /* Line parameter to ttopen() is ignored */
  11281.         k = ttopen(line,&x,mdmtyp, 0);
  11282.         if (k < 0) {
  11283.         printf("?Unable to connect to %s\n",ssh_hst);
  11284.         mdmtyp = mdmsav;
  11285.                 slrestor();
  11286.         return(success = 0);
  11287.         }
  11288.         duplex = 0;             /* Remote echo */
  11289.         ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
  11290.         debug(F110,"ssh ttname",ttname,0);
  11291.         makestr(&slmsg,NULL);    /* No SET LINE error message */
  11292.         cxtype = CXT_SSH;
  11293. #ifndef NODIAL
  11294.         dialsta = DIA_UNK;
  11295. #endif /* NODIAL */
  11296.         success = 1;        /* SET LINE succeeded */
  11297.         network = 1;        /* Network connection (not serial) */
  11298.         local = 1;            /* Local mode (not remote) */
  11299.         if ((reliable != SET_OFF || !setreliable))
  11300.           reliable = SET_ON;    /* Transport is reliable end to end */
  11301. #ifdef OS2
  11302.             DialerSend(OPT_KERMIT_CONNECT, 0);
  11303. #endif /* OS2 */
  11304.         setflow();            /* Set appropriate flow control */
  11305.  
  11306.         haveline = 1;
  11307. #ifdef CKLOGDIAL
  11308. #ifdef NETCONN
  11309.         dolognet();
  11310. #endif /* NETCONN */
  11311. #endif /* CKLOGDIAL */
  11312.  
  11313. #ifndef NOSPL
  11314.         if (local) {
  11315.         if (nmac) {        /* Any macros defined? */
  11316.             int k;        /* Yes */
  11317.             k = mlook(mactab,"on_open",nmac); /* Look this up */
  11318.             if (k >= 0) {                  /* If found, */
  11319.             if (dodo(k,ssh_hst,0) > -1)   /* set it up, */
  11320.               parser(1);              /* and execute it */
  11321.             }
  11322.         }
  11323.         }
  11324. #endif /* NOSPL */
  11325. #ifdef LOCUS        
  11326.         if (autolocus)
  11327.         setlocus(1,1);
  11328. #endif /* LOCUS */
  11329.  
  11330.     /* Command was confirmed so we can pre-pop command level. */
  11331.     /* This is so CONNECT module won't think we're executing a */
  11332.     /* script if CONNECT was the final command in the script. */
  11333.         if (cmdlvl > 0)
  11334.           prepop();
  11335.         return(success = 1);
  11336.  
  11337.       default:
  11338.         return(-2);
  11339.     }
  11340.     }
  11341. #endif /* SSHBUILTIN */
  11342.  
  11343. #ifdef SFTP_BUILTIN
  11344.     if (cx == XXSFTP) {            /* SFTP (Secure Shell File Transfer) */
  11345.     extern int netsave;
  11346.     int k, x, havehost = 0, trips = 0;
  11347.         int    tmpver = -1, tmpxfw = -1;
  11348. #ifndef SSHTEST
  11349.         extern int sl_ssh_xfw, sl_ssh_xfw_saved;
  11350.         extern int sl_ssh_ver, sl_ssh_ver_saved;
  11351. #endif /* SSHTEST */
  11352.         extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
  11353.         extern char * slmsg;
  11354.     extern char uidbuf[], sl_uidbuf[];
  11355.         extern char pwbuf[], * g_pswd;
  11356.         extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
  11357.     struct FDB sw, kw, fl;
  11358.  
  11359.         if (ssh_tmpstr)
  11360.       memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  11361.         makestr(&ssh_tmpstr,NULL);
  11362.         makestr(&ssh_tmpuid,NULL);
  11363.         makestr(&ssh_tmpcmd,NULL);
  11364.         makestr(&ssh_tmpport,NULL);
  11365.  
  11366.     cmfdbi(&kw,            /* 1st FDB - commands */
  11367.            _CMKEY,            /* fcode */
  11368.            "host [ port ],\n or action", /* hlpmsg */
  11369.            "",            /* default */
  11370.            "",            /* addtl string data */
  11371.            nsftpkwtab,        /* addtl numeric data 1: tbl size */
  11372.            0,            /* addtl numeric data 2: 0 = keyword */
  11373.            xxstring,        /* Processing function */
  11374.            sftpkwtab,        /* Keyword table */
  11375.            &fl            /* Pointer to next FDB */
  11376.            );
  11377.     cmfdbi(&fl,            /* Host */
  11378.            _CMFLD,            /* fcode */
  11379.            "",            /* hlpmsg */
  11380.            "",            /* default */
  11381.            "",            /* addtl string data */
  11382.            0,            /* addtl numeric data 1 */
  11383.            0,            /* addtl numeric data 2 */
  11384.            xxstring,
  11385.            NULL,
  11386.            NULL
  11387.            );
  11388.  
  11389.     x = cmfdb(&kw);
  11390.     if (x == -3) {
  11391.         printf("?sftp what?\n");
  11392.         return(-9);
  11393.     }
  11394.     if (x < 0)
  11395.       return(x);
  11396.     havehost = 0;
  11397.     if (cmresult.fcode == _CMFLD) {
  11398.         havehost = 1;
  11399.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
  11400.         cmresult.nresult = SFTP_OPN;
  11401.     }
  11402.     switch (cmresult.nresult) {    /* SFTP keyword */
  11403.       case SFTP_OPN:        /* SFTP OPEN */
  11404.         if (!havehost) {
  11405.         if ((x = cmfld("Host","",&s,xxstring)) < 0)
  11406.           return(x);
  11407.         ckstrncpy(line,s,LINBUFSIZ);
  11408.         }
  11409.         /* Parse [ port ] [ switches ] */
  11410.         cmfdbi(&kw,            /* Switches */
  11411.            _CMKEY,
  11412.            "Port number or service name,\nor switch",
  11413.            "",
  11414.            "",
  11415.            nsshkrmopnsw,
  11416.            4,
  11417.            xxstring,
  11418.            sshkrmopnsw,
  11419.            &fl
  11420.            );
  11421.         cmfdbi(&fl,            /* Port number or service name */
  11422.            _CMFLD,
  11423.            "",
  11424.            "",
  11425.            "",
  11426.            0,
  11427.            0,
  11428.            xxstring,
  11429.            NULL,
  11430.            NULL
  11431.            );
  11432.         trips = 0;            /* Explained below */
  11433.         while (1) {            /* Parse port and switches */
  11434.         x = cmfdb(&kw);        /* Get a field */
  11435.         if (x == -3)        /* User typed CR so quit from loop */
  11436.           break;
  11437.         if (x < 0)        /* Other parse error, pass it back */
  11438.           return(x);
  11439.         switch (cmresult.fcode) { /* Field or Keyword? */
  11440.                   case _CMFLD:          /* Field */
  11441.                     makestr(&ssh_tmpport,cmresult.sresult);
  11442.             break;
  11443.           case _CMKEY:        /* Keyword */
  11444.             switch (cmresult.nresult) {    /* Which one? */
  11445.               case SSHSW_USR:            /* /USER: */
  11446.             if (!cmgbrk()) {
  11447.                 printf("?This switch requires an argument\n");
  11448.                 return(-9);
  11449.             }
  11450.             if ((y = cmfld("Username","",&s,xxstring)) < 0)
  11451.               return(y);
  11452.             s = brstrip(s);
  11453.             makestr(&ssh_tmpuid,s);
  11454.             break;
  11455.                       case SSHSW_PWD:
  11456.             if (!cmgbrk()) {
  11457.                 printf("?This switch requires an argument\n");
  11458.                 return(-9);
  11459.             }
  11460.             debok = 0;
  11461.             if ((x = cmfld("Password","",&s,xxstring)) < 0) {
  11462.                 if (x == -3) {
  11463.                 makestr(&ssh_tmpstr,"");
  11464.                 } else {
  11465.                 return(x);
  11466.                 }
  11467.             } else {
  11468.                 s = brstrip(s);
  11469.                 if ((x = (int)strlen(s)) > PWBUFL) {
  11470.                 makestr(&slmsg,"Internal error");
  11471.                 printf("?Sorry, too long - max = %d\n",PWBUFL);
  11472.                 return(-9);
  11473.                 }
  11474.                 makestr(&ssh_tmpstr,s);
  11475.             }
  11476.             break;
  11477.  
  11478.                     case SSHSW_VER:
  11479.             if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
  11480.               return(x);
  11481.             if (z < 1 || z > 2) {
  11482.                 printf("?Out of range: %d\n",z);
  11483.                 return(-9);
  11484.             }
  11485.                         tmpver = z;
  11486.             break;
  11487.                     default:
  11488.                         return(-2);
  11489.             }
  11490.         }
  11491.         if (trips++ == 0) {    /* After first time through */
  11492.             cmfdbi(&kw,        /* only parse switches, not port. */
  11493.                _CMKEY,
  11494.                "Switch",
  11495.                "",
  11496.                "",
  11497.                nsshkrmopnsw,
  11498.                4,
  11499.                xxstring,
  11500.                sshkrmopnsw,
  11501.                NULL
  11502.                );
  11503.         }
  11504.         }
  11505.         if ((x = cmcfm()) < 0)    /* Get confirmation */
  11506.           return(x);
  11507.               if (clskconnx(1) < 0) {    /* Close current Kermit connection */
  11508.                   if ( ssh_tmpstr ) {
  11509.                       memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
  11510.                       makestr(&ssh_tmpstr,NULL);
  11511.                   }
  11512.                   return(success = 0);
  11513.               }
  11514.               makestr(&ssh_hst,line);    /* Stash everything */
  11515.               if (ssh_tmpuid) {
  11516.                   if (!sl_uid_saved) {
  11517.                       ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
  11518.                       sl_uid_saved = 1;
  11519.                   }
  11520.                   ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
  11521.                   makestr(&ssh_tmpuid,NULL);
  11522.               }
  11523.               if (ssh_tmpport) {
  11524.                   makestr(&ssh_prt,ssh_tmpport);
  11525.                   makestr(&ssh_tmpport,NULL);
  11526.               } else
  11527.                   makestr(&ssh_prt,NULL);
  11528.  
  11529.               /* Set the Subsystem to Kermit */
  11530.               ssh_cas = 1;
  11531.               makestr(&ssh_cmd,"sftp");
  11532.  
  11533.               if (tmpver > -1) {
  11534. #ifndef SSHTEST
  11535.                   if (!sl_ssh_ver_saved) {
  11536.                       sl_ssh_ver = ssh_ver;
  11537.                       sl_ssh_ver_saved = 1;
  11538.                   }
  11539. #endif /* SSHTEST */
  11540.                   ssh_ver = tmpver;
  11541.               }
  11542.               /* Disable X11 Forwarding */
  11543. #ifndef SSHTEST
  11544.               if (!sl_ssh_xfw_saved) {
  11545.                   sl_ssh_xfw = ssh_xfw;
  11546.                   sl_ssh_xfw_saved = 1;
  11547.               }
  11548. #endif /* SSHTEST */
  11549.               ssh_xfw = 0;
  11550.  
  11551.               if (ssh_tmpstr) {
  11552.                   if (ssh_tmpstr[0]) {
  11553.                       ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
  11554.                       pwflg = 1;
  11555.                       pwcrypt = 0;
  11556.                   } else
  11557.                       pwflg = 0;
  11558.                   makestr(&ssh_tmpstr,NULL);
  11559.               }
  11560.               nettype = NET_SSH;
  11561.               if (mdmsav < 0)
  11562.                   mdmsav = mdmtyp;
  11563.               mdmtyp = -nettype;
  11564.               x = 1;
  11565.  
  11566. #ifndef NOSPL
  11567.             makestr(&g_pswd,pwbuf);             /* Save global pwbuf */
  11568.             g_pflg = pwflg;                     /* and flag */
  11569.             g_pcpt = pwcrypt;
  11570. #endif /* NOSPL */
  11571.  
  11572.         /* Line parameter to ttopen() is ignored */
  11573.         k = ttopen(line,&x,mdmtyp, 0);
  11574.         if (k < 0) {
  11575.         printf("?Unable to connect to %s\n",ssh_hst);
  11576.         mdmtyp = mdmsav;
  11577.                 slrestor();
  11578.         return(success = 0);
  11579.         }
  11580.         duplex = 0;             /* Remote echo */
  11581.         ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
  11582.         debug(F110,"ssh ttname",ttname,0);
  11583.         makestr(&slmsg,NULL);    /* No SET LINE error message */
  11584.         cxtype = CXT_SSH;
  11585. #ifndef NODIAL
  11586.         dialsta = DIA_UNK;
  11587. #endif /* NODIAL */
  11588.         success = 1;        /* SET LINE succeeded */
  11589.         network = 1;        /* Network connection (not serial) */
  11590.         local = 1;            /* Local mode (not remote) */
  11591.         if ((reliable != SET_OFF || !setreliable))
  11592.           reliable = SET_ON;    /* Transport is reliable end to end */
  11593. #ifdef OS2
  11594.             DialerSend(OPT_KERMIT_CONNECT, 0);
  11595. #endif /* OS2 */
  11596.         setflow();            /* Set appropriate flow control */
  11597.  
  11598.         haveline = 1;
  11599. #ifdef CKLOGDIAL
  11600. #ifdef NETCONN
  11601.         dolognet();
  11602. #endif /* NETCONN */
  11603. #endif /* CKLOGDIAL */
  11604.  
  11605. #ifndef NOSPL
  11606.         if (local) {
  11607.         if (nmac) {        /* Any macros defined? */
  11608.             int k;        /* Yes */
  11609.             k = mlook(mactab,"on_open",nmac); /* Look this up */
  11610.             if (k >= 0) {                  /* If found, */
  11611.             if (dodo(k,ssh_hst,0) > -1)   /* set it up, */
  11612.               parser(1);              /* and execute it */
  11613.             }
  11614.         }
  11615.         }
  11616. #endif /* NOSPL */
  11617. #ifdef LOCUS        
  11618.         if (autolocus)
  11619.         setlocus(1,1);
  11620. #endif /* LOCUS */
  11621.  
  11622.     /* Command was confirmed so we can pre-pop command level. */
  11623.     /* This is so CONNECT module won't think we're executing a */
  11624.     /* script if CONNECT was the final command in the script. */
  11625.         if (cmdlvl > 0)
  11626.           prepop();
  11627.  
  11628.             success = sftp_do_init();
  11629.         return(success = 1);
  11630.  
  11631.       case SFTP_CD:
  11632.       case SFTP_CHGRP:
  11633.       case SFTP_CHMOD:
  11634.       case SFTP_CHOWN:
  11635.       case SFTP_RM:
  11636.       case SFTP_DIR:
  11637.       case SFTP_GET:
  11638.       case SFTP_MKDIR:
  11639.       case SFTP_PUT:
  11640.       case SFTP_PWD:
  11641.       case SFTP_REN:
  11642.       case SFTP_RMDIR:
  11643.       case SFTP_LINK:
  11644.       case SFTP_VER:
  11645.         if ((y = cmtxt("command parameters","",&s,xxstring)) < 0) 
  11646.           return(y);
  11647.         if (ssh_tchk() < 0 || !ssh_cas || strcmp(ssh_cmd,"sftp")) {
  11648.         printf("?Not connected to SFTP Service\n");
  11649.         return(success = 0);
  11650.         }
  11651.         success = sftp_do_cmd(cmresult.nresult,s);
  11652.         return(success);
  11653.       default:
  11654.         return(-2);
  11655.     }
  11656.     }
  11657. #endif /* SFTP_BUILTIN */
  11658.  
  11659.     if (cx == XXRLOG) {            /* RLOGIN */
  11660. #ifdef RLOGCODE
  11661.     int x,z;
  11662. #ifdef OS2
  11663.     if (!tcp_avail) {
  11664.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  11665. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n"
  11666.            );
  11667.         success = 0;
  11668.         return(-9);
  11669.     } else {
  11670. #endif /* OS2 */
  11671.         x = nettype;        /* Save net type in case of failure */
  11672.         z = ttnproto;        /* Save protocol in case of failure */
  11673.         nettype = NET_TCPB;
  11674.         ttnproto = NP_RLOGIN;
  11675.         if ((y = setlin(XYHOST,0,1)) <= 0) {
  11676.         nettype = x;        /* Failed, restore net type. */
  11677.         ttnproto = z;        /* and protocol */
  11678.         success = 0;
  11679.         }
  11680.         didsetlin++;
  11681. #ifdef OS2
  11682.     }
  11683. #endif /* OS2 */
  11684.     return(y);
  11685. #else
  11686.     printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n");
  11687.     return(-9);
  11688. #endif /* RLOGCODE */
  11689.     }
  11690. #endif /* NETCONN */
  11691. #endif /* NOLOCAL */
  11692.  
  11693. #ifndef NOXMIT
  11694.     if (cx == XXTRA) {            /* TRANSMIT */
  11695.     extern int xfrxla;
  11696.     int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval;
  11697.     int xxecho = 0;
  11698.     int scan = 1;
  11699.     char c;
  11700.     struct FDB sf, sw, tx;        /* FDBs for parse functions */
  11701. #ifndef NOCSETS
  11702.     extern int tcs_transp;        /* Term charset is transparent */
  11703. #else
  11704.     int tcs_transp = 1;
  11705. #endif /* NOCSETS */
  11706.  
  11707. #ifdef COMMENT
  11708.     xbinary = binary;        /* Default text/binary mode */
  11709. #else
  11710.     xbinary = 0;            /* Default is text */
  11711. #endif /* COMMENT */
  11712.     xxecho = xmitx;
  11713.  
  11714.     cmfdbi(&sw,            /* First FDB - command switches */
  11715.            _CMKEY,            /* fcode */
  11716.            "Filename, or switch",    /* hlpmsg */
  11717.            "",            /* default */
  11718.            "",            /* addtl string data */
  11719.            nxmitsw,            /* addtl numeric data 1: tbl size */
  11720.            4,            /* addtl numeric data 2: 4 = cmswi */
  11721.            xxstring,        /* Processing function */
  11722.            xmitsw,            /* Keyword table */
  11723.            &sf            /* Pointer to next FDB */
  11724.            );
  11725.     cmfdbi(&sf,            /* 2nd FDB - file to send */
  11726.            _CMIFI,            /* fcode */
  11727.            "File to transmit",    /* hlpmsg */
  11728.            "",            /* default */
  11729.            "",            /* addtl string data */
  11730.            0,            /* addtl numeric data 1 */
  11731.            0,            /* addtl numeric data 2 */
  11732.            xxstring,
  11733.            NULL,
  11734. #ifdef PIPESEND
  11735.            &tx
  11736. #else
  11737.            NULL
  11738. #endif /* PIPESEND */
  11739.            );
  11740. #ifdef PIPESEND
  11741.         cmfdbi(&tx,
  11742.            _CMTXT,            /* fcode */
  11743.            "Command",        /* hlpmsg */
  11744.            "",            /* default */
  11745.            "",            /* addtl string data */
  11746.            0,            /* addtl numeric data 1 */
  11747.            0,            /* addtl numeric data 2 */
  11748.            xxstring,
  11749.            NULL,
  11750.            NULL
  11751.            );
  11752. #endif /* PIPESEND */
  11753.  
  11754.     while (1) {
  11755.         x = cmfdb(&sw);
  11756.         if (x < 0)
  11757.           return(x);
  11758.         if (cmresult.fcode != _CMKEY)
  11759.           break;
  11760.         c = cmgbrk();        /* Have switch, get break character */
  11761.         if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  11762.         printf("?This switch does not take an argument\n");
  11763.         return(-9);
  11764.         }
  11765.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  11766.         printf("?This switch requires an argument\n");
  11767.         return(-9);
  11768.         }
  11769.         n = cmresult.nresult;    /* Numeric result = switch ID */
  11770.         switch (n) {        /* Process the switch */
  11771. #ifdef PIPESEND
  11772.           case XMI_CMD:        /* Transmit from a command */
  11773.         if (nopush) {
  11774.             printf("?Sorry, system command access is disabled\n");
  11775.             return(-9);
  11776.         }
  11777.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  11778.         xpipe = 1;        /* (No way to undo this one) */
  11779.         break;
  11780. #endif /* PIPESEND */
  11781.  
  11782.           case XMI_BIN:        /* Binary */
  11783.         xbinary = 1;
  11784.         xxlate = 0;        /* Don't translate charsets */
  11785.         scan = 0;
  11786.         break;
  11787.  
  11788.           case XMI_TXT:        /* Text */
  11789.         xbinary = 0;
  11790.         xxlate = !tcs_transp;    /* Translate if TERM CHAR not TRANSP */
  11791.         scan = 0;
  11792.         break;
  11793.  
  11794.           case XMI_TRA:        /* Transparent text */
  11795.         xbinary = 0;
  11796.         xxlate = 0;        /* But don't translate charsets */
  11797.         scan = 0;
  11798.         break;
  11799.  
  11800. #ifdef COMMENT
  11801.           case XMI_VRB:        /* /VERBOSE */
  11802.           case XMI_QUI:        /* /QUIET */
  11803.         break;            /* (not implemented yet) */
  11804. #endif /* COMMENT */
  11805.  
  11806.           case XMI_NOW:        /* /NOWAIT */
  11807.         xxnowait = 1;
  11808.         break;
  11809.  
  11810.           case XMI_NOE:        /* /NOWAIT */
  11811.         xxecho = 0;
  11812.         break;
  11813.  
  11814.           default:
  11815.         return(-2);
  11816.         }
  11817.  
  11818.     }
  11819.     if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT)
  11820.       return(-2);
  11821.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */
  11822.     if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  11823.       ckstrncpy(line,tmpbuf,LINBUFSIZ);
  11824.     s = line;
  11825.     if ((y = cmcfm()) < 0)        /* Confirm */
  11826.       return(y);
  11827. #ifdef CK_APC
  11828.     if ((apcactive == APC_LOCAL) ||
  11829.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  11830.       return(success = 0);
  11831. #endif /* CK_APC */
  11832.     if (cmresult.nresult != 0) {
  11833.         printf("?Only a single file may be transmitted\n");
  11834.         return(-9);
  11835.     }
  11836. #ifdef PIPESEND
  11837.     if (xpipe) {
  11838.         s = brstrip(s);
  11839.         if (!*s) {
  11840.         printf("?Sorry, a command to send from is required\n");
  11841.         return(-9);
  11842.         }
  11843.         pipesend = 1;
  11844.     }
  11845. #endif /* PIPESEND */
  11846.  
  11847.     if (scan && (filepeek
  11848. #ifndef NOXFER
  11849.              || patterns
  11850. #endif /* NOXFER */
  11851.              )) {        /* If user didn't specify type */
  11852.         int k, x;                  /* scan the file to see */
  11853.         x = -1;
  11854.         k = scanfile(s,&x,nscanfile);
  11855.         if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  11856.     }
  11857.     if (!xfrxla) xxlate = 0;
  11858.     success = transmit(s,
  11859.                (char) (xxnowait ? '\0' : (char)xmitp),
  11860.                xxlate,
  11861.                xbinary,
  11862.                xxecho
  11863.                );
  11864.     return(success);
  11865.     }
  11866. #endif /* NOXMIT */
  11867.  
  11868. #ifndef NOFRILLS
  11869.     if (cx == XXTYP  || cx == XXCAT || cx == XXMORE ||
  11870.     cx == XXHEAD || cx == XXTAIL) {
  11871.     int paging = 0, havename = 0, head = 0, width = 0;
  11872.     int height = 0, count = 0;
  11873.     char pfxbuf[64], * prefix = NULL;
  11874.     char outfile[CKMAXPATH+1];
  11875.     struct FDB sf, sw;
  11876.     char * pat = NULL;
  11877.     int incs = 0, outcs = 0, cset = -1, number = 0;
  11878. #ifdef UNICODE
  11879.         char * tocs = "";
  11880.     extern int fileorder;
  11881. #ifdef OS2
  11882. #ifdef NT
  11883.     char guibuf[128], * gui_title = NULL;
  11884.     int  gui = 0;
  11885. #endif /* NT */
  11886. #ifndef NOCSETS
  11887.     extern int tcsr, tcsl;
  11888. #endif /* NOCSETS */
  11889. #endif /* OS2 */
  11890. #endif /* UNICODE */
  11891.  
  11892.     outfile[0] = NUL;
  11893.  
  11894.     if (cx == XXMORE)
  11895.       paging = 1;
  11896.     else if (cx == XXCAT)
  11897.       paging = 0;
  11898.     else
  11899.       paging = (typ_page < 0) ? xaskmore : typ_page;
  11900.     if (paging < 0)
  11901.       paging = saveask;
  11902.  
  11903.     if (cx == XXHEAD) {
  11904.         head = 10;
  11905.         cx = XXTYP;
  11906.     } else if (cx == XXTAIL) {
  11907.         head = -10;
  11908.         cx = XXTYP;
  11909.     }
  11910.  
  11911. #ifdef IKSD
  11912.     if (inserver && !ENABLED(en_typ)) {
  11913.         printf("?Sorry, TYPE command disabled\n");
  11914.         return(-9);
  11915.     }
  11916. #endif /* IKSD */
  11917.  
  11918.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  11919.            _CMKEY,            /* fcode */
  11920.            "Filename or switch",    /* hlpmsg */
  11921.            "",            /* default */
  11922.            "",            /* addtl string data */
  11923.            ntypetab,        /* addtl numeric data 1: tbl size */
  11924.            4,            /* addtl numeric data 2: 4 = cmswi */
  11925.            xxstring,        /* Processing function */
  11926.            typetab,            /* Keyword table */
  11927.            &sf            /* Pointer to next FDB */
  11928.            );
  11929.     cmfdbi(&sf,            /* 1st FDB - file to type */
  11930.            _CMIFI,            /* fcode */
  11931.            "",            /* hlpmsg */
  11932.            "",            /* default */
  11933.            "",            /* addtl string data */
  11934.            0,            /* addtl numeric data 1 */
  11935.            0,            /* addtl numeric data 2 */
  11936.            xxstring,
  11937.            NULL,
  11938.            NULL
  11939.            );
  11940.  
  11941.     while (!havename) {
  11942.         x = cmfdb(&sw);        /* Parse something */
  11943.         debug(F101,"type cmfdb","",x);
  11944.         debug(F101,"type cmresult.fcode","",cmresult.fcode);
  11945.         debug(F101,"type cmresult.nresult","",cmresult.nresult);
  11946.         if (x < 0) {            /* Error */
  11947.         if (x == -3) {
  11948.             x = -9;
  11949.             printf("?Filename required\n");
  11950.         }
  11951.         return(x);
  11952.         } else if (cmresult.fcode == _CMKEY) {
  11953.         char c; int getval;
  11954.         c = cmgbrk();
  11955.         getval = (c == ':' || c == '=');
  11956.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  11957.             printf("?This switch does not take an argument\n");
  11958.             return(-9);
  11959.         }
  11960. #ifdef COMMENT
  11961.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  11962.             printf("?This switch requires an argument\n");
  11963.             /* Not if it has a default! */
  11964.             return(-9);
  11965.         }
  11966. #endif /* COMMENT */
  11967.         switch (cmresult.nresult) {
  11968. #ifdef CK_TTGWSIZ
  11969.           case TYP_PAG:
  11970.             paging = 1;
  11971.             break;
  11972.  
  11973.           case TYP_NOP:
  11974.             paging = 0;
  11975.             break;
  11976. #endif /* CK_TTGWSIZ */
  11977.  
  11978.           case TYP_COU:
  11979.             paging = 0;
  11980.             count = 1;
  11981.             break;
  11982.  
  11983.           case TYP_HEA:
  11984.           case TYP_TAI:
  11985.             y = 10;
  11986.             if (getval)
  11987.               if ((x = cmnum("Number of lines",
  11988.                      "10",10,&y,xxstring)) < 0)
  11989.             return(x);
  11990.             head = (cmresult.nresult == TYP_TAI) ? -y : y;
  11991.             break;
  11992.  
  11993.           case TYP_WID:
  11994.             y = typ_wid > -1 ? typ_wid : cmd_cols;
  11995.             if (getval)
  11996.               if ((x = cmnum("Column at which to truncate",
  11997.                      ckitoa(y),10,&y,xxstring)) < 0)
  11998.             return(x);
  11999.             width = y;
  12000.             break;
  12001.  
  12002. #ifdef KUI
  12003.           case TYP_HIG:
  12004.             if (getval)
  12005.               if ((x = cmnum("Height of GUI dialog",
  12006.                      ckitoa(y),10,&y,xxstring)) < 0)
  12007.             return(x);
  12008.             height = y;
  12009.             break;
  12010. #endif /* KUI */
  12011.  
  12012.           case TYP_PAT:
  12013.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  12014.             printf("?This switch requires an argument\n");
  12015.             return(-9);
  12016.             }
  12017.             if ((x = cmfld("pattern","",&s,xxstring)) < 0)
  12018.               return(x);
  12019.             ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  12020.             pat = tmpbuf;
  12021.             break;
  12022.  
  12023.           case TYP_PFX:
  12024.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  12025.             printf("?This switch requires an argument\n");
  12026.             return(-9);
  12027.             }
  12028.             if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0)
  12029.               return(x);
  12030.             if ((int)strlen(s) > 63) {
  12031.             printf("?Too long - 63 max\n");
  12032.             return(-9);
  12033.             }
  12034.             ckstrncpy(pfxbuf,s,64);
  12035.             prefix = brstrip(pfxbuf);
  12036.             number = 0;
  12037.             break;
  12038.  
  12039. #ifdef KUI
  12040.           case TYP_GUI:
  12041.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  12042.             printf("?This switch requires an argument\n");
  12043.             return(-9);
  12044.             }
  12045.             if ((x = cmfld("Dialog box title","",&s,xxstring)) < 0) {
  12046.             if (x != -3)
  12047.               return(x);
  12048.             } else {
  12049.             if ((int)strlen(s) > 127) {
  12050.                 printf("?Too long - 127 max\n");
  12051.                 return(-9);
  12052.             }
  12053.             ckstrncpy(guibuf,s,128);
  12054.             gui_title = brstrip(guibuf);
  12055.             }
  12056.             gui = 1;
  12057.             break;
  12058. #endif /* KUI */
  12059.  
  12060.           case TYP_NUM:        /* /NUMBER */
  12061.             number = 1;
  12062.             prefix = NULL;
  12063.             break;
  12064.  
  12065. #ifdef UNICODE
  12066.           case TYP_XPA:        /* /TRANSPARENT */
  12067.             incs = 0;
  12068.             cset = 0;
  12069.             outcs = -1;
  12070.             break;
  12071.  
  12072.           case TYP_XIN:        /* /CHARACTER-SET: */
  12073.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  12074.             printf("?This switch requires an argument\n");
  12075.             return(-9);
  12076.             }
  12077.             if ((incs = cmkey(fcstab,nfilc,
  12078.                       "character-set name","",xxstring)) < 0) {
  12079.             if (incs == -3)    /* Note: No default */
  12080.               incs = -2;
  12081.             return(incs);
  12082.             }
  12083.             cset = incs;
  12084.             break;
  12085.  
  12086.           case TYP_XUT:        /* /TRANSLATE-TO: */
  12087.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  12088.             printf("?This switch requires an argument\n");
  12089.             return(-9);
  12090.             }
  12091. #ifdef OS2
  12092.             if (!inserver && !k95stdout) {
  12093.             tocs = "ucs2";
  12094.             } else {
  12095. #ifdef CKOUNI
  12096.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  12097. #else /* CKOUNI */
  12098.             extern struct keytab ttcstab[];
  12099.             extern int ntxrtab;
  12100.             tocs = rlookup(ttcstab,ntermc,tocs);
  12101.             if (!tocs)
  12102.               tocs = getdcset();
  12103. #endif /* CKOUNI */
  12104.                     }
  12105. #else /* OS2 */
  12106.             tocs = getdcset();
  12107. #endif /* OS2 */
  12108.             if ((outcs = cmkey(fcstab,nfilc,
  12109.                        "character-set",tocs,xxstring)) < 0)
  12110.               return(outcs);
  12111.             break;
  12112. #endif /* UNICODE */
  12113.           case TYP_OUT:
  12114.             if ((x = cmofi("File for result lines","",
  12115.                    &s,xxstring)) < 0)
  12116.               return(x);
  12117.             ckstrncpy(outfile,s,CKMAXPATH);
  12118.             break;
  12119.         }
  12120.         } else if (cmresult.fcode == _CMIFI)
  12121.           havename = 1;
  12122.         else
  12123.           return(-2);
  12124.     }
  12125.     if (havename) {
  12126.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  12127.         y = cmresult.nresult;
  12128.     } else {
  12129.         if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
  12130.         if (x == -3) {
  12131.             printf("?Name of an existing file required\n");
  12132.             return(-9);
  12133.         } else return(x);
  12134.         }
  12135.         ckstrncpy(line,s,LINBUFSIZ);
  12136.     }
  12137.     if (y != 0) {
  12138.         printf("?A single file please\n");
  12139.         return(-9);
  12140.     }
  12141. #ifdef KUI
  12142.     if ( outfile[0] && gui ) {
  12143.         printf("?/GUI and /OUTPUT are incompatible\n");
  12144.         return(-9);
  12145.     }
  12146. #endif /* KUI */
  12147.  
  12148.     if ((y = cmcfm()) < 0)        /* Confirm the command */
  12149.       return(y);
  12150.  
  12151. #ifdef UNICODE
  12152.     fileorder = -1;
  12153.     if (cset < 0 && filepeek) {    /* If no charset switches given */
  12154.         int k, x = -1;
  12155.         k = scanfile(line,&x,nscanfile); /* Call file analyzer */
  12156.         debug(F111,"type scanfile",line,k);
  12157.         debug(F101,"type scanfile flag","",x);
  12158.         switch(k) {
  12159.           case FT_UTF8:        /* which can detect UTF-8... */
  12160.         cset = 0;
  12161.         incs = FC_UTF8;
  12162.         break;
  12163.           case FT_UCS2:        /* and UCS-2... */
  12164.         cset = 0;
  12165.         incs = FC_UCS2;
  12166.         fileorder = x;        /* even if there is no BOM. */
  12167.         debug(F101,"type fileorder","",fileorder);
  12168.         break;
  12169.         }
  12170.     }
  12171. #ifdef OS2
  12172.         if (cset < 0) {            /* If input charset still not known */
  12173. #ifdef CKOUNI
  12174.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  12175. #else /* CKOUNI */
  12176.             extern struct keytab ttcstab[];
  12177.             extern int ntxrtab;
  12178.             tocs = rlookup(ttcstab,ntermc,incs);
  12179.             if (!tocs)
  12180.           tocs = getdcset();
  12181. #endif /* CKOUNI */
  12182.             incs = lookup(fcstab,tocs,nfilc,&x);
  12183.         }
  12184. #endif /* OS2 */
  12185.  
  12186.         if (outcs == 0 && incs != 0) {    /* Supply default target charset */
  12187.         int x = 0;            /* if switch not given. */
  12188.         tocs = getdcset();
  12189.         outcs = lookup(fcstab,tocs,nfilc,&x);
  12190.     }
  12191. #else  /* !UNICODE */
  12192.     if (cset < 0) incs = outcs = 0;
  12193. #endif /* UNICODE */
  12194.  
  12195.     if (outfile[0] && paging)    /* This combination makes no sense */
  12196.       paging = 0;            /* so turn off paging */
  12197.  
  12198. #ifdef KUI
  12199.     /* No paging when dialog is used */
  12200.     if ( gui && paging )
  12201.       paging = 0;
  12202.  
  12203.     if ( !gui && height ) {
  12204.         printf("?The /HEIGHT switch is not supported without /GUI\n");
  12205.         return(-9);
  12206.     }
  12207. #endif /* KUI */
  12208.  
  12209.     if (count) paging = -1;
  12210.     debug(F111,"type",line,paging);
  12211. #ifdef KUI
  12212.     if ( gui ) {
  12213.         s = (char *)1;    /* ok, its an ugly hack */
  12214.         if (gui_text_popup_create(gui_title ?
  12215.                       gui_title : line, height,width) < 0) {
  12216.         printf("?/GUI not supported on this system\n");
  12217.         gui = 0;
  12218.         return(-9);
  12219.         }
  12220.         width = 0;
  12221.     } else
  12222. #endif /* KUI */
  12223.       s = outfile;
  12224.     success =
  12225.       dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number);
  12226.     return(success);
  12227.     }
  12228. #endif /* NOFRILLS */
  12229.  
  12230. #ifndef NOCSETS
  12231.     if (cx == XXXLA) {            /* TRANSLATE file's charset */
  12232.     _PROTOTYP (int doxlate, ( void ) );
  12233.     return(doxlate());
  12234.     }
  12235. #endif /* NOCSETS */
  12236.  
  12237.     if (cx == XXVER) {            /* VERSION */
  12238.     int n = 0;
  12239.     extern char * ck_patch, * ck_s_test;
  12240. #ifdef COMMENT
  12241.     extern int hmtopline;
  12242. #endif /* COMMENT */
  12243.     if ((y = cmcfm()) < 0)
  12244.           return(y);
  12245.  
  12246. #ifdef CK_64BIT
  12247.     printf("\n%s, for%s (64-bit)\n Numeric: %ld",versio,ckxsys,vernum);
  12248. #else
  12249.     printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum);
  12250. #endif    /* CK_64BIT */
  12251.     printf("\n\n");
  12252.         printf("Authors:\n");
  12253.     printf(" Frank da Cruz, Columbia University\n");
  12254.         printf(" Jeffrey Eric Altman, Secure Endpoints, Inc. %s\n",
  12255.            "<jaltman@secure-endpoints.com>"
  12256.            );
  12257.     printf(" Contributions from many others.\n");
  12258.     n = 7;
  12259.     if (*ck_s_test) {
  12260.         printf("\nTHIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n");
  12261.         n += 2;
  12262.     }
  12263.     if (*ck_patch) {
  12264.         printf(" Patches: %s\n", ck_patch);
  12265.         n++;
  12266.     }
  12267.     printf(" Type COPYRIGHT for copyright and license.\n\n");
  12268. #ifdef OS2
  12269.     shoreg();
  12270. #else
  12271. #ifdef COMMENT
  12272.     hmtopline = n+1;
  12273.     hmsga(copyright);
  12274.     hmtopline = 0;
  12275. #endif /* COMMENT */
  12276. #endif /* OS2 */
  12277.     return(success = 1);
  12278.     }
  12279.  
  12280.     if (cx == XXCPR) {            /* COPYRIGHT or LICENSE */
  12281.     if ((y = cmcfm()) < 0)
  12282.           return(y);
  12283. #ifdef OS2
  12284.     if (inserver) {            /* Free WIKSD */
  12285.         extern char * wiksdcpr[];
  12286.         hmsga(wiksdcpr);
  12287.     } else
  12288. #endif /* OS2 */
  12289.       hmsga(copyright);
  12290.     return(success = 1);
  12291.     }
  12292.  
  12293. #ifndef MAC                /* Only for multiuser systems */
  12294. #ifndef OS2
  12295. #ifndef NOFRILLS
  12296.     if (cx == XXWHO) {            /* WHO */
  12297.     char *wc;
  12298. #ifdef IKSD
  12299.     if (inserver && !ENABLED(en_who)) {
  12300.         printf("?Sorry, WHO command disabled\n");
  12301.         return(-9);
  12302.     }
  12303. #endif /* IKSD */
  12304. #ifdef datageneral
  12305.     if ((z = cmcfm()) < 0) return(z);
  12306.     if (nopush) {
  12307.         printf("?Sorry, who not allowed\n");
  12308.         return(success = 0);
  12309.     }
  12310.         xsystem(WHOCMD);
  12311. #else
  12312.     if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y);
  12313.         if (nopush) {
  12314.         printf("?Sorry, WHO command disabled\n");
  12315.         return(success = 0);
  12316.     }
  12317.     if (!(wc = getenv("CK_WHO"))) wc = WHOCMD;
  12318.     if (wc)
  12319.       if ((int) strlen(wc) > 0) {
  12320.           ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL);
  12321.           xsystem(line);
  12322.       }
  12323. #endif /* datageneral */
  12324.     return(success = 1);
  12325.     }
  12326. #endif /* NOFRILLS */
  12327. #endif /* OS2 */
  12328. #endif /* MAC */
  12329.  
  12330. #ifndef NOFRILLS
  12331.     if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */
  12332.     int x,y;            /* On stack in case of \fexec() */
  12333.     if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) {
  12334.         if (x == -3) printf("?Write to what?\n");
  12335.         return(x);
  12336.     }
  12337.     if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y);
  12338.     s = brstrip(s);
  12339.     switch (x) {
  12340.       case LOGD: y = ZDFILE; break;
  12341.       case LOGP: y = ZPFILE; break;
  12342. #ifndef NOLOCAL
  12343.       case LOGS: y = ZSFILE; break;
  12344. #endif /* NOLOCAL */
  12345.       case LOGT: y = ZTFILE; break;
  12346. #ifndef NOSPL
  12347.       case LOGW: y = ZWFILE; break;
  12348. #endif /* NOSPL */
  12349.       case LOGX:            /* SCREEN (stdout) */
  12350.       case LOGE:            /* ERROR  (stderr) */
  12351.         if (x == LOGE) {
  12352.         debug(F110,
  12353.               (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0);
  12354.         fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : "");
  12355.         } else {
  12356.         debug(F110,
  12357.               (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0);
  12358.         printf("%s%s",s,(cx == XXWRL) ? "\n" : "");
  12359.         }
  12360.         return(success = 1);
  12361.       default: return(-2);
  12362.     }
  12363.     if (chkfn(y) > 0) {
  12364.         x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s);
  12365.         if (x < 0) printf("?Write error\n");
  12366.     } else {
  12367.         x = -1;
  12368.         printf("?File or log not open\n");
  12369.     }
  12370.     return(success = (x == 0) ? 1 : 0);
  12371.     }
  12372. #endif /* NOFRILLS */
  12373.  
  12374. #ifndef NOXFER
  12375.     if (cx == XXASC || cx == XXBIN) {
  12376.     if ((x = cmcfm()) < 0) return(x);
  12377. #ifdef NEWFTP
  12378.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  12379.       return(success = doftptyp((cx == XXASC) ? 0 : 1));
  12380. #endif /* NEWFTP */
  12381.     binary = (cx == XXASC) ? XYFT_T : XYFT_B;
  12382.     return(success = 1);
  12383.     }
  12384. #endif /* NOXFER */
  12385.  
  12386.     if (cx == XXCLS) {
  12387.     if ((x = cmcfm()) < 0) return(x);
  12388.     y = ck_cls();
  12389.     return(success = (y > -1) ? 1 : 0);
  12390.     }
  12391.  
  12392. #ifdef CK_MKDIR
  12393.     if (cx == XXMKDIR || cx == XXLMKD) {
  12394.     char *p;
  12395. #ifdef LOCUS
  12396.     if (!locus && cx != XXLMKD) {
  12397. #ifdef NOXFER
  12398.         return(-2);
  12399. #else
  12400.         return(dormt(XZMKD));
  12401. #endif /* NOXFER */
  12402.         }
  12403. #endif /* LOCUS */
  12404. #ifdef IKSD
  12405.     if (inserver && !ENABLED(en_mkd)) {
  12406.         printf("?Sorry, directory creation is disabled\n");
  12407.         return(-9);
  12408.     }
  12409. #endif /* IKSD */
  12410.     if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) {
  12411.         if (x != -3) {
  12412.         return(x);
  12413.         } else {
  12414.         printf("?Directory name required\n");
  12415.         return(-9);
  12416.         }
  12417.     }
  12418.     ckstrncpy(line,s,LINBUFSIZ);
  12419.     s = line;
  12420.     if ((x = cmcfm()) < 0) return(x);
  12421.     s = brstrip(s);
  12422.     bgchk();            /* Set msgflg */
  12423.     x = ckmkdir(0,s,&p,msgflg,0);
  12424. #ifdef COMMENT
  12425.     if (msgflg && x == 0)
  12426.       printf("?Directory already exists\n");
  12427. #endif /* COMMENT */
  12428.     return(success = (x < 0) ? 0 : 1);
  12429.     }
  12430.     if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */
  12431.     char *p;
  12432. #ifdef LOCUS
  12433.     if (!locus && cx != XXLRMD) {
  12434. #ifdef NOXFER
  12435.         return(-2);
  12436. #else
  12437.         return(dormt(XZRMD));
  12438. #endif /* NOXFER */
  12439.         }
  12440. #endif /* LOCUS */
  12441. #ifdef IKSD
  12442.     if (inserver && !ENABLED(en_rmd)) {
  12443.         printf("?Sorry, directory removal is disabled\n");
  12444.         return(-9);
  12445.     }
  12446. #endif /* IKSD */
  12447.     if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0)
  12448.       return(x);
  12449.     ckstrncpy(line,s,LINBUFSIZ);
  12450.     s = line;
  12451.     if ((x = cmcfm()) < 0) return(x);
  12452.     s = brstrip(s);
  12453.     x = ckmkdir(1,s,&p,msgflg,0);
  12454.     return(success = (x < 0) ? 0 : 1);
  12455.     }
  12456. #endif /* CK_MKDIR */
  12457.  
  12458. #ifdef TNCODE
  12459.     if (cx == XXTELOP)
  12460.       return(dotelopt());
  12461. #endif /* TNCODE */
  12462.  
  12463. #ifndef NOPUSH
  12464.     if (cx == XXNPSH) {
  12465.     if ((z = cmcfm()) < 0) return(z);
  12466.         nopush = 1;
  12467. #ifndef NOSERVER
  12468.         en_hos = 0;
  12469. #endif /* NOSERVER */
  12470. #ifdef PIPESEND
  12471.     usepipes = 0;
  12472. #endif /* PIPESEND */
  12473.         return(success = 1);
  12474.     }
  12475. #endif /* NOPUSH */
  12476.  
  12477. #ifdef OS2
  12478.     if (cx == XXNSCR) {
  12479.     if ((z = cmcfm()) < 0) return(z);
  12480.         tt_scroll = 0;
  12481.         return(success = 1);
  12482.     }
  12483. #endif /* OS2 */
  12484.  
  12485. #ifndef NOSPL
  12486.     if (cx == XXLOCAL)            /* LOCAL variable declarations */
  12487.       return(success = dolocal());
  12488. #endif /* NOSPL */
  12489.  
  12490.     if (cx == XXKERMI) {        /* The KERMIT command */
  12491.     char * list[65];
  12492.     extern char **xargv;
  12493.     extern int xargc;
  12494.     int i;
  12495.     if ((y = cmtxt("kermit command-line arguments, -h for help",
  12496.                "",&s,xxstring)) < 0)
  12497.       return(y);
  12498.     ckstrncpy(line,"kermit ",LINBUFSIZ);
  12499.     ckstrncat(line,s,LINBUFSIZ-8);
  12500.     xwords(line,64,list,0);
  12501.     for (i = 1; i < 64; i++) {
  12502.         if (!list[i])
  12503.           break;
  12504.     }
  12505.     i--;
  12506.     xargc = i;
  12507.     xargv = list;
  12508.     xargv++;
  12509.     sstate = cmdlin();
  12510.     if (sstate) {
  12511.         extern int justone;
  12512.         debug(F000,"KERMIT sstate","",sstate);
  12513.         justone = 1;        /* Force return to command mode */
  12514.         proto();            /* after protocol */
  12515.         return(success);
  12516.     } else {
  12517.         debug(F101,"KERMIT sstate","",sstate);
  12518.         return(success = 1);    /* Not exactly right, but... */
  12519.     }
  12520.     }
  12521.     if (cx == XXDATE) {            /* DATE command */
  12522.     extern char cmdatebuf[], * cmdatemsg;
  12523.  
  12524. #ifndef COMMENT
  12525.     char * dp;
  12526.     if ((y = cmtxt("date and/or time, or carriage return for current",
  12527.                "",&s,xxstring)) < 0)
  12528.       return(y);
  12529.     s = brstrip(s);
  12530.     dp = cmcvtdate(s,1);
  12531.     if (!dp) {
  12532.         printf("?%s\n",cmdatemsg ? cmdatemsg : "Date conversion error");
  12533.         success = 0;
  12534.     } else {
  12535.         printf("%s\n",dp);
  12536.         success = 1;
  12537.     }
  12538. #else
  12539.     /* This works fine but messes up my "dates" torture-test script */
  12540.  
  12541.     if ((x = cmdate("Date and/or time, or carriage return for current",
  12542.             "",&s,0,xxstring)) < 0) {
  12543.         return(x);
  12544.     } else {
  12545.         printf("%s\n",cmdatebuf);
  12546.         success = 1;
  12547.     }
  12548. #endif /* COMMENT */
  12549.     return(success);
  12550.     }
  12551. #ifndef NOPUSH
  12552. #ifndef NOFRILLS
  12553.     if (cx == XXEDIT)
  12554.       return(doedit());
  12555. #endif /* NOFRILLS */
  12556. #endif /* NOPUSH */
  12557.  
  12558. #ifdef BROWSER                /* Defined only ifndef NOPUSH */
  12559.     if (cx == XXBROWS)
  12560.       return(dobrowse());
  12561. #endif /* BROWSER */
  12562.  
  12563. #ifdef CK_TAPI
  12564.     if (cx == XXTAPI) {            /* Microsoft TAPI */
  12565.     return (success = dotapi());
  12566.     }
  12567. #endif /* CK_TAPI */
  12568.  
  12569. #ifndef NOXFER
  12570.     if (cx == XXWHERE) {
  12571.     extern char * rfspec, * sfspec, * srfspec, * rrfspec;
  12572.     if ((x = cmcfm()) < 0) return(x);
  12573.     printf("\nFile most recently...\n\n");
  12574.     printf("  Sent:       %s\n",   sfspec ? sfspec : "(none)");
  12575.     if (sfspec && srfspec) {
  12576.         printf("  Stored as:  %s\n",   srfspec);
  12577.         printf("\n");
  12578.     }
  12579.     printf("  Received:   %s\n",   rrfspec ? rrfspec : "(none)");
  12580.     if (rfspec && rrfspec)
  12581.     printf("  Stored as:  %s\n",   rfspec);
  12582.     printf(
  12583. "\nIf the full path is not shown, then the file is probably in your current\n"
  12584.            );
  12585.     printf(
  12586. "directory or your download directory (if any - SHOW FILE to find out).\n\n"
  12587.            );
  12588.     return(success = 1);
  12589.     }
  12590. #endif /* NOXFER */
  12591.  
  12592. #ifdef CK_RECALL
  12593.     if (cx == XXREDO)
  12594.       return(doredo());
  12595. #endif /* CK_RECALL */
  12596.  
  12597. #ifdef CKROOT
  12598.     if (cx == XXCHRT)            /* Change Kermit's root directory */
  12599.       return(dochroot());
  12600. #endif /* CKROOT */
  12601.  
  12602. #ifdef CK_KERBEROS
  12603.     if (cx == XXAUTH) {            /* KERBEROS */
  12604.     x = cp_auth();            /* Parse it */
  12605. #ifdef IKSD
  12606.         if (inserver) {
  12607.             printf("?Command disabled in IKSD.\r\n");
  12608.             return(success = 0);
  12609.         }
  12610. #endif /* IKSD */
  12611.     if (x < 0)            /* Pass parse errors back */
  12612.       return(x);
  12613.     return(success = doauth(cx));
  12614.     }
  12615. #endif /* CK_KERBEROS */
  12616.  
  12617. #ifndef NOLOCAL
  12618.     if (cx == XXTERM) {
  12619.     return(settrmtyp());
  12620.     }
  12621. #endif /* NOLOCAL */
  12622.  
  12623.     if (cx == XXSTATUS) {
  12624.     if ((x = cmcfm()) < 0) return(x);
  12625.     printf( " %s\n", success ? "SUCCESS" : "FAILURE" );
  12626.     return(0);            /* Don't change it */
  12627.     }
  12628.  
  12629.     if (cx == XXFAIL) {
  12630.     if ((x = cmcfm()) < 0) return(x);
  12631.     return(success = 0);
  12632.     }
  12633.  
  12634.     if (cx == XXSUCC) {
  12635.     if ((x = cmcfm()) < 0) return(x);
  12636.     return(success = 1);
  12637.     }
  12638.  
  12639.     if (cx == XXNLCL) {
  12640.     extern int nolocal;
  12641.     if ((x = cmcfm()) < 0) return(x);
  12642.     nolocal = 1;
  12643.     return(success = 1);
  12644.     }
  12645.  
  12646. #ifndef NOXFER
  12647.     if (cx == XXRASG)            /* Shortcuts for REMOTE commands */
  12648.       return(dormt(XZASG));
  12649.     if (cx == XXRCWD)
  12650.       return(dormt(XZCWD));
  12651.     if (cx == XXRCPY)
  12652.       return(dormt(XZCPY));
  12653.     if (cx == XXRDEL)
  12654.       return(dormt(XZDEL));
  12655.     if (cx == XXRDIR)
  12656.       return(dormt(XZDIR));
  12657.     if (cx == XXRXIT)
  12658.       return(dormt(XZXIT));
  12659.     if (cx == XXRHLP)
  12660.       return(dormt(XZHLP));
  12661.     if (cx == XXRHOS)
  12662.       return(dormt(XZHOS));
  12663.     if (cx == XXRKER)
  12664.       return(dormt(XZKER));
  12665.     if (cx == XXRPWD)
  12666.       return(dormt(XZPWD));
  12667.     if (cx == XXRQUE)
  12668.       return(dormt(XZQUE));
  12669.     if (cx == XXRREN)
  12670.       return(dormt(XZREN));
  12671.     if (cx == XXRMKD)
  12672.       return(dormt(XZMKD));
  12673.     if (cx == XXRMSG)
  12674.       return(dormt(XZMSG));
  12675.     if (cx == XXRRMD)
  12676.       return(dormt(XZRMD));
  12677.     if (cx == XXRSET)
  12678.       return(dormt(XZSET));
  12679.     if (cx == XXRSPA)
  12680.       return(dormt(XZSPA));
  12681.     if (cx == XXRTYP)
  12682.       return(dormt(XZTYP));
  12683.     if (cx == XXRWHO)
  12684.       return(dormt(XZWHO));
  12685.     if (cx == XXRCDUP)
  12686.       return(dormt(XZCDU));
  12687.     if (cx == XXRPRI)
  12688.       return(dormt(XZPRI));
  12689. #endif /* NOXFER */
  12690.  
  12691.     if (cx == XXRESET) {        /* RESET */
  12692.     if ((x = cmcfm()) < 0)
  12693.       return(x);
  12694.     doclean(0);            /* Close all files */
  12695.     return(success = 1);
  12696.     }
  12697.  
  12698. #ifndef NOXFER
  12699. #ifndef NOCSETS
  12700.     if (cx == XXASSOC)            /* ASSOCIATE */
  12701.       return(doassoc());
  12702. #endif /* NOCSETS */
  12703. #endif /* NOXFER */
  12704.  
  12705. #ifndef NOSPL
  12706.     if (cx == XXSHIFT) {        /* SHIFT */
  12707.     if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0)
  12708.       return(y);
  12709.     if ((z = cmcfm()) < 0)
  12710.       return(z);
  12711.     return(success = doshift(x));
  12712.     }
  12713. #endif /* NOSPL */
  12714.  
  12715. #ifndef NOHELP
  12716.     if (cx == XXMAN)
  12717.       return(domanual());
  12718. #endif /* NOHELP */
  12719.  
  12720. #ifndef NOSPL
  12721.     if (cx == XXSORT)            /* SORT an array */
  12722.       return(dosort());
  12723. #endif /* NOSPL */
  12724.  
  12725.     if (cx == XXPURGE) {
  12726. #ifdef IKSD
  12727.     if (inserver && (!ENABLED(en_del)
  12728. #ifdef CK_LOGIN
  12729.                           || isguest
  12730. #endif /* CK_LOGIN */
  12731.              )) {
  12732.         printf("?Sorry, DELETE is disabled\n");
  12733.         return(-9);
  12734.     }
  12735. #endif /* IKSD */
  12736. #ifdef CK_APC
  12737.     if ((apcactive == APC_LOCAL) ||
  12738.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  12739.       return(success = 0);
  12740. #endif /* CK_APC */
  12741. #ifdef CKPURGE
  12742.         return(dopurge());
  12743. #else
  12744. #ifdef VMS
  12745.     if ((x = cmtxt("optional switches followed by filespec",
  12746.                "",&s,xxstring)) < 0)
  12747.       return(x);
  12748.     if (nopush) {
  12749.         printf("?Sorry, DCL access is disabled\n");
  12750.         return(-9);
  12751.     }
  12752.     ckstrncpy(line,s,LINBUFSIZ);
  12753.     s = line;
  12754.     x = mlook(mactab,"purge",nmac);
  12755.     return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs));
  12756. #else
  12757.     return(-2);
  12758. #endif /* VMS */
  12759. #endif /* CKPURGE */
  12760.     }
  12761.  
  12762. #ifndef NOSPL
  12763.     if (cx == XXFAST) {
  12764.     if ((x = cmcfm()) < 0) return(x);
  12765.     x = mlook(mactab,"fast",nmac);
  12766.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  12767.     }
  12768.     if (cx == XXCAU) {
  12769.     if ((x = cmcfm()) < 0) return(x);
  12770.     x = mlook(mactab,"cautious",nmac);
  12771.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  12772.     }
  12773.     if (cx == XXROB) {
  12774.     if ((x = cmcfm()) < 0) return(x);
  12775.     x = mlook(mactab,"robust",nmac);
  12776.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  12777.     }
  12778. #endif /* NOSPL */
  12779.  
  12780.     if (cx == XXSCRN) {            /* SCREEN */
  12781.     int row, col;
  12782.     if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0)
  12783.       return(x);
  12784.     switch (x) {            /* MOVE-TO (cursor position) */
  12785.       case SCN_MOV:
  12786.         if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0)
  12787.           return(y);
  12788.         row = z;
  12789.         y = cmnum("Column (1-based)","1",10,&z,xxstring);
  12790.         if (y < 0)
  12791.           return(y);
  12792.         col = z;
  12793.         if ((y = cmcfm()) < 0)
  12794.           return(y);
  12795.         if (row < 0 || col < 0) {
  12796.         printf("?Row and Column must be 1 or greater\n");
  12797.         return(-9);
  12798.         }
  12799.         if (cmd_rows > 0 && row > cmd_rows)
  12800.           row = cmd_rows;
  12801.         if (cmd_cols > 0 && col > cmd_cols)
  12802.           col = cmd_cols;
  12803.         y = ck_curpos(row,col);
  12804.         return(success = (y > -1) ? 1 : 0);
  12805.  
  12806.       case SCN_CLR:            /* CLEAR */
  12807.         if ((y = cmcfm()) < 0)
  12808.           return(y);
  12809.         debug(F100,"screen calling ck_cls()","",0);
  12810.         y = ck_cls();
  12811.         return(success = (y > -1) ? 1 : 0);
  12812.  
  12813.       case SCN_CLE:            /* CLEOL */
  12814.         if ((y = cmcfm()) < 0)
  12815.           return(y);
  12816.         y = ck_cleol();
  12817.         return(success = (y > -1) ? 1 : 0);
  12818.     }
  12819.     }
  12820.  
  12821. #ifndef NOHTTP
  12822. #ifdef TCPSOCKET
  12823.     if (cx == XXHTTP)
  12824.       return(dohttp());
  12825. #endif /* TCPSOCKET */
  12826. #endif /* NOHTTP */
  12827.  
  12828. #ifndef NOSPL
  12829.     if (cx == XXARRAY) {        /* ARRAY */
  12830. #ifndef NOSHOW
  12831.     extern int showarray();
  12832. #endif /* NOSHOW */
  12833.     if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0)
  12834.       return(x);
  12835.     switch (x) {
  12836.       case ARR_DCL:
  12837.         return(dodcl(XXDCL));
  12838.       case ARR_SRT:
  12839.         return(dosort());
  12840. #ifndef NOSHOW
  12841.       case ARR_SHO:
  12842.         return(showarray());
  12843. #endif /* NOSHOW */
  12844.       case ARR_CPY:
  12845.         return(copyarray());
  12846.       case ARR_SET:
  12847.       case ARR_CLR:
  12848.         return(clrarray(x));
  12849.       case ARR_DST:
  12850.         return(unarray());
  12851.       case ARR_RSZ:
  12852.         return(rszarray());
  12853.       case ARR_EQU:
  12854.         return(linkarray());
  12855.  
  12856.       default:
  12857.         printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf);
  12858.         return(-9);
  12859.     }
  12860.     }
  12861.     if (cx == XXTRACE)
  12862.       return(dotrace());
  12863. #endif /* NOSPL */
  12864.  
  12865. #ifdef CK_PERMS
  12866. #ifdef UNIX
  12867.     if (cx == XXCHMOD)
  12868.       return(douchmod());        /* Do Unix chmod */
  12869. #endif /* UNIX */
  12870. #endif /* CK_PERMS */
  12871.  
  12872.     if (cx == XXPROMP)
  12873.       return(doprompt());
  12874.  
  12875.     if (cx == XXGREP)
  12876.       return(dogrep());
  12877.  
  12878.     if (cx == XXDEBUG) {        /* DEBUG */
  12879. #ifndef DEBUG
  12880.     int dummy = 0;
  12881.     return(seton(&dummy));
  12882. #else
  12883.     return(seton(&deblog));
  12884. #endif /* DEBUG */
  12885.     }
  12886.  
  12887. #ifdef CKLEARN
  12888.     if (cx == XXLEARN) {        /* LEARN */
  12889.     struct FDB of, sw, cm;
  12890.     int closing = 0, off = 0, on = 0, confirmed = 0;
  12891.     char c;
  12892.  
  12893.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  12894.            _CMKEY,            /* fcode */
  12895.            "Script file name, or switch", /* hlpmsg */
  12896.            "",            /* default */
  12897.            "",            /* addtl string data */
  12898.            3,            /* addtl numeric data 1: tbl size */
  12899.            4,            /* addtl numeric data 2: 4 = cmswi */
  12900.            xxstring,        /* Processing function */
  12901.            learnswi,        /* Keyword table */
  12902.            &of            /* Pointer to next FDB */
  12903.            );
  12904.     cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm);
  12905.     cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL);
  12906.     line[0] = NUL;
  12907.  
  12908.     while (!confirmed) {
  12909.         x = cmfdb(&sw);        /* Parse something */
  12910.         if (x < 0)
  12911.           return(x);
  12912.         switch (cmresult.fcode) {    /* What was it? */
  12913.           case _CMOFI:        /* Output file name */
  12914.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  12915.         break;
  12916.           case _CMKEY:        /* Switch */
  12917.         c = cmgbrk();
  12918.         if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) {
  12919.             printf("?This switch does not take an argument\n");
  12920.             return(-9);
  12921.         }
  12922.         switch (cmresult.nresult) {
  12923.           case 2:        /* /CLOSE */
  12924.             closing = 1;    /* Fall thru on purpose */
  12925.           case 0:        /* /OFF */
  12926.             off = 1;
  12927.             on = 0;
  12928.             break;
  12929.           case 1:        /* /ON */
  12930.             on = 1;
  12931.             off = 0;
  12932.             break;
  12933.         }
  12934.         break;
  12935.           case _CMCFM:        /* Confirmation */
  12936.         confirmed++;
  12937.         break;
  12938.         }
  12939.     }
  12940.     if (closing) {
  12941.         if (learnfp) {
  12942.         fclose(learnfp);
  12943.         learnfp = NULL;
  12944.         }
  12945.         makestr(&learnfile,NULL);
  12946.     }
  12947.     if (line[0]) {
  12948.         if (!on && !off)
  12949.           on = 1;
  12950.         if (learnfp) {
  12951.         fclose(learnfp);
  12952.         learnfp = NULL;
  12953.         }
  12954.         makestr(&learnfile,line);
  12955.         if (learnfile) {
  12956.         char * modes = "w";
  12957.         learnfp = fopen(learnfile,modes);
  12958.         if (!learnfp) {
  12959.             debug(F110,"LEARN file open error",learnfile,0);
  12960.             perror(learnfile);
  12961.             return(-9);
  12962.         } else {
  12963. #ifdef ZFNQFP
  12964.             if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf))
  12965.               makestr(&learnfile,tmpbuf);
  12966. #endif /* ZFNQFP */
  12967.             debug(F110,"LEARN file open ok",learnfile,0);
  12968.             if (!quiet) {
  12969.             printf("Recording to %s...\n\n",learnfile);
  12970.             printf(
  12971. " WARNING: If you type your password during script recording, it will appear\n\
  12972.  in the file.  Be sure to edit it or take other appropriate precautions.\n\n"
  12973.                    );
  12974.             }
  12975.             fputs(  "; Scriptfile: ",learnfp);
  12976.             fputs(learnfile,learnfp);
  12977.             fputs("\n; Directory:  ",learnfp);
  12978.             fputs(zgtdir(),learnfp);
  12979.             fputs("\n; Recorded:   ",learnfp);
  12980.             fputs(ckdate(),learnfp);
  12981.             fputs("\n",learnfp);
  12982.         }
  12983.         }
  12984.     }
  12985.     if (on) {
  12986.         learning = 1;
  12987.     } else if (off) {
  12988.         learning = 0;
  12989.     }
  12990.     debug(F101,"LEARN learning","",learning);
  12991.     return(success = 1);
  12992.     }
  12993. #endif /* CKLEARN */
  12994.  
  12995. #ifdef NEWFTP
  12996.     if (cx == XXUSER || cx == XXACCT) {
  12997.     if (!ftpisopen()) {
  12998.         printf("?FTP connection is not open\n");
  12999.         return(-9);
  13000.     }
  13001.     return(success = (cx == XXUSER) ? doftpusr() : doftpacct());
  13002.     }
  13003.     if (cx == XXSITE || cx == XXPASV) {
  13004.     if (!ftpisopen()) {
  13005.         printf("?FTP connection is not open\n");
  13006.         return(-9);
  13007.     }
  13008.     return(success = (cx == XXSITE) ? doftpsite() : dosetftppsv());
  13009.     }
  13010. #endif /* NEWFTP */
  13011.  
  13012.     if (cx == XXORIE) {            /* ORIENTATION */
  13013.     extern char * myname;
  13014.     int i, y, n = 0;
  13015.         char * s, *p, vbuf[32];
  13016.     char * vars[16];       char * legend[16];
  13017.  
  13018.     if ((y = cmcfm()) < 0)
  13019.       return(y);
  13020.  
  13021.     printf("\nProgram name:\n  %s\n\n",myname);
  13022.     n += 4;
  13023.  
  13024. #ifdef NT
  13025.     vars[0] = "home";      legend[0] = "Your home directory";
  13026.     vars[1] = "directory"; legend[1] = "K95's current directory";
  13027.     vars[2] = "exedir";    legend[2] = "K95 Program directory";
  13028.     vars[3] = "inidir";    legend[3] = "K95 Initialization file directory";
  13029.     vars[4] = "startup";   legend[4] = "Current directory when started";
  13030.     
  13031.         vars[5] = "common";
  13032.         legend[5] = "K95 data for all users and K95SITE.INI file";
  13033.     
  13034.         vars[6] = "personal";  legend[6] = "Your personal data directory tree";
  13035.         vars[7] = "desktop";   legend[7] = "Your deskop directory tree";
  13036.     
  13037.         vars[8] = "appdata";
  13038.         legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file";
  13039.     
  13040.         vars[9] = "download";  legend[9] = "Your K95 download directory";
  13041.         vars[10] = "tmpdir";   legend[10] = "Your TEMP directory";
  13042.     vars[11] = NULL;       legend[11] = NULL;
  13043.  
  13044.     for (i = 0; i < 16 && vars[i]; i++) {
  13045.         printf("%s:\n",legend[i]);
  13046.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13047.         ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
  13048.         printf("  Variable:   %s\n",vbuf);
  13049.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13050.         y = TMPBUFSIZ;
  13051.         s = tmpbuf;
  13052.         zzstring(vbuf,&s,&y);
  13053.         line[0] = NUL;
  13054.         ckGetLongPathName(tmpbuf,line,LINBUFSIZ);
  13055.         printf("  Long name:  %s\n",line);
  13056.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13057.         line[0] = NUL;
  13058.         GetShortPathName(tmpbuf,line,LINBUFSIZ);
  13059.         printf("  Short name: %s\n",line);
  13060.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13061.             printf("\n");
  13062.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13063.     }
  13064. #else  /* NT */
  13065.  
  13066.     vars[0] = "home";      legend[0] = "Your home directory";
  13067.     vars[1] = "directory"; legend[1] = "Kermit's current directory";
  13068.     vars[2] = "exedir";    legend[2] = "Kermit's program directory";
  13069.     vars[3] = "inidir";    legend[3] = "Initialization file directory";
  13070.     vars[4] = "startup";   legend[4] = "Current directory when started";
  13071.     vars[5] = "download";  legend[5] = "Kermit download directory";
  13072.     vars[6] = NULL;           legend[6] = NULL;
  13073.  
  13074.     for (i = 0; i < 16 && vars[i]; i++) {
  13075.         printf("%s:\n",legend[i]);
  13076.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13077.         ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
  13078.         printf("  Variable: %s\n",vbuf);
  13079.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13080.         y = TMPBUFSIZ;
  13081.         s = tmpbuf;
  13082.         zzstring(vbuf,&s,&y);
  13083.             printf("  Value:    %s\n",tmpbuf);
  13084.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13085.             printf("\n");
  13086.         if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  13087.     }
  13088. #endif /* NT */
  13089.     return(success = 1);
  13090.     }
  13091.  
  13092. #ifdef NT
  13093.     if (cx == XXDIALER) {
  13094.         StartDialer();
  13095.         return(success = 1);
  13096.     }
  13097. #endif /* NT */
  13098.  
  13099.     if (cx == XXCONT) {            /* CONTINUE */
  13100.     if ((x = cmcfm()) < 0)
  13101.       return(x);
  13102.     if (!xcmdsrc) {            /* At prompt: continue script */
  13103.         if (cmdlvl > 0)
  13104.           popclvl();        /* Pop command level */
  13105.         return(success = 1);    /* always succeeds */
  13106. #ifndef NOSPL
  13107.     } else {            /* In script: whatever... */
  13108.         x = mlook(mactab,"continue",nmac);
  13109.         /* Don't set success */
  13110.         return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  13111. #endif /* NOSPL */
  13112.     }
  13113.     }
  13114.     if (cx == XXNOTAV) {        /* Command in table not available */
  13115.     ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  13116.     if ((x = cmtxt("Rest of command","",&s,NULL)) < 0)
  13117.       return(x);
  13118.     printf("Sorry, \"%s\" not configured in this version of Kermit.\n",
  13119.            tmpbuf
  13120.            );
  13121.     return(success = 0);
  13122.     }
  13123.     return(-2);                /* None of the above */
  13124.  
  13125. } /* end of docmd() */
  13126.  
  13127. #endif /* NOICP */
  13128.