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

  1. #ifdef SSHTEST
  2. #define SSHBUILTIN
  3. #endif /* SSHTEST */
  4.  
  5. #include "ckcsym.h"
  6. char *userv = "User Interface 8.0.254, 8 Feb 2002";
  7.  
  8. /*  C K U U S R --  "User Interface" for C-Kermit (Part 1)  */
  9.  
  10. /*
  11.   Author: Frank da Cruz <fdc@columbia.edu>
  12.   Columbia University Academic Information Systems, New York City.
  13.  
  14.   Copyright (C) 1985, 2002,
  15.     Trustees of Columbia University in the City of New York.
  16.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  17.     copyright text in the ckcmai.c module for disclaimer and permissions.
  18. */
  19.  
  20. /*
  21.   Originally the entire user interface was in one module, ckuusr.c.  Over
  22.   the years it has been split into many modules: ckuus2.c, ckuus3.c, ...,
  23.   ckuus7.c.  ckuus2.c contains the HELP command parser and help-text strings;
  24.   ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains
  25.   routines needed by both the command-line interface and the interactive
  26.   command parser.
  27. */
  28.  
  29. /*
  30.   The ckuus*.c modules depend on the existence of C library features like
  31.   fopen, fgets, feof, (f)printf, argv/argc, etc.  Other functions that are
  32.   likely to vary among different platforms -- like setting terminal modes or
  33.   interrupts -- are invoked via calls to functions that are defined in the
  34.   system- dependent modules, ck?[ft]io.c.  The command line parser processes
  35.   any arguments found on the command line, as passed to main() via argv/argc.
  36.   The interactive parser uses the facilities of the cmd package (developed for
  37.   this program, but usable by any program).  Any command parser may be
  38.   substituted for this one.  The only requirements for the Kermit command
  39.   parser are these:
  40.  
  41.   . Set parameters via global variables like duplex, speed, ttname, etc.  See
  42.     ckmain.c for the declarations and descriptions of these variables.
  43.  
  44.   . If a command can be executed without the use of Kermit protocol, then
  45.     execute the command directly and set the variable sstate to 0. Examples
  46.     include 'set' commands, local directory listings, the 'connect' command.
  47.  
  48.   . If a command requires the Kermit protocol, set the following variables:
  49.  
  50.      sstate                             string data
  51.        'x' (enter server mode)            (none)
  52.        'r' (send a 'get' command)         cmarg, cmarg2
  53.        'v' (enter receive mode)           cmarg2
  54.        'g' (send a generic command)       cmarg
  55.        's' (send files)                   nfils, cmarg & cmarg2 OR cmlist
  56.        'c' (send a remote host command)   cmarg
  57.  
  58.      cmlist is an array of pointers to strings.
  59.      cmarg, cmarg2 are pointers to strings.
  60.      nfils is an integer.
  61.  
  62.      cmarg can be a filename string (possibly wild), or
  63.     a pointer to a prefabricated generic command string, or
  64.     a pointer to a host command string.
  65.      cmarg2 is an "as-name" - the name to send file(s) under, or
  66.     the name under which to store incoming file(s); must not be wild.
  67.     A null or empty value means to use the file's own name.
  68.      cmlist is a list of filenames, such as passed via argv.
  69.      nfils is an integer, interpreted as follows:
  70.        -1: filespec (possibly wild) in cmarg, must be expanded internally.
  71.     0: send from stdin (standard input).
  72.        >0: number of files to send, from cmlist.
  73.  
  74.   The screen() function is used to update the screen during file transfer.
  75.   The tlog() function writes to a transaction log.
  76.   The debug() function writes to a debugging log.
  77.   The intmsg() and chkint() functions provide the user i/o for interrupting
  78.     file transfers.
  79. */
  80.  
  81. /* Includes */
  82.  
  83. #ifdef MULTINET
  84. #define MULTINET_OLD_STYLE        /* Leave select prototype undefined */
  85. #endif /* MULTINET */
  86.  
  87. #include "ckcdeb.h"
  88. #include "ckcasc.h"
  89. #include "ckcker.h"
  90. #include "ckcnet.h"            /* Network symbols */
  91. #include "ckuusr.h"
  92. #include "ckcxla.h"
  93.  
  94. int g_fncact = -1;            /* Needed for NOICP builds */
  95. int noinit = 0;                /* Flag for skipping init file */
  96. int nscanfile = SCANFILEBUF;
  97.  
  98. int locus = 1;                /* Current LOCUS is LOCAL */
  99. int autolocus = 1;            /* Automatic LOCUS switching enabled */
  100.  
  101. #ifndef NOICP
  102. #ifdef CKLEARN
  103. #ifdef VMS
  104. #include <time.h>            /* For CKLEARN */
  105. #endif /* VMS */
  106. #endif /* CKLEARN */
  107. #ifdef OS2
  108. #ifndef NT
  109. #define INCL_NOPM
  110. #define INCL_VIO            /* Needed for ckocon.h */
  111. #include <os2.h>
  112. #undef COMMENT
  113. #else
  114. #define APIRET ULONG
  115. #include <windows.h>
  116. #include <tapi.h>
  117. #include "cknwin.h"
  118. #include "ckntap.h"            /* CK_TAPI definition */
  119. #endif /* NT */
  120. #include "ckowin.h"
  121. #include "ckocon.h"
  122. extern int tcp_avail;
  123. extern bool viewonly;
  124. extern int k95stdout;
  125. #ifndef NOTERM
  126. extern tt_status[VNUM];
  127. #endif /* NOTERM */
  128. int display_demo = 1;
  129. #include "ckossh.h"
  130. #endif /* OS2 */
  131.  
  132. int optlines = 0;
  133. int didsetlin = 0;
  134.  
  135. #ifdef NEWFTP
  136. extern int ftpget, ftpisopen(), ftpbye(), doftpres();
  137. _PROTOTYP(int doftptyp,(int));
  138. #endif /* NEWFTP */
  139.  
  140. #ifdef VMS
  141. extern int batch;
  142. #endif /* VMS */
  143.  
  144. #ifdef datageneral
  145. #include <packets:common.h>
  146. #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
  147. #endif /* datageneral */
  148.  
  149. extern int xcmdsrc, hints, cmflgs, whyclosed;
  150.  
  151. char * hlptok = NULL;
  152.  
  153. #ifdef CK_TTGWSIZ            /* Whether to use more-prompting */
  154. int xaskmore = 1;            /* Momentary setting */
  155. int saveask  = 1;            /* Permanent setting */
  156. #else
  157. int xaskmore = 0;
  158. int saveask  = 0;
  159. #endif /* CK_TTGWSIZ */
  160.  
  161. #ifndef NOCSETS
  162. extern int nfilc;
  163. extern struct keytab fcstab[];
  164. extern int fcharset;
  165. #endif /* NOCSETS */
  166.  
  167. char * g_pswd = NULL;
  168. int g_pcpt = -1;
  169. int g_pflg = -1;
  170.  
  171. extern int cmd_rows, cmd_cols;
  172.  
  173. #ifdef CKROOT
  174. extern int ckrooterr;
  175. #endif /* CKROOT */
  176.  
  177. extern int inserver, filepeek;
  178.  
  179. #ifdef CKLEARN
  180. FILE * learnfp = NULL;
  181. char * learnfile = NULL;
  182. int learning = 0;
  183. #endif /* CKLEARN */
  184.  
  185. #ifndef NOXFER
  186. extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size,
  187.   sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz,
  188.   spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable,
  189.   setreliable;
  190.  
  191. #ifdef IKSDCONF
  192. extern int iksdcf;
  193. #endif /* IKSDCONF */
  194.  
  195. #ifdef CK_LOGIN
  196. extern int isguest;
  197. #endif /* CK_LOGIN */
  198.  
  199. extern long sendstart;
  200.  
  201. extern char *cmarg, *cmarg2, **cmlist, *dftty;
  202.  
  203. extern struct keytab fntab[]; extern int nfntab;
  204. extern struct ck_p ptab[NPROTOS];
  205.  
  206. int sndcmd = 0;        /* Last command was a SEND-class command. */
  207.  
  208. int g_xfermode = -1;
  209. int g_proto  = -1;
  210. int g_urpsiz = -1;
  211. int g_spsizf = -1;
  212. int g_spsiz  = -1;
  213. int g_spsizr = -1;
  214. int g_spmax  = -1;
  215. int g_wslotr = -1;
  216. int g_prefixing = -1;
  217. int g_fncnv  = -1;
  218. int g_fnspath = -1;
  219. int g_fnrpath = -1;
  220. int g_fnact  = -1;
  221. int g_displa = -1;
  222. int g_spath  = -1;
  223. int g_rpath  = -1;
  224. char * g_sfilter = NULL;
  225. char * g_rfilter = NULL;
  226.  
  227. extern int patterns;
  228. #ifdef PATTERNS
  229. extern char *txtpatterns[], *binpatterns[];
  230. int g_patterns = -1;
  231. #endif /* PATTERNS */
  232. int g_skipbup = -1;
  233.  
  234. #ifdef PIPESEND
  235. extern int usepipes, pipesend;
  236. extern char * sndfilter;
  237. #endif /* PIPESEND */
  238.  
  239. #ifndef NOSPL
  240. extern int sndxlo, sndxhi, sndxin;
  241. #endif /* NOSPL */
  242.  
  243. extern char fspec[];            /* Most recent filespec */
  244. extern int fspeclen;            /* Length of fspec[] buffer */
  245.  
  246. #ifndef NOFRILLS
  247. extern int rmailf;            /* MAIL command items */
  248. extern char optbuf[];
  249. #endif /* NOFRILLS */
  250.  
  251. extern int
  252.   en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri,
  253.   en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit,
  254.   en_mkd, en_rmd, en_asg;
  255.  
  256. #ifndef NOMSEND                /* Multiple SEND */
  257. extern char *msfiles[];
  258. int filesinlist = 0;            /* And ADD ... */
  259. extern struct filelist * filehead;
  260. extern struct filelist * filetail;
  261. extern struct filelist * filenext;
  262. extern int addlist;
  263. #endif /* NOMSEND */
  264.  
  265. static struct keytab addtab[] = {
  266. #ifdef PATTERNS
  267.     { "binary-patterns", ADD_BIN, 0 },
  268. #endif /* PATTERNS */
  269. #ifndef NOMSEND
  270.     { "send-list", ADD_SND, 0 },
  271. #endif /* NOMSEND */
  272. #ifdef PATTERNS
  273.     { "text-patterns", ADD_TXT, 0 },
  274. #endif /* PATTERNS */
  275.     { "", 0, 0 }
  276. };
  277. static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;
  278.  
  279. #ifndef NOCSETS
  280. struct keytab assoctab[] = {
  281.     { "file-character-set",     ASSOC_FC, 0 },
  282.     { "transfer-character-set", ASSOC_TC, 0 },
  283.     { "xfer-character-set",     ASSOC_TC, CM_INV }
  284. };
  285. static int nassoc = sizeof(assoctab)/sizeof(struct keytab);
  286. extern int afcset[MAXFCSETS+1];        /* Character-set associations */
  287. extern int axcset[MAXTCSETS+1];
  288. #endif /* NOCSETS */
  289.  
  290. #ifndef ADDCMD
  291. #ifndef NOMSEND
  292. #define ADDCMD
  293. #endif /* NOMSEND */
  294. #ifndef ADDCMD
  295. #ifdef PATTERNS
  296. #define ADDCMD
  297. #endif /* PATTERNS */
  298. #endif /* ADDCMD */
  299. #endif /* ADDCMD */
  300. #endif /* NOXFER */
  301.  
  302. /* External Kermit Variables, see ckmain.c for description. */
  303.  
  304. extern xx_strp xxstring;
  305. extern long xvernum;
  306.  
  307. extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel,
  308.   pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;
  309. #ifdef TNCODE
  310. extern int debses;
  311. extern char tn_msg[];
  312. #endif /* TNCODE */
  313.  
  314. int sleepcan = 1;
  315. int g_binary = -1;
  316. int g_recursive = -1;
  317. int g_matchdot = -1;
  318. extern int nolinks;
  319.  
  320. extern long vernum;
  321. extern char *versio, *copyright[];
  322. extern char *ckxsys;
  323. #ifndef NOHELP
  324. extern char *introtxt[];
  325. extern char *newstxt[];
  326. #endif /* NOHELP */
  327.  
  328. #ifndef OS2
  329. #ifndef UNIX
  330. extern char *PWDCMD;
  331. #endif /* UNIX */
  332. extern char *WHOCMD;
  333. #endif /* OS2 */
  334.  
  335. extern char ttname[];
  336.  
  337. extern CHAR sstate;
  338.  
  339. extern int network;            /* Have active network connection */
  340. extern int nettype;            /* Type of network */
  341. extern int ttnproto;                    /* NET_TCPB protocol */
  342.  
  343. #ifndef NODIAL
  344. extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */
  345. #endif /* NODIAL */
  346.  
  347. #ifdef CK_APC
  348. extern int apcactive, apcstatus;
  349. #endif /* CK_APC */
  350.  
  351. #ifndef NOPUSH
  352. #ifndef NOFRILLS
  353. extern char editor[];
  354. extern char editopts[];
  355. extern char editfile[];
  356. #endif /* NOFRILLS */
  357. #endif /* NOPUSH */
  358.  
  359. #ifdef BROWSER
  360. extern char browser[];            /* Web browser application */
  361. extern char browsopts[];        /* Web browser options */
  362. extern char browsurl[];            /* Most recent URL */
  363. #endif /* BROWSER */
  364. #ifndef NOFTP
  365. char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */
  366. char ftpopts[128] = { NUL, NUL };    /* ftp command-line options */
  367. #endif /* NOFTP */
  368. extern struct keytab onoff[];        /* On/Off keyword table */
  369.  
  370. #ifdef CK_TMPDIR
  371. int f_tmpdir = 0;            /* Directory changed temporarily */
  372. char savdir[TMPDIRLEN];            /* For saving current directory */
  373. #endif /* CK_TMPDIR */
  374.  
  375. int activecmd = -1;            /* Keyword index of active command */
  376. int doconx = -1;            /* CONNECT-class command active */
  377. int ooflag = 0;                /* User-settable on/off flag */
  378.  
  379. int rcflag = 0;                /* Pointer to home directory string */
  380. int repars,                /* Reparse needed */
  381.     techo = 0;                /* Take echo */
  382. int secho = 1;                /* SCRIPT echo */
  383.  
  384. int xitwarn =            /* Warn about open connection on exit */
  385. #ifdef NOWARN
  386. 0
  387. #else
  388. 1
  389. #endif /* NOWARN */
  390. ;
  391.  
  392. struct keytab onoffsw[] = {
  393.     { "/off", 0, 0 },
  394.     { "/on",  1, 0 }
  395. };
  396.  
  397. #ifdef CKEXEC
  398. struct keytab redirsw[] = {
  399.     { "/redirect", 1, 0 }
  400. };
  401. #endif /* CKEXEC */
  402.  
  403. #ifndef NOXMIT
  404. /* Variables for TRANSMIT command */
  405.  
  406. int xmitx = 1;            /* Whether to echo during TRANSMIT */
  407. int xmitf = 0;            /* Character to fill empty lines */
  408. int xmitl = 0;            /* 0 = Don't send linefeed too */
  409. int xmitp = LF;            /* Host line prompt */
  410. int xmits = 0;            /* Use shift-in/shift-out, 0 = no */
  411. int xmitw = 0;            /* Milliseconds to pause during TRANSMIT */
  412. int xmitt = 1;            /* Seconds to wait for each char to echo */
  413. int xmita = 1;            /* Action upon timeout */
  414.  
  415. #define XMI_BIN 1
  416. #define XMI_TXT 2
  417. #define XMI_CMD 3
  418. #define XMI_TRA 4
  419. #define XMI_VRB 5
  420. #define XMI_QUI 6
  421. #define XMI_NOW 7
  422. #define XMI_NOE 8
  423.  
  424. static struct keytab xmitsw[] = {    /* TRANSMIT command options */
  425.     { "/binary",          XMI_BIN, 0 },
  426. #ifdef PIPESEND
  427.     { "/command",         XMI_CMD, CM_INV|CM_PSH },
  428. #endif /* PIPESEND */
  429.     { "/noecho",          XMI_NOE, 0 },
  430.     { "/nowait",          XMI_NOW, 0 },
  431. #ifdef PIPESEND
  432.     { "/pipe",            XMI_CMD, 0 },
  433. #endif /* PIPESEND */
  434. #ifdef COMMENT
  435.     { "/quiet",           XMI_QUI, 0 },
  436. #endif /* COMMENT */
  437.     { "/text",            XMI_TXT, 0 },
  438.     { "/transparent",     XMI_TRA, 0 },
  439. #ifdef COMMENT
  440.     { "/verbose",         XMI_VRB, 0 },
  441. #endif /* COMMENT */
  442.     { "", 0, 0 }
  443. };
  444. #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1
  445. static int nxmitsw = NXMITSW;
  446.  
  447. #endif /* NOXMIT */
  448.  
  449. /* Declarations from ck?fio.c module */
  450.  
  451. extern char *SPACMD, *SPACM2;        /* SPACE commands */
  452.  
  453. /* Command-oriented items */
  454.  
  455. #ifdef DCMDBUF
  456. extern char *cmdbuf;            /* Command buffers */
  457. extern char *atmbuf;
  458. extern char *line;            /* Character buffer for anything */
  459. extern char *tmpbuf;            /* Short temporary string buffer */
  460. extern int *ifcmd;
  461. extern int *intime;
  462. extern int *inpcas;
  463. #else
  464. extern char cmdbuf[];            /* Command buffers */
  465. extern char atmbuf[];
  466. extern char line[];            /* Character buffer for anything */
  467. extern char tmpbuf[];            /* Temporary buffer */
  468. extern int ifcmd[];
  469. extern int intime[];
  470. extern int inpcas[];
  471. #endif /* DCMDBUF */
  472.  
  473. #ifndef NOSPL
  474. extern char * prstring[];
  475. #endif /* NOSPL */
  476.  
  477. char *lp;                /* Pointer to line buffer */
  478.  
  479. #ifndef NOSPL
  480. int unkmacro = 0;            /* Flag for in ON_UNKNOWN_COMMAND */
  481. int oldeval = 0;
  482. char evalbuf[33];            /* EVALUATE result */
  483. extern char * inpbuf;            /* Buffer for INPUT and REINPUT */
  484. char *inpbp;                /* And pointer to same */
  485. extern char lblbuf[];            /* Buffer for labels */
  486. int m_found;                /* MINPUT result */
  487. int i_active = 0;            /* INPUT command is active */
  488. char *ms[MINPMAX];            /* Pointers to MINPUT strings */
  489. static int mp[MINPMAX];            /* and flags */
  490. extern int fndiags, fnerror, fnsuccess;    /* Function diagnostics */
  491. #ifndef NOSEXP
  492. char * lastsexp = NULL;            /* S-Expressions */
  493. char * sexpval = NULL;
  494. int sexpecho = SET_AUTO;
  495. #endif /* NOSEXP */
  496. #endif /* NOSPL */
  497.  
  498. char psave[PROMPTL] = { NUL };        /* For saving & restoring prompt */
  499.  
  500. extern int success;            /* Command success/failure flag */
  501. extern int cmdlvl;            /* Current position in command stack */
  502.  
  503. #ifndef NOSPL
  504. int                    /* SET INPUT parameters. */
  505. /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */
  506.   inbufsize = 0,            /* INPUT buffer size */
  507.   indef = 1,                /* default timeout, seconds */
  508.   inecho = 1,                /* 1 = echo on */
  509.   inautodl = 0,                /* INPUT autodownload */
  510.   inintr = 1,                /* INPUT interrupion allowed */
  511.   insilence = 0;            /* 0 = no silence constraint */
  512. #ifdef OS2
  513. int interm = 1;                /* Terminal emulator displays input */
  514. #endif /* OS2 */
  515. int maclvl = -1;            /* Macro nesting level */
  516. int mecho = 0;                /* Macro echo, 0 = don't */
  517. char varnam[6];                /* For variable names */
  518. extern int macargc[];            /* ARGC from macro invocation */
  519.  
  520. extern char *m_arg[MACLEVEL][NARGS];    /* Stack of macro arguments */
  521. extern char *mrval[];
  522.  
  523. extern char **a_ptr[];            /* Array pointers */
  524. extern int a_dim[];            /* Array dimensions */
  525. extern int a_link[];
  526.  
  527. #ifdef DCMDBUF
  528. extern struct cmdptr *cmdstk;        /* The command stack itself */
  529. #else
  530. extern struct cmdptr cmdstk[];        /* The command stack itself */
  531. #endif /* DCMDBUF */
  532.  
  533. long ck_alarm = 0;            /* SET ALARM value */
  534. char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  535. char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' };
  536.  
  537. #endif /* NOSPL */
  538.  
  539. static int x, y, z = 0;            /* Local workers */
  540. static char *s;
  541.  
  542. #define xsystem(s) zsyscmd(s)
  543.  
  544. /* Top-Level Interactive Command Keyword Table */
  545. /* Keywords must be in lowercase and in alphabetical order. */
  546.  
  547. struct keytab cmdtab[] = {
  548. #ifndef NOPUSH
  549.     { "!",       XXSHE, CM_INV|CM_PSH }, /* Shell escape */
  550. #else
  551.     { "!",       XXNOTAV, CM_INV|CM_PSH },
  552. #endif /* NOPUSH */
  553.     { "#",           XXCOM, CM_INV },    /* Comment */
  554. #ifndef NOSPL
  555.     { "(",           XXSEXP,CM_INV },    /* S-Expression */
  556.     { ".",           XXDEF, CM_INV },    /* Assignment */
  557.     { ":",           XXLBL, CM_INV },    /* Label */
  558. #endif /* NOSPL */
  559. #ifdef CK_REDIR
  560. #ifndef NOPUSH
  561.     { "<",           XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  562. #else
  563.     { "<",           XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */
  564. #endif /* NOPUSH */
  565. #endif /* CK_REDIR */
  566. #ifndef NOPUSH
  567.     { "@",           XXSHE, CM_INV|CM_PSH }, /* DCL escape */
  568. #else
  569.     { "@",           XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */
  570. #endif /* NOPUSH */
  571.  
  572. #ifdef CK_RECALL
  573.     { "^",           XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */
  574. #endif /* CK_RECALL */
  575. #ifndef NOSPL
  576.     { "_asg",        XXASX,   CM_INV },    /* Used internally by FOR, etc */
  577.     { "_assign",     XXASX,   CM_INV },    /* Used internally by FOR, etc */
  578.     { "_decrement",  XX_DECR, CM_INV },
  579.     { "_define",     XXDFX,   CM_INV },    /* Used internally by FOR, etc */
  580.     { "_evaluate",   XX_EVAL, CM_INV },
  581.     { "_forward",    XXXFWD,  CM_INV },    /* Used internally by SWITCH   */
  582.     { "_getargs",    XXGTA,   CM_INV },    /* Used internally by FOR, etc */
  583.     { "_increment",  XX_INCR, CM_INV },
  584.     { "_putargs",    XXPTA,   CM_INV },    /* Used internally by FOR, etc */
  585.     { "_undefine",   XXUNDFX, CM_INV },
  586. #endif /* NOSPL */
  587.  
  588.     { "about",       XXVER,   CM_INV },    /* Synonym for VERSION */
  589. #ifndef NOSPL
  590. #ifdef NEWFTP
  591.     { "account",     XXACCT,  CM_INV }, /* (FTP) Account */
  592. #endif /* NEWFTP */
  593. #ifdef ADDCMD
  594.     { "add",         XXADD, 0 },    /* ADD */
  595. #endif /* ADDCMD */
  596. #ifndef NODIAL
  597.     { "answer",      XXANSW, CM_LOC },    /* ANSWER the phone */
  598. #else
  599.     { "answer",      XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */
  600. #endif /* NODIAL */
  601.     { "apc",         XXAPC, 0 },    /* Application Program Command */
  602. #ifndef NOSPL
  603.     { "array",       XXARRAY, 0 },    /* Array operations */
  604. #endif /* NOSPL */
  605.     { "ascii",       XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  606.     { "asg",         XXASS, CM_INV },    /* Invisible synonym for ASSIGN */
  607.     { "ask",         XXASK, 0 },    /* ASK for text, assign to variable */
  608.     { "askq",        XXASKQ,0 },    /* ASK quietly (no echo) */
  609. #ifndef NOSPL
  610.     { "ass",         XXASS, CM_INV|CM_ABR }, /* ASSIGN */
  611.     { "assert",      XXASSER, CM_INV },    /* ASSERT */
  612.     { "assign",      XXASS, 0 },    /* ASSIGN */
  613. #endif /* NOSPL */
  614. #ifndef NOXFER
  615. #ifndef NOCSETS
  616.     { "associate",   XXASSOC, 0 },    /* ASSOCIATE */
  617. #else
  618.     { "associate",   XXNOTAV, CM_INV },    /* ASSOCIATE */
  619. #endif /* NOCSETS */
  620. #endif /* NOXFER */
  621. #ifdef CK_KERBEROS
  622. #ifdef CK_AUTHENTICATION
  623.     { "authenticate",XXAUTH, 0 },    /* Authentication */
  624. #else
  625.     { "authenticate",XXAUTH, CM_INV },
  626. #endif /* CK_AUTHENTICATION */
  627. #endif /* CK_KERBEROS */
  628. #endif /* NOSPL */
  629. #ifndef NOFRILLS
  630.     { "back",        XXBACK, 0 },    /* BACK to previous directory */
  631. #else
  632.     { "back",        XXNOTAV,CM_INV },
  633. #endif /* NOFRILLS */
  634.     { "beep",        XXBEEP,CM_INV },    /* BEEP */
  635. #ifndef NOXFER
  636.     { "binary",      XXBIN, CM_INV },    /* == SET FILE TYPE BINARY */
  637. #endif /* NOXFER */
  638. #ifndef NOFRILLS
  639.     { "bug",         XXBUG, CM_INV },    /* BUG report instructions */
  640. #else
  641.     { "bug",         XXNOTAV, CM_INV },
  642. #endif /* NOFRILLS */
  643. #ifdef BROWSER
  644.     { "browse",      XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */
  645. #else
  646.     { "browse",      XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  647. #endif /* BROWSER */
  648. #ifndef NOXFER
  649.     { "bye",         XXBYE, 0 },    /* BYE to remote server */
  650. #endif /* NOXFER */
  651. #ifndef NOLOCAL
  652.     { "c",           XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */
  653. #endif /* NOLOCAL */
  654. #ifndef NOFRILLS
  655.     { "cat",         XXCAT, CM_INV },    /* Invisible synonym for TYPE */
  656. #endif /* NOFRILLS */
  657. #ifndef NOSPL
  658.  
  659. #ifndef NOXFER
  660.     { "cautious",    XXCAU, CM_INV },
  661. #endif /* NOXFER */
  662.  
  663. #endif /* NOSPL */
  664.  
  665.     { "cd",          XXCWD, 0 },    /* Change Directory */
  666.     { "cdup",        XXCDUP, CM_INV },    /* Change Directory Up */
  667.  
  668. #ifndef NOXFER
  669. #ifdef PIPESEND
  670.     { "cget",        XXCGET, CM_INV|CM_PSH }, /* CGET */
  671. #else
  672.     { "cget",        XXNOTAV, CM_INV|CM_PSH }, /* CGET */
  673. #endif /* PIPESEND */
  674. #endif /* NOXFER */
  675.     { "ch",          XXCHK,   CM_INV|CM_ABR },
  676.     { "check",       XXCHK,   0 },    /* CHECK for a feature */
  677. #ifdef CK_PERMS
  678. #ifdef UNIX
  679.     { "chmod",       XXCHMOD, 0 },    /* CHMOD */
  680. #else
  681.     { "chmod",       XXNOTAV, CM_INV },
  682. #endif /* UNIX */
  683. #else
  684.     { "chmod",       XXNOTAV, CM_INV },
  685. #endif /* CK_PERMS */
  686. #ifdef CKROOT
  687.     { "chroot",      XXCHRT,  CM_INV },    /* CHROOT */
  688. #endif /* CKROOT */
  689.     { "ckermit",     XXKERMI, CM_INV },    /* CKERMIT (like KERMIT) */
  690.     { "cl",          XXCLO,   CM_ABR|CM_INV },
  691. #ifndef NOFRILLS
  692.     { "clear",       XXCLE, 0 },    /* CLEAR input and/or device buffer */
  693. #else
  694.     { "clear",       XXNOTAV, CM_INV },
  695. #endif /* NOFRILLS */
  696.     { "close",         XXCLO, 0 },    /* CLOSE a log or other file */
  697.     { "cls",         XXCLS, CM_INV },    /* Clear Screen (CLS) */
  698.     { "comment",     XXCOM, CM_INV },    /* Introduce a comment */
  699. #ifndef NOLOCAL
  700.     { "connect",     XXCON, CM_LOC },    /* Begin terminal connection */
  701. #else
  702.     { "connect",     XXNOTAV, CM_LOC },
  703. #endif /* NOLOCAL */
  704. #ifndef NOFRILLS
  705. #ifdef ZCOPY
  706.     { "co",          XXCPY, CM_INV|CM_ABR },
  707.     { "cop",         XXCPY, CM_INV|CM_ABR },
  708.     { "copy",        XXCPY, 0 },    /* COPY a file */
  709. #else
  710.     { "copy",        XXNOTAV, CM_INV },
  711. #endif /* ZCOPY */
  712.     { "copyright",   XXCPR, CM_INV },    /* COPYRIGHT */
  713. #ifdef ZCOPY
  714.     { "cp",          XXCPY, CM_INV },    /* COPY a file */
  715. #endif /* ZCOPY */
  716. #ifndef NOLOCAL
  717. #ifndef OS2
  718.     { "cq",          XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */
  719. #endif /* OS2 */
  720. #endif /* NOLOCAL */
  721. #ifndef NOXFER
  722. #ifdef PIPESEND
  723.     { "creceive",    XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */
  724.     { "csend",       XXCSEN,CM_INV|CM_PSH }, /* SEND from command */
  725. #else
  726.     { "creceive",    XXNOTAV,CM_INV|CM_PSH },
  727.     { "csend",       XXNOTAV,CM_INV|CM_PSH },
  728. #endif /* PIPESEND */
  729. #endif /* NOXFER */
  730. #endif /* NOFRILLS */
  731.  
  732.     { "cwd",         XXCWD,   CM_INV },    /* Traditional synonym for cd */
  733.  
  734. #ifndef NOSPL
  735.     { "date",        XXDATE,  0 },    /* DATE */
  736.     { "dcl",         XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  737.     { "debug",       XXDEBUG, CM_INV },
  738.     { "declare",     XXDCL,   CM_INV },    /* DECLARE an array (see ARRAY) */
  739.     { "decrement",   XXDEC,   0 },    /* DECREMENT a numeric variable */
  740.     { "define",      XXDEF,   0 },    /* DEFINE a macro or variable */
  741. #else
  742.     { "date",        XXNOTAV, CM_INV },
  743.     { "dcl",         XXNOTAV, CM_INV },
  744.     { "declare",     XXNOTAV, CM_INV },
  745.     { "decrement",   XXNOTAV, CM_INV },
  746.     { "define",      XXNOTAV, CM_INV },
  747. #endif /* NOSPL */
  748.  
  749. #ifndef NOFRILLS
  750.     { "delete",      XXDEL, 0 },    /* DELETE a file */
  751. #else
  752.     { "delete",      XXNOTAV, CM_INV },
  753. #endif /* NOFRILLS */
  754.  
  755. #ifndef NODIAL
  756.     { "dial",        XXDIAL,  CM_LOC },    /* DIAL a phone number */
  757. #else
  758.     { "dial",        XXNOTAV, CM_INV|CM_LOC },
  759. #endif /* NODIAL */
  760.  
  761.     { "directory",   XXDIR, 0 },    /* DIRECTORY of files */
  762.  
  763. #ifndef NOFRILLS
  764. #ifndef NOSERVER
  765.     { "disable",     XXDIS, 0 },    /* DISABLE a server function */
  766. #else
  767.     { "disable",     XXNOTAV, CM_INV },
  768. #endif /* NOSERVER */
  769. #endif /* NOFRILLS */
  770.  
  771. #ifndef NOSPL
  772.     { "do",          XXDO,  0 },    /* DO (execute) a macro */
  773. #else
  774.     { "do",          XXNOTAV, CM_INV },
  775. #endif /* NOSPL */
  776.  
  777.     { "e",           XXEXI, CM_INV|CM_ABR },
  778.  
  779. #ifndef NOFRILLS
  780. #ifndef NOXFER
  781.     { "e-packet",    XXERR, CM_INV },    /* Send an Error-Packet */
  782. #endif /* NOXFER */
  783. #endif /* NOFRILLS */
  784.  
  785.     { "echo",        XXECH, 0 },    /* ECHO text */
  786.  
  787. #ifndef NOFRILLS
  788. #ifndef NOPUSH
  789.     { "edit",        XXEDIT, CM_PSH },    /* EDIT */
  790. #else
  791.     { "edit",        XXNOTAV, CM_INV|CM_PSH }, /* EDIT */
  792. #endif /* NOPUSH */
  793. #endif /* NOFRILLS */
  794.  
  795.     { "eightbit",    XXEIGHT, CM_INV },    /* EIGHTBIT */
  796.  
  797. #ifndef NOSPL
  798.     { "else",        XXELS, CM_INV },    /* ELSE part of IF statement */
  799. #else
  800.     { "else",        XXNOTAV, CM_INV },    /* ELSE part of IF statement */
  801. #endif /* NOSPL */
  802.  
  803. #ifndef NOSERVER
  804. #ifndef NOFRILLS
  805.     { "enable",      XXENA,  0 },    /* ENABLE a server function */
  806. #else
  807.     { "enable",      XXNOTAV, CM_INV },
  808. #endif /* NOFRILLS */
  809. #endif /* NOSERVER */
  810.  
  811. #ifndef NOSPL
  812.     { "end",         XXEND,  0 },    /* END command file or macro */
  813. #else
  814.     { "end",         XXNOTAV, CM_INV },
  815. #endif /* NOSPL */
  816.  
  817.     { "erase",       XXDEL, CM_INV },    /* Synonym for DELETE */
  818.  
  819. #ifndef NOSPL
  820.     { "evaluate",    XXEVAL, 0 },    /* EVALUATE */
  821. #else
  822.     { "evaluate",    XXNOTAV, CM_INV },
  823. #endif /* NOSPL */
  824.  
  825.     { "ex",          XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */
  826.  
  827. #ifdef CKEXEC
  828.     { "exec",        XXEXEC, CM_INV|CM_LOC }, /* exec() */
  829. #else
  830.     { "exec",        XXNOTAV, CM_INV|CM_LOC },
  831. #endif /* CKEXEC */
  832.  
  833.     { "exit",       XXEXI, 0 },        /* EXIT from C-Kermit */
  834.     { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */
  835.  
  836. #ifdef OS2
  837.     { "extproc",     XXCOM, CM_INV },    /* Dummy command for OS/2 */
  838. #endif /* OS2 */
  839.  
  840. #ifndef NOXFER
  841.     { "f",           XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */
  842. #endif /* NOXFER */
  843.  
  844. #ifndef NOSPL
  845.     { "fail",        XXFAIL, CM_INV },    /* FAIL */
  846.  
  847. #ifndef NOXFER
  848.     { "fast",        XXFAST, CM_INV },
  849. #endif /* NOXFER */
  850.  
  851. #ifdef CKCHANNELIO
  852.     { "fclose",      XXF_CL, CM_INV },    /* FCLOSE */
  853.     { "fcount",      XXF_CO, CM_INV },    /* FCOUNT */
  854.     { "fflush",      XXF_FL, CM_INV },    /* FFLUSH */
  855. #endif /* CKCHANNELIO */
  856.  
  857. #ifndef NOXFER
  858.     { "fi",          XXFIN, CM_INV|CM_ABR }, /* FINISH */
  859. #endif /* NOXFER */
  860.  
  861. #ifdef CKCHANNELIO
  862.     { "file",        XXFILE, 0 },    /* FILE */
  863. #endif /* CKCHANNELIO */
  864. #endif /* NOSPL */
  865.  
  866. #ifndef NOXFER
  867.     { "fin",         XXFIN, CM_INV|CM_ABR }, /* FINISH */
  868. #endif /* NOXFER */
  869.  
  870. #ifndef UNIXOROSK
  871.     { "find",        XXGREP, 0 },    /* FIND (grep) */
  872. #else
  873.     { "find",        XXGREP,CM_INV },
  874. #endif /* UNIXOROSK */
  875.  
  876. #ifndef NOXFER
  877.     { "finish",      XXFIN, 0 },    /* FINISH */
  878. #endif /* NOXFER */
  879.  
  880. #ifdef TCPSOCKET
  881.     { "firewall",    XXFIREW, CM_INV|CM_HLP },
  882. #endif /* TCPSOCKET */
  883.  
  884. #ifdef CKCHANNELIO
  885.     { "flist",       XXF_LI, CM_INV },    /* FLIST */
  886.     { "fopen",       XXF_OP, CM_INV },    /* FOPEN */
  887. #endif /* CKCHANNELIO */
  888.  
  889. #ifndef NOSPL
  890.     { "fo",          XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */
  891.     { "for",         XXFOR, 0 },    /* FOR loop */
  892.     { "forward",     XXFWD, CM_INV },    /* FORWARD */
  893. #endif /* NOSPL */
  894. #ifndef NOFRILLS
  895.     { "fot",       XXDIR, CM_INV },    /* "fot" = "dir" (for Chris) */
  896. #endif /* NOFRILLS */
  897.  
  898. #ifdef CKCHANNELIO
  899.     { "fread",      XXF_RE, CM_INV },    /* FREAD */
  900.     { "frewind",    XXF_RW, CM_INV },    /* FREWIND */
  901.     { "fseek",      XXF_SE, CM_INV },    /* FSEEK */
  902.     { "fstatus",    XXF_ST, CM_INV },    /* FSTATUS */
  903. #endif /* CKCHANNELIO */
  904.  
  905. #ifdef TCPSOCKET
  906. #ifndef NOFTP
  907. #ifdef SYSFTP
  908. #ifndef NOPUSH
  909.     { "ftp",       XXFTP,   CM_INV|CM_PSH|CM_LOC }, /* System FTP */
  910. #else
  911.     { "ftp",       XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  912. #endif /* NOPUSH */
  913. #else  /* SYSFTP */
  914.     { "ftp",       XXFTP,   0 },    /* Built-in FTP */
  915. #endif /* SYSFTP */
  916. #endif /* NOFTP */
  917. #endif /* TCPSOCKET */
  918.  
  919. #ifndef NOSPL
  920.     { "function",    XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */
  921. #endif /* NOSPL */
  922.  
  923. #ifdef CKCHANNELIO
  924.     { "fwrite",      XXF_WR, CM_INV },    /* FWRITE */
  925. #endif /* CKCHANNELIO */
  926.  
  927. #ifndef NOXFER
  928.     { "g",           XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */
  929. #ifndef NOSPL
  930.     { "ge",          XXGET, CM_INV|CM_ABR }, /* Ditto */
  931. #endif /* NOSPL */
  932.     { "get",         XXGET, 0 },    /* GET */
  933. #endif /* NOXFER */
  934. #ifndef NOSPL
  935.     { "getc",        XXGETC, 0 },    /* GETC */
  936. #ifdef OS2
  937.     { "getkeycode",  XXGETK, 0 },    /* GETKEYCODE */
  938. #endif /* OS2 */
  939. #ifndef NOFRILLS
  940.     { "getok",       XXGOK, 0 },    /* GETOK (ask for Yes/No/OK) */
  941. #endif /* NOFRILLS */
  942. #endif /* NOSPL */
  943. #ifndef NOSPL
  944.     { "goto",        XXGOTO,0 },    /* GOTO label in take file or macro */
  945. #endif /* NOSPL */
  946. #ifdef UNIXOROSK
  947.     { "grep",        XXGREP,0 },    /* GREP (find) */
  948. #else
  949.     { "grep",        XXGREP,CM_INV },    /* GREP (find) */
  950. #endif /* UNIXOROSK */
  951.     { "h",           XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  952.     { "he",          XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  953. #ifndef NOFRILLS
  954.     { "head",        XXHEAD, 0 },
  955. #endif /* NOFRILLS */
  956. #ifndef NOLOCAL
  957.     { "hangup",      XXHAN, CM_LOC },    /* HANGUP the connection */
  958. #endif /* NOLOCAL */
  959.     { "HELP",        XXHLP, 0 },    /* Display HELP text */
  960. #ifndef NOHTTP
  961. #ifdef TCPSOCKET
  962.     { "http",        XXHTTP, 0 },    /* HTTP operations */
  963. #endif /* TCPSOCKET */
  964. #endif /* NOHTTP */
  965. #ifndef NOSPL
  966.     { "i",           XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  967.     { "if",          XXIF,  0 },         /* IF ( condition ) command */
  968. #ifdef TCPSOCKET
  969.     { "iksd",        XXIKSD, CM_INV },         /* Make connection to IKSD */
  970. #else
  971.     { "iksd",        XXNOTAV, CM_INV },
  972. #endif /* TCPSOCKET */
  973.     { "in",          XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  974.     { "increment",   XXINC, 0 },    /* Increment a numeric variable */
  975.     { "input",       XXINP, 0 },    /* INPUT text from comm device */
  976. #endif /* NOSPL */
  977.  
  978. #ifndef NOHELP
  979.     { "int",         XXINT, CM_INV|CM_ABR },
  980.     { "intr",        XXINT, CM_INV|CM_ABR },
  981.     { "INTRO",       XXINT, 0 },
  982.     { "introduction",XXINT, CM_INV },    /* Print introductory text */
  983. #else
  984.     { "intro",       XXNOTAV, CM_INV },
  985.     { "introduction",XXNOTAV, CM_INV },
  986. #endif /* NOHELP */
  987.  
  988. #ifdef OS2
  989.     { "k95",         XXKERMI, CM_INV },    /* Hmmm what's this... */
  990.     { "kermit",      XXKERMI, CM_INV },
  991. #else
  992.     { "kermit",      XXKERMI, CM_INV },
  993. #endif /* OS2 */
  994.  
  995. #ifdef OS2
  996. #ifndef NOKVERBS
  997.     { "kverb",       XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */
  998. #endif /* NOKVERBS */
  999. #endif /* OS2 */
  1000.  
  1001. #ifndef NOFRILLS
  1002.     { "l",           XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
  1003. #endif /* NOFRILLS */
  1004.  
  1005.     { "lcd",         XXLCWD, CM_INV },
  1006.     { "lcdup",       XXLCDU, CM_INV },
  1007.     { "lcwd",        XXLCWD, CM_INV },
  1008.     { "ldelete",     XXLDEL, CM_INV },
  1009.     { "ldirectory",  XXLDIR, CM_INV },
  1010.  
  1011. #ifdef CKLEARN
  1012.     { "learn",       XXLEARN, 0 },    /* LEARN - automatic script writing */
  1013. #else
  1014.     { "learn",       XXNOTAV, CM_INV },
  1015. #endif /* CKLEARN */
  1016.  
  1017.     { "li",          XXLNOUT, CM_INV|CM_ABR },
  1018.     { "LICENSE",     XXCPR, 0 },    /* LICENSE */
  1019.  
  1020. #ifndef NOSPL
  1021.     { "lineout",     XXLNOUT, 0 },    /* LINEOUT = OUTPUT + eol */
  1022. #endif /* NOSPL */
  1023.  
  1024. #ifdef NT
  1025.     { "link",        XXLINK, 0 },       /* LINK source destination */
  1026. #endif /* NT */
  1027.  
  1028.     { "lmkdir",      XXLMKD, CM_INV },
  1029.  
  1030. #ifndef NOFRILLS
  1031.     { "lo",          XXLOG,  CM_INV|CM_ABR }, /* Invisible synonym for log */
  1032. #endif /* NOFRILLS */
  1033.  
  1034. #ifndef NOSPL
  1035.     { "local",       XXLOCAL, CM_INV },    /* LOCAL variable declaration */
  1036. #else
  1037.     { "local",       XXNOTAV, CM_INV },
  1038. #endif /* NOSPL */
  1039.  
  1040.     { "log",           XXLOG, 0 },    /* Open a log file */
  1041.  
  1042.     { "login",       XXLOGIN,  0 },    /* (REMOTE) LOGIN to server or IKSD */
  1043.     { "logout",      XXLOGOUT, 0 },    /* LOGOUT from server or IKSD */
  1044.  
  1045. #ifndef NOFRILLS
  1046. #ifndef NODIAL
  1047.     { "lookup",      XXLOOK,  0 },    /* LOOKUP */
  1048. #else
  1049.     { "lookup",      XXNOTAV, CM_INV },
  1050. #endif /* NODIAL */
  1051.  
  1052.     { "lpwd",        XXLPWD, CM_INV },
  1053.     { "lrename",     XXLREN, CM_INV },
  1054.     { "lrmdir",      XXLRMD, CM_INV },
  1055.  
  1056. #ifdef UNIXOROSK
  1057.     { "ls",          XXLS,  CM_INV|CM_PSH }, /* UNIX ls command */
  1058. #else
  1059.     { "ls",          XXDIR, CM_INV },    /* Invisible synonym for DIR */
  1060. #endif /* UNIXOROSK */
  1061. #ifndef NOXFER
  1062.     { "mail",        XXMAI, 0 },    /* Send a file as e-mail */
  1063. #endif /* NOXFER */
  1064. #ifndef NOHELP
  1065.     { "manual",      XXMAN, CM_PSH },    /* MAN(UAL) */
  1066. #else
  1067.     { "manual",      XXNOTAV, CM_INV|CM_PSH },
  1068. #endif /* NOHELP */
  1069. #endif /* NOFRILLS */
  1070. #ifdef CK_MKDIR
  1071.     { "md",          XXMKDIR, CM_INV },    /* Synonym for MKDIR */
  1072. #endif /* CK_MKDIR */
  1073. #ifdef CK_MINPUT
  1074.     { "minput",      XXMINP, 0 },    /* MINPUT */
  1075. #else
  1076.     { "minput",      XXNOTAV, CM_INV },
  1077. #endif /* CK_MINPUT */
  1078. #ifndef NOMSEND
  1079.     { "mget",        XXMGET, 0 },    /* MGET */
  1080. #else
  1081.     { "mget",        XXNOTAV, CM_INV },
  1082. #endif /* NOMSEND */
  1083. #ifdef CK_MKDIR
  1084.     { "mkdir",       XXMKDIR, 0 },    /* MKDIR */
  1085. #else
  1086.     { "mkdir",       XXNOTAV, CM_INV },
  1087. #endif /* CK_MKDIR */
  1088.  
  1089. #ifndef NOXFER
  1090. #ifndef NOMSEND
  1091.     { "mmove",       XXMMOVE, 0 },    /* MMOVE */
  1092. #else
  1093.     { "mmove",       XXNOTAV, CM_INV },
  1094. #endif /* NOMSEND */
  1095. #endif /* NOXFER */
  1096.  
  1097. #ifndef NOFRILLS
  1098.     { "more",        XXMORE, CM_INV },    /* MORE */
  1099. #endif /* NOFRILLS */
  1100.  
  1101. #ifndef NOXFER
  1102.     { "move",        XXMOVE, 0 },    /* MOVE  */
  1103. #endif /* NOXFER */
  1104.  
  1105. #ifndef NOSPL
  1106.     { "mpause",      XXMSL, CM_INV },    /* Millisecond sleep */
  1107. #else
  1108.     { "mpause",      XXNOTAV, CM_INV },
  1109. #endif /* NOSPL */
  1110.  
  1111. #ifndef NOXFER
  1112. #ifndef NOMSEND
  1113.     { "mput",        XXMSE, CM_INV },    /* MPUT = MSEND */
  1114.     { "ms",          XXMSE, CM_INV|CM_ABR },
  1115.     { "msend",       XXMSE, 0 },    /* Multiple SEND */
  1116. #else
  1117.     { "mput",        XXNOTAV, CM_INV },
  1118.     { "msend",       XXNOTAV, CM_INV },
  1119. #endif /* NOMSEND */
  1120. #endif /* NOXFER */
  1121. #ifndef NOSPL
  1122.     { "msleep",      XXMSL, 0 },    /* Millisecond sleep */
  1123. #else
  1124.     { "msleep",      XXNOTAV, CM_INV },
  1125. #endif /* NOSPL */
  1126. #ifndef NOFRILLS
  1127.     { "mv",          XXREN, CM_INV },    /* Synonym for rename */
  1128. #endif /* NOFRILLS */
  1129. #ifndef NOHELP
  1130.     { "news",        XXNEW, CM_INV },    /* Display NEWS of new features */
  1131. #else
  1132.     { "news",        XXNOTAV, CM_INV },
  1133. #endif /* NOHELP */
  1134.     { "nolocal",     XXNLCL, CM_INV },    /* Disable SET LINE / SET HOST */
  1135.     { "nopush",      XXNPSH, CM_INV },    /* Disable PUSH command/features */
  1136. #ifndef NOSPL
  1137.     { "o",           XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */
  1138.     { "open",        XXOPE, 0 },    /* OPEN file for reading or writing */
  1139. #else
  1140.     { "open",        XXNPSH, CM_INV },    /* Disable PUSH command/features */
  1141. #endif /* NOSPL */
  1142. #ifndef NOHELP
  1143.     { "options",     XXOPTS,CM_INV|CM_HLP }, /* Options */
  1144. #endif /* NOHELP */
  1145. #ifndef NOSPL
  1146.     { "output",      XXOUT, 0 },    /* OUTPUT text to comm device */
  1147. #else
  1148.     { "output",      XXNOTAV, CM_INV },
  1149. #endif /* NOSPL */
  1150. #ifdef ANYX25
  1151. #ifndef IBMX25
  1152.     { "pad",         XXPAD, CM_LOC },    /* X.3 PAD commands */
  1153. #endif /* IBMX25 */
  1154. #endif /* ANYX25 */
  1155.  
  1156. #ifndef NOHELP
  1157.     { "patterns",    XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */
  1158. #endif /* NOHELP */
  1159.  
  1160. #ifndef NOSPL
  1161.     { "pause",       XXPAU, 0 },    /* Sleep for specified interval */
  1162. #else
  1163.     { "pause",       XXNOTAV, CM_INV },
  1164. #endif /* NOSPL */
  1165. #ifndef NODIAL
  1166.     { "pdial",       XXPDIA,  CM_LOC },    /* PDIAL (partial dial) */
  1167. #else
  1168.     { "pdial",       XXNOTAV, CM_INV|CM_LOC },
  1169. #endif /* NODIAL */
  1170. #ifdef TCPSOCKET
  1171. #ifndef NOPUSH
  1172.     { "ping",        XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */
  1173. #else
  1174.     { "ping",        XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  1175. #endif /* NOPUSH */
  1176. #endif /* TCPSOCKET */
  1177. #ifdef NETCMD
  1178. #ifndef NOPUSH
  1179.     { "pipe",        XXPIPE, CM_PSH },    /* PIPE */
  1180. #else
  1181.     { "pipe",        XXNOTAV, CM_INV|CM_PSH }, /* PIPE */
  1182. #endif /* NOPUSH */
  1183. #endif /* NETCMD */
  1184.  
  1185. #ifndef NOSPL
  1186.     { "pop",         XXEND, CM_INV },    /* Invisible synonym for END */
  1187. #endif /* NOSPL */
  1188. #ifndef NOFRILLS
  1189.     { "print",       XXPRI, 0 },    /* PRINT a file locally */
  1190. #endif /* NOFRILLS */
  1191.  
  1192.     { "prompt",      XXPROMP, CM_INV },    /* Go interactive (from script) */
  1193.  
  1194. #ifndef NOXFER
  1195. #ifdef CK_RESEND
  1196.     { "psend",       XXPSEN, CM_INV },    /* PSEND */
  1197. #else
  1198.     { "psend",       XXNOTAV, CM_INV },
  1199. #endif /* CK_RESEND */
  1200. #endif /* NOXFER */
  1201.  
  1202. #ifdef NETPTY
  1203.     { "pty",         XXPTY, CM_PSH },    /* PTY */
  1204. #else
  1205.     { "pty",         XXNOTAV, CM_INV|CM_PSH },
  1206. #endif /* NETPTY */
  1207.  
  1208. #ifndef NOPUSH
  1209.     { "pu",          XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */
  1210. #endif /* NOPUSH */
  1211.  
  1212. #ifdef CKPURGE
  1213.     { "purge",       XXPURGE, 0 },    /* PURGE (real) */
  1214. #else
  1215. #ifdef VMS
  1216.     { "purge",       XXPURGE, 0 },    /* PURGE (fake) */
  1217. #else
  1218.     { "purge",       XXNOTAV, CM_INV },
  1219. #endif /* VMS */
  1220. #endif /* CKPURGE */
  1221.  
  1222. #ifndef NOPUSH
  1223.     { "push",        XXSHE, CM_PSH },    /* PUSH command (like RUN, !) */
  1224. #else
  1225.     { "push",        XXNOTAV, CM_INV|CM_PSH },
  1226. #endif /* NOPUSH */
  1227.  
  1228. #ifndef NOXFER
  1229.     { "put",         XXSEN, CM_INV },    /* PUT = SEND */
  1230. #endif /* NOXFER */
  1231.  
  1232.     { "pwd",         XXPWD, 0 },    /* Print Working Directory */
  1233.     { "q",           XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */
  1234.  
  1235. #ifndef NOXFER
  1236.     { "query",       XXRQUE,CM_INV },    /* (= REMOTE QUERY) */
  1237. #endif /* NOXFER */
  1238.  
  1239.     { "quit",        XXQUI, 0 },    /* QUIT from program = EXIT */
  1240.  
  1241. #ifndef NOXFER
  1242.     { "r",           XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */
  1243. #endif /* NOXFER */
  1244.  
  1245. #ifndef NOXFER
  1246.     { "rasg",        XXRASG, CM_INV },    /* REMOTE ASSIGN */
  1247.     { "rassign",     XXRASG, CM_INV },    /* ditto */
  1248.     { "rcd",         XXRCWD, CM_INV },    /* REMOTE CD */
  1249.     { "rcdup",       XXRCDUP,CM_INV },    /* REMOTE CD */
  1250.     { "rcopy",       XXRCPY, CM_INV },    /* REMOTE COPY */
  1251.     { "rcwd",        XXRCWD, CM_INV },    /* REMOTE CWD */
  1252.     { "rdelete",     XXRDEL, CM_INV },    /* REMOTE DELETE */
  1253.     { "rdirectory",  XXRDIR, CM_INV },    /* REMODE DIRECTORY */
  1254. #endif /* NOXFER */
  1255.  
  1256. #ifndef NOSPL
  1257.     { "read",        XXREA, 0 },    /* READ a line from a file */
  1258. #else
  1259.     { "read",        XXNOTAV, CM_INV },
  1260. #endif /* NOSPL */
  1261.  
  1262. #ifndef NOXFER
  1263.     { "receive",     XXREC, 0 },    /* RECEIVE files */
  1264. #endif /* NOXFER */
  1265.  
  1266. #ifndef NODIAL
  1267.     { "red",         XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */
  1268.     { "redi",        XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */
  1269.     { "redial",      XXRED, CM_LOC },    /* REDIAL last DIAL number */
  1270. #else
  1271.     { "red",         XXNOTAV, CM_INV|CM_LOC },
  1272.     { "redi",        XXNOTAV, CM_INV|CM_LOC },
  1273.     { "redial",      XXNOTAV, CM_INV|CM_LOC },
  1274. #endif /* NODIAL */
  1275.  
  1276. #ifdef CK_REDIR
  1277. #ifdef OS2
  1278. #ifndef NOPUSH
  1279.     { "redirect",    XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  1280. #else
  1281.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1282. #endif /* NOPUSH */
  1283. #else /* OS2 */
  1284. #ifndef NOPUSH
  1285.     { "redirect",    XXFUN, CM_PSH },    /* REDIRECT */
  1286. #else
  1287.     { "redirect",    XXNOTAV, CM_INV|CM_PSH },
  1288. #endif /* NOPUSH */
  1289. #endif /* OS2 */
  1290. #endif /* CK_REDIR */
  1291.  
  1292. #ifdef CK_RECALL
  1293.     { "redo",        XXREDO,  CM_NOR },    /* REDO */
  1294. #else
  1295.     { "redo",        XXNOTAV, CM_INV },
  1296. #endif /* CK_RECALL */
  1297.  
  1298. #ifndef NOXFER
  1299. #ifdef CK_RESEND
  1300.     { "reget",       XXREGET, 0 },    /* REGET */
  1301. #else
  1302.     { "reget",       XXNOTAV, CM_INV },
  1303. #endif /* CK_RESEND */
  1304. #endif /* NOXFER */
  1305.  
  1306. #ifndef NOSPL
  1307.     { "reinput",     XXREI, CM_INV },    /* REINPUT (from INPUT buffer) */
  1308. #else
  1309.     { "reinput",     XXNOTAV, CM_INV },
  1310. #endif /* NOSPL */
  1311.  
  1312. #ifndef NOXFER
  1313. #ifdef ADDCMD
  1314.     { "rem",         XXREM, CM_INV|CM_ABR },
  1315.     { "remo",        XXREM, CM_INV|CM_ABR },
  1316. #endif /* ADDCMD */
  1317.     { "remote",         XXREM, 0 },    /* Send REMOTE command to server */
  1318. #endif /* NOXFER */
  1319.  
  1320. #ifdef ADDCMD
  1321.     { "remove",      XXREMV,0 },    /* REMOVE (something from a list) */
  1322. #else
  1323.     { "remove",      XXNOTAV, CM_INV },
  1324. #endif /* ADDCMD */
  1325.  
  1326. #ifndef NOFRILLS
  1327. #ifndef NORENAME
  1328.     { "rename",      XXREN, 0 },    /* RENAME a local file */
  1329. #else
  1330.     { "rename",      XXNOTAV, CM_INV },
  1331. #endif /* NORENAME */
  1332.     { "replay",      XXTYP, CM_INV },    /* REPLAY (for now, just type) */
  1333. #endif /* NOFRILLS */
  1334.  
  1335. #ifndef NOXFER
  1336. #ifdef CK_RESEND
  1337.     { "res",         XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1338.     { "rese",        XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1339.     { "resend",      XXRSEN, 0 },    /* RESEND */
  1340. #else
  1341.     { "res",         XXNOTAV, CM_INV },
  1342.     { "rese",        XXNOTAV, CM_INV },
  1343.     { "resend",      XXNOTAV, CM_INV },
  1344. #endif /* CK_RESEND */
  1345. #endif /* NOXFER */
  1346.  
  1347.     { "reset",       XXRESET, CM_INV },    /* RESET */
  1348.  
  1349. #ifdef CK_RESEND
  1350. #ifndef NOSPL
  1351.     { "ret",         XXRET, CM_INV|CM_ABR },
  1352. #endif /* NOSPL */
  1353. #endif /* CK_RESEND */
  1354.  
  1355. #ifndef NOXFER
  1356.     { "retrieve",    XXRETR, CM_INV },    /* RETRIEVE */
  1357. #endif /* NOXFER */
  1358.  
  1359. #ifndef NOSPL
  1360.     { "return",      XXRET, 0 },    /* RETURN from a function */
  1361. #else
  1362.     { "return",      XXNOTAV, CM_INV },
  1363. #endif /* NOSPL */
  1364.  
  1365. #ifndef NOXFER
  1366.     { "rexit",       XXRXIT, CM_INV },    /* REMOTE EXIT */
  1367. #endif /* NOXFER */
  1368.  
  1369. #ifdef CK_REXX
  1370. #ifndef NOPUSH
  1371.     { "rexx",        XXREXX, CM_PSH },    /* Execute a Rexx command */
  1372. #else
  1373.     { "rexx",        XXNOTAV, CM_INV|CM_PSH },
  1374. #endif /* NOPUSH */
  1375. #endif /* CK_REXX */
  1376.  
  1377. #ifndef NOXFER
  1378.     { "rhelp",       XXRHLP, CM_INV },    /* REMOTE HELP */
  1379.     { "rhost",       XXRHOS, CM_INV },    /* REMOTE HOST */
  1380.     { "rkermit",     XXRKER, CM_INV },    /* REMOTE KERMIT */
  1381. #endif /* NOXFER */
  1382.  
  1383. #ifdef TCPSOCKET
  1384.     { "rlogin",      XXRLOG, CM_LOC },    /* Make an Rlogin connection */
  1385. #else
  1386.     { "rlogin",      XXNOTAV, CM_INV|CM_LOC },
  1387. #endif /* TCPSOCKET */
  1388.  
  1389. #ifndef NOFRILLS
  1390.     { "rm",          XXDEL, CM_INV },    /* Invisible synonym for delete */
  1391. #endif /* NOFRILLS */
  1392.  
  1393. #ifdef CK_MKDIR
  1394.     { "rmdir",       XXRMDIR, 0 },    /* RMDIR */
  1395. #else
  1396.     { "rmdir",       XXNOTAV, CM_INV },
  1397. #endif /* CK_MKDIR */
  1398.  
  1399. #ifndef NOXFER
  1400.     { "rmkdir",      XXRMKD, CM_INV },    /* REMOTE MKDIR */
  1401. #ifndef NOSPL
  1402.     { "robust",      XXROB,  CM_INV },
  1403. #else
  1404.     { "robust",      XXNOTAV, CM_INV },
  1405. #endif /* NOSPL */
  1406.     { "rprint",      XXRPRI, CM_INV },  /* REMOTE PRINT */
  1407.     { "rpwd",        XXRPWD, CM_INV },    /* REMOTE PWD */
  1408.     { "rquery",      XXRQUE, CM_INV },    /* REMOTE QUERY */
  1409. #endif /* NOXFER */
  1410.  
  1411. #ifdef CK_RECALL
  1412.     { "rr",          XXREDO, CM_INV|CM_NOR },
  1413. #endif /* CK_RECALL */
  1414.  
  1415. #ifndef NOXFER
  1416.     { "rrename",    XXRREN, CM_INV },    /* REMOTE RENAME */
  1417.     { "rrmdir",     XXRRMD, CM_INV },    /* REMOTE REMDIR */
  1418.     { "rset",       XXRSET, CM_INV },    /* REMOTE SET */
  1419.     { "rspace",     XXRSPA, CM_INV },    /* REMOTE SPACE */
  1420.     { "rtype",      XXRTYP, CM_INV },    /* REMOTE TYPE */
  1421. #endif /* NOXFER */
  1422.  
  1423. #ifndef NOPUSH
  1424.     { "run",         XXSHE, CM_PSH },    /* RUN a program or command */
  1425. #else
  1426.     { "run",         XXNOTAV, CM_INV|CM_PSH },
  1427. #endif /* NOPUSH */
  1428.  
  1429. #ifndef NOXFER
  1430.     { "rwho",        XXRWHO, CM_INV },    /* REMOTE WHO */
  1431.     { "s",           XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */
  1432. #endif /* NOXFER */
  1433.  
  1434. #ifndef NOSETKEY
  1435. #ifdef OS2
  1436.     { "save",       XXSAVE, 0 },        /* SAVE something */
  1437. #else
  1438.     { "save",       XXSAVE, CM_INV },
  1439. #endif /* OS2 */
  1440. #else
  1441.     { "save",       XXNOTAV, CM_INV },
  1442. #endif /* NOSETKEY */
  1443.  
  1444. #ifndef NOSCRIPT
  1445.     { "sc",        XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1446.     { "scr",       XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1447. #endif /* NOSCRIPT */
  1448.     { "screen",      XXSCRN, 0 },    /* SCREEN actions */
  1449. #ifndef NOSCRIPT
  1450.     { "script",       XXLOGI, CM_LOC },    /* Expect-Send-style script line */
  1451. #else
  1452.     { "script",       XXNOTAV, CM_INV|CM_LOC },
  1453. #endif /* NOSCRIPT */
  1454.  
  1455.     { "search",    XXGREP,CM_INV },    /* Synonym for GREP and FIND */
  1456.  
  1457. #ifndef NOXFER
  1458.     { "send",       XXSEN, 0 },        /* Send (a) file(s) */
  1459. #ifndef NOSERVER
  1460.     { "server",       XXSER, 0 },        /* Be a SERVER */
  1461. #else
  1462.     { "server",       XXNOTAV, CM_INV },
  1463. #endif /* NOSERVER */
  1464. #endif /* NOXFER */
  1465.  
  1466.     { "set",       XXSET, 0 },        /* SET parameters */
  1467.  
  1468. #ifndef NOSPL
  1469. #ifndef NOSEXP
  1470.     { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */
  1471. #endif /* NOSEXP */
  1472. #ifndef NOSHOW
  1473.     { "sh",          XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */
  1474. #endif /* NOSHOW */
  1475.     { "shift",       XXSHIFT, 0 },    /* SHIFT args */
  1476. #else
  1477.     { "shift",       XXNOTAV, CM_INV },
  1478. #endif /* NOSPL */
  1479.  
  1480. #ifndef NOSHOW
  1481.     { "show",        XXSHO, 0 },        /* SHOW parameters */
  1482. #else
  1483.     { "show",        XXNOTAV, CM_INV },
  1484. #endif /* NOSHOW */
  1485.  
  1486. #ifndef NOSPL
  1487. #ifndef NOFRILLS
  1488.     { "sleep",       XXPAU, CM_INV },    /* SLEEP for specified interval */
  1489. #endif /* NOFRILLS */
  1490.     { "sort",        XXSORT, CM_INV },    /* (see ARRAY) */
  1491. #else
  1492.     { "sort",        XXNOTAV, CM_INV },
  1493. #endif /* NOSPL */
  1494.  
  1495. #ifndef MAC
  1496. #ifndef NOFRILLS
  1497.     { "sp",          XXSPA, CM_INV|CM_ABR },
  1498.     { "spa",         XXSPA, CM_INV|CM_ABR },
  1499. #endif /* NOFRILLS */
  1500.     { "space",       XXSPA, 0 },    /* Show available disk SPACE */
  1501. #endif /* MAC */
  1502.  
  1503. #ifndef NOFRILLS
  1504. #ifndef NOPUSH
  1505.     { "spawn",       XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1506. #else
  1507.     { "spawn",       XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1508. #endif /* NOPUSH */
  1509. #endif /* NOFRILLS */
  1510.  
  1511. #ifdef ANYSSH
  1512.     { "ssh",         XXSSH, 0 },
  1513. #endif /* ANYSSH */
  1514.  
  1515. #ifndef NOXFER
  1516.     { "sta",         XXSTA, CM_INV|CM_ABR },
  1517.     { "stat",        XXSTA, CM_INV|CM_ABR },
  1518.     { "statistics",  XXSTA, 0 },    /* Display file transfer stats */
  1519. #endif /* NOXFER */
  1520.  
  1521.     { "status",      XXSTATUS,0 },    /* Show status of previous command */
  1522.  
  1523. #ifndef NOSPL
  1524.     { "stop",        XXSTO,   0 },    /* STOP all take files and macros */
  1525.     { "succeed",     XXSUCC,  CM_INV },    /* SUCCEED */
  1526. #else
  1527.     { "stop",        XXNOTAV, CM_INV },
  1528.     { "succeed",     XXNOTAV, CM_INV },
  1529. #endif /* NOSPL */
  1530.  
  1531. #ifndef NOFRILLS
  1532.     { "SUPPORT",     XXBUG, 0 },    /* Tech support instructions */
  1533. #else
  1534.     { "support",     XXNOTAV, CM_INV },
  1535. #endif /* NOFRILLS */
  1536.  
  1537. #ifndef NOJC
  1538.     { "suspend",     XXSUS, CM_PSH },    /* SUSPEND C-Kermit (UNIX only) */
  1539. #else
  1540.     { "suspend",     XXNOTAV, CM_INV|CM_PSH },
  1541. #endif /* NOJC */
  1542.  
  1543. #ifndef NOSPL
  1544.     { "switch",      XXSWIT, 0 },    /* SWITCH */
  1545. #else
  1546.     { "switch",      XXNOTAV, CM_INV },
  1547. #endif /* NOSPL */
  1548.  
  1549. #ifdef CK_TAPI
  1550.     { "ta",       XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */
  1551. #endif /* CK_TAPI */
  1552.  
  1553. #ifndef NOFRILLS
  1554.     { "tail",        XXTAIL, 0 },    /* Display end of a local file */
  1555. #endif /* NOFRILLS */
  1556.  
  1557.     { "take",       XXTAK, 0 },        /* TAKE commands from a file */
  1558.  
  1559. #ifdef CK_TAPI
  1560.     { "tapi",       XXTAPI, CM_LOC },    /* Microsoft TAPI commands */
  1561. #else
  1562.     { "tapi",       XXNOTAV, CM_INV|CM_LOC },
  1563. #endif /* CK_TAPI */
  1564.  
  1565. #ifndef NOFRILLS
  1566. #ifdef TCPSOCKET
  1567.     { "tel",         XXTEL, CM_INV|CM_ABR|CM_LOC },
  1568.     { "telnet",      XXTEL, CM_LOC },    /* TELNET (TCP/IP only) */
  1569.     { "telopt",      XXTELOP, CM_INV },    /* TELOPT (ditto) */
  1570. #else
  1571.     { "tel",         XXNOTAV, CM_INV|CM_LOC },
  1572.     { "telnet",      XXNOTAV, CM_INV|CM_LOC },
  1573.     { "telopt",      XXNOTAV, CM_INV },
  1574. #endif /* TCPSOCKET */
  1575. #ifdef OS2
  1576.     { "terminal",    XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */
  1577. #else
  1578.     { "terminal",    XXTERM, CM_INV },
  1579. #endif /* OS2 */
  1580. #endif /* NOFRILLS */
  1581. #ifndef NOXFER
  1582.     { "text",        XXASC, CM_INV },    /* == SET FILE TYPE TEXT */
  1583. #endif /* NOXFER */
  1584.  
  1585. #ifndef NOSPL
  1586.     { "trace",       XXTRACE, 0 },    /* TRACE */
  1587. #else
  1588.     { "trace",       XXNOTAV, CM_INV },
  1589. #endif /* NOSPL */
  1590.  
  1591. #ifndef NOCSETS
  1592.     { "translate",   XXXLA, 0 },    /* TRANSLATE local file char sets */
  1593. #else
  1594.     { "translate",   XXNOTAV, CM_INV },
  1595. #endif /* NOCSETS */
  1596.  
  1597. #ifndef NOXMIT
  1598.     { "transmit",    XXTRA, 0 },    /* Send (upload) a file, no protocol */
  1599. #else
  1600.     { "transmit",    XXNOTAV, CM_INV },
  1601. #endif /* NOXMIT */
  1602.  
  1603. #ifndef NOFRILLS
  1604.     { "type",        XXTYP, 0 },    /* Display a local file */
  1605. #endif /* NOFRILLS */
  1606.  
  1607. #ifndef NOSPL
  1608.     { "undcl",       XXUNDCL, CM_INV },
  1609.     { "undeclare",   XXUNDCL, 0 },    /* UNDECLARE an array */
  1610.     { "undefine",    XXUNDEF, 0 },    /* UNDEFINE a variable or macro */
  1611. #else
  1612.     { "undcl",       XXNOTAV, CM_INV },
  1613.     { "undeclare",   XXNOTAV, CM_INV },
  1614.     { "undefine",    XXNOTAV, CM_INV },
  1615. #endif /* NOSPL */
  1616.  
  1617. #ifdef NEWFTP
  1618.     { "user",        XXUSER,  CM_INV }, /* (FTP) USER */
  1619. #endif /* NEWFTP */
  1620.  
  1621.     { "version",     XXVER, 0 },    /* VERSION-number display */
  1622.  
  1623. #ifdef OS2
  1624.     { "viewonly",    XXVIEW, CM_LOC },    /* VIEWONLY Terminal Mode */
  1625. #endif /* OS2 */
  1626.  
  1627.     { "void",        XXVOID, 0 },    /* VOID */
  1628.  
  1629. #ifndef NOSPL
  1630.     { "wait",        XXWAI, 0 },    /* WAIT */
  1631. #else
  1632.     { "wait",        XXNOTAV, CM_INV },
  1633. #endif /* NOSPL */
  1634.  
  1635.     { "wermit",      XXKERMI, CM_INV },
  1636.  
  1637. #ifndef NOXFER
  1638.     { "where",       XXWHERE, 0 },    /* WHERE (did my file go?) */
  1639. #endif /* NOXFER */
  1640.  
  1641. #ifndef NOSPL
  1642.     { "while",       XXWHI, 0 },    /* WHILE loop */
  1643. #else
  1644.     { "while",       XXNOTAV, CM_INV },
  1645. #endif /* NOSPL */
  1646.  
  1647. #ifndef OS2
  1648. #ifndef MAC
  1649. #ifndef NOFRILLS
  1650.     { "who",         XXWHO, CM_PSH },    /* WHO's logged in? */
  1651. #endif /* NOFRILLS */
  1652. #endif /* MAC */
  1653. #endif /* OS2 */
  1654.  
  1655. #ifndef NOHELP
  1656.     { "wildcards",   XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */
  1657. #endif /* NOHELP */
  1658.  
  1659. #ifndef NOSPL
  1660.     { "wr",          XXWRI, CM_INV|CM_ABR },
  1661.     { "wri",         XXWRI, CM_INV|CM_ABR },
  1662.     { "writ",        XXWRI, CM_INV|CM_ABR },
  1663.     { "write",       XXWRI, 0 },    /* WRITE characters to a file */
  1664.     { "write-line",  XXWRL, CM_INV },    /* WRITE a line to a file */
  1665.     { "writeln",     XXWRL, CM_INV },    /* Pascalisch synonym for write-line */
  1666. #else
  1667.     { "wr",          XXNOTAV, CM_INV },
  1668.     { "wri",         XXNOTAV, CM_INV },
  1669.     { "writ",        XXNOTAV, CM_INV },
  1670.     { "write",       XXNOTAV, CM_INV },
  1671.     { "write-line",  XXNOTAV, CM_INV },
  1672.     { "writeln",     XXNOTAV, CM_INV },
  1673. #endif /* NOSPL */
  1674.  
  1675. #ifndef NOFRILLS
  1676.     { "xecho",       XXXECH,0 },    /* XECHO */
  1677. #endif /* NOFRILLS */
  1678.  
  1679. #ifndef NOSPL
  1680.     { "xif",         XXIFX, CM_INV },    /* Extended IF command (obsolete) */
  1681. #else
  1682.     { "xif",         XXNOTAV, CM_INV },
  1683. #endif /* NOSPL */
  1684.  
  1685. #ifndef NOCSETS
  1686.     { "xlate",       XXXLA, CM_INV },    /* Synonym for TRANSLATE */
  1687. #else
  1688.     { "xlate",       XXNOTAV, CM_INV },
  1689. #endif /* NOCSETS */
  1690.  
  1691. #ifndef NOXMIT
  1692.     { "xmit",        XXTRA, CM_INV },    /* Synonym for TRANSMIT */
  1693. #else
  1694.     { "xmit",        XXNOTAV, CM_INV },
  1695. #endif /* NOXMIT */
  1696.  
  1697. #ifndef OS2
  1698. #ifndef NOJC
  1699.     { "z",           XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */
  1700. #else
  1701.     { "z",           XXNOTAV, CM_INV|CM_PSH },
  1702. #endif /* NOJC */
  1703. #endif /* OS2 */
  1704.  
  1705.     { "", 0, 0 }
  1706. };
  1707. int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1;
  1708.  
  1709. /* NOTE: Tokens must also be entered above into cmdtab[]. */
  1710.  
  1711. char toktab[] = {
  1712. #ifndef NOPUSH
  1713.     '!',                /* Shell escape */
  1714. #endif /* NOPUSH */
  1715.     '#',                /* Comment */
  1716. #ifndef NOSPL
  1717.     '(',                /* S-Expression */
  1718.     '.',                /* Assignment */
  1719. #endif /* NOSPL */
  1720.     ';',                /* Comment */
  1721. #ifndef NOSPL
  1722.     ':',                /* Label */
  1723. #endif /* NOSPL */
  1724. #ifndef NOPUSH
  1725. #ifdef CK_REDIR
  1726.     '<',                /* REDIRECT */
  1727. #endif /* CK_REDIR */
  1728.     '@',                /* DCL escape */
  1729. #endif /* NOPUSH */
  1730. #ifdef CK_RECALL
  1731.     '^',                /* Command recall */
  1732. #endif /* CK_RECALL */
  1733. #ifndef NOSPL
  1734.     '{',                /* Immediate macro */
  1735. #endif /* NOSPL */
  1736.     '\0'                /* End of this string */
  1737. };
  1738. int xxdot = 0;                /* Used with "." token */
  1739.  
  1740. struct keytab yesno[] = {        /* Yes/No keyword table */
  1741.     { "no",    0, 0 },
  1742.     { "ok",    1, 0 },
  1743.     { "yes",   1, 0 }
  1744. };
  1745. int nyesno = (sizeof(yesno) / sizeof(struct keytab));
  1746.  
  1747. /* Save keyword table */
  1748.  
  1749. struct keytab savtab[] = {
  1750. #ifdef OS2
  1751.     { "command",  XSCMD, 0 },
  1752. #else
  1753. #ifdef CK_RECALL
  1754.     { "command",  XSCMD, 0 },
  1755. #endif /* CK_RECALL */
  1756. #endif /* OS2 */
  1757. #ifndef NOSETKEY
  1758.     { "keymap",   XSKEY, 0 },
  1759. #endif /* NOSETKEY */
  1760. #ifdef OS2
  1761.     { "terminal", XSTERM, 0 },
  1762. #endif /* OS2 */
  1763.     { "", 0, 0 }
  1764. };
  1765. int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1;
  1766.  
  1767. /* Parameter keyword table */
  1768.  
  1769. struct keytab prmtab[] = {
  1770.     { "alarm",            XYALRM,  0 },
  1771. #ifdef COMMENT                /* SET ANSWER not implemented yet */
  1772. #ifndef NODIAL
  1773.     { "answer",           XYANSWER,0 },
  1774. #endif /* NODIAL */
  1775. #endif /* COMMENT */
  1776.     { "ask-timer",        XYTIMER, 0 },
  1777. #ifndef NOXFER
  1778.     { "attributes",       XYATTR,  0 },
  1779. #endif /* NOXFER */
  1780. #ifdef CK_AUTHENTICATION
  1781.     { "authentication",   XYAUTH,  0 },
  1782. #else  /* CK_AUTHENTICATION */
  1783. #ifdef CK_SSL
  1784.     { "authentication",   XYAUTH,  0 },
  1785. #endif /* CK_SSL */
  1786. #endif /* CK_AUTHENTICATION */
  1787.     { "b",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1788.     { "ba",          XYBACK,  CM_INV|CM_ABR|CM_PSH },
  1789. #ifdef VMS
  1790.     { "background",       XYBACK,  CM_INV|CM_PSH },
  1791.     { "batch",            XYBACK,  CM_PSH },
  1792. #else
  1793.     { "background",       XYBACK,  CM_PSH },
  1794.     { "batch",            XYBACK,  CM_INV|CM_PSH },
  1795. #endif /* VMS */
  1796. #ifndef NOLOCAL
  1797.     { "baud",              XYSPEE,  CM_INV|CM_LOC },
  1798. #endif /* NOLOCAL */
  1799.     { "bell",             XYBELL,  0 },
  1800. #ifndef NOXFER
  1801.     { "block-check",        XYCHKT,  0 },
  1802. #endif /* NOXFER */
  1803. #ifdef OS2
  1804. #ifdef BPRINT
  1805.     { "bprinter",         XYBDCP,  CM_INV },
  1806. #endif /* BPRINT */
  1807. #endif /*  OS2 */
  1808. #ifdef BROWSER
  1809.     { "browser",          XYBROWSE,CM_PSH|CM_LOC },
  1810. #endif /* BROWSER */
  1811. #ifndef NOXFER
  1812. #ifdef DYNAMIC
  1813.     { "buffers",          XYBUF,   0 },
  1814. #endif /* DYNAMIC */
  1815. #endif /* NOXFER */
  1816. #ifndef NOLOCAL
  1817. #ifndef MAC
  1818.     { "carrier-watch",    XYCARR,  CM_LOC },
  1819. #endif /* MAC */
  1820. #endif /* NOLOCAL */
  1821. #ifndef NOSPL
  1822.     { "case",             XYCASE,  0 },
  1823. #endif /* NOSPL */
  1824.     { "cd",               XYCD,    0 },
  1825. #ifndef NOXFER
  1826.     { "cl",               XYCLEAR, CM_INV|CM_ABR },
  1827.     { "cle",              XYCLEAR, CM_INV|CM_ABR },
  1828.     { "clea",             XYCLEAR, CM_INV|CM_ABR },
  1829.     { "clear",            XYCLEAR, CM_INV|CM_ABR },
  1830.     { "clear-channel",    XYCLEAR, 0 },
  1831.     { "clearchannel",     XYCLEAR, CM_INV },
  1832. #endif /* NOXFER */
  1833. #ifndef NOLOCAL
  1834.     { "close-on-disconnect", XYDISC, CM_INV|CM_LOC },
  1835. #endif /* NOLOCAL */
  1836.     { "cmd",              XYCMD,   CM_INV },
  1837.     { "command",          XYCMD,   0 },
  1838. #ifdef CK_SPEED
  1839.     { "con",              XYQCTL,  CM_INV|CM_ABR },
  1840. #endif /* CK_SPEED */
  1841.     { "console",          XYCMD,   CM_INV },
  1842. #ifdef CK_SPEED
  1843.     { "control-character",XYQCTL,  0 },
  1844. #endif /* CK_SPEED */
  1845. #ifndef NOSPL
  1846.     { "count",            XYCOUN,  0 },
  1847. #endif /* NOSPL */
  1848. #ifndef NOXFER
  1849.     { "d",          XYDELA,  CM_INV|CM_ABR },
  1850.     { "de",          XYDELA,  CM_INV|CM_ABR },
  1851. #endif /* NOXFER */
  1852.     { "debug",            XYDEBU,  0 },
  1853. #ifdef VMS
  1854.     { "default",          XYDFLT,  0 },
  1855. #else
  1856. #ifndef MAC
  1857.     { "default",          XYDFLT,  CM_INV },
  1858. #endif /* MAC */
  1859. #endif /* VMS */
  1860. #ifndef NOXFER
  1861.     { "delay",              XYDELA,  0 },
  1862.     { "destination",      XYDEST,  0 },
  1863. #endif /* NOXFER */
  1864. #ifndef NODIAL
  1865.     { "di",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1866.     { "dia",          XYDIAL,  CM_INV|CM_ABR|CM_LOC },
  1867.     { "dial",             XYDIAL,  CM_LOC },
  1868. #endif /* NODIAL */
  1869. #ifdef OS2
  1870.     { "dialer",          XYDLR,   CM_INV },
  1871. #endif /* OS2 */
  1872. #ifndef NOLOCAL
  1873.     { "disconnect",       XYDISC,  CM_LOC },
  1874.     { "duplex",              XYDUPL,  CM_LOC },
  1875. #endif /* NOLOCAL */
  1876. #ifndef NOPUSH
  1877. #ifndef NOFRILLS
  1878.     { "editor",           XYEDIT,  CM_PSH },
  1879. #endif /*  NOFRILLS */
  1880. #endif /* NOPUSH */
  1881. #ifdef CK_CTRLZ
  1882.     { "eof",              XYEOF,   CM_INV },
  1883. #endif /* CK_CTRLZ */
  1884. #ifndef NOLOCAL
  1885.     { "escape-character", XYESC,   CM_LOC },
  1886. #endif /* NOLOCAL */
  1887. #ifndef NOSPL
  1888.     { "evaluate",         XYEVAL,  CM_INV },
  1889. #endif /* NOSPL */
  1890.     { "exit",          XYEXIT,  0 },
  1891. #ifndef NOXFER
  1892.     { "f-ack-bug",        XYFACKB, CM_INV },
  1893.     { "f-ack-path",       XYFACKP, CM_INV },
  1894. #endif /* NOXFER */
  1895.     { "file",             XYFILE,  0 },
  1896.     { "fl",                 XYFLOW,  CM_INV|CM_ABR },
  1897. #ifndef NOSPL
  1898.     { "flag",             XYFLAG,  0 },
  1899. #endif /* NOSPL */
  1900. #ifdef TCPSOCKET
  1901. #ifndef SYSFTP
  1902. #ifndef NOFTP
  1903.     { "ft",                 XYFTPX,  CM_INV|CM_ABR },
  1904.     { "ftp",                XYFTPX,  0 },
  1905. #endif /* NOFTP */
  1906. #endif /* SYSFTP */
  1907. #endif /* TCPSOCKET */
  1908. #ifdef BROWSER
  1909.     { "ftp-client",       XYFTP,   CM_PSH },
  1910. #endif /* BROWSER */
  1911.     { "flow-control",       XYFLOW,  0 },
  1912. #ifndef NOSPL
  1913.     { "function",         XYFUNC,  0 },
  1914. #endif /* NOSPL */
  1915. #ifdef NEWFTP
  1916.     { "get-put-remote",   XYGPR,   0 },
  1917. #endif /* NEWFTP */
  1918. #ifdef KUI
  1919.     { "gui",              XYGUI,   0 },
  1920. #endif /* KUI */
  1921.     { "handshake",          XYHAND,  0 },
  1922.     { "hints",            XYHINTS, 0 },
  1923. #ifdef NETCONN
  1924.     { "host",             XYHOST,  CM_LOC },
  1925. #endif /* NETCONN */
  1926. #ifndef NOSPL
  1927.     { "i",          XYINPU,  CM_INV|CM_ABR },
  1928. #endif /* NOSPL */
  1929. #ifdef IKSD
  1930.     { "iks",              XYIKS,   0 },
  1931. #else
  1932.     { "iks",              XYIKS,   CM_INV },
  1933. #endif /* IKSD */
  1934. #ifndef NOSPL
  1935.     { "in",          XYINPU,  CM_INV|CM_ABR },
  1936. #endif /* NOSPL */
  1937. #ifndef NOXFER
  1938.     { "incomplete",         XYIFD,   CM_INV },
  1939. #endif /* NOXFER */
  1940. #ifndef NOSPL
  1941.     { "input",            XYINPU,  0 },
  1942. #endif /* NOSPL */
  1943. #ifndef NOSETKEY
  1944.     { "key",          XYKEY,   0 },
  1945. #endif /* NOSETKEY */
  1946.     { "l",                XYLINE,  CM_INV|CM_ABR },
  1947. #ifndef NOCSETS
  1948.     { "language",         XYLANG,  0 },
  1949. #endif /* NOCSETS */
  1950. #ifndef NOLOCAL
  1951.     { "line",             XYLINE,  CM_LOC },
  1952.     { "local-echo",      XYLCLE,  CM_INV|CM_LOC },
  1953. #endif /* NOLOCAL */
  1954. #ifdef LOCUS
  1955.     { "locus",            XYLOCUS, 0 },
  1956. #endif /* LOCUS */
  1957. #ifndef NOSPL
  1958.     { "login",          XYLOGIN, CM_LOC },
  1959. #endif /* NOSPL */
  1960. #ifndef NOSPL
  1961.     { "macro",            XYMACR,  0 },
  1962. #endif /* NOSPL */
  1963. #ifdef COMMENT
  1964. #ifdef VMS
  1965.     { "messages",         XYMSGS,  0 },
  1966. #endif /* VMS */
  1967. #endif /* COMMENT */
  1968. #ifndef NODIAL
  1969.     { "modem",          XYMODM,  CM_LOC },
  1970. #endif /* NODIAL */
  1971. #ifndef NOLOCAL
  1972. #ifdef OS2MOUSE
  1973.     { "mouse",          XYMOUSE, 0 },
  1974. #endif /* OS2MOUSE */
  1975. #endif /* NOLOCAL */
  1976. #ifdef OS2
  1977.     { "mskermit",         XYMSK,   0 },
  1978. #endif /* OS2 */
  1979. #ifdef NETCONN
  1980.     { "network",          XYNET,   CM_LOC },
  1981. #endif /* NETCONN */
  1982. #ifndef NOSPL
  1983.     { "output",           XYOUTP,  0 },
  1984. #endif /* NOSPL */
  1985.     { "options",          XYOPTS,  0 },
  1986.     { "pause",            XYSLEEP, CM_INV },
  1987. #ifdef ANYX25
  1988. #ifndef IBMX25
  1989.     { "pad",              XYPAD,   CM_LOC },
  1990. #endif /* IBMX25 */
  1991. #endif /* ANYX25 */
  1992.     { "parity",              XYPARI,  0 },
  1993. #ifndef NOLOCAL
  1994. #ifdef OS2
  1995.     { "port",             XYLINE,  CM_LOC },
  1996. #else
  1997.     { "port",             XYLINE,  CM_INV|CM_LOC },
  1998. #endif /* OS2 */
  1999. #endif /* NOLOCAL */
  2000. #ifndef NOFRILLS
  2001.     { "pr",                 XYPROM,  CM_INV|CM_ABR },
  2002.     { "printer",          XYPRTR,  0 },
  2003. #endif /* NOFRILLS */
  2004. #ifdef OS2
  2005.     { "priority",         XYPRTY,  0 },
  2006. #endif /* OS2 */
  2007. #ifdef CK_SPEED
  2008.     { "prefixing",        XYPREFIX, 0 },
  2009. #endif /* CK_SPEED */
  2010. #ifndef NOFRILLS
  2011.     { "prompt",              XYPROM,  0 },
  2012. #endif /* NOFRILLS */
  2013. #ifndef NOXFER
  2014.     { "protocol",      XYPROTO, 0 },
  2015. #endif /* NOXFER */
  2016.     { "q",          XYQUIE,  CM_INV|CM_ABR },
  2017. #ifndef NOXFER
  2018.     { "q8flag",           XYQ8FLG, CM_INV },
  2019. #endif /* NOXFER */
  2020. #ifdef QNX
  2021.     { "qnx-port-lock",    XYQNXPL, 0 },
  2022. #else
  2023.     { "qnx-port-lock",    XYQNXPL, CM_INV },
  2024. #endif /* QNX */
  2025.     { "quiet",          XYQUIE,  0 },
  2026. #ifndef NOXFER
  2027.     { "rec",              XYRECV,  CM_INV|CM_ABR },
  2028.     { "receive",          XYRECV,  0 },
  2029.     { "recv",             XYRECV,  CM_INV },
  2030. #endif /* NOXFER */
  2031.     { "reliable",         XYRELY,  0 },
  2032. #ifndef NOXFER
  2033.     { "repeat",           XYREPT,  0 },
  2034.     { "retry-limit",      XYRETR,  0 },
  2035. #endif /* NOXFER */
  2036. #ifdef CKROOT
  2037.     { "root",             XYROOT,  0 },
  2038. #endif /* CKROOT */
  2039. #ifndef NOSCRIPT
  2040.     { "script",          XYSCRI,  CM_LOC },
  2041. #endif /* NOSCRIPT */
  2042. #ifndef NOXFER
  2043.     { "send",             XYSEND,  0 },
  2044. #ifndef NOLOCAL
  2045. #ifndef NOSERVER
  2046.     { "ser",              XYSERV,  CM_INV|CM_ABR },
  2047. #endif /* NOSERVER */
  2048. #endif /* NOXFER */
  2049.     { "serial",           XYSERIAL,CM_LOC },
  2050. #endif /* NOLOCAL */
  2051. #ifndef NOSERVER
  2052.     { "server",           XYSERV,  0 },
  2053. #endif /* NOSERVER */
  2054. #ifdef SESLIMIT
  2055. #ifndef NOLOCAL
  2056.     { "session-l",        XYSESS,  CM_INV|CM_ABR },
  2057. #endif /* NOLOCAL */
  2058.     { "session-limit",    XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */
  2059. #endif /* SESLIMIT */
  2060.  
  2061. #ifndef NOLOCAL
  2062.     { "session-log",      XYSESS,  CM_LOC },
  2063. #endif /* NOLOCAL */
  2064.  
  2065. #ifndef NOSPL
  2066. #ifndef NOSEXP
  2067.     { "sexpression",      XYSEXP,  CM_INV },
  2068. #endif /* NOSEXP */
  2069. #endif /* NOSPL */
  2070.  
  2071.     { "sleep",            XYSLEEP, 0 },
  2072.  
  2073. #ifndef NOLOCAL
  2074.     { "speed",              XYSPEE,  CM_LOC },
  2075. #endif /* NOLOCAL */
  2076.  
  2077. #ifdef ANYSSH
  2078.     { "ssh",              XYSSH,   0 },
  2079. #endif /* ANYSSH */
  2080.  
  2081. #ifndef NOSPL
  2082.     { "startup-file",     XYSTARTUP, CM_INV },
  2083. #endif /* NOSPL */
  2084.  
  2085. #ifndef NOLOCAL
  2086. #ifdef HWPARITY
  2087.     { "stop-bits",        XYSTOP, CM_LOC },
  2088. #else
  2089. #ifdef TN_COMPORT
  2090.     { "stop-bits",        XYSTOP, CM_LOC },
  2091. #endif /* TN_COMPORT */
  2092. #endif /* HWPARITY */
  2093. #endif /* NOLOCAL */
  2094.  
  2095. #ifndef NOXFER
  2096. #ifdef STREAMING
  2097.     { "streaming",        XYSTREAM, 0 },
  2098. #endif /* STREAMING */
  2099. #endif /* NOXFER */
  2100.  
  2101. #ifndef NOJC
  2102.     { "suspend",          XYSUSP,  CM_PSH },
  2103. #endif /* NOJC */
  2104. #ifdef CKSYSLOG
  2105.     { "syslog",           XYSYSL,  CM_INV },
  2106. #endif /* CKSYSLOG */
  2107.     { "take",             XYTAKE,  0 },
  2108.  
  2109. #ifdef CK_TAPI
  2110.     { "tapi",             XYTAPI,  CM_LOC },
  2111. #endif /* CK_TAPI */
  2112.  
  2113. #ifndef NOTCPOPTS
  2114. #ifdef TCPSOCKET
  2115.     { "tcp",              XYTCP,   CM_LOC },
  2116. #endif /* TCPSOCKET */
  2117. #endif /* NOTCPOPTS */
  2118.  
  2119. #ifdef TNCODE
  2120.     { "tel",              XYTEL,   CM_INV|CM_ABR },
  2121.     { "telnet",           XYTEL,   0 },
  2122.     { "telopt",           XYTELOP, 0 },
  2123. #endif /* TNCODE */
  2124.  
  2125. #ifndef NOSPL
  2126.     { "temp-directory",   XYTMPDIR,0 },
  2127. #endif /* NOSPL */
  2128.  
  2129. #ifndef NOLOCAL
  2130.     { "terminal",         XYTERM,  CM_LOC },
  2131. #endif /* NOLOCAL */
  2132.  
  2133. #ifdef OS2
  2134.     { "title",          XYTITLE, CM_LOC },
  2135. #endif /* OS2 */
  2136. #ifdef TLOG
  2137.     { "transaction-log",  XYTLOG,  0 },
  2138. #endif /* TLOG */
  2139. #ifndef NOXFER
  2140.     { "transfer",         XYXFER,  0 },
  2141. #endif /* NOXFER */
  2142. #ifndef NOXMIT
  2143.     { "transmit",         XYXMIT,  0 },
  2144. #endif /* NOXMIT */
  2145. #ifndef NOXFER
  2146. #ifndef NOCSETS
  2147.     { "unknown-char-set", XYUNCS,  0 },
  2148. #endif /* NOCSETS */
  2149. #endif /* NOXFER */
  2150.     { "wait",             XYSLEEP, CM_INV },
  2151. #ifndef NOPUSH
  2152. #ifdef UNIX
  2153.     { "wildcard-expansion", XYWILD, 0 },
  2154. #endif /* UNIX */
  2155. #endif /* NOPUSH */
  2156. #ifdef NT
  2157.     { "w",                XYWIND,  CM_INV|CM_ABR },
  2158.     { "wi",               XYWIND,  CM_INV|CM_ABR },
  2159.     { "win",              XYWIND,  CM_INV|CM_ABR },
  2160. #endif /* NT */
  2161.     { "window-size",      XYWIND,  0 },
  2162. #ifdef NT
  2163.     { "win95",            XYWIN95, 0 },
  2164. #endif /* NT */
  2165. #ifdef ANYX25
  2166.     { "x.25",             XYX25,   CM_LOC },
  2167.     { "x25",              XYX25,   CM_INV|CM_LOC },
  2168. #endif /* ANYX25 */
  2169.     { "xfer",             XYXFER,  CM_INV },
  2170. #ifndef NOXMIT
  2171.     { "xmit",             XYXMIT,  CM_INV },
  2172. #endif /* NOXMIT */
  2173.     { "", 0, 0 }
  2174. };
  2175. int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */
  2176.  
  2177. struct keytab scntab[] = {        /* Screen commands */
  2178.     { "clear",   SCN_CLR, 0 },
  2179.     { "cleol",   SCN_CLE, 0 },
  2180.     { "move-to", SCN_MOV, 0 }
  2181. };
  2182. int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */
  2183.  
  2184. #ifdef ANYSSH                /* SSH command table */
  2185. #ifdef SSHBUILTIN
  2186. int    ssh_pf_lcl_n = 0,
  2187.        ssh_pf_rmt_n = 0;
  2188. struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */
  2189. struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */
  2190. extern char * ssh_hst, * ssh_cmd, * ssh_prt;
  2191. extern int    ssh_ver,   ssh_xfw;
  2192. char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL;
  2193.  
  2194. int
  2195.  sshk_type = SSHKT_2D,            /* SSH KEY CREATE /TYPE:x */
  2196.  sshk_bits = 1024,            /* SSH KEY CREATE /BITS:n */
  2197.  sshk_din  = SKDF_OSSH,            /* SSH KEY DISPLAY /IN-FORMAT: */
  2198.  sshk_dout = SKDF_OSSH;            /* SSH KEY DISPLAY /OUT-FORMAT: */
  2199.  
  2200. char
  2201.  * sshk1_comment = NULL,        /* SSH V1 COMMENT */
  2202.  * sshkp_old = NULL,            /* Old key passphrase */
  2203.  * sshkp_new = NULL,            /* New key passphrase */
  2204.  * sshkc_pass = NULL,            /* KEY CREATE /PASS:xxx */
  2205.  * sshkc_comm = NULL,            /* KEY CREATE /V1-RSA-COMMENT:xxx */
  2206.  * sshd_file = NULL,            /* DISPLAY file */
  2207.  * sshk_file = NULL;            /* SSH CREATE KEY file */
  2208.  
  2209. static struct keytab sshclr[] = {
  2210.     { "local-port-forward",  SSHC_LPF, 0 },
  2211.     { "remote-port-forward", SSHC_RPF, 0 },
  2212.     { "", 0, 0 }
  2213. };
  2214. static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1;
  2215.  
  2216. struct keytab sshopnsw[] = {
  2217.     { "/command",        SSHSW_CMD, CM_ARG },
  2218.     { "/password",       SSHSW_PWD, CM_ARG },
  2219.     { "/subsystem",      SSHSW_SUB, CM_ARG },
  2220.     { "/user",           SSHSW_USR, CM_ARG },
  2221.     { "/version",        SSHSW_VER, CM_ARG },
  2222.     { "/x11-forwarding", SSHSW_X11, CM_ARG },
  2223.     { "", 0, 0 }
  2224. };
  2225. int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1;
  2226.  
  2227. static struct keytab sshkwtab[] = {
  2228.     { "add",                 XSSH_ADD, 0 },
  2229.     { "agent",               XSSH_AGT, 0 },
  2230.     { "clear",               XSSH_CLR, 0 },
  2231.     { "forward-local-port",  XSSH_FLP, CM_INV },
  2232.     { "forward-remote-port", XSSH_FRP, CM_INV },
  2233.     { "key",                 XSSH_KEY, 0 },
  2234.     { "open",                XSSH_OPN, 0 },
  2235.     { "v2",                  XSSH_V2,  0 },
  2236.     { "", 0, 0 }
  2237. };
  2238. static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1;
  2239.  
  2240. static struct keytab ssh2tab[] = {
  2241.     { "rekey", XSSH2_RKE, 0 },
  2242.     { "", 0, 0 }
  2243. };
  2244. static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab));
  2245.  
  2246. static struct keytab addfwd[] = {    /* SET SSH ADD command table */
  2247.     { "local-port-forward",  SSHF_LCL, 0 },
  2248.     { "remote-port-forward", SSHF_RMT, 0 },
  2249.     { "", 0, 0 }
  2250. };
  2251. static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
  2252.  
  2253. static struct keytab sshagent[] = {    /* SET SSH AGENT command table */
  2254.     { "add",    SSHA_ADD, 0 },
  2255.     { "delete", SSHA_DEL, 0 },
  2256.     { "list",   SSHA_LST, 0 },
  2257.     { "", 0, 0 }
  2258. };
  2259. static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1;
  2260.  
  2261. static struct keytab sshagtsw[] = {    /* SET SSH AGENT LIST switch table */
  2262.     { "/fingerprint", SSHASW_FP, 0 },
  2263.     { "", 0, 0 }
  2264. };
  2265. static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1;
  2266.  
  2267. static struct keytab sshkey[] = {    /* SET SSH KEY command table */
  2268.     { "change-passphrase",  SSHK_PASS, 0 },
  2269.     { "create",             SSHK_CREA, 0 },
  2270.     { "display",            SSHK_DISP, 0 },
  2271.     { "v1",                 SSHK_V1,   0 },
  2272.     { "", 0, 0 }
  2273. };
  2274. static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1;
  2275.  
  2276. static struct keytab sshkv1[] = {    /* SET SSH KEY V1 command table */
  2277.     { "set-comment",  1, 0 }
  2278. };
  2279.  
  2280. static struct keytab sshkpsw[] = {    /* SET SSH KEY PASSPHRASE table */
  2281.     { "/new-passphrase",  2, CM_ARG },
  2282.     { "/old-passphrase",  1, CM_ARG }
  2283. };
  2284.  
  2285. static struct keytab sshkcrea[] = {    /* SSH KEY CREATE table */
  2286.     { "/bits",           SSHKC_BI, CM_ARG },
  2287.     { "/passphrase",     SSHKC_PP, CM_ARG },
  2288.     { "/type",           SSHKC_TY, CM_ARG },
  2289.     { "/v1-rsa-comment", SSHKC_1R, CM_ARG }
  2290. };
  2291. static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab));
  2292.  
  2293. static struct keytab sshkcty[] = {    /* SSH KEY CREATE /TYPE:xxx */
  2294.     { "srp",    SSHKT_SRP, 0 },
  2295.     { "v1-rsa", SSHKT_1R, 0 },
  2296.     { "v2-dsa", SSHKT_2D, 0 },
  2297.     { "v2-rsa", SSHKT_2R, 0 }
  2298. };
  2299. static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab));
  2300.  
  2301. static struct keytab sshdswi[] = {    /* SET SSH KEY DISPLAY /switches */
  2302.     { "/format", SSHKD_OUT, CM_ARG }
  2303. };
  2304. static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab));
  2305.  
  2306. #ifdef COMMENT
  2307. static struct keytab sshdifmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2308.     { "openssh", SKDF_OSSH, 0 },
  2309.     { "ssh.com", SKDF_SSHC, 0 }
  2310. };
  2311. static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab));
  2312. #endif /* COMMENT */
  2313.  
  2314. static struct keytab sshdofmt[] = {    /* SSH KEY DISPLAY /IN-FORMAT: */
  2315.     { "fingerprint", SKDF_FING, 0 },
  2316.     { "ietf",        SKDF_IETF, 0 },
  2317.     { "openssh",     SKDF_OSSH, 0 },
  2318.     { "ssh.com",     SKDF_SSHC, 0 }
  2319. };
  2320. static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab));
  2321. #endif /* SSHBUILTIN */
  2322. #endif /* ANYSSH */
  2323.  
  2324. #ifdef NETCONN
  2325. struct keytab netkey[] = {        /* SET NETWORK table */
  2326.     { "directory", XYNET_D,  0 },
  2327.     { "type",      XYNET_T,  0 }
  2328. };
  2329. int nnetkey = (sizeof(netkey) / sizeof(struct keytab));
  2330.  
  2331. struct keytab netcmd[] = {
  2332. /*
  2333.   These are the network types.
  2334. */
  2335. #ifdef NETCMD
  2336.     { "command",       NET_CMD,  CM_INV }, /* Command */
  2337. #endif /* NETCMD */
  2338.  
  2339. #ifdef DECNET                /* DECnet / PATHWORKS */
  2340.     { "decnet",        NET_DEC,  0 },
  2341. #endif /* DECNET */
  2342.  
  2343. #ifdef NETDLL
  2344.     { "dll",           NET_DLL,  CM_INV }, /* DLL to be loaded */
  2345. #endif /* NETDLL */
  2346.  
  2347. #ifdef NETFILE
  2348.     { "file",           NET_FILE, CM_INV }, /* FILE (real crude) */
  2349. #endif /* NETFILE */
  2350.  
  2351. #ifdef NPIPE                /* Named Pipes */
  2352.     { "named-pipe",     NET_PIPE,  0 },
  2353. #endif /* NPIPE */
  2354.  
  2355. #ifdef CK_NETBIOS
  2356.     { "netbios",        NET_BIOS,  0 },    /* NETBIOS */
  2357. #endif /* CK_NETBIOS */
  2358.  
  2359. #ifdef DECNET                /* DECnet / PATHWORKS (alias) */
  2360.     { "pathworks",     NET_DEC,  CM_INV },
  2361. #endif /* DECNET */
  2362.  
  2363. #ifdef NETCMD
  2364.     { "pipe",          NET_CMD,  0 },    /* Pipe */
  2365. #endif /* NETCMD */
  2366.  
  2367. #ifdef NETPTY
  2368.     { "pseudoterminal",NET_PTY, 0 },    /* Pseudoterminal */
  2369. #endif /* NETPTY */
  2370.  
  2371. #ifdef NETPTY
  2372.     { "pty",          NET_PTY,  CM_INV }, /* Inv syn for pseudoterm */
  2373. #endif /* NETPTY */
  2374.  
  2375. #ifdef SSHBUILTIN
  2376.     { "ssh",          NET_SSH,  0 },
  2377. #endif /* SSHBUILTIN */
  2378.  
  2379. #ifdef SUPERLAT
  2380.     { "superlat",     NET_SLAT, 0 },    /* Meridian Technologies' SuperLAT */
  2381. #endif /* SUPERLAT */
  2382.  
  2383. #ifdef TCPSOCKET            /* TCP/IP sockets library */
  2384.     { "tcp/ip",       NET_TCPB, 0 },
  2385. #endif /* TCPSOCKET */
  2386. #ifdef SUPERLAT
  2387.     { "tes32",        NET_SLAT, 0 },    /* Emulux TES32 */
  2388. #endif /* SUPERLAT */
  2389. #ifdef ANYX25                /* X.25 */
  2390. #ifdef SUNX25
  2391.     { "x",            NET_SX25, CM_INV|CM_ABR },
  2392.     { "x.25",         NET_SX25, 0 },
  2393.     { "x25",          NET_SX25, CM_INV },
  2394. #else
  2395. #ifdef STRATUSX25
  2396.     { "x",            NET_VX25, CM_INV|CM_ABR },
  2397.     { "x.25",         NET_VX25, 0 },
  2398.     { "x25",          NET_VX25, CM_INV },
  2399. #endif /* STRATUSX25 */
  2400. #endif /* SUNX25 */
  2401. #ifdef IBMX25
  2402.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2403.     { "x.25",         NET_IX25, CM_INV },
  2404.     { "x25",          NET_IX25, CM_INV },
  2405. #endif /* IBMX25 */
  2406. #ifdef HPX25
  2407.     { "x",            NET_IX25, CM_INV|CM_ABR },
  2408.     { "x.25",         NET_IX25, 0 },
  2409.     { "x25",          NET_IX25, CM_INV },
  2410. #endif /* HPX25 */
  2411. #endif /* ANYX25 */
  2412.     { "", 0, 0 }
  2413. };
  2414. int nnets = (sizeof(netcmd) / sizeof(struct keytab));
  2415.  
  2416. #ifndef NOTCPOPTS
  2417. #ifdef TCPSOCKET
  2418.  
  2419. /* TCP options */
  2420.  
  2421. struct keytab tcpopt[] = {
  2422.     { "address",   XYTCP_ADDRESS, 0 },
  2423. #ifdef CK_DNS_SRV
  2424.     { "dns-service-records", XYTCP_DNS_SRV, 0 },
  2425. #endif /* CK_DNS_SRV */
  2426. #ifdef SO_DONTROUTE
  2427.     { "dontroute",   XYTCP_DONTROUTE, 0 },
  2428. #endif /* SO_DONTROUTE */
  2429. #ifndef NOHTTP
  2430.     { "http-proxy", XYTCP_HTTP_PROXY, 0 },
  2431. #endif /* NOHTTP */
  2432. #ifdef SO_KEEPALIVE
  2433.     { "keepalive", XYTCP_KEEPALIVE, 0 },
  2434. #endif /* SO_KEEPALIVE */
  2435. #ifdef SO_LINGER
  2436.     { "linger", XYTCP_LINGER, 0 },
  2437. #endif /* SO_LINGER */
  2438. #ifdef TCP_NODELAY
  2439.     { "nagle",  XYTCP_NAGLE,    CM_INV },
  2440.     { "nodelay", XYTCP_NODELAY, 0 },
  2441. #endif /* TCP_NODELAY */
  2442.     { "reverse-dns-lookup", XYTCP_RDNS, 0 },
  2443. #ifdef SO_RCVBUF
  2444.     { "recvbuf", XYTCP_RECVBUF, 0 },
  2445. #endif /* SO_RCVBUF */
  2446. #ifdef SO_SNDBUF
  2447.     { "sendbuf", XYTCP_SENDBUF, 0 },
  2448. #endif /* SO_SNDBUF */
  2449. #ifdef NT
  2450. #ifdef CK_SOCKS
  2451.     { "socks-server", XYTCP_SOCKS_SVR, 0 },
  2452. #endif /* CK_SOCKS */
  2453. #endif /* NT */
  2454. #ifdef VMS
  2455. #ifdef DEC_TCPIP
  2456.     { "ucx-port-bug", XYTCP_UCX, 0 },
  2457. #endif /* DEC_TCPIP */
  2458. #endif /* VMS */
  2459.     { "",0,0 }
  2460. };
  2461. int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab));
  2462. #endif /* TCPSOCKET */
  2463. #endif /* NOTCPOPTS */
  2464. #endif /* NETCONN */
  2465.  
  2466. #ifdef OS2
  2467. /* K95 Manual Chapter Table -- Keep these two tables in sync! */
  2468.  
  2469. static char * linktbl[] = {        /* Internal links in k95.htm */
  2470.     "#top",                /* 00 */
  2471.     "#what",                /* 01 */
  2472.     "#install",                /* 02 */
  2473.     "#start",                /* 03 */
  2474.     "#dialer",                /* 04 */
  2475.     "#entries",                /* 05 */
  2476.     "#command",                /* 06 */
  2477.     "#terminal",            /* 07 */
  2478.     "#transfer",            /* 08 */
  2479.     "#hostmode"                /* 09 */
  2480. };
  2481.  
  2482. static struct keytab chaptbl[] = {
  2483.     { "Command-Screen",     6, 0 },
  2484.     { "Contents",           0, 0 },
  2485.     { "Dialer-Entries",     5, 0 },
  2486.     { "File-Transfer",      8, 0 },
  2487.     { "Getting-Started",    3, 0 },
  2488.     { "Host-Mode",          9, 0 },
  2489.     { "Installation",       2, 0 },
  2490.     { "Terminal-Emulation", 7, 0 },
  2491.     { "Using-The-Dialer",   4, 0 },
  2492.     { "What-Is-K95",        1, 0 },
  2493.     { "",                   0, 0 }
  2494. };
  2495. static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1);
  2496. #endif /* OS2 */
  2497.  
  2498. #ifndef NOXFER
  2499. /* Remote Command Table */
  2500.  
  2501. struct keytab remcmd[] = {
  2502. #ifndef NOSPL
  2503.     { "as",        XZASG, CM_INV|CM_ABR },
  2504.     { "asg",       XZASG, CM_INV },
  2505.     { "assign",    XZASG, 0 },
  2506. #endif /* NOSPL */
  2507.     { "cd",        XZCWD, 0 },
  2508.     { "cdup",      XZCDU, CM_INV },
  2509.     { "copy",      XZCPY, 0 },
  2510.     { "cwd",       XZCWD, CM_INV },
  2511.     { "delete",    XZDEL, 0 },
  2512.     { "directory", XZDIR, 0 },
  2513.     { "e",         XZXIT, CM_ABR|CM_INV },
  2514.     { "erase",     XZDEL, CM_INV },
  2515.     { "exit",      XZXIT, 0 },
  2516.     { "help",      XZHLP, 0 },
  2517. #ifndef NOPUSH
  2518.     { "host",      XZHOS, 0 },
  2519. #endif /* NOPUSH */
  2520. #ifndef NOFRILLS
  2521.     { "kermit",    XZKER, 0 },
  2522.     { "l",         XZLGI, CM_ABR|CM_INV },
  2523.     { "lo",        XZLGI, CM_ABR|CM_INV },
  2524.     { "log",       XZLGI, CM_ABR|CM_INV },
  2525.     { "login",     XZLGI, 0 },
  2526.     { "logout",    XZLGO, 0 },
  2527.     { "mkdir",     XZMKD, 0 },
  2528.     { "print",     XZPRI, 0 },
  2529. #endif /* NOFRILLS */
  2530.     { "pwd",       XZPWD, 0 },
  2531. #ifndef NOSPL
  2532.     { "query",       XZQUE, 0 },
  2533. #endif /* NOSPL */
  2534.     { "rename",    XZREN, 0 },
  2535.     { "rmdir",     XZRMD, 0 },
  2536.     { "set",       XZSET, 0 },
  2537.     { "space",       XZSPA, 0 },
  2538. #ifndef NOFRILLS
  2539.     { "type",      XZTYP, 0 },
  2540.     { "who",       XZWHO, 0 },
  2541. #endif /* NOFRILLS */
  2542.     { "", 0, 0}
  2543. };
  2544. int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1;
  2545. #endif /* NOXFER */
  2546.  
  2547. struct keytab logtab[] = {
  2548. #ifdef CKLOGDIAL
  2549.     { "connections",  LOGM, CM_INV },
  2550.     { "cx",           LOGM, 0 },
  2551. #endif /* CKLOGDIAL */
  2552. #ifdef DEBUG
  2553.     { "debugging",    LOGD, 0 },
  2554. #endif /* DEBUG */
  2555.     { "packets",      LOGP, 0 },
  2556. #ifndef NOLOCAL
  2557.     { "session",      LOGS, 0 },
  2558. #endif /* NOLOCAL */
  2559. #ifdef TLOG
  2560.     { "transactions", LOGT, 0 },
  2561. #endif /* TLOG */
  2562.     { "", 0, 0 }
  2563. };
  2564. int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1;
  2565.  
  2566. struct keytab writab[] = {
  2567. #ifndef NOSPL
  2568.     { "append-file",     LOGW, CM_INV },
  2569. #endif /* NOSPL */
  2570.     { "debug-log",       LOGD, 0 },
  2571.     { "error",           LOGE, 0 },
  2572. #ifndef NOSPL
  2573.     { "file",            LOGW, 0 },
  2574. #endif /* NOSPL */
  2575.     { "packet-log",      LOGP, 0 },
  2576.     { "screen",          LOGX, 0 },
  2577. #ifndef NOLOCAL
  2578.     { "session-log",     LOGS, 0 },
  2579. #endif /* NOLOCAL */
  2580.     { "sys$output",      LOGX, CM_INV },
  2581.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2582.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2583.     { "tra",             LOGT, CM_ABR|CM_INV },
  2584.     { "tran",            LOGT, CM_ABR|CM_INV },
  2585.     { "trans",           LOGT, CM_ABR|CM_INV },
  2586.     { "transa",          LOGT, CM_ABR|CM_INV },
  2587.     { "transac",         LOGT, CM_ABR|CM_INV },
  2588.     { "transact",        LOGT, CM_ABR|CM_INV },
  2589.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2590.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2591.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2592.     { "transaction-log", LOGT, 0 },
  2593.     { "transactions",    LOGT, CM_INV }
  2594. };
  2595. int nwri = (sizeof(writab) / sizeof(struct keytab));
  2596.  
  2597. #ifdef COMMENT                /* INPUT switches not used yet... */
  2598. static struct keytab inswtab[] = {
  2599. #ifdef COMMENT
  2600.     { "/assign",       IN_ASG, CM_ARG },
  2601. #endif /* COMMENT */
  2602.     { "/autodownload", IN_ADL, CM_ARG },
  2603.     { "/case",         IN_CAS, CM_ARG },
  2604.     { "/echo",         IN_ECH, CM_ARG },
  2605.     { "/interrupts",   IN_NOI, CM_ARG },
  2606.     { "/silence",      IN_SIL, CM_ARG },
  2607. #ifdef COMMENT
  2608.     { "/pattern",      IN_PAT, CM_ARG },
  2609. #endif /* COMMENT */
  2610.     { "", 0, 0 }
  2611. };
  2612. static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1;
  2613. #endif /* COMMENT */
  2614.  
  2615. static struct keytab clrtab[] = {    /* Keywords for CLEAR command */
  2616. #ifndef NOSPL
  2617.     { "alarm",            CLR_ALR,         0 },
  2618. #ifdef CK_APC
  2619.     { "apc",              CLR_APC,         0 },
  2620. #endif /* CK_APC */
  2621. #ifdef PATTERNS
  2622.     { "binary-patterns",  CLR_BIN,         0 },
  2623. #endif /* PATTERNS */
  2624.     { "both",             CLR_DEV|CLR_INP, CM_INV },
  2625. #endif /* NOSPL */
  2626. #ifdef OS2
  2627.     { "command-screen",   CLR_CMD,         0 },
  2628. #endif /* OS2 */
  2629. #ifndef NOSPL
  2630.     { "device",           CLR_DEV,         CM_INV|CM_ABR },
  2631.     { "device-and-input", CLR_DEV|CLR_INP, 0 },
  2632. #endif /* NOSPL */
  2633.     { "device-buffer",    CLR_DEV,         0 },
  2634. #ifndef NODIAL
  2635.     { "dial-status",      CLR_DIA,     0 },
  2636. #endif /* NODIAL */
  2637. #ifndef NOSPL
  2638.     { "input-buffer",     CLR_INP,         0 },
  2639. #endif /* NOSPL */
  2640.     { "keyboard-buffer",  CLR_KBD,         0 },
  2641.     { "send-list",        CLR_SFL,         0 },
  2642. #ifdef OS2
  2643.     { "scr",              CLR_SCL,         CM_INV|CM_ABR },
  2644. #endif /* OS2 */
  2645.     { "screen",           CLR_SCR,         0 },
  2646. #ifdef OS2
  2647.     { "scrollback",       CLR_SCL,         CM_INV },
  2648.     { "terminal-screen",  CLR_TRM,         0 },
  2649. #endif /* OS2 */
  2650. #ifdef PATTERNS
  2651.     { "text-patterns",    CLR_TXT,         0 },
  2652. #endif /* PATTERNS */
  2653.     { "", 0, 0 }
  2654. };
  2655. int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1;
  2656.  
  2657. struct keytab clstab[] = {        /* Keywords for CLOSE command */
  2658. #ifndef NOSPL
  2659.     { "!read",           LOGR, CM_INV },
  2660.     { "!write",          LOGW, CM_INV },
  2661. #ifndef NOPUSH
  2662. #endif /* NOPUSH */
  2663. #endif /* NOSPL */
  2664. #ifndef NOSPL
  2665.     { "append-file",     LOGW, CM_INV },
  2666. #endif /* NOSPL */
  2667. #ifndef NOLOCAL
  2668.     { "connection",      9999, 0 },
  2669. #endif /* NOLOCAL */
  2670. #ifdef CKLOGDIAL
  2671.     { "cx-log",          LOGM, 0 },
  2672. #endif /* CKLOGDIAL */
  2673. #ifdef DEBUG
  2674.     { "debug-log",       LOGD, 0 },
  2675. #endif /* DEBUG */
  2676.     { "host",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2677.     { "line",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2678.     { "p",               LOGP, CM_INV|CM_ABR },
  2679.     { "packet-log",      LOGP, 0 },
  2680.     { "port",            9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2681. #ifndef NOSPL
  2682.     { "read-file",       LOGR, 0 },
  2683. #endif /* NOSPL */
  2684. #ifndef NOLOCAL
  2685.     { "session-log",     LOGS, 0 },
  2686. #endif /* NOLOCAL */
  2687. #ifdef TLOG
  2688.     { "t",               LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2689.     { "tr",              LOGT, CM_ABR|CM_INV }, /* the book... */
  2690.     { "tra",             LOGT, CM_ABR|CM_INV },
  2691.     { "tran",            LOGT, CM_ABR|CM_INV },
  2692.     { "trans",           LOGT, CM_ABR|CM_INV },
  2693.     { "transa",          LOGT, CM_ABR|CM_INV },
  2694.     { "transac",         LOGT, CM_ABR|CM_INV },
  2695.     { "transact",        LOGT, CM_ABR|CM_INV },
  2696.     { "transacti",       LOGT, CM_ABR|CM_INV },
  2697.     { "transactio",      LOGT, CM_ABR|CM_INV },
  2698.     { "transaction",     LOGT, CM_ABR|CM_INV },
  2699.     { "transaction-log", LOGT, 0 },
  2700.     { "transactions",    LOGT, CM_INV },
  2701. #endif /* TLOG */
  2702. #ifndef NOSPL
  2703.     { "write-file",      LOGW, 0 },
  2704. #endif /* NOSPL */
  2705.     { "", 0, 0 }
  2706. };
  2707. int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1;
  2708.  
  2709. /* SHOW command arguments */
  2710.  
  2711. #ifndef NOSHOW
  2712. struct keytab shotab[] = {
  2713. #ifndef NOSPL
  2714.     { "alarm",        SHALRM, 0 },
  2715.     { "arg",          SHARG, CM_INV|CM_ABR },
  2716.     { "arguments",    SHARG, 0 },
  2717.     { "args",         SHARG, CM_INV },
  2718.     { "arrays",       SHARR, 0 },
  2719. #endif /* NOSPL */
  2720.  
  2721. #ifndef NOCSETS
  2722.     { "associations", SHASSOC, 0 },
  2723. #endif /* NOCSETS */
  2724.  
  2725. #ifndef NOXFER
  2726.     { "attributes",   SHATT, 0 },
  2727. #endif /* NOXFER */
  2728.  
  2729. #ifdef CK_AUTHENTICATION
  2730.     { "authentication", SHOAUTH, CM_INV },
  2731. #endif /* CK_AUTHENTICATION */
  2732.  
  2733. #ifndef NOPUSH
  2734. #ifdef BROWSER
  2735.     { "browser",      SHBROWSE, CM_PSH|CM_LOC },
  2736. #endif /*  BROWSER */
  2737. #endif /* NOPUSH */
  2738.     { "cd",           SHCD, 0 },
  2739.     { "character-sets", SHCSE, 0 },
  2740.     { "cmd",          SHCMD, CM_INV },
  2741. #ifndef NOLOCAL
  2742.     { "com",          SHCOM, CM_INV|CM_ABR },
  2743.     { "comm",         SHCOM, CM_INV|CM_ABR },
  2744.     { "communications", SHCOM, 0 },
  2745. #endif /* NOLOCAL */
  2746.     { "command",      SHCMD, 0 },
  2747.     { "connection",   SHCONNX, 0 },
  2748. #ifdef CK_SPEED
  2749.     { "control-prefixing", SHCTL, 0 },
  2750. #endif /* CK_SPEED */
  2751. #ifdef CKLOGDIAL
  2752.     { "cx",           SHCONNX, CM_INV },
  2753. #endif /* CKLOGDIAL */
  2754. #ifndef NOSPL
  2755.     { "count",        SHCOU, 0 },
  2756. #endif /* NOSPL */
  2757.     { "d",            SHDIA, CM_INV|CM_ABR },
  2758. #ifdef VMS
  2759.     { "default",      SHDFLT, 0 },
  2760. #else
  2761.     { "default",      SHDFLT, CM_INV },
  2762. #endif /* VMS */
  2763. #ifndef NODIAL
  2764.     { "dial",         SHDIA, CM_LOC },
  2765. #endif /* NODIAL */
  2766.     { "double/ignore",SHDBL, 0 },
  2767. #ifndef NOPUSH
  2768. #ifndef NOFRILLS
  2769.     { "editor",       SHEDIT, CM_PSH },
  2770. #endif /*  NOFRILLS */
  2771. #endif /* NOPUSH */
  2772. #ifndef NOLOCAL
  2773.     { "escape",       SHESC, CM_LOC },
  2774. #endif /* NOLOCAL */
  2775.     { "exit",         SHEXI, 0 },
  2776.     { "extended-options", SHXOPT, CM_INV },
  2777.     { "features",     SHFEA, 0 },
  2778.     { "file",         SHFIL, 0 },
  2779. #ifndef NOLOCAL
  2780.     { "flow-control", SHOFLO, 0 },
  2781. #endif /* NOLOCAL */
  2782. #ifdef BROWSER
  2783.     { "ftp",          SHOFTP, CM_PSH|CM_LOC },
  2784. #else
  2785. #ifndef NOFTP
  2786. #ifndef SYSFTP
  2787. #ifdef TCPSOCKET
  2788.     { "ftp",          SHOFTP, 0 },    /* (built-in ftp) */
  2789. #endif /* TCPSOCKET */
  2790. #endif /* SYSFTP */
  2791. #endif /* NOFTP */
  2792. #endif /* BROWSER */
  2793. #ifndef NOSPL
  2794.     { "functions",    SHFUN, 0 },
  2795.     { "globals",      SHVAR, 0 },
  2796. #endif /* NOSPL */
  2797. #ifdef KUI
  2798.     { "gui",          SHOGUI, 0 },
  2799. #endif /* KUI */
  2800. #ifdef CK_RECALL
  2801.     { "history",      SHHISTORY, 0 },
  2802. #endif /* CK_RECALL */
  2803.     { "ignore/double",SHDBL, CM_INV },
  2804.     { "iksd",         SHOIKS, CM_INV },
  2805. #ifndef NOSPL
  2806.     { "input",        SHINP, 0 },
  2807. #endif /* NOSPL */
  2808. #ifndef NOSETKEY
  2809.     { "k",            SHKEY, CM_INV|CM_ABR },
  2810.     { "key",          SHKEY, 0 },
  2811. #ifndef NOKVERBS
  2812.     { "kverbs",       SHKVB, 0 },
  2813. #endif /* NOKVERBS */
  2814. #endif /* NOSETKEY */
  2815. #ifdef CK_LABELED
  2816.     { "labeled-file-info", SHLBL, 0 },
  2817. #endif /* CK_LABELED */
  2818. #ifndef NOCSETS
  2819.     { "languages",    SHLNG, 0 },
  2820. #endif /* NOCSETS */
  2821.     { "logs",         SHLOG, 0 },
  2822. #ifndef NOSPL
  2823.     { "macros",       SHMAC, 0 },
  2824. #endif /* NOSPL */
  2825. #ifndef NODIAL
  2826.     { "modem",        SHMOD, CM_LOC },
  2827. #else
  2828.     { "modem-signals",SHCOM, CM_INV|CM_LOC },
  2829. #endif /* NODIAL */
  2830. #ifndef NOLOCAL
  2831. #ifdef OS2MOUSE
  2832.     { "mouse",        SHMOU, CM_LOC },
  2833. #endif /* OS2MOUSE */
  2834. #endif /* NOLOCAL */
  2835. #ifdef NETCONN
  2836.     { "network",      SHNET, CM_LOC },
  2837. #else
  2838.     { "network",      SHNET, CM_INV|CM_LOC },
  2839. #endif /* NETCONN */
  2840.     { "options",      SHOPTS, 0 },
  2841. #ifndef NOSPL
  2842.     { "output",       SHOUTP, CM_INV },
  2843. #endif /* NOSPL */
  2844. #ifdef ANYX25
  2845. #ifndef IBMX25
  2846.     { "pad",          SHPAD,  CM_LOC },
  2847. #endif /* IBMX25 */
  2848. #endif /* ANYX25 */
  2849.     { "parameters",   SHPAR,  CM_INV },
  2850. #ifdef PATTERNS
  2851.     { "patterns",     SHOPAT, 0 },
  2852. #endif /* PATTERNS */
  2853.     { "printer",      SHPRT,  0 },
  2854. #ifdef CK_SPEED
  2855.     { "prefixing",    SHCTL,  CM_INV },
  2856. #endif /* CK_SPEED */
  2857. #ifndef NOXFER
  2858.     { "protocol",     SHPRO,  0 },
  2859. #endif /* NOXFER */
  2860. #ifndef NOSPL
  2861.     { "scripts",      SHSCR,  CM_LOC },
  2862. #endif /* NOSPL */
  2863.     { "send-list",    SHSFL,  0 },
  2864. #ifndef NOSERVER
  2865.     { "server",       SHSER,  0 },
  2866. #endif /* NOSERVER */
  2867. #ifndef NOSEXP
  2868.     { "sexpression",  SHSEXP, 0 },
  2869. #endif /* NOSEXP */
  2870. #ifdef ANYSSH
  2871.     { "ssh",          SHOSSH, 0 },
  2872. #endif /* ANYSSH */
  2873.     { "stack",        SHSTK,  0 },
  2874.     { "status",       SHSTA,  0 },
  2875. #ifdef STREAMING
  2876.     { "streaming",    SHOSTR, 0 },
  2877. #endif /* STREAMING */
  2878. #ifndef NOLOCAL
  2879. #ifdef OS2
  2880.     { "tabs",          SHTAB, CM_INV|CM_LOC },
  2881. #endif /* OS2 */
  2882. #ifdef CK_TAPI
  2883.     { "tapi",          SHTAPI, CM_LOC },
  2884.     { "tapi-comm",     SHTAPI_C, CM_INV|CM_LOC },
  2885.     { "tapi-location", SHTAPI_L, CM_INV|CM_LOC },
  2886.     { "tapi-modem",    SHTAPI_M, CM_INV|CM_LOC },
  2887. #endif /* CK_TAPI */
  2888.     { "tcp",           SHTCP,  CM_LOC },
  2889. #ifdef TNCODE
  2890.     { "tel",           SHTEL,  CM_INV|CM_ABR },
  2891.     { "telnet",        SHTEL,  0 },
  2892.     { "telopt",        SHTOPT, 0 },
  2893. #endif /* TNCODE */
  2894.     { "terminal",      SHTER,  CM_LOC },
  2895. #endif /* NOLOCAL */
  2896. #ifndef NOXMIT
  2897.     { "tr",            SHXMI, CM_INV|CM_ABR },
  2898.     { "tra",           SHXMI, CM_INV|CM_ABR },
  2899.     { "tran",          SHXMI, CM_INV|CM_ABR },
  2900.     { "trans",         SHXMI, CM_INV|CM_ABR },
  2901. #endif /* NOXMIT */
  2902. #ifndef NOXFER
  2903.     { "transfer",      SHOXFER, 0 },
  2904. #endif /* NOXFER */
  2905. #ifndef NOXMIT
  2906.     { "transmit",      SHXMI, 0 },
  2907. #endif /* NOXMIT */
  2908. #ifdef CK_TRIGGER
  2909.     { "trigger",       SHTRIG, CM_LOC },
  2910. #endif /* CK_TRIGGER */
  2911. #ifndef NOSETKEY
  2912. #ifndef NOKVERBS
  2913. #ifdef OS2
  2914.     { "udk",           SHUDK, CM_LOC },
  2915. #endif /* OS2 */
  2916. #endif /* NOKVERBS */
  2917. #endif /* NOSETKEY */
  2918. #ifndef NOSPL
  2919.     { "variables",     SHBUI, 0 },
  2920. #endif /* NOSPL */
  2921. #ifndef NOFRILLS
  2922.     { "versions",      SHVER, 0 },
  2923. #endif /* NOFRILLS */
  2924. #ifdef OS2
  2925.     { "vscrn",         SHVSCRN, CM_INV|CM_LOC },
  2926. #endif /* OS2 */
  2927.     { "xfer",          SHOXFER,  CM_INV },
  2928. #ifndef NOXMIT
  2929.     { "xmit",          SHXMI,    CM_INV },
  2930. #endif /* NOXMIT */
  2931.     { "", 0, 0 }
  2932. };
  2933. int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1;
  2934. #endif /* NOSHOW */
  2935.  
  2936. #ifdef ANYX25
  2937. #ifndef IBMX25
  2938. struct keytab padtab[] = {              /* PAD commands */
  2939.     { "clear",      XYPADL, 0 },
  2940.     { "interrupt",  XYPADI, 0 },
  2941.     { "reset",      XYPADR, 0 },
  2942.     { "status",     XYPADS, 0 }
  2943. };
  2944. int npadc = (sizeof(padtab) / sizeof(struct keytab));
  2945. #endif /* IBMX25 */
  2946. #endif /* ANYX25 */
  2947.  
  2948. #ifndef NOSERVER
  2949. static struct keytab kmstab[] = {
  2950.     { "both",    3, 0 },
  2951.     { "local",   1, 0 },
  2952.     { "remote",  2, 0 }
  2953. };
  2954.  
  2955. static struct keytab enatab[] = {    /* ENABLE commands */
  2956.     { "all",        EN_ALL,  0 },
  2957. #ifndef NOSPL
  2958.     { "as",         EN_ASG,  CM_INV|CM_ABR },
  2959.     { "asg",        EN_ASG,  CM_INV },
  2960.     { "assign",     EN_ASG,  0 },
  2961. #endif /* NOSPL */
  2962. #ifndef datageneral
  2963.     { "bye",        EN_BYE,  0 },
  2964. #endif /* datageneral */
  2965.     { "cd",         EN_CWD,  0 },
  2966. #ifdef ZCOPY
  2967.     { "copy",       EN_CPY,  0 },
  2968. #endif /* ZCOPY */
  2969.     { "cwd",        EN_CWD,  CM_INV },
  2970.     { "delete",     EN_DEL,  0 },
  2971.     { "directory",  EN_DIR,  0 },
  2972.     { "enable",     EN_ENA,  CM_INV },
  2973.     { "exit",       EN_XIT,  0 },
  2974.     { "finish",     EN_FIN,  0 },
  2975.     { "get",        EN_GET,  0 },
  2976.     { "host",       EN_HOS,  0 },
  2977.     { "mail",       EN_MAI,  0 },
  2978.     { "mkdir",      EN_MKD,  0 },
  2979. #ifndef NOSPL
  2980.     { "query",      EN_QUE,  0 },
  2981. #endif /* NOSPL */
  2982.     { "print",      EN_PRI,  0 },
  2983.     { "rename",     EN_REN,  0 },
  2984.     { "retrieve",   EN_RET,  CM_INV },
  2985.     { "rmdir",      EN_RMD,  0 },
  2986.     { "send",       EN_SEN,  0 },
  2987.     { "set",        EN_SET,  0 },
  2988.     { "space",      EN_SPA,  0 },
  2989.     { "type",       EN_TYP,  0 },
  2990.     { "who",        EN_WHO,  0 }
  2991. };
  2992. static int nena = (sizeof(enatab) / sizeof(struct keytab));
  2993. #endif /* NOSERVER */
  2994.  
  2995. struct keytab txtbin[] = {
  2996.     { "all",        2, 0 },
  2997.     { "binary",     1, 0 },
  2998.     { "text",       0, 0 }
  2999. };
  3000.  
  3001. #ifndef NOXFER
  3002. static struct keytab sndtab[] = {    /* SEND command options */
  3003.     { "/after",           SND_AFT, CM_ARG },
  3004. #ifndef NOSPL
  3005.     { "/array",           SND_ARR, CM_ARG },
  3006. #endif /* NOSPL */
  3007.     { "/as-name",         SND_ASN, CM_ARG },
  3008.     { "/b",               SND_BIN, CM_INV|CM_ABR },
  3009.     { "/before",          SND_BEF, CM_ARG },
  3010.     { "/binary",          SND_BIN, 0 },
  3011. #ifdef CALIBRATE
  3012.     { "/c",               SND_CMD, CM_INV|CM_ABR },
  3013.     { "/calibrate",       SND_CAL, CM_INV|CM_ARG },
  3014. #endif /* CALIBRATE */
  3015.     { "/command",         SND_CMD, CM_PSH },
  3016.     { "/delete",          SND_DEL, 0 },
  3017. #ifdef UNIXOROSK
  3018.     { "/dotfiles",        SND_DOT, 0 },
  3019. #endif /* UNIXOROSK */
  3020.     { "/except",          SND_EXC, CM_ARG },
  3021. #ifdef PIPESEND
  3022.     { "/filter",          SND_FLT, CM_ARG|CM_PSH },
  3023. #endif /* PIPESEND */
  3024.     { "/filenames",       SND_NAM, CM_ARG },
  3025. #ifdef CKSYMLINK
  3026.     { "/followlinks",      SND_LNK, 0 },
  3027. #endif /* CKSYMLINK */
  3028. #ifdef VMS
  3029.     { "/image",           SND_IMG, 0 },
  3030. #else
  3031.     { "/image",           SND_BIN, CM_INV },
  3032. #endif /* VMS */
  3033. #ifdef CK_LABELED
  3034.     { "/labeled",         SND_LBL, 0 },
  3035. #endif /* CK_LABELED */
  3036.     { "/larger-than",     SND_LAR, CM_ARG },
  3037.     { "/listfile",        SND_FIL, CM_ARG },
  3038. #ifndef NOFRILLS
  3039.     { "/mail",            SND_MAI, CM_ARG },
  3040. #endif /* NOFRILLS */
  3041. #ifdef CK_TMPDIR
  3042.     { "/move-to",         SND_MOV, CM_ARG },
  3043. #endif /* CK_TMPDIR */
  3044.     { "/nobackupfiles",   SND_NOB, 0 },
  3045. #ifdef UNIXOROSK
  3046.     { "/nodotfiles",      SND_NOD, 0 },
  3047. #endif /* UNIXOROSK */
  3048. #ifdef CKSYMLINK
  3049.     { "/nofollowlinks",      SND_NLK, 0 },
  3050. #endif /* CKSYMLINK */
  3051.     { "/not-after",       SND_NAF, CM_ARG },
  3052.     { "/not-before",      SND_NBE, CM_ARG },
  3053.     { "/pathnames",       SND_PTH, CM_ARG },
  3054.     { "/print",           SND_PRI, CM_ARG },
  3055. #ifdef CK_XYZ
  3056.     { "/protocol",        SND_PRO, CM_ARG },
  3057. #else
  3058.     { "/protocol",        SND_PRO, CM_ARG|CM_INV },
  3059. #endif /* CK_XYZ */
  3060.     { "/quiet",           SND_SHH, 0 },
  3061.     { "/recover",         SND_RES, 0 },
  3062. #ifdef RECURSIVE
  3063. /* Systems where we do recursion */
  3064.     { "/recursive",       SND_REC, 0 },
  3065. #else
  3066. #ifdef VMS
  3067. /* Systems that do recursion themselves without our assistance */
  3068. /* if we give them the right kind of wildcard */
  3069.     { "/recursive",       SND_REC, 0 },
  3070. #else
  3071. #ifdef datageneral
  3072.     { "/recursive",       SND_REC, 0 },
  3073. #else
  3074.     { "/recursive",       SND_REC, CM_INV },
  3075. #endif /* datageneral */
  3076. #endif /* VMS */
  3077. #endif /* RECURSIVE */
  3078.     { "/rename-to",       SND_REN, CM_ARG },
  3079.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3080.     { "/smaller-than",    SND_SMA, CM_ARG },
  3081.     { "/starting-at",     SND_STA, CM_ARG },
  3082. #ifndef NOFRILLS
  3083.     { "/su",              SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3084.     { "/sub",             SND_ASN, CM_ARG|CM_INV|CM_ABR },
  3085.     { "/subject",         SND_ASN, CM_ARG },
  3086. #endif /* NOFRILLS */
  3087. #ifdef RECURSIVE
  3088.     { "/subdirectories",  SND_REC, CM_INV },
  3089. #endif /* RECURSIVE */
  3090.     { "/text",            SND_TXT, 0 },
  3091.     { "/transparent",     SND_XPA, 0 },
  3092.     { "/type",            SND_TYP, CM_ARG }
  3093. };
  3094. #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab)
  3095. static int nsndtab = NSNDTAB;
  3096.  
  3097. #ifndef NOMSEND
  3098. static struct keytab msndtab[] = {    /* MSEND options */
  3099.     { "/after",           SND_AFT, CM_ARG },
  3100.     { "/before",          SND_BEF, CM_ARG },
  3101.     { "/binary",          SND_BIN, 0 },
  3102.     { "/delete",          SND_DEL, 0 },
  3103.     { "/except",          SND_EXC, CM_ARG },
  3104.     { "/filenames",       SND_NAM, CM_ARG },
  3105. #ifdef CKSYMLINK
  3106.     { "/followlinks",      SND_LNK, 0 },
  3107. #endif /* CKSYMLINK */
  3108. #ifdef VMS
  3109.     { "/image",           SND_IMG, 0 },
  3110. #else
  3111.     { "/image",           SND_BIN, CM_INV },
  3112. #endif /* VMS */
  3113. #ifdef CK_LABELED
  3114.     { "/labeled",         SND_LBL, 0 },
  3115. #endif /* CK_LABELED */
  3116.     { "/larger-than",     SND_LAR, CM_ARG },
  3117.     { "/list",            SND_FIL, CM_ARG },
  3118. #ifndef NOFRILLS
  3119.     { "/mail",            SND_MAI, CM_ARG },
  3120. #endif /* NOFRILLS */
  3121. #ifdef CK_TMPDIR
  3122.     { "/move-to",         SND_MOV, CM_ARG },
  3123. #endif /* CK_TMPDIR */
  3124. #ifdef CKSYMLINK
  3125.     { "/nofollowlinks",    SND_NLK, 0 },
  3126. #endif /* CKSYMLINK */
  3127.     { "/not-after",       SND_NAF, CM_ARG },
  3128.     { "/not-before",      SND_NBE, CM_ARG },
  3129.     { "/pathnames",       SND_PTH, CM_ARG },
  3130.     { "/print",           SND_PRI, CM_ARG },
  3131. #ifdef CK_XYZ
  3132.     { "/protocol",        SND_PRO, CM_ARG },
  3133. #endif /* CK_XYZ */
  3134.     { "/quiet",           SND_SHH, 0 },
  3135.     { "/recover",         SND_RES, 0 },
  3136.     { "/rename-to",       SND_REN, CM_ARG },
  3137.     { "/since",           SND_AFT, CM_INV|CM_ARG },
  3138.     { "/smaller-than",    SND_SMA, CM_ARG },
  3139.     { "/starting-at",     SND_STA, CM_ARG },
  3140. #ifndef NOFRILLS
  3141.     { "/subject",         SND_ASN, CM_ARG },
  3142. #endif /* NOFRILLS */
  3143.     { "/text",            SND_TXT, 0 },
  3144.     { "/transparent",     SND_XPA, 0 },
  3145.     { "/type",            SND_TYP, CM_ARG }
  3146. };
  3147. #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab)
  3148. static int nmsndtab = NMSNDTAB;
  3149. #endif /* NOMSEND */
  3150. #endif /* NOXFER */
  3151.  
  3152. /* CONNECT command switches */
  3153.  
  3154. #define CONN_II  0    /* Idle interval */
  3155. #define CONN_IS  1    /* Idle string */
  3156. #define CONN_IL  2    /* Idle limit */
  3157. #define CONN_NV  3    /* Non-Verbose */
  3158. #define CONN_TL  4    /* Time limit */
  3159. #define CONN_TS  5    /* Trigger string */
  3160. #define CONN_AS  6    /* Asynchronous */
  3161. #define CONN_SY  7    /* Synchronous */
  3162. #define CONN_MAX 7    /* Number of CONNECT switches */
  3163.  
  3164. #ifndef NOLOCAL
  3165. static struct keytab conntab[] = {
  3166. #ifdef OS2
  3167.     { "/asynchronous",    CONN_AS, CM_INV },
  3168. #endif /* OS2 */
  3169. #ifdef XLIMITS
  3170.     { "/idle-interval",   CONN_II, CM_ARG },
  3171.     { "/idle-limit",      CONN_IL, CM_ARG },
  3172.     { "/idle-string",     CONN_IS, CM_ARG },
  3173.     { "/quietly",         CONN_NV, CM_INV },
  3174. #else
  3175.     { "/quietly",         CONN_NV, 0 },
  3176. #endif /* XLIMITS */
  3177. #ifdef OS2
  3178.     { "/synchronous",     CONN_SY, CM_INV },
  3179. #endif /* OS2 */
  3180. #ifdef XLIMITS
  3181.     { "/time-limit",      CONN_TL, CM_ARG },
  3182. #endif /* XLIMITS */
  3183. #ifdef CK_TRIGGER
  3184.     { "/trigger",         CONN_TS, CM_ARG },
  3185. #endif /* CK_TRIGGER */
  3186.     { "",0,0 }
  3187. };
  3188. #define NCONNTAB sizeof(conntab)/sizeof(struct keytab)
  3189. static int nconntab = NCONNTAB;
  3190. #endif /* NOLOCAL */
  3191.  
  3192. #ifndef NOXFER
  3193. static struct keytab stattab[] = {    /* STATISTICS command switches */
  3194.     { "/brief",   1, 0 },
  3195.     { "/verbose", 0, 0 }
  3196. };
  3197. #endif /* NOXFER */
  3198.  
  3199. #ifndef NOSPL
  3200. #ifdef COMMENT
  3201. struct mtab mactab[MAC_MAX] = {        /* Preinitialized macro table */
  3202.     { NULL, NULL, 0 }
  3203. };
  3204. #else
  3205. struct mtab *mactab;            /* Dynamically allocated macro table */
  3206. #endif /* COMMENT */
  3207. int nmac = 0;
  3208.  
  3209. struct keytab mackey[MAC_MAX];        /* Macro names as command keywords */
  3210. #endif /* NOSPL */
  3211.  
  3212. #ifndef NOSPL
  3213. #ifdef  OS2
  3214. struct keytab beeptab[] = {        /* Beep options */
  3215.     { "error", BP_FAIL, 0 },
  3216.     { "information", BP_NOTE, 0 },
  3217.     { "warning", BP_WARN, 0 }
  3218. };
  3219. int nbeeptab = sizeof(beeptab)/sizeof(struct keytab);
  3220.  
  3221. /* CLEAR COMMMAND-SCREEN options */
  3222.  
  3223. #define CLR_C_ALL 0
  3224. #define CLR_C_BOL 1
  3225. #define CLR_C_BOS 2
  3226. #define CLR_C_EOL 3
  3227. #define CLR_C_EOS 4
  3228. #define CLR_C_LIN 5
  3229. #define CLR_C_SCR 6
  3230.  
  3231. struct keytab clrcmdtab[] = {
  3232.     { "all",        CLR_C_ALL, 0 },
  3233.     { "bol",        CLR_C_BOL, 0 },
  3234.     { "bos",        CLR_C_BOS, 0 },
  3235.     { "eol",        CLR_C_EOL, 0 },
  3236.     { "eos",        CLR_C_EOS, 0 },
  3237.     { "line",       CLR_C_LIN, 0 },
  3238.     { "scrollback", CLR_C_SCR, 0 }
  3239. };
  3240. int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab);
  3241. #endif /* OS2 */
  3242. #endif /* NOSPL */
  3243.  
  3244. #ifdef COMMENT
  3245. /* Not used at present */
  3246. static struct keytab pagetab[] = {
  3247.     { "/more",   1, CM_INV },
  3248.     { "/nopage", 0, 0 },
  3249.     { "/page",   1, 0 }
  3250. };
  3251. int npagetab = sizeof(pagetab)/sizeof(struct keytab);
  3252. #endif /* COMMENT */
  3253.  
  3254. #define TYP_NOP  0            /* /NOPAGE */
  3255. #define TYP_PAG  1            /* /PAGE */
  3256. #define TYP_HEA  2            /* /HEAD:n */
  3257. #define TYP_TAI  3            /* /TAIL:n */
  3258. #define TYP_PAT  4            /* /MATCH:pattern */
  3259. #define TYP_WID  5            /* /WIDTH:cols */
  3260. #define TYP_COU  6            /* /COUNT */
  3261. #define TYP_OUT  7            /* /OUTPUT:file */
  3262. #define TYP_PFX  8            /* /PREFIX:string */
  3263. #ifdef UNICODE
  3264. #define TYP_XIN  9            /* /TRANSLATE-FROM:charset */
  3265. #define TYP_XUT 10            /* /TRANSLATE-TO:charset */
  3266. #define TYP_XPA 11            /* /TRANSPARENT */
  3267. #endif /* UNICODE */
  3268. #define TYP_NUM 12            /* /NUMBER */
  3269.  
  3270. static struct keytab typetab[] = {    /* TYPE command switches */
  3271.     { "/count",          TYP_COU, 0 },
  3272. #ifdef UNICODE
  3273.     { "/character-set",  TYP_XIN, CM_ARG },
  3274. #endif /* UNICODE */
  3275.     { "/head",           TYP_HEA, CM_ARG },
  3276.     { "/match",          TYP_PAT, CM_ARG },
  3277. #ifdef CK_TTGWSIZ
  3278.     { "/more",           TYP_PAG, CM_INV },
  3279.     { "/nopage",         TYP_NOP, 0 },
  3280.     { "/number",         TYP_NUM, 0 },
  3281.     { "/output",         TYP_OUT, CM_ARG },
  3282.     { "/page",           TYP_PAG, 0 },
  3283. #endif /* CK_TTGWSIZ */
  3284.     { "/prefix",         TYP_PFX, CM_ARG },
  3285.     { "/tail",           TYP_TAI, CM_ARG },
  3286. #ifdef UNICODE
  3287.     { "/translate-to",   TYP_XUT, CM_ARG },
  3288.     { "/transparent",    TYP_XPA, 0 },
  3289. #endif /* UNICODE */
  3290.     { "/width",          TYP_WID, CM_ARG },
  3291. #ifdef UNICODE
  3292.     { "/xlate-to",       TYP_XUT, CM_INV|CM_ARG },
  3293. #endif /* UNICODE */
  3294.     { "", 0, 0 }
  3295. };
  3296. int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1;
  3297.  
  3298. int typ_page = -1;            /* TYPE /[NO]PAGE default */
  3299. int typ_wid  = -1;
  3300.  
  3301. #ifndef NOSPL
  3302. #define TRA_ALL 999            /* TRACE command */
  3303. #define TRA_ASG 0
  3304. #define TRA_CMD 1
  3305.  
  3306. int tra_asg = 0;
  3307. int tra_cmd = 0;
  3308.  
  3309. static struct keytab tracetab[] = {    /* TRACE options */
  3310.     { "all",            TRA_ALL, 0 },
  3311.     { "assignments",    TRA_ASG, 0 },
  3312.     { "command-level",  TRA_CMD, 0 }
  3313. };
  3314. static int ntracetab = sizeof(tracetab)/sizeof(struct keytab);
  3315. #endif /* NOSPL */
  3316.  
  3317. #ifndef NOSHOW
  3318. VOID
  3319. showtypopts() {
  3320.     printf(" TYPE ");
  3321.     if (typ_page > -1) {
  3322.     prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE");
  3323.     } else
  3324.       prtopt(&optlines,"(no options set)");
  3325.     if (typ_wid > -1) {
  3326.     ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL);
  3327.     prtopt(&optlines,tmpbuf);
  3328.     }
  3329.     prtopt(&optlines,"");
  3330. }
  3331. #endif /* NOSHOW */
  3332.  
  3333. int
  3334. settypopts() {                /* Set TYPE option defaults */
  3335.     int xp = -1;
  3336.     int c, getval;
  3337.     while (1) {
  3338.     if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) {
  3339.         if (y == -3)
  3340.           break;
  3341.         else
  3342.           return(y);
  3343.     }
  3344.     c = cmgbrk();
  3345.     if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  3346.         printf("?This switch does not take an argument\n");
  3347.         return(-9);
  3348.     }
  3349.     switch (y) {
  3350.       case TYP_NOP: xp = 0; break;
  3351.       case TYP_PAG: xp = 1; break;
  3352.       case TYP_WID:
  3353.         if (getval)
  3354.           if ((x = cmnum("Column at which to truncate",
  3355.                  ckitoa(cmd_cols),10,&y,xxstring)) < 0)
  3356.         return(x);
  3357.         typ_wid = y;
  3358.         break;
  3359.  
  3360.           default:
  3361.         printf("?Sorry, this option can not be set\n");
  3362.         return(-9);
  3363.     }
  3364.     }
  3365.     if ((x = cmcfm()) < 0)        /* Get confirmation */
  3366.       return(x);
  3367.     if (xp > -1) typ_page = xp;        /* Confirmed, save defaults */
  3368.     return(success = 1);
  3369. }
  3370.  
  3371. /* Forward declarations of functions local to this module */
  3372.  
  3373. #ifdef UNIX
  3374. _PROTOTYP (int douchmod, ( void ) );
  3375. #endif /* UNIX */
  3376. #ifdef CKPURGE
  3377. _PROTOTYP (int dopurge,  ( void ) );
  3378. #endif /* CKPURGE */
  3379. #ifndef NOSPL
  3380. _PROTOTYP (int doundef,  ( int  ) );
  3381. _PROTOTYP (int doask,    ( int  ) );
  3382. _PROTOTYP (int dodef,    ( int  ) );
  3383. _PROTOTYP (int doelse,   ( void ) );
  3384. _PROTOTYP (int dofor,    ( void ) );
  3385. _PROTOTYP (int doincr,   ( int  ) );
  3386. #endif /* NOSPL  */
  3387. #ifndef NODIAL
  3388. _PROTOTYP (int dodial,   ( int  ) );
  3389. #endif /* NODIAL */
  3390. _PROTOTYP (int dodel,    ( void ) );
  3391. _PROTOTYP (int dopaus,   ( int  ) );
  3392. #ifndef NOPUSH
  3393. #ifdef TCPSOCKET
  3394. _PROTOTYP (int doping,   ( void ) );
  3395. _PROTOTYP (int doftp,    ( void ) );
  3396. #endif /* TCPSOCKET */
  3397. #endif /* NOPUSH */
  3398. #ifndef NORENAME
  3399. #ifndef NOFRILLS
  3400. _PROTOTYP (int dorenam,  ( void ) );
  3401. #endif /* NOFRILLS */
  3402. #endif /* NORENAME */
  3403. #ifdef ZCOPY
  3404. _PROTOTYP (int docopy,   ( void ) );
  3405. #endif /* ZCOPY */
  3406. #ifdef NT
  3407. _PROTOTYP (int dolink,   ( void ));
  3408. #endif /* NT */
  3409. #ifdef CK_REXX
  3410. _PROTOTYP (int dorexx,   ( void ) );
  3411. #endif /* CK_REXX */
  3412.  
  3413. #ifdef TNCODE
  3414. static struct keytab telcmd[] = {
  3415.     { "abort", TN_ABORT, CM_INV },    /* Emotionally toned - don't show */
  3416.     { "ao",    TN_AO,    0 },
  3417.     { "ayt",   TN_AYT,   0 },
  3418.     { "break", BREAK,    0 },
  3419.     { "cancel",TN_ABORT, 0 },
  3420.     { "dmark", TN_DM,    0 },
  3421.     { "do",    DO,       0 },
  3422.     { "dont",  DONT,     0 },
  3423.     { "ec",    TN_EC,    0 },
  3424.     { "el",    TN_EL,    0 },
  3425.     { "eof",   TN_EOF,   0 },
  3426.     { "eor",   TN_EOR,   0 },
  3427. #ifdef CK_KERBEROS
  3428. #ifdef KRB5
  3429. #define TN_FWD 1
  3430.     { "forward", TN_FWD, CM_INV },
  3431. #endif /* KRB5 */
  3432. #endif /* CK_KERBEROS */
  3433.     { "ga",    TN_GA,    0 },
  3434.     { "ip",    TN_IP,    0 },
  3435.     { "nop",   TN_NOP,   0 },
  3436.     { "sak",   TN_SAK,   CM_INV },
  3437.     { "sb",    SB,       0 },
  3438.     { "se",    SE,       0 },
  3439.     { "susp",  TN_SUSP,  0 },
  3440.     { "will",  WILL,     0 },
  3441.     { "wont",  WONT,     0 }
  3442. };
  3443. static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab));
  3444.  
  3445. static struct keytab tnopts[] = {
  3446. #ifdef CK_AUTHENTICATION
  3447.     { "auth",   TELOPT_AUTHENTICATION,   0 },
  3448. #else
  3449.     { "auth",   TELOPT_AUTHENTICATION,   CM_INV },
  3450. #endif /* CK_AUTHENTICATION */
  3451.     { "binary", TELOPT_BINARY, 0 },
  3452. #ifdef TN_COMPORT
  3453.     { "c",      TELOPT_COMPORT, CM_INV|CM_ABR},
  3454.     { "co",     TELOPT_COMPORT, CM_INV|CM_ABR},
  3455.     { "com",    TELOPT_COMPORT, CM_INV|CM_ABR},
  3456.     { "com-port-control", TELOPT_COMPORT, 0 },
  3457.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3458. #else  /* TN_COMPORT */
  3459.     { "com-port-control", TELOPT_COMPORT, CM_INV },
  3460.     { "comport-control", TELOPT_COMPORT, CM_INV},
  3461. #endif /* TN_COMPORT */
  3462.     { "echo", TELOPT_ECHO, 0 },
  3463. #ifdef CK_ENCRYPTION
  3464.     { "encrypt", TELOPT_ENCRYPTION, 0 },
  3465. #else
  3466.     { "encrypt", TELOPT_ENCRYPTION, CM_INV },
  3467. #endif /* CK_ENCRYPTION */
  3468. #ifdef CK_FORWARD_X
  3469.     { "forward-x", TELOPT_FORWARD_X, 0 },
  3470. #else
  3471.     { "forward-x", TELOPT_FORWARD_X, CM_INV },
  3472. #endif /* CK_FORWARD_X */
  3473. #ifdef IKS_OPTION
  3474.     { "kermit", TELOPT_KERMIT, 0 },
  3475. #else
  3476.     { "kermit", TELOPT_KERMIT, CM_INV },
  3477. #endif /* IKS_OPTION */
  3478.     { "lflow",  TELOPT_LFLOW, CM_INV },
  3479.     { "logout", TELOPT_LOGOUT, CM_INV },
  3480. #ifdef CK_NAWS
  3481.     { "naws", TELOPT_NAWS, 0 },
  3482. #else
  3483.     { "naws", TELOPT_NAWS, CM_INV },
  3484. #endif /* CK_NAWS */
  3485. #ifdef CK_ENVIRONMENT
  3486.     { "new-environment", TELOPT_NEWENVIRON,  0 },
  3487. #else
  3488.     { "new-environment", TELOPT_NEWENVIRON,  CM_INV },
  3489. #endif /* CK_ENVIRONMENT */
  3490.     { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT,  CM_INV },
  3491.     { "pragma-logon",    TELOPT_PRAGMA_LOGON,  CM_INV },
  3492.     { "pragma-sspi",     TELOPT_SSPI_LOGON,  CM_INV },
  3493.     { "sak",   TELOPT_IBM_SAK, CM_INV },
  3494. #ifdef CK_SNDLOC
  3495.     { "send-location",   TELOPT_SNDLOC,  0 },
  3496. #else
  3497.     { "send-location",   TELOPT_SNDLOC,  CM_INV },
  3498. #endif /* CK_SNDLOC */
  3499.     { "sga", TELOPT_SGA, 0 },
  3500. #ifdef CK_SSL
  3501.     { "start-tls",       TELOPT_START_TLS,  0 },
  3502. #else
  3503.     { "start-tls",       TELOPT_START_TLS,  CM_INV },
  3504. #endif /* CK_SSL */
  3505.     { "ttype", TELOPT_TTYPE, 0 },
  3506. #ifdef CK_ENVIRONMENT
  3507.     { "xdisplay-location", TELOPT_XDISPLOC, 0 },
  3508. #else
  3509.     { "xdisplay-location", TELOPT_XDISPLOC, CM_INV },
  3510. #endif /* CK_ENVIRONMENT */
  3511.     { "", 0, 0 }
  3512. };
  3513. static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1;
  3514.  
  3515. static struct keytab tnsbopts[] = {
  3516. #ifdef CK_NAWS
  3517.     { "naws", TELOPT_NAWS, 0 },
  3518. #endif /* CK_NAWS */
  3519.     { "", 0, 0 }
  3520. };
  3521. static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1;
  3522. #endif /* TNCODE */
  3523.  
  3524. #ifdef TCPSOCKET
  3525. #ifndef NOPUSH
  3526. #ifdef SYSFTP
  3527. int
  3528. doftp() {                /* (External) FTP command */
  3529.     char *p, *f;            /* (See doxftp() for internal one) */
  3530.     int x;
  3531.  
  3532.     if (network)            /* If we have a current connection */
  3533.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3534.     else *line = '\0';            /* as default host */
  3535.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3536.       if (*p == ':') { *p = '\0'; break; }
  3537.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3538.       return(x);
  3539.     if (nopush) {
  3540.         printf("?Sorry, FTP command disabled\n");
  3541.         return(success = 0);
  3542.     }
  3543. /* Construct FTP command */
  3544. #ifdef VMS
  3545. #ifdef MULTINET                /* TGV MultiNet */
  3546.     ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL);
  3547. #else
  3548.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3549. #endif /* MULTINET */
  3550. #else                    /* Not VMS */
  3551. #ifdef OS2ORUNIX
  3552. #ifndef NOFTP
  3553.     f = ftpapp;
  3554.     if (!f) f = "";
  3555.     if (!f[0]) f = "ftp";
  3556.     ckmakmsg(line,LINBUFSIZ,f," ",s,NULL);
  3557. #ifdef OS2
  3558.     p = line + strlen(ftpapp);
  3559.     while (p != line) {
  3560.         if (*p == '/') *p = '\\';
  3561.         p--;
  3562.     }
  3563. #endif /* OS2 */
  3564. #else /* NOFTP */
  3565.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3566. #endif /* NOFTP */
  3567. #else /* OS2ORUNIX */
  3568.     ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3569. #endif /* OS2ORUNIX */
  3570. #endif /* VMS */
  3571.     conres();                /* Make console normal  */
  3572. #ifdef DEC_TCPIP
  3573.     printf("\n");            /* Prevent prompt-stomping */
  3574. #endif /* DEC_TCPIP */
  3575.     x = zshcmd(line);
  3576.     concb((char)escape);
  3577.     return(success = x);
  3578. }
  3579. #endif /* SYSFTP */
  3580.  
  3581. int
  3582. doping() {                /* PING command */
  3583.     char *p;                /* just runs ping program */
  3584.     int x;
  3585.  
  3586.     if (network)            /* If we have a current connection */
  3587.       ckstrncpy(line,ttname,LINBUFSIZ);    /* get the host name */
  3588.     else *line = '\0';            /* as default host to be pinged. */
  3589.     for (p = line; *p; p++)        /* Remove ":service" from end. */
  3590.       if (*p == ':') { *p = '\0'; break; }
  3591.     if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3592.       return(x);
  3593.     if (nopush) {
  3594.         printf("?Sorry, PING command disabled\n");
  3595.         return(success = 0);
  3596.     }
  3597.  
  3598.     /* Construct PING command */
  3599. #ifdef VMS
  3600. #ifdef MULTINET                /* TGV MultiNet */
  3601.     ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL);
  3602. #else
  3603.     ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */
  3604. #endif /* MULTINET */
  3605. #else                    /* Not VMS */
  3606.     ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL);
  3607. #endif /* VMS */
  3608.     conres();                /* Make console normal  */
  3609. #ifdef DEC_TCPIP
  3610.     printf("\n");            /* Prevent prompt-stomping */
  3611. #endif /* DEC_TCPIP */
  3612.     x = zshcmd(line);
  3613.     concb((char)escape);
  3614.     return(success = x);
  3615. }
  3616. #endif /* NOPUSH */
  3617. #endif /* TCPSOCKET */
  3618.  
  3619. static VOID
  3620. doend(x) int x; {
  3621. #ifndef NOSPL
  3622.     /* Pop from all FOR/WHILE/XIF/SWITCH's */
  3623.     debug(F101,"doend maclvl 1","",maclvl);
  3624.     while ((maclvl > 0) &&
  3625.        (m_arg[maclvl-1][0]) &&
  3626.        (cmdstk[cmdlvl].src == CMD_MD) &&
  3627.        (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  3628.         !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  3629.         !strncmp(m_arg[maclvl-1][0],"_whi",4) ||
  3630.         !strncmp(m_arg[maclvl-1][0],"_swi",4))) {
  3631.     debug(F110,"END popping",m_arg[maclvl-1][0],0);
  3632.     dogta(XXPTA);            /* Put args back */
  3633.     popclvl();            /* Pop up two levels */
  3634.     popclvl();
  3635.     debug(F101,"doend maclvl 2","",maclvl);
  3636.     }
  3637.     if (maclvl > -1) {
  3638.     if (mrval[maclvl])        /* Free previous retval if any */
  3639.       free(mrval[maclvl]);
  3640.     mrval[maclvl] = malloc(16);    /* Room for up to 15 digits */
  3641.     if (mrval[maclvl])        /* Record current retval */
  3642.       ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL);
  3643.     }
  3644. #endif /* NOSPL */
  3645.     popclvl();                /* Now pop out of macro or TAKE file */
  3646. #ifndef NOSPL
  3647. #ifdef DEBUG
  3648.     if (deblog) {
  3649.     debug(F101,"END maclvl 3","",maclvl);
  3650.     debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl);
  3651.     debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1);
  3652.     }
  3653. #endif /* DEBUG */
  3654. #endif /* NOSPL */
  3655. }
  3656.  
  3657. #ifdef CKROOT
  3658. int
  3659. dochroot() {
  3660.     if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) {
  3661.     if (x == -3) {
  3662.         printf("?Directory name required\n");
  3663.         return(-9);
  3664.     }
  3665.     return(x);
  3666.     }
  3667.     ckstrncpy(line,s,LINBUFSIZ);
  3668.     s = line;
  3669.     if ((x = cmcfm()) < 0) return(x);
  3670.     s = brstrip(s);
  3671.     x = zsetroot(s);
  3672.     if (x < 0) {
  3673.     char * m = NULL;
  3674.     switch (x) {
  3675.       case -1:
  3676.       case -2: m = "Not a directory"; break;
  3677.       case -3: m = "Internal error"; break;
  3678.       case -4: m = "Access denied"; break;
  3679.       case -5: m = "Off limits"; break;
  3680.     }
  3681.     if (m) printf("%s: \"%s\"\n", m, s);
  3682.     return(m ? -9 : -2);
  3683.     } else {
  3684.     nopush = 1;
  3685.     return(success = 1);
  3686.     }
  3687. }
  3688. #endif /* CKROOT */
  3689.  
  3690. #ifndef NOXFER
  3691. static char * asnbuf = NULL;        /* As-name buffer pointer */
  3692.  
  3693. char sndxnam[] = { "_array_x_" };    /* (with replaceable x!) */
  3694.  
  3695. /*
  3696.   The new SEND command, replacing BSEND, CSEND, PSEND, etc etc.
  3697.   Call with cx = top-level keyword value.  Returns:
  3698.     < 0  On parse error.
  3699.     0    On other type of failure (e.g. requested operation not allowed).
  3700.     1    On success with sstate set to 's' so protocol will begin.
  3701. */
  3702.  
  3703. /*  D O X S E N D  --  Parse SEND and related commands with switches  */
  3704.  
  3705. int
  3706. doxsend(cx) int cx; {
  3707.     int c, i, n, wild, confirmed = 0;    /* Workers */
  3708.     int x, y;                /* of the world... */
  3709.     int getval = 0;            /* Whether to get switch value */
  3710.     extern char * snd_move;        /* Directory to move sent files to */
  3711.     extern char * snd_rename;        /* What to rename sent files to */
  3712.     extern char * filefile;        /* File containing filenames to send */
  3713.     extern int xfiletype;        /* Send only text (or binary) files */
  3714.     extern struct keytab pathtab[];    /* PATHNAMES option keywords */
  3715.     extern int npathtab;        /* How many of them */
  3716.     extern int recursive;        /* Recursive directory traversal */
  3717.     extern int rprintf;            /* REMOTE PRINT flag */
  3718.     extern int fdispla;            /* TRANSFER DISPLAY setting */
  3719.     extern int skipbup;            /* Skip backup files when sending */
  3720.     struct stringint {            /* Temporary array for switch values */
  3721.     char * sval;
  3722.     int ival;
  3723.     } pv[SND_MAX+1];
  3724.     struct FDB sf, sw, fl, cm;        /* FDBs for each parse function */
  3725.     int mlist = 0;            /* Flag for MSEND or MMOVE */
  3726.     char * m;                /* For making help messages */
  3727.     extern struct keytab protos[];    /* File transfer protocols */
  3728.     extern int xfrxla, g_xfrxla, nprotos;
  3729.     extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */
  3730.     extern char sndnbefore[], sndnafter[];
  3731.     extern long sndsmaller, sndlarger, calibrate;
  3732. #ifndef NOSPL
  3733.     int range[2];            /* Array range */
  3734.     char ** ap = NULL;            /* Array pointer */
  3735.     int arrayx = -1;            /* Array index */
  3736. #endif /* NOSPL */
  3737.  
  3738. #ifdef NEWFTP
  3739.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  3740.     if (cx == XXMAI) {
  3741.         printf("?Sorry, No MAIL with FTP\n");
  3742.         return(-9);
  3743.     }
  3744.     return(doftpput(cx,0));
  3745.     }
  3746. #endif /* NEWFTP */
  3747.  
  3748.     for (i = 0; i <= SND_MAX; i++) {    /* Initialize switch values */
  3749.     pv[i].sval = NULL;        /* to null pointers */
  3750.     pv[i].ival = -1;        /* and -1 int values */
  3751.     }
  3752. #ifndef NOSPL
  3753.     range[0] = -1;
  3754.     range[1] = -1;
  3755.     sndxin = -1;            /* Array index */
  3756. #endif /* NOSPL */
  3757.     sndarray = NULL;            /* Array pointer */
  3758.  
  3759. #ifdef UNIXOROSK
  3760.     g_matchdot = matchdot;        /* Match dot files */
  3761. #endif /* UNIXOROSK */
  3762.     g_recursive = recursive;        /* Recursive sending */
  3763.     recursive = 0;            /* Save global value, set local */
  3764.     debug(F101,"xsend entry fncnv","",fncnv);
  3765.  
  3766.     /* Preset switch values based on top-level command that called us */
  3767.  
  3768.     switch (cx) {
  3769.       case XXMSE:            /* MSEND */
  3770.     mlist = 1; break;
  3771.       case XXCSEN:            /* CSEND */
  3772.     pv[SND_CMD].ival = 1; break;
  3773.       case XXMMOVE:            /* MMOVE */
  3774.     mlist = 1;
  3775.       case XXMOVE:            /* MOVE */
  3776.     pv[SND_DEL].ival = 1; break;
  3777.       case XXRSEN:            /* RESEND */
  3778.     pv[SND_BIN].ival = 1;        /* Implies /BINARY */
  3779.     pv[SND_RES].ival = 1; break;
  3780.       case XXMAI:            /* MAIL */
  3781.     pv[SND_MAI].ival = 1; break;
  3782.     }
  3783.  
  3784.     /* Set up chained parse functions... */
  3785.  
  3786.     cmfdbi(&sw,                /* First FDB - command switches */
  3787.        _CMKEY,            /* fcode */
  3788.        "Filename, or switch",    /* hlpmsg */
  3789.        "",                /* default */
  3790.        "",                /* addtl string data */
  3791. #ifdef NOMSEND
  3792.        nsndtab,            /* addtl numeric data 1: tbl size */
  3793. #else
  3794.        mlist ? nmsndtab : nsndtab,    /* addtl numeric data 1: tbl size */
  3795. #endif /* NOMSEND */
  3796.        4,                /* addtl numeric data 2: 4 = cmswi */
  3797.        xxstring,            /* Processing function */
  3798. #ifdef NOMSEND
  3799.        sndtab,            /* Keyword table */
  3800. #else
  3801.        mlist ? msndtab : sndtab,
  3802. #endif /* NOMSEND */
  3803.        &sf                /* Pointer to next FDB */
  3804.        );
  3805.     cmfdbi(&sf,                /* 2nd FDB - file to send */
  3806.        _CMIFI,            /* fcode */
  3807.        "File(s) to send",        /* hlpmsg */
  3808.        "",                /* default */
  3809.        "",                /* addtl string data */
  3810.        nolinks,            /* addtl numeric data 1 */
  3811.        0,                /* addtl numeric data 2 */
  3812.        xxstring,
  3813.        NULL,
  3814.        mlist ? &cm : &fl
  3815.        );
  3816.     cmfdbi(&fl,                /* 3rd FDB - command to send from */
  3817.        _CMFLD,            /* fcode */
  3818.        "Command",            /* hlpmsg */
  3819.        "",                /* default */
  3820.        "",                /* addtl string data */
  3821.        0,                /* addtl numeric data 1 */
  3822.        0,                /* addtl numeric data 2 */
  3823.        xxstring,
  3824.        NULL,
  3825.        &cm
  3826.        );
  3827.     cmfdbi(&cm,                /* 4th FDB - Confirmation */
  3828.        _CMCFM,            /* fcode */
  3829.        "",                /* hlpmsg */
  3830.        "",                /* default */
  3831.        "",                /* addtl string data */
  3832.        0,                /* addtl numeric data 1 */
  3833.        0,                /* addtl numeric data 2 */
  3834.        NULL,
  3835.        NULL,
  3836.        NULL
  3837.        );
  3838.  
  3839.     while (1) {                /* Parse 0 or more switches */
  3840.     x = cmfdb(&sw);            /* Parse something */
  3841.     debug(F101,"xsend cmfdb","",x);
  3842.     if (x < 0)            /* Error */
  3843.       goto xsendx;            /* or reparse needed */
  3844.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  3845.       break;
  3846. /*
  3847.   They gave a switch, but let's see how they terminated it.
  3848.   If they ended it with : or =, then we must parse a value.
  3849.   If they ended it with anything else, then we must NOT parse a value.
  3850. */
  3851.     c = cmgbrk();            /* Get break character */
  3852.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  3853.     if (getval && !(cmresult.kflags & CM_ARG)) {
  3854.         printf("?This switch does not take arguments\n");
  3855.         x = -9;
  3856.         goto xsendx;
  3857.     }
  3858.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  3859.         printf("?This switch requires an argument\n");
  3860.         x = -9;
  3861.         goto xsendx;
  3862.     }
  3863.     n = cmresult.nresult;        /* Numeric result = switch value */
  3864.     debug(F101,"xsend switch","",n);
  3865.  
  3866.     switch (n) {            /* Process the switch */
  3867.       case SND_CMD:            /* These take no args */
  3868.         if (nopush) {
  3869.         printf("?Sorry, system command access is disabled\n");
  3870.         x = -9;
  3871.         goto xsendx;
  3872.         }
  3873. #ifdef PIPESEND
  3874.         else if (sndfilter) {
  3875.         printf(
  3876. "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n");
  3877.         x = -9;
  3878.         goto xsendx;
  3879.         }
  3880. #endif /* PIPESEND */
  3881.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  3882.         pv[n].ival = 1;        /* Just set the flag */
  3883.         pv[SND_ARR].ival = 0;
  3884.         break;
  3885.  
  3886.       case SND_REC:            /* /RECURSIVE */
  3887.         recursive = 2;        /* Set the real variable */
  3888.         pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */
  3889.         pv[n].ival = 1;        /* Just set the flag */
  3890.         break;
  3891.  
  3892.       case SND_RES:            /* /RECOVER (resend) */
  3893.         pv[SND_ARR].ival = 0;
  3894.         pv[SND_BIN].ival = 1;    /* Implies /BINARY */
  3895.       case SND_NOB:            /* /NOBACKUP */
  3896.       case SND_DEL:            /* /DELETE */
  3897.       case SND_SHH:            /* /QUIET */
  3898.         pv[n].ival = 1;        /* Just set the flag */
  3899.         break;
  3900.  
  3901. #ifdef UNIXOROSK
  3902. /* Like recursive, these are set immediately because they affect cmifi() */
  3903.       case SND_DOT:            /* /DOTFILES */
  3904.         matchdot = 1;
  3905.         break;
  3906.       case SND_NOD:            /* /NODOTFILES */
  3907.         matchdot = 0;
  3908.         break;
  3909. #endif /* UNIXOROSK */
  3910.  
  3911.       /* File transfer modes - each undoes the others */
  3912.  
  3913.       case SND_BIN:            /* Binary */
  3914.       case SND_TXT:            /* Text */
  3915.       case SND_IMG:            /* Image */
  3916.       case SND_LBL:            /* Labeled */
  3917.         pv[SND_BIN].ival = 0;
  3918.         pv[SND_TXT].ival = 0;
  3919.         pv[SND_IMG].ival = 0;
  3920.         pv[SND_LBL].ival = 0;
  3921.         pv[n].ival = 1;
  3922.         break;
  3923.  
  3924. #ifdef CKSYMLINK
  3925.       case SND_LNK:
  3926.       case SND_NLK:
  3927.         nolinks = (n == SND_NLK) ? 2 : 0;
  3928.         cmfdbi(&sf,            /* Redo cmifi() */
  3929.            _CMIFI,        /* fcode */
  3930.            "File(s) to send",    /* hlpmsg */
  3931.            "",            /* default */
  3932.            "",            /* addtl string data */
  3933.            nolinks,        /* addtl numeric data 1 */
  3934.            0,            /* addtl numeric data 2 */
  3935.            xxstring,
  3936.            NULL,
  3937.            mlist ? &cm : &fl
  3938.            );
  3939.         break;
  3940. #endif /* CKSYMLINK */
  3941.  
  3942.       case SND_EXC:            /* Excludes */
  3943.         if (!getval) break;
  3944.         if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
  3945.         if (x == -3) {
  3946.             printf("?Pattern required\n");
  3947.             x = -9;
  3948.         }
  3949.         goto xsendx;
  3950.         }
  3951.         if (pv[n].sval) free(pv[n].sval);
  3952.         y = strlen(s);
  3953.         if (y > 256) {
  3954.         printf("?Pattern too long - 256 max\n");
  3955.         x = -9;
  3956.         goto xsendx;
  3957.         }
  3958.         pv[n].sval = malloc(y+1);
  3959.         if (pv[n].sval) {
  3960.         strcpy(pv[n].sval,s);    /* safe */
  3961.         pv[n].ival = 1;
  3962.         }
  3963.         break;
  3964.  
  3965.       case SND_MOV:            /* MOVE after */
  3966.       case SND_REN:            /* RENAME after */
  3967.         if (!getval) break;
  3968.         if ((x = cmfld(n == SND_MOV ?
  3969.        "device and/or directory for source file after sending" :
  3970.        "new name for source file after sending",
  3971.                "",
  3972.                &s,
  3973.                n == SND_MOV ? xxstring : NULL
  3974.                )) < 0) {
  3975.         if (x == -3) {
  3976.             printf("%s\n", n == SND_MOV ?
  3977.                "?Destination required" :
  3978.                "?New name required"
  3979.                );
  3980.             x = -9;
  3981.         }
  3982.         goto xsendx;
  3983.         }
  3984.         if (pv[n].sval) free(pv[n].sval);
  3985.         s = brstrip(s);
  3986.         y = strlen(s);
  3987.         if (y > 0) {
  3988.         pv[n].sval = malloc(y+1);
  3989.         if (pv[n].sval) {
  3990.             strcpy(pv[n].sval,s); /* safe */
  3991.             pv[n].ival = 1;
  3992.         }
  3993.         }
  3994.         break;
  3995.  
  3996.       case SND_SMA:            /* Smaller / larger than */
  3997.       case SND_LAR:
  3998.         if (!getval) break;
  3999.         if ((x = cmnum("Size in bytes","0",10,&y,xxstring)) < 0)
  4000.           goto xsendx;
  4001.         pv[n].ival = y;
  4002.         break;
  4003.  
  4004.       case SND_AFT:            /* Send /AFTER:date-time */
  4005.       case SND_BEF:            /* Send /BEFORE:date-time */
  4006.       case SND_NAF:            /* Send /NOT-AFTER:date-time */
  4007.       case SND_NBE:            /* Send /NOT-BEFORE:date-time */
  4008.         if (!getval) break;
  4009.         if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) {
  4010.         if (x == -3) {
  4011.             printf("?Date-time required\n");
  4012.             x = -9;
  4013.         }
  4014.         goto xsendx;
  4015.         }
  4016.         if (pv[n].sval) free(pv[n].sval);
  4017.         pv[n].sval = malloc((int)strlen(s)+1);
  4018.         if (pv[n].sval) {
  4019.         strcpy(pv[n].sval,s);    /* safe */
  4020.         pv[n].ival = 1;
  4021.         }
  4022.         break;
  4023.  
  4024.       case SND_MAI:            /* Send as mail (= MAIL) */
  4025. #ifdef IKSD
  4026.         if (inserver && !ENABLED(en_mai)) {
  4027.         printf("?Sorry, sending files as mail is disabled\n");
  4028.         return(-9);
  4029.         }
  4030. #endif /* IKSD */
  4031.         pv[n].ival = 1;
  4032.         if (!getval) break;
  4033.         if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) {
  4034.         if (x == -3) {
  4035.             printf("?address required\n");
  4036.             x = -9;
  4037.         }
  4038.         goto xsendx;
  4039.         }
  4040.         s = brstrip(s);
  4041.         if (pv[n].sval) free(pv[n].sval);
  4042.         pv[n].sval = malloc((int)strlen(s)+1);
  4043.         if (pv[n].sval)
  4044.           strcpy(pv[n].sval,s);    /* safe */
  4045.         break;
  4046.  
  4047.       case SND_PRI:            /* Send to be printed (REMOTE PRINT) */
  4048. #ifdef IKSD
  4049.         if (inserver && !ENABLED(en_mai)) {
  4050.         printf("?Sorry, sending files for printing is disabled\n");
  4051.         return(-9);
  4052.         }
  4053. #endif /* IKSD */
  4054.         pv[n].ival = 1;
  4055.         if (!getval) break;
  4056.         if ((x = cmfld("Print options","",&s,xxstring)) < 0)
  4057.           if (x != -3) goto xsendx;
  4058.         s = brstrip(s);
  4059.         if (pv[n].sval) free(pv[n].sval);
  4060.         pv[n].sval = malloc((int)strlen(s)+1);
  4061.         if (pv[n].sval)
  4062.           strcpy(pv[n].sval,s);    /* safe */
  4063.         break;
  4064.  
  4065.       case SND_ASN:            /* As-name */
  4066.         debug(F101,"xsend /as-name getval","",getval);
  4067.         if (!getval) break;
  4068.         if ((x = cmfld("Name to send under","",&s,NULL)) < 0) {
  4069.         if (x == -3) {
  4070.             printf("?name required\n");
  4071.             x = -9;
  4072.         }
  4073.         goto xsendx;
  4074.         }
  4075.         s = brstrip(s);
  4076.         if ((y = strlen(s)) > 0) {
  4077.         if (pv[n].sval) free(pv[n].sval);
  4078.         pv[n].sval = malloc(y+1);
  4079.         if (pv[n].sval) {
  4080.             strcpy(pv[n].sval,s); /* safe */
  4081.             pv[n].ival = 1;
  4082.         }
  4083.         }
  4084.         break;
  4085.  
  4086.       case SND_STA:            /* Starting position (= PSEND) */
  4087.         if (!getval) break;
  4088.         if ((x = cmnum("0-based position","0",10,&y,xxstring)) < 0)
  4089.           goto xsendx;
  4090.         pv[n].ival = y;
  4091.         break;
  4092.  
  4093.       case SND_PRO:            /* Protocol to use */
  4094.         if (!getval) break;
  4095.         if ((x = cmkey(protos,nprotos,"File-transfer protocol","",
  4096.                xxstring)) < 0) {
  4097.         if (x == -3) {
  4098.             printf("?name of protocol required\n");
  4099.             x = -9;
  4100.         }
  4101.         goto xsendx;
  4102.         }
  4103.         pv[n].ival = x;
  4104.         break;
  4105.  
  4106. #ifdef PIPESEND
  4107.       case SND_FLT:            /* Filter */
  4108.         debug(F101,"xsend /filter getval","",getval);
  4109.         if (!getval) break;
  4110.         if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) {
  4111.         if (x == -3)
  4112.           s = "";
  4113.         else
  4114.           goto xsendx;
  4115.         }
  4116.         s = brstrip(s);
  4117.         y = strlen(s);
  4118.         for (x = 0; x < y; x++) {    /* Make sure they included "\v(...)" */
  4119.         if (s[x] != '\\') continue;
  4120.         if (s[x+1] == 'v') break;
  4121.         }
  4122.         if (x == y) {
  4123.         printf(
  4124.         "?Filter must contain a replacement variable for filename.\n"
  4125.                );
  4126.         x = -9;
  4127.         goto xsendx;
  4128.         }
  4129.         pv[n].ival = 1;
  4130.         if (pv[n].sval) {
  4131.         free(pv[n].sval);
  4132.         pv[n].sval = NULL;
  4133.         }
  4134.         if ((y = strlen(s)) > 0) {
  4135.         if ((pv[n].sval = malloc(y+1)))
  4136.           strcpy(pv[n].sval,s);    /* safe */
  4137.         }
  4138.         break;
  4139. #endif /* PIPESEND */
  4140.  
  4141.       case SND_PTH:            /* Pathnames */
  4142.         if (!getval) {
  4143.         pv[n].ival = PATH_REL;
  4144.         break;
  4145.         }
  4146.         if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0)
  4147.           goto xsendx;
  4148.         pv[n].ival = x;
  4149.         break;
  4150.  
  4151.       case SND_NAM:            /* Filenames */
  4152.         if (!getval) break;
  4153.         if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0)
  4154.           goto xsendx;
  4155.         debug(F101,"xsend /filenames","",x);
  4156.         pv[n].ival = x;
  4157.         break;
  4158.  
  4159. #ifdef CALIBRATE
  4160.           case SND_CAL:            /* /CALIBRATE */
  4161.         if (getval) {
  4162.         if ((x = cmnum("number of Kbytes to send",
  4163.                "1024",10,&y,xxstring)) < 0)
  4164.           goto xsendx;
  4165.         } else
  4166.           y = 1024;
  4167.         pv[n].ival = y;
  4168.         pv[SND_ARR].ival = 0;
  4169.         break;
  4170. #endif /* CALIBRATE */
  4171.  
  4172.       case SND_FIL:            /* Name of file containing filnames */
  4173.         if (!getval) break;
  4174.         if ((x = cmifi("Name of file containing list of filenames",
  4175.                    "",&s,&y,xxstring)) < 0) {
  4176.         if (x == -3) {
  4177.             printf("?Filename required\n");
  4178.             x = -9;
  4179.         }
  4180.         goto xsendx;
  4181.         } else if (y) {
  4182.         printf("?Wildcards not allowed\n");
  4183.         x = -9;
  4184.         goto xsendx;
  4185.         }
  4186.         if (pv[n].sval)
  4187.           free(pv[n].sval);
  4188.         if (s) if (*s) {
  4189.         if ((pv[n].sval = malloc((int)strlen(s)+1))) {
  4190.             strcpy(pv[n].sval,s);
  4191.             pv[n].ival = 1;
  4192.             pv[SND_ARR].ival = 0;
  4193.         }
  4194.         }
  4195.         break;
  4196.  
  4197. #ifndef NOSPL
  4198.       case SND_ARR:            /* SEND /ARRAY: */
  4199.         if (!getval) break;
  4200.         ap = NULL;
  4201.         if ((x = cmfld("Array name (a single letter will do)",
  4202.                "",
  4203.                &s,
  4204.                NULL
  4205.                )) < 0) {
  4206.         if (x == -3)
  4207.           break;
  4208.         else
  4209.           return(x);
  4210.         }
  4211.         if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  4212.         printf("?Bad array: %s\n",s);
  4213.         return(-9);
  4214.         }
  4215.         if (!(ap = a_ptr[x])) {
  4216.         printf("?No such array: %s\n",s);
  4217.         return(-9);
  4218.         }
  4219.         pv[n].ival = 1;
  4220.         pv[SND_CMD].ival = 0;    /* Undo any conflicting ones... */
  4221.         pv[SND_RES].ival = 0;
  4222.         pv[SND_CAL].ival = 0;
  4223.         pv[SND_FIL].ival = 0;
  4224.         arrayx = x;
  4225.         break;
  4226. #endif /* NOSPL */
  4227.  
  4228.       case SND_XPA:            /* /TRANSPARENT */
  4229.         pv[n].ival = 1;
  4230.         break;
  4231.  
  4232.       case SND_TYP:            /* Only files of given type */
  4233.         if (!getval) break;
  4234.         if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0)
  4235.           goto xsendx;
  4236.         pv[n].ival = (x == 2) ? -1 : x;
  4237.         break;
  4238.  
  4239.       default:
  4240.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  4241.         x = -9;
  4242.         goto xsendx;
  4243.     }
  4244.     }
  4245.     debug(F101,"xsend cmresult fcode","",cmresult.fcode);
  4246.  
  4247. #ifdef COMMENT
  4248.     /* List switch parsing results in debug log */
  4249.     for (i = 0; i <= SND_MAX; i++) {
  4250.     ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL);
  4251.     debug(F111,line, pv[i].sval, pv[i].ival);
  4252.     }
  4253. #endif /* COMMENT */
  4254.  
  4255. /* Now we have all switches, plus maybe a filename or command, or nothing */
  4256.  
  4257. #ifdef PIPESEND
  4258.     if (protocol != PROTO_K && pv[SND_CMD].ival > 0) {
  4259.     printf("?Sorry, %s works only with Kermit protocol\n",
  4260.            (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND");
  4261.     x = -9;
  4262.     goto xsendx;
  4263.     }
  4264.     if (pv[SND_RES].ival > 0 ||    /* /RECOVER */
  4265.     pv[SND_STA].ival > 0) {    /* or /STARTING */
  4266.     if (sndfilter || pv[SND_FLT].ival > 0) {
  4267.         printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n");
  4268.         x = -9;
  4269.         goto xsendx;
  4270.     }
  4271.     }
  4272. #endif /* PIPESEND */
  4273.  
  4274.     cmarg = "";
  4275.     cmarg2 = "";
  4276.     line[0] = NUL;
  4277.     s = line;
  4278.     wild = 0;
  4279.  
  4280.     switch (cmresult.fcode) {        /* How did we get out of switch loop */
  4281.       case _CMIFI:            /* Input filename */
  4282.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
  4283.     if (pv[SND_ARR].ival > 0)
  4284.       cmarg2 = line;
  4285.     else
  4286.       wild = cmresult.nresult;    /* Wild flag */
  4287.     if (!recursive && !wild)
  4288.       nolinks = 0;
  4289.     break;
  4290.       case _CMFLD:            /* Field */
  4291.     /* Only allowed with /COMMAND and /ARRAY */
  4292.     if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) {
  4293. #ifdef CKROOT
  4294.         if (ckrooterr)
  4295.           printf("?Off limits: %s\n",cmresult.sresult);
  4296.         else
  4297. #endif /* CKROOT */
  4298.           printf("?%s - \"%s\"\n",
  4299.            iswild(cmresult.sresult) ?
  4300.            "No files match" : "File not found",
  4301.            cmresult.sresult
  4302.            );
  4303.         x = -9;
  4304.         goto xsendx;
  4305.     }
  4306.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  4307.     if (pv[SND_ARR].ival > 0)
  4308.       cmarg2 = line;
  4309.     break;
  4310.       case _CMCFM:            /* Confirmation */
  4311.     /* s = ""; */
  4312.     confirmed = 1;
  4313.     break;
  4314.       default:
  4315.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  4316.     x = -9;
  4317.     goto xsendx;
  4318.     }
  4319.     debug(F110,"xsend string",s,0);
  4320.     debug(F101,"xsend confirmed","",confirmed);
  4321.  
  4322.     /* Save and change protocol and transfer mode */
  4323.     /* Global values are restored in main parse loop */
  4324.  
  4325.     g_proto = protocol;            /* Save current global protocol */
  4326.     g_urpsiz = urpsiz;
  4327.     g_spsizf = spsizf;
  4328.     g_spsiz = spsiz;
  4329.     g_spsizr = spsizr;
  4330.     g_spmax = spmax;
  4331.     g_wslotr = wslotr;
  4332.     g_prefixing = prefixing;
  4333.     g_fncact = fncact;
  4334.     g_fncnv = fncnv;
  4335.     g_fnspath = fnspath;
  4336.     g_fnrpath = fnrpath;
  4337.     g_xfrxla = xfrxla;
  4338.  
  4339.     if (pv[SND_PRO].ival > -1) {    /* Change according to switch */
  4340.     protocol = pv[SND_PRO].ival;
  4341.         if (ptab[protocol].rpktlen > -1) /* copied from initproto() */
  4342.             urpsiz = ptab[protocol].rpktlen;
  4343.         if (ptab[protocol].spktflg > -1)
  4344.             spsizf = ptab[protocol].spktflg;
  4345.         if (ptab[protocol].spktlen > -1) {
  4346.             spsiz = ptab[protocol].spktlen;
  4347.             if (spsizf)
  4348.           spsizr = spmax = spsiz;
  4349.         }
  4350.         if (ptab[protocol].winsize > -1)
  4351.             wslotr = ptab[protocol].winsize;
  4352.         if (ptab[protocol].prefix > -1)
  4353.             prefixing = ptab[protocol].prefix;
  4354.         if (ptab[protocol].fnca > -1)
  4355.             fncact  = ptab[protocol].fnca;
  4356.         if (ptab[protocol].fncn > -1)
  4357.             fncnv   = ptab[protocol].fncn;
  4358.         if (ptab[protocol].fnsp > -1)
  4359.             fnspath = ptab[protocol].fnsp;
  4360.         if (ptab[protocol].fnrp > -1)
  4361.             fnrpath = ptab[protocol].fnrp;
  4362.     }
  4363.     debug(F101,"xsend protocol","",protocol);
  4364.  
  4365.     if (pv[SND_NOB].ival > -1) {    /* /NOBACKUP (skip backup file) */
  4366.     g_skipbup = skipbup;
  4367.     skipbup = 1;
  4368.     }
  4369.     if (pv[SND_REC].ival > 0)        /* /RECURSIVE */
  4370.       recursive = 2;
  4371.  
  4372.     if (pv[SND_TYP].ival > -1) {    /* /TYPE */
  4373.     xfiletype = pv[SND_TYP].ival;
  4374.     if (xfiletype == 2)
  4375.       xfiletype = -1;
  4376.     }
  4377.     g_binary = binary;            /* Save global transfer mode */
  4378. #ifdef PATTERNS
  4379.     g_patterns = patterns;        /* Save FILE PATTERNS setting */
  4380. #endif /* PATTERNS */
  4381.     if (pv[SND_BIN].ival > 0) {        /* Change according to switch */
  4382.     /* If they said /BINARY they mean /BINARY */
  4383.     patterns = 0;            /* So no pattern-based switching */
  4384.     g_xfermode = xfermode;        /* or automatic transfer mode */
  4385.     xfermode = XMODE_M;
  4386.     binary = XYFT_B;
  4387.     debug(F101,"doxsend /BINARY xfermode","",xfermode);
  4388.     } else if (pv[SND_TXT].ival > 0) {    /* Ditto for /TEXT */
  4389.     patterns = 0;
  4390.     g_xfermode = xfermode;
  4391.     xfermode = XMODE_M;
  4392.     binary = XYFT_T;
  4393.     debug(F101,"doxsend /TEXT xfermode","",xfermode);
  4394.     } else if (pv[SND_IMG].ival > 0) {
  4395. #ifdef VMS
  4396.     binary = XYFT_I;
  4397. #else
  4398.     binary = XYFT_B;
  4399. #endif /* VMS */
  4400.     }
  4401. #ifdef CK_LABELED
  4402.     else if (pv[SND_LBL].ival > 0) {
  4403.     binary = XYFT_L;
  4404.     }
  4405. #endif /* CK_LABELED */
  4406.     debug(F101,"xsend binary","",binary);
  4407.  
  4408.     if (pv[SND_XPA].ival > 0)        /* /TRANSPARENT */
  4409.       xfrxla = 0;            /* Don't translate character sets */
  4410.  
  4411.     /* Check for legal combinations of switches, filenames, etc */
  4412.  
  4413. #ifdef PIPESEND
  4414.     if (pv[SND_CMD].ival > 0) {    /* COMMAND - strip any braces */
  4415.     debug(F110,"SEND /COMMAND before stripping",s,0);
  4416.     s = brstrip(s);
  4417.     debug(F110,"SEND /COMMAND after stripping",s,0);
  4418.     if (!*s) {
  4419.         printf("?Sorry, a command to send from is required\n");
  4420.         x = -9;
  4421.         goto xsendx;
  4422.     }
  4423.     cmarg = s;
  4424.     }
  4425. #endif /* PIPESEND */
  4426.  
  4427. /* Set up /MOVE and /RENAME */
  4428.  
  4429.     if (pv[SND_DEL].ival > 0 &&
  4430.     (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) {
  4431.     printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n");
  4432.     x = -9;
  4433.     goto xsendx;
  4434.     }
  4435. #ifdef CK_TMPDIR
  4436.     if (pv[SND_MOV].ival > 0) {
  4437.     int len;
  4438.     char * p = pv[SND_MOV].sval;
  4439. #ifdef CK_LOGIN
  4440.     if (isguest) {
  4441.         printf("?Sorry, /MOVE-TO not available to guests\n");
  4442.         x = -9;
  4443.         goto xsendx;
  4444.     }
  4445. #endif /* CK_LOGIN */
  4446.     len = strlen(p);
  4447.     if (!isdir(p)) {        /* Check directory */
  4448. #ifdef CK_MKDIR
  4449.         char * s = NULL;
  4450.         s = (char *)malloc(len + 4);
  4451.         if (s) {
  4452.         strcpy(s,p);        /* safe */
  4453. #ifdef datageneral
  4454.         if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; }
  4455. #else
  4456.         if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; }
  4457. #endif /* datageneral */
  4458.         s[len++] = 'X';
  4459.         s[len] = NUL;
  4460.         x = zmkdir(s);
  4461.         free(s);
  4462.         if (x < 0) {
  4463.             printf("?Can't create \"%s\"\n",p);
  4464.             x = -9;
  4465.             goto xsendx;
  4466.         }
  4467.         }
  4468. #else
  4469.         printf("?Directory \"%s\" not found\n",p);
  4470.         x = -9;
  4471.         goto xsendx;
  4472. #endif /* CK_MKDIR */
  4473.     }
  4474.     makestr(&snd_move,p);
  4475.     }
  4476. #endif /* CK_TMPDIR */
  4477.  
  4478.     if (pv[SND_REN].ival > 0) {        /* /RENAME */
  4479.     char * p = pv[SND_REN].sval;
  4480. #ifdef CK_LOGIN
  4481.     if (isguest) {
  4482.         printf("?Sorry, /RENAME-TO not available to guests\n");
  4483.         x = -9;
  4484.         goto xsendx;
  4485.     }
  4486. #endif /* CK_LOGIN */
  4487.     if (!p) p = "";
  4488.     if (!*p) {
  4489.         printf("?New name required for /RENAME\n");
  4490.         x = -9;
  4491.         goto xsendx;
  4492.     }
  4493.     p = brstrip(p);
  4494. #ifndef NOSPL
  4495.     /* If name given is wild, rename string must contain variables */
  4496.     if (wild) {
  4497.         char * s = tmpbuf;
  4498.         x = TMPBUFSIZ;
  4499.         zzstring(p,&s,&x);
  4500.         if (!strcmp(tmpbuf,p)) {
  4501.         printf(
  4502.     "?/RENAME for file group must contain variables such as \\v(filename)\n"
  4503.                );
  4504.         x = -9;
  4505.         goto xsendx;
  4506.         }
  4507.     }
  4508. #endif /* NOSPL */
  4509.     makestr(&snd_rename,p);
  4510.     }
  4511.  
  4512. /* Handle /RECOVER and /START */
  4513.  
  4514. #ifdef CK_RESEND
  4515.     if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek
  4516. #ifdef PATTERNS
  4517.     && !patterns
  4518. #else
  4519. #ifdef VMS
  4520. /* VMS sets text/binary automatically later when it opens the file */
  4521.     && 0
  4522. #endif /* VMS */
  4523. #endif /* PATTERNS */
  4524.     ) {
  4525.     printf("?Sorry, /BINARY required\n");
  4526.     x = -9;
  4527.     goto xsendx;
  4528.     }
  4529.     if (pv[SND_STA].ival > 0) {        /* /START */
  4530.     if (wild) {
  4531.         printf("?Sorry, wildcards not permitted with /START\n");
  4532.         x = -9;
  4533.         goto xsendx;
  4534.     }
  4535.     if (sizeof(int) < 4) {
  4536.         printf("?Sorry, this command needs 32-bit integers\n");
  4537.         x = -9;
  4538.         goto xsendx;
  4539.     }
  4540. #ifdef CK_XYZ
  4541.     if (protocol != PROTO_K) {
  4542.         printf("?Sorry, SEND /START works only with Kermit protocol\n");
  4543.         x = -9;
  4544.         goto xsendx;
  4545.     }
  4546. #endif /* CK_XYZ */
  4547.     }
  4548. #ifdef CK_XYZ
  4549.     if (pv[SND_RES].ival > 0) {
  4550.     if (protocol != PROTO_K && protocol != PROTO_Z) {
  4551.         printf(
  4552.     "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n"
  4553.            );
  4554.         x = -9;
  4555.         goto xsendx;
  4556.     }
  4557.     }
  4558. #endif /* CK_XYZ */
  4559. #endif /* CK_RESEND */
  4560.  
  4561.     if (protocol == PROTO_K) {
  4562.     if ((pv[SND_MAI].ival > 0 ||    /* MAIL */
  4563.          pv[SND_PRI].ival > 0 ||    /* PRINT */
  4564.          pv[SND_RES].ival > 0    /* RESEND */
  4565.          ) &&
  4566.         (!atdiso || !atcapr)) {    /* Disposition attribute off? */
  4567.         printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n");
  4568.         x = -9;
  4569.         goto xsendx;
  4570.     }
  4571.     }
  4572.  
  4573. #ifdef CK_XYZ
  4574.     if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) {
  4575.     printf(
  4576. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  4577.            );
  4578.     x = -9;
  4579.     goto xsendx;
  4580.     }
  4581. #endif /* CK_XYZ */
  4582.  
  4583.     if (!confirmed) {            /* CR not typed yet, get more fields */
  4584.     char *m;
  4585.     if (mlist) {            /* MSEND or MMOVE */
  4586.         nfils = 0;            /* We already have the first one */
  4587. #ifndef NOMSEND
  4588.         msfiles[nfils++] = line;    /* Store pointer */
  4589.         lp = line + (int)strlen(line) + 1; /* Point past it */
  4590.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4591.         while (1) {            /* Get more filenames */
  4592.         char *p;
  4593.         if ((x = cmifi("Names of files to send, separated by spaces",
  4594.                    "", &s,&y,xxstring)) < 0) {
  4595.             if (x != -3)
  4596.               goto xsendx;
  4597.             if ((x = cmcfm()) < 0)
  4598.               goto xsendx;
  4599.             break;
  4600.         }
  4601.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  4602.         p = lp;            /* remember pointer, */
  4603.         while ((*lp++ = *s++))    /* and copy it into buffer */
  4604.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  4605.               printf("?MSEND list too long\n");
  4606.               line[0] = NUL;
  4607.               x = -9;
  4608.               goto xsendx;
  4609.           }
  4610.         debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4611.         if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */
  4612. #ifdef ZFNQFP
  4613.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  4614.         p = tmpbuf;
  4615. #endif /* ZFNQFP */
  4616.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  4617.             strcat(fspec,p);    /* safe */
  4618.             strcat(fspec," ");    /* safe */
  4619.         } else
  4620. #ifdef COMMENT
  4621.           printf("WARNING - \\v(filespec) buffer overflow\n");
  4622. #else
  4623.           debug(F101,"doxsend filespec buffer overflow","",0);
  4624. #endif /* COMMENT */
  4625.         }
  4626. #endif /* NOMSEND */
  4627.     } else {            /* Regular SEND */
  4628.         char *p; int y;
  4629.         nfils = -1;
  4630.         if (pv[SND_MAI].ival > 0)
  4631.           m = (pv[SND_MAI].sval) ?
  4632.         "e-mail address (optional)" :
  4633.           "e-mail address (required)";
  4634.         else if (pv[SND_PRI].ival > 0)
  4635.           m = "printer options (optional)";
  4636.         else if (wild)
  4637.           m =
  4638. "\nOptional as-name template containing replacement variables \
  4639. like \\v(filename)";
  4640.         else
  4641.           m = "Optional name to send it with";
  4642.         if ((x = cmtxt(m,"",&p,NULL)) < 0)
  4643.           goto xsendx;
  4644.         if (!p) p = "";
  4645.         if (*p) {            /* If some text was given... */
  4646.         p = brstrip(p);        /* Replace /AS-NAME: value if any */
  4647.         if ((y = strlen(p)) > 0) {
  4648.                     if (pv[SND_MAI].ival > 0) {
  4649.                         makestr(&pv[SND_MAI].sval, p);
  4650.                     } else {
  4651.             if (pv[SND_ASN].sval) free(pv[SND_ASN].sval);
  4652.             pv[SND_ASN].sval = malloc(y+1);
  4653.             if (pv[SND_ASN].sval) {
  4654.                 strcpy(pv[SND_ASN].sval,p);    /* safe */
  4655.                 pv[SND_ASN].ival = 1;
  4656.             }
  4657.             }
  4658.         }
  4659.         }
  4660.     }
  4661.     }
  4662.     /* Set cmarg2 from as-name, however we got it. */
  4663.  
  4664.     if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) {
  4665.     int x;
  4666.     x = strlen(line);
  4667.     ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1);
  4668.     cmarg2 = line+x+2;
  4669.     debug(F110,"doxsend cmarg2",cmarg2,0);
  4670.     }
  4671.  
  4672. #ifndef NOFRILLS
  4673.     if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) {
  4674.     printf("Sorry, /MAIL and /PRINT are conflicting options\n");
  4675.     x = -9;
  4676.     goto xsendx;
  4677.     }
  4678.     n = 0;                /* /MAIL or /PRINT? */
  4679.     if (pv[SND_MAI].ival > 0)
  4680.       n = SND_MAI;
  4681.     else if (pv[SND_PRI].ival > 0)
  4682.       n = SND_PRI;
  4683.     if (n) {                /* Yes... */
  4684. #ifdef DEBUG
  4685.     char * p;
  4686.     if (n == SND_MAI)
  4687.       p = "/MAIL";
  4688.     else
  4689.       p = "/PRINT";
  4690.     debug(F111,"xsend",p,n);
  4691. #endif /* DEBUG */
  4692. #ifdef CK_XYZ
  4693.     if (protocol != PROTO_K) {
  4694.         printf("Sorry, %s available only with Kermit protocol\n",
  4695.            (n == SND_MAI) ? "/MAIL" : "/PRINT"
  4696.            );
  4697.         x = -9;
  4698.         goto xsendx;
  4699.     }
  4700. #endif /* CK_XYZ */
  4701.     debug(F101,"xsend print/mail wild","",wild);
  4702.     *optbuf = NUL;            /* Wipe out any old options */
  4703.     s = pv[n].sval;            /* mail address or print switch val */
  4704.     if (!s) s = "";
  4705.     debug(F110,"doxsend mail address or printer options",s,0);
  4706.     if (n == SND_MAI && !*s) {
  4707.         printf("?E-mail address required\n");
  4708.         x = -9;
  4709.         goto xsendx;
  4710.     } else if ((int)strlen(s) > 94) { /* Ensure legal size */
  4711.         printf("?%s too long\n",
  4712.            (n == SND_MAI) ?
  4713.            "E-mail address" :
  4714.            "Print option string"
  4715.            );
  4716.         x = -9;
  4717.         goto xsendx;
  4718.     }
  4719.     ckstrncpy(optbuf,s,OPTBUFLEN);    /* OK, copy to option buffer */
  4720.     cmarg = line;            /* File to send */
  4721.     if (n == SND_MAI) {
  4722.         debug(F110,"xsend mailing",cmarg,0);
  4723.         debug(F110,"xsend address:",optbuf,0);
  4724.         rmailf = 1;
  4725.     } else {
  4726.         debug(F110,"xsend printing",cmarg,0);
  4727.         debug(F110,"xsend options",optbuf,0);
  4728.         rprintf = 1;
  4729.     }
  4730.     }
  4731. #endif /* NOFRILLS */
  4732.  
  4733. #ifdef CALIBRATE
  4734.     if (pv[SND_CAL].ival > 0) {        /* Handle /CALIBRATE */
  4735.     if (confirmed) {
  4736.         calibrate = pv[SND_CAL].ival * 1024L;
  4737.         sndsrc = -9;
  4738.         nfils = 1;
  4739.         wild = 0;
  4740. #ifndef NOMSEND
  4741.         addlist = 0;
  4742. #endif /* NOMSEND */
  4743.         ckstrncpy(line,"CALIBRATION",LINBUFSIZ);
  4744.         s = cmarg = line;
  4745.         if (!cmarg2) cmarg2 = "";
  4746.         debug(F110,"doxsend cmarg2 calibrate",cmarg2,0);
  4747.     } else if (line[0]) {
  4748.         calibrate = 0L;
  4749.         pv[SND_CAL].ival = 0L;
  4750.     }
  4751.     }
  4752. #endif /* CALIBRATE */
  4753.  
  4754.     if (pv[SND_FIL].ival > 0) {
  4755.     if (confirmed && !calibrate) {
  4756.         if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) {
  4757.         debug(F110,"xsend can't open",pv[SND_FIL].sval,0);
  4758.         printf("?Failure to open %s\n",filefile);
  4759.         x = -9;
  4760.         goto xsendx;
  4761.         }
  4762.         makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */
  4763.         debug(F110,"xsend opened",filefile,0);
  4764.         wild = 1;
  4765.     }
  4766.     }
  4767.  
  4768.     /* SEND alone... */
  4769.  
  4770. #ifndef NOSPL
  4771.     if (confirmed && pv[SND_ARR].ival > 0) {
  4772.     if (!*cmarg2) {
  4773.         sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE);
  4774.         cmarg2 = sndxnam;
  4775.     }
  4776.     cmarg = "";
  4777.     goto sendend;
  4778.     }
  4779. #endif /* NOSPL */
  4780.  
  4781.     if (confirmed && !line[0] && !filefile && !calibrate) {
  4782. #ifndef NOMSEND
  4783.     if (filehead) {            /* OK if we have a SEND-LIST */
  4784.         nfils = filesinlist;
  4785.         sndsrc = nfils;        /* Like MSEND */
  4786.         addlist = 1;        /* But using a different list... */
  4787.         filenext = filehead;
  4788.         goto sendend;
  4789.     }
  4790. #endif /* NOMSEND */
  4791.     printf("?Filename required but not given\n");
  4792.     x = -9;
  4793.     goto xsendx;
  4794.     }
  4795.  
  4796.     /* Not send-list or array */
  4797.  
  4798. #ifndef NOMSEND
  4799.     addlist = 0;            /* Don't use SEND-LIST. */
  4800.     filenext = NULL;
  4801. #endif /* NOMSEND */
  4802.  
  4803.     if (mlist) {            /* MSEND or MMOVE */
  4804. #ifndef NOMSEND
  4805.     cmlist = msfiles;        /* List of files to send */
  4806.     sndsrc = nfils;
  4807.     cmarg2 = "";
  4808.     sendstart = 0L;
  4809. #endif /* NOMSEND */
  4810. #ifdef PIPESEND
  4811.     pipesend = 0;
  4812. #endif /* PIPESEND */
  4813.     } else if (filefile) {        /* File contains list of filenames */
  4814.     s = "";
  4815.     cmarg = "";
  4816.     cmarg2 = "";
  4817.     line[0] = NUL;
  4818.     nfils = 1;
  4819.     sndsrc = 1;
  4820.  
  4821.     } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) {
  4822.  
  4823.     nfils = sndsrc = -1;    /* Not MSEND, MMOVE, /LIST, or /ARRAY */
  4824.     if (                /* or /COMMAND */
  4825.  
  4826. #ifndef NOFRILLS
  4827.         !rmailf && !rprintf        /* Not MAIL or PRINT */
  4828. #else
  4829.         1
  4830. #endif /* NOFRILLS */
  4831.         ) {
  4832.         int y = 1;
  4833.         if (!wild)
  4834.           y = zchki(s);
  4835.         if (y < 0) {
  4836.         printf("?Read access denied - \"%s\"\n", s);
  4837.         x = -9;
  4838.         goto xsendx;
  4839.         }
  4840.         if (s != line)        /* We might already have done this. */
  4841.           ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */
  4842.         else
  4843.           debug(F110,"doxsend line=s",line,0);
  4844.         cmarg = line;        /* File to send */
  4845.     }
  4846.     zfnqfp(cmarg,fspeclen,fspec);
  4847.     }
  4848.     if (!mlist) {            /* For all but MSEND... */
  4849. #ifdef PIPESEND
  4850.     if (pv[SND_CMD].ival > 0)    /* /COMMAND sets pipesend flag */
  4851.       pipesend = 1;
  4852.     debug(F101,"xsend /COMMAND pipesend","",pipesend);
  4853.     if (pipesend && filefile) {
  4854.         printf("?Invalid switch combination\n");
  4855.         x = -9;
  4856.         goto xsendx;
  4857.     }
  4858. #endif /* PIPESEND */
  4859.  
  4860. #ifndef NOSPL
  4861.     /* If as-name given and filespec is wild, as-name must contain variables */
  4862.     debug(F111,"doxsend cmarg2 wild",cmarg2,wild);
  4863.     if (wild && *cmarg2) {
  4864.         char * s = tmpbuf;
  4865.         x = TMPBUFSIZ;
  4866.         zzstring(cmarg2,&s,&x);
  4867.         if (!strcmp(tmpbuf,cmarg2)) {
  4868.         printf(
  4869.     "?As-name for file group must contain variables such as \\v(filename)\n"
  4870.                );
  4871.         x = -9;
  4872.         goto xsendx;
  4873.         }
  4874.     }
  4875. #endif /* NOSPL */
  4876.  
  4877.     /* Strip braces from as-name */
  4878.     debug(F110,"xsend cmarg2 before stripping",cmarg2,0);
  4879.     cmarg2 = brstrip(cmarg2);
  4880.     debug(F110,"xsend filename",cmarg,0);
  4881.     debug(F110,"xsend as-name",cmarg2,0);
  4882.  
  4883.     /* Copy as-name to a safe place */
  4884.  
  4885.     if (asnbuf) {
  4886.         free(asnbuf);
  4887.         asnbuf = NULL;
  4888.     }
  4889.     if ((y = strlen(cmarg2)) > 0) {
  4890.         asnbuf = (char *) malloc(y + 1);
  4891.         if (asnbuf) {
  4892.         strcpy(asnbuf,cmarg2);    /* safe */
  4893.         cmarg2 = asnbuf;
  4894.         } else cmarg2 = "";
  4895.     }
  4896.  
  4897. #ifdef CK_RESEND
  4898.     debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival);
  4899.     if (pv[SND_STA].ival > -1) {    /* /START position */
  4900.         if (wild) {
  4901.         printf("?/STARTING-AT may not be used with multiple files.\n");
  4902.         x = -9;
  4903.         goto xsendx;
  4904.         } else
  4905.           sendstart = pv[SND_STA].ival;
  4906.     } else
  4907.       sendstart = 0L;
  4908.     debug(F101,"xsend /STARTING","",sendstart);
  4909. #endif /* CK_RESEND */
  4910.     }
  4911.  
  4912. sendend:                /* Common successful exit */
  4913.     moving = 0;
  4914.     if (pv[SND_SHH].ival > 0) {        /* SEND /QUIET... */
  4915.     g_displa = fdispla;
  4916.     fdispla = 0;
  4917.     debug(F101,"xsend display","",fdispla);
  4918.     }
  4919.  
  4920. #ifndef NOSPL                /* SEND /ARRAY... */
  4921.     if (pv[SND_ARR].ival > 0) {
  4922.     if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */
  4923.     if (range[0] == -1)        /* If low end of range not specified */
  4924.       range[0] = 1;            /* default to 1 */
  4925.     if (range[1] == -1)        /* If high not specified */
  4926.       range[1] = a_dim[arrayx];    /* default to size of array */
  4927.     if ((range[0] < 0) ||        /* Check range */
  4928.         (range[0] > a_dim[arrayx]) ||
  4929.         (range[1] < range[0]) ||
  4930.         (range[1] > a_dim[arrayx])) {
  4931.         printf("?Bad array range - [%d:%d]\n",range[0],range[1]);
  4932.         x = -9;
  4933.         goto xsendx;
  4934.     }
  4935.     sndarray = ap;            /* Array pointer */
  4936.     sndxin = arrayx;        /* Array index */
  4937.     sndxlo = range[0];        /* Array range */
  4938.     sndxhi = range[1];
  4939.     sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  4940.  
  4941. #ifdef COMMENT
  4942.     printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */
  4943.            (sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  4944.     printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi);
  4945.     printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2);
  4946.     while ((x = agnbyte()) > -1) {
  4947.         putchar((char)x);
  4948.     }
  4949.     return(1);
  4950. #endif /* COMMENT */
  4951.     }
  4952. #endif /* NOSPL */
  4953.  
  4954.     if (pv[SND_ARR].ival < 1) {        /* File selection & disposition... */
  4955.  
  4956.     if (pv[SND_DEL].ival > 0)    /* /DELETE was specified */
  4957.       moving = 1;
  4958.     debug(F101,"xsend /DELETE","",moving);
  4959.     if (pv[SND_AFT].ival > 0)    /* Copy SEND criteria */
  4960.       ckstrncpy(sndafter,pv[SND_AFT].sval,19);
  4961.     if (pv[SND_BEF].ival > 0)
  4962.       ckstrncpy(sndbefore,pv[SND_BEF].sval,19);
  4963.     if (pv[SND_NAF].ival > 0)
  4964.       ckstrncpy(sndnafter,pv[SND_NAF].sval,19);
  4965.     if (pv[SND_NBE].ival > 0)
  4966.       ckstrncpy(sndnbefore,pv[SND_NBE].sval,19);
  4967.     if (pv[SND_EXC].ival > 0)
  4968.       makelist(pv[SND_EXC].sval,sndexcept,8);
  4969.     if (pv[SND_SMA].ival > -1)
  4970.       sndsmaller = pv[SND_SMA].ival;
  4971.     if (pv[SND_LAR].ival > -1)
  4972.       sndlarger = pv[SND_LAR].ival;
  4973.     if (pv[SND_NAM].ival > -1) {
  4974.         g_fncnv = fncnv;        /* Save global value */
  4975.         fncnv = pv[SND_NAM].ival;
  4976.         debug(F101,"xsend fncnv","",fncnv);
  4977.     }
  4978.     if (pv[SND_PTH].ival > -1) {
  4979.         g_spath = fnspath;        /* Save global values */
  4980.         fnspath = pv[SND_PTH].ival;
  4981. #ifndef NZLTOR
  4982.         if (fnspath != PATH_OFF) {
  4983.         g_fncnv = fncnv;    /* Bad bad... */
  4984.         fncnv = XYFN_C;
  4985.         }
  4986. #endif /* NZLTOR */
  4987.         debug(F101,"xsend fnspath","",fnspath);
  4988.         debug(F101,"xsend fncnv","",fncnv);
  4989.     }
  4990.     }
  4991.  
  4992. #ifdef PIPESEND
  4993.     if (pv[SND_FLT].ival > 0) {
  4994.     makestr(&sndfilter,pv[SND_FLT].sval);
  4995.     debug(F110,"xsend /FILTER", sndfilter, 0);
  4996.     }
  4997. #endif /* PIPESEND */
  4998.  
  4999. #ifdef CK_APC
  5000. /* MOVE not allowed in APCs */
  5001.     if (moving &&
  5002.     (apcactive == APC_LOCAL || apcactive == APC_REMOTE)
  5003.     && !(apcstatus & APC_UNCH))
  5004.       return(success = 0);
  5005. #endif /* CK_APC */
  5006. #ifdef IKS_OPTION
  5007.     if (
  5008. #ifdef CK_XYZ
  5009.         protocol == PROTO_K &&
  5010. #endif /* CK_XYZ */
  5011.         !iks_wait(KERMIT_REQ_START,1)) {
  5012.         printf("?A Kermit Server is not available to process this command.\n");
  5013.         printf("?Start a RECEIVE command to complement this command.\n");
  5014.     }
  5015. #endif /* IKS_OPTION */
  5016.  
  5017. #ifdef IKSD
  5018. #ifdef CK_LOGIN
  5019.     if (moving && inserver && isguest) {
  5020.         printf("?File deletion not allowed for guests.\n");
  5021.     return(-9);
  5022.     }
  5023. #endif /* CK_LOGIN */
  5024. #endif /* IKSD */
  5025.  
  5026.     sstate = 's';            /* Set start state to SEND */
  5027.     sndcmd = 1;
  5028. #ifdef CK_RESEND
  5029.     if (pv[SND_RES].ival > 0)        /* Send sendmode appropriately */
  5030.       sendmode = SM_RESEND;
  5031.     else if (pv[SND_STA].ival > 0)
  5032.       sendmode = SM_PSEND;
  5033.     else
  5034. #endif /* CK_RESEND */
  5035.     if (mlist)
  5036.       sendmode = SM_MSEND;
  5037.     else
  5038.       sendmode = SM_SEND;
  5039. #ifdef MAC
  5040.     what = W_SEND;
  5041.     scrcreate();
  5042. #endif /* MAC */
  5043.     if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */
  5044.     displa = 1;            /* turn on file transfer display */
  5045.     }
  5046.     x = 0;
  5047.  
  5048.   xsendx:                /* Common exit, including failure */
  5049.     debug(F101,"doxsend sndsrc","",sndsrc);
  5050.     for (i = 0; i <= SND_MAX; i++) {    /* Free malloc'd memory */
  5051.     if (pv[i].sval)
  5052.       free(pv[i].sval);
  5053.     }
  5054.     return(x);
  5055. }
  5056. #endif /* NOXFER */
  5057.  
  5058. #ifndef NOLOCAL
  5059. /*  D O X C O N N  --  CONNECT command parsing with switches */
  5060.  
  5061. #ifdef XLIMITS
  5062. #define XLIMORTRIGGER
  5063. #else
  5064. #ifdef CK_TRIGGER
  5065. #define XLIMORTRIGGER
  5066. #endif /* CK_TRIGGER */
  5067. #endif /*  XLIMITS */
  5068.  
  5069. #ifdef CKTIDLE
  5070. int tt_idlelimit = 0;            /* Terminal idle limit */
  5071. int tt_idleact = IDLE_RET;        /* Terminal idle action */
  5072. #endif /* CKTIDLE */
  5073.  
  5074. #ifdef OS2                /* K95 only: */
  5075. extern int
  5076.   tt_idlesnd_tmo;            /*   Idle interval */
  5077. int tt_timelimit = 0;            /*   Time limit, 0 = none */
  5078. extern char *                /* Parse results - strings: */
  5079.   tt_idlesnd_str;            /*   Idle string */
  5080. #endif /* OS2 */
  5081.  
  5082. #ifdef CK_TRIGGER
  5083. extern char *tt_trigger[];
  5084. extern CHAR *tt_trmatch[];
  5085. extern char *triggerval;
  5086. static char *g_tt_trigger[TRIGGERS];
  5087. #endif /* CK_TRIGGER */
  5088.  
  5089. #ifdef OS2
  5090. static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */
  5091. static int g_tt_idlelimit;
  5092. static char * g_tt_idlesnd_str;        /* global settings */
  5093. #endif /* OS2 */
  5094.  
  5095. static struct stringint {        /* Temporary array for switch values */
  5096.     char * sval;
  5097.     int ival;
  5098. } pv[CONN_MAX+1];
  5099.  
  5100. VOID
  5101. resconn() {
  5102.     int i;
  5103.  
  5104. #ifdef OS2
  5105.     tt_idlelimit   = g_tt_idlelimit;
  5106.     tt_idlesnd_tmo = g_tt_idlesnd_tmo;
  5107.     tt_timelimit   = g_tt_timelimit;
  5108.     tt_idlesnd_str = g_tt_idlesnd_str;
  5109. #endif /* OS2 */
  5110.  
  5111. #ifdef CK_TRIGGER
  5112.     for (i = 0; i < TRIGGERS; i++)
  5113.       tt_trigger[i] = g_tt_trigger[i];
  5114. #endif /* CK_TRIGGER */
  5115.  
  5116.     for (i = 0; i <= CONN_MAX; i++) {    /* Free malloc'd memory */
  5117.     if (pv[i].sval)
  5118.       free(pv[i].sval);
  5119.         pv[i].sval = NULL;
  5120.     }
  5121. }
  5122.  
  5123. int
  5124. doxconn(cx) int cx; {
  5125.     int c, i, n;            /* Workers */
  5126.     int x, y;
  5127.     int getval = 0;            /* Whether to get switch value */
  5128.     int async = 0;                      /* Make an async connect */
  5129.     struct FDB sw, cm;            /* FDBs for each parse function */
  5130.     extern FILE * tfile[];
  5131.     extern char * macp[];
  5132.  
  5133. #ifdef OS2
  5134.     g_tt_idlesnd_tmo = tt_idlesnd_tmo;    /* Save global settings */
  5135.     g_tt_timelimit   = tt_timelimit;
  5136.     g_tt_idlelimit   = tt_idlelimit;
  5137.     g_tt_idlesnd_str = tt_idlesnd_str;
  5138. #endif /* OS2 */
  5139.  
  5140. #ifdef CK_TRIGGER
  5141.     if (!tt_trigger[0]) {        /* First initialization */
  5142.     for (i = 1; i < TRIGGERS; i++)
  5143.       tt_trigger[i] = NULL;
  5144.     }
  5145.     for (i = 0; i < TRIGGERS; i++)
  5146.       g_tt_trigger[i] = tt_trigger[i];
  5147.     if (triggerval) {
  5148.     free(triggerval);
  5149.     triggerval = NULL;
  5150.     }
  5151. #endif /* CK_TRIGGER */
  5152.  
  5153.     for (i = 0; i <= CONN_MAX; i++) {    /* Initialize switch values */
  5154.     pv[i].sval = NULL;        /* to null pointers */
  5155.     pv[i].ival = -1;        /* and -1 int values */
  5156.     }
  5157.     if (cx == XXCQ)            /* CQ == CONNECT /QUIETLY */
  5158.       pv[CONN_NV].ival = 1;
  5159.  
  5160.     /* Set up chained parse functions... */
  5161.  
  5162.     cmfdbi(&sw,                /* First FDB - command switches */
  5163.        _CMKEY,            /* fcode */
  5164.        "Switch",            /* hlpmsg */
  5165.        "",                /* default */
  5166.        "",                /* addtl string data */
  5167.        nconntab,            /* addtl numeric data 1: tbl size */
  5168.        4,                /* addtl numeric data 2: 4 = cmswi */
  5169.        xxstring,            /* Processing function */
  5170.        conntab,            /* Keyword table */
  5171.        &cm                /* Pointer to next FDB */
  5172.        );
  5173.     cmfdbi(&cm,                /* 2nd FDB - Confirmation */
  5174.        _CMCFM,            /* fcode */
  5175.        "",                /* hlpmsg */
  5176.        "",                /* default */
  5177.        "",                /* addtl string data */
  5178.        0,                /* addtl numeric data 1 */
  5179.        0,                /* addtl numeric data 2 */
  5180.        NULL,
  5181.        NULL,
  5182.        NULL
  5183.        );
  5184.  
  5185.     while (1) {                /* Parse 0 or more switches */
  5186.     x = cmfdb(&sw);            /* Parse switch or confirmation */
  5187.     debug(F101,"doxconn cmfdb","",x);
  5188.     if (x < 0) {            /* Error */
  5189.         if (x == -9 || x == -2)
  5190.           printf("?No switches match - \"%s\"\n",atmbuf);
  5191.         goto xconnx;        /* or reparse needed */
  5192.     }
  5193.     if (cmresult.fcode != _CMKEY)    /* Break out if not a switch */
  5194.       break;
  5195.     c = cmgbrk();            /* Get break character */
  5196.     getval = (c == ':' || c == '='); /* to see how they ended the switch */
  5197.     if (getval && !(cmresult.kflags & CM_ARG)) {
  5198.         printf("?This switch does not take arguments\n");
  5199.         x = -9;
  5200.         goto xconnx;
  5201.     }
  5202.     if (!getval && (cmgkwflgs() & CM_ARG)) {
  5203.         printf("?This switch requires an argument\n");
  5204.         return(-9);
  5205.     }
  5206.     n = cmresult.nresult;        /* Numeric result = switch value */
  5207.     debug(F101,"doxconn switch","",n);
  5208.  
  5209.     switch (n) {            /* Process the switch */
  5210. #ifdef OS2
  5211.       case CONN_AS:            /* Asynchronous */
  5212.             pv[CONN_AS].ival = 1;
  5213.             pv[CONN_SY].ival = 0;
  5214.             break;
  5215.           case CONN_SY:                 /* Synchronous */
  5216.             pv[CONN_SY].ival = 1;
  5217.             pv[CONN_AS].ival = 0;
  5218.             break;
  5219. #endif /* OS2 */
  5220.       case CONN_NV:            /* Non-verbal */
  5221.         pv[n].ival = 1;
  5222.         break;
  5223. #ifdef XLIMITS
  5224.       case CONN_II:            /* Idle-interval */
  5225.       case CONN_IL:            /* Idle-limit */
  5226.       case CONN_TL:            /* Time-limit */
  5227.         if (!getval) break;
  5228.         if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
  5229.           goto xconnx;
  5230.         pv[n].ival = y;
  5231.         break;
  5232.       case CONN_IS:            /* Idle-string */
  5233. #endif /* XLIMITS */
  5234. #ifdef CK_TRIGGER
  5235.       case CONN_TS:            /* Trigger-string */
  5236. #endif /* CK_TRIGGER */
  5237. #ifdef XLIMORTRIGGER
  5238.         if (!getval) break;
  5239.         if ((x = cmfld("String (enclose in braces if it contains spaces)",
  5240.                "",&s,xxstring)) < 0) {
  5241.         if (x == -3) {
  5242.             printf("?String required\n");
  5243.             x = -9;
  5244.         }
  5245.         goto xconnx;
  5246.         }
  5247.         if (n != CONN_TS)
  5248.           s = brstrip(s);
  5249.         if ((y = strlen(s)) > 0) {
  5250.         if (pv[n].sval) free(pv[n].sval);
  5251.         pv[n].sval = malloc(y+1);
  5252.         if (pv[n].sval) {
  5253.             strcpy(pv[n].sval,s); /* safe */
  5254.             pv[n].ival = 1;
  5255.         }
  5256.         }
  5257.         break;
  5258. #endif /* XLIMORTRIGGER */
  5259.       default:
  5260.         printf("?Unexpected switch value - %d\n",cmresult.nresult);
  5261.         x = -9;
  5262.         goto xconnx;
  5263.     }
  5264.     }
  5265.     debug(F101,"doxconn cmresult.fcode","",cmresult.fcode);
  5266.     if (cmresult.fcode != _CMCFM) {
  5267.     printf("?Unexpected function code: %d\n",cmresult.fcode);
  5268.     x = -9;
  5269.     goto xconnx;
  5270.     }
  5271.  
  5272.     /* Command was confirmed so we can pre-pop command level. */
  5273.     /* This is so CONNECT module won't think we're executing a script */
  5274.     /* if CONNECT was the final command in the script. */
  5275.  
  5276.     if (cmdlvl > 0)
  5277.       prepop();
  5278.  
  5279. #ifdef OS2                /* Make results available globally */
  5280.     if (pv[CONN_IL].ival > -1)        /* Idle limit */
  5281.       tt_idlelimit = pv[CONN_IL].ival;
  5282.     if (pv[CONN_II].ival > -1)        /* Idle limit */
  5283.       tt_idlesnd_tmo = pv[CONN_II].ival;
  5284.     if (pv[CONN_IS].sval)        /* Idle string */
  5285.       if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1))
  5286.     strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */
  5287.     if (pv[CONN_TL].ival > -1)        /* Session limit */
  5288.       tt_timelimit = pv[CONN_TL].ival;
  5289.     async = (pv[CONN_AS].ival > 0 ||
  5290.              pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0;
  5291. #endif /* OS2 */
  5292.  
  5293. #ifdef CK_TRIGGER
  5294.     if (pv[CONN_TS].sval)        /* Trigger strings */
  5295.       makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS);
  5296.     for (i = 0; i < TRIGGERS; i++)    /* Trigger match pointers */
  5297.       tt_trmatch[i] = NULL;
  5298.     if (triggerval) {            /* Reset trigger value */
  5299.     free(triggerval);
  5300.     triggerval = NULL;
  5301.     }
  5302. #endif /* CK_TRIGGER */
  5303.  
  5304.     x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async);
  5305.     {
  5306.     int xx;
  5307.     debug(F101,"doxconn doconect returns","",x);
  5308.     if ((xx = ttchk()) < 0) dologend();
  5309.     debug(F101,"doxconn ttchk returns","",xx);
  5310.     }
  5311.  
  5312. #ifdef CK_TRIGGER
  5313.     debug(F111,"doxconn doconect triggerval",triggerval,x);
  5314. #endif /* CK_TRIGGER */
  5315.  
  5316.   xconnx:
  5317.     /* Back from CONNECT -- Restore global settings */
  5318.  
  5319.     if (!async)
  5320.       resconn();
  5321.  
  5322.     success = (x > 0) ? 1 : 0;
  5323.     return(x);
  5324. }
  5325. #endif /* NOLOCAL */
  5326.  
  5327. #ifdef ADDCMD
  5328. /* cx == XXADD or XXREMV */
  5329. /* fc == ADD_BIN or ADD_TXT */
  5330. static int
  5331. doadd(cx,fc) int cx, fc; {
  5332. #ifdef PATTERNS
  5333.     char * tmp[FTPATTERNS];
  5334.     char **p = NULL;
  5335.     int i, j, k, n = 0, x = 0, last;
  5336.  
  5337. #endif /* PATTERNS */
  5338.     if (cx != XXADD && cx != XXREMV) {
  5339.     printf("?Unexpected function code: %d\n",cx);
  5340.     return(-9);
  5341.     }
  5342. #ifdef PATTERNS
  5343.     while (n < FTPATTERNS) {        /* Collect new patterns */
  5344.     tmp[n] = NULL;
  5345.     if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
  5346.       break;
  5347.     ckstrncpy(line,s,LINBUFSIZ);
  5348.     s = brstrip(line);
  5349.     makestr(&(tmp[n++]),s);
  5350.     }
  5351.     if (x == -3)
  5352.       x = cmcfm();
  5353.     if (x < 0)
  5354.       goto xdoadd;
  5355.     p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */
  5356.     last = 0;
  5357.     for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */
  5358.     if (!p[i]) {
  5359.         last = i;
  5360.         break;
  5361.     }
  5362.     }
  5363.     if (cx == XXADD) {            /* Adding */
  5364.     if (last + n > FTPATTERNS) {    /* Check if too many */
  5365.         printf("?Too many patterns - %d is the maximum\n", FTPATTERNS);
  5366.         goto xdoadd;
  5367.     }
  5368.         for (i = 0; i < n; i++) {        /* Copy in the new ones. */
  5369.           for (j = 0, x = 0; x == 0 && j < last ; j++ )
  5370.             x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5371.           if (x == 0)
  5372.             makestr(&(p[last++]),tmp[i]);
  5373.         }
  5374.         makestr(&(p[last]),NULL);    /* Null-terminate the list */
  5375.         x = 1;
  5376.         goto xdoadd;                    /* Done */
  5377.     } else if (cx == XXREMV) {        /* Remove something(s) */
  5378.     int j, k;
  5379.     if (last == 0)                    /* List is empty */
  5380.       goto xdoadd;                    /* Nothing to remove */
  5381.     for (i = 0; i < n; i++) {            /* i = Patterns they typed */
  5382.         for (j = 0; j < last; j++) {        /* j = Patterns in list */
  5383.         /* Change this to ckstrcmp()... */
  5384.         if (filecase)
  5385.                   x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5386.         else
  5387.           x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */
  5388.         if (x) {                    /* This one matches */
  5389.             makestr(&(p[j]),NULL);      /* Free it */
  5390.             for (k = j; k < last; k++)  /* Move the rest up */
  5391.               p[k] = p[k+1];
  5392.             p[k] = NULL;            /* Erase last one */
  5393.             if (!p[k])
  5394.               break;
  5395.         }
  5396.         }
  5397.     }
  5398.     }
  5399.   xdoadd:                /* Common exit */
  5400.     for (i = 0; i < n; i++)
  5401.       if (tmp[i])
  5402.     free(tmp[i]);
  5403.     return(x);
  5404. #endif /* PATTERNS */
  5405. }
  5406.  
  5407. /* ADD SEND-LIST */
  5408.  
  5409. static int
  5410. addsend(cx) int cx; {
  5411. #ifndef NOMSEND
  5412.     extern struct keytab fttab[];
  5413.     extern int nfttyp;
  5414.     struct filelist * flp;
  5415.     char * fmode = "";
  5416.     int xmode = 0;
  5417.     int xbinary = 0;
  5418. #endif /* NOMSEND */
  5419.  
  5420. #ifdef NOMSEND
  5421.     printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n");
  5422.     return(-9);
  5423. #endif /* NOMSEND */
  5424.     if (cx == XXREMV) {
  5425.     printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n");
  5426.     return(-9);
  5427.     }
  5428. #ifndef NOMSEND
  5429. #ifndef XYZ_INTERNAL
  5430.     if (protocol != PROTO_K) {
  5431.        printf("?Sorry, ADD SEND-LIST does not work with external protocols\n");
  5432.        return(-9);
  5433.     }
  5434. #endif /* XYZ_INTERNAL */
  5435.  
  5436.     x = cmifi("File specification to add","", &s,&y,xxstring);
  5437.     if (x < 0) {
  5438.     if (x == -3) {
  5439.         printf("?A file specification is required\n");
  5440.         return(-9);
  5441.     } else
  5442.       return(x);
  5443.     }
  5444.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5445.     s = tmpbuf;
  5446.     if (filesinlist == 0)        /* Take care of \v(filespec) */
  5447.       fspec[0] = NUL;
  5448.     zfnqfp(s,LINBUFSIZ,line);
  5449.     s = line;
  5450.     if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) {
  5451.     strcat(fspec,s);        /* safe */
  5452.     strcat(fspec," ");        /* safe */
  5453.     } else
  5454.       printf("WARNING - \\v(filespec) buffer overflow\n");
  5455.  
  5456.  
  5457.     xbinary = binary;
  5458.     if ((patterns || filepeek)        /* FILE PATTERNS or SCAN is ON */
  5459. #ifdef CK_LABELED
  5460.     && binary != XYFT_L        /* And not if FILE TYPE LABELED */
  5461. #endif /* CK_LABELED */
  5462. #ifdef VMS
  5463.     && binary != XYFT_I        /* or FILE TYPE IMAGE */
  5464. #endif /* VMS */
  5465.     ) {
  5466.     int k, x;
  5467.     x = -1;
  5468.     k = scanfile(line,&x,nscanfile);
  5469.     if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  5470.     }
  5471.     fmode = gfmode(xbinary,0);
  5472.     if ((x = cmkey(fttab,nfttyp,
  5473.            "type of file transfer", fmode, xxstring)) < 0)
  5474.       return(x);
  5475.     xmode = x;
  5476.  
  5477.     cmarg2 = "";
  5478.     if ((x = cmfld(y ?
  5479.   "\nAs-name template containing replacement variables such as \\v(filename)" :
  5480.   "Name to send it with", "",&s,NULL)) < 0)
  5481.       if (x != -3)
  5482.     return(x);
  5483. #ifndef NOSPL
  5484.     if (y && *s) {
  5485.     char * p = tmpbuf;
  5486.     x = TMPBUFSIZ;
  5487.     zzstring(s,&p,&x);
  5488.     if (!strcmp(tmpbuf,s)) {
  5489.         printf(
  5490.   "?As-name for file group must contain variables such as \\v(filename)\n"
  5491.            );
  5492.         return(-9);
  5493.     }
  5494.     }
  5495. #endif /* NOSPL */
  5496.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5497.     cmarg2 = tmpbuf;
  5498.  
  5499.     if ((x = cmcfm()) < 0)
  5500.       return(x);
  5501.     flp = (struct filelist *) malloc(sizeof(struct filelist));
  5502.     if (flp) {
  5503.     if (filetail)
  5504.       filetail->fl_next = flp;
  5505.     filetail = flp;
  5506.     if (!filehead)
  5507.       filehead = flp;
  5508.     x = (int) strlen(line);    /* Length of filename */
  5509.     s = (char *) malloc(x + 1);
  5510.     if (s) {
  5511.         strcpy(s,line);        /* safe */
  5512.         flp->fl_name = s;
  5513.         flp->fl_mode = xmode;
  5514.         x = (int) strlen(cmarg2);    /* Length of as-name */
  5515.         if (x < 1) {
  5516.         flp->fl_alias = NULL;
  5517.         } else {
  5518.         s = (char *) malloc(x + 1);
  5519.         if (s) {
  5520.             strcpy(s,cmarg2);    /* safe */
  5521.             flp->fl_alias = s;
  5522.         } else {
  5523.             printf("Sorry, can't allocate space for as-name");
  5524.             return(-9);
  5525.         }
  5526.         }
  5527.         flp->fl_next = NULL;
  5528.         filesinlist++;        /* Count this node */
  5529.         return(success = 1);    /* Finished adding this node */
  5530.     } else {
  5531.         printf("Sorry, can't allocate space for name");
  5532.         return(-9);
  5533.     }
  5534.     } else {
  5535.     printf("Sorry, can't allocate file list node");
  5536.     return(-9);
  5537.     }
  5538. #endif /* NOMSEND */
  5539. }
  5540. #endif /* ADDCMD */
  5541.  
  5542. #ifndef NOHTTP                /* HTTP ops... */
  5543. #ifdef TCPSOCKET
  5544. #define HTTP_GET 0            /* GET */
  5545. #define HTTP_PUT 1            /* PUT */
  5546. #define HTTP_POS 2            /* POST */
  5547. #define HTTP_IDX 3            /* INDEX */
  5548. #define HTTP_HED 4                      /* HEAD */
  5549. #define HTTP_DEL 5                      /* DELETE */
  5550. #define HTTP_CON 6                      /* CONNECT */
  5551. #define HTTP_OPN 7                      /* OPEN */
  5552. #define HTTP_CLS 8                      /* CLOSE */
  5553.  
  5554. static struct keytab httptab[] = {
  5555.     { "close",   HTTP_CLS, 0 },
  5556.     { "connect", HTTP_CON, 0 },
  5557.     { "delete",  HTTP_DEL, 0 },
  5558.     { "get",     HTTP_GET, 0 },
  5559.     { "head",    HTTP_HED, 0 },
  5560.     { "index",   HTTP_IDX, 0 },
  5561.     { "open",    HTTP_OPN, 0 },
  5562.     { "put",     HTTP_PUT, 0 },
  5563.     { "post",    HTTP_POS, 0 }
  5564. };
  5565. static int nhttptab = sizeof(httptab)/sizeof(struct keytab);
  5566.  
  5567. /* HTTP switches */
  5568. #define HT_SW_AG 0            /* /AGENT */
  5569. #define HT_SW_HD 1            /* /HEADER */
  5570. #define HT_SW_US 2            /* /USER */
  5571. #define HT_SW_PW 3            /* /PASSWORD */
  5572. #define HT_SW_AR 4                      /* /ARRAY */
  5573. #define HT_SW_TP 5                      /* /TOSCREEN */
  5574.  
  5575. static struct keytab httpswtab[] = {
  5576.     { "/agent",    HT_SW_AG, CM_ARG },
  5577. #ifndef NOSPL
  5578.     { "/array",    HT_SW_AR, CM_ARG },
  5579. #endif /* NOSPL */
  5580.     { "/header",   HT_SW_HD, CM_ARG },
  5581.     { "/password", HT_SW_PW, CM_ARG },
  5582.     { "/toscreen", HT_SW_TP, 0 },
  5583.     { "/user",     HT_SW_US, CM_ARG },
  5584.     { "", 0, 0 }
  5585. };
  5586. static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1;
  5587.  
  5588. /* HTTP PUT/POST switches */
  5589. #define HT_PP_MT 0            /* /MIME-TYPE */
  5590.  
  5591. static struct keytab httpptab[] = {
  5592.     { "/mime-type", HT_PP_MT, CM_ARG },
  5593.     { "", 0, 0 }
  5594. };
  5595. static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1;
  5596.  
  5597. #define HTTP_MAXHDR 8
  5598.  
  5599. static int
  5600. xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type)
  5601.     int action;
  5602.     char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array;
  5603.     int type;
  5604. /* xdohttp */ {
  5605.     int i, rc = 0;
  5606.     char * hdrlist[HTTP_MAXHDR];
  5607.     char rfile[CKMAXPATH+1];
  5608.     extern int httpfd;
  5609.  
  5610.     /* Check for a valid state to execute the command */
  5611.     if (inserver) {
  5612.         printf("?The HTTP command may not be used from the IKS\r\n");
  5613.     } else if (httpfd == -1) {
  5614.         if (http_reopen() < 0)
  5615.       printf("?No connection\n");
  5616.         else
  5617.       rc = 1;
  5618.     } else {
  5619.     rc = 1;
  5620.     }
  5621.  
  5622.     /* If the command is not valid, exit with failure */
  5623.     if (rc == 0)
  5624.         return(success = 0);
  5625.  
  5626.     if (action != HTTP_CON && rf[0] != '/') {
  5627.         rfile[0] = '/';
  5628.         ckstrncpy(&rfile[1],rf,CKMAXPATH);
  5629.     } else {
  5630.         ckstrncpy(rfile,rf,CKMAXPATH);
  5631.     }
  5632.     for (i = 0; i < HTTP_MAXHDR; i++)    /* Initialize header list */
  5633.       hdrlist[i] = NULL;
  5634.     makelist(hdr,hdrlist,HTTP_MAXHDR);    /* Make header list */
  5635.  
  5636. #ifdef BETADEBUG
  5637.     for (i = 0; i < nhttptab; i++)    /* Find action keyword */
  5638.       if (httptab[i].kwval == action)
  5639.     break;
  5640.     if (i == nhttptab) {        /* Shouldn't happen... */
  5641.     printf("?Invalid action - %d\n",action);
  5642.     return(0);            /* Failure */
  5643.     }
  5644.  
  5645.     printf("HTTP action:  %s\n",httptab[i].kwd);
  5646.     printf(" Agent:       %s\n",agent ? agent : "(null)");
  5647.  
  5648.     if (hdrlist[1]) {
  5649.     printf(" Header list: 1. %s\n",hdrlist[0]);
  5650.     for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++)
  5651.       printf("%15d. %s\n",i+1,hdrlist[i]);
  5652.     } else
  5653.       printf(" Header:      %s\n",hdrlist[0] ? hdrlist[0] : "(null)");
  5654.  
  5655.     printf(" User:        %s\n",user ? user : "(null)");
  5656. #ifdef COMMENT
  5657.     printf(" Password:    %s\n",pass ? pass : "(null)");
  5658. #endif /* COMMENT */
  5659.  
  5660. #ifndef NOSPL
  5661.     if (array)
  5662.       printf(" Array:       \\%%%c[]\n", array);
  5663.     else
  5664.       printf(" Array:       (none)\n");
  5665. #endif /* NOSPL */
  5666.  
  5667.     if (action == HTTP_PUT || action == HTTP_POS)
  5668.       printf(" Mime-type:   %s\n",mime ? mime : "(null)");
  5669.  
  5670.     printf(" Local file:  %s\n",lfile ? lfile : "(null)");
  5671.     printf(" Remote file: %s\n",rfile ? rfile : "(null)");
  5672.     printf(" Destination file: %s\n",dfile ? dfile : "(null)");
  5673. #endif /* BETADEBUG */
  5674.  
  5675.     /* The http_xxxx() functions return 0 on success, -1 on failure */
  5676.     switch (action) {
  5677.       case HTTP_CON: {
  5678.       extern int ttyfd;
  5679.       rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile);
  5680.       break;
  5681.       }
  5682.       case HTTP_DEL:
  5683.         rc = http_delete(agent,hdrlist,user,pass,array,rfile);
  5684.         break;
  5685.       case HTTP_GET:
  5686.         rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5687.         break;
  5688.       case HTTP_HED:
  5689.         rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5690.         break;
  5691.       case HTTP_PUT:
  5692.         rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5693.               type);
  5694.         break;
  5695.       case HTTP_POS:
  5696.         rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5697.                type);
  5698.         break;
  5699.       case HTTP_IDX:
  5700.         rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5701.         break;
  5702.       default:
  5703.         rc = -1;
  5704.     }
  5705.     return(rc == 0 ? 1 : 0);            /* Success is set by caller */
  5706. }
  5707. #endif /* TCPSOCKET */
  5708. #endif /* NOHTTP */
  5709.  
  5710. #ifndef NOSPL                /* ARRAY ops... */
  5711. static struct keytab arraytab[] = {
  5712.     { "clear",     ARR_CLR, 0 },
  5713.     { "copy",      ARR_CPY, 0 },
  5714.     { "dcl",       ARR_DCL, CM_INV },
  5715.     { "declare",   ARR_DCL, 0 },
  5716.     { "destroy",   ARR_DST, CM_INV },
  5717.     { "equate",    ARR_EQU, CM_INV },
  5718.     { "link",      ARR_EQU, 0 },
  5719.     { "resize",    ARR_RSZ, 0 },
  5720.     { "set",       ARR_SET, 0 },
  5721. #ifndef NOSHOW
  5722.     { "show",      ARR_SHO, 0 },
  5723. #endif /* NOSHOW */
  5724.     { "sort",      ARR_SRT, 0 },
  5725.     { "undeclare", ARR_DST, 0 },
  5726.     { "", 0, 0 }
  5727. };
  5728. static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1;
  5729.  
  5730. #ifdef CKLEARN
  5731. static struct keytab learnswi[] = {
  5732.     { "/close",    2, 0 },
  5733.     { "/off",      0, 0 },
  5734.     { "/on",       1, 0 }
  5735. };
  5736. #endif /* CKLEARN */
  5737.  
  5738. int
  5739. arrayitoa(x) int x; {            /* Array index to array letter */
  5740.     if (x == 1)
  5741.       return(64);
  5742.     else if (x < 0 || x > (122 - ARRAYBASE))
  5743.       return(-1);
  5744.     else
  5745.       return(x + ARRAYBASE);
  5746. }
  5747.  
  5748. int
  5749. arrayatoi(c) int c; {            /* Array letter to array index */
  5750.     if (c == 64)
  5751.       c = 96;
  5752.     if (c > 63 && c < 91)
  5753.       c += 32;
  5754.     if (c < ARRAYBASE || c > 122)
  5755.       return(-1);
  5756.     return(c - ARRAYBASE);
  5757. }
  5758.  
  5759. static int                /* Declare an array */
  5760. dodcl(cx) int cx; {
  5761.     int i, n, v, lo, hi, rc = 0;
  5762.     int isdynamic = 0;
  5763.     char tmpbuf[64];
  5764.     char ** p = NULL;
  5765.     char tmp[64];            /* Local temporary string buffer */
  5766.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5767.     if (y == -3) {
  5768.         printf("?Array name required\n");
  5769.         return(-9);
  5770.     } else return(y);
  5771.     }
  5772.     ckstrncpy(line,s,LINBUFSIZ);
  5773.     s = line;
  5774.     x = arraybounds(s,&lo,&hi);        /* Check syntax and get bounds */
  5775.     debug(F111,"XXX dodcl arraybounds",s,x);
  5776.     if (x < 0) {            /* Error - Maybe it's a variable */
  5777.     char * p;            /* whose value is an array name */
  5778.     int n;
  5779.     p = tmpbuf;
  5780.     n = 63;
  5781.     p[0] = NUL;
  5782.     if (s[0] == CMDQ && s[1] == '&')
  5783.       s++;
  5784.     if (zzstring(s,&p,&n) > -1) {
  5785.         s = tmpbuf;
  5786.         x = arraybounds(s,&lo,&hi);
  5787.         debug(F111,"XXX dodcl arraybounds 2",s,x);
  5788.     }
  5789.     if (x < 0) {
  5790.         printf("?Bad array name - \"%s\"\n",s);
  5791.         return(-9);
  5792.     }
  5793.     }
  5794.     debug(F101,"XXX dodcl lo","",lo);
  5795.     debug(F101,"XXX dodcl hi","",hi);
  5796.  
  5797.     if (lo < 0 && hi < 0) {        /* Have good array name and bounds */
  5798.     isdynamic = 1;
  5799.     n = CMDBL / 5;
  5800.     } else if (hi > -1) {
  5801.     printf("?Segment notation not allowed in array declarations\n");
  5802.     return(-9);
  5803.     } else
  5804.       n = lo;
  5805.     x = arrayitoa(x);
  5806.     if (cx == XXUNDCL) {
  5807.     n = 0;
  5808.     v = 0;
  5809.     if ((y = cmcfm()) < 0)
  5810.       return(y);
  5811.     } else {
  5812.     p = (char **)malloc(sizeof(char **)*(n+1));
  5813.     if (!p) {
  5814.         printf("?Memory allocation error\n");
  5815.         return(-9);
  5816.     }
  5817.     v = 0;                /* Highest initialized member */
  5818.     p[0] = NULL;            /* Element 0 */
  5819.     while (n > 0 && v < n) {    /* Parse initializers */
  5820.         p[v+1] = NULL;
  5821.         ckmakxmsg(tmp,
  5822.               64,
  5823.               "Initial value for \\&",
  5824.               ckctoa((char)x),
  5825.               "[",
  5826.               ckitoa(v+1),
  5827.               "]",
  5828.               NULL,NULL,NULL,NULL,NULL,NULL,NULL
  5829.               );
  5830.         if ((rc = cmfld((char *)tmp,"",&s,xxstring)) < 0) { /* Get field */
  5831.         if (rc == -3)        /* If answer is empty, we're done */
  5832.           break;
  5833.         else            /* Parse error, free temp pointers */
  5834.           goto dclx;
  5835.         }
  5836.         rc = 1;
  5837.         if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */
  5838.           continue;
  5839.         s = brstrip(s);        /* Strip any braces */
  5840.         makestr(&(p[++v]),s);
  5841.     }
  5842.     if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0)
  5843.       return(y);
  5844.     if (isdynamic)
  5845.       n = v;
  5846.     }
  5847.     if (dclarray((char)x,n) < 0) {    /* Declare the array */
  5848.     printf("?Declare failed\n");
  5849.     goto dclx;
  5850.     }
  5851.     for (i = 1; i <= v; i++) {        /* Add any initial values */
  5852.     tmp[0] = '&';
  5853.     ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]");
  5854.     if (addmac(tmp,p[i]) < 0) {
  5855.         printf("Array initialization error: %s %s\n",tmp,p[i]);
  5856.         rc = -9;
  5857.         goto dclx;
  5858.     }
  5859.     }
  5860.   dclx:
  5861.     if (p) {
  5862.     for (i = 1; i <= v; i++)
  5863.       if (p[i]) free(p[i]);
  5864.     free((char *)p);
  5865.     }
  5866.     debug(F101,"DCL rc","",rc);
  5867.     return(success = rc);
  5868. }
  5869.  
  5870. static int
  5871. rszarray() {
  5872.     int i, x, y, n, lo, hi, islink = -1;
  5873.     char c, * s, ** ap = NULL;
  5874.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5875.     if (x == -3) {
  5876.         printf("?Array name required\n");
  5877.         return(-9);
  5878.     } else return(x);
  5879.     }
  5880.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  5881.     s = line;
  5882.     x = arraybounds(s,&lo,&hi);
  5883.     if (x < 0) {            /* Parse the name, get index */
  5884.     printf("?Bad array reference - \"%s\"\n", s);
  5885.     return(-9);
  5886.     }
  5887.     if (lo < 0 && hi < 0) {
  5888.     y = cmnum("New size","",10,&lo,xxstring);
  5889.     if (y < 0) {
  5890.         if (y == -3)
  5891.           printf("?New size required\n");
  5892.         return(y);
  5893.     }
  5894.     }
  5895.     if ((y = cmcfm()) < 0)
  5896.       return(y);
  5897.     if (a_link[x] > -1) {        /* Link? */
  5898.     islink = x;            /* Yes follow it */
  5899.     x = a_link[x];            /* and remember */
  5900.     }
  5901.     if (!a_ptr[x]) {
  5902.     printf("?Array not declared - \"%s\"\n", s);
  5903.     return(-9);
  5904.     }
  5905.     if (lo < 0) {
  5906.     printf("?New size required\n");
  5907.     return(-9);
  5908.     }
  5909.     if (hi > -1) {
  5910.     printf("?Array segments not allowed for this operation\n");
  5911.     return(-9);
  5912.     }
  5913.     c = arrayitoa(x);            /* Get array letter */
  5914.     if (c == '@') {            /* Argument vector array off limits */
  5915.     printf("?Sorry, \\&@[] is read-only\n");
  5916.     return(-9);
  5917.     }
  5918.     if (lo == 0) {            /* If new size is 0... */
  5919.     dclarray(c,0);            /* Undeclare the array */
  5920.     return(success = 1);
  5921.     }
  5922.     n = a_dim[x];            /* Current size */
  5923.     ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */
  5924.     y = (n < lo) ? n : lo;
  5925.     for (i = 0; i <= y; i++)        /* Copy the part that fits */
  5926.       ap[i] = a_ptr[x][i];
  5927.     if (n < lo) {            /* If original array smaller */
  5928.     for (; i <= lo; i++)        /* initialize extra elements in */
  5929.       ap[i] = NULL;            /* new array to NULL. */
  5930.     } else if (n > lo) {        /* If new array smaller */
  5931.     for (; i <= lo; i++)        /* deallocate leftover elements */
  5932.       makestr(&(a_ptr[x][i]),NULL);    /* from original array. */
  5933.     }
  5934.     free((char *)a_ptr[x]);        /* Free original array list */
  5935.     a_ptr[x] = ap;            /* Replace with new one */
  5936.     a_dim[x] = lo;            /* Record the new dimension */
  5937.     if (islink > -1) {            /* Was this a link? */
  5938.     a_ptr[islink] = ap;        /* If so point to the resized array */
  5939.     a_dim[islink] = lo;
  5940.     } else {                /* If not are there links to here? */
  5941.     for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  5942.         if (i != x && a_link[i] == x) {     /* Find and update them */
  5943.         a_ptr[i] = ap;
  5944.         a_dim[i] = lo;
  5945.         }
  5946.     }
  5947.     }
  5948.     return(success = 1);
  5949. }
  5950.  
  5951. static int
  5952. copyarray() {
  5953.     int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0;
  5954.     char c1, c2, * a1, * a2;
  5955.     if ((y = cmfld("Name of source array","",&s,NULL)) < 0)
  5956.       return(y);
  5957.     ckstrncpy(line,s,LINBUFSIZ);
  5958.     a1 = line;
  5959.     if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) {
  5960.     printf("?Bad array reference - \"%s\"\n", a1);
  5961.     return(-9);
  5962.     } else if (!a_ptr[x1]) {
  5963.     printf("?Array not declared - \"%s\"\n", a1);
  5964.     return(-9);
  5965.     }
  5966.     c1 = arrayitoa(x1);
  5967.  
  5968.     if ((y = cmfld("Name of destination array","",&s,NULL)) < 0)
  5969.       return(y);
  5970.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5971.     a2 = tmpbuf;
  5972.     if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) {
  5973.     printf("?Bad array reference - \"%s\"\n", a2);
  5974.     return(-9);
  5975.     }
  5976.     c2 = arrayitoa(x2);
  5977.  
  5978.     if ((x = cmcfm()) < 0)
  5979.       return(x);
  5980.  
  5981.     if (c2 == '@') {            /* Argument vector array off limits */
  5982.     printf("?Sorry, \\&@[] is read-only\n");
  5983.     return(-9);
  5984.     }
  5985.     if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */
  5986.       whole = 1;                      /* whole array... */
  5987.  
  5988.     if (lo1 < 0) lo1 = whole ? 0 : 1;    /* Supply lower bound of source */
  5989.     if (hi1 < 0) hi1 = a_dim[x1];    /* Supply upper bound of source */
  5990.     if (lo2 < 0) lo2 = whole ? 0 : 1;    /* Lower bound of target */
  5991.     if (hi2 < 0) hi2 = lo2 + hi1 - lo1;    /* Upper bound of target */
  5992.     if (a_ptr[x2]) {            /* Target array is already declared? */
  5993.     if (hi2 > a_dim[x2])        /* If upper bound out of range */
  5994.       hi2 = a_dim[x2];        /* shrink to fit */
  5995.     } else {                /* Otherwise... */
  5996.     x2 = dclarray(c2, hi2);        /* declare the target array */
  5997.     }
  5998.     for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */
  5999.     makestr(&(a_ptr[x2][j]),a_ptr[x1][i]);
  6000.     }
  6001.     return(success = 1);
  6002. }
  6003.  
  6004. static int                /* Undeclare an array */
  6005. unarray() {
  6006.     int x, y, n, rc = 0;
  6007.     char c, * s;
  6008.  
  6009.     if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6010.     if (y == -3) {
  6011.         printf("?Array name required\n");
  6012.         return(-9);
  6013.     } else return(y);
  6014.     }
  6015.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6016.     s = line;
  6017.     if ((y = cmcfm()) < 0)
  6018.       return(y);
  6019.     if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */
  6020.     printf("?Bad array reference - \"%s\"\n", s);
  6021.     return(-9);
  6022.     }
  6023.     if (y > 0 || n > 0) {
  6024.     printf("?Partial arrays can not be destroyed\n");
  6025.     return(-9);
  6026.     }
  6027.     c = arrayitoa(x);            /* Get array letter */
  6028.     if (a_ptr[x]) {            /* If array is declared */
  6029.     if (c == '@') {            /* Argument vector array off limits */
  6030.         printf("?Sorry, \\&@[] is read-only\n");
  6031.         return(-9);
  6032.     }
  6033.     rc = dclarray(c,0);        /* Undeclare the array */
  6034.     } else                /* It wasn't declared */
  6035.       rc = 1;
  6036.     if (rc > -1) {            /* Set return code and success */
  6037.     success = 1;
  6038.     rc = 1;
  6039.     } else {
  6040.     success = 0;
  6041.     printf("?Failed - destroy \"\\&%c[]\"\n", c);
  6042.     rc = -9;
  6043.     }
  6044.     return(rc);
  6045. }
  6046.  
  6047. static int
  6048. clrarray(cx) int cx; {
  6049.     int i, x, lo, hi;
  6050.     char c, * s, * val = NULL;
  6051.  
  6052.     if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  6053.     if (x == -3) {
  6054.         printf("?Array name required\n");
  6055.         return(-9);
  6056.     } else return(x);
  6057.     }
  6058.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of name */
  6059.     s = line;
  6060.     if (cx == ARR_SET) {        /* SET */
  6061.     if ((x = cmtxt("Value","",&val,xxstring)) < 0)
  6062.       return(x);
  6063.     ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */
  6064.     val = tmpbuf;
  6065.     if (!*val) val = NULL;
  6066.     } else if ((x = cmcfm()) < 0)    /* CLEAR */
  6067.       return(x);
  6068.  
  6069.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */
  6070.     printf("?Bad array reference - \"%s\"\n", s);
  6071.     return(-9);
  6072.     }
  6073.     c = arrayitoa(x);            /* Get array letter */
  6074.     if (!a_ptr[x]) {            /* If array is declared */
  6075.     printf("?Array %s is not declared\n", s);
  6076.     return(-9);
  6077.     } else if (c == '@') {        /* Argument vector array off limits */
  6078.     printf("?Sorry, \\&@[] is read-only\n");
  6079.     return(-9);
  6080.     }
  6081.     if (lo < 0) lo = 0;
  6082.     if (hi < 0) hi = a_dim[x];
  6083.     for (i = lo; i <= hi; i++)        /* Clear/Set selected range */
  6084.       makestr(&(a_ptr[x][i]),val);
  6085.  
  6086.     return(success = 1);
  6087. }
  6088.  
  6089. extern char **aa_ptr[CMDSTKL][28];
  6090. extern int aa_dim[CMDSTKL][28];
  6091.  
  6092. static int                /* Create symbolic link to an array */
  6093. linkarray() {
  6094.     int i = 0, x, y, lo, hi, flag = 0;
  6095.     char c, * s, * p;
  6096.  
  6097.     if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) {
  6098.     if (x == -3) {
  6099.         printf("?Array name required\n");
  6100.         return(-9);
  6101.     } else return(x);
  6102.     }
  6103.     ckstrncpy(line,s,LINBUFSIZ);    /* Make safe copy of link name */
  6104.     s = line;
  6105.     if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) {
  6106.     if (x == -3) {
  6107.         printf("?Array name required\n");
  6108.         return(-9);
  6109.     } else return(x);
  6110.     }
  6111.     ckstrncpy(tmpbuf,p,TMPBUFSIZ);    /* Make safe copy of array name */
  6112.     p = tmpbuf;
  6113.     if ((x = cmcfm()) < 0)
  6114.       return(x);
  6115.  
  6116.     if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */
  6117.     printf("?Bad array reference - \"%s\"\n", s);
  6118.     return(-9);
  6119.     }
  6120.     if (a_ptr[x]) {            /* Must not already exist */
  6121.     c = arrayitoa(x);
  6122.     printf("?Array already exists: \\&%c[]\n", c);
  6123.     return(-9);
  6124.     }
  6125.     if (lo > -1 || hi > -1) {
  6126.     printf("?Sorry, whole arrays only: %s\n",s);
  6127.     return(-9);
  6128.     }
  6129.     if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */
  6130.     printf("?Bad array reference - \"%s\"\n", s);
  6131.     return(-9);
  6132.     }
  6133.     if (lo > -1 || hi > -1) {
  6134.     printf("?Sorry, whole arrays only: %s\n",p);
  6135.     return(-9);
  6136.     }
  6137.     if (x == y) {
  6138.     for (i = cmdlvl; i >= 0; i--)
  6139.       if (aa_ptr[i][x]) {
  6140.           flag++;
  6141.           break;
  6142.       }
  6143.     }
  6144.     if (flag) {
  6145.     a_ptr[x] = aa_ptr[i][y];    /* Link to saved copy */
  6146.     a_dim[x] = aa_dim[i][y];
  6147.     } else {                /* Otherwise... */
  6148.     c = arrayitoa(y);        /* Check if it's declared */
  6149.     if (!a_ptr[y]) {
  6150.         printf("?Array is not declared: \\&%c[]\n", c);
  6151.         return(-9);
  6152.     }
  6153.     if (a_link[y] > -1) {        /* And if it's a link itself */
  6154.         printf("?Links to links not allowed: \\&%c[]\n", c);
  6155.         return(-9);
  6156.     }
  6157.     a_ptr[x] = a_ptr[y];        /* All OK, make the link */
  6158.     a_dim[x] = a_dim[y];
  6159.     }
  6160.     a_link[x] = y;
  6161.     return(success = 1);
  6162. }
  6163. #endif /* NOSPL */
  6164.  
  6165. #ifndef NOCSETS
  6166. static char * dcsetname = NULL;
  6167.  
  6168. /* Get Display Character-Set Name */
  6169.  
  6170. char *
  6171. getdcset() {
  6172.     char * s;
  6173.     int y;
  6174. #ifdef PCFONTS
  6175.     extern int tt_font, ntermfont;
  6176.     extern struct keytab term_font[];
  6177. #endif /* PCFONTS */
  6178.  
  6179.     s = "";
  6180. #ifdef OS2
  6181.     y = os2getcp();            /* Default is current code page */
  6182.     switch (y) {
  6183.       case 437: s = "cp437"; break;
  6184.       case 850: s = "cp850"; break;
  6185.       case 852: s = "cp852"; break;
  6186.       case 857: s = "cp857"; break;
  6187.       case 858: s = "cp858"; break;
  6188.       case 862: s = "cp862"; break;
  6189.       case 866: s = "cp866"; break;
  6190.       case 869: s = "cp869"; break;
  6191.       case 1250: s = "cp1250"; break;
  6192.       case 1251: s = "cp1251"; break;
  6193.       case 1252: s = "cp1252"; break;
  6194.       case 1253: s = "cp1253"; break;
  6195.       case 1254: s = "cp1254"; break;
  6196.       case 1255: s = "cp1255"; break;
  6197.       case 1256: s = "cp1256"; break;
  6198.       case 1257: s = "cp1257"; break;
  6199.       case 1258: s = "cp1258"; break;
  6200.     }
  6201. #ifdef PCFONTS
  6202. /*
  6203.    If the user has loaded a font with SET TERMINAL FONT then we want
  6204.    to change the default code page to the font that was loaded.
  6205. */
  6206.     if (tt_font != TTF_ROM) {
  6207.     for (y = 0; y < ntermfont; y++ ) {
  6208.         if (term_font[y].kwval == tt_font) {
  6209.         s = term_font[y].kwd;
  6210.         break;
  6211.         }
  6212.     }
  6213.     }
  6214. #endif /* PCFONTS */
  6215. #else /* OS2 */
  6216. #ifdef COMMENT
  6217.     /* Hack not needed as of C-Kermit 7.1 */
  6218.     if (fcharset == FC_1LATIN) {
  6219.     s = "latin1-iso";        /* Hack to avoid reporting "cp1252" */
  6220.     } else {                /* Report current file character set */
  6221. #endif /* COMMENT */
  6222.     for (y = 0; y <= nfilc; y++)
  6223.       if (fcstab[y].kwval == fcharset) {
  6224.           s = fcstab[y].kwd;
  6225.           break;
  6226.       }
  6227. #ifdef COMMENT
  6228.     }
  6229. #endif /* COMMENT */
  6230. #endif /* OS2 */
  6231.     makestr(&dcsetname,s);        /* Return stable pointer */
  6232.     return((char *)dcsetname);
  6233. }
  6234. #endif /* NOCSETS */
  6235.  
  6236. #ifndef NOFRILLS
  6237. static int
  6238. doclear() {
  6239.     if ((x = cmkey(clrtab,nclear,"item to clear",
  6240. #ifdef NOSPL
  6241.            "device-buffer"
  6242. #else
  6243.            "device-and-input"
  6244. #endif /* NOSPL */
  6245.            ,xxstring)) < 0) return(x);
  6246. #ifndef NOSPL
  6247. #ifdef OS2
  6248.     if (x == CLR_CMD || x == CLR_TRM) {
  6249.     if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n",
  6250.                "all",xxstring)) < 0)
  6251.       return(z);
  6252.     }
  6253. #endif /* OS2 */
  6254. #endif /* NOSPL */
  6255.     if ((y = cmcfm()) < 0)
  6256.       return(y);
  6257.  
  6258.     /* Clear device input buffer if requested */
  6259.     y = (x & CLR_DEV) ? ttflui() : 0;
  6260.  
  6261.     if (x & CLR_SCR)            /* CLEAR SCREEN */
  6262.       y = ck_cls();            /* (= SCREEN CLEAR = CLS) */
  6263.  
  6264.     if (x & CLR_KBD) {            /* CLEAR KEYBOARD */
  6265.     int n;
  6266.     n = conchk();
  6267.     y = 0;
  6268.     while (n-- > 0 && (y = coninc(0) > -1))
  6269.       ;
  6270.     y = (y > -1) ? 0 : -1;
  6271.     }
  6272.  
  6273. #ifndef NOSPL
  6274.     /* Clear INPUT command buffer if requested */
  6275.     if (x & CLR_INP) {
  6276.     for (z = 0; z < inbufsize; z++)
  6277.       inpbuf[z] = NUL;
  6278.     inpbp = inpbuf;
  6279.     y = 0;
  6280.     }
  6281. #ifdef CK_APC
  6282.     if (x & CLR_APC) {
  6283.     debug(F101,"Executing CLEAR APC","",apcactive);
  6284.     apcactive = 0;
  6285.     y = 0;
  6286.     }
  6287. #endif /* CK_APC */
  6288.     if (x & CLR_ALR) {
  6289.     setalarm(0L);
  6290.     y = 0;
  6291.     }
  6292. #endif /* NOSPL */
  6293.  
  6294. #ifdef PATTERNS
  6295.     if (x & (CLR_TXT|CLR_BIN)) {
  6296.     int i;
  6297.     for (i = 0; i < FTPATTERNS; i++) {
  6298.         if (x & CLR_TXT)
  6299.           makestr(&txtpatterns[i],NULL);
  6300.         if (x & CLR_BIN)
  6301.           makestr(&binpatterns[i],NULL);
  6302.     }
  6303.     y = 0;
  6304.     }
  6305. #endif /* PATTERNS */
  6306.  
  6307. #ifndef NODIAL
  6308.     if (x & CLR_DIA) {
  6309.     dialsta = DIA_UNK;
  6310.     y = 0;
  6311.     }
  6312. #endif /* NODIAL */
  6313.  
  6314. #ifndef NOMSEND
  6315.     if (x & CLR_SFL) {            /* CLEAR SEND-LIST */
  6316.     if (filehead) {
  6317.         struct filelist * flp, * next;
  6318.         flp = filehead;
  6319.         while (flp) {
  6320.         if (flp->fl_name)
  6321.           free(flp->fl_name);
  6322.         if (flp->fl_alias)
  6323.           free(flp->fl_alias);
  6324.         next = flp->fl_next;
  6325.         free((char *)flp);
  6326.         flp = next;
  6327.         }
  6328.     }
  6329.     filesinlist = 0;
  6330.     filehead = NULL;
  6331.     filetail = NULL;
  6332.     addlist = 0;
  6333.     y = 0;
  6334.     }
  6335. #endif /* NOMSEND */
  6336.  
  6337. #ifdef OS2
  6338. #ifndef NOLOCAL
  6339.     switch (x) {
  6340.       case CLR_SCL:
  6341.     clearscrollback(VTERM);
  6342.     break;
  6343.       case CLR_CMD:
  6344.     switch ( z ) {
  6345.       case CLR_C_ALL:
  6346.         clear();
  6347.         break;
  6348.       case CLR_C_BOS:
  6349.         clrboscr_escape(VCMD,SP);
  6350.         break;
  6351.       case CLR_C_BOL:
  6352.         clrbol_escape(VCMD,SP);
  6353.         break;
  6354.       case CLR_C_EOL:
  6355.         clrtoeoln(VCMD,SP);
  6356.         break;
  6357.       case CLR_C_EOS:
  6358.         clreoscr_escape(VCMD,SP);
  6359.         break;
  6360.       case CLR_C_LIN:
  6361.         clrline_escape(VCMD,SP);
  6362.         break;
  6363.       case CLR_C_SCR:
  6364.         clearscrollback(VCMD);
  6365.         break;
  6366.     default:
  6367.         printf("Not implemented yet, sorry.\n");
  6368.         break;
  6369.     }
  6370.     break;
  6371.  
  6372. #ifndef NOTERM
  6373.       case CLR_TRM:
  6374.      switch ( z ) {
  6375.       case CLR_C_ALL:
  6376.          if (VscrnGetBufferSize(VTERM) > 0 ) {
  6377.          VscrnScroll(VTERM, UPWARD, 0,
  6378.                  VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1),
  6379.                  VscrnGetHeight(VTERM) -
  6380.                  (tt_status[VTERM]?1:0), TRUE, SP
  6381.                  );
  6382.          cleartermscreen(VTERM);
  6383.          }
  6384.          break;
  6385.       case CLR_C_BOS:
  6386.         clrboscr_escape(VTERM,SP);
  6387.         break;
  6388.       case CLR_C_BOL:
  6389.         clrbol_escape(VTERM,SP);
  6390.         break;
  6391.       case CLR_C_EOL:
  6392.         clrtoeoln(VTERM,SP);
  6393.         break;
  6394.       case CLR_C_EOS:
  6395.         clreoscr_escape(VTERM,SP);
  6396.         break;
  6397.       case CLR_C_LIN:
  6398.         clrline_escape(VTERM,SP);
  6399.         break;
  6400.      case CLR_C_SCR:
  6401.          clearscrollback(VTERM);
  6402.          break;
  6403.      default:
  6404.          printf("Not implemented yet, sorry.\n");
  6405.          break;
  6406.     }
  6407.     break;
  6408. #endif /* NOTERM */
  6409.     }
  6410.     y = 0;
  6411. #endif /* NOLOCAL */
  6412. #endif /* OS2 */
  6413.     return(success = (y == 0));
  6414. }
  6415. #endif /* NOFRILLS */
  6416.  
  6417. #ifndef NOSPL
  6418. static int
  6419. doeval(cx) int cx; {
  6420.     char *p;
  6421.     char vnambuf[VNAML], * vnp = NULL;    /* These must be on the stack */
  6422.     if (!oldeval) {
  6423.     if ((y = cmfld("Variable name","",&s,
  6424.                ((cx == XX_EVAL) ? xxstring : NULL))) < 0) {
  6425.         if (y == -3) {
  6426.         printf("?Variable name required\n");
  6427.         return(-9);
  6428.         } else return(y);
  6429.     }
  6430.     ckstrncpy(vnambuf,s,VNAML);    /* Make a copy. */
  6431.     vnp = vnambuf;
  6432.     if (vnambuf[0] == CMDQ &&
  6433.         (vnambuf[1] == '%' || vnambuf[1] == '&'))
  6434.       vnp++;
  6435.     y = 0;
  6436.     if (*vnp == '%' || *vnp == '&') {
  6437.         if ((y = parsevar(vnp,&x,&z)) < 0)
  6438.           return(y);
  6439.     }
  6440.     }
  6441.     if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0)
  6442.       return(x);
  6443.     p = evala(s);
  6444.     if (!p) p = "";
  6445.     if (oldeval && *p)
  6446.       printf("%s\n", p);
  6447.     ckstrncpy(evalbuf,p,32);
  6448.     if (!oldeval)
  6449.       return(success = addmac(vnambuf,p));
  6450.     else
  6451.       return(success = *p ? 1 : 0);
  6452. }
  6453. #endif /* NOSPL */
  6454.  
  6455. #ifdef TNCODE
  6456. static int
  6457. dotelopt() {
  6458.     if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 )
  6459.       return(x);
  6460.     switch (x) {
  6461.       case WILL:
  6462.       case WONT:
  6463.       case DO:
  6464.       case DONT:
  6465.     if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0)
  6466.       return(y);
  6467.     if ((z = cmcfm()) < 0) return(z);
  6468.  
  6469.     switch (x) {
  6470.       case WILL:
  6471.         if (TELOPT_UNANSWERED_WILL(y))
  6472.           return(success = 0);
  6473.         break;
  6474.       case WONT:
  6475.         if (TELOPT_UNANSWERED_WONT(y))
  6476.           return(success = 0);
  6477.         break;
  6478.       case DO:
  6479.         if (TELOPT_UNANSWERED_DO(y))
  6480.           return(success = 0);
  6481.         break;
  6482.       case DONT:
  6483.         if (TELOPT_UNANSWERED_DONT(y))
  6484.           return(success = 0);
  6485.         break;
  6486.     }
  6487.     if (local) {
  6488.         success = ((tn_sopt(x,y) > -1) ? 1 : 0);
  6489.     } else {
  6490.         printf("ff%02x%02x\n",x,y);
  6491.         success = 1;
  6492.     }
  6493.     if (success) {
  6494.         switch (x) {
  6495.           case WILL:
  6496.         TELOPT_UNANSWERED_WILL(y) = 1;
  6497.         break;
  6498.           case WONT:
  6499.         if ( TELOPT_ME(y) )
  6500.           TELOPT_UNANSWERED_WONT(y) = 1;
  6501.         break;
  6502.           case DO:
  6503.         TELOPT_UNANSWERED_DO(y) = 1;
  6504.         break;
  6505.           case DONT:
  6506.         if ( TELOPT_ME(y) )
  6507.           TELOPT_UNANSWERED_DONT(y) = 1;
  6508.         break;
  6509.         }
  6510.         if (tn_wait("XXTELOP") < 0) {
  6511.         tn_push();
  6512.         success = 0;
  6513.         }
  6514.     }
  6515.     return(success);
  6516.       case SB:
  6517.     if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0)
  6518.       return(y);
  6519.     switch (y) {
  6520.       case TELOPT_NAWS:
  6521.         /* Some compilers require switch() to have at least 1 case */
  6522. #ifdef CK_NAWS
  6523.         TELOPT_SB(TELOPT_NAWS).naws.x = 0;
  6524.         TELOPT_SB(TELOPT_NAWS).naws.y = 0;
  6525.         if (local)
  6526.           return(success = ((tn_snaws() > -1) ? 1 : 0));
  6527.         else
  6528.           return(success = 0);
  6529. #else
  6530.         return(success = 0);
  6531. #endif /* CK_NAWS */
  6532.     }
  6533.         return(success = 0);
  6534.  
  6535. #ifdef CK_KERBEROS
  6536. #ifdef KRB5
  6537.       case TN_FWD:
  6538.         success = (kerberos5_forward() == AUTH_SUCCESS);
  6539.         return(success);
  6540. #endif /* KRB5 */
  6541. #endif /* CK_KERBEROS */
  6542.  
  6543.       default:
  6544.     if ((z = cmcfm()) < 0) return(z);
  6545. #ifndef NOLOCAL
  6546.     if (local) {
  6547.         CHAR temp[3];
  6548.         if (network && IS_TELNET()) { /* TELNET */
  6549.         temp[0] = (CHAR) IAC;
  6550.         temp[1] = x;
  6551.         temp[2] = NUL;
  6552.         success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0);
  6553.         if (tn_deb || debses || deblog) {
  6554.             /* TN_MSG_LEN is in ckctel.h */
  6555.             ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL);
  6556.             debug(F101,tn_msg,"",x);
  6557.             if (debses || tn_deb) tn_debug(tn_msg);
  6558.         }
  6559.         return(success);
  6560.         }
  6561.             return(success = 0);
  6562.     } else {
  6563. #endif /* NOLOCAL */
  6564.         printf("ff%02x\n",x);
  6565.         return(success = 1);
  6566. #ifndef NOLOCAL
  6567.     }
  6568. #endif /* NOLOCAL */
  6569.     }
  6570. }
  6571. #endif /* TNCODE */
  6572.  
  6573.  
  6574. #ifndef NOPUSH
  6575. #ifndef NOFRILLS
  6576. static int
  6577. doedit() {
  6578. #ifdef OS2
  6579.     char * p = NULL;
  6580. #endif /* OS2 */
  6581.     if (!editor[0]) {
  6582.     s = getenv("EDITOR");
  6583.     if (s) ckstrncpy(editor,s,CKMAXPATH);
  6584.     editor[CKMAXPATH] = NUL;
  6585.     if (!editor[0]) {
  6586.         printf("?Editor not defined - use SET EDITOR to define\n");
  6587.         return(-9);
  6588.     }
  6589.     }
  6590.     ckstrncpy(tmpbuf,editfile,TMPBUFSIZ);
  6591. /*
  6592.   cmiofi() lets us parse the name of an existing file, or the name of
  6593.   a nonexistent file to be created.
  6594. */
  6595.     x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring);
  6596.     if (x < 0) {
  6597.     if (x == -9) {
  6598.         if (zchko(s) < 0) {
  6599.         printf("Can't create \"%s\"\n",s);
  6600.         return(x);
  6601.         }
  6602.     } else if (x != -3)
  6603.       return(x);
  6604.     }
  6605.     if (x == -3)
  6606.       tmpbuf[0] = NUL;
  6607.     else {
  6608.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6609.     if (iswild((char *)tmpbuf)) {
  6610.         printf("?A single file please\n");
  6611.         return(-9);
  6612.     }
  6613.     }
  6614.     if ((z = cmcfm()) < 0) return(z);
  6615.     if (nopush) {
  6616.     printf("?Sorry, editing not allowed\n");
  6617.     return(success = 0);
  6618.     }
  6619.     if (tmpbuf[0]) {
  6620.     /* Get full path in case we change directories between EDIT commands */
  6621.     zfnqfp(tmpbuf, CKMAXPATH, editfile);
  6622.     editfile[CKMAXPATH] = NUL;
  6623. #ifdef OS2
  6624.     p = editfile;            /* Flip the stupid slashes */
  6625.     while (*p) {
  6626.         if (*p == '/') *p = '\\';
  6627.         p++;
  6628.     }
  6629. #endif /* OS2 */
  6630.     } else
  6631.       editfile[0] = NUL;
  6632.     x = 0;
  6633.     if (editopts[0]) {
  6634. #ifdef OS2
  6635.     x = ckindex("%1",(char *)editopts,0,0,1);
  6636.     if (x > 0)
  6637.       editopts[x] = 's';
  6638.     else
  6639. #endif /* OS2 */
  6640.       x = ckindex("%s",(char *)editopts,0,0,1);
  6641.     }
  6642.     if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) {
  6643.     if (x)
  6644.       sprintf(tmpbuf,editopts,editfile);
  6645.     else
  6646.       sprintf(tmpbuf,"%s %s",editopts,editfile);
  6647.     }
  6648.     s = line;
  6649.     ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL);
  6650. #ifdef OS2
  6651.     p = s + strlen(editor);        /* And again with the slashes */
  6652.     while (p != s) {
  6653.     if (*p == '/') *p = '\\';
  6654.     p--;
  6655.     }
  6656. #endif /* OS2 */
  6657.     conres();
  6658.     x = zshcmd(s);
  6659.     concb((char)escape);
  6660.     return(x);
  6661. }
  6662. #endif /* NOFRILLS */
  6663. #endif /* NOPUSH */
  6664.  
  6665. #ifdef BROWSER
  6666. static int
  6667. dobrowse() {
  6668. #ifdef OS2
  6669.     char * p = NULL;
  6670. #endif /* OS2 */
  6671.     if (nopush) {
  6672.     printf("?Sorry, browsing not allowed\n");
  6673.     return(success = 0);
  6674.     }
  6675. #ifndef NT
  6676.     /* Windows lets the Shell Execute the URL if no Browser is defined */
  6677.     if (!browser[0]) {
  6678.     s = getenv("BROWSER");
  6679.     if (s) ckstrncpy(browser,s,CKMAXPATH);
  6680.     browser[CKMAXPATH] = NUL;
  6681.     if (!browser[0]) {
  6682.         printf("?Browser not defined - use SET BROWSER to define\n");
  6683.         return(-9);
  6684.     }
  6685.     }
  6686. #endif /* NT */
  6687.     ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ);
  6688.     if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0)
  6689.       return(x);
  6690.     ckstrncpy(browsurl,s,4096);
  6691.     x = 0;
  6692.     if (browsopts[0]) {
  6693. #ifdef OS2
  6694.     x = ckindex("%1",(char *)browsopts,0,0,1);
  6695.     if (x > 0)
  6696.       browsopts[x] = 's';
  6697.     else
  6698. #endif /* OS2 */
  6699.       x = ckindex("%s",(char *)browsopts,0,0,1);
  6700.     }
  6701.     if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) {
  6702.     if (x)
  6703.       sprintf(tmpbuf,browsopts,browsurl);
  6704.     else
  6705.       sprintf(tmpbuf,"%s %s",browsopts,browsurl);
  6706.     }
  6707. #ifdef NT
  6708.     if (!browser[0])
  6709.       return(success = Win32ShellExecute(browsurl));
  6710. #endif /* NT */
  6711.     s = line;
  6712.     ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL);
  6713. #ifdef OS2
  6714.     p = line + strlen(browser);        /* Flip slashes */
  6715.     while (p != line) {
  6716.     if (*p == '/') *p = '\\';
  6717.     p--;
  6718.     }
  6719. #endif /* OS2 */
  6720.     conres();
  6721.     x = zshcmd(s);
  6722.     concb((char)escape);
  6723.     return(x);
  6724. }
  6725. #endif /* BROWSER */
  6726.  
  6727. #ifdef CK_RECALL
  6728. static int
  6729. doredo() {            /* Find a previous cmd and redo it */
  6730.     extern int on_recall, in_recall;
  6731.     int x;
  6732.     char * p;
  6733.  
  6734.     if ((x = cmtxt(
  6735. "pattern, or first few characters of a previous command",
  6736.            "*",&s,xxstring)) < 0)
  6737.       return(x);
  6738.     ckstrncpy(line,s,LINBUFSIZ);
  6739.     x = strlen(s);
  6740.     s = line;
  6741.     if (*s == '{') {            /* Braces disable adding * to end */
  6742.     if (s[x-1] == '}') {
  6743.         s[x-1] = NUL;
  6744.         s++;
  6745.         x--;
  6746.     }
  6747.     } else {                /* No braces, add * to end. */
  6748.     s[x] = '*';
  6749.     s[x+1] = NUL;
  6750.     }
  6751.  
  6752.     while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL;
  6753.  
  6754.     if (!on_recall || !in_recall) {
  6755.     printf("?Sorry, command recall can't be used now.\n");
  6756.     return(-9);
  6757.     }
  6758.     if ((p = cmgetcmd(s))) {        /* Look for it history buffer */
  6759.     ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */
  6760.     cmaddnext();            /* Force re-add to history buffer */
  6761.     return(cmflgs = -1);        /* Force reparse */
  6762.     } else {
  6763.     printf("?Sorry - \"%s\" not found\n", s);
  6764.     return(-9);
  6765.     }
  6766. }
  6767. #endif /* CK_RECALL */
  6768.  
  6769. #ifndef NOXFER
  6770. #ifndef NOCSETS
  6771. static int
  6772. doassoc()  {                /* ASSOCIATE */
  6773.     extern struct keytab tcstab[];
  6774.     extern int ntcs;
  6775.     if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 )
  6776.       return(x);
  6777.  
  6778.     switch (x) {            /* Associate what? */
  6779.  
  6780.       case ASSOC_TC:            /* Transfer character-set... */
  6781.     if ((x = cmkey(tcstab, ntcs,
  6782.                "transfer character-set name","",xxstring)) < 0)
  6783.       return(x);
  6784.     if ((y = cmkey(fcstab, nfilc,
  6785.                "with file character-set","", xxstring)) < 0)
  6786.       if (y != -3)
  6787.         return(y);
  6788.     if ((z = cmcfm()) < 0)
  6789.       return(z);
  6790.     axcset[x] = y;
  6791.     return(success = 1);
  6792.  
  6793.       case ASSOC_FC:            /* File character-set... */
  6794.     if ((x = cmkey(fcstab, nfilc,
  6795.                "file character-set name","",xxstring)) < 0)
  6796.       return(x);
  6797.     if ((y = cmkey(tcstab, ntcs,
  6798.                "with transfer character-set","", xxstring)) < 0)
  6799.       if (y != -3)
  6800.         return(y);
  6801.     if ((z = cmcfm()) < 0)
  6802.       return(z);
  6803.     afcset[x] = y;
  6804.     return(success = 1);
  6805.  
  6806.       default:
  6807.     return(-2);
  6808.     }
  6809. }
  6810. #endif /* NOCSETS */
  6811. #endif /* NOXFER */
  6812.  
  6813. #ifndef NOHELP
  6814. static int
  6815. domanual() {
  6816. #ifdef OS2
  6817.     if ((x = cmcfm()) < 0)
  6818.       return(x);
  6819.     if (nopush) {
  6820.     printf("?Sorry, access to system commands is disabled.\n");
  6821.     return(-9);
  6822.     }
  6823.     y = mxlook(mactab,"manual",nmac);
  6824.     if (y > -1) {
  6825.     z = maclvl;            /* Save the current maclvl */
  6826.     dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  6827.     while (maclvl > z) {
  6828.         debug(F101,"XXMAN loop maclvl 1","",maclvl);
  6829.         sstate = (CHAR) parser(1);
  6830.         debug(F101,"XXMAN loop maclvl 2","",maclvl);
  6831.         if (sstate) proto();
  6832.     }
  6833.     debug(F101,"XXMAN loop exit maclvl","",maclvl);
  6834.     return(success);
  6835.     }
  6836.     return(success = 0);
  6837. #else
  6838.     if ((x = cmtxt(
  6839. #ifdef UNIX
  6840.            "Carriage return to confirm the command, or manual topic",
  6841. #else
  6842.            "Carriage return to confirm the command, or help topic",
  6843. #endif /* UNIX */
  6844.            "kermit",
  6845.            &s,
  6846.            xxstring
  6847.            )
  6848.      ) < 0)
  6849.       return(x);
  6850. #endif /* OS2 */
  6851.  
  6852. #ifdef UNIX
  6853.     ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL);
  6854. #else
  6855.     ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL);
  6856. #endif /* UNIX */
  6857.     debug(F110,"MANUAL",tmpbuf,0);
  6858.     if (nopush) {
  6859.     printf("?Sorry, access to system commands is disabled.\n");
  6860.     return(-9);
  6861.     } else {
  6862.     conres();            /* Restore the console */
  6863.     success = zshcmd(tmpbuf);
  6864.     concb((char)escape);        /* Restore CBREAK mode */
  6865.     return(success);
  6866.     }
  6867. }
  6868. #endif /* NOHELP */
  6869.  
  6870. #ifndef NOHTTP
  6871. #ifdef TCPSOCKET
  6872. static struct keytab sslswtab[] = {
  6873.     { "/ssl", 1, 0 },
  6874.     { "/tls", 1, 0 }
  6875. };
  6876.  
  6877. #ifndef NOURL
  6878. struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  6879. #endif /* NOURL */
  6880.  
  6881. static int
  6882. dohttp() {                /* HTTP */
  6883.     struct FDB sw, kw, fi;
  6884.     int n, getval, allinone = 0;
  6885.     char c, * p;
  6886.     char rdns[128];
  6887.  
  6888.     char * http_agent = NULL;        /* Parse results */
  6889.     char * http_hdr   = NULL;
  6890.     char * http_user  = NULL;
  6891.     char * http_pass  = NULL;
  6892.     char * http_mime  = NULL;
  6893.     char * http_lfile = NULL;
  6894.     char * http_rfile = NULL;
  6895.     char * http_dfile = NULL;
  6896.     char   http_array = NUL;
  6897.     int    http_action = -1;
  6898.  
  6899.     char * http_host = NULL;
  6900.     char * http_srv  = NULL;
  6901.     int    http_ssl  = 0;
  6902.  
  6903.     static char * http_d_agent = NULL;
  6904.     static char * http_d_user = NULL;
  6905.     static char * http_d_pass = NULL;
  6906.  
  6907.     static int    http_d_type = 0;
  6908.     int           http_type = http_d_type;
  6909.  
  6910. #ifdef OS2
  6911.     p = "Kermit 95";            /* Default user agent */
  6912. #else
  6913.     p = "C-Kermit";
  6914. #endif /* OS2 */
  6915.     makestr(&http_agent,p);
  6916.     makestr(&http_mime,"text/HTML");    /* MIME type default */
  6917.     rdns[0] = '\0';
  6918.  
  6919.     cmfdbi(&sw,                /* 1st FDB - general switches */
  6920.        _CMKEY,                /* fcode */
  6921.        "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */
  6922.        "",                /* default */
  6923.        "",                /* addtl string data */
  6924.        nhttpswtab,            /* addtl numeric data 1: tbl size */
  6925.        4,                /* addtl numeric data 2: 4 = cmswi */
  6926.        xxstring,            /* Processing function */
  6927.        httpswtab,            /* Keyword table */
  6928.        &kw                /* Pointer to next FDB */
  6929.        );
  6930.     cmfdbi(&kw,                /* 2nd FDB - commands */
  6931.        _CMKEY,                /* fcode */
  6932.        "Command",            /* hlpmsg */
  6933.        "",                /* default */
  6934.        "",                /* addtl string data */
  6935.        nhttptab,            /* addtl numeric data 1: tbl size */
  6936.        0,                /* addtl numeric data 2: 0 = keyword */
  6937.        xxstring,            /* Processing function */
  6938.        httptab,                /* Keyword table */
  6939.        NULL                /* Pointer to next FDB */
  6940.        );
  6941.  
  6942.     while (1) {
  6943.     x = cmfdb(&sw);            /* Parse something */
  6944.     if (x < 0)            /* Error */
  6945.       goto xhttp;
  6946.     n = cmresult.nresult;
  6947.     if (cmresult.fdbaddr == &kw)    /* Command - exit this loop */
  6948.       break;
  6949.     c = cmgbrk();            /* Switch... */
  6950.     getval = (c == ':' || c == '=');
  6951.     x = -9;
  6952.     if (getval && !(cmgkwflgs() & CM_ARG)) {
  6953.         printf("?This switch does not take an argument\n");
  6954.         goto xhttp;
  6955.     }
  6956.     switch (cmresult.nresult) {    /* Handle each switch */
  6957.           case HT_SW_TP:                /* /TOSCREEN */
  6958.             http_type = 1;
  6959.             break;
  6960.       case HT_SW_AG:        /* /AGENT */
  6961.         if (getval) {
  6962.         if ((x = cmfld("User agent",p,&s,xxstring)) < 0)
  6963.           goto xhttp;
  6964.         } else {
  6965.         s = p;
  6966.         }
  6967.         makestr(&http_agent,s);
  6968.         break;
  6969.       case HT_SW_HD:        /* /HEADER */
  6970.         s = NULL;
  6971.         if (getval) {
  6972.         if ((x = cmfld("Header line","",&s,xxstring)) < 0) {
  6973.             if (x == -3)
  6974.               s = NULL;
  6975.             else
  6976.               goto xhttp;
  6977.         }
  6978.         }
  6979.         makestr(&http_hdr,s);
  6980.         break;
  6981.       case HT_SW_US:        /* /USER */
  6982.         s = NULL;
  6983.         if (getval) {
  6984.         if ((x = cmfld("User ID","",&s,xxstring)) < 0) {
  6985.                   if (x == -3)
  6986.                     s = "";
  6987.                   else
  6988.             goto xhttp;
  6989.                 }
  6990.         }
  6991.         makestr(&http_user,s);
  6992.         break;
  6993.       case HT_SW_PW:        /* /PASSWORD */
  6994.         debok = 0;
  6995.         s = NULL;
  6996.         if (getval) {
  6997.         if ((x = cmfld("Password","",&s,xxstring)) < 0)
  6998.           goto xhttp;
  6999.         }
  7000.         makestr(&http_pass,s);
  7001.         break;
  7002. #ifndef NOSPL
  7003.       case HT_SW_AR: {        /* /ARRAY: */
  7004.           char * s2, array = NUL;
  7005.           if (!getval) {
  7006.           printf("?This switch requires an argument\n");
  7007.           x = -9;
  7008.           goto xhttp;
  7009.           }
  7010.           if ((x = cmfld("Array name (a single letter will do)",
  7011.                  "",
  7012.                  &s,
  7013.                  NULL
  7014.                  )) < 0) {
  7015.           if (x == -3) {
  7016.               printf("?Array name required\n");
  7017.               x = -9;
  7018.               goto xhttp;
  7019.           } else
  7020.             goto xhttp;
  7021.           }
  7022.           if (!*s) {
  7023.           printf("?Array name required\n");
  7024.           x = -9;
  7025.           goto xhttp;
  7026.           }
  7027.           s2 = s;
  7028.           if (*s == CMDQ) s++;
  7029.           if (*s == '&') s++;
  7030.           if (!isalpha(*s)) {
  7031.           printf("?Bad array name - \"%s\"\n",s2);
  7032.           x = -9;
  7033.           goto xhttp;
  7034.           }
  7035.           array = *s++;
  7036.           if (isupper(array))
  7037.         array = tolower(array);
  7038.           if (*s && (*s != '[' || *(s+1) != ']')) {
  7039.           printf("?Bad array name - \"%s\"\n",s2);
  7040.           http_array = NUL;
  7041.           x = -9;
  7042.           goto xhttp;
  7043.           }
  7044.           http_array = array;
  7045.           break;
  7046.       }
  7047. #endif /* NOSPL */
  7048.       default:
  7049.         x = -2;
  7050.         goto xhttp;
  7051.     }
  7052.     }
  7053.     http_action = n;            /* Save the action */
  7054.     if (http_action == HTTP_PUT || http_action == HTTP_POS) {
  7055.     cmfdbi(&sw,            /* 1st FDB - switch */
  7056.            _CMKEY,            /* fcode */
  7057.            "Local filename\n Or switch", /* help */
  7058.            "",            /* default */
  7059.            "",            /* addtl string data */
  7060.            nhttpptab,        /* keyword table size */
  7061.            4,            /* addtl numeric data 2: 4 = cmswi */
  7062.            xxstring,        /* Processing function */
  7063.            httpptab,        /* Keyword table */
  7064.            &fi            /* Pointer to next FDB */
  7065.            );
  7066.     cmfdbi(&fi,            /* 2nd FDB - filename */
  7067.            _CMIFI,            /* fcode */
  7068.            "Local filename",    /* hlpmsg */
  7069.            "",            /* default */
  7070.            "",            /* addtl string data */
  7071.            0,            /* addtl numeric data 1 */
  7072.            0,            /* addtl numeric data 2 */
  7073.            xxstring,
  7074.            NULL,
  7075.            NULL
  7076.            );
  7077.     while (1) {
  7078.         x = cmfdb(&sw);
  7079.         if (x < 0)
  7080.           goto xhttp;        /* Free any malloc'd temp strings */
  7081.         n = cmresult.nresult;
  7082.         if (cmresult.fcode != _CMKEY)
  7083.           break;
  7084.         c = cmgbrk();        /* Switch... */
  7085.         getval = (c == ':' || c == '=');
  7086.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  7087.         printf("?This switch does not take an argument\n");
  7088.         x = -9;
  7089.         goto xhttp;
  7090.         }
  7091.         switch (n) {
  7092.           case HT_PP_MT:
  7093.         s = "text/HTML";
  7094.         if (getval) {
  7095.             if ((x = cmfld("MIME type",
  7096.                    "text/HTML",&s,xxstring)) < 0)
  7097.               goto xhttp;
  7098.         }
  7099.         makestr(&http_mime,s);
  7100.         break;
  7101.           default:
  7102.         x = -2;
  7103.         goto xhttp;
  7104.         }
  7105.     }
  7106.     makestr(&http_lfile,cmresult.sresult);
  7107.     n = ckindex("/",http_lfile,-1,1,0);
  7108.     if (n)
  7109.       p = &http_lfile[n];
  7110.     else
  7111.       p = http_lfile;
  7112.     if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) {
  7113.           if (x == -3) {
  7114.             printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post");
  7115.             x = -9;
  7116.           }
  7117.           goto xhttp;
  7118.         }
  7119.     if (!*s) s = NULL;
  7120.     makestr(&http_rfile,s);
  7121.  
  7122.     if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) {
  7123.           if (x != -3)
  7124.             goto xhttp;
  7125.         }
  7126.         if (*s)
  7127.           makestr(&http_dfile,s);
  7128.     }
  7129.     switch (http_action) {
  7130.       case HTTP_DEL:            /* DELETE */
  7131.     if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7132.           if (x == -3) {
  7133.             printf("?Delete what?\n");
  7134.             x = -9;
  7135.           }
  7136.           goto xhttp;
  7137.         }
  7138.     makestr(&http_rfile,s);
  7139.     break;
  7140.       case HTTP_CON:            /* CONNECT */
  7141.         if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) {
  7142.           if (x == -3) {
  7143.             printf("?Remote host[:port] is required\n");
  7144.             x = -9;
  7145.           }
  7146.           goto xhttp;
  7147.         }
  7148.     makestr(&http_rfile,s);
  7149.     break;
  7150.       case HTTP_HED: {            /* HEAD */
  7151.       char buf[CKMAXPATH+1];
  7152.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7153.           if (x == -3) {
  7154.           printf("?Head of what?\n");
  7155.           x = -9;
  7156.           }
  7157.           goto xhttp;
  7158.       }
  7159.       makestr(&http_rfile,s);
  7160.  
  7161.       if (http_array || http_type) { /* Default result filename */
  7162.           p = "";             /* None if /ARRAY or /TOSCREEN */
  7163.       } else {
  7164.           n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */
  7165.           if (n)                          /* and add ".head" */
  7166.         p = &http_rfile[n];
  7167.           else
  7168.         p = http_rfile;
  7169.           ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL);
  7170.           p = buf;
  7171.       }
  7172.       if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) {
  7173.           if (x != -3)
  7174.         goto xhttp;
  7175.       }
  7176.       makestr(&http_lfile,s);
  7177.       break;
  7178.       }
  7179.       case HTTP_GET:            /* GET */
  7180.       case HTTP_IDX: {            /* INDEX */
  7181.       char * lfile = "";
  7182.       if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  7183.           if (x == -3) {
  7184.           printf("?Get what?\n");
  7185.           x = -9;
  7186.           }
  7187.           goto xhttp;
  7188.       }
  7189.       makestr(&http_rfile,s);
  7190.       if (http_action == HTTP_GET && !http_type)
  7191.         zstrip(http_rfile,&lfile);
  7192.       if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0)
  7193.         if (x != -3)
  7194.           goto xhttp;
  7195.       makestr(&http_lfile,s);
  7196.       break;
  7197.       }
  7198.       case HTTP_OPN: {
  7199.       int sslswitch = 0;
  7200. #ifdef CK_SSL
  7201.       struct FDB sw, fl;
  7202.       cmfdbi(&sw,
  7203.          _CMKEY,        /* fcode */
  7204.          "IP host name or address, or switch", /* hlpmsg */
  7205.          "",            /* default */
  7206.          "",            /* addtl string data */
  7207.          2,            /* addtl numeric data 1: tbl size */
  7208.          4,            /* addtl numeric data 2: 4 = cmswi */
  7209.          xxstring,        /* Processing function */
  7210.          sslswtab,        /* Keyword table */
  7211.          &fl            /* Pointer to next FDB */
  7212.          );
  7213.       cmfdbi(&fl,            /* 2nd FDB - host */
  7214.          _CMFLD,        /* fcode */
  7215.          "",            /* hlpmsg */
  7216.          "",            /* default */
  7217.          "",            /* addtl string data */
  7218.          0,            /* addtl numeric data 1 */
  7219.          0,            /* addtl numeric data 2 */
  7220.          xxstring,
  7221.          NULL,
  7222.          NULL
  7223.          );
  7224.       x = cmfdb(&sw);        /* Parse switch or host */
  7225.       if (x < 0)            /* Error */
  7226.         goto xhttp;
  7227.       if (cmresult.fcode == _CMFLD) { /* Host */
  7228.           s = cmresult.sresult;      /* Set up expected pointer */
  7229.           goto havehost;              /* Go parse rest of command */
  7230.       }
  7231.       sslswitch = 1;        /* /SSL or /TLS switch - set flag */
  7232. #endif /* CK_SSL */
  7233.  
  7234.       /* Parse host */
  7235.  
  7236.       if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) {
  7237.           if (x == -3) {
  7238.           printf("?Open what?\n");
  7239.           x = -9;
  7240.           }
  7241.           goto xhttp;
  7242.       }
  7243.  
  7244.     havehost:            /* Come here with s -> host */
  7245. #ifdef CK_URL
  7246.       x = urlparse(s,&http_url);    /* Was a URL given? */
  7247.       if (x < 1) {            /* Not a URL */
  7248. #endif /* CK_URL */
  7249.           makestr(&http_host,s);
  7250.           if ((x =
  7251.            cmfld("Service name or port number",
  7252.              "http",&s,xxstring)) < 0)
  7253.         goto xhttp;
  7254.           else
  7255.         makestr(&http_srv,s);
  7256. #ifdef CK_URL
  7257.       } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */
  7258.              ckstrcmp(http_url.svc,"https",-1,0)) {
  7259.           printf("?Non-HTTP URL\n");
  7260.           x = -9;
  7261.           goto xhttp;
  7262.       } else {            /* Have HTTP URL */
  7263.           makestr(&http_srv, http_url.svc);
  7264.           makestr(&http_user,http_url.usr);
  7265.           makestr(&http_pass,http_url.psw);
  7266.           makestr(&http_host,http_url.hos);
  7267.           if (http_url.por)
  7268.         makestr(&http_srv,http_url.por);
  7269.           makestr(&http_rfile,http_url.pth);
  7270.       }
  7271.       if (http_rfile) {        /* Open, GET, and Close */
  7272.           printf("?Directory/file path not allowed in HTTP OPEN URL\n");
  7273.           x = -9;
  7274.           goto xhttp;
  7275.       }
  7276.       if (!ckstrcmp("https",http_srv,-1,0) || sslswitch ||
  7277.           !ckstrcmp("443",http_srv,-1,0))
  7278.         http_ssl = 1;
  7279. #endif /* CK_URL */
  7280.       break;
  7281.       }
  7282.       case HTTP_CLS:
  7283.         break;
  7284.     }
  7285.     if ((x = cmcfm()) < 0)
  7286.       goto xhttp;
  7287.  
  7288.     if (http_action == HTTP_OPN) {
  7289.         x = (http_open(http_host,http_srv,http_ssl,rdns,128) == 0);
  7290.         if (x) {
  7291.             if (!quiet) {
  7292.               if (rdns[0])
  7293.                 printf("Connected to %s [%s]\r\n",http_host,rdns);
  7294.               else
  7295.                 printf("Connected to %s\r\n",http_host);
  7296.             }
  7297.             if (http_agent) {
  7298.                 if (http_d_agent)
  7299.           free(http_d_agent);
  7300.                 http_d_agent = http_agent;
  7301.                 http_agent = NULL;
  7302.             }
  7303.             if (http_user) {
  7304.                 if (http_d_user)
  7305.           free(http_d_user);
  7306.                 http_d_user = http_user;
  7307.                 http_user = NULL;
  7308.             }
  7309.             if (http_pass) {
  7310.                 if (http_d_pass) {
  7311.                     memset(http_d_pass,0,strlen(http_d_pass));
  7312.                     free(http_d_pass);
  7313.                 }
  7314.                 http_d_pass = http_pass;
  7315.                 http_pass = NULL;
  7316.             }
  7317.             http_d_type = http_type;
  7318.         } else {
  7319.             if (!quiet)
  7320.           printf("?HTTP Connection failed.\r\n");
  7321.         }
  7322.     } else if (http_action == HTTP_CLS) {
  7323.         if (http_d_agent) {
  7324.             free(http_d_agent);
  7325.             http_d_agent = NULL;
  7326.         }
  7327.         if (http_d_user) {
  7328.             free(http_d_user);
  7329.             http_d_user = NULL;
  7330.         }
  7331.         if (http_d_pass) {
  7332.             memset(http_d_pass,0,strlen(http_d_pass));
  7333.             free(http_d_pass);
  7334.             http_d_pass = NULL;
  7335.         }
  7336.         http_d_type = 0;
  7337.         x = (http_close() == 0);
  7338.     }
  7339.     if ((http_action != HTTP_CLS) &&
  7340.     (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */
  7341.  
  7342.     /* All-in-one actions when a URL is given... */
  7343.  
  7344. #ifdef CK_URL
  7345.     if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */
  7346.         if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */
  7347.         ckstrcmp(http_url.svc,"https",-1,0)) {
  7348.         printf("?Non-HTTP URL\n");
  7349.         x = -9;
  7350.         goto xhttp;
  7351.         } else {            /* Yes, collect the pieces */
  7352.         makestr(&http_srv, http_url.svc);
  7353.         makestr(&http_user,http_url.usr);
  7354.         makestr(&http_pass,http_url.psw);
  7355.         makestr(&http_host,http_url.hos);
  7356.         if (http_url.por)
  7357.           makestr(&http_srv,http_url.por);
  7358.         makestr(&http_rfile,http_url.pth);
  7359.         }
  7360.         if (!http_rfile) {        /* Still have a path? */
  7361.                 makestr(&http_rfile,"/");
  7362.         }
  7363.         if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */
  7364.         !ckstrcmp("443",http_srv,-1,0))
  7365.           http_ssl = 1;
  7366.         if (http_isconnected())    /* Close any open HTTP connection */
  7367.           http_close();
  7368.         if (http_pass == NULL && http_d_pass != NULL)
  7369.           makestr(&http_pass,http_d_pass);
  7370.         x = (http_open(http_host,http_srv,http_ssl,rdns,128) == 0);
  7371.         if (x < 0) {
  7372.         x = 0;
  7373.         goto xhttp;
  7374.         }
  7375.         allinone = 1;
  7376.     }
  7377. #endif /* CK_URL */
  7378.         if (http_pass == NULL && http_d_pass != NULL)
  7379.       makestr(&http_pass,http_d_pass);
  7380.  
  7381.     if (http_action == HTTP_OPN && allinone) {
  7382.         http_action = HTTP_GET;
  7383.     }
  7384.         x = xdohttp(http_action,
  7385.                     http_lfile,
  7386.             http_rfile,
  7387.                     http_dfile,
  7388.             http_agent ? http_agent : http_d_agent,
  7389.             http_hdr,
  7390.             http_user  ? http_user  : http_d_user,
  7391.             http_pass  ? http_pass  : http_d_pass,
  7392.             http_mime,
  7393.             http_array,
  7394.             http_type
  7395.             );
  7396.     if (allinone)
  7397.       x = (http_close() == 0);
  7398.     }
  7399.  
  7400.   xhttp:
  7401.     if (http_agent) free(http_agent);
  7402.     if (http_hdr)   free(http_hdr);
  7403.     if (http_user)  free(http_user);
  7404.     if (http_pass) {
  7405.         memset(http_pass,0,strlen(http_pass));
  7406.         free(http_pass);
  7407.     }
  7408.     if (http_mime)  free(http_mime);
  7409.     if (http_lfile) free(http_lfile);
  7410.     if (http_rfile) free(http_rfile);
  7411.     if (http_dfile) free(http_dfile);
  7412.     if (http_host)  free(http_host);
  7413.     if (http_srv)   free(http_srv);
  7414.  
  7415.     if (x > -1)
  7416.       success = x;
  7417.     return(x);
  7418. }
  7419. #endif /* TCPSOCKET */
  7420. #endif /* NOHTTP */
  7421.  
  7422.  
  7423. #ifndef NOSPL
  7424. static int
  7425. dotrace() {
  7426.     int on = 1;
  7427.     struct FDB sw, kw;
  7428.     cmfdbi(&sw,                /* 1st FDB - switch */
  7429.        _CMKEY,            /* fcode */
  7430.        "Trace object;\n Or switch", /* help */
  7431.        "",                /* default */
  7432.        "",                /* addtl string data */
  7433.        2,                /* keyword table size */
  7434.        4,                /* addtl numeric data 2: 4 = cmswi */
  7435.        xxstring,            /* Processing function */
  7436.        onoffsw,            /* Keyword table */
  7437.        &kw                /* Pointer to next FDB */
  7438.        );
  7439.     cmfdbi(&kw,                /* 2nd FDB - Trace object */
  7440.        _CMKEY,            /* fcode */
  7441.        "Trace object",        /* help */
  7442.        "all",            /* default */
  7443.        "",                /* addtl string data */
  7444.        ntracetab,            /* keyword table size */
  7445.        0,                /* addtl numeric data 2: 0 = keyword */
  7446.        xxstring,            /* Processing function */
  7447.        tracetab,            /* Keyword table */
  7448.        NULL                /* Pointer to next FDB */
  7449.        );
  7450.     if ((x = cmfdb(&sw)) < 0)
  7451.       return(x);
  7452.     if (cmresult.fdbaddr == &sw) {
  7453.     on = cmresult.nresult;
  7454.     if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0)
  7455.       return(x);
  7456.     } else {
  7457.     x = cmresult.nresult;
  7458.     }
  7459.     if ((y = cmcfm()) < 0)
  7460.       return(y);
  7461.  
  7462.     switch (x) {
  7463.       case TRA_ASG:
  7464.     tra_asg = on;
  7465.     break;
  7466.       case TRA_CMD:
  7467.     tra_cmd = on;
  7468.     break;
  7469.       case TRA_ALL:
  7470.     tra_asg = on;
  7471.     tra_cmd = on;
  7472.     break;
  7473.       default:
  7474.     return(-2);
  7475.     }
  7476.     printf("TRACE %s\n", on ? "ON" : "OFF");
  7477.     return(success = 1);
  7478. }
  7479. #endif /* NOSPL */
  7480.  
  7481.  
  7482. static int
  7483. doprompt() {
  7484.     extern int xcmdsrc;
  7485.     if ((x = cmtxt("Optional message","",&s,xxstring)) < 0)
  7486.       return(x);
  7487. #ifdef NOSPL
  7488.     printf("?Sorry, PROMPT requires script programming language\n");
  7489.     return(-9);
  7490. #else
  7491.     debug(F101,"Prompt cmdlvl","",cmdlvl);
  7492.     cmdlvl++;
  7493.     if (cmdlvl > CMDSTKL) {
  7494.     printf("?Command stack overflow: %d\n",cmdlvl);
  7495.     cmdlvl--;
  7496.     return(-9);
  7497.     }
  7498.     xcmdsrc = CMD_KB;
  7499.     cmdstk[cmdlvl].src = CMD_KB;    /* Say we're at the prompt */
  7500.     cmdstk[cmdlvl].lvl = 0;
  7501.     cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs;
  7502.     if (tra_cmd)
  7503.       printf("[%d] +P: \"(prompt)\"\n",cmdlvl);
  7504.     concb((char)escape);
  7505.     if (!quiet)
  7506.       printf("(Recursive command prompt; use END or RETURN to return...)\n");
  7507.  
  7508.     if (*s) {                /* If prompt given */
  7509.     makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */
  7510.     cmsetp(s);            /* Set new one */
  7511.     }
  7512.     return(success = 1);
  7513. #endif /* NOSPL */
  7514. }
  7515.  
  7516. #ifdef CKLEARN
  7517. VOID
  7518. learncmd(s) char *s; {            /* Record commands in learned script */
  7519.     char buf[64];
  7520.     int i, k;
  7521.     if (learnfp && learning) {        /* Only if open and on */
  7522.     k = ckstrncpy(buf,s,64);
  7523.     for (i = 0; i < k; i++) {    /* Get top-level command keyword */
  7524.         if (buf[i] <= SP) {
  7525.         buf[i] = NUL;
  7526.         break;
  7527.         }
  7528.     }
  7529.     k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */
  7530.     if (k == XXCON || k == XXLEARN)      /* Don't record CONNECT or LEARN */
  7531.       return;
  7532.     if (k == XXTEL) {
  7533.         fputs("SET HOST /NETWORK:TCP",learnfp);
  7534.         fputs(&s[i],learnfp);
  7535.         fputs(" TELNET /TELNET",learnfp);
  7536.         fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp);
  7537.     } else {
  7538.         fputs(s,learnfp);
  7539.         fputs("\n",learnfp);
  7540.     }
  7541.     }
  7542. }
  7543. #endif /* CKLEARN */
  7544.  
  7545.  
  7546. /*  D O C M D  --  Do a command  */
  7547.  
  7548. /*
  7549.  Returns:
  7550.    -2: user typed an illegal command
  7551.    -1: reparse needed
  7552.     0: parse was successful (even tho command may have failed).
  7553. */
  7554. #ifdef DEBUG
  7555. int cmdstats[256] = { -1, -1 };
  7556. #endif /* DEBUG */
  7557.  
  7558. int
  7559. docmd(cx) int cx; {
  7560.     extern int nolocal, cmkwflgs;
  7561.  
  7562.     debug(F101,"docmd entry, cx","",cx);
  7563.     activecmd = cx;
  7564.     doconx = ((activecmd == XXCON)  || (activecmd == XXTEL) ||
  7565.           (activecmd == XXRLOG) || (activecmd == XXPIPE) ||
  7566.               (activecmd == XXIKSD) || (activecmd == XXPTY));
  7567. /*
  7568.   Originally all commands were handled with a big switch() statement,
  7569.   but eventually this started blowing up compilers.  Now we have a series
  7570.   of separate if statements and small switches, with the commands that are
  7571.   most commonly executed in scipts and loops coming first, to speed up
  7572.   compute-bound scripts.
  7573.   */
  7574.  
  7575. #ifdef DEBUG
  7576.     if (cmdstats[0] == -1) {        /* Count commands */
  7577.     int i;                /* for tuning... */
  7578.     for (i = 0; i < 256; i++)
  7579.       cmdstats[i] = 0;
  7580.     }
  7581. #endif /* DEBUG */
  7582.  
  7583.     switch (cx) {
  7584.       case -4:                /* EOF */
  7585. #ifdef OSK
  7586.     if (msgflg)  printf("\n");
  7587. #else
  7588.     if (msgflg)  printf("\r\n");
  7589. #endif /* OSK */
  7590.       doexit(GOOD_EXIT,xitsta);
  7591.       case -3:                /* Null command */
  7592.     return(0);
  7593.       case -9:                /* Like -2, but errmsg already done */
  7594.       case -1:                /* Reparse needed */
  7595.     return(cx);
  7596.       case -6:                /* Special */
  7597.       case -2:                /* Error, maybe */
  7598.  
  7599. #ifndef NOSPL
  7600. /*
  7601.   Maybe they typed a macro name.  Let's look it up and see.
  7602. */
  7603.     if (cx == -6)            /* If they typed CR */
  7604.       ckstrncat(cmdbuf,"\015",CMDBL); /*  add it back to command buffer. */
  7605.     if (ifcmd[cmdlvl] == 2)        /* Watch out for IF commands. */
  7606.       ifcmd[cmdlvl]--;
  7607.     repars = 1;            /* Force reparse */
  7608.     cmres();
  7609.     cx = XXDO;            /* Try DO command */
  7610. #else
  7611.     return(cx);
  7612. #endif /* NOSPL */
  7613.       default:
  7614.     if (cx < 0)
  7615.       return(cx);
  7616.     break;
  7617.     }
  7618. #ifdef DEBUG
  7619.     if (cx < 256)
  7620.       cmdstats[cx]++;
  7621. #endif /* DEBUG */
  7622.  
  7623.     if ((cmkwflgs & CM_PSH)
  7624. #ifndef NOPUSH
  7625.     && nopush
  7626. #endif /* NOPUSH */
  7627.     ) {
  7628.     printf("?Access to system disabled\n");
  7629.     return(-9);
  7630.     }
  7631.     if ((cmkwflgs & CM_LOC)
  7632. #ifndef NOLOCAL
  7633.     && nolocal
  7634. #endif /* NOLOCAL */
  7635.     ) {
  7636.     printf("?Connections disabled\n");
  7637.     return(-9);
  7638.     }
  7639.  
  7640. #ifndef NOSPL
  7641.     /* Used in FOR loops */
  7642.  
  7643.     if (cx == XX_INCR || cx == XXINC  || /* _INCREMENT, INCREMENT */
  7644.     cx == XX_DECR || cx == XXDEC)     /* _DECREMENT, DECREMENT */
  7645.       return(doincr(cx));
  7646.  
  7647.     /* Define (or change the definition of) a macro or variable */
  7648.  
  7649.     if (cx == XXUNDEF || cx == XXUNDFX) {
  7650. #ifdef IKSD
  7651.     if (inserver && !ENABLED(en_asg)) {
  7652.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7653.         return(-9);
  7654.     }
  7655. #endif /* IKSD */
  7656.     return(doundef(cx));        /* [_]UNDEFINE */
  7657.     }
  7658.     if (cx == XXDEF || cx == XXASS ||
  7659.     cx == XXDFX || cx == XXASX) {
  7660. #ifdef IKSD
  7661.     if (inserver && !ENABLED(en_asg)) {
  7662.         printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7663.         return(-9);
  7664.     }
  7665. #endif /* IKSD */
  7666.     if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */
  7667.       xxdot = 1;            /* i.e. with space after it... */
  7668.     return(dodef(cx));        /* DEFINE, ASSIGN, etc... */
  7669.     }
  7670.  
  7671.     /* IF, WHILE, and friends  */
  7672.  
  7673.     if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) {
  7674.     return(doif(cx));
  7675.     }
  7676.     if (cx == XXSWIT) {            /* SWITCH */
  7677.     return(doswitch());
  7678.     }
  7679.  
  7680.     /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */
  7681.  
  7682.     if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */
  7683.     /* Note, here we don't set SUCCESS/FAILURE flag */
  7684. #ifdef COMMENT
  7685.     if ((y = cmfld("label","",&s,xxstring)) < 0) {
  7686.         if (y == -3) {
  7687.         if (cx != XXXFWD) {
  7688.             printf("?Label name required\n");
  7689.             return(-9);
  7690.         }
  7691.         } else
  7692.           return(y);
  7693.     }
  7694.     ckstrncpy(lblbuf,s,LBLSIZ);
  7695.     if ((x = cmcfm()) < 0) return(x);
  7696. #else
  7697.     if ((y = cmtxt("label","",&s,xxstring)) < 0) {
  7698.         if (y == -3) {
  7699.         if (cx != XXXFWD) {
  7700.             printf("?GOTO: Label name required: \"%s\" \"%s\"\n",
  7701.                atmbuf,
  7702.                cmdbuf);
  7703.             return(-9);
  7704.         }
  7705.         } else
  7706.           return(y);
  7707.     }
  7708.     ckstrncpy(lblbuf,s,LBLSIZ);
  7709. #endif /* COMMENT */
  7710.     s = lblbuf;
  7711.     return(dogoto(s,cx));
  7712.     }
  7713.     if (cx == XXDO || cx == XXMACRO) {    /* DO (a macro) */
  7714.     char mnamebuf[16];        /* (buffer for controlled temp name) */
  7715.     struct FDB kw, fl;
  7716.     int mx;                /* Macro index (on stack!) */
  7717.  
  7718.     if (cx == XXDO) {
  7719.         if (nmac == 0) {
  7720.         printf("\n?No macros defined\n");
  7721.         return(-9);
  7722.         }
  7723.         for (y = 0; y < nmac; y++) { /* copy the macro table into a */
  7724.         mackey[y].kwd = mactab[y].kwd; /* regular keyword table */
  7725.         mackey[y].kwval = y;    /* with value = pointer to macro tbl */
  7726.         mackey[y].flgs = mactab[y].flgs;
  7727.         }
  7728.         cmfdbi(&kw,            /* First FDB - macro name */
  7729.            _CMKEY,        /* fcode */
  7730.            "Macro",        /* hlpmsg */
  7731.            "",            /* default */
  7732.            "",            /* addtl string data */
  7733.            nmac,        /* addtl numeric data 1: tbl size */
  7734.            0,            /* addtl numeric data 2: 0 = cmkey */
  7735.            xxstring,        /* Processing function */
  7736.            mackey,        /* Keyword table */
  7737.            &fl            /* Pointer to next FDB */
  7738.            );
  7739.         cmfdbi(&fl,            /* 2nd FDB - for "{" */
  7740.            _CMFLD,        /* fcode */
  7741.            "",            /* hlpmsg */
  7742.            "",
  7743.            "",            /* addtl string data */
  7744.            0,            /* addtl numeric data 1 */
  7745.            0,            /* addtl numeric data 2 */
  7746.            xxstring,
  7747.            NULL,
  7748.            NULL
  7749.            );
  7750.         x = cmfdb(&kw);        /* Parse something */
  7751.         if (x < 0) {        /* Error */
  7752.         if (x == -3) {
  7753.             printf("?Macro name required\n");
  7754.             return(-9);
  7755.         } else
  7756.           return(x);
  7757.         }
  7758.         if (cmresult.fcode == _CMKEY) {
  7759.         extern int mtchanged;
  7760.         char * macroname = NULL;
  7761.  
  7762.         /* In case args include an \fexec() that changes the macro table */
  7763.  
  7764.         mx = x;            /* Save macro index on stack */
  7765.         mtchanged = 0;        /* Mark state of macro table */
  7766.         makestr(¯oname,mactab[mx].kwd); /* Save name */
  7767.  
  7768.         if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0)
  7769.           return(y);        /* Get macro args */
  7770.  
  7771.         if (mtchanged) {    /* Macro table changed? */
  7772.             mx = mlook(mactab,macroname,nmac); /* Look up name again */
  7773.         }
  7774.         if (macroname)
  7775.           free(macroname);
  7776.  
  7777.         return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ?
  7778.                (success = 0) : 1);
  7779.         }
  7780.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);    /* _CMFLD */
  7781.         if (atmbuf[0] == '{') {
  7782.         if ((y = cmcfm()) < 0)
  7783.           return(y);
  7784.         }
  7785.     } else {            /* XXMACRO */
  7786.         int k = 0;
  7787.         line[k++] = '{';
  7788.         line[k++] = SP;
  7789.         if ((y = cmtxt("braced list of commands","",&s,xxstring)) < 0)
  7790.           return(y);
  7791.         ckstrncpy(line+k,s,LINBUFSIZ-k);
  7792.     }
  7793.     x = strlen(line);
  7794.     if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
  7795.       return(-2);
  7796.     if (line[0] != '{' && line[x-1] != '}') {
  7797.         /* Unknown command.  If ON_UNKNOWN_COMMAND macro is defined, */
  7798.         /* parse args and then execute it, but only if it is not */
  7799.         /* already active. */
  7800.         int k = -1;
  7801.         if (!unkmacro) {
  7802.         k = mxlook(mactab,"on_unknown_command",nmac);
  7803.         }
  7804.         if (k > -1) {
  7805.         ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  7806.         z = maclvl;        /* Save the current maclvl */
  7807.         if ((y = cmtxt("text","",&s,xxstring)) < 0)
  7808.           return(y);
  7809.         ckstrncat(tmpbuf," ",TMPBUFSIZ);
  7810.         ckstrncat(tmpbuf,s,TMPBUFSIZ);
  7811.         unkmacro = 1;
  7812.         debug(F110,"ON_UNKNOWN_COMMAND",s,0);
  7813.         dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  7814.         while (maclvl > z) {
  7815.             sstate = (CHAR) parser(1);
  7816.             if (sstate) proto();
  7817.         }
  7818.         debug(F101,"UNKMAC loop exit maclvl","",maclvl);
  7819.         unkmacro = 0;
  7820.         return(success);
  7821.         }
  7822.             if (x > 0)
  7823.           printf("?Not a command or macro name: \"%s\"\n",line);
  7824.             else
  7825.           printf("?Not a command or macro name.\n");
  7826.         return(-9);
  7827.     }
  7828.     s = brstrip(line);
  7829.     sprintf(mnamebuf," ..tmp:%03d",cmdlvl);    /* safe (16) */
  7830.     x = addmac(mnamebuf,s);
  7831.     return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
  7832.     }
  7833.  
  7834.     if (cx == XXLBL) {            /* LABEL */
  7835.     if ((x = cmfld("label","",&s,xxstring)) < 0) {
  7836.         if (x == -3) {
  7837.         printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
  7838.         return(-9);
  7839.         } else return(x);
  7840.     }
  7841.     debug(F111,"LABEL",s,x);
  7842.     if ((x = cmcfm()) < 0) return(x);
  7843.     return(0);
  7844.     }
  7845.  
  7846.     if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE,  EVALUATE  */
  7847.       return(doeval(cx));
  7848.  
  7849. #ifndef NOSEXP
  7850.     if (cx == XXSEXP) {            /* Lisp-like S-Expression */
  7851.     struct stringarray * q;
  7852.     char /* *p, *r, */ *tmp, *m;
  7853.     int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
  7854.     extern int sexprc, sexppv;
  7855.  
  7856.     tmp = tmpbuf;            /* Buffer to collect SEXP */
  7857.     tmpbuf[0] = NUL;        /* Clear it */
  7858.     size = TMPBUFSIZ;        /* Capacity of buffer */
  7859.     sexprc = -1;            /* Assume bad input */
  7860.     n = 0;                /* Paren balance counter */
  7861.  
  7862.     while (1) {            /* Allow SEXP on multiple lines */
  7863.         m = contd ?
  7864.           "Continuation of S-Expression" :
  7865.         "S-Expression (\"help sexp\" for details)";
  7866.         x = cmtxt(m,"",&s,xxstring);
  7867.         if (x < 0)
  7868.           return(x);
  7869.         if (!*s)            /* Needed for (=) and (:) */
  7870.           s = atmbuf;
  7871.         k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
  7872.         if (k < 1) {
  7873.         printf("?SEXP too long - %d max\n",TMPBUFSIZ);
  7874.         return(-9);
  7875.         }
  7876.         debug(F111,contd ? "sexp contd" : "sexp",s,k);
  7877.  
  7878.         for (i = len; i < len+k; i++) { /* Check balance  */
  7879.         if (!quote && tmpbuf[i] == CMDQ) {
  7880.             quote = 1;
  7881.             continue;
  7882.         }
  7883.         if (quote) {
  7884.             quote = 0;
  7885.             continue;
  7886.         }
  7887.         if (tmpbuf[i] == '(')
  7888.           n++;
  7889.         else if (tmpbuf[i] == ')')
  7890.           n--;
  7891.         }
  7892.         if (n == 0) {        /* Break when balanced */
  7893.         break;
  7894.         }
  7895.         if (n < 0) {        /* Too many right parens */
  7896.         printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
  7897.         return(-9);
  7898.         }
  7899.         contd++;            /* Need more right parens */
  7900.         cmini(ckxech);        /* so keep parsing */
  7901.         tmp += k;            /* adjust buffer pointer */
  7902.         size -= k;            /* and capacity */
  7903.         len += k;            /* and length so far */
  7904.     }
  7905.     s = tmpbuf;
  7906.     makestr(&lastsexp,s);
  7907.     q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */
  7908.     debug(F101,"sexp split","",q->a_size);
  7909.  
  7910.     if (q->a_size == 1) {        /* We should get exactly one back */
  7911.         char * result, * dosexp();
  7912.         sexprc = 0;            /* Reset out-of-band return code */
  7913.         result = dosexp(s);        /* Get result */
  7914.         debug(F111,"sexp result",result,sexprc);
  7915.         if (sexprc == 0) {        /* Success */
  7916.         /* Echo the result if desired */
  7917.         if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
  7918.           printf(" %s\n",result ? result : "");
  7919.         makestr(&sexpval,result);
  7920.         success = sexppv > -1 ? sexppv : 1;
  7921.         return(success);
  7922.         }
  7923.     }
  7924.     if (sexprc < 0)
  7925.       printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
  7926.     return(-9);
  7927.     }
  7928. #endif /* NOSEXP */
  7929.  
  7930. #endif /* NOSPL */
  7931.  
  7932.     if (cx == XXECH || cx == XXXECH || cx == XXVOID
  7933. #ifndef NOSPL
  7934.     || cx == XXAPC
  7935. #endif /* NOSPL */
  7936.     ) {                /* ECHO or APC */
  7937.     if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
  7938.                "Text to be echoed" :
  7939.                ((cx == XXVOID) ? "Text" :
  7940.             "Application Program Command text"),
  7941.                "",
  7942.                &s,
  7943.                xxstring
  7944.                )
  7945.          ) < 0)
  7946.       return(x);
  7947.     if (!s) s = "";
  7948. #ifdef COMMENT
  7949. /* This is to preserver the pre-8.0 behavior but it's too confusing */
  7950.     x = strlen(s);
  7951.     x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
  7952. #endif /* COMMENT */
  7953.     s = brstrip(s);            /* Strip braces and doublequotes */
  7954.     if (cx == XXECH) {        /* ECHO */
  7955. #ifndef NOSPL
  7956.         if (!fndiags || fnsuccess) {
  7957. #endif /* NOSPL */
  7958. #ifdef COMMENT
  7959.         /* The "if (x)" business preserves previous behavior */
  7960.         /* by putting back the doublequotes if they were included. */
  7961.         if (x)
  7962.           printf("\"%s\"\n",s);
  7963.         else
  7964. #endif /* COMMENT */
  7965.           printf("%s\n",s);
  7966. #ifndef NOSPL
  7967.         }
  7968. #endif /* NOSPL */
  7969.     } else if (cx == XXXECH) {    /* XECHO */
  7970.         if (x)
  7971.           printf("\"%s\"",s);
  7972.         else
  7973.           printf("%s",s);
  7974. #ifdef UNIX
  7975.         fflush(stdout);
  7976. #endif /* UNIX */
  7977.     } else if (cx == XXAPC) {    /* APC */
  7978. #ifdef CK_APC
  7979.         if (apcactive == APC_LOCAL ||
  7980.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  7981.           return(success = 0);
  7982. #endif /* CK_APC */
  7983.         if (!local) {
  7984.         printf("%c_%s%c\\",ESC,s,ESC);
  7985. #ifdef UNIX
  7986.         fflush(stdout);
  7987. #endif /* UNIX */
  7988.  
  7989.         } else {            /* Local mode - have connection */
  7990. #ifndef NOSPL
  7991.         if (ckmakxmsg(tmpbuf,    /* Form APC string in buffer */
  7992.                   TMPBUFSIZ,
  7993.                   ckctoa((char)ESC),
  7994.                   ckctoa('_'),
  7995.                   s,
  7996.                   ckctoa((char)ESC),
  7997.                   ckctoa('\\'),
  7998.                   NULL,NULL,NULL,NULL,NULL,NULL,NULL
  7999.                   ) > 0)
  8000.           return(success = dooutput(tmpbuf, XXOUT));
  8001.         printf("?Too long\n");
  8002.         return(-9);
  8003. #else
  8004.         printf("%c_%s%c\\",ESC,s,ESC);
  8005. #endif /* NOSPL */
  8006.         }
  8007.     }
  8008.     return(success = 1);
  8009.     }
  8010.  
  8011. #ifndef NOSPL
  8012. /* Copy macro args from/to two levels up, used internally by _floop et al. */
  8013.     if (cx == XXGTA || cx == XXPTA) {    /* _GETARGS, _PUTARGS */
  8014.     int x;
  8015.     debug(F101,"docmd XXGTA","",XXGTA);
  8016.     debug(F101,"docmd cx","",cx);
  8017.     debug(F101,"docmd XXGTA maclvl","",maclvl);
  8018.     x = dogta(cx);
  8019.     debug(F101,"docmd dogta returns","",x);
  8020.     debug(F101,"docmd dogta maclvl","",maclvl);
  8021.     return(x);
  8022.     }
  8023. #endif /* NOSPL */
  8024.  
  8025. #ifndef NOSPL
  8026. #ifdef CKCHANNELIO
  8027.     if (cx == XXFILE)
  8028.       return(dofile(cx));
  8029.     else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
  8030.          cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
  8031.          cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
  8032.       return(dofile(cx));
  8033. #endif /* CKCHANNELIO */
  8034.  
  8035. /* ASK, ASKQ, READ */
  8036.     if (cx == XXASK  || cx == XXASKQ || cx == XXREA ||
  8037.     cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
  8038.     return(doask(cx));
  8039.     }
  8040. #endif /* NOSPL */
  8041.  
  8042. #ifndef NOFRILLS
  8043.     if (cx == XXBUG) {            /* BUG */
  8044.     if ((x = cmcfm()) < 0) return(x);
  8045.     return(dobug());
  8046.     }
  8047. #endif /* NOFRILLS */
  8048.  
  8049. #ifndef NOXFER
  8050.     if (cx == XXBYE) {            /* BYE */
  8051.     extern int ftp_cmdlin;
  8052.     if ((x = cmcfm()) < 0) return(x);
  8053.  
  8054. #ifdef NEWFTP
  8055.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  8056.         extern int stayflg, ftp_fai;
  8057.         success = ftpbye();
  8058.         if (ftp_cmdlin && !stayflg && !local)
  8059.           doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
  8060.         else
  8061.           return(success);
  8062.     }
  8063. #endif /* NEWFTP */
  8064.  
  8065.     if (!local) {
  8066.         printf("?No connection - use EXIT to quit.\n");
  8067.         return(-9);
  8068.     }
  8069.  
  8070. #ifdef CK_XYZ
  8071.     if (protocol != PROTO_K) {
  8072.         printf("?Sorry, BYE only works with Kermit protocol\n");
  8073.         return(-9);
  8074.     }
  8075. #endif /* CK_XYZ */
  8076.  
  8077. #ifdef IKS_OPTION
  8078.         if (
  8079. #ifdef CK_XYZ
  8080.             protocol == PROTO_K &&
  8081. #endif /* CK_XYZ */
  8082.             !iks_wait(KERMIT_REQ_START,1)) {
  8083.         printf(
  8084.          "?A Kermit Server is not available to process this command\n");
  8085.         return(-9);            /* Correct the return code */
  8086.         }
  8087. #endif /* IKS_OPTION */
  8088.  
  8089.     bye_active = 1;
  8090.     sstate = setgen('L',"","","");
  8091.     if (local) ttflui();        /* If local, flush tty input buffer */
  8092.     return(0);
  8093.     }
  8094. #endif /* NOXFER */
  8095.  
  8096.     if (cx == XXBEEP) {            /* BEEP */
  8097.         int x;
  8098. #ifdef OS2
  8099.     int y;
  8100.         if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
  8101.                xxstring)) < 0 )
  8102.       return (y);
  8103.         if ((x = cmcfm()) < 0) return(x);
  8104.         bleep((short)y);        /* y is one of the BP_ values */
  8105. #else  /* OS2 */
  8106.         if ((x = cmcfm()) < 0) return(x);
  8107. #ifndef NOSPL
  8108.         bleep(BP_NOTE);
  8109. #else
  8110.     putchar('\07');
  8111. #endif /* NOSPL */
  8112. #endif /* OS2 */
  8113.         return(0);
  8114.     }
  8115.  
  8116. #ifndef NOFRILLS
  8117.     if (cx == XXCLE)            /* CLEAR */
  8118.       return(success = doclear());
  8119. #endif /* NOFRILLS */
  8120.  
  8121.     if (cx == XXCOM) {            /* COMMENT */
  8122.     if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
  8123.       return(x);
  8124.     /* Don't change SUCCESS flag for this one */
  8125.     return(0);
  8126.     }
  8127.  
  8128. #ifndef NOLOCAL
  8129.     if (cx == XXCON || cx == XXCQ)    /* CONNECT or CONNECT /QUIETLY */
  8130.       return(doxconn(cx));
  8131. #endif /* NOLOCAL */
  8132.  
  8133. #ifndef NOFRILLS
  8134. #ifdef ZCOPY
  8135.     if (cx == XXCPY) {            /* COPY a file */
  8136. #ifdef IKSD
  8137.     if (inserver && !ENABLED(en_cpy)) {
  8138.         printf("?Sorry, COPY is disabled\n");
  8139.         return(-9);
  8140.     }
  8141. #endif /* IKSD */
  8142. #ifdef CK_APC
  8143.     if (apcactive == APC_LOCAL ||
  8144.         (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8145.         )
  8146.       return(success = 0);
  8147. #endif /* CK_APC */
  8148.     return(docopy());
  8149.     }
  8150. #endif /* ZCOPY */
  8151. #ifdef NT
  8152.     if ( cx == XXLINK ) {
  8153. #ifdef IKSD
  8154.         if (inserver && !ENABLED(en_cpy)) {
  8155.             printf("?Sorry, LINK (COPY) is disabled\n");
  8156.             return(-9);
  8157.         }
  8158. #endif /* IKSD */
  8159. #ifdef CK_APC
  8160.         if (apcactive == APC_LOCAL ||
  8161.             (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8162.             )
  8163.           return(success = 0);
  8164. #endif /* CK_APC */
  8165.         return(dolink());
  8166.     }
  8167. #endif /* NT */
  8168. #endif /* NOFRILLS */
  8169.  
  8170.     /* CD[UP] or BACK */
  8171.     if (cx == XXCWD  || cx == XXCDUP || cx == XXBACK ||
  8172.     cx == XXLCWD || cx == XXLCDU) {
  8173. #ifdef LOCUS
  8174.     if (!locus) {
  8175.         if (cx == XXCWD) {
  8176. #ifdef NOXFER
  8177.                 return(-2);
  8178. #else
  8179.                 return(dormt(XZCWD));
  8180. #endif /* NOXFER */
  8181.         } else if (cx == XXCDUP) {
  8182. #ifdef NOXFER
  8183.                 return(-2);
  8184. #else
  8185.                 return(dormt(XZCDU));
  8186. #endif /* NOXFER */
  8187.             }
  8188.     }
  8189. #endif /* LOCUS */
  8190. #ifdef IKSD
  8191.     if (inserver && !ENABLED(en_cwd)) {
  8192.         printf("?Sorry, changing directories is disabled\n");
  8193.         return(-9);
  8194.     }
  8195. #endif /* IKSD */
  8196.     return(success = docd(cx));
  8197.     }
  8198.  
  8199.     if (cx == XXCHK)            /* CHECK */
  8200.       return(success = dochk());
  8201.  
  8202.     if (cx == XXCLO) {            /* CLOSE */
  8203.     x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
  8204.           "connection",xxstring);
  8205.     if (x == -3) {
  8206.         printf("?You must say which file or log\n");
  8207.         return(-9);
  8208.     }
  8209.     if (x < 0) return(x);
  8210.     if ((y = cmcfm()) < 0) return(y);
  8211. #ifndef NOLOCAL
  8212.     if (x == 9999) {        /* CLOSE CONNECTION */
  8213.         x = clsconnx(0);
  8214.         switch (x) {
  8215.           case 0:
  8216.         if (msgflg) printf("?Connection was not open\n");
  8217.           case -1:
  8218.         return(0);
  8219.           case 1:
  8220.         whyclosed = WC_CLOS;
  8221.         return(1);
  8222.         }
  8223.         return(0);
  8224.     }
  8225. #endif /* NOLOCAL */
  8226.     y = doclslog(x);
  8227.     success = (y == 1);
  8228.     return(success);
  8229.     }
  8230.  
  8231. #ifndef NOSPL
  8232.     if (cx == XXDCL || cx == XXUNDCL) {    /* DECLARE an array */
  8233.     return(dodcl(cx));
  8234.     }
  8235. #endif /* NOSPL */
  8236.  
  8237. #ifndef NODIAL
  8238.     if (cx == XXRED  || cx == XXDIAL || cx == XXPDIA ||
  8239.     cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
  8240. #ifdef VMS
  8241.     extern int batch;
  8242. #else
  8243. #ifdef UNIXOROSK
  8244.     extern int backgrd;
  8245. #endif /* UNIXOROSK */
  8246. #endif /* VMS */
  8247.     x = dodial(cx);
  8248.     debug(F101,"dodial returns","",x);
  8249.     if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
  8250.         (x > 0) &&            /* If DIAL or REDIAL succeeded */
  8251.         (dialsta != DIA_PART) &&    /* and it wasn't partial */
  8252.         (dialcon > 0)) {
  8253.         if ((dialcon == 1 ||    /* And DIAL CONNECT is ON, */
  8254.         ((dialcon == 2) &&    /* or DIAL CONNECT is AUTO */
  8255.          !xcmdsrc        /* and we're at top level... */
  8256. #ifdef VMS
  8257.          && !batch        /* Not if running from batch */
  8258. #else
  8259. #ifdef UNIXOROSK
  8260.          && !backgrd        /* Not if running in background */
  8261. #endif /* UNIXOROSK */
  8262. #endif /* VMS */
  8263.          ))) /* Or AUTO */
  8264.           x = doconect(dialcq,    /* Then also CONNECT */
  8265.                            cmdlvl == 0 ? 1 : 0
  8266.                );
  8267.         if (ttchk() < 0)
  8268.           dologend();
  8269.     }
  8270.     return(success = x);
  8271.     }
  8272. #endif /* NODIAL */
  8273.  
  8274. #ifndef NOPUSH
  8275. #ifdef CK_REXX
  8276.     if (cx == XXREXX) {            /* REXX */
  8277.         extern int nopush;
  8278.         if ( nopush )
  8279.           return(success=0);
  8280.         return(dorexx());
  8281.     }
  8282. #endif /* CK_REXX */
  8283. #endif /* NOPUSH */
  8284.  
  8285. #ifndef NOFRILLS
  8286.     if (cx == XXDEL || cx == XXLDEL) {    /* DELETE */
  8287. #ifdef LOCUS
  8288.     if (!locus && cx != XXLDEL) {
  8289. #ifdef NOXFER
  8290.         return(-2);
  8291. #else
  8292.         return(dormt(XZDEL));
  8293. #endif /* NOXFER */
  8294.         }
  8295. #endif /* LOCUS */
  8296. #ifdef IKSD
  8297.     if (inserver && (!ENABLED(en_del)
  8298. #ifdef CK_LOGIN
  8299.              || isguest
  8300. #endif /* CK_LOGIN */
  8301.              )) {
  8302.         printf("?Sorry, DELETE is disabled\n");
  8303.         return(-9);
  8304.     }
  8305. #endif /* IKSD */
  8306. #ifdef CK_APC
  8307.     if ((apcactive == APC_LOCAL) ||
  8308.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8309.       return(success = 0);
  8310. #endif /* CK_APC */
  8311.     return(dodel());
  8312.     }
  8313. #endif /* NOFRILLS */
  8314.  
  8315.     if (cx == XXDIR || cx == XXLS || cx == XXLDIR) { /* DIRECTORY or LS */
  8316. #ifdef LOCUS
  8317.     if (!locus && cx != XXLDIR) {
  8318. #ifdef NOXFER
  8319.         return(-2);
  8320. #else
  8321.         return(dormt(XZDIR));
  8322. #endif /* NOXFER */
  8323.         }
  8324. #endif /* LOCUS */
  8325. #ifdef IKSD
  8326.     if (inserver && !ENABLED(en_dir)) {
  8327.         printf("?Sorry, DIRECTORY is disabled\n");
  8328.         return(-9);
  8329.     }
  8330. #endif /* IKSD */
  8331.     return(dodir(cx));
  8332.     }
  8333.  
  8334. #ifndef NOSPL
  8335.     if (cx == XXELS)            /* ELSE */
  8336.       return(doelse());
  8337. #endif /* NOSPL */
  8338.  
  8339. #ifndef NOSERVER
  8340. #ifndef NOFRILLS
  8341.     if (cx == XXENA || cx == XXDIS) {    /* ENABLE, DISABLE */
  8342.     s = (cx == XXENA) ?
  8343.       "Server function to enable" :
  8344.         "Server function to disable";
  8345.  
  8346.     if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
  8347.         if (x == -3) {
  8348.         printf("?Name of server function required\n");
  8349.         return(-9);
  8350.         } else return(x);
  8351.     }
  8352.     if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
  8353.         if (y == -3) {
  8354.         printf("?Please specify remote, local, or both\n");
  8355.         return(-9);
  8356.         } else return(y);
  8357.     }
  8358.     if (cx == XXDIS)        /* Disabling, not enabling */
  8359.       y = 3 - y;
  8360.     if ((z = cmcfm()) < 0) return(z);
  8361. #ifdef CK_APC
  8362.     if ((apcactive == APC_LOCAL) ||
  8363.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8364.       return(success = 0);
  8365. #endif /* CK_APC */
  8366. #ifdef IKSD
  8367.         /* This may seem like it duplicates the work in doenable()  */
  8368.         /* but this code returns failure whereas doenable() returns */
  8369.         /* success.                                                 */
  8370.         if (inserver &&
  8371. #ifdef IKSDCONF
  8372.             iksdcf &&
  8373. #endif /* IKSDCONF */
  8374.             (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
  8375.               isguest))
  8376.             return(success = 0);
  8377. #endif /* IKSD */
  8378.     return(doenable(y,x));
  8379.     }
  8380. #endif /* NOFRILLS */
  8381. #endif /* NOSERVER */
  8382.  
  8383. #ifndef NOSPL
  8384.     if (cx == XXRET) {            /* RETURN */
  8385.     if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
  8386.       return(x);
  8387.     s = brstrip(s);            /* Strip braces */
  8388.     if (cmdlvl == 0)        /* At top level, nothing happens... */
  8389.       return(success = 1);
  8390.     switch (cmdstk[cmdlvl].src) {    /* Action depends on command source */
  8391.       case CMD_TF:            /* Command file */
  8392.         popclvl();            /* Pop command level */
  8393.         return(success = 1);    /* always succeeds */
  8394.       case CMD_MD:            /* Macro */
  8395.       case CMD_KB:            /* Prompt */
  8396.         return(doreturn(s));    /* Trailing text is return value. */
  8397.       default:            /* Shouldn't happen */
  8398.         return(-2);
  8399.     }
  8400.     }
  8401. #endif /* NOSPL */
  8402.  
  8403. #ifndef NOSPL
  8404.     if (cx == XXOPE)            /* OPEN */
  8405.       return(doopen());
  8406. #endif /* NOSPL */
  8407.  
  8408. #ifndef NOSPL
  8409.     if (cx == XXOUT || cx == XXLNOUT) {    /* OUTPUT or LINEOUT */
  8410.     if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
  8411.       return(x);
  8412. #ifdef CK_APC
  8413.     if ((apcactive == APC_LOCAL) ||
  8414.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8415.       return(success = 0);
  8416. #endif /* CK_APC */
  8417.     debug(F110,"OUTPUT 1",s,0);
  8418.     s = brstrip(s);            /* Strip enclosing braces, */
  8419.     debug(F110,"OUTPUT 2",s,0);
  8420. /*
  8421.   I don't think I could ever fully explain this in a million years...
  8422.   We have read the user's string without calling the variable-expander
  8423.   function.  Now, before we call it, we have to double backslashes that
  8424.   appear before \N, \B, \L, and \ itself, so the expander function will
  8425.   reduce them back to single backslashes, so when we call dooutput()...
  8426.   But it's more complicated than that.
  8427. */
  8428.     if (cmdgquo()) {        /* Only if COMMAND QUOTING ON ... */
  8429.         for (x = 0, y = 0; s[x]; x++, y++) {
  8430.         if (s[x] == CMDQ) {
  8431.             char c = s[x+1];
  8432.             if (c == 'n' || c == 'N' ||
  8433.             c == 'b' || c == 'B' ||
  8434.             c == 'l' || c == 'L' ||
  8435.             c == CMDQ)
  8436.               line[y++] = CMDQ;
  8437.         }
  8438.         line[y] = s[x];
  8439.         }
  8440.         line[y++] = '\0';        /* Now expand variables, etc. */
  8441.         debug(F110,"OUTPUT 3",line,0);
  8442.         s = line+y+1;
  8443.         x = LINBUFSIZ - (int) strlen(line) - 1;
  8444.         debug(F101,"OUTPUT size","",x);
  8445.         if (zzstring(line,&s,&x) < 0)
  8446.           return(success = 0);
  8447.         s = line+y+1;
  8448.         debug(F110,"OUTPUT 4",s,0);
  8449.     }
  8450.     success = dooutput(s,cx);
  8451.     return(success);
  8452.     }
  8453. #endif /* NOSPL */
  8454.  
  8455. #ifdef ANYX25
  8456. #ifndef IBMX25
  8457.     if (cx == XXPAD) {            /* PAD commands */
  8458.     x = cmkey(padtab,npadc,"PAD command","",xxstring);
  8459.     if (x == -3) {
  8460.         printf("?You must specify a PAD command to execute\n");
  8461.         return(-9);
  8462.     }
  8463.     if (x < 0) return(x);
  8464.  
  8465.     switch (x) {
  8466.       case XYPADL:
  8467.         if (x25stat() < 0)
  8468.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8469.         else {
  8470.         x25clear();
  8471.         initpad();
  8472.         }
  8473.         break;
  8474.       case XYPADS:
  8475.         if (x25stat() < 0)
  8476.           printf("Not connected\r\n");
  8477.         else {
  8478.         extern int linkid, lcn;
  8479.         conol("Connected thru ");
  8480.         conol(ttname);
  8481.         printf(", Link id %d, Logical channel number %d\r\n",
  8482.                linkid,lcn);
  8483.         }
  8484.         break;
  8485.       case XYPADR:
  8486.         if (x25stat() < 0)
  8487.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8488.         else
  8489.           x25reset(0,0);
  8490.         break;
  8491.       case XYPADI:
  8492.         if (x25stat() < 0)
  8493.           printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8494.         else
  8495.           x25intr(0);
  8496.     }
  8497.     return(0);
  8498.     }
  8499. #endif /* IBMX25 */
  8500. #endif /* ANYX25 */
  8501.  
  8502. #ifndef NOSPL
  8503.     if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
  8504.       return(dopaus(cx));
  8505. #endif /* NOSPL */
  8506.  
  8507. #ifndef NOFRILLS
  8508.     if (cx == XXPRI) {
  8509. #ifdef IKSD
  8510. #ifdef CK_LOGIN
  8511.     if (inserver && (isguest || !ENABLED(en_pri))) {
  8512.         printf("?Sorry, printing is disabled\n");
  8513.         return(-9);
  8514.     }
  8515. #endif /* CK_LOGIN */
  8516. #endif /* IKSD */
  8517.     if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
  8518.         if (x == -3) {
  8519.         printf("?A file specification is required\n");
  8520.         return(-9);
  8521.         } else return(x);
  8522.     }
  8523.     if (y != 0) {
  8524.         printf("?Wildcards not allowed\n");
  8525.         return(-9);
  8526.     }
  8527.     ckstrncpy(line,s,LINBUFSIZ);
  8528.     s = "";
  8529. #ifndef NT
  8530.     if ((x = cmtxt("Local print command options, or carriage return","",&s,
  8531.                xxstring)) < 0)
  8532.       return(x);
  8533. #endif /* NT */
  8534.     if ((x = cmcfm()) < 0)
  8535.       return(x);
  8536.     return(success = (zprint(s,line) == 0) ? 1 : 0);
  8537.     }
  8538. #endif /* NOFRILLS */
  8539.  
  8540. #ifdef TCPSOCKET
  8541. #ifndef NOPUSH
  8542.     if (cx == XXPNG)             /* PING an IP host */
  8543.       return(doping());
  8544. #endif /* NOPUSH */
  8545.  
  8546. #ifndef NOFTP
  8547.     if (cx == XXFTP)            /* FTP */
  8548. #ifdef SYSFTP
  8549. #ifndef NOPUSH
  8550.       return(doftp());            /* Just runs system's ftp program */
  8551. #else
  8552.       return(-2);
  8553. #endif /* NOPUSH */
  8554. #else
  8555.     return(doxftp());
  8556. #endif /* SYSFTP */
  8557. #endif /* NOFTP */
  8558. #endif /* TCPSOCKET */
  8559.  
  8560.     if (cx == XXPWD || cx == XXLPWD) {    /* PWD */
  8561. #ifdef OS2
  8562.     char *pwp;
  8563. #endif /* OS2 */
  8564.     if ((x = cmcfm()) < 0)
  8565.       return(x);
  8566. #ifdef LOCUS
  8567.     if (!locus && cx != XXLPWD) {
  8568. #ifdef NOXFER
  8569.         return(-2);
  8570. #else
  8571.         return(dormt(XZPWD));
  8572. #endif /* NOXFER */
  8573.         }
  8574. #endif /* LOCUS */
  8575.  
  8576. #ifndef MAC
  8577. #ifndef OS2
  8578. #ifdef UNIX
  8579.     printf("%s\n",zgtdir());
  8580. #else
  8581.     xsystem(PWDCMD);
  8582. #endif /* UNIX */
  8583.     return(success = 1);        /* Blind faith */
  8584. #else  /* OS2 */
  8585.     if (pwp = zgtdir()) {
  8586.         printf("%s\n",pwp);
  8587.         return(success = ((int)strlen(pwp) > 0));
  8588.     } else return(success = 0);
  8589. #endif /* OS2 */
  8590. #else  /* MAC */
  8591.     if (pwp = zgtdir()) {
  8592.         printf("%s\n",pwp);
  8593.         return(success = ((int)strlen(pwp) > 0));
  8594.     } else return(success = 0);
  8595. #endif /* MAC */
  8596.     }
  8597.  
  8598.     if (cx == XXQUI || cx == XXEXI) {    /* EXIT, QUIT */
  8599.     extern int quitting;
  8600.  
  8601.     if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
  8602.       return(y);
  8603.     if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
  8604.       return(y);
  8605.     s = brstrip(s);
  8606.     ckstrncpy(line,s,LINBUFSIZ);
  8607.  
  8608.     if (!hupok(0))            /* Check if connection still open */
  8609.       return(success = 0);
  8610.  
  8611.     if (line[0])            /* Print EXIT message if given */
  8612.       printf("%s\n",(char *)line);
  8613.  
  8614.     quitting = 1;            /* Flag that we are quitting. */
  8615.  
  8616. #ifdef VMS
  8617.     doexit(GOOD_EXIT,x);
  8618. #else
  8619. #ifdef OSK
  8620. /* Returning any codes here makes the OS-9 shell print an error message. */
  8621.     doexit(GOOD_EXIT,-1);
  8622. #else
  8623. #ifdef datageneral
  8624.         doexit(GOOD_EXIT,x);
  8625. #else
  8626.     doexit(x,-1);
  8627. #endif /* datageneral */
  8628. #endif /* OSK */
  8629. #endif /* VMS */
  8630.     }
  8631.  
  8632. #ifndef NOXFER
  8633. #ifndef NOFRILLS
  8634.     if (cx == XXERR) {            /* ERROR */
  8635. #ifdef CK_XYZ
  8636.     if (protocol != PROTO_K) {
  8637.         printf("Sorry, E-PACKET only works with Kermit protocol\n");
  8638.         return(-9);
  8639.     }
  8640. #endif /* CK_XYZ */
  8641.     if ((x = cmcfm()) < 0) return(x);
  8642.     ttflui();
  8643.     epktflg = 1;
  8644.     sstate = 'a';
  8645.     return(0);
  8646.     }
  8647. #endif /* NOFRILLS */
  8648.  
  8649.     if (cx == XXFIN) {            /* FINISH */
  8650. #ifdef NEWFTP
  8651.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8652.       return(ftpbye());
  8653. #endif /* NEWFTP */
  8654. #ifdef CK_XYZ
  8655.     if (protocol != PROTO_K) {
  8656.         printf("Sorry, FINISH only works with Kermit protocol\n");
  8657.         return(-9);
  8658.     }
  8659. #endif /* CK_XYZ */
  8660.     if ((x = cmcfm()) < 0) return(x);
  8661.  
  8662. #ifdef IKS_OPTION
  8663.         if (
  8664. #ifdef CK_XYZ
  8665.             protocol == PROTO_K &&
  8666. #endif /* CK_XYZ */
  8667.             !iks_wait(KERMIT_REQ_START,1)) {
  8668.         printf(
  8669.               "?A Kermit Server is not available to process this command\n");
  8670.         return(-9);            /* Correct the return code */
  8671.         }
  8672. #endif /* IKS_OPTION */
  8673.  
  8674.     sstate = setgen('F',"","","");
  8675.     if (local) ttflui();        /* If local, flush tty input buffer */
  8676.     return(0);
  8677.     }
  8678. #endif /* NOXFER */
  8679.  
  8680. #ifndef NOSPL
  8681.     if (cx == XXFOR)            /* FOR loop */
  8682.       return(dofor());
  8683. #endif /* NOSPL */
  8684.  
  8685. #ifndef NOXFER
  8686.     /* GET MGET REGET RETRIEVE etc */
  8687.     if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
  8688. #ifdef IKSD
  8689.     if (inserver && !ENABLED(en_sen)) {
  8690.         printf("?Sorry, reception of files is disabled\n");
  8691.         return(-9);
  8692.     }
  8693. #endif /* IKSD */
  8694.     return(doxget(cx));
  8695.     }
  8696. #endif /* NOXFER */
  8697.  
  8698. #ifndef NOSPL
  8699. #ifndef NOFRILLS
  8700.     if (cx == XXGOK) {            /* GETOK */
  8701.     return(success = doask(cx));
  8702.     }
  8703. #endif /* NOFRILLS */
  8704. #endif /* NOSPL */
  8705.  
  8706.     if (cx == XXHLP) {            /* HELP */
  8707. #ifdef NOHELP
  8708.     return(dohlp(XXHLP));
  8709. #else
  8710.     x = cmkey2(cmdtab,ncmd,"\nCommand or topic","help",toktab,xxstring,3);
  8711.     debug(F101,"HELP command x","",x);
  8712.     if (x == -5) {
  8713.         y = chktok(toktab);
  8714.         debug(F101,"HELP cmkey token","",y);
  8715.         /* ungword(); */
  8716.         switch (y) {
  8717. #ifndef NOPUSH
  8718.           case '!': x = XXSHE; break;
  8719. #endif /* NOPUSH */
  8720.           case '#': x = XXCOM; break;
  8721.           case ';': x = XXCOM; break;
  8722. #ifndef NOSPL
  8723.               case '.': x = XXDEF; break;
  8724.           case ':': x = XXLBL; break;
  8725. #ifndef NOSEXP
  8726.           case '(': x = XXSEXP; break;
  8727. #endif /* NOSEXP */
  8728. #endif /* NOSPL */
  8729.           case '&': x = XXECH; break;
  8730.           default:
  8731.         printf("\n?Invalid - %s\n",cmdbuf);
  8732.         x = -2;
  8733.         }
  8734.     }
  8735.     makestr(&hlptok,atmbuf);
  8736.     debug(F111,"HELP token",hlptok,x);
  8737.     return(dohlp(x));
  8738. #endif /* NOHELP */
  8739.     }
  8740.  
  8741. #ifndef NOHELP
  8742.     if (cx == XXINT)            /* INTRO */
  8743.       return(hmsga(introtxt));
  8744.     if (cx == XXNEW) {            /* NEWS */
  8745.     int x;
  8746.     extern char * k_info_dir;
  8747.     x = hmsga(newstxt);
  8748.     return(x);
  8749.     }
  8750.  
  8751. #ifdef OS2ONLY
  8752.     if (cx == XXUPD) {            /* View UPDATE file */
  8753.         extern char exedir[];
  8754.         char * pTopic;
  8755.         char updstr[2048];
  8756.         if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
  8757.             return x;
  8758. #ifdef COMMENT
  8759.     sprintf(updstr,
  8760.         "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
  8761. %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
  8762.         exedir,exedir,exedir,exedir,pTopic
  8763.         );
  8764. #else
  8765.     if (ckmakxmsg(updstr,
  8766.              2048,
  8767.              "start view ",
  8768.              exedir,
  8769.              "\\docs\\k2.inf+",
  8770.              exedir,
  8771.              "\\docs\\using_ck.inf+",
  8772.              exedir,
  8773.              "\\docs\\dialing.inf+",
  8774.              exedir,
  8775.              "\\docs\\modems.inf ",
  8776.              pTopic,
  8777.              NULL,
  8778.              NULL
  8779.              ) > 0)
  8780. #endif /* COMMENT */
  8781.       system(updstr);
  8782.         return(success = 1);
  8783.     }
  8784. #endif /* OS2ONLY */
  8785. #endif /* NOHELP */
  8786.  
  8787. #ifndef NOLOCAL
  8788.     if (cx == XXHAN) {            /* HANGUP */
  8789.     if ((x = cmcfm()) < 0) return(x);
  8790. #ifdef NEWFTP
  8791.     if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
  8792.       return(success = ftpbye());
  8793. #endif /* NEWFTP */
  8794. #ifndef NODIAL
  8795.     if ((x = mdmhup()) < 1) {
  8796.         debug(F101,"HANGUP mdmup","",x);
  8797. #endif /* NODIAL */
  8798.         x = tthang();
  8799.         debug(F101,"HANGUP tthang","",x);
  8800.         x = (x > -1);
  8801. #ifndef NODIAL
  8802.     }
  8803.     dialsta = DIA_UNK;
  8804. #endif /* NODIAL */
  8805.     whyclosed = WC_CLOS;
  8806.     ttchk();            /* In case of CLOSE-ON-DISCONNECT */
  8807.     dologend();
  8808. #ifdef OS2
  8809.     if (x)
  8810.       DialerSend(OPT_KERMIT_HANGUP, 0);
  8811. #endif /* OS2 */
  8812.     if (x) haveline = 0;
  8813.     return(success = x);
  8814.     }
  8815. #endif /* NOLOCAL */
  8816.  
  8817. #ifndef NOSPL
  8818.     /* INPUT, REINPUT, and MINPUT */
  8819.  
  8820.     if (cx == XXINP || cx == XXREI || cx == XXMINP) {
  8821.     long zz;
  8822.     extern int x_ifnum, ispattern;
  8823.     zz = -1L;
  8824.     x_ifnum = 1;            /* Turn off internal complaints */
  8825.     y = cmnum("Seconds to wait for input,\n or time of day hh:mm:ss",
  8826.           ckitoa(indef), 10, &x, xxstring
  8827.           );
  8828.     x_ifnum = 0;
  8829.     if (y < 0) {
  8830.         if (y == -2) {        /* Invalid number or expression */
  8831.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  8832.         if (zz < 0L) {
  8833.             printf("?Number, expression, or time of day required\n");
  8834.             return(-9);
  8835.         } else {
  8836.             char now[32];    /* Current time */
  8837.             char *p;
  8838.             long tnow;
  8839.             p = now;
  8840.             ztime(&p);
  8841.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  8842.             if (zz < tnow)    /* User's time before now */
  8843.               zz += 86400L;    /* So make it tomorrow */
  8844.             zz -= tnow;        /* Seconds from now. */
  8845.         }
  8846.         } else
  8847.           return(y);
  8848.     }
  8849.     if (zz > -1L) {
  8850.         x = zz;
  8851.         if (zz != (long) x) {
  8852.         printf(
  8853. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  8854.                );
  8855.         return(-9);
  8856.         }
  8857.     }
  8858.  
  8859. #ifdef CK_MINPUT
  8860.     for (y = 0; y < MINPMAX; y++) {    /* Initialize strings */
  8861.         mp[y] = 0;            /* Assume it's not a pattern */
  8862.         if (ms[y]) {
  8863.         free(ms[y]);        /* Free old strings, if any */
  8864.         ms[y] = NULL;
  8865.         }
  8866.     }
  8867.     if (cx == XXMINP) {        /* MINPUT */
  8868.         int i, k, n = 0, rc = 0;
  8869.         struct stringarray * q;
  8870.         if ((y = cmtxt("List of targets","",&s,xxstring)) < 0)
  8871.           return(y);
  8872.         if ((q = cksplit(1,0,s," ",NULL,3,0,0))) {
  8873.         char ** ap = q->a_head;
  8874.  
  8875.         n = q->a_size;
  8876.         debug(F101,"minput cksplit size","",n);
  8877.  
  8878.         for (i = 1, k = 0; i <= n; i++) { /* Array is 1-based */
  8879.             if (!ap[i])                  /* Add non-empty elements */
  8880.               continue;
  8881.             if (!*(ap[i]))
  8882.               continue;
  8883.             makestr(&(ms[k++]),ap[i]);    /* Not empty - add it */
  8884.             debug(F111,"MINPUT",ms[k-1],k-1);
  8885.             if (k > MINPMAX)              /* Check for too many */
  8886.               break;
  8887.         }
  8888.         rc = (k > 0) ? 1 : 0;
  8889.         }
  8890.     } else {
  8891. #endif /* CK_MINPUT */
  8892.  
  8893.         /* INPUT or REINPUT */
  8894.  
  8895.         if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
  8896.           return(y);
  8897.         mp[0] = ispattern ? 1 : 0;
  8898.         makestr(&(ms[0]),brstrip(s));
  8899.         ms[1] = NULL;
  8900.  
  8901. #ifdef CK_MINPUT
  8902.     }
  8903. #endif /* CK_MINPUT */
  8904.  
  8905.     if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
  8906.         i_active = 1;
  8907.         success = doinput(x,ms,mp);    /* Go try to input the search string */
  8908.         i_active = 0;
  8909.     } else {            /* REINPUT */
  8910.         success = doreinp(x,s,ispattern);
  8911.     }
  8912.     if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
  8913.         popclvl();            /* If so, pop command level. */
  8914.         if (pflag && cmdlvl == 0) {
  8915.         if (cx == XXINP)  printf("?INPUT timed out\n");
  8916.         if (cx == XXMINP) printf("?MINPUT timed out\n");
  8917.         if (cx == XXREI)  printf("?REINPUT failed\n");
  8918.         }
  8919.     }
  8920.     return(success);        /* Return do(re)input's return code */
  8921.     }
  8922.  
  8923. #endif /* NOSPL */
  8924.  
  8925.     if (cx == XXLOG) {            /* LOG */
  8926.     x = cmkey(logtab,nlog,"What to log","",xxstring);
  8927.     if (x == -3) {
  8928.         printf("?Type of log required\n");
  8929.         return(-9);
  8930.     }
  8931.     if (x < 0) return(x);
  8932.     x = dolog(x);
  8933.     if (x < 0)
  8934.       return(x);
  8935.     else
  8936.       return(success = x);
  8937.     }
  8938.  
  8939.     if (cx == XXLOGIN) {        /* (REMOTE) LOGIN */
  8940. #ifdef NEWFTP
  8941.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8942.       return(success = doftpusr());
  8943. #endif /* NEWFTP */
  8944. #ifdef IKSD
  8945.     if (inserver) {
  8946.         printf("?Already logged in\n");
  8947.         return(-9);
  8948.     } else
  8949. #endif /* IKSD */
  8950.     {
  8951. #ifdef NOXFER
  8952.         return(-2);
  8953. #else
  8954.         return(dormt(XZLGI));
  8955. #endif /* NOXFER */
  8956.     }
  8957.     }
  8958.     if (cx == XXLOGOUT) {        /* (REMOTE) LOGOUT */
  8959. #ifdef NEWFTP
  8960.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8961.       return(success = doftpres());
  8962. #endif /* NEWFTP */
  8963.  
  8964. #ifdef IKSD
  8965.         if (inserver) {
  8966.         if ((x = cmcfm()) < 0)
  8967.           return(x);
  8968.         doexit(GOOD_EXIT,xitsta);
  8969.     } else
  8970. #endif /* IKSD */
  8971.     if (!local || (network && ttchk() < 0)) {
  8972.         printf("?No connection.\n");
  8973.         return(-9);
  8974.     } else {
  8975. #ifdef NOXFER
  8976.         return(-2);
  8977. #else
  8978.         return(dormt(XZLGO));
  8979. #endif /* NOXFER */
  8980.     }
  8981.     }
  8982.  
  8983. #ifndef NOSCRIPT
  8984.     if (cx == XXLOGI) {            /* UUCP-style script */
  8985.     if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
  8986.       return(x);
  8987. #ifdef CK_APC
  8988.     if ((apcactive == APC_LOCAL) ||
  8989.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8990.       return(success = 0);
  8991. #endif /* CK_APC */
  8992. #ifdef VMS
  8993.     conres();            /* For Ctrl-C to work... */
  8994. #endif /* VMS */
  8995.     return(success = dologin(s));    /* Return 1=completed, 0=failed */
  8996.     }
  8997. #endif /* NOSCRIPT */
  8998.  
  8999. #ifndef NOXFER
  9000. #ifdef PIPESEND
  9001.     if (cx == XXCREC) {            /* CRECEIVE */
  9002.     if (protocol != PROTO_K) {
  9003.         printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
  9004.         return(-9);
  9005.     } else
  9006.       return(doxget(cx));
  9007.     }
  9008.     if (cx == XXCGET) {            /* CGET */
  9009.     return(doxget(cx));
  9010.     }
  9011. #endif /* PIPESEND */
  9012.  
  9013.     if (cx == XXREC)            /* RECEIVE */
  9014.       return(doxget(cx));
  9015. #endif /* NOXFER */
  9016.  
  9017. #ifndef NOXFER
  9018.     if (cx == XXREM) {            /* REMOTE */
  9019. #ifdef NEWFTP
  9020.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9021.       return(doftprmt(0,0));
  9022. #endif /* NEWFTP */
  9023. #ifdef CK_XYZ
  9024.     if (protocol != PROTO_K) {
  9025.         printf("Sorry, REMOTE commands only work with Kermit protocol\n");
  9026.         return(-9);
  9027.     }
  9028. #endif /* CK_XYZ */
  9029.     x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
  9030.     if (x == -3) {
  9031.         printf("?You must specify a command for the remote server\n");
  9032.         return(-9);
  9033.     }
  9034.     return(dormt(x));
  9035.     }
  9036. #endif /* NOXFER */
  9037.  
  9038. #ifndef NORENAME
  9039. #ifndef NOFRILLS
  9040.     if (cx == XXREN || cx == XXLREN) {    /* RENAME */
  9041. #ifdef LOCUS
  9042.     if (!locus && cx != XXLREN) {
  9043. #ifdef NOXFER
  9044.         return(-2);
  9045. #else
  9046.         return(dormt(XZREN));
  9047. #endif /* NOXFER */
  9048.         }
  9049. #endif /* LOCUS */
  9050. #ifdef IKSD
  9051.     if (inserver && (!ENABLED(en_ren)
  9052. #ifdef CK_LOGIN
  9053.              || isguest
  9054. #endif /* CK_LOGIN */
  9055.              )) {
  9056.         printf("?Sorry, renaming of files is disabled\n");
  9057.         return(-9);
  9058.     }
  9059. #endif /* IKSD */
  9060. #ifdef CK_APC
  9061.     if ((apcactive == APC_LOCAL) ||
  9062.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9063.       return(success = 0);
  9064. #endif /* CK_APC */
  9065.     return(dorenam());
  9066.     }
  9067. #endif /* NOFRILLS */
  9068. #endif /* NORENAME */
  9069.  
  9070.     if (cx == XXEIGHT) {        /* EIGHTBIT */
  9071.     extern int parity, cmask, cmdmsk;
  9072.     if ((x = cmcfm()) < 0)
  9073.       return(x);
  9074.     parity = 0;
  9075.     cmask = 0xff;
  9076.     cmdmsk = 0xff;
  9077.     return(success = 1);
  9078.     }
  9079.  
  9080. #ifndef NOXFER
  9081. /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
  9082.  
  9083.     if (cx == XXSEN            /* SEND */
  9084. #ifdef PIPESEND
  9085.     || cx == XXCSEN            /* CSEND */
  9086. #endif /* PIPESEND */
  9087.     || cx == XXMOVE            /* MOVE */
  9088.     || cx == XXMAI            /* MAIL */
  9089. #ifdef CK_RESEND
  9090.     || cx == XXRSEN            /* RESEND */
  9091. #endif /* CK_RESEND */
  9092.     ) {
  9093. #ifdef IKSD
  9094.     if (inserver && !ENABLED(en_get)) {
  9095.         printf("?Sorry, sending files is disabled\n");
  9096.         return(-9);
  9097.     }
  9098. #endif /* IKSD */
  9099.     return(doxsend(cx));
  9100.     }
  9101.  
  9102. /* PSEND, ADD, and REMOVE use special parsing */
  9103.  
  9104. #ifdef ADDCMD
  9105.     /* ADD and REMOVE */
  9106.     if (cx == XXADD || cx == XXREMV) {
  9107.     char * m;
  9108.     m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
  9109.     x = cmkey(addtab,naddtab,m,"",xxstring);
  9110.     if (x < 0)
  9111.       return(x);
  9112. #ifndef NOMSEND
  9113.     if (x == ADD_SND)
  9114.       return(addsend(cx));
  9115.     else
  9116. #endif /* NOMSEND */
  9117.       return(doadd(cx,x));
  9118.     }
  9119. #endif /* ADDCMD */
  9120.  
  9121. #ifdef CK_RESEND
  9122.     if (cx == XXPSEN) {            /* PSEND */
  9123.     int seekto = 0;
  9124.  
  9125.     cmarg = cmarg2 = "";
  9126.     x = cmifi("File to partially send", "", &s, &y, xxstring);
  9127.     if (x < 0) {
  9128.         if (x == -3) {
  9129.         printf("?A file specification is required\n");
  9130.         return(-9);
  9131.         } else return(x);
  9132.     }
  9133.     nfils = -1;            /* Files come from internal list. */
  9134. #ifndef NOMSEND
  9135.         addlist = 0;            /* Don't use SEND-LIST. */
  9136.         filenext = NULL;
  9137. #endif /* NOMSEND */
  9138.     ckstrncpy(line,s,LINBUFSIZ);    /* Save copy of string just parsed. */
  9139.     debug(F110,"PSEND line",line,0);
  9140.     if (y != 0) {
  9141.         printf("?Sorry, wildcards not permitted in this command\n");
  9142.         return(-9);
  9143.     }
  9144.     if (sizeof(int) < 4) {
  9145.         printf("?Sorry, this command needs 32-bit integers\n");
  9146.         return(-9);
  9147.     }
  9148.     x = cmnum("starting position (byte number)",
  9149.           "",10,&seekto,xxstring);
  9150.     if (x < 0)
  9151.       return(x);
  9152.     zfnqfp(s,fspeclen,fspec);    /* Get full path */
  9153.     if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
  9154.       return(x);
  9155.     ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9156.  
  9157. #ifdef IKSD
  9158.     if (inserver && !ENABLED(en_get)) {
  9159.         printf("?Sorry, sending files is disabled\n");
  9160.         return(-9);
  9161.     }
  9162. #endif /* IKSD */
  9163. #ifdef PIPESEND
  9164.     if (sndfilter) {
  9165.         printf("?Sorry, no PSEND while SEND FILTER selected\n");
  9166.         return(-9);
  9167.     }
  9168. #endif /* PIPESEND */
  9169. #ifdef CK_XYZ
  9170.     if ((protocol == PROTO_X || protocol == PROTO_XC)) {
  9171.         printf("Sorry, PSEND works only with Kermit protocol\n");
  9172.         return(-9);
  9173.     }
  9174. #endif /* CK_XYZ */
  9175.  
  9176.     cmarg2 = brstrip(tmpbuf);    /* Strip braces */
  9177.     cmarg = line;            /* File to send */
  9178.     debug(F110,"PSEND filename",cmarg,0);
  9179.     debug(F110,"PSEND as-name",cmarg2,0);
  9180.     sendstart = seekto;
  9181.     sstate = 's';            /* Set start state to SEND */
  9182. #ifndef NOMSEND
  9183.     addlist = 0;
  9184.     filenext = NULL;
  9185. #endif /* NOMSEND */
  9186.     sendmode = SM_PSEND;
  9187. #ifdef MAC
  9188.     what = W_SEND;
  9189.     scrcreate();
  9190. #endif /* MAC */
  9191.     if (local) {            /* If in local mode, */
  9192.         displa = 1;            /* enable file transfer display */
  9193.     }
  9194.     return(0);
  9195.     }
  9196. #endif /* CK_RESEND */
  9197. #endif /* NOXFER */
  9198.  
  9199. #ifndef NOXFER
  9200. #ifndef NOMSEND
  9201.     if (cx == XXMSE || cx == XXMMOVE) {
  9202. #ifdef NEWFTP
  9203.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9204.       return(doftpput(cx,0));
  9205. #endif /* NEWFTP */
  9206. #ifdef CK_XYZ
  9207.     if (protocol == PROTO_X || protocol == PROTO_XC) {
  9208.         printf(
  9209. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  9210.            );
  9211.         return(-9);
  9212.     }
  9213. #endif /* CK_XYZ */
  9214.         return(doxsend(cx));
  9215.     }
  9216.  
  9217. #ifdef COMMENT                /* (moved to doxsend) */
  9218.     if (cx == XXMSE || cx == XXMMOVE) {    /* MSEND and MMOVE commands */
  9219.     nfils = 0;            /* Like getting a list of */
  9220.     lp = line;            /* files on the command line */
  9221.     addlist = 0;            /* Do not use SEND-LIST */
  9222.     filenext = NULL;        /* Ditto ! */
  9223.  
  9224.     while (1) {
  9225.         char *p;
  9226.         if ((x = cmifi("Names of files to send, separated by spaces","",
  9227.                &s,&y,xxstring)) < 0) {
  9228.         if (x == -3) {
  9229.             if (nfils <= 0) {
  9230.             printf("?A file specification is required\n");
  9231.             return(-9);
  9232.             } else break;
  9233.         }
  9234.         return(x);
  9235.         }
  9236.         msfiles[nfils++] = lp;    /* Got one, count it, point to it, */
  9237.         p = lp;            /* remember pointer, */
  9238.         while (*lp++ = *s++)    /* and copy it into buffer */
  9239.           if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  9240.           printf("?MSEND list too long\n");
  9241.           line[0] = NUL;
  9242.           return(-9);
  9243.           }
  9244.         debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
  9245.         if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
  9246. #ifdef ZFNQFP
  9247.         zfnqfp(p,TMPBUFSIZ,tmpbuf);
  9248.         p = tmpbuf;
  9249. #endif /* ZFNQFP */
  9250.         if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  9251.         strcat(fspec,p);    /* safe */
  9252.         strcat(fspec," ");    /* safe */
  9253.         } else printf("WARNING - \\v(filespec) buffer overflow\n");
  9254.     }
  9255.     cmlist = msfiles;        /* Point cmlist to pointer array */
  9256.     cmarg2 = "";            /* No internal expansion list (yet) */
  9257.     sndsrc = nfils;            /* Filenames come from cmlist */
  9258.     sendmode = SM_MSEND;        /* Remember this kind of SENDing */
  9259.     sstate = 's';            /* Set start state for SEND */
  9260.     if (cx == XXMMOVE)        /* If MMOVE'ing, */
  9261.       moving = 1;            /*  set this flag. */
  9262. #ifdef MAC
  9263.     what = W_SEND;
  9264.     scrcreate();
  9265. #endif /* MAC */
  9266.     if (local) {            /* If in local mode, */
  9267.         displa = 1;            /* turn on file transfer display */
  9268.         ttflui();            /* and flush tty input buffer. */
  9269.     }
  9270.     return(0);
  9271.     }
  9272. #endif /* COMMENT */
  9273. #endif /* NOMSEND */
  9274. #endif /* NOXFER */
  9275.  
  9276. #ifndef NOSERVER
  9277.     if (cx == XXSER) {            /* SERVER */
  9278. #ifdef CK_XYZ
  9279.     if (protocol != PROTO_K) {
  9280.         printf("Sorry, SERVER only works with Kermit protocol\n");
  9281.         return(-9);
  9282.     }
  9283. #endif /* CK_XYZ */
  9284. #ifdef COMMENT
  9285. /*
  9286.   Parse for time limit, but since we don't use it yet,
  9287.   the parsing is commented out.
  9288. */
  9289.     x_ifnum = 1;            /* Turn off internal complaints */
  9290.     y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
  9291.           "0", 10, &x, xxstring
  9292.           );
  9293.     x_ifnum = 0;
  9294.     if (y < 0) {
  9295.         if (y == -2) {        /* Invalid number or expression */
  9296.         zz = tod2sec(atmbuf);    /* Convert to secs since midnight */
  9297.         if (zz < 0L) {
  9298.             printf("?Number, expression, or time of day required\n");
  9299.             return(-9);
  9300.         } else {
  9301.             char now[32];    /* Current time */
  9302.             char *p;
  9303.             long tnow;
  9304.             p = now;
  9305.             ztime(&p);
  9306.             tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  9307.             if (zz < tnow)    /* User's time before now */
  9308.               zz += 86400L;    /* So make it tomorrow */
  9309.             zz -= tnow;        /* Seconds from now. */
  9310.         }
  9311.         } else
  9312.           return(y);
  9313.     }
  9314.     if (zz > -1L) {
  9315.         x = zz;
  9316.         if (zz != (long) x) {
  9317.         printf(
  9318. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  9319.                );
  9320.         return(-9);
  9321.         }
  9322.     }
  9323.     if (x < 0)
  9324.       x = 0;
  9325. #endif /* COMMENT */
  9326.  
  9327.     if ((x = cmcfm()) < 0) return(x);
  9328.     sstate = 'x';
  9329. #ifdef MAC
  9330.     what = W_RECV;
  9331.     scrcreate();
  9332. #endif /* MAC */
  9333.     if (local) displa = 1;
  9334. #ifdef AMIGA
  9335.     reqoff();            /* No DOS requestors while server */
  9336. #endif /* AMIGA */
  9337.     return(0);
  9338.     }
  9339. #endif /* NOSERVER */
  9340.  
  9341.     if (cx == XXSAVE) {            /* SAVE command */
  9342.     x = cmkey(savtab,nsav,"option","keymap",xxstring);
  9343.     if (x == -3) {
  9344.         printf("?You must specify an option to save\n");
  9345.         return(-9);
  9346.     }
  9347.     if (x < 0) return(x);
  9348.     /* have to set success separately for each item in doprm()... */
  9349.     /* actually not really, could have just had doprm return 0 or 1 */
  9350.     /* and set success here... */
  9351.     y = dosave(x);
  9352.     if (y == -3) {
  9353.         printf("?More fields required\n");
  9354.         return(-9);
  9355.     } else return(y);
  9356.     }
  9357.  
  9358.     if (cx == XXSET) {            /* SET command */
  9359.     x = cmkey(prmtab,nprm,"Parameter","",xxstring);
  9360.     if (x == -3) {
  9361.         printf("?You must specify a parameter to set\n");
  9362.         return(-9);
  9363.     }
  9364.     if (x < 0) return(x);
  9365.     /* have to set success separately for each item in doprm()... */
  9366.     /* actually not really, could have just had doprm return 0 or 1 */
  9367.     /* and set success here... */
  9368.     y = doprm(x,0);
  9369.     if (y == -3) {
  9370.         printf("?More fields required\n");
  9371.         return(-9);
  9372.     } else return(y);
  9373.     }
  9374.  
  9375. #ifndef NOPUSH
  9376.     if (cx == XXSHE            /* SHELL (system) command */
  9377.     || cx == XXEXEC            /* exec() */
  9378.     ) {
  9379.     int rx = 0;
  9380.     char * p = NULL;
  9381.     int i /* ,n */ ;
  9382. #ifdef UNIXOROSK
  9383.     char * args[256];
  9384. #endif /* UNIXOROSK */
  9385.  
  9386. #ifdef IKSD
  9387.     if (inserver && (nopush || !ENABLED(en_hos))) {
  9388.         printf("?Sorry, host command access is disabled\n");
  9389.         return(-9);
  9390.     }
  9391. #endif /* IKSD */
  9392.  
  9393. #ifdef CKEXEC
  9394.     if (cx == XXEXEC) {        /* EXEC (overlay ourselves) */
  9395.         struct FDB sw, fl;
  9396.         cmfdbi(&sw,            /* First FDB - command switches */
  9397.            _CMKEY,        /* fcode */
  9398.            "Command to overlay C-Kermit\n or switch", /* hlpmsg */
  9399.            "",            /* default */
  9400.            "",            /* addtl string data */
  9401.            1,            /* addtl numeric data 1: tbl size */
  9402.            4,            /* addtl numeric data 2: 4 = cmswi */
  9403.            xxstring,        /* Processing function */
  9404.            redirsw,        /* Keyword table */
  9405.            &fl            /* Pointer to next FDB */
  9406.            );
  9407.         cmfdbi(&fl,            /* 2nd FDB - command to exec */
  9408.            _CMFLD,        /* fcode */
  9409.            "Command to overlay C-Kermit", /* hlpmsg */
  9410.            "",            /* default */
  9411.            "",            /* addtl string data */
  9412.            0,            /* addtl numeric data 1 */
  9413.            0,            /* addtl numeric data 2 */
  9414.            xxstring,
  9415.            NULL,
  9416.            NULL            /* No more after this */
  9417.            );
  9418.         while (1) {
  9419.         x = cmfdb(&sw);        /* Parse something */
  9420.         debug(F101,"exec cmfdb","",x);
  9421.         if (x < 0)
  9422.           return(x);
  9423.         /* Generalize this if we add more switches */
  9424.         if (cmresult.fcode == _CMKEY) {
  9425.             rx = 1;
  9426.             continue;
  9427.         }
  9428.         if (cmresult.fcode == _CMFLD)
  9429.           break;
  9430.         return(-2);
  9431.         }
  9432.         ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
  9433.         if (!tmpbuf[0]) {
  9434.         printf("?Command required\n");
  9435.         return(-9);
  9436.         }
  9437.         p = brstrip(tmpbuf);
  9438.         args[0] = NULL;        /* Set argv[0] to it */
  9439.         makestr(&args[0],p);
  9440.         for (i = 1; i < 255; i++) {    /* Get arguments for command */
  9441.         if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
  9442.             if (x == -3) {
  9443.             if ((x = cmcfm()) < 0)
  9444.               return(x);
  9445.             break;
  9446.             } else
  9447.               return(x);
  9448.         }
  9449.         args[i] = NULL;
  9450.         s = brstrip(s);
  9451.         makestr(&args[i],s);
  9452.         }
  9453.         args[i] = NULL;
  9454.     } else {
  9455. #endif /* CKEXEC */
  9456.         if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
  9457.           return(x);
  9458. #ifdef CKEXEC
  9459.     }
  9460. #endif /* CKEXEC */
  9461.         if (nopush)
  9462.           return(success = 0);
  9463. #ifdef CK_APC
  9464.     if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  9465.       return(success = 0);
  9466. #endif /* CK_APC */
  9467.     conres();            /* Make console normal  */
  9468. #ifdef OS2
  9469.     if (!(s && *s)) {
  9470.         os2push();
  9471.             return(success = 1);
  9472.     } else
  9473. #endif /* OS2 */
  9474.       if (cx == XXSHE) {
  9475.           x = zshcmd(s);
  9476.           debug(F101,"RUN zshcmd code","",x);
  9477.           concb((char)escape);
  9478.           return(success = x);
  9479. #ifdef CKEXEC
  9480.       } else {
  9481. #ifdef DEBUG
  9482.           if (deblog) {
  9483.           debug(F111,"EXEC cmd",p,0);
  9484.           for (i = 0; i < 256 && args[i]; i++)
  9485.             debug(F111,"EXEC arg",args[i],i);
  9486.           }
  9487. #endif /* DEBUG */
  9488.           if (p) {
  9489.           z_exec(p,args,rx);    /* Overlay ourself */
  9490.           debug(F100,"EXEC fails","",0);
  9491.           concb((char)escape);    /* In case it returns */
  9492.           }
  9493.           return(success = 0);
  9494. #endif /* CKEXEC */
  9495.       }
  9496.     }
  9497.  
  9498. #ifdef CK_REDIR
  9499.     if (cx == XXFUN) {            /* REDIRECT */
  9500. #ifdef CK_APC
  9501.     if ((apcactive == APC_LOCAL) ||
  9502.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9503.       return(success = 0);
  9504. #endif /* CK_APC */
  9505.     ckmakmsg(tmpbuf,
  9506.          TMPBUFSIZ,
  9507.          "Local command to run,\n",
  9508.          "with its standard input/output redirected to ",
  9509.          local ? ttname : "the communications connection",
  9510.          "\n"
  9511.          );
  9512.     if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
  9513.       return(x);
  9514.         if (nopush) {
  9515.             printf("?REDIRECT disabled\n");
  9516.             return(success=0);
  9517.         }
  9518.     if (!local) {
  9519.         printf("?SET LINE or SET HOST required first\n");
  9520.         return(-9);
  9521.     }
  9522.     if (!*s) {
  9523.         printf("?REDIRECT requires a command to redirect\n");
  9524.         return(-9);
  9525.     }
  9526.     return(success = ttruncmd(s));
  9527.     }
  9528. #endif /* CK_REDIR */
  9529. #endif /* NOPUSH */
  9530.  
  9531. #ifndef NOSHOW
  9532.     if (cx == XXSHO) {            /* SHOW */
  9533.     x = cmkey(shotab,nsho,"","parameters",xxstring);
  9534.     if (x < 0) return(x);
  9535.     return(doshow(x));
  9536.     }
  9537. #endif /* NOSHOW */
  9538.  
  9539. #ifndef MAC
  9540.     if (cx == XXSPA) {            /* SPACE */
  9541. #ifdef IKSD
  9542.     if (inserver && !ENABLED(en_spa)) {
  9543.         printf("?Sorry, SPACE command disabled\n");
  9544.         return(-9);
  9545.     }
  9546. #endif /* IKSD */
  9547. #ifdef datageneral
  9548.     /* AOS/VS can take an argument after its "space" command. */
  9549.     if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0)
  9550.       return(x);
  9551.     if (nopush) {
  9552.         printf("?Sorry, SPACE command disabled\n");
  9553.         return(-9);
  9554.     } else if (*s == NUL) {
  9555.         xsystem(SPACMD);
  9556.     } else {
  9557.         ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL);
  9558.         xsystem(line);
  9559.     }
  9560. #else
  9561. #ifdef OS2
  9562.     if ((x = cmtxt("Press Enter for current disk,\n\
  9563.  or specify a disk letter like A:","",&s,xxstring)) < 0)
  9564.       return(x);
  9565.     if (*s == NUL) {        /* Current disk */
  9566.             unsigned long space = zdskspace(0);
  9567.             if (space > 0 && space < 1024)
  9568.               printf(" Free space: unknown\n");
  9569.             else
  9570.           printf(" Free space: %ldK\n", space/1024L);
  9571.     } else {
  9572.         int drive = toupper(*s);
  9573.             unsigned long space = zdskspace(drive - 'A' + 1);
  9574.             if (space > 0 && space < 1024)
  9575.               printf(" Drive %c: unknown free\n");
  9576.             else
  9577.               printf(" Drive %c: %ldK free\n", drive,space / 1024L);
  9578.     }
  9579. #else
  9580. #ifdef UNIXOROSK
  9581.     x = cmdir("Confirm for current disk,\n\
  9582.  or specify a disk device or directory","",&s,xxstring);
  9583.     if (x == -3)
  9584.       s = "";
  9585.     else if (x < 0)
  9586.       return(x);
  9587.         ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9588.         s = tmpbuf;
  9589.     if ((x = cmcfm()) < 0) return(x);
  9590.     if (nopush) {
  9591.         printf("?Sorry, SPACE command disabled\n");
  9592.         return(-9);
  9593.     }
  9594.     if (!*s) {            /* Current disk */
  9595.         xsystem(SPACMD);
  9596.     } else {            /* Specified disk */
  9597.         ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL);
  9598.         xsystem(line);
  9599.     }
  9600. #else
  9601.     if ((x = cmcfm()) < 0) return(x);
  9602.     if (nopush) {
  9603.         printf("?Sorry, SPACE command disabled\n");
  9604.         return(-9);
  9605.     }
  9606.     xsystem(SPACMD);
  9607. #endif /* UNIXOROSK */
  9608. #endif /* OS2 */
  9609. #endif /* datageneral */
  9610.     return(success = 1);        /* Pretend it worked */
  9611.     }
  9612. #endif /* MAC */
  9613.  
  9614. #ifndef NOXFER
  9615.     if (cx == XXSTA) {            /* STATISTICS */
  9616.     if ((x = cmkey(stattab,2,"Carriage return, or option",
  9617.                "/brief",xxstring)) < 0)
  9618.       return(x);
  9619.     if ((y = cmcfm()) < 0) return(y);
  9620.     return(success = dostat(x));
  9621.     }
  9622. #endif /* NOXFER */
  9623.  
  9624.     if (cx == XXSTO || cx == XXEND) {    /* STOP, END, or POP */
  9625.     if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0)
  9626.       return(y);
  9627.     if ((y = cmtxt("Message to print","",&s,xxstring)) < 0)
  9628.       return(y);
  9629.     s = brstrip(s);
  9630.     if (*s) printf("%s\n",s);
  9631.     if (cx == XXSTO) {
  9632.         dostop();
  9633.     } else {
  9634.         doend(x);
  9635.     }
  9636.     return(success = (x == 0));
  9637.     }
  9638.     if (cx == XXSUS) {            /* SUSPEND */
  9639.     if ((y = cmcfm()) < 0) return(y);
  9640. #ifdef NOJC
  9641.     printf("Sorry, this version of Kermit cannot be suspended\n");
  9642. #else
  9643. #ifdef IKSD
  9644.     if (inserver) {
  9645.         printf("?Sorry, IKSD can not be suspended\n");
  9646.         return(-9);
  9647.     } else
  9648. #endif /* IKSD */
  9649.       if (nopush) {
  9650.         printf("?Sorry, access to system is disabled\n");
  9651.         return(-9);
  9652.     }
  9653.     stptrap(0);
  9654. #endif /* NOJC */
  9655.     return(0);
  9656.     }
  9657.  
  9658.     if (cx == XXTAK) {            /* TAKE */
  9659. #ifdef OS2
  9660.     extern char startupdir[],exedir[],inidir[];
  9661.     char * scriptenv, * keymapenv;
  9662.     int xx;
  9663. #define TAKEPATHLEN 4096
  9664. #else /* OS2 */
  9665. #define TAKEPATHLEN 1024
  9666. #endif /* OS2 */
  9667.     char takepath[TAKEPATHLEN];
  9668.  
  9669.     if (tlevel >= MAXTAKE-1) {
  9670.         printf("?Take files nested too deeply\n");
  9671.         return(-9);
  9672.     }
  9673. #ifdef OS2
  9674. #ifdef NT
  9675.     scriptenv = getenv("K95SCRIPTS");
  9676.     keymapenv = getenv("K95KEYMAPS");
  9677. #else /* NT */
  9678.     scriptenv = getenv("K2SCRIPTS");
  9679.     keymapenv = getenv("K2KEYMAPS");
  9680. #endif /* NT */
  9681.     if (!scriptenv)
  9682.       scriptenv = getenv("CK_SCRIPTS");
  9683.     if (!keymapenv)
  9684.       keymapenv = getenv("CK_KEYMAPS");
  9685. #ifdef COMMENT
  9686.     /* This is not only unsafe but it's wrong */
  9687.     /* There are 19 %s's but 24 strings to print */
  9688.     sprintf(takepath,        /* UNSAFE */
  9689.                 /* semicolon-separated path list */
  9690.                 "%s%s%s%s%s;%s%s;%s%s;%s;%s%s;%s%s;%s;%s%s;%s%s",
  9691.                 scriptenv?scriptenv:"",
  9692.                 (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
  9693.                 keymapenv?keymapenv:"",
  9694.                 (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
  9695.                 startupdir,
  9696.                 startupdir, "SCRIPTS/",
  9697.                 startupdir, "KEYMAPS/",
  9698.                 inidir,
  9699.                 inidir, "SCRIPTS/",
  9700.                 inidir, "KEYMAPS/",
  9701.                 zhome(),
  9702.                 zhome(), "SCRIPTS/",
  9703.                 zhome(), "KEYMAPS/",
  9704.                 exedir,
  9705.                 exedir, "SCRIPTS/",
  9706.                 exedir, "KEYMAPS/"
  9707.                 );
  9708. #else
  9709.     ckstrncpy(takepath,scriptenv?scriptenv:"",TAKEPATHLEN); /* SAFE */
  9710.     ckstrncat(takepath,
  9711.           (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
  9712.           TAKEPATHLEN
  9713.           );
  9714.     ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN);
  9715.     ckstrncat(takepath,
  9716.           (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
  9717.           TAKEPATHLEN
  9718.           );
  9719.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9720.     ckstrncat(takepath,";",TAKEPATHLEN);
  9721.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9722.     ckstrncat(takepath,"SCRIPTS/",TAKEPATHLEN);
  9723.     ckstrncat(takepath,";",TAKEPATHLEN);
  9724.     ckstrncat(takepath,startupdir,TAKEPATHLEN);
  9725.     ckstrncat(takepath,"KEYMAPS/",TAKEPATHLEN);
  9726.     ckstrncat(takepath,";",TAKEPATHLEN);
  9727.  
  9728.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9729.     ckstrncat(takepath,";",TAKEPATHLEN);
  9730.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9731.     ckstrncat(takepath,"SCRIPTS/",TAKEPATHLEN);
  9732.     ckstrncat(takepath,";",TAKEPATHLEN);
  9733.     ckstrncat(takepath,inidir,TAKEPATHLEN);
  9734.     ckstrncat(takepath,"KEYMAPS/",TAKEPATHLEN);
  9735.     ckstrncat(takepath,";",TAKEPATHLEN);
  9736.  
  9737.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9738.     ckstrncat(takepath,";",TAKEPATHLEN);
  9739.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9740.     ckstrncat(takepath,"SCRIPTS/",TAKEPATHLEN);
  9741.     ckstrncat(takepath,";",TAKEPATHLEN);
  9742.     ckstrncat(takepath,zhome(),TAKEPATHLEN);
  9743.     ckstrncat(takepath,"KEYMAPS/",TAKEPATHLEN);
  9744.     ckstrncat(takepath,";",TAKEPATHLEN);
  9745.  
  9746.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9747.     ckstrncat(takepath,";",TAKEPATHLEN);
  9748.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9749.     ckstrncat(takepath,"SCRIPTS/",TAKEPATHLEN);
  9750.     ckstrncat(takepath,";",TAKEPATHLEN);
  9751.     ckstrncat(takepath,exedir,TAKEPATHLEN);
  9752.     ckstrncat(takepath,"KEYMAPS/",TAKEPATHLEN);
  9753.     ckstrncat(takepath,";",TAKEPATHLEN);
  9754. #endif /* COMMENT */
  9755.  
  9756. #else /* not OS2 */
  9757.     y = TAKEPATHLEN;
  9758.     s = takepath;
  9759.     zzstring("\\v(home)",&s,&y);
  9760. #endif /* OS2 */
  9761.  
  9762.     if ((y = cmifip("Commands from file",
  9763.             "",&s,&x,0,takepath,xxstring)) < 0) {
  9764.         if (y == -3) {
  9765.         printf("?A file name is required\n");
  9766.         return(-9);
  9767.         } else
  9768.           return(y);
  9769.     }
  9770.     if (x != 0) {
  9771.         printf("?Wildcards not allowed in command file name\n");
  9772.         return(-9);
  9773.     }
  9774.     ckstrncpy(line,s,LINBUFSIZ);
  9775.     debug(F110,"TAKE file",s,0);
  9776.     if (isdir(s)) {
  9777.         printf("?Can't execute a directory - \"%s\"\n", s);
  9778.         return(-9);
  9779.     }
  9780. #ifndef NOTAKEARGS
  9781.     {
  9782.         char * p;
  9783.         x = strlen(line);
  9784.         debug(F111,"TAKE args",line,x);
  9785.         p = line + x + 1;
  9786.         if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0)
  9787.           return(y);
  9788.         if (*s) {            /* Args given? */
  9789.         ckstrncpy(p,s,LINBUFSIZ-x-1);
  9790. #ifdef ZFNQFP
  9791.         zfnqfp(line,TMPBUFSIZ,tmpbuf);
  9792.         s = tmpbuf;
  9793. #else
  9794.         s = line;
  9795. #endif /* ZFNQFP */
  9796.         debug(F110,"TAKE filename",s,0);
  9797.         x = strlen(s);
  9798.         debug(F101,"TAKE new len",s,x);
  9799.  
  9800. #ifdef COMMENT
  9801. /*
  9802.   This was added in C-Kermit 7.0 to allow args to be passed from the TAKE
  9803.   command to the command file.  But it overwrites the current argument vector,
  9804.   which is at best surprising, and at worst unsafe.
  9805. */
  9806.         addmac("%0",s);        /* Define %0 = name of file */
  9807.         varnam[0] = '%';
  9808.         varnam[2] = '\0';
  9809.         debug(F110,"take arg 0",s,0);
  9810.         debug(F110,"take args",p,0);
  9811.         for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */
  9812.             varnam[1] = (char) (y + '0');
  9813.             delmac(varnam,0);
  9814.         }
  9815.         xwords(p,MAXARGLIST,NULL,0); /* Assign new args */
  9816.         debug(F110,"take args",p,0);
  9817. #else
  9818. /*
  9819.   This method is used in 8.0.  If the TAKE command includes arguments, we
  9820.   insert an intermediate temporary macro between the current level; we pass
  9821.   the arguments to the macro and then the macro TAKEs the command file.
  9822.   If the user Ctrl-C's out of the TAKE file, some temporary macro definitions
  9823.   and other small malloc'd bits might be left behind.
  9824. */
  9825.         {
  9826.             char * q = NULL;
  9827.             char * r = NULL;
  9828.             int k, m;
  9829.             m = maclvl;
  9830.             q = (char *)malloc(x+24);
  9831.             if (q) {
  9832.             r = (char *)malloc(x+24);
  9833.             if (r) {
  9834.                 sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */
  9835.                 sprintf(r,"take %s",s); /* safe */
  9836.                 k = addmac(q,r);
  9837.                 if (k > -1) {
  9838.                 dodo(k,p,0);
  9839.                 while (maclvl > m) {
  9840.                     sstate = (CHAR) parser(1);
  9841.                     if (sstate) proto();
  9842.                 }
  9843.                 }
  9844.                 k = delmac(q,0);
  9845.                 free(q);
  9846.                 free(r);
  9847.                 return(success);
  9848.             }
  9849.             }
  9850.         }
  9851.         return(success = 0);
  9852. #endif /* COMMENT */
  9853.         }
  9854.     }
  9855. #else
  9856.     if ((y = cmcfm()) < 0) return(y);
  9857. #endif /* NOTAKEARGS */
  9858.     return(success = dotake(line));
  9859.     }
  9860.  
  9861. #ifndef NOLOCAL
  9862. #ifdef OS2
  9863.     if (cx == XXVIEW) {            /* VIEW Only Terminal mode */
  9864.     viewonly = TRUE;
  9865.     success = doconect(0, 0);
  9866.     viewonly = FALSE;
  9867.     return success;
  9868.     }
  9869. #endif /* OS2 */
  9870.  
  9871. #ifdef NETCONN
  9872.     if (cx == XXTEL || cx == XXIKSD) {    /* TELNET */
  9873.     int x,z;
  9874. #ifdef OS2
  9875.     if (!tcp_avail) {
  9876.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  9877. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n");
  9878.         success = 0;
  9879.         return(-9);
  9880.     } else
  9881. #endif /* OS2 */
  9882.       {
  9883.       x = nettype;            /* Save net type in case of failure */
  9884.       z = ttnproto;            /* Save protocol in case of failure */
  9885.       nettype = NET_TCPB;
  9886.       ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT;
  9887.       if ((y = setlin(XYHOST,0,1)) <= 0) {
  9888.               nettype = x;        /* Failed, restore net type. */
  9889.               ttnproto = z;        /* and protocol */
  9890.               success = 0;
  9891.       }
  9892.       didsetlin++;
  9893.         }
  9894.     return(y);
  9895.     }
  9896.  
  9897. #ifndef PTYORPIPE
  9898. #ifdef NETCMD
  9899. #define PTYORPIPE
  9900. #else
  9901. #ifdef NETPTY
  9902. #define PTYORPIPE
  9903. #endif /* NETPTY */
  9904. #endif /* NETCMD */
  9905. #endif /* PTYORPIPE */
  9906.  
  9907. #ifdef PTYORPIPE
  9908.     if (cx == XXPIPE || cx == XXPTY) {    /* PIPE or PTY */
  9909.     int x;
  9910.     extern int netsave;
  9911.     x = nettype;            /* Save net type in case of failure */
  9912.     nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY;
  9913.     if ((y = setlin(XYHOST,0,1)) < 0) {
  9914.         nettype = x;        /* Failed, restore net type. */
  9915.         ttnproto = z;        /* and protocol */
  9916.         success = 0;
  9917.     }
  9918.     didsetlin++;
  9919.     netsave = x;
  9920.     return(y);
  9921.     }
  9922. #endif /* PTYORPIPE */
  9923.  
  9924. #ifdef ANYSSH
  9925.     if (cx == XXSSH) {            /* SSH (Secure Shell) */
  9926.     extern int netsave;
  9927. #ifdef SSHBUILTIN
  9928.     int k, x, havehost = 0, trips = 0;
  9929.         int    tmpver = -1, tmpxfw = -1;
  9930.         char * tmpstring = NULL;
  9931. #ifndef SSHTEST
  9932.         extern int sl_ssh_xfw, sl_ssh_xfw_saved;
  9933.         extern int sl_ssh_ver, sl_ssh_ver_saved;
  9934. #endif /* SSHTEST */
  9935.         extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
  9936.         extern char * slmsg;
  9937.     extern char uidbuf[], sl_uidbuf[];
  9938.         extern char pwbuf[], * g_pswd;
  9939.         extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
  9940.     struct FDB sw, kw, fl;
  9941.  
  9942.         makestr(&ssh_tmpuid,NULL);
  9943.         makestr(&ssh_tmpcmd,NULL);
  9944.         makestr(&ssh_tmpport,NULL);
  9945.  
  9946.     cmfdbi(&kw,            /* 1st FDB - commands */
  9947.            _CMKEY,            /* fcode */
  9948.            "host [ port ],\n or action",    /* hlpmsg */
  9949.            "",            /* default */
  9950.            "",            /* addtl string data */
  9951.            nsshcmd,            /* addtl numeric data 1: tbl size */
  9952.            0,            /* addtl numeric data 2: 0 = keyword */
  9953.            xxstring,        /* Processing function */
  9954.            sshkwtab,        /* Keyword table */
  9955.            &fl            /* Pointer to next FDB */
  9956.            );
  9957.     cmfdbi(&fl,            /* Host */
  9958.            _CMFLD,            /* fcode */
  9959.            "",            /* hlpmsg */
  9960.            "",            /* default */
  9961.            "",            /* addtl string data */
  9962.            0,            /* addtl numeric data 1 */
  9963.            0,            /* addtl numeric data 2 */
  9964.            xxstring,
  9965.            NULL,
  9966.            NULL
  9967.            );
  9968.  
  9969.     x = cmfdb(&kw);
  9970.     if (x == -3) {
  9971.         printf("?ssh what?\n");
  9972.         return(-9);
  9973.     }
  9974.     if (x < 0)
  9975.       return(x);
  9976.     havehost = 0;
  9977.     if (cmresult.fcode == _CMFLD) {
  9978.         havehost = 1;
  9979.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
  9980.         cmresult.nresult = XSSH_OPN;
  9981.     }
  9982.     switch (cmresult.nresult) {    /* SSH keyword */
  9983.       case XSSH_OPN:        /* SSH OPEN */
  9984.         if (!havehost) {
  9985.         if ((x = cmfld("Host","",&s,xxstring)) < 0)
  9986.           return(x);
  9987.         ckstrncpy(line,s,LINBUFSIZ);
  9988.         }
  9989.         /* Parse [ port ] [ switches ] */
  9990.         cmfdbi(&kw,            /* Switches */
  9991.            _CMKEY,
  9992.            "Port number or service name,\nor switch",
  9993.            "",
  9994.            "",
  9995.            nsshopnsw,
  9996.            4,
  9997.            xxstring,
  9998.            sshopnsw,
  9999.            &fl
  10000.            );
  10001.         cmfdbi(&fl,            /* Port number or service name */
  10002.            _CMFLD,
  10003.            "",
  10004.            "",
  10005.            "",
  10006.            0,
  10007.            0,
  10008.            xxstring,
  10009.            NULL,
  10010.            NULL
  10011.            );
  10012.         trips = 0;            /* Explained below */
  10013.         while (1) {            /* Parse port and switches */
  10014.         x = cmfdb(&kw);        /* Get a field */
  10015.         if (x == -3)        /* User typed CR so quit from loop */
  10016.           break;
  10017.         if (x < 0)        /* Other parse error, pass it back */
  10018.           return(x);
  10019.         switch (cmresult.fcode) { /* Field or Keyword? */
  10020.                   case _CMFLD:          /* Field */
  10021.                     makestr(&ssh_tmpport,cmresult.sresult);
  10022.             break;
  10023.           case _CMKEY:        /* Keyword */
  10024.             switch (cmresult.nresult) {    /* Which one? */
  10025.               case SSHSW_USR:            /* /USER: */
  10026.             if (!cmgbrk()) {
  10027.                 printf("?This switch requires an argument\n");
  10028.                 return(-9);
  10029.             }
  10030.             if ((y = cmfld("Username","",&s,xxstring)) < 0)
  10031.               return(y);
  10032.             s = brstrip(s);
  10033.             makestr(&ssh_tmpuid,s);
  10034.             break;
  10035.                       case SSHSW_PWD:
  10036.             if (!cmgbrk()) {
  10037.                 printf("?This switch requires an argument\n");
  10038.                 return(-9);
  10039.             }
  10040.             debok = 0;
  10041.             if ((x = cmfld("Password","",&s,xxstring)) < 0) {
  10042.                 if (x == -3) {
  10043.                 makestr(&tmpstring,"");
  10044.                 } else {
  10045.                 return(x);
  10046.                 }
  10047.             } else {
  10048.                 s = brstrip(s);
  10049.                 if ((x = (int)strlen(s)) > PWBUFL) {
  10050.                 makestr(&slmsg,"Internal error");
  10051.                 printf("?Sorry, too long - max = %d\n",PWBUFL);
  10052.                 return(-9);
  10053.                 }
  10054.                 makestr(&tmpstring,s);
  10055.             }
  10056.             break;
  10057.  
  10058.               case SSHSW_VER:
  10059.             if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
  10060.               return(x);
  10061.             if (z < 1 || z > 2) {
  10062.                 printf("?Out of range: %d\n",z);
  10063.                 return(-9);
  10064.             }
  10065.                         tmpver = z;
  10066.             break;
  10067.               case SSHSW_CMD:
  10068.               case SSHSW_SUB:
  10069.             if ((x = cmfld("Text","",&s,xxstring)) < 0)
  10070.               return(x);
  10071.                         makestr(&ssh_tmpcmd,s);
  10072.             ssh_cas = (cmresult.nresult == SSHSW_SUB);
  10073.             break;
  10074.               case SSHSW_X11:
  10075.             if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  10076.               return(x);
  10077.                         tmpxfw = x;
  10078.             break;
  10079.               default:
  10080.                 return(-2);
  10081.             }
  10082.         }
  10083.         if (trips++ == 0) {    /* After first time through */
  10084.             cmfdbi(&kw,        /* only parse switches, not port. */
  10085.                _CMKEY,
  10086.                "Switch",
  10087.                "",
  10088.                "",
  10089.                nsshopnsw,
  10090.                4,
  10091.                xxstring,
  10092.                sshopnsw,
  10093.                NULL
  10094.                );
  10095.         }
  10096.         }
  10097.         if ((x = cmcfm()) < 0)    /* Get confirmation */
  10098.           return(x);
  10099.         makestr(&ssh_hst,line);    /* Stash everything */
  10100.         if (ssh_tmpuid) {
  10101.                 if (!sl_uid_saved) {
  10102.                     ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
  10103.                     sl_uid_saved = 1;
  10104.                 }
  10105.         ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
  10106.         makestr(&ssh_tmpuid,NULL);
  10107.         }
  10108.             if (ssh_tmpport) {
  10109.                 makestr(&ssh_prt,ssh_tmpport);
  10110.                 makestr(&ssh_tmpport,NULL);
  10111.             } else
  10112.                 makestr(&ssh_prt,NULL);
  10113.  
  10114.             if (ssh_tmpcmd) {
  10115.                 makestr(&ssh_cmd,brstrip(ssh_tmpcmd));
  10116.                 makestr(&ssh_tmpcmd,NULL);
  10117.             } else
  10118.                 makestr(&ssh_cmd,NULL);
  10119.  
  10120.             if (tmpver > -1) {
  10121. #ifndef SSHTEST
  10122.                 if (!sl_ssh_ver_saved) {
  10123.                     sl_ssh_ver = ssh_ver;
  10124.                     sl_ssh_ver_saved = 1;
  10125.                 }
  10126. #endif /* SSHTEST */
  10127.                 ssh_ver = tmpver;
  10128.             }
  10129.             if (tmpxfw > -1) {
  10130. #ifndef SSHTEST
  10131.                 if (!sl_ssh_xfw_saved) {
  10132.                     sl_ssh_xfw = ssh_xfw;
  10133.                     sl_ssh_xfw_saved = 1;
  10134.                 }
  10135. #endif /* SSHTEST */
  10136.                 ssh_xfw = tmpxfw;
  10137.             }
  10138.         if (tmpstring) {
  10139.         if (tmpstring[0]) {
  10140.             ckstrncpy(pwbuf,tmpstring,PWBUFL+1);
  10141.             pwflg = 1;
  10142.             pwcrypt = 0;
  10143.         } else
  10144.           pwflg = 0;
  10145.         makestr(&tmpstring,NULL);
  10146.         }
  10147.         nettype = NET_SSH;
  10148.         if (mdmsav < 0)
  10149.           mdmsav = mdmtyp;
  10150.         mdmtyp = -nettype;
  10151.         x = 1;
  10152.  
  10153. #ifndef NOSPL
  10154.             makestr(&g_pswd,pwbuf);             /* Save global pwbuf */
  10155.             g_pflg = pwflg;                     /* and flag */
  10156.             g_pcpt = pwcrypt;
  10157. #endif /* NOSPL */
  10158.  
  10159.         /* Line parameter to ttopen() is ignored */
  10160.         k = ttopen(line,&x,mdmtyp, 0);
  10161.         if (k < 0) {
  10162.         printf("?Unable to connect to %s\n",ssh_hst);
  10163.         mdmtyp = mdmsav;
  10164.                 slrestor();
  10165.         return(success = 0);
  10166.         }
  10167.         duplex = 0;             /* Remote echo */
  10168.         ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
  10169.         debug(F110,"ssh ttname",ttname,0);
  10170.         makestr(&slmsg,NULL);    /* No SET LINE error message */
  10171.         cxtype = CXT_SSH;
  10172. #ifndef NODIAL
  10173.         dialsta = DIA_UNK;
  10174. #endif /* NODIAL */
  10175.         success = 1;        /* SET LINE succeeded */
  10176.         network = 1;        /* Network connection (not serial) */
  10177.         local = 1;            /* Local mode (not remote) */
  10178.         if ((reliable != SET_OFF || !setreliable))
  10179.           reliable = SET_ON;    /* Transport is reliable end to end */
  10180. #ifdef OS2
  10181.             DialerSend(OPT_KERMIT_CONNECT, 0);
  10182. #endif /* OS2 */
  10183.         setflow();            /* Set appropriate flow control */
  10184.  
  10185.         haveline = 1;
  10186. #ifdef CKLOGDIAL
  10187. #ifdef NETCONN
  10188.         dolognet();
  10189. #endif /* NETCONN */
  10190. #endif /* CKLOGDIAL */
  10191.  
  10192. #ifndef NOSPL
  10193.         if (local) {
  10194.         if (nmac) {        /* Any macros defined? */
  10195.             int k;        /* Yes */
  10196.             k = mlook(mactab,"on_open",nmac); /* Look this up */
  10197.             if (k >= 0) {                  /* If found, */
  10198.             if (dodo(k,ssh_hst,0) > -1)   /* set it up, */
  10199.               parser(1);              /* and execute it */
  10200.             }
  10201.         }
  10202.         }
  10203. #endif /* NOSPL */
  10204. #ifdef LOCUS        
  10205.         if (autolocus) {
  10206.         if (!locus && msgflg)
  10207.           printf(
  10208.             "Switching LOCUS for file-management commands to LOCAL.\n"
  10209.                  );
  10210.         locus = 1;
  10211.         }
  10212. #endif /* LOCUS */
  10213.  
  10214.     /* Command was confirmed so we can pre-pop command level. */
  10215.     /* This is so CONNECT module won't think we're executing a */
  10216.     /* script if CONNECT was the final command in the script. */
  10217.         if (cmdlvl > 0)
  10218.           prepop();
  10219.         success = doconect(0,cmdlvl == 0 ? 1 : 0);
  10220.         if (ttchk() < 0)
  10221.           dologend();
  10222.         return(success);
  10223.  
  10224.       case XSSH_CLR:
  10225.         if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) {
  10226.             if (y == -3) {
  10227.             printf("?clear what?\n");
  10228.             return(-9);
  10229.         }
  10230.             return(y);
  10231.         }
  10232.         if ((x = cmcfm()) < 0)
  10233.           return(x);
  10234.         switch (y) {
  10235.           case SSHC_LPF:
  10236.                 ssh_pf_lcl_n = 0;
  10237.         break;
  10238.           case SSHC_RPF:
  10239.         ssh_pf_rmt_n = 0;
  10240.         break;
  10241.           default:
  10242.         return(-2);
  10243.         }
  10244.             return(success = 1);    /* or whatever */
  10245.  
  10246.       case XSSH_AGT: {        /* SSH AGENT */
  10247.           int doeach = 0;
  10248.           if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0)
  10249.         return(y);
  10250.           switch (y) {
  10251.         case SSHA_ADD:        /* SSH AGENT ADD ... */
  10252.           if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10253. #ifndef SSHTEST
  10254.               if (x == -3)    /* No name given */
  10255.             doeach = 1;    /* so do them all */
  10256.               else
  10257. #endif /* SSHTEST */
  10258.             return(x);
  10259.           }
  10260.           ckstrncpy(line,s,LINBUFSIZ);
  10261.           if ((x = cmcfm()) < 0)
  10262.             return(x);
  10263. #ifdef SSHTEST
  10264.           x = 0;
  10265. #else
  10266.           if (doeach) {
  10267.                       int i;
  10268.                       x = 0;
  10269.                       for (i = 0; i < ssh_idf_n; i++)
  10270.             x += ssh_agent_add_file(ssh_idf[i]);
  10271.           } else
  10272.             x = ssh_agent_add_file(line);
  10273. #endif /* SSHTEST */
  10274.           return(success = (x == 0));
  10275.  
  10276.         case SSHA_DEL: {    /* SSH AGENT DELETE ... */
  10277.             int doall = 0;
  10278.             if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
  10279. #ifndef SSHTEST
  10280.             if (x == -3)    /* No name given */
  10281.               doall = 1;    /* so do them all */
  10282.             else
  10283. #endif /* SSHTEST */
  10284.               return(x);
  10285.             }
  10286.             ckstrncpy(line,s,LINBUFSIZ);
  10287.             if ((x = cmcfm()) < 0)
  10288.               return(x);
  10289. #ifdef SSHTEST
  10290.             x = 0;
  10291. #else
  10292.             if (doall)
  10293.               x = ssh_agent_delete_all();
  10294.             else
  10295.               x = ssh_agent_delete_file(line);
  10296. #endif /* SSHTEST */
  10297.             return(success = (x == 0));
  10298.         }
  10299.         case SSHA_LST: {
  10300.             int fingerprint = 0;
  10301.             if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) {
  10302.             if (y == -3)
  10303.               break;
  10304.             else
  10305.               return(y);
  10306.             } else if (cmgbrk() > SP) {
  10307.             printf("?This switch does not take an argument\n");
  10308.             return(-9);
  10309.             } else if (y == SSHASW_FP) {
  10310.             fingerprint = 1;
  10311.             }
  10312.             if ((x = cmcfm()) < 0)
  10313.               return(x);
  10314. #ifdef SSHTEST
  10315.             return(success = 1);
  10316. #else
  10317.             return(success =
  10318.                (ssh_agent_list_identities(fingerprint) == 0));
  10319. #endif /* SSHTEST */
  10320.         }
  10321.         default:
  10322.           return(-2);
  10323.           }
  10324.       }
  10325.       case XSSH_ADD: {        /* SSH ADD */
  10326.           /* ssh add { local, remote } port host port */
  10327.           int cx, i, j, k;
  10328.           char * h;
  10329.           if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0)
  10330.         return(cx);
  10331.           if ((x = cmnum((cx == SSHF_LCL) ?
  10332.                  "Local port number" : "Remote port number",
  10333.                  "",10,&j,xxstring)) < 0)
  10334.         return(x);
  10335.           if ((x = cmfld("Host","",&s,xxstring)) < 0)
  10336.         return(x);
  10337.           makestr(&h,s);
  10338.           if ((x = cmnum("Port","",10,&k,xxstring)) < 0)
  10339.         return(x);
  10340.           if ((x = cmcfm()) < 0)
  10341.         return(x);
  10342.  
  10343.           switch(cx) {
  10344.         case SSHF_LCL:
  10345.            if (ssh_pf_lcl_n == 32) {
  10346.                printf(
  10347. "?Maximum number of local port forwardings already specified\n"
  10348.                  );
  10349.                free(h);
  10350.                return(success = 0);
  10351.           }
  10352.           ssh_pf_lcl[ssh_pf_lcl_n].p1 = j;
  10353.           makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h);
  10354.           makestr(&h,NULL);
  10355.           ssh_pf_lcl[ssh_pf_lcl_n].p2 = k;
  10356.           ssh_pf_lcl_n++;
  10357.           break;
  10358.         case SSHF_RMT:
  10359.           if (ssh_pf_rmt_n == 32) {
  10360.               printf(
  10361. "?Maximum number of remote port forwardings already specified\n"
  10362.                 );
  10363.               free(h);
  10364.               return(success = 0);
  10365.           }
  10366.           ssh_pf_rmt[ssh_pf_rmt_n].p1 = j;
  10367.           makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h);
  10368.           makestr(&h,NULL);
  10369.           ssh_pf_rmt[ssh_pf_rmt_n].p2 = k;
  10370.           ssh_pf_rmt_n++;
  10371.           }
  10372.           return(success = 1);
  10373.       }
  10374.       /* Not supporting arbitrary forwarding yet */
  10375.       case XSSH_FLP:        /* SSH FORWARD-LOCAL-PORT */
  10376.       case XSSH_FRP: {        /* SSH FORWARD-REMOTE-PORT */
  10377.           int li_port = 0;
  10378.           int to_port = 0;
  10379.           char * fw_host = NULL;
  10380.           int n;
  10381.               if ((x = cmnum(cmresult.nresult == XSSH_FLP ?
  10382.                               "local-port":"remote-port",
  10383.                               "",10,&li_port,xxstring)) < 0)
  10384.                   return(x);
  10385.               if (li_port < 1 || li_port > 65535) {
  10386.                   printf("?Out range - min: 1, max: 65535\n");
  10387.                   return(-9);
  10388.               }
  10389.           if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0)
  10390.         return(x);
  10391.               n = ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  10392.               fw_host = tmpbuf;
  10393.               if ((x = cmnum("host-port",ckuitoa(li_port),10,
  10394.                               &to_port,xxstring)) < 0)
  10395.                   return(x);
  10396.               if (to_port < 1 || to_port > 65535) {
  10397.                   printf("?Out range - min: 1, max: 65535\n");
  10398.                   return(-9);
  10399.               }
  10400.           if ((x = cmcfm()) < 0)
  10401.         return(x);
  10402.           switch (cmresult.nresult) {
  10403.                 case XSSH_FLP:    /* SSH FORWARD-LOCAL-PORT */
  10404. #ifndef SSHTEST
  10405.                   ssh_fwd_local_port(li_port,fw_host,to_port);
  10406. #endif /* SSHTEST */
  10407.           return(success = 1);
  10408.         case XSSH_FRP:    /* SSH FORWARD-REMOTE-PORT */
  10409. #ifndef SSHTEST
  10410.                   ssh_fwd_remote_port(li_port,fw_host,to_port);
  10411. #endif /* SSHTEST */
  10412.           return(success = 1);
  10413.           }
  10414.           return(success = 1);
  10415.       }
  10416.     case XSSH_V2:        /* SSH V2 */
  10417.       if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0)
  10418.         return(cx);
  10419.       switch (cx) {
  10420.         case XSSH2_RKE:
  10421.           if ((x = cmcfm()) < 0)
  10422.         return(x);
  10423. #ifndef SSHTEST
  10424.           ssh_v2_rekey();
  10425. #endif /* SSHTEST */
  10426.           return(success = 1);
  10427.         default:
  10428.           return(-2);
  10429.       }
  10430.     case XSSH_KEY:
  10431.       if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0)
  10432.         return(cx);
  10433.       switch (cx) {
  10434.         case SSHK_PASS: {    /* Change passphrase */
  10435.           char * oldp = NULL, * newp = NULL;
  10436.           struct FDB df, sw;
  10437.           cmfdbi(&sw,
  10438.              _CMKEY,        /* fcode */
  10439.              "Filename, or switch", /* hlpmsg */
  10440.              "",        /* default */
  10441.              "",        /* addtl string data */
  10442.              2,            /* addtl numeric data 1: tbl size */
  10443.              4,            /* addtl numeric data 2: 4 = cmswi */
  10444.              xxstring,        /* Processing function */
  10445.              sshkpsw,        /* Keyword table */
  10446.              &df        /* Pointer to next FDB */
  10447.              );
  10448.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10449.              _CMIFI,        /* output file */
  10450.              "",        /* hlpmsg */
  10451.              "",        /* default */
  10452.              "",        /* addtl string data */
  10453.              0,            /* addtl numeric data 1 */
  10454.              0,            /* addtl numeric data 2 */
  10455.              xxstring,
  10456.              NULL,
  10457.              NULL
  10458.              );
  10459.           line[0] = NUL;
  10460.  
  10461.           while (1) {
  10462.           x = cmfdb(&sw);
  10463.           if (x == -3) break;
  10464.           if (x < 0)
  10465.             return(x);
  10466.           if (cmresult.fcode != _CMKEY)
  10467.             break;
  10468.           if (!cmgbrk()) {
  10469.               printf("?This switch requires an argument\n");
  10470.               return(-9);
  10471.           }
  10472.           if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10473.             return(y);
  10474.           switch (cmresult.nresult) {
  10475.             case 1:        /* Old */
  10476.               makestr(&oldp,s);
  10477.               break;
  10478.             case 2:        /* New */
  10479.               makestr(&newp,s);
  10480.           }
  10481.           }
  10482.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10483.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10484.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10485.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10486.           }
  10487.           if ((x = cmcfm()) < 0) return(x);
  10488.  
  10489. #ifndef SSHTEST
  10490.           x = sshkey_change_passphrase(line[0] ? line : NULL,
  10491.                          oldp, newp);
  10492. #endif /* SSHTEST */
  10493.           makestr(&oldp,NULL);
  10494.           makestr(&newp,NULL);
  10495.           success = (x == 0);
  10496.           return(success);
  10497.         }
  10498.         case SSHK_CREA: {    /* SSH KEY CREATE /switches... */
  10499.           int bits = 1024, keytype = SSHKT_2R;
  10500.           char * pass = NULL, * comment = NULL;
  10501.           struct FDB df, sw;
  10502.  
  10503.               /*
  10504.                * char * sshkey_default_file(int keytype) 
  10505.                * will provide the default filename for a given keytype
  10506.                * is it possible to have the default value for the 2nd
  10507.                * FDB set and changed when a /TYPE switch is provided?
  10508.                * Would this allow for tab completion of the filename?
  10509.                */
  10510.           cmfdbi(&sw,
  10511.              _CMKEY,        /* fcode */
  10512.              "Filename, or switch", /* hlpmsg */
  10513.              "",        /* default */
  10514.              "",        /* addtl string data */
  10515.              nsshkcrea,        /* addtl numeric data 1: tbl size */
  10516.              4,            /* addtl numeric data 2: 4 = cmswi */
  10517.              xxstring,        /* Processing function */
  10518.              sshkcrea,        /* Keyword table */
  10519.              &df        /* Pointer to next FDB */
  10520.              );
  10521.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10522.              _CMOFI,        /* output file */
  10523.              "",        /* hlpmsg */
  10524.              "",        /* default */
  10525.              "",        /* addtl string data */
  10526.              0,            /* addtl numeric data 1 */
  10527.              0,            /* addtl numeric data 2 */
  10528.              xxstring,
  10529.              NULL,
  10530.              NULL
  10531.              );
  10532.           line[0] = NUL;
  10533.  
  10534.           while (1) {
  10535.           x = cmfdb(&sw);
  10536.           if (x == -3) break;
  10537.           if (x < 0)
  10538.             return(x);
  10539.           if (cmresult.fcode != _CMKEY)
  10540.             break;
  10541.           if (!cmgbrk()) {
  10542.               printf("?This switch requires an argument\n");
  10543.               return(-9);
  10544.           }
  10545.           switch (cmresult.nresult) {
  10546.             case SSHKC_BI:    /* /BITS:n */
  10547.               if ((y = cmnum("","1024",10,&z,xxstring)) < 0)
  10548.             return(y);
  10549.               if (z < 512 || z > 4096) {
  10550.               printf("?Out range - min: 512, max: 4096\n");
  10551.               return(-9);
  10552.               }
  10553.               bits = z;
  10554.               break;
  10555.             case SSHKC_PP:    /* /PASSPHRASE:blah */
  10556.               if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
  10557.             return(y);
  10558.               makestr(&pass,s);
  10559.               break;
  10560.             case SSHKC_TY:    /* /TYPE:keyword */
  10561.               if ((y = cmkey(sshkcty,nsshkcty,"",
  10562.                      "v2-rsa",xxstring)) < 0)
  10563.             return(y);
  10564.               keytype = y;
  10565.               break;
  10566.             case SSHKC_1R:    /* /COMMENT */
  10567.               if ((y = cmfld("Text","",&s,xxstring)) < 0)
  10568.             return(y);
  10569.               makestr(&comment,s);
  10570.               break;
  10571.           }
  10572.           }
  10573.           if (cmresult.fcode == _CMOFI) { /* Filename */
  10574.                   if (cmresult.sresult) {
  10575.                       ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10576.                       if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10577.                           ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10578.           }
  10579.           }
  10580.           if ((y = cmcfm()) < 0) /* Confirm */
  10581.         return(y);
  10582. #ifndef SSHTEST
  10583.           x = sshkey_create(line[0] ? line : NULL,
  10584.                 bits, pass, keytype, comment);
  10585.           if (pass)
  10586.         memset(pass,0,strlen(pass));
  10587. #endif /* SSHTEST */
  10588.           makestr(&pass,NULL);
  10589.           makestr(&comment,NULL);
  10590.           return(success = (x == 0));
  10591.         }
  10592.         case SSHK_DISP: {    /* SSH KEY DISPLAY /switches... */
  10593.           char c;
  10594.           int infmt = 0, outfmt = 0;
  10595.           struct FDB df, sw;
  10596.           cmfdbi(&sw,
  10597.              _CMKEY,        /* fcode */
  10598.              "Filename, or switch", /* hlpmsg */
  10599.              "",        /* default */
  10600.              "",        /* addtl string data */
  10601.              nsshdswi,        /* addtl numeric data 1: tbl size */
  10602.              4,            /* addtl numeric data 2: 4 = cmswi */
  10603.              xxstring,        /* Processing function */
  10604.              sshdswi,        /* Keyword table */
  10605.              &df        /* Pointer to next FDB */
  10606.              );
  10607.           cmfdbi(&df,        /* 2nd FDB - file for display */
  10608.              _CMIFI,        /* fcode */
  10609.              "",        /* hlpmsg */
  10610.              "",        /* default */
  10611.              "",        /* addtl string data */
  10612.              0,            /* addtl numeric data 1 */
  10613.              0,            /* addtl numeric data 2 */
  10614.              xxstring,
  10615.              NULL,
  10616.              NULL
  10617.              );
  10618.           line[0] = NUL;
  10619.  
  10620.           while (1) {
  10621.           x = cmfdb(&sw);
  10622.           if (x == -3) break;
  10623.           if (x < 0)
  10624.             return(x);
  10625.           if (cmresult.fcode != _CMKEY)
  10626.             break;
  10627.           if (!cmgbrk()) {
  10628.               printf("?This switch requires an argument\n");
  10629.               return(-9);
  10630.           }
  10631.           switch (cmresult.nresult) {
  10632. #ifdef COMMENT
  10633.             case SSHKD_IN:    /* /IN-FORMAT: */
  10634.               if ((y = cmkey(sshdifmt,nsshdifmt,
  10635.                      "","",xxstring)) < 0)
  10636.             return(y);
  10637.               infmt = y;
  10638.               break;
  10639. #endif /* COMMENT */
  10640.             case SSHKD_OUT:    /* /FORMAT: */
  10641.               if ((y = cmkey(sshdofmt,nsshdofmt,
  10642.                      "","",xxstring)) < 0)
  10643.             return(y);
  10644.               outfmt = y;
  10645.               break;
  10646.           }
  10647.           }
  10648.           if (cmresult.fcode == _CMIFI) { /* Filename */
  10649.           ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  10650.           if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10651.             ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10652.           }
  10653. #ifdef COMMENT
  10654.           if (!line[0]) {
  10655.           printf("?Key filename required\n");
  10656.           return(-9);
  10657.           }
  10658. #endif /* COMMENT */
  10659.           if ((y = cmcfm()) < 0) /* Confirm */
  10660.         return(y);
  10661. #ifndef SSHTEST
  10662.           switch (outfmt) {
  10663.         case SKDF_OSSH:
  10664.                   /* 2nd param is optional passphrase */
  10665.           x = sshkey_display_public(line[0] ? line : NULL, NULL);
  10666.           break;
  10667.         case SKDF_SSHC:
  10668.                   /* 2nd param is optional passphrase */
  10669.           x = sshkey_display_public_as_ssh2(line[0] ? line : NULL,
  10670.                             NULL);
  10671.           break;
  10672.         case SKDF_IETF:
  10673.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 1);
  10674.           break;
  10675.         case SKDF_FING:
  10676.           x = sshkey_display_fingerprint(line[0] ? line : NULL, 0);
  10677.           break;
  10678.           }
  10679. #endif /* SSHTEST */
  10680.           return(success = (x == 0));
  10681.         }
  10682.         case SSHK_V1:        /* SSH KEY V1 SET-COMMENT */
  10683.           if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0)
  10684.         return(x);
  10685.           if (x != 1) return(-2);
  10686.           if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) {
  10687.           if (x == -3) {
  10688.               printf("?Name of key file required\n");
  10689.               return(-9);
  10690.           }
  10691.           }
  10692.           ckstrncpy(line,s,LINBUFSIZ);
  10693.           if ((x = cmtxt("Comment text","",&s,xxstring)) < 0)
  10694.         return(x);
  10695. #ifndef SSHTEST
  10696.           x = sshkey_v1_change_comment(line,  /* filename */
  10697.                        s,     /* new comment */
  10698.                        NULL   /* passphrase */
  10699.                        );
  10700. #endif /* SSHTEST */
  10701.           success = (x == 0);
  10702.           return(success);
  10703.       }
  10704.       default:
  10705.         return(-2);
  10706.     }
  10707. #else  /* SSHBUILTIN */
  10708. #ifdef SSHCMD
  10709.     x = nettype;
  10710.     if ((y = setlin(XXSSH,0,1)) < 0) {
  10711.         if (errno)
  10712.           printf("?%s\n",ck_errstr());
  10713.             else
  10714. #ifdef COMMENT
  10715.         /* This isn't right either because it catches command editing */
  10716.           printf("?Sorry, pseudoterminal open failed\n");
  10717.             if (hints)
  10718.           printf("Hint: Try \"ssh -t %s\"\n",line);
  10719. #else
  10720.           return(y);
  10721. #endif /* COMMENT */
  10722.         nettype = x;        /* Failed, restore net type. */
  10723.         ttnproto = z;        /* and protocol */
  10724.         success = 0;
  10725.     }
  10726.     didsetlin++;
  10727.     netsave = x;
  10728.     return(y);
  10729. #endif /* SSHCMD */
  10730. #endif /* SSHBUILTIN */
  10731.     }
  10732. #endif /* ANYSSH */
  10733.  
  10734.     if (cx == XXRLOG) {            /* RLOGIN */
  10735. #ifdef RLOGCODE
  10736.     int x,z;
  10737. #ifdef OS2
  10738.     if (!tcp_avail) {
  10739.         printf("?Sorry, either TCP/IP is not available on this system or\n\
  10740. necessary DLLs did not load.  Use SHOW NETWORK to check network status.\n"
  10741.            );
  10742.         success = 0;
  10743.         return(-9);
  10744.     } else {
  10745. #endif /* OS2 */
  10746.         x = nettype;        /* Save net type in case of failure */
  10747.         z = ttnproto;        /* Save protocol in case of failure */
  10748.         nettype = NET_TCPB;
  10749.         ttnproto = NP_RLOGIN;
  10750.         if ((y = setlin(XYHOST,0,1)) <= 0) {
  10751.         nettype = x;        /* Failed, restore net type. */
  10752.         ttnproto = z;        /* and protocol */
  10753.         success = 0;
  10754.         }
  10755.         didsetlin++;
  10756. #ifdef OS2
  10757.     }
  10758. #endif /* OS2 */
  10759.     return(y);
  10760. #else
  10761.     printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n");
  10762.     return(-9);
  10763. #endif /* RLOGCODE */
  10764.     }
  10765. #endif /* NETCONN */
  10766. #endif /* NOLOCAL */
  10767.  
  10768. #ifndef NOXMIT
  10769.     if (cx == XXTRA) {            /* TRANSMIT */
  10770.     extern int xfrxla;
  10771.     int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval;
  10772.     int xxecho = 0;
  10773.     int scan = 1;
  10774.     char c;
  10775.     struct FDB sf, sw, tx;        /* FDBs for parse functions */
  10776. #ifndef NOCSETS
  10777.     extern int tcs_transp;        /* Term charset is transparent */
  10778. #else
  10779.     int tcs_transp = 1;
  10780. #endif /* NOCSETS */
  10781.  
  10782. #ifdef COMMENT
  10783.     xbinary = binary;        /* Default text/binary mode */
  10784. #else
  10785.     xbinary = 0;            /* Default is text */
  10786. #endif /* COMMENT */
  10787.     xxecho = xmitx;
  10788.  
  10789.     cmfdbi(&sw,            /* First FDB - command switches */
  10790.            _CMKEY,            /* fcode */
  10791.            "Filename, or switch",    /* hlpmsg */
  10792.            "",            /* default */
  10793.            "",            /* addtl string data */
  10794.            nxmitsw,            /* addtl numeric data 1: tbl size */
  10795.            4,            /* addtl numeric data 2: 4 = cmswi */
  10796.            xxstring,        /* Processing function */
  10797.            xmitsw,            /* Keyword table */
  10798.            &sf            /* Pointer to next FDB */
  10799.            );
  10800.     cmfdbi(&sf,            /* 2nd FDB - file to send */
  10801.            _CMIFI,            /* fcode */
  10802.            "File to transmit",    /* hlpmsg */
  10803.            "",            /* default */
  10804.            "",            /* addtl string data */
  10805.            0,            /* addtl numeric data 1 */
  10806.            0,            /* addtl numeric data 2 */
  10807.            xxstring,
  10808.            NULL,
  10809. #ifdef PIPESEND
  10810.            &tx
  10811. #else
  10812.            NULL
  10813. #endif /* PIPESEND */
  10814.            );
  10815. #ifdef PIPESEND
  10816.         cmfdbi(&tx,
  10817.            _CMTXT,            /* fcode */
  10818.            "Command",        /* hlpmsg */
  10819.            "",            /* default */
  10820.            "",            /* addtl string data */
  10821.            0,            /* addtl numeric data 1 */
  10822.            0,            /* addtl numeric data 2 */
  10823.            xxstring,
  10824.            NULL,
  10825.            NULL
  10826.            );
  10827. #endif /* PIPESEND */
  10828.  
  10829.     while (1) {
  10830.         x = cmfdb(&sw);
  10831.         if (x < 0)
  10832.           return(x);
  10833.         if (cmresult.fcode != _CMKEY)
  10834.           break;
  10835.         c = cmgbrk();        /* Have switch, get break character */
  10836.         if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  10837.         printf("?This switch does not take an argument\n");
  10838.         return(-9);
  10839.         }
  10840.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  10841.         printf("?This switch requires an argument\n");
  10842.         return(-9);
  10843.         }
  10844.         n = cmresult.nresult;    /* Numeric result = switch ID */
  10845.         switch (n) {        /* Process the switch */
  10846. #ifdef PIPESEND
  10847.           case XMI_CMD:        /* Transmit from a command */
  10848.         if (nopush) {
  10849.             printf("?Sorry, system command access is disabled\n");
  10850.             return(-9);
  10851.         }
  10852.         sw.hlpmsg = "Command, or switch"; /* Change help message */
  10853.         xpipe = 1;        /* (No way to undo this one) */
  10854.         break;
  10855. #endif /* PIPESEND */
  10856.  
  10857.           case XMI_BIN:        /* Binary */
  10858.         xbinary = 1;
  10859.         xxlate = 0;        /* Don't translate charsets */
  10860.         scan = 0;
  10861.         break;
  10862.  
  10863.           case XMI_TXT:        /* Text */
  10864.         xbinary = 0;
  10865.         xxlate = !tcs_transp;    /* Translate if TERM CHAR not TRANSP */
  10866.         scan = 0;
  10867.         break;
  10868.  
  10869.           case XMI_TRA:        /* Transparent text */
  10870.         xbinary = 0;
  10871.         xxlate = 0;        /* But don't translate charsets */
  10872.         scan = 0;
  10873.         break;
  10874.  
  10875. #ifdef COMMENT
  10876.           case XMI_VRB:        /* /VERBOSE */
  10877.           case XMI_QUI:        /* /QUIET */
  10878.         break;            /* (not implemented yet) */
  10879. #endif /* COMMENT */
  10880.  
  10881.           case XMI_NOW:        /* /NOWAIT */
  10882.         xxnowait = 1;
  10883.         break;
  10884.  
  10885.           case XMI_NOE:        /* /NOWAIT */
  10886.         xxecho = 0;
  10887.         break;
  10888.  
  10889.           default:
  10890.         return(-2);
  10891.         }
  10892.  
  10893.     }
  10894.     if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT)
  10895.       return(-2);
  10896.     ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */
  10897.     if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  10898.       ckstrncpy(line,tmpbuf,LINBUFSIZ);
  10899.     s = line;
  10900.     if ((y = cmcfm()) < 0)        /* Confirm */
  10901.       return(y);
  10902. #ifdef CK_APC
  10903.     if ((apcactive == APC_LOCAL) ||
  10904.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  10905.       return(success = 0);
  10906. #endif /* CK_APC */
  10907.     if (cmresult.nresult != 0) {
  10908.         printf("?Only a single file may be transmitted\n");
  10909.         return(-9);
  10910.     }
  10911. #ifdef PIPESEND
  10912.     if (xpipe) {
  10913.         s = brstrip(s);
  10914.         if (!*s) {
  10915.         printf("?Sorry, a command to send from is required\n");
  10916.         return(-9);
  10917.         }
  10918.         pipesend = 1;
  10919.     }
  10920. #endif /* PIPESEND */
  10921.  
  10922.     if (scan && (filepeek
  10923. #ifndef NOXFER
  10924.              || patterns
  10925. #endif /* NOXFER */
  10926.              )) {        /* If user didn't specify type */
  10927.         int k, x;                  /* scan the file to see */
  10928.         x = -1;
  10929.         k = scanfile(s,&x,nscanfile);
  10930.         if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  10931.     }
  10932.     if (!xfrxla) xxlate = 0;
  10933.     success = transmit(s,
  10934.                (char) (xxnowait ? '\0' : (char)xmitp),
  10935.                xxlate,
  10936.                xbinary,
  10937.                xxecho
  10938.                );
  10939.     return(success);
  10940.     }
  10941. #endif /* NOXMIT */
  10942.  
  10943. #ifndef NOFRILLS
  10944.     if (cx == XXTYP  || cx == XXCAT || cx == XXMORE ||
  10945.     cx == XXHEAD || cx == XXTAIL) {
  10946.     int paging = 0, havename = 0, head = 0, width = 0, count = 0;
  10947.     char pfxbuf[64], * prefix = NULL;
  10948.     char outfile[CKMAXPATH+1];
  10949.     struct FDB sf, sw;
  10950.     char * pat = NULL;
  10951.     int incs = 0, outcs = 0, cset = -1, number = 0;
  10952. #ifdef UNICODE
  10953.         char * tocs = "";
  10954.     extern int fileorder;
  10955. #ifdef OS2
  10956. #ifndef NOCSETS
  10957.     extern int tcsr, tcsl;
  10958. #endif /* NOCSETS */
  10959. #endif /* OS2 */
  10960. #endif /* UNICODE */
  10961.  
  10962.     outfile[0] = NUL;
  10963.  
  10964.     if (cx == XXMORE)
  10965.       paging = 1;
  10966.     else if (cx == XXCAT)
  10967.       paging = 0;
  10968.     else
  10969.       paging = (typ_page < 0) ? xaskmore : typ_page;
  10970.     if (paging < 0)
  10971.       paging = saveask;
  10972.  
  10973.     if (cx == XXHEAD) {
  10974.         head = 10;
  10975.         cx = XXTYP;
  10976.     } else if (cx == XXTAIL) {
  10977.         head = -10;
  10978.         cx = XXTYP;
  10979.     }
  10980.  
  10981. #ifdef IKSD
  10982.     if (inserver && !ENABLED(en_typ)) {
  10983.         printf("?Sorry, TYPE command disabled\n");
  10984.         return(-9);
  10985.     }
  10986. #endif /* IKSD */
  10987.  
  10988.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  10989.            _CMKEY,            /* fcode */
  10990.            "Filename or switch",    /* hlpmsg */
  10991.            "",            /* default */
  10992.            "",            /* addtl string data */
  10993.            ntypetab,        /* addtl numeric data 1: tbl size */
  10994.            4,            /* addtl numeric data 2: 4 = cmswi */
  10995.            xxstring,        /* Processing function */
  10996.            typetab,            /* Keyword table */
  10997.            &sf            /* Pointer to next FDB */
  10998.            );
  10999.     cmfdbi(&sf,            /* 1st FDB - file to type */
  11000.            _CMIFI,            /* fcode */
  11001.            "",            /* hlpmsg */
  11002.            "",            /* default */
  11003.            "",            /* addtl string data */
  11004.            0,            /* addtl numeric data 1 */
  11005.            0,            /* addtl numeric data 2 */
  11006.            xxstring,
  11007.            NULL,
  11008.            NULL
  11009.            );
  11010.  
  11011.     while (!havename) {
  11012.         x = cmfdb(&sw);        /* Parse something */
  11013.         debug(F101,"type cmfdb","",x);
  11014.         debug(F101,"type cmresult.fcode","",cmresult.fcode);
  11015.         debug(F101,"type cmresult.nresult","",cmresult.nresult);
  11016.         if (x < 0) {            /* Error */
  11017.         if (x == -3) {
  11018.             x = -9;
  11019.             printf("?Filename required\n");
  11020.         }
  11021.         return(x);
  11022.         } else if (cmresult.fcode == _CMKEY) {
  11023.         char c; int getval;
  11024.         c = cmgbrk();
  11025.         getval = (c == ':' || c == '=');
  11026.         if (getval && !(cmgkwflgs() & CM_ARG)) {
  11027.             printf("?This switch does not take an argument\n");
  11028.             return(-9);
  11029.         }
  11030. #ifdef COMMENT
  11031.         if (!getval && (cmgkwflgs() & CM_ARG)) {
  11032.             printf("?This switch requires an argument\n");
  11033.             /* Not if it has a default! */
  11034.             return(-9);
  11035.         }
  11036. #endif /* COMMENT */
  11037.         switch (cmresult.nresult) {
  11038. #ifdef CK_TTGWSIZ
  11039.           case TYP_PAG:
  11040.             paging = 1;
  11041.             break;
  11042.  
  11043.           case TYP_NOP:
  11044.             paging = 0;
  11045.             break;
  11046. #endif /* CK_TTGWSIZ */
  11047.  
  11048.           case TYP_COU:
  11049.             paging = 0;
  11050.             count = 1;
  11051.             break;
  11052.  
  11053.           case TYP_HEA:
  11054.           case TYP_TAI:
  11055.             y = 10;
  11056.             if (getval)
  11057.               if ((x = cmnum("Number of lines",
  11058.                      "10",10,&y,xxstring)) < 0)
  11059.             return(x);
  11060.             head = (cmresult.nresult == TYP_TAI) ? -y : y;
  11061.             break;
  11062.  
  11063.           case TYP_WID:
  11064.             y = typ_wid > -1 ? typ_wid : cmd_cols;
  11065.             if (getval)
  11066.               if ((x = cmnum("Column at which to truncate",
  11067.                      ckitoa(y),10,&y,xxstring)) < 0)
  11068.             return(x);
  11069.             width = y;
  11070.             break;
  11071.  
  11072.           case TYP_PAT:
  11073.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11074.             printf("?This switch requires an argument\n");
  11075.             return(-9);
  11076.             }
  11077.             if ((x = cmfld("pattern","",&s,xxstring)) < 0)
  11078.               return(x);
  11079.             ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  11080.             pat = tmpbuf;
  11081.             break;
  11082.  
  11083.           case TYP_PFX:
  11084.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11085.             printf("?This switch requires an argument\n");
  11086.             return(-9);
  11087.             }
  11088.             if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0)
  11089.               return(x);
  11090.             if ((int)strlen(s) > 63) {
  11091.             printf("?Too long - 63 max\n");
  11092.             return(-9);
  11093.             }
  11094.             ckstrncpy(pfxbuf,s,64);
  11095.             prefix = brstrip(pfxbuf);
  11096.             number = 0;
  11097.             break;
  11098.  
  11099.           case TYP_NUM:        /* /NUMBER */
  11100.             number = 1;
  11101.             prefix = NULL;
  11102.             break;
  11103.  
  11104. #ifdef UNICODE
  11105.           case TYP_XPA:        /* /TRANSPARENT */
  11106.             incs = 0;
  11107.             cset = 0;
  11108.             outcs = -1;
  11109.             break;
  11110.  
  11111.           case TYP_XIN:        /* /CHARACTER-SET: */
  11112.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11113.             printf("?This switch requires an argument\n");
  11114.             return(-9);
  11115.             }
  11116.             if ((incs = cmkey(fcstab,nfilc,
  11117.                       "character-set name","",xxstring)) < 0) {
  11118.             if (incs == -3)    /* Note: No default */
  11119.               incs = -2;
  11120.             return(incs);
  11121.             }
  11122.             cset = incs;
  11123.             break;
  11124.  
  11125.           case TYP_XUT:        /* /TRANSLATE-TO: */
  11126.             if (!getval && (cmgkwflgs() & CM_ARG)) {
  11127.             printf("?This switch requires an argument\n");
  11128.             return(-9);
  11129.             }
  11130. #ifdef OS2
  11131.             if (!inserver && !k95stdout) {
  11132.             tocs = "ucs2";
  11133.             } else {
  11134. #ifdef CKOUNI
  11135.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  11136. #else /* CKOUNI */
  11137.             extern struct keytab ttcstab[];
  11138.             extern int ntxrtab;
  11139.             tocs = rlookup(ttcstab,ntermc,tocs);
  11140.             if (!tocs)
  11141.               tocs = getdcset();
  11142. #endif /* CKOUNI */
  11143.                     }
  11144. #else /* OS2 */
  11145.             tocs = getdcset();
  11146. #endif /* OS2 */
  11147.             if ((outcs = cmkey(fcstab,nfilc,
  11148.                        "character-set",tocs,xxstring)) < 0)
  11149.               return(outcs);
  11150.             break;
  11151. #endif /* UNICODE */
  11152.           case TYP_OUT:
  11153.             if ((x = cmofi("File for result lines","",
  11154.                    &s,xxstring)) < 0)
  11155.               return(x);
  11156.             ckstrncpy(outfile,s,CKMAXPATH);
  11157.             break;
  11158.         }
  11159.         } else if (cmresult.fcode == _CMIFI)
  11160.           havename = 1;
  11161.         else
  11162.           return(-2);
  11163.     }
  11164.     if (havename) {
  11165.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  11166.         y = cmresult.nresult;
  11167.     } else {
  11168.         if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
  11169.         if (x == -3) {
  11170.             printf("?Name of an existing file required\n");
  11171.             return(-9);
  11172.         } else return(x);
  11173.         }
  11174.         ckstrncpy(line,s,LINBUFSIZ);
  11175.     }
  11176.     if (y != 0) {
  11177.         printf("?A single file please\n");
  11178.         return(-9);
  11179.     }
  11180.     if ((y = cmcfm()) < 0)        /* Confirm the command */
  11181.       return(y);
  11182.  
  11183. #ifdef UNICODE
  11184.     fileorder = -1;
  11185.     if (cset < 0 && filepeek) {    /* If no charset switches given */
  11186.         int k, x = -1;
  11187.         k = scanfile(line,&x,nscanfile); /* Call file analyzer */
  11188.         debug(F111,"type scanfile",line,k);
  11189.         debug(F101,"type scanfile flag","",x);
  11190.         switch(k) {
  11191.           case FT_UTF8:        /* which can detect UTF-8... */
  11192.         cset = 0;
  11193.         incs = FC_UTF8;
  11194.         break;
  11195.           case FT_UCS2:        /* and UCS-2... */
  11196.         cset = 0;
  11197.         incs = FC_UCS2;
  11198.         fileorder = x;        /* even if there is no BOM. */
  11199.         debug(F101,"type fileorder","",fileorder);
  11200.         break;
  11201.         }
  11202.     }
  11203. #ifdef OS2
  11204.         if (cset < 0) {            /* If input charset still not known */
  11205. #ifdef CKOUNI
  11206.             tocs = rlookup(txrtab,ntxrtab,tcsl);
  11207. #else /* CKOUNI */
  11208.             extern struct keytab ttcstab[];
  11209.             extern int ntxrtab;
  11210.             tocs = rlookup(ttcstab,ntermc,incs);
  11211.             if (!tocs)
  11212.           tocs = getdcset();
  11213. #endif /* CKOUNI */
  11214.             incs = lookup(fcstab,tocs,nfilc,&x);
  11215.         }
  11216. #endif /* OS2 */
  11217.  
  11218.         if (outcs == 0 && incs != 0) {    /* Supply default target charset */
  11219.         int x = 0;            /* if switch not given. */
  11220.         tocs = getdcset();
  11221.         outcs = lookup(fcstab,tocs,nfilc,&x);
  11222.     }
  11223. #else  /* !UNICODE */
  11224.     if (cset < 0) incs = outcs = 0;
  11225. #endif /* UNICODE */
  11226.  
  11227.     if (outfile[0] && paging)    /* This combination makes no sense */
  11228.       paging = 0;            /* so turn off paging */
  11229.  
  11230.     if (count) paging = -1;
  11231.     debug(F111,"type",line,paging);
  11232.     s = outfile;
  11233.     success =
  11234.       dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number);
  11235.     return(success);
  11236.     }
  11237. #endif /* NOFRILLS */
  11238.  
  11239. #ifndef NOCSETS
  11240.     if (cx == XXXLA) {            /* TRANSLATE file's charset */
  11241.     _PROTOTYP (int doxlate, ( void ) );
  11242.     return(doxlate());
  11243.     }
  11244. #endif /* NOCSETS */
  11245.  
  11246.     if (cx == XXVER) {            /* VERSION */
  11247.     int n = 0;
  11248.     extern char * ck_patch, * ck_s_test;
  11249. #ifdef COMMENT
  11250.     extern int hmtopline;
  11251. #endif /* COMMENT */
  11252.     if ((y = cmcfm()) < 0)
  11253.           return(y);
  11254.  
  11255.     printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum);
  11256.     printf("\n");
  11257.     n = 3;
  11258.     if (*ck_s_test) {
  11259.         printf("\n THIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n");
  11260.         n += 2;
  11261.     }
  11262.     if (*ck_patch) {
  11263.         printf(" Patches: %s\n", ck_patch);
  11264.         n++;
  11265.     }
  11266.     printf(" Type COPYRIGHT for copyright information.\n\n");
  11267. #ifdef OS2
  11268.     shoreg();
  11269. #else
  11270. #ifdef COMMENT
  11271.     hmtopline = n+1;
  11272.     hmsga(copyright);
  11273.     hmtopline = 0;
  11274. #endif /* COMMENT */
  11275. #endif /* OS2 */
  11276.     return(success = 1);
  11277.     }
  11278.  
  11279.     if (cx == XXCPR) {            /* COPYRIGHT or LICENSE */
  11280.     if ((y = cmcfm()) < 0)
  11281.           return(y);
  11282.     hmsga(copyright);
  11283.     return(success = 1);
  11284.     }
  11285.  
  11286. #ifndef MAC                /* Only for multiuser systems */
  11287. #ifndef OS2
  11288. #ifndef NOFRILLS
  11289.     if (cx == XXWHO) {            /* WHO */
  11290.     char *wc;
  11291. #ifdef IKSD
  11292.     if (inserver && !ENABLED(en_who)) {
  11293.         printf("?Sorry, WHO command disabled\n");
  11294.         return(-9);
  11295.     }
  11296. #endif /* IKSD */
  11297. #ifdef datageneral
  11298.     if ((z = cmcfm()) < 0) return(z);
  11299.     if (nopush) {
  11300.         printf("?Sorry, who not allowed\n");
  11301.         return(success = 0);
  11302.     }
  11303.         xsystem(WHOCMD);
  11304. #else
  11305.     if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y);
  11306.         if (nopush) {
  11307.         printf("?Sorry, WHO command disabled\n");
  11308.         return(success = 0);
  11309.     }
  11310.     if (!(wc = getenv("CK_WHO"))) wc = WHOCMD;
  11311.     if (wc)
  11312.       if ((int) strlen(wc) > 0) {
  11313.           ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL);
  11314.           xsystem(line);
  11315.       }
  11316. #endif /* datageneral */
  11317.     return(success = 1);
  11318.     }
  11319. #endif /* NOFRILLS */
  11320. #endif /* OS2 */
  11321. #endif /* MAC */
  11322.  
  11323. #ifndef NOFRILLS
  11324.     if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */
  11325.     int x,y;            /* On stack in case of \fexec() */
  11326.     if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) {
  11327.         if (x == -3) printf("?Write to what?\n");
  11328.         return(x);
  11329.     }
  11330.     if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y);
  11331.     s = brstrip(s);
  11332.     switch (x) {
  11333.       case LOGD: y = ZDFILE; break;
  11334.       case LOGP: y = ZPFILE; break;
  11335. #ifndef NOLOCAL
  11336.       case LOGS: y = ZSFILE; break;
  11337. #endif /* NOLOCAL */
  11338.       case LOGT: y = ZTFILE; break;
  11339. #ifndef NOSPL
  11340.       case LOGW: y = ZWFILE; break;
  11341. #endif /* NOSPL */
  11342.       case LOGX:            /* SCREEN (stdout) */
  11343.       case LOGE:            /* ERROR  (stderr) */
  11344.         if (x == LOGE) {
  11345.         debug(F110,
  11346.               (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0);
  11347.         fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : "");
  11348.         } else {
  11349.         debug(F110,
  11350.               (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0);
  11351.         printf("%s%s",s,(cx == XXWRL) ? "\n" : "");
  11352.         }
  11353.         return(success = 1);
  11354.       default: return(-2);
  11355.     }
  11356.     if (chkfn(y) > 0) {
  11357.         x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s);
  11358.         if (x < 0) printf("?Write error\n");
  11359.     } else {
  11360.         x = -1;
  11361.         printf("?File or log not open\n");
  11362.     }
  11363.     return(success = (x == 0) ? 1 : 0);
  11364.     }
  11365. #endif /* NOFRILLS */
  11366.  
  11367. #ifndef NOXFER
  11368.     if (cx == XXASC || cx == XXBIN) {
  11369.     if ((x = cmcfm()) < 0) return(x);
  11370. #ifdef NEWFTP
  11371.     if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  11372.       return(success = doftptyp((cx == XXASC) ? 0 : 1));
  11373. #endif /* NEWFTP */
  11374.     binary = (cx == XXASC) ? XYFT_T : XYFT_B;
  11375.     return(success = 1);
  11376.     }
  11377. #endif /* NOXFER */
  11378.  
  11379.     if (cx == XXCLS) {
  11380.     if ((x = cmcfm()) < 0) return(x);
  11381.     y = ck_cls();
  11382.     return(success = (y > -1) ? 1 : 0);
  11383.     }
  11384.  
  11385. #ifdef CK_MKDIR
  11386.     if (cx == XXMKDIR || cx == XXLMKD) {
  11387.     char *p;
  11388. #ifdef LOCUS
  11389.     if (!locus && cx != XXLMKD) {
  11390. #ifdef NOXFER
  11391.         return(-2);
  11392. #else
  11393.         return(dormt(XZMKD));
  11394. #endif /* NOXFER */
  11395.         }
  11396. #endif /* LOCUS */
  11397. #ifdef IKSD
  11398.     if (inserver && !ENABLED(en_mkd)) {
  11399.         printf("?Sorry, directory creation is disabled\n");
  11400.         return(-9);
  11401.     }
  11402. #endif /* IKSD */
  11403.     if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) {
  11404.         if (x != -3) {
  11405.         return(x);
  11406.         } else {
  11407.         printf("?Directory name required\n");
  11408.         return(-9);
  11409.         }
  11410.     }
  11411.     ckstrncpy(line,s,LINBUFSIZ);
  11412.     s = line;
  11413.     if ((x = cmcfm()) < 0) return(x);
  11414.     s = brstrip(s);
  11415.     bgchk();            /* Set msgflg */
  11416.     x = ckmkdir(0,s,&p,msgflg,0);
  11417. #ifdef COMMENT
  11418.     if (msgflg && x == 0)
  11419.       printf("?Directory already exists\n");
  11420. #endif /* COMMENT */
  11421.     return(success = (x < 0) ? 0 : 1);
  11422.     }
  11423.     if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */
  11424.     char *p;
  11425. #ifdef LOCUS
  11426.     if (!locus && cx != XXLRMD) {
  11427. #ifdef NOXFER
  11428.         return(-2);
  11429. #else
  11430.         return(dormt(XZRMD));
  11431. #endif /* NOXFER */
  11432.         }
  11433. #endif /* LOCUS */
  11434. #ifdef IKSD
  11435.     if (inserver && !ENABLED(en_rmd)) {
  11436.         printf("?Sorry, directory removal is disabled\n");
  11437.         return(-9);
  11438.     }
  11439. #endif /* IKSD */
  11440.     if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0)
  11441.       return(x);
  11442.     ckstrncpy(line,s,LINBUFSIZ);
  11443.     s = line;
  11444.     if ((x = cmcfm()) < 0) return(x);
  11445.     s = brstrip(s);
  11446.     x = ckmkdir(1,s,&p,msgflg,0);
  11447.     return(success = (x < 0) ? 0 : 1);
  11448.     }
  11449. #endif /* CK_MKDIR */
  11450.  
  11451. #ifdef TNCODE
  11452.     if (cx == XXTELOP)
  11453.       return(dotelopt());
  11454. #endif /* TNCODE */
  11455.  
  11456. #ifndef NOPUSH
  11457.     if (cx == XXNPSH) {
  11458.     if ((z = cmcfm()) < 0) return(z);
  11459.         nopush = 1;
  11460. #ifndef NOSERVER
  11461.         en_hos = 0;
  11462. #endif /* NOSERVER */
  11463. #ifdef PIPESEND
  11464.     usepipes = 0;
  11465. #endif /* PIPESEND */
  11466.         return(success = 1);
  11467.     }
  11468. #endif /* NOPUSH */
  11469.  
  11470. #ifndef NOSPL
  11471.     if (cx == XXLOCAL)            /* LOCAL variable declarations */
  11472.       return(success = dolocal());
  11473. #endif /* NOSPL */
  11474.  
  11475.     if (cx == XXKERMI) {        /* The KERMIT command */
  11476.     char * list[65];
  11477.     extern char **xargv;
  11478.     extern int xargc;
  11479.     int i;
  11480.     if ((y = cmtxt("kermit command-line arguments, -h for help",
  11481.                "",&s,xxstring)) < 0)
  11482.       return(y);
  11483.     ckstrncpy(line,"kermit ",LINBUFSIZ);
  11484.     ckstrncat(line,s,LINBUFSIZ-8);
  11485.     xwords(line,64,list,0);
  11486.     for (i = 1; i < 64; i++) {
  11487.         if (!list[i])
  11488.           break;
  11489.     }
  11490.     i--;
  11491.     xargc = i;
  11492.     xargv = list;
  11493.     xargv++;
  11494.     sstate = cmdlin();
  11495.     if (sstate) {
  11496.         extern int justone;
  11497.         debug(F000,"KERMIT sstate","",sstate);
  11498.         justone = 1;        /* Force return to command mode */
  11499.         proto();            /* after protocol */
  11500.         return(success);
  11501.     } else {
  11502.         debug(F101,"KERMIT sstate","",sstate);
  11503.         return(success = 1);    /* Not exactly right, but... */
  11504.     }
  11505.     }
  11506.     if (cx == XXDATE) {            /* DATE command */
  11507.     extern char cmdatebuf[], * cmdatemsg;
  11508.  
  11509. #ifndef COMMENT
  11510.     char * dp;
  11511.     if ((y = cmtxt("date and/or time, or carriage return for current",
  11512.                "",&s,xxstring)) < 0)
  11513.       return(y);
  11514.     s = brstrip(s);
  11515.     dp = cmcvtdate(s,1);
  11516.     if (!dp) {
  11517.         printf("?%s\n",cmdatemsg);
  11518.         success = 0;
  11519.     } else {
  11520.         printf("%s\n",dp);
  11521.         success = 1;
  11522.     }
  11523. #else
  11524.     /* This works fine but messes up my "dates" torture-test script */
  11525.  
  11526.     if ((x = cmdate("Date and/or time, or carriage return for current",
  11527.             "",&s,0,xxstring)) < 0) {
  11528.         return(x);
  11529.     } else {
  11530.         printf("%s\n",cmdatebuf);
  11531.         success = 1;
  11532.     }
  11533. #endif /* COMMENT */
  11534.     return(success);
  11535.     }
  11536. #ifndef NOPUSH
  11537. #ifndef NOFRILLS
  11538.     if (cx == XXEDIT)
  11539.       return(doedit());
  11540. #endif /* NOFRILLS */
  11541. #endif /* NOPUSH */
  11542.  
  11543. #ifdef BROWSER                /* Defined only ifndef NOPUSH */
  11544.     if (cx == XXBROWS)
  11545.       return(dobrowse());
  11546. #endif /* BROWSER */
  11547.  
  11548. #ifdef CK_TAPI
  11549.     if (cx == XXTAPI) {            /* Microsoft TAPI */
  11550.     return (success = dotapi());
  11551.     }
  11552. #endif /* CK_TAPI */
  11553.  
  11554. #ifndef NOXFER
  11555.     if (cx == XXWHERE) {
  11556.     extern char * rfspec, * sfspec, * srfspec, * rrfspec;
  11557.     if ((x = cmcfm()) < 0) return(x);
  11558.     printf("\nFile most recently...\n\n");
  11559.     printf("  Sent:       %s\n",   sfspec ? sfspec : "(none)");
  11560.     if (sfspec && srfspec) {
  11561.         printf("  Stored as:  %s\n",   srfspec);
  11562.         printf("\n");
  11563.     }
  11564.     printf("  Received:   %s\n",   rrfspec ? rrfspec : "(none)");
  11565.     if (rfspec && rrfspec)
  11566.     printf("  Stored as:  %s\n",   rfspec);
  11567.     printf(
  11568. "\nIf the full path is not shown, then the file is probably in your current\n"
  11569.            );
  11570.     printf(
  11571. "directory or your download directory (if any - SHOW FILE to find out).\n\n"
  11572.            );
  11573.     return(success = 1);
  11574.     }
  11575. #endif /* NOXFER */
  11576.  
  11577. #ifdef CK_RECALL
  11578.     if (cx == XXREDO)
  11579.       return(doredo());
  11580. #endif /* CK_RECALL */
  11581.  
  11582. #ifdef CKROOT
  11583.     if (cx == XXCHRT)            /* Change Kermit's root directory */
  11584.       return(dochroot());
  11585. #endif /* CKROOT */
  11586.  
  11587. #ifdef CK_KERBEROS
  11588.     if (cx == XXAUTH) {            /* KERBEROS */
  11589.     x = cp_auth();            /* Parse it */
  11590. #ifdef IKSD
  11591.         if (inserver) {
  11592.             printf("?Command disabled in IKSD.\r\n");
  11593.             return(success = 0);
  11594.         }
  11595. #endif /* IKSD */
  11596.     if (x < 0)            /* Pass parse errors back */
  11597.       return(x);
  11598.     return(success = doauth(cx));
  11599.     }
  11600. #endif /* CK_KERBEROS */
  11601.  
  11602. #ifndef NOLOCAL
  11603.     if (cx == XXTERM) {
  11604.     return(settrmtyp());
  11605.     }
  11606. #endif /* NOLOCAL */
  11607.  
  11608.     if (cx == XXSTATUS) {
  11609.     if ((x = cmcfm()) < 0) return(x);
  11610.     printf( " %s\n", success ? "SUCCESS" : "FAILURE" );
  11611.     return(0);            /* Don't change it */
  11612.     }
  11613.  
  11614.     if (cx == XXFAIL) {
  11615.     if ((x = cmcfm()) < 0) return(x);
  11616.     return(success = 0);
  11617.     }
  11618.  
  11619.     if (cx == XXSUCC) {
  11620.     if ((x = cmcfm()) < 0) return(x);
  11621.     return(success = 1);
  11622.     }
  11623.  
  11624.     if (cx == XXNLCL) {
  11625.     extern int nolocal;
  11626.     if ((x = cmcfm()) < 0) return(x);
  11627.     nolocal = 1;
  11628.     return(success = 1);
  11629.     }
  11630.  
  11631. #ifndef NOXFER
  11632.     if (cx == XXRASG)            /* Shortcuts for REMOTE commands */
  11633.       return(dormt(XZASG));
  11634.     if (cx == XXRCWD)
  11635.       return(dormt(XZCWD));
  11636.     if (cx == XXRCPY)
  11637.       return(dormt(XZCPY));
  11638.     if (cx == XXRDEL)
  11639.       return(dormt(XZDEL));
  11640.     if (cx == XXRDIR)
  11641.       return(dormt(XZDIR));
  11642.     if (cx == XXRXIT)
  11643.       return(dormt(XZXIT));
  11644.     if (cx == XXRHLP)
  11645.       return(dormt(XZHLP));
  11646.     if (cx == XXRHOS)
  11647.       return(dormt(XZHOS));
  11648.     if (cx == XXRKER)
  11649.       return(dormt(XZKER));
  11650.     if (cx == XXRPWD)
  11651.       return(dormt(XZPWD));
  11652.     if (cx == XXRQUE)
  11653.       return(dormt(XZQUE));
  11654.     if (cx == XXRREN)
  11655.       return(dormt(XZREN));
  11656.     if (cx == XXRMKD)
  11657.       return(dormt(XZMKD));
  11658.     if (cx == XXRRMD)
  11659.       return(dormt(XZRMD));
  11660.     if (cx == XXRSET)
  11661.       return(dormt(XZSET));
  11662.     if (cx == XXRSPA)
  11663.       return(dormt(XZSPA));
  11664.     if (cx == XXRTYP)
  11665.       return(dormt(XZTYP));
  11666.     if (cx == XXRWHO)
  11667.       return(dormt(XZWHO));
  11668.     if (cx == XXRCDUP)
  11669.       return(dormt(XZCDU));
  11670.     if (cx == XXRPRI)
  11671.       return(dormt(XZPRI));
  11672. #endif /* NOXFER */
  11673.  
  11674.     if (cx == XXRESET) {        /* RESET */
  11675.     if ((x = cmcfm()) < 0)
  11676.       return(x);
  11677.     doclean(0);            /* Close all files */
  11678.     return(success = 1);
  11679.     }
  11680.  
  11681. #ifndef NOXFER
  11682. #ifndef NOCSETS
  11683.     if (cx == XXASSOC)            /* ASSOCIATE */
  11684.       return(doassoc());
  11685. #endif /* NOCSETS */
  11686. #endif /* NOXFER */
  11687.  
  11688. #ifndef NOSPL
  11689.     if (cx == XXSHIFT) {        /* SHIFT */
  11690.     if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0)
  11691.       return(y);
  11692.     if ((z = cmcfm()) < 0)
  11693.       return(z);
  11694.     return(success = doshift(x));
  11695.     }
  11696. #endif /* NOSPL */
  11697.  
  11698. #ifndef NOHELP
  11699.     if (cx == XXMAN)
  11700.       return(domanual());
  11701. #endif /* NOHELP */
  11702.  
  11703. #ifndef NOSPL
  11704.     if (cx == XXSORT)            /* SORT an array */
  11705.       return(dosort());
  11706. #endif /* NOSPL */
  11707.  
  11708.     if (cx == XXPURGE) {
  11709. #ifdef IKSD
  11710.     if (inserver && (!ENABLED(en_del)
  11711. #ifdef CK_LOGIN
  11712.                           || isguest
  11713. #endif /* CK_LOGIN */
  11714.              )) {
  11715.         printf("?Sorry, DELETE is disabled\n");
  11716.         return(-9);
  11717.     }
  11718. #endif /* IKSD */
  11719. #ifdef CK_APC
  11720.     if ((apcactive == APC_LOCAL) ||
  11721.         ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  11722.       return(success = 0);
  11723. #endif /* CK_APC */
  11724. #ifdef CKPURGE
  11725.         return(dopurge());
  11726. #else
  11727. #ifdef VMS
  11728.     if ((x = cmtxt("optional switches followed by filespec",
  11729.                "",&s,xxstring)) < 0)
  11730.       return(x);
  11731.     if (nopush) {
  11732.         printf("?Sorry, DCL access is disabled\n");
  11733.         return(-9);
  11734.     }
  11735.     ckstrncpy(line,s,LINBUFSIZ);
  11736.     s = line;
  11737.     x = mlook(mactab,"purge",nmac);
  11738.     return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs));
  11739. #else
  11740.     return(-2);
  11741. #endif /* VMS */
  11742. #endif /* CKPURGE */
  11743.     }
  11744.  
  11745. #ifndef NOSPL
  11746.     if (cx == XXFAST) {
  11747.     if ((x = cmcfm()) < 0) return(x);
  11748.     x = mlook(mactab,"fast",nmac);
  11749.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11750.     }
  11751.     if (cx == XXCAU) {
  11752.     if ((x = cmcfm()) < 0) return(x);
  11753.     x = mlook(mactab,"cautious",nmac);
  11754.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11755.     }
  11756.     if (cx == XXROB) {
  11757.     if ((x = cmcfm()) < 0) return(x);
  11758.     x = mlook(mactab,"robust",nmac);
  11759.     return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
  11760.     }
  11761. #endif /* NOSPL */
  11762.  
  11763.     if (cx == XXSCRN) {            /* SCREEN */
  11764.     int row, col;
  11765.     if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0)
  11766.       return(x);
  11767.     switch (x) {            /* MOVE-TO (cursor position) */
  11768.       case SCN_MOV:
  11769.         if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0)
  11770.           return(y);
  11771.         row = z;
  11772.         y = cmnum("Column (1-based)","1",10,&z,xxstring);
  11773.         if (y < 0)
  11774.           return(y);
  11775.         col = z;
  11776.         if ((y = cmcfm()) < 0)
  11777.           return(y);
  11778.         if (row < 0 || col < 0) {
  11779.         printf("?Row and Column must be 1 or greater\n");
  11780.         return(-9);
  11781.         }
  11782.         if (cmd_rows > 0 && row > cmd_rows)
  11783.           row = cmd_rows;
  11784.         if (cmd_cols > 0 && col > cmd_cols)
  11785.           col = cmd_cols;
  11786.         y = ck_curpos(row,col);
  11787.         return(success = (y > -1) ? 1 : 0);
  11788.  
  11789.       case SCN_CLR:            /* CLEAR */
  11790.         if ((y = cmcfm()) < 0)
  11791.           return(y);
  11792.         debug(F100,"screen calling ck_cls()","",0);
  11793.         y = ck_cls();
  11794.         return(success = (y > -1) ? 1 : 0);
  11795.  
  11796.       case SCN_CLE:            /* CLEOL */
  11797.         if ((y = cmcfm()) < 0)
  11798.           return(y);
  11799.         y = ck_cleol();
  11800.         return(success = (y > -1) ? 1 : 0);
  11801.     }
  11802.     }
  11803.  
  11804. #ifndef NOHTTP
  11805. #ifdef TCPSOCKET
  11806.     if (cx == XXHTTP)
  11807.       return(dohttp());
  11808. #endif /* TCPSOCKET */
  11809. #endif /* NOHTTP */
  11810.  
  11811. #ifndef NOSPL
  11812.     if (cx == XXARRAY) {        /* ARRAY */
  11813. #ifndef NOSHOW
  11814.     extern int showarray();
  11815. #endif /* NOSHOW */
  11816.     if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0)
  11817.       return(x);
  11818.     switch (x) {
  11819.       case ARR_DCL:
  11820.         return(dodcl(XXDCL));
  11821.       case ARR_SRT:
  11822.         return(dosort());
  11823. #ifndef NOSHOW
  11824.       case ARR_SHO:
  11825.         return(showarray());
  11826. #endif /* NOSHOW */
  11827.       case ARR_CPY:
  11828.         return(copyarray());
  11829.       case ARR_SET:
  11830.       case ARR_CLR:
  11831.         return(clrarray(x));
  11832.       case ARR_DST:
  11833.         return(unarray());
  11834.       case ARR_RSZ:
  11835.         return(rszarray());
  11836.       case ARR_EQU:
  11837.         return(linkarray());
  11838.  
  11839.       default:
  11840.         printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf);
  11841.         return(-9);
  11842.     }
  11843.     }
  11844.     if (cx == XXTRACE)
  11845.       return(dotrace());
  11846. #endif /* NOSPL */
  11847.  
  11848. #ifdef CK_PERMS
  11849. #ifdef UNIX
  11850.     if (cx == XXCHMOD)
  11851.       return(douchmod());        /* Do Unix chmod */
  11852. #endif /* UNIX */
  11853. #endif /* CK_PERMS */
  11854.  
  11855.     if (cx == XXPROMP)
  11856.       return(doprompt());
  11857.  
  11858.     if (cx == XXGREP)
  11859.       return(dogrep());
  11860.  
  11861.     if (cx == XXDEBUG) {        /* DEBUG */
  11862. #ifndef DEBUG
  11863.     int dummy = 0;
  11864.     return(seton(&dummy));
  11865. #else
  11866.     return(seton(&deblog));
  11867. #endif /* DEBUG */
  11868.     }
  11869.  
  11870. #ifdef CKLEARN
  11871.     if (cx == XXLEARN) {        /* LEARN */
  11872.     struct FDB of, sw, cm;
  11873.     int closing = 0, off = 0, on = 0, confirmed = 0;
  11874.     char c;
  11875.  
  11876.     cmfdbi(&sw,            /* 2nd FDB - optional /PAGE switch */
  11877.            _CMKEY,            /* fcode */
  11878.            "Script file name, or switch", /* hlpmsg */
  11879.            "",            /* default */
  11880.            "",            /* addtl string data */
  11881.            3,            /* addtl numeric data 1: tbl size */
  11882.            4,            /* addtl numeric data 2: 4 = cmswi */
  11883.            xxstring,        /* Processing function */
  11884.            learnswi,        /* Keyword table */
  11885.            &of            /* Pointer to next FDB */
  11886.            );
  11887.     cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm);
  11888.     cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL);
  11889.     line[0] = NUL;
  11890.  
  11891.     while (!confirmed) {
  11892.         x = cmfdb(&sw);        /* Parse something */
  11893.         if (x < 0)
  11894.           return(x);
  11895.         switch (cmresult.fcode) {    /* What was it? */
  11896.           case _CMOFI:        /* Output file name */
  11897.         ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  11898.         break;
  11899.           case _CMKEY:        /* Switch */
  11900.         c = cmgbrk();
  11901.         if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) {
  11902.             printf("?This switch does not take an argument\n");
  11903.             return(-9);
  11904.         }
  11905.         switch (cmresult.nresult) {
  11906.           case 2:        /* /CLOSE */
  11907.             closing = 1;    /* Fall thru on purpose */
  11908.           case 0:        /* /OFF */
  11909.             off = 1;
  11910.             on = 0;
  11911.             break;
  11912.           case 1:        /* /ON */
  11913.             on = 1;
  11914.             off = 0;
  11915.             break;
  11916.         }
  11917.         break;
  11918.           case _CMCFM:        /* Confirmation */
  11919.         confirmed++;
  11920.         break;
  11921.         }
  11922.     }
  11923.     if (closing) {
  11924.         if (learnfp) {
  11925.         fclose(learnfp);
  11926.         learnfp = NULL;
  11927.         }
  11928.         makestr(&learnfile,NULL);
  11929.     }
  11930.     if (line[0]) {
  11931.         if (!on && !off)
  11932.           on = 1;
  11933.         if (learnfp) {
  11934.         fclose(learnfp);
  11935.         learnfp = NULL;
  11936.         }
  11937.         makestr(&learnfile,line);
  11938.         if (learnfile) {
  11939.         char * modes = "w";
  11940.         learnfp = fopen(learnfile,modes);
  11941.         if (!learnfp) {
  11942.             debug(F110,"LEARN file open error",learnfile,0);
  11943.             perror(learnfile);
  11944.             return(-9);
  11945.         } else {
  11946. #ifdef ZFNQFP
  11947.             if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf))
  11948.               makestr(&learnfile,tmpbuf);
  11949. #endif /* ZFNQFP */
  11950.             debug(F110,"LEARN file open ok",learnfile,0);
  11951.             if (!quiet) {
  11952.             printf("Recording to %s...\n\n",learnfile);
  11953.             printf(
  11954. " WARNING: If you type your password during script recording, it will appear\n\
  11955.  in the file.  Be sure to edit it or take other appropriate precautions.\n\n"
  11956.                    );
  11957.             }
  11958.             fputs(  "; Scriptfile: ",learnfp);
  11959.             fputs(learnfile,learnfp);
  11960.             fputs("\n; Directory:  ",learnfp);
  11961.             fputs(zgtdir(),learnfp);
  11962.             fputs("\n; Recorded:   ",learnfp);
  11963.             fputs(ckdate(),learnfp);
  11964.             fputs("\n",learnfp);
  11965.         }
  11966.         }
  11967.     }
  11968.     if (on) {
  11969.         learning = 1;
  11970.     } else if (off) {
  11971.         learning = 0;
  11972.     }
  11973.     debug(F101,"LEARN learning","",learning);
  11974.     return(success = 1);
  11975.     }
  11976. #endif /* CKLEARN */
  11977.  
  11978. #ifdef NEWFTP
  11979.     if (cx == XXUSER || cx == XXACCT) {
  11980.     if (!ftpisopen()) {
  11981.         printf("?FTP connection is not open\n");
  11982.         return(-9);
  11983.     }
  11984.     return(success = (cx == XXUSER) ? doftpusr() : doftpacct());
  11985.     }
  11986. #endif /* NEWFTP */
  11987.  
  11988.     if (cx == XXNOTAV) {        /* Command in table not available */
  11989.     ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  11990.     if ((x = cmtxt("Rest of command","",&s,NULL)) < 0)
  11991.       return(x);
  11992.     printf("Sorry, \"%s\" not configured in this version of Kermit.\n",
  11993.            tmpbuf
  11994.            );
  11995.     return(success = 0);
  11996.     }
  11997.     return(-2);                /* None of the above */
  11998.  
  11999. } /* end of docmd() */
  12000.  
  12001. #endif /* NOICP */
  12002.