6 char *userv = "User Interface 8.0.278, 12 Mar 2004";
8 /* C K U U S R -- "User Interface" for C-Kermit (Part 1) */
12 Frank da Cruz <fdc@columbia.edu>,
13 The Kermit Project, Columbia University, New York City
14 Jeffrey E Altman <jaltman@secure-endpoints.com>
15 Secure Endpoints Inc., New York City
17 Copyright (C) 1985, 2004,
18 Trustees of Columbia University in the City of New York.
19 All rights reserved. See the C-Kermit COPYING.TXT file or the
20 copyright text in the ckcmai.c module for disclaimer and permissions.
24 Originally the entire user interface was in one module, ckuusr.c. Over
25 the years it has been split into many modules: ckuus2.c, ckuus3.c, ...,
26 ckuus7.c. ckuus2.c contains the HELP command parser and help-text strings;
27 ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains
28 routines needed by both the command-line interface and the interactive
33 The ckuus*.c modules depend on the existence of C library features like
34 fopen, fgets, feof, (f)printf, argv/argc, etc. Other functions that are
35 likely to vary among different platforms -- like setting terminal modes or
36 interrupts -- are invoked via calls to functions that are defined in the
37 system- dependent modules, ck?[ft]io.c. The command line parser processes
38 any arguments found on the command line, as passed to main() via argv/argc.
39 The interactive parser uses the facilities of the cmd package (developed for
40 this program, but usable by any program). Any command parser may be
41 substituted for this one. The only requirements for the Kermit command
44 . Set parameters via global variables like duplex, speed, ttname, etc. See
45 ckmain.c for the declarations and descriptions of these variables.
47 . If a command can be executed without the use of Kermit protocol, then
48 execute the command directly and set the variable sstate to 0. Examples
49 include 'set' commands, local directory listings, the 'connect' command.
51 . If a command requires the Kermit protocol, set the following variables:
54 'x' (enter server mode) (none)
55 'r' (send a 'get' command) cmarg, cmarg2
56 'v' (enter receive mode) cmarg2
57 'g' (send a generic command) cmarg
58 's' (send files) nfils, cmarg & cmarg2 OR cmlist
59 'c' (send a remote host command) cmarg
61 cmlist is an array of pointers to strings.
62 cmarg, cmarg2 are pointers to strings.
65 cmarg can be a filename string (possibly wild), or
66 a pointer to a prefabricated generic command string, or
67 a pointer to a host command string.
68 cmarg2 is an "as-name" - the name to send file(s) under, or
69 the name under which to store incoming file(s); must not be wild.
70 A null or empty value means to use the file's own name.
71 cmlist is a list of filenames, such as passed via argv.
72 nfils is an integer, interpreted as follows:
73 -1: filespec (possibly wild) in cmarg, must be expanded internally.
74 0: send from stdin (standard input).
75 >0: number of files to send, from cmlist.
77 The screen() function is used to update the screen during file transfer.
78 The tlog() function writes to a transaction log.
79 The debug() function writes to a debugging log.
80 The intmsg() and chkint() functions provide the user i/o for interrupting
87 #define MULTINET_OLD_STYLE /* Leave select prototype undefined */
93 #include "ckcnet.h" /* Network symbols */
97 int g_fncact = -1; /* Needed for NOICP builds */
98 int noinit = 0; /* Flag for skipping init file */
99 int nscanfile = SCANFILEBUF;
101 int rcdactive = 0; /* RCD active */
102 int keepallchars = 0; /* See cmfld() */
104 int locus = 1; /* Current LOCUS is LOCAL */
106 int autolocus = 2; /* Automatic LOCUS switching: ASK */
108 int autolocus = 1; /* Automatic LOCUS switching enabled */
114 #include <time.h> /* For CKLEARN */
120 #define INCL_VIO /* Needed for ckocon.h */
128 #include "ckntap.h" /* CK_TAPI definition */
132 extern int tcp_avail;
133 extern bool viewonly;
134 extern int k95stdout;
135 extern int tt_scroll;
137 extern tt_status[VNUM];
139 int display_demo = 1;
150 extern int ftpget, ftpisopen(), doftpres();
151 _PROTOTYP(int doftptyp,(int));
159 #include <packets:common.h>
160 #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
161 #endif /* datageneral */
163 extern int xcmdsrc, hints, cmflgs, whyclosed;
165 char * hlptok = NULL;
167 #ifdef CK_TTGWSIZ /* Whether to use more-prompting */
168 int xaskmore = 1; /* Momentary setting */
169 int saveask = 1; /* Permanent setting */
173 #endif /* CK_TTGWSIZ */
177 extern struct keytab fcstab[];
181 char * g_pswd = NULL;
185 extern int cmd_rows, cmd_cols;
188 extern int ckrooterr;
191 extern int inserver, filepeek;
194 FILE * learnfp = NULL;
195 char * learnfile = NULL;
200 extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size,
201 sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz,
202 spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable,
207 #endif /* IKSDCONF */
211 #endif /* CK_LOGIN */
213 extern long sendstart;
215 extern char *cmarg, *cmarg2, **cmlist, *dftty;
217 extern struct keytab fntab[]; extern int nfntab;
218 extern struct ck_p ptab[NPROTOS];
220 int sndcmd = 0; /* Last command was a SEND-class command. */
230 int g_prefixing = -1;
238 char * g_sfilter = NULL;
239 char * g_rfilter = NULL;
243 extern char *txtpatterns[], *binpatterns[];
245 #endif /* PATTERNS */
249 extern int usepipes, pipesend;
250 extern char * sndfilter;
251 #endif /* PIPESEND */
254 extern int sndxlo, sndxhi, sndxin;
257 extern char fspec[]; /* Most recent filespec */
258 extern int fspeclen; /* Length of fspec[] buffer */
261 extern int rmailf; /* MAIL command items */
262 extern char optbuf[];
263 #endif /* NOFRILLS */
266 en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri,
267 en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit,
268 en_mkd, en_rmd, en_asg;
270 #ifndef NOMSEND /* Multiple SEND */
271 extern char *msfiles[];
272 int filesinlist = 0; /* And ADD ... */
273 extern struct filelist * filehead;
274 extern struct filelist * filetail;
275 extern struct filelist * filenext;
279 static struct keytab addtab[] = {
281 { "binary-patterns", ADD_BIN, 0 },
282 #endif /* PATTERNS */
284 { "send-list", ADD_SND, 0 },
287 { "text-patterns", ADD_TXT, 0 },
288 #endif /* PATTERNS */
291 static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;
294 struct keytab assoctab[] = {
295 { "file-character-set", ASSOC_FC, 0 },
296 { "transfer-character-set", ASSOC_TC, 0 },
297 { "xfer-character-set", ASSOC_TC, CM_INV }
299 static int nassoc = sizeof(assoctab)/sizeof(struct keytab);
300 extern int afcset[MAXFCSETS+1]; /* Character-set associations */
301 extern int axcset[MAXTCSETS+1];
311 #endif /* PATTERNS */
316 /* External Kermit Variables, see ckmain.c for description. */
318 extern xx_strp xxstring;
321 extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel,
322 pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;
325 extern char tn_msg[];
330 int g_recursive = -1;
335 extern char *versio, *copyright[];
338 extern char *introtxt[];
339 extern char *newstxt[];
349 extern char ttname[];
353 extern int network; /* Have active network connection */
354 extern int nettype; /* Type of network */
355 extern int ttnproto; /* NET_TCPB protocol */
358 extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */
362 extern int apcactive, apcstatus;
367 extern char editor[];
368 extern char editopts[];
369 extern char editfile[];
370 #endif /* NOFRILLS */
374 extern char browser[]; /* Web browser application */
375 extern char browsopts[]; /* Web browser options */
376 extern char browsurl[]; /* Most recent URL */
379 char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */
380 char ftpopts[128] = { NUL, NUL }; /* ftp command-line options */
382 extern struct keytab onoff[]; /* On/Off keyword table */
385 int f_tmpdir = 0; /* Directory changed temporarily */
386 char savdir[TMPDIRLEN]; /* For saving current directory */
387 #endif /* CK_TMPDIR */
389 int activecmd = -1; /* Keyword index of active command */
390 int doconx = -1; /* CONNECT-class command active */
391 int ooflag = 0; /* User-settable on/off flag */
393 int rcflag = 0; /* Pointer to home directory string */
394 int repars, /* Reparse needed */
395 techo = 0; /* Take echo */
396 int secho = 1; /* SCRIPT echo */
398 int xitwarn = /* Warn about open connection on exit */
406 struct keytab onoffsw[] = {
412 struct keytab redirsw[] = {
413 { "/redirect", 1, 0 }
418 /* Variables for TRANSMIT command */
420 int xmitx = 1; /* Whether to echo during TRANSMIT */
421 int xmitf = 0; /* Character to fill empty lines */
422 int xmitl = 0; /* 0 = Don't send linefeed too */
423 int xmitp = LF; /* Host line prompt */
424 int xmits = 0; /* Use shift-in/shift-out, 0 = no */
425 int xmitw = 0; /* Milliseconds to pause during TRANSMIT */
426 int xmitt = 1; /* Seconds to wait for each char to echo */
427 int xmita = 1; /* Action upon timeout */
438 static struct keytab xmitsw[] = { /* TRANSMIT command options */
439 { "/binary", XMI_BIN, 0 },
441 { "/command", XMI_CMD, CM_INV|CM_PSH },
442 #endif /* PIPESEND */
443 { "/noecho", XMI_NOE, 0 },
444 { "/nowait", XMI_NOW, 0 },
446 { "/pipe", XMI_CMD, 0 },
447 #endif /* PIPESEND */
449 { "/quiet", XMI_QUI, 0 },
451 { "/text", XMI_TXT, 0 },
452 { "/transparent", XMI_TRA, 0 },
454 { "/verbose", XMI_VRB, 0 },
458 #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1
459 static int nxmitsw = NXMITSW;
463 /* Declarations from ck?fio.c module */
465 extern char *SPACMD, *SPACM2; /* SPACE commands */
467 /* Command-oriented items */
470 extern char *cmdbuf; /* Command buffers */
472 extern char *line; /* Character buffer for anything */
473 extern char *tmpbuf; /* Short temporary string buffer */
478 extern char cmdbuf[]; /* Command buffers */
479 extern char atmbuf[];
480 extern char line[]; /* Character buffer for anything */
481 extern char tmpbuf[]; /* Temporary buffer */
488 extern char * prstring[];
491 char *lp; /* Pointer to line buffer */
494 int unkmacro = 0; /* Flag for in ON_UNKNOWN_COMMAND */
496 char evalbuf[33]; /* EVALUATE result */
497 extern char * inpbuf; /* Buffer for INPUT and REINPUT */
498 char *inpbp; /* And pointer to same */
499 extern char lblbuf[]; /* Buffer for labels */
500 int m_found; /* MINPUT result */
501 int i_active = 0; /* INPUT command is active */
502 char *ms[MINPMAX]; /* Pointers to MINPUT strings */
503 static int mp[MINPMAX]; /* and flags */
504 extern int fndiags, fnerror, fnsuccess; /* Function diagnostics */
506 char * lastsexp = NULL; /* S-Expressions */
507 char * sexpval = NULL;
508 int sexpecho = SET_AUTO;
512 char psave[PROMPTL] = { NUL }; /* For saving & restoring prompt */
514 extern int success; /* Command success/failure flag */
515 extern int cmdlvl; /* Current position in command stack */
518 int /* SET INPUT parameters. */
519 /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */
520 inbufsize = 0, /* INPUT buffer size */
521 indef = 1, /* default timeout, seconds */
522 inecho = 1, /* 1 = echo on */
523 inautodl = 0, /* INPUT autodownload */
524 inintr = 1, /* INPUT interrupion allowed */
525 innomatch = 0, /* INPUT /NOMATCH */
526 insilence = 0; /* 0 = no silence constraint */
529 CKFLOAT inscale = 1.0; /* Timeout scale factor */
533 int interm = 1; /* Terminal emulator displays input */
535 int maclvl = -1; /* Macro nesting level */
536 int mecho = 0; /* Macro echo, 0 = don't */
537 char varnam[6]; /* For variable names */
538 extern int macargc[]; /* ARGC from macro invocation */
540 extern char *m_arg[MACLEVEL][NARGS]; /* Stack of macro arguments */
541 extern char *mrval[];
543 extern char **a_ptr[]; /* Array pointers */
544 extern int a_dim[]; /* Array dimensions */
548 extern struct cmdptr *cmdstk; /* The command stack itself */
550 extern struct cmdptr cmdstk[]; /* The command stack itself */
553 long ck_alarm = 0; /* SET ALARM value */
554 char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
555 char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' };
558 struct keytab inputsw[] = {
559 { "/nomatch", INPSW_NOM, 0 }
561 static int ninputsw = sizeof(inputsw)/sizeof(struct keytab);
565 static int x, y, z = 0; /* Local workers */
569 static char c1chars[] = { /* C1 control chars escept NUL */
570 001,002,003,004,005,006,007,010,011,012,013,014,015,016,017,020,
571 021,022,023,024,025,026,027,030,031,032,033,034,035,036,037
573 #endif /* CK_MINPUT */
575 #define xsystem(s) zsyscmd(s)
577 /* Top-Level Interactive Command Keyword Table */
578 /* Keywords must be in lowercase and in alphabetical order. */
580 struct keytab cmdtab[] = {
582 { "!", XXSHE, CM_INV|CM_PSH }, /* Shell escape */
584 { "!", XXNOTAV, CM_INV|CM_PSH },
586 { "#", XXCOM, CM_INV }, /* Comment */
588 { "(", XXSEXP,CM_INV }, /* S-Expression */
589 { ".", XXDEF, CM_INV }, /* Assignment */
590 { ":", XXLBL, CM_INV }, /* Label */
594 { "<", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
596 { "<", XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */
598 #endif /* CK_REDIR */
600 { "@", XXSHE, CM_INV|CM_PSH }, /* DCL escape */
602 { "@", XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */
606 { "^", XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */
607 #endif /* CK_RECALL */
609 { "_asg", XXASX, CM_INV }, /* Used internally by FOR, etc */
610 { "_assign", XXASX, CM_INV }, /* Used internally by FOR, etc */
611 { "_decrement", XX_DECR, CM_INV },
612 { "_define", XXDFX, CM_INV }, /* Used internally by FOR, etc */
613 { "_evaluate", XX_EVAL, CM_INV },
614 { "_forward", XXXFWD, CM_INV }, /* Used internally by SWITCH */
615 { "_getargs", XXGTA, CM_INV }, /* Used internally by FOR, etc */
616 { "_increment", XX_INCR, CM_INV },
617 { "_putargs", XXPTA, CM_INV }, /* Used internally by FOR, etc */
618 { "_undefine", XXUNDFX, CM_INV },
621 { "about", XXVER, CM_INV }, /* Synonym for VERSION */
624 { "account", XXACCT, CM_INV }, /* (FTP) Account */
627 { "add", XXADD, 0 }, /* ADD */
630 { "answer", XXANSW, CM_LOC }, /* ANSWER the phone */
632 { "answer", XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */
634 { "apc", XXAPC, 0 }, /* Application Program Command */
636 { "array", XXARRAY, 0 }, /* Array operations */
638 { "ascii", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */
639 { "asg", XXASS, CM_INV }, /* Invisible synonym for ASSIGN */
640 { "ask", XXASK, 0 }, /* ASK for text, assign to variable */
641 { "askq", XXASKQ,0 }, /* ASK quietly (no echo) */
643 { "ass", XXASS, CM_INV|CM_ABR }, /* ASSIGN */
644 { "assert", XXASSER, CM_INV }, /* ASSERT */
645 { "assign", XXASS, 0 }, /* ASSIGN */
649 { "associate", XXASSOC, 0 }, /* ASSOCIATE */
651 { "associate", XXNOTAV, CM_INV }, /* ASSOCIATE */
655 #ifdef CK_AUTHENTICATION
656 { "authenticate",XXAUTH, 0 }, /* Authentication */
658 { "authenticate",XXAUTH, CM_INV },
659 #endif /* CK_AUTHENTICATION */
660 #endif /* CK_KERBEROS */
663 { "back", XXBACK, 0 }, /* BACK to previous directory */
665 { "back", XXNOTAV,CM_INV },
666 #endif /* NOFRILLS */
667 { "beep", XXBEEP,CM_INV }, /* BEEP */
669 { "binary", XXBIN, CM_INV }, /* == SET FILE TYPE BINARY */
672 { "bug", XXBUG, CM_INV }, /* BUG report instructions */
674 { "bug", XXNOTAV, CM_INV },
675 #endif /* NOFRILLS */
677 { "browse", XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */
679 { "browse", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
682 { "bye", XXBYE, 0 }, /* BYE to remote server */
685 { "c", XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */
688 { "cat", XXCAT, CM_INV }, /* Invisible synonym for TYPE */
689 #endif /* NOFRILLS */
693 { "cautious", XXCAU, CM_INV },
698 { "cd", XXCWD, 0 }, /* Change Directory */
699 { "cdup", XXCDUP, CM_INV }, /* Change Directory Up */
703 { "cget", XXCGET, CM_INV|CM_PSH }, /* CGET */
705 { "cget", XXNOTAV, CM_INV|CM_PSH }, /* CGET */
706 #endif /* PIPESEND */
708 { "ch", XXCHK, CM_INV|CM_ABR },
709 { "check", XXCHK, 0 }, /* CHECK for a feature */
712 { "chmod", XXCHMOD, 0 }, /* CHMOD */
714 { "chmod", XXNOTAV, CM_INV },
717 { "chmod", XXNOTAV, CM_INV },
718 #endif /* CK_PERMS */
720 { "chroot", XXCHRT, CM_INV }, /* CHROOT */
722 { "ckermit", XXKERMI, CM_INV }, /* CKERMIT (like KERMIT) */
723 { "cl", XXCLO, CM_ABR|CM_INV },
725 { "clear", XXCLE, 0 }, /* CLEAR input and/or device buffer */
727 { "clear", XXNOTAV, CM_INV },
728 #endif /* NOFRILLS */
729 { "close", XXCLO, 0 }, /* CLOSE a log or other file */
730 { "cls", XXCLS, CM_INV }, /* Clear Screen (CLS) */
731 { "comment", XXCOM, CM_INV }, /* Introduce a comment */
733 { "connect", XXCON, CM_LOC }, /* Begin terminal connection */
735 { "connect", XXNOTAV, CM_LOC },
737 { "continue", XXCONT, CM_INV }, /* CONTINUE */
740 { "co", XXCPY, CM_INV|CM_ABR },
741 { "cop", XXCPY, CM_INV|CM_ABR },
742 { "copy", XXCPY, 0 }, /* COPY a file */
744 { "copy", XXNOTAV, CM_INV },
746 { "copyright", XXCPR, CM_INV }, /* COPYRIGHT */
748 { "cp", XXCPY, CM_INV }, /* COPY a file */
752 { "cq", XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */
757 { "creceive", XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */
758 { "csend", XXCSEN,CM_INV|CM_PSH }, /* SEND from command */
760 { "creceive", XXNOTAV,CM_INV|CM_PSH },
761 { "csend", XXNOTAV,CM_INV|CM_PSH },
762 #endif /* PIPESEND */
764 #endif /* NOFRILLS */
766 { "cwd", XXCWD, CM_INV }, /* Traditional synonym for cd */
769 { "date", XXDATE, 0 }, /* DATE */
770 { "dcl", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */
771 { "debug", XXDEBUG, CM_INV },
772 { "declare", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */
773 { "decrement", XXDEC, 0 }, /* DECREMENT a numeric variable */
774 { "define", XXDEF, 0 }, /* DEFINE a macro or variable */
776 { "date", XXNOTAV, CM_INV },
777 { "dcl", XXNOTAV, CM_INV },
778 { "declare", XXNOTAV, CM_INV },
779 { "decrement", XXNOTAV, CM_INV },
780 { "define", XXNOTAV, CM_INV },
784 { "delete", XXDEL, 0 }, /* DELETE a file */
786 { "delete", XXNOTAV, CM_INV },
787 #endif /* NOFRILLS */
790 { "dial", XXDIAL, CM_LOC }, /* DIAL a phone number */
792 { "dial", XXNOTAV, CM_INV|CM_LOC },
796 { "dialer", XXDIALER, CM_INV }, /* K95 Dialer */
799 { "directory", XXDIR, 0 }, /* DIRECTORY of files */
803 { "disable", XXDIS, 0 }, /* DISABLE a server function */
805 { "disable", XXNOTAV, CM_INV },
806 #endif /* NOSERVER */
807 #endif /* NOFRILLS */
810 { "do", XXDO, 0 }, /* DO (execute) a macro */
812 { "do", XXNOTAV, CM_INV },
815 { "e", XXEXI, CM_INV|CM_ABR },
819 { "e-packet", XXERR, CM_INV }, /* Send an Error-Packet */
821 #endif /* NOFRILLS */
823 { "echo", XXECH, 0 }, /* ECHO text */
827 { "edit", XXEDIT, CM_PSH }, /* EDIT */
829 { "edit", XXNOTAV, CM_INV|CM_PSH }, /* EDIT */
831 #endif /* NOFRILLS */
833 { "eightbit", XXEIGHT, CM_INV }, /* EIGHTBIT */
836 { "else", XXELS, CM_INV }, /* ELSE part of IF statement */
838 { "else", XXNOTAV, CM_INV }, /* ELSE part of IF statement */
843 { "enable", XXENA, 0 }, /* ENABLE a server function */
845 { "enable", XXNOTAV, CM_INV },
846 #endif /* NOFRILLS */
847 #endif /* NOSERVER */
850 { "end", XXEND, 0 }, /* END command file or macro */
852 { "end", XXNOTAV, CM_INV },
855 { "erase", XXDEL, CM_INV }, /* Synonym for DELETE */
858 { "evaluate", XXEVAL, 0 }, /* EVALUATE */
860 { "evaluate", XXNOTAV, CM_INV },
863 { "ex", XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */
866 { "exec", XXEXEC, CM_INV|CM_LOC }, /* exec() */
868 { "exec", XXNOTAV, CM_INV|CM_LOC },
871 { "exit", XXEXI, 0 }, /* EXIT from C-Kermit */
872 { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */
875 { "extproc", XXCOM, CM_INV }, /* Dummy command for OS/2 */
879 { "f", XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */
883 { "fail", XXFAIL, CM_INV }, /* FAIL */
886 { "fast", XXFAST, CM_INV },
890 { "fclose", XXF_CL, CM_INV }, /* FCLOSE */
891 { "fcount", XXF_CO, CM_INV }, /* FCOUNT */
892 { "fflush", XXF_FL, CM_INV }, /* FFLUSH */
893 #endif /* CKCHANNELIO */
896 { "fi", XXFIN, CM_INV|CM_ABR }, /* FINISH */
900 { "file", XXFILE, 0 }, /* FILE */
901 #endif /* CKCHANNELIO */
905 { "fin", XXFIN, CM_INV|CM_ABR }, /* FINISH */
909 { "find", XXGREP, 0 }, /* FIND (grep) */
911 { "find", XXGREP,CM_INV },
912 #endif /* UNIXOROSK */
915 { "finish", XXFIN, 0 }, /* FINISH */
919 { "firewall", XXFIREW, CM_INV|CM_HLP },
920 #endif /* TCPSOCKET */
923 { "flist", XXF_LI, CM_INV }, /* FLIST */
924 { "fopen", XXF_OP, CM_INV }, /* FOPEN */
925 #endif /* CKCHANNELIO */
928 { "fo", XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */
929 { "for", XXFOR, 0 }, /* FOR loop */
930 { "forward", XXFWD, CM_INV }, /* FORWARD */
933 { "fot", XXDIR, CM_INV }, /* "fot" = "dir" (for Chris) */
934 #endif /* NOFRILLS */
937 { "fread", XXF_RE, CM_INV }, /* FREAD */
938 { "frewind", XXF_RW, CM_INV }, /* FREWIND */
939 { "fseek", XXF_SE, CM_INV }, /* FSEEK */
940 { "fstatus", XXF_ST, CM_INV }, /* FSTATUS */
941 #endif /* CKCHANNELIO */
947 { "ftp", XXFTP, CM_INV|CM_PSH|CM_LOC }, /* System FTP */
949 { "ftp", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
952 { "ftp", XXFTP, 0 }, /* Built-in FTP */
955 { "ftp", XXNOTAV, CM_INV }, /* No FTP */
957 #endif /* TCPSOCKET */
960 { "function", XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */
964 { "fwrite", XXF_WR, CM_INV }, /* FWRITE */
965 #endif /* CKCHANNELIO */
968 { "g", XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */
970 { "ge", XXGET, CM_INV|CM_ABR }, /* Ditto */
972 { "get", XXGET, 0 }, /* GET */
975 { "getc", XXGETC, 0 }, /* GETC */
977 { "getkeycode", XXGETK, 0 }, /* GETKEYCODE */
980 { "getok", XXGOK, 0 }, /* GETOK (ask for Yes/No/OK) */
981 #endif /* NOFRILLS */
984 { "goto", XXGOTO,0 }, /* GOTO label in take file or macro */
987 { "grep", XXGREP,0 }, /* GREP (find) */
989 { "grep", XXGREP,CM_INV }, /* GREP (find) */
990 #endif /* UNIXOROSK */
991 { "h", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
992 { "he", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
994 { "head", XXHEAD, 0 },
995 #endif /* NOFRILLS */
997 { "hangup", XXHAN, CM_LOC }, /* HANGUP the connection */
999 { "HELP", XXHLP, 0 }, /* Display HELP text */
1002 { "http", XXHTTP, 0 }, /* HTTP operations */
1003 #endif /* TCPSOCKET */
1006 { "i", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
1007 { "if", XXIF, 0 }, /* IF ( condition ) command */
1009 { "iksd", XXIKSD, CM_INV }, /* Make connection to IKSD */
1011 { "iksd", XXNOTAV, CM_INV },
1012 #endif /* TCPSOCKET */
1013 { "in", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
1014 { "increment", XXINC, 0 }, /* Increment a numeric variable */
1015 { "input", XXINP, 0 }, /* INPUT text from comm device */
1019 { "int", XXINT, CM_INV|CM_ABR },
1020 { "intr", XXINT, CM_INV|CM_ABR },
1021 { "INTRO", XXINT, 0 },
1022 { "introduction",XXINT, CM_INV }, /* Print introductory text */
1024 { "intro", XXNOTAV, CM_INV },
1025 { "introduction",XXNOTAV, CM_INV },
1029 { "k95", XXKERMI, CM_INV }, /* Hmmm what's this... */
1033 { "kcd", XXKCD, 0 },
1036 { "kermit", XXKERMI, CM_INV },
1040 { "kverb", XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */
1041 #endif /* NOKVERBS */
1045 { "l", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
1046 #endif /* NOFRILLS */
1048 { "lcd", XXLCWD, CM_INV },
1049 { "lcdup", XXLCDU, CM_INV },
1050 { "lcwd", XXLCWD, CM_INV },
1051 { "ldelete", XXLDEL, CM_INV },
1052 { "ldirectory", XXLDIR, CM_INV },
1055 { "learn", XXLEARN, 0 }, /* LEARN - automatic script writing */
1057 { "learn", XXNOTAV, CM_INV },
1058 #endif /* CKLEARN */
1060 { "li", XXLNOUT, CM_INV|CM_ABR },
1061 { "LICENSE", XXCPR, 0 }, /* LICENSE */
1064 { "lineout", XXLNOUT, 0 }, /* LINEOUT = OUTPUT + eol */
1068 { "link", XXLINK, 0 }, /* LINK source destination */
1071 { "lmkdir", XXLMKD, CM_INV },
1074 { "lo", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
1075 #endif /* NOFRILLS */
1078 { "local", XXLOCAL, CM_INV }, /* LOCAL variable declaration */
1080 { "local", XXNOTAV, CM_INV },
1083 { "log", XXLOG, 0 }, /* Open a log file */
1085 { "login", XXLOGIN, 0 }, /* (REMOTE) LOGIN to server or IKSD */
1086 { "logout", XXLOGOUT, 0 }, /* LOGOUT from server or IKSD */
1090 { "lookup", XXLOOK, 0 }, /* LOOKUP */
1092 { "lookup", XXNOTAV, CM_INV },
1095 { "lpwd", XXLPWD, CM_INV },
1096 { "lrename", XXLREN, CM_INV },
1097 { "lrmdir", XXLRMD, CM_INV },
1100 { "ls", XXLS, CM_INV|CM_PSH }, /* UNIX ls command */
1102 { "ls", XXDIR, CM_INV }, /* Invisible synonym for DIR */
1103 #endif /* UNIXOROSK */
1105 { "mail", XXMAI, 0 }, /* Send a file as e-mail */
1108 { "manual", XXMAN, CM_PSH }, /* MAN(UAL) */
1110 { "manual", XXNOTAV, CM_INV|CM_PSH },
1112 #endif /* NOFRILLS */
1114 { "md", XXMKDIR, CM_INV }, /* Synonym for MKDIR */
1115 #endif /* CK_MKDIR */
1117 { "minput", XXMINP, 0 }, /* MINPUT */
1119 { "minput", XXNOTAV, CM_INV },
1120 #endif /* CK_MINPUT */
1122 { "mget", XXMGET, 0 }, /* MGET */
1124 { "mget", XXNOTAV, CM_INV },
1125 #endif /* NOMSEND */
1127 { "mkdir", XXMKDIR, 0 }, /* MKDIR */
1129 { "mkdir", XXNOTAV, CM_INV },
1130 #endif /* CK_MKDIR */
1134 { "mmove", XXMMOVE, 0 }, /* MMOVE */
1136 { "mmove", XXNOTAV, CM_INV },
1137 #endif /* NOMSEND */
1141 { "more", XXMORE, CM_INV }, /* MORE */
1142 #endif /* NOFRILLS */
1145 { "move", XXMOVE, 0 }, /* MOVE */
1149 { "mpause", XXMSL, CM_INV }, /* Millisecond sleep */
1151 { "mpause", XXNOTAV, CM_INV },
1156 { "mput", XXMSE, CM_INV }, /* MPUT = MSEND */
1157 { "ms", XXMSE, CM_INV|CM_ABR },
1158 { "msend", XXMSE, 0 }, /* Multiple SEND */
1160 { "mput", XXNOTAV, CM_INV },
1161 { "msend", XXNOTAV, CM_INV },
1162 #endif /* NOMSEND */
1165 { "msleep", XXMSL, 0 }, /* Millisecond sleep */
1167 { "msleep", XXNOTAV, CM_INV },
1170 { "mv", XXREN, CM_INV }, /* Synonym for rename */
1171 #endif /* NOFRILLS */
1173 { "news", XXNEW, CM_INV }, /* Display NEWS of new features */
1175 { "news", XXNOTAV, CM_INV },
1177 { "nolocal", XXNLCL, CM_INV }, /* Disable SET LINE / SET HOST */
1178 { "nopush", XXNPSH, CM_INV }, /* Disable PUSH command/features */
1180 { "noscroll", XXNSCR, CM_INV }, /* Disable scroll operations */
1183 { "o", XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */
1184 { "open", XXOPE, 0 }, /* OPEN file for reading or writing */
1186 { "open", XXOPE, CM_INV }, /* OPEN */
1189 { "options", XXOPTS,CM_INV|CM_HLP }, /* Options */
1191 { "orientation", XXORIE, 0 },
1193 { "output", XXOUT, 0 }, /* OUTPUT text to comm device */
1195 { "output", XXNOTAV, CM_INV },
1199 { "pad", XXPAD, CM_LOC }, /* X.3 PAD commands */
1204 { "passive", XXPASV, CM_INV }, /* (FTP) PASSIVE */
1208 { "patterns", XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */
1212 { "pause", XXPAU, 0 }, /* Sleep for specified interval */
1214 { "pause", XXNOTAV, CM_INV },
1217 { "pdial", XXPDIA, CM_LOC }, /* PDIAL (partial dial) */
1219 { "pdial", XXNOTAV, CM_INV|CM_LOC },
1223 { "ping", XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */
1225 { "ping", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
1227 #endif /* TCPSOCKET */
1230 { "pipe", XXPIPE, CM_PSH }, /* PIPE */
1232 { "pipe", XXNOTAV, CM_INV|CM_PSH }, /* PIPE */
1237 { "pop", XXEND, CM_INV }, /* Invisible synonym for END */
1240 { "print", XXPRI, 0 }, /* PRINT a file locally */
1241 #endif /* NOFRILLS */
1243 { "prompt", XXPROMP, CM_INV }, /* Go interactive (from script) */
1247 { "psend", XXPSEN, CM_INV }, /* PSEND */
1249 { "psend", XXNOTAV, CM_INV },
1250 #endif /* CK_RESEND */
1254 { "pty", XXPTY, CM_PSH }, /* PTY */
1256 { "pty", XXNOTAV, CM_INV|CM_PSH },
1260 { "pu", XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */
1264 { "purge", XXPURGE, 0 }, /* PURGE (real) */
1267 { "purge", XXPURGE, 0 }, /* PURGE (fake) */
1269 { "purge", XXNOTAV, CM_INV },
1271 #endif /* CKPURGE */
1274 { "push", XXSHE, CM_PSH }, /* PUSH command (like RUN, !) */
1276 { "push", XXNOTAV, CM_INV|CM_PSH },
1280 { "put", XXSEN, CM_INV }, /* PUT = SEND */
1283 { "pwd", XXPWD, 0 }, /* Print Working Directory */
1284 { "q", XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */
1287 { "query", XXRQUE,CM_INV }, /* (= REMOTE QUERY) */
1290 { "quit", XXQUI, 0 }, /* QUIT from program = EXIT */
1293 { "r", XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */
1297 { "rasg", XXRASG, CM_INV }, /* REMOTE ASSIGN */
1298 { "rassign", XXRASG, CM_INV }, /* ditto */
1299 { "rcd", XXRCWD, CM_INV }, /* REMOTE CD */
1300 { "rcdup", XXRCDUP,CM_INV }, /* REMOTE CD */
1301 { "rcopy", XXRCPY, CM_INV }, /* REMOTE COPY */
1302 { "rcwd", XXRCWD, CM_INV }, /* REMOTE CWD */
1303 { "rdelete", XXRDEL, CM_INV }, /* REMOTE DELETE */
1304 { "rdirectory", XXRDIR, CM_INV }, /* REMODE DIRECTORY */
1308 { "read", XXREA, 0 }, /* READ a line from a file */
1310 { "read", XXNOTAV, CM_INV },
1314 { "receive", XXREC, 0 }, /* RECEIVE files */
1318 { "red", XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */
1319 { "redi", XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */
1320 { "redial", XXRED, CM_LOC }, /* REDIAL last DIAL number */
1322 { "red", XXNOTAV, CM_INV|CM_LOC },
1323 { "redi", XXNOTAV, CM_INV|CM_LOC },
1324 { "redial", XXNOTAV, CM_INV|CM_LOC },
1330 { "redirect", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
1332 { "redirect", XXNOTAV, CM_INV|CM_PSH },
1336 { "redirect", XXFUN, CM_PSH }, /* REDIRECT */
1338 { "redirect", XXNOTAV, CM_INV|CM_PSH },
1341 #endif /* CK_REDIR */
1344 { "redo", XXREDO, CM_NOR }, /* REDO */
1346 { "redo", XXNOTAV, CM_INV },
1347 #endif /* CK_RECALL */
1351 { "reget", XXREGET, 0 }, /* REGET */
1353 { "reget", XXNOTAV, CM_INV },
1354 #endif /* CK_RESEND */
1358 { "reinput", XXREI, CM_INV }, /* REINPUT (from INPUT buffer) */
1360 { "reinput", XXNOTAV, CM_INV },
1365 { "rem", XXREM, CM_INV|CM_ABR },
1366 { "remo", XXREM, CM_INV|CM_ABR },
1368 { "remote", XXREM, 0 }, /* Send REMOTE command to server */
1372 { "remove", XXREMV,0 }, /* REMOVE (something from a list) */
1374 { "remove", XXNOTAV, CM_INV },
1379 { "rename", XXREN, 0 }, /* RENAME a local file */
1381 { "rename", XXNOTAV, CM_INV },
1382 #endif /* NORENAME */
1383 { "replay", XXTYP, CM_INV }, /* REPLAY (for now, just type) */
1384 #endif /* NOFRILLS */
1388 { "res", XXRSEN, CM_INV|CM_ABR }, /* RESEND */
1389 { "rese", XXRSEN, CM_INV|CM_ABR }, /* RESEND */
1390 { "resend", XXRSEN, 0 }, /* RESEND */
1392 { "res", XXNOTAV, CM_INV },
1393 { "rese", XXNOTAV, CM_INV },
1394 { "resend", XXNOTAV, CM_INV },
1395 #endif /* CK_RESEND */
1398 { "reset", XXRESET, CM_INV }, /* RESET */
1402 { "ret", XXRET, CM_INV|CM_ABR },
1404 #endif /* CK_RESEND */
1407 { "retrieve", XXRETR, CM_INV }, /* RETRIEVE */
1411 { "return", XXRET, 0 }, /* RETURN from a function */
1413 { "return", XXNOTAV, CM_INV },
1417 { "rexit", XXRXIT, CM_INV }, /* REMOTE EXIT */
1422 { "rexx", XXREXX, CM_PSH }, /* Execute a Rexx command */
1424 { "rexx", XXNOTAV, CM_INV|CM_PSH },
1426 #endif /* CK_REXX */
1429 { "rhelp", XXRHLP, CM_INV }, /* REMOTE HELP */
1430 { "rhost", XXRHOS, CM_INV }, /* REMOTE HOST */
1431 { "rkermit", XXRKER, CM_INV }, /* REMOTE KERMIT */
1435 { "rlogin", XXRLOG, CM_LOC }, /* Make an Rlogin connection */
1437 { "rlogin", XXNOTAV, CM_INV|CM_LOC },
1438 #endif /* TCPSOCKET */
1441 { "rm", XXDEL, CM_INV }, /* Invisible synonym for delete */
1442 #endif /* NOFRILLS */
1445 { "rmdir", XXRMDIR, 0 }, /* RMDIR */
1447 { "rmdir", XXNOTAV, CM_INV },
1448 #endif /* CK_MKDIR */
1451 { "rmkdir", XXRMKD, CM_INV }, /* REMOTE MKDIR */
1453 { "robust", XXROB, CM_INV },
1455 { "robust", XXNOTAV, CM_INV },
1457 { "rprint", XXRPRI, CM_INV }, /* REMOTE PRINT */
1458 { "rpwd", XXRPWD, CM_INV }, /* REMOTE PWD */
1459 { "rquery", XXRQUE, CM_INV }, /* REMOTE QUERY */
1463 { "rr", XXREDO, CM_INV|CM_NOR },
1464 #endif /* CK_RECALL */
1467 { "rrename", XXRREN, CM_INV }, /* REMOTE RENAME */
1468 { "rrmdir", XXRRMD, CM_INV }, /* REMOTE REMDIR */
1469 { "rset", XXRSET, CM_INV }, /* REMOTE SET */
1470 { "rspace", XXRSPA, CM_INV }, /* REMOTE SPACE */
1471 { "rtype", XXRTYP, CM_INV }, /* REMOTE TYPE */
1475 { "run", XXSHE, CM_PSH }, /* RUN a program or command */
1477 { "run", XXNOTAV, CM_INV|CM_PSH },
1481 { "rwho", XXRWHO, CM_INV }, /* REMOTE WHO */
1482 { "s", XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */
1487 { "save", XXSAVE, 0 }, /* SAVE something */
1489 { "save", XXSAVE, CM_INV },
1492 { "save", XXNOTAV, CM_INV },
1493 #endif /* NOSETKEY */
1496 { "sc", XXLOGI, CM_INV|CM_ABR|CM_LOC },
1497 { "scr", XXLOGI, CM_INV|CM_ABR|CM_LOC },
1498 #endif /* NOSCRIPT */
1499 { "screen", XXSCRN, 0 }, /* SCREEN actions */
1501 { "script", XXLOGI, CM_LOC }, /* Expect-Send-style script line */
1503 { "script", XXNOTAV, CM_INV|CM_LOC },
1504 #endif /* NOSCRIPT */
1506 { "search", XXGREP,CM_INV }, /* Synonym for GREP and FIND */
1509 { "send", XXSEN, 0 }, /* Send (a) file(s) */
1511 { "server", XXSER, 0 }, /* Be a SERVER */
1513 { "server", XXNOTAV, CM_INV },
1514 #endif /* NOSERVER */
1517 { "set", XXSET, 0 }, /* SET parameters */
1521 { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */
1525 { "sftp", XXSFTP, 0 }, /* SFTP */
1526 #endif /* SFTP_BUILTIN */
1529 { "sh", XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */
1531 { "shift", XXSHIFT, 0 }, /* SHIFT args */
1533 { "shift", XXNOTAV, CM_INV },
1537 { "show", XXSHO, 0 }, /* SHOW parameters */
1539 { "show", XXNOTAV, CM_INV },
1543 { "site", XXSITE, CM_INV }, /* (FTP) SITE */
1547 { "skermit", XXSKRM, 0 }, /* SKERMIT */
1548 #endif /* SSHBUILTIN */
1552 { "sleep", XXPAU, CM_INV }, /* SLEEP for specified interval */
1553 #endif /* NOFRILLS */
1557 { "sort", XXSORT, CM_INV }, /* (see ARRAY) */
1559 { "sort", XXNOTAV, CM_INV },
1564 { "sp", XXSPA, CM_INV|CM_ABR },
1565 { "spa", XXSPA, CM_INV|CM_ABR },
1566 #endif /* NOFRILLS */
1567 { "space", XXSPA, 0 }, /* Show available disk SPACE */
1572 { "spawn", XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
1574 { "spawn", XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
1576 #endif /* NOFRILLS */
1579 { "ssh", XXSSH, 0 },
1583 { "sta", XXSTA, CM_INV|CM_ABR },
1584 { "stat", XXSTA, CM_INV|CM_ABR },
1585 { "statistics", XXSTA, 0 }, /* Display file transfer stats */
1588 { "status", XXSTATUS,0 }, /* Show status of previous command */
1591 { "stop", XXSTO, 0 }, /* STOP all take files and macros */
1592 { "succeed", XXSUCC, CM_INV }, /* SUCCEED */
1594 { "stop", XXNOTAV, CM_INV },
1595 { "succeed", XXNOTAV, CM_INV },
1599 { "SUPPORT", XXBUG, 0 }, /* Tech support instructions */
1601 { "support", XXNOTAV, CM_INV },
1602 #endif /* NOFRILLS */
1605 { "suspend", XXSUS, CM_PSH }, /* SUSPEND C-Kermit (UNIX only) */
1607 { "suspend", XXNOTAV, CM_INV|CM_PSH },
1611 { "switch", XXSWIT, 0 }, /* SWITCH */
1613 { "switch", XXNOTAV, CM_INV },
1617 { "ta", XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */
1618 #endif /* CK_TAPI */
1621 { "tail", XXTAIL, 0 }, /* Display end of a local file */
1622 #endif /* NOFRILLS */
1624 { "take", XXTAK, 0 }, /* TAKE commands from a file */
1627 { "tapi", XXTAPI, CM_LOC }, /* Microsoft TAPI commands */
1629 { "tapi", XXNOTAV, CM_INV|CM_LOC },
1630 #endif /* CK_TAPI */
1634 { "tel", XXTEL, CM_INV|CM_ABR|CM_LOC },
1635 { "telnet", XXTEL, CM_LOC }, /* TELNET (TCP/IP only) */
1636 { "telopt", XXTELOP, CM_INV }, /* TELOPT (ditto) */
1638 { "tel", XXNOTAV, CM_INV|CM_LOC },
1639 { "telnet", XXNOTAV, CM_INV|CM_LOC },
1640 { "telopt", XXNOTAV, CM_INV },
1641 #endif /* TCPSOCKET */
1643 { "terminal", XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */
1645 { "terminal", XXTERM, CM_INV },
1647 #endif /* NOFRILLS */
1649 { "text", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */
1653 { "trace", XXTRACE, 0 }, /* TRACE */
1655 { "trace", XXNOTAV, CM_INV },
1659 { "translate", XXXLA, 0 }, /* TRANSLATE local file char sets */
1661 { "translate", XXNOTAV, CM_INV },
1662 #endif /* NOCSETS */
1665 { "transmit", XXTRA, 0 }, /* Send (upload) a file, no protocol */
1667 { "transmit", XXNOTAV, CM_INV },
1671 { "type", XXTYP, 0 }, /* Display a local file */
1672 #endif /* NOFRILLS */
1675 { "undcl", XXUNDCL, CM_INV },
1676 { "undeclare", XXUNDCL, 0 }, /* UNDECLARE an array */
1677 { "undefine", XXUNDEF, 0 }, /* UNDEFINE a variable or macro */
1679 { "undcl", XXNOTAV, CM_INV },
1680 { "undeclare", XXNOTAV, CM_INV },
1681 { "undefine", XXNOTAV, CM_INV },
1685 { "user", XXUSER, CM_INV }, /* (FTP) USER */
1688 { "version", XXVER, 0 }, /* VERSION-number display */
1691 { "viewonly", XXVIEW, CM_LOC }, /* VIEWONLY Terminal Mode */
1694 { "void", XXVOID, 0 }, /* VOID */
1697 { "wait", XXWAI, 0 }, /* WAIT */
1699 { "wait", XXNOTAV, CM_INV },
1702 { "wermit", XXKERMI, CM_INV },
1705 { "where", XXWHERE, 0 }, /* WHERE (did my file go?) */
1709 { "while", XXWHI, 0 }, /* WHILE loop */
1711 { "while", XXNOTAV, CM_INV },
1717 { "who", XXWHO, CM_PSH }, /* WHO's logged in? */
1718 #endif /* NOFRILLS */
1723 { "wildcards", XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */
1727 { "wr", XXWRI, CM_INV|CM_ABR },
1728 { "wri", XXWRI, CM_INV|CM_ABR },
1729 { "writ", XXWRI, CM_INV|CM_ABR },
1730 { "write", XXWRI, 0 }, /* WRITE characters to a file */
1731 { "write-line", XXWRL, CM_INV }, /* WRITE a line to a file */
1732 { "writeln", XXWRL, CM_INV }, /* Pascalisch synonym for write-line */
1734 { "wr", XXNOTAV, CM_INV },
1735 { "wri", XXNOTAV, CM_INV },
1736 { "writ", XXNOTAV, CM_INV },
1737 { "write", XXNOTAV, CM_INV },
1738 { "write-line", XXNOTAV, CM_INV },
1739 { "writeln", XXNOTAV, CM_INV },
1743 { "xecho", XXXECH,0 }, /* XECHO */
1744 #endif /* NOFRILLS */
1747 { "xif", XXIFX, CM_INV }, /* Extended IF command (obsolete) */
1749 { "xif", XXNOTAV, CM_INV },
1753 { "xlate", XXXLA, CM_INV }, /* Synonym for TRANSLATE */
1755 { "xlate", XXNOTAV, CM_INV },
1756 #endif /* NOCSETS */
1759 { "xmit", XXTRA, CM_INV }, /* Synonym for TRANSMIT */
1761 { "xmit", XXNOTAV, CM_INV },
1766 { "z", XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */
1768 { "z", XXNOTAV, CM_INV|CM_PSH },
1773 { "{", XXMACRO, CM_INV }, /* Immediate macro */
1777 int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1;
1779 /* NOTE: Tokens must also be entered above into cmdtab[]. */
1783 '!', /* Shell escape */
1787 '(', /* S-Expression */
1788 '.', /* Assignment */
1797 #endif /* CK_REDIR */
1798 '@', /* DCL escape */
1801 '^', /* Command recall */
1802 #endif /* CK_RECALL */
1804 '{', /* Immediate macro */
1806 '\0' /* End of this string */
1808 int xxdot = 0; /* Used with "." token */
1810 struct keytab yesno[] = { /* Yes/No keyword table */
1815 int nyesno = (sizeof(yesno) / sizeof(struct keytab));
1817 /* Save keyword table */
1819 struct keytab savtab[] = {
1821 { "command", XSCMD, 0 },
1824 { "command", XSCMD, 0 },
1825 #endif /* CK_RECALL */
1828 { "keymap", XSKEY, 0 },
1829 #endif /* NOSETKEY */
1831 { "terminal", XSTERM, 0 },
1835 int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1;
1837 /* Parameter keyword table */
1839 struct keytab prmtab[] = {
1840 { "alarm", XYALRM, 0 },
1841 #ifdef COMMENT /* SET ANSWER not implemented yet */
1843 { "answer", XYANSWER,0 },
1845 #endif /* COMMENT */
1846 { "ask-timer", XYTIMER, 0 },
1848 { "attributes", XYATTR, 0 },
1850 #ifdef CK_AUTHENTICATION
1851 { "authentication", XYAUTH, 0 },
1852 #else /* CK_AUTHENTICATION */
1854 { "authentication", XYAUTH, 0 },
1856 #endif /* CK_AUTHENTICATION */
1857 { "b", XYBACK, CM_INV|CM_ABR|CM_PSH },
1858 { "ba", XYBACK, CM_INV|CM_ABR|CM_PSH },
1860 { "background", XYBACK, CM_INV|CM_PSH },
1861 { "batch", XYBACK, CM_PSH },
1863 { "background", XYBACK, CM_PSH },
1864 { "batch", XYBACK, CM_INV|CM_PSH },
1867 { "baud", XYSPEE, CM_INV|CM_LOC },
1868 #endif /* NOLOCAL */
1869 { "bell", XYBELL, 0 },
1871 { "block-check", XYCHKT, 0 },
1875 { "bprinter", XYBDCP, CM_INV },
1879 { "browser", XYBROWSE,CM_PSH|CM_LOC },
1880 #endif /* BROWSER */
1883 { "buffers", XYBUF, 0 },
1884 #endif /* DYNAMIC */
1888 { "carrier-watch", XYCARR, CM_LOC },
1890 #endif /* NOLOCAL */
1892 { "case", XYCASE, 0 },
1896 { "cl", XYCLEAR, CM_INV|CM_ABR },
1897 { "cle", XYCLEAR, CM_INV|CM_ABR },
1898 { "clea", XYCLEAR, CM_INV|CM_ABR },
1899 { "clear", XYCLEAR, CM_INV|CM_ABR },
1900 { "clear-channel", XYCLEAR, 0 },
1901 { "clearchannel", XYCLEAR, CM_INV },
1904 { "close-on-disconnect", XYDISC, CM_INV|CM_LOC },
1905 #endif /* NOLOCAL */
1906 { "cmd", XYCMD, CM_INV },
1907 { "command", XYCMD, 0 },
1909 { "con", XYQCTL, CM_INV|CM_ABR },
1910 #endif /* CK_SPEED */
1911 { "console", XYCMD, CM_INV },
1913 { "control-character",XYQCTL, 0 },
1914 #endif /* CK_SPEED */
1916 { "count", XYCOUN, 0 },
1919 { "d", XYDELA, CM_INV|CM_ABR },
1920 { "de", XYDELA, CM_INV|CM_ABR },
1922 { "debug", XYDEBU, 0 },
1924 { "default", XYDFLT, 0 },
1927 { "default", XYDFLT, CM_INV },
1931 { "delay", XYDELA, 0 },
1932 { "destination", XYDEST, 0 },
1935 { "di", XYDIAL, CM_INV|CM_ABR|CM_LOC },
1936 { "dia", XYDIAL, CM_INV|CM_ABR|CM_LOC },
1937 { "dial", XYDIAL, CM_LOC },
1940 { "dialer", XYDLR, CM_INV },
1943 { "disconnect", XYDISC, CM_LOC },
1944 { "duplex", XYDUPL, CM_LOC },
1945 #endif /* NOLOCAL */
1948 { "editor", XYEDIT, CM_PSH },
1949 #endif /* NOFRILLS */
1952 { "eof", XYEOF, CM_INV },
1953 #endif /* CK_CTRLZ */
1955 { "escape-character", XYESC, CM_LOC },
1956 #endif /* NOLOCAL */
1958 { "evaluate", XYEVAL, CM_INV },
1960 { "exit", XYEXIT, 0 },
1962 { "f-ack-bug", XYFACKB, CM_INV },
1963 { "f-ack-path", XYFACKP, CM_INV },
1965 { "file", XYFILE, 0 },
1966 { "fl", XYFLOW, CM_INV|CM_ABR },
1968 { "flag", XYFLAG, 0 },
1973 { "ft", XYFTPX, CM_INV|CM_ABR },
1974 { "ftp", XYFTPX, 0 },
1977 #endif /* TCPSOCKET */
1979 { "ftp-client", XYFTP, CM_PSH },
1980 #endif /* BROWSER */
1981 { "flow-control", XYFLOW, 0 },
1983 { "function", XYFUNC, 0 },
1986 { "get-put-remote", XYGPR, 0 },
1989 { "gui", XYGUI, 0 },
1991 { "handshake", XYHAND, 0 },
1992 { "hints", XYHINTS, 0 },
1994 { "host", XYHOST, CM_LOC },
1995 #endif /* NETCONN */
1997 { "i", XYINPU, CM_INV|CM_ABR },
2000 { "iks", XYIKS, 0 },
2002 { "iks", XYIKS, CM_INV },
2005 { "in", XYINPU, CM_INV|CM_ABR },
2008 { "incomplete", XYIFD, CM_INV },
2011 { "input", XYINPU, 0 },
2014 { "key", XYKEY, 0 },
2015 #endif /* NOSETKEY */
2016 { "l", XYLINE, CM_INV|CM_ABR },
2018 { "language", XYLANG, 0 },
2019 #endif /* NOCSETS */
2021 { "line", XYLINE, CM_LOC },
2022 { "local-echo", XYLCLE, CM_INV|CM_LOC },
2023 #endif /* NOLOCAL */
2025 { "locus", XYLOCUS, 0 },
2028 { "login", XYLOGIN, CM_LOC },
2031 { "macro", XYMACR, 0 },
2033 { "match", XYMATCH, 0 },
2036 { "messages", XYMSGS, 0 },
2038 #endif /* COMMENT */
2040 { "modem", XYMODM, CM_LOC },
2044 { "mouse", XYMOUSE, 0 },
2045 #endif /* OS2MOUSE */
2046 #endif /* NOLOCAL */
2048 { "mskermit", XYMSK, 0 },
2051 { "network", XYNET, CM_LOC },
2052 #endif /* NETCONN */
2054 { "output", XYOUTP, 0 },
2056 { "options", XYOPTS, 0 },
2057 { "pause", XYSLEEP, CM_INV },
2060 { "pad", XYPAD, CM_LOC },
2063 { "parity", XYPARI, 0 },
2066 { "port", XYLINE, CM_LOC },
2068 { "port", XYLINE, CM_INV|CM_LOC },
2070 #endif /* NOLOCAL */
2072 { "pr", XYPROM, CM_INV|CM_ABR },
2073 { "printer", XYPRTR, 0 },
2074 #endif /* NOFRILLS */
2076 { "priority", XYPRTY, 0 },
2079 { "prefixing", XYPREFIX, 0 },
2080 #endif /* CK_SPEED */
2082 { "prompt", XYPROM, 0 },
2083 #endif /* NOFRILLS */
2085 { "protocol", XYPROTO, 0 },
2087 { "q", XYQUIE, CM_INV|CM_ABR },
2089 { "q8flag", XYQ8FLG, CM_INV },
2092 { "qnx-port-lock", XYQNXPL, 0 },
2094 { "qnx-port-lock", XYQNXPL, CM_INV },
2096 { "quiet", XYQUIE, 0 },
2098 { "rec", XYRECV, CM_INV|CM_ABR },
2099 { "receive", XYRECV, 0 },
2100 { "recv", XYRECV, CM_INV },
2102 { "reliable", XYRELY, 0 },
2104 { "repeat", XYREPT, 0 },
2105 { "retry-limit", XYRETR, 0 },
2108 { "root", XYROOT, 0 },
2111 { "script", XYSCRI, CM_LOC },
2112 #endif /* NOSCRIPT */
2114 { "send", XYSEND, 0 },
2117 { "ser", XYSERV, CM_INV|CM_ABR },
2118 #endif /* NOSERVER */
2120 { "serial", XYSERIAL,CM_LOC },
2121 #endif /* NOLOCAL */
2123 { "server", XYSERV, 0 },
2124 #endif /* NOSERVER */
2127 { "session-l", XYSESS, CM_INV|CM_ABR },
2128 #endif /* NOLOCAL */
2129 { "session-limit", XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */
2130 #endif /* SESLIMIT */
2133 { "session-log", XYSESS, CM_LOC },
2134 #endif /* NOLOCAL */
2138 { "sexpression", XYSEXP, CM_INV },
2142 { "sleep", XYSLEEP, 0 },
2145 { "speed", XYSPEE, CM_LOC },
2146 #endif /* NOLOCAL */
2149 { "ssh", XYSSH, 0 },
2153 { "startup-file", XYSTARTUP, CM_INV },
2158 { "stop-bits", XYSTOP, CM_LOC },
2161 { "stop-bits", XYSTOP, CM_LOC },
2162 #endif /* TN_COMPORT */
2163 #endif /* HWPARITY */
2164 #endif /* NOLOCAL */
2168 { "streaming", XYSTREAM, 0 },
2169 #endif /* STREAMING */
2173 { "suspend", XYSUSP, CM_PSH },
2176 { "syslog", XYSYSL, CM_INV },
2177 #endif /* CKSYSLOG */
2178 { "take", XYTAKE, 0 },
2181 { "tapi", XYTAPI, CM_LOC },
2182 #endif /* CK_TAPI */
2186 { "tcp", XYTCP, CM_LOC },
2187 #endif /* TCPSOCKET */
2188 #endif /* NOTCPOPTS */
2191 { "tel", XYTEL, CM_INV|CM_ABR },
2192 { "telnet", XYTEL, 0 },
2193 { "telopt", XYTELOP, 0 },
2197 { "temp-directory", XYTMPDIR,0 },
2201 { "terminal", XYTERM, CM_LOC },
2202 #endif /* NOLOCAL */
2205 { "title", XYTITLE, CM_LOC },
2208 { "transaction-log", XYTLOG, 0 },
2211 { "transfer", XYXFER, 0 },
2214 { "transmit", XYXMIT, 0 },
2218 { "unknown-char-set", XYUNCS, 0 },
2219 #endif /* NOCSETS */
2221 { "wait", XYSLEEP, CM_INV },
2224 { "wildcard-expansion", XYWILD, 0 },
2228 { "w", XYWIND, CM_INV|CM_ABR },
2229 { "wi", XYWIND, CM_INV|CM_ABR },
2230 { "win", XYWIND, CM_INV|CM_ABR },
2232 { "window-size", XYWIND, 0 },
2234 { "win95", XYWIN95, 0 },
2237 { "x.25", XYX25, CM_LOC },
2238 { "x25", XYX25, CM_INV|CM_LOC },
2240 { "xfer", XYXFER, CM_INV },
2242 { "xmit", XYXMIT, CM_INV },
2246 int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */
2248 struct keytab scntab[] = { /* Screen commands */
2249 { "clear", SCN_CLR, 0 },
2250 { "cleol", SCN_CLE, 0 },
2251 { "move-to", SCN_MOV, 0 }
2253 int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */
2255 #ifdef ANYSSH /* SSH command table */
2257 int ssh_pf_lcl_n = 0,
2259 struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */
2260 struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */
2261 extern char * ssh_hst, * ssh_cmd, * ssh_prt;
2262 extern int ssh_ver, ssh_xfw;
2263 char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL,
2264 * ssh_tmpstr = NULL;
2267 sshk_type = SSHKT_2D, /* SSH KEY CREATE /TYPE:x */
2268 sshk_bits = 1024, /* SSH KEY CREATE /BITS:n */
2269 sshk_din = SKDF_OSSH, /* SSH KEY DISPLAY /IN-FORMAT: */
2270 sshk_dout = SKDF_OSSH; /* SSH KEY DISPLAY /OUT-FORMAT: */
2273 * sshk1_comment = NULL, /* SSH V1 COMMENT */
2274 * sshkp_old = NULL, /* Old key passphrase */
2275 * sshkp_new = NULL, /* New key passphrase */
2276 * sshkc_pass = NULL, /* KEY CREATE /PASS:xxx */
2277 * sshkc_comm = NULL, /* KEY CREATE /V1-RSA-COMMENT:xxx */
2278 * sshd_file = NULL, /* DISPLAY file */
2279 * sshk_file = NULL; /* SSH CREATE KEY file */
2281 static struct keytab sshclr[] = {
2282 { "local-port-forward", SSHC_LPF, 0 },
2283 { "remote-port-forward", SSHC_RPF, 0 },
2286 static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1;
2288 struct keytab sshopnsw[] = {
2289 { "/command", SSHSW_CMD, CM_ARG },
2290 { "/password", SSHSW_PWD, CM_ARG },
2291 { "/subsystem", SSHSW_SUB, CM_ARG },
2292 { "/user", SSHSW_USR, CM_ARG },
2293 { "/version", SSHSW_VER, CM_ARG },
2294 { "/x11-forwarding", SSHSW_X11, CM_ARG },
2297 int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1;
2299 static struct keytab sshkwtab[] = {
2300 { "add", XSSH_ADD, 0 },
2301 { "agent", XSSH_AGT, 0 },
2302 { "clear", XSSH_CLR, 0 },
2303 { "forward-local-port", XSSH_FLP, CM_INV },
2304 { "forward-remote-port", XSSH_FRP, CM_INV },
2305 { "key", XSSH_KEY, 0 },
2306 { "open", XSSH_OPN, 0 },
2307 { "v2", XSSH_V2, 0 },
2310 static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1;
2312 static struct keytab ssh2tab[] = {
2313 { "rekey", XSSH2_RKE, 0 },
2316 static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab));
2318 static struct keytab addfwd[] = { /* SET SSH ADD command table */
2319 { "local-port-forward", SSHF_LCL, 0 },
2320 { "remote-port-forward", SSHF_RMT, 0 },
2323 static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
2325 static struct keytab sshagent[] = { /* SET SSH AGENT command table */
2326 { "add", SSHA_ADD, 0 },
2327 { "delete", SSHA_DEL, 0 },
2328 { "list", SSHA_LST, 0 },
2331 static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1;
2333 static struct keytab sshagtsw[] = { /* SET SSH AGENT LIST switch table */
2334 { "/fingerprint", SSHASW_FP, 0 },
2337 static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1;
2339 static struct keytab sshkey[] = { /* SET SSH KEY command table */
2340 { "change-passphrase", SSHK_PASS, 0 },
2341 { "create", SSHK_CREA, 0 },
2342 { "display", SSHK_DISP, 0 },
2343 { "v1", SSHK_V1, 0 },
2346 static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1;
2348 static struct keytab sshkv1[] = { /* SET SSH KEY V1 command table */
2349 { "set-comment", 1, 0 }
2352 static struct keytab sshkpsw[] = { /* SET SSH KEY PASSPHRASE table */
2353 { "/new-passphrase", 2, CM_ARG },
2354 { "/old-passphrase", 1, CM_ARG }
2357 static struct keytab sshkcrea[] = { /* SSH KEY CREATE table */
2358 { "/bits", SSHKC_BI, CM_ARG },
2359 { "/passphrase", SSHKC_PP, CM_ARG },
2360 { "/type", SSHKC_TY, CM_ARG },
2361 { "/v1-rsa-comment", SSHKC_1R, CM_ARG }
2363 static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab));
2365 static struct keytab sshkcty[] = { /* SSH KEY CREATE /TYPE:xxx */
2366 { "srp", SSHKT_SRP, 0 },
2367 { "v1-rsa", SSHKT_1R, 0 },
2368 { "v2-dsa", SSHKT_2D, 0 },
2369 { "v2-rsa", SSHKT_2R, 0 }
2371 static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab));
2373 static struct keytab sshdswi[] = { /* SET SSH KEY DISPLAY /switches */
2374 { "/format", SSHKD_OUT, CM_ARG }
2376 static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab));
2379 static struct keytab sshdifmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */
2380 { "openssh", SKDF_OSSH, 0 },
2381 { "ssh.com", SKDF_SSHC, 0 }
2383 static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab));
2384 #endif /* COMMENT */
2386 static struct keytab sshdofmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */
2387 { "fingerprint", SKDF_FING, 0 },
2388 { "ietf", SKDF_IETF, 0 },
2389 { "openssh", SKDF_OSSH, 0 },
2390 { "ssh.com", SKDF_SSHC, 0 }
2392 static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab));
2394 static struct keytab sshkermit[] = { /* SKERMIT */
2395 { "open", SKRM_OPN, 0 }
2397 static int nsshkermit = (sizeof(sshkermit) / sizeof(struct keytab));
2399 struct keytab sshkrmopnsw[] = {
2400 { "/password", SSHSW_PWD, CM_ARG },
2401 { "/user", SSHSW_USR, CM_ARG },
2402 { "/version", SSHSW_VER, CM_ARG },
2405 int nsshkrmopnsw = (sizeof(sshkrmopnsw) / sizeof(struct keytab)) - 1;
2406 #endif /* SSHBUILTIN */
2409 static struct keytab sftpkwtab[] = { /* SFTP */
2410 { "cd", SFTP_CD, 0 },
2411 { "chgrp", SFTP_CHGRP, 0 },
2412 { "chmod", SFTP_CHMOD, 0 },
2413 { "chown", SFTP_CHOWN, 0 },
2414 { "delete", SFTP_RM, 0 },
2415 { "dir", SFTP_DIR, 0 },
2416 { "get", SFTP_GET, 0 },
2417 { "mkdir", SFTP_MKDIR, 0 },
2418 { "open", SFTP_OPN, 0 },
2419 { "put", SFTP_PUT, 0 },
2420 { "pwd", SFTP_PWD, 0 },
2421 { "rename", SFTP_REN, 0 },
2422 { "rm", SFTP_RM, CM_INV },
2423 { "rmdir", SFTP_RMDIR, 0 },
2424 { "symlink", SFTP_LINK, 0 },
2425 { "version", SFTP_VER, 0 }
2427 static int nsftpkwtab = (sizeof(sftpkwtab) / sizeof(struct keytab));
2428 #endif /* SFTP_BUILTIN */
2432 struct keytab netkey[] = { /* SET NETWORK table */
2433 { "directory", XYNET_D, 0 },
2434 { "type", XYNET_T, 0 }
2436 int nnetkey = (sizeof(netkey) / sizeof(struct keytab));
2438 struct keytab netcmd[] = {
2440 These are the network types.
2443 { "command", NET_CMD, CM_INV }, /* Command */
2446 #ifdef DECNET /* DECnet / PATHWORKS */
2447 { "decnet", NET_DEC, 0 },
2451 { "dll", NET_DLL, CM_INV }, /* DLL to be loaded */
2455 { "file", NET_FILE, CM_INV }, /* FILE (real crude) */
2456 #endif /* NETFILE */
2458 #ifdef NPIPE /* Named Pipes */
2459 { "named-pipe", NET_PIPE, 0 },
2463 { "netbios", NET_BIOS, 0 }, /* NETBIOS */
2464 #endif /* CK_NETBIOS */
2466 #ifdef DECNET /* DECnet / PATHWORKS (alias) */
2467 { "pathworks", NET_DEC, CM_INV },
2471 { "pipe", NET_CMD, 0 }, /* Pipe */
2475 { "pseudoterminal",NET_PTY, 0 }, /* Pseudoterminal */
2479 { "pty", NET_PTY, CM_INV }, /* Inv syn for pseudoterm */
2483 { "ssh", NET_SSH, 0 },
2484 #endif /* SSHBUILTIN */
2487 { "superlat", NET_SLAT, 0 }, /* Meridian Technologies' SuperLAT */
2488 #endif /* SUPERLAT */
2490 #ifdef TCPSOCKET /* TCP/IP sockets library */
2491 { "tcp/ip", NET_TCPB, 0 },
2492 #endif /* TCPSOCKET */
2494 { "tes32", NET_SLAT, 0 }, /* Emulux TES32 */
2495 #endif /* SUPERLAT */
2496 #ifdef ANYX25 /* X.25 */
2498 { "x", NET_SX25, CM_INV|CM_ABR },
2499 { "x.25", NET_SX25, 0 },
2500 { "x25", NET_SX25, CM_INV },
2503 { "x", NET_VX25, CM_INV|CM_ABR },
2504 { "x.25", NET_VX25, 0 },
2505 { "x25", NET_VX25, CM_INV },
2506 #endif /* STRATUSX25 */
2509 { "x", NET_IX25, CM_INV|CM_ABR },
2510 { "x.25", NET_IX25, CM_INV },
2511 { "x25", NET_IX25, CM_INV },
2514 { "x", NET_IX25, CM_INV|CM_ABR },
2515 { "x.25", NET_IX25, 0 },
2516 { "x25", NET_IX25, CM_INV },
2521 int nnets = (sizeof(netcmd) / sizeof(struct keytab));
2528 struct keytab tcpopt[] = {
2529 { "address", XYTCP_ADDRESS, 0 },
2531 { "dns-service-records", XYTCP_DNS_SRV, 0 },
2532 #endif /* CK_DNS_SRV */
2534 { "dontroute", XYTCP_DONTROUTE, 0 },
2535 #endif /* SO_DONTROUTE */
2537 { "http-proxy", XYTCP_HTTP_PROXY, 0 },
2540 { "keepalive", XYTCP_KEEPALIVE, 0 },
2541 #endif /* SO_KEEPALIVE */
2543 { "linger", XYTCP_LINGER, 0 },
2544 #endif /* SO_LINGER */
2546 { "nagle", XYTCP_NAGLE, CM_INV },
2547 { "nodelay", XYTCP_NODELAY, 0 },
2548 #endif /* TCP_NODELAY */
2549 { "reverse-dns-lookup", XYTCP_RDNS, 0 },
2551 { "recvbuf", XYTCP_RECVBUF, 0 },
2552 #endif /* SO_RCVBUF */
2554 { "sendbuf", XYTCP_SENDBUF, 0 },
2555 #endif /* SO_SNDBUF */
2558 { "socks-server", XYTCP_SOCKS_SVR, 0 },
2559 #endif /* CK_SOCKS */
2563 { "ucx-port-bug", XYTCP_UCX, 0 },
2564 #endif /* DEC_TCPIP */
2568 int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab));
2569 #endif /* TCPSOCKET */
2570 #endif /* NOTCPOPTS */
2571 #endif /* NETCONN */
2574 /* K95 Manual Chapter Table -- Keep these two tables in sync! */
2576 static char * linktbl[] = { /* Internal links in k95.htm */
2579 "#install", /* 02 */
2582 "#entries", /* 05 */
2583 "#command", /* 06 */
2584 "#terminal", /* 07 */
2585 "#transfer", /* 08 */
2586 "#hostmode" /* 09 */
2589 static struct keytab chaptbl[] = {
2590 { "Command-Screen", 6, 0 },
2591 { "Contents", 0, 0 },
2592 { "Dialer-Entries", 5, 0 },
2593 { "File-Transfer", 8, 0 },
2594 { "Getting-Started", 3, 0 },
2595 { "Host-Mode", 9, 0 },
2596 { "Installation", 2, 0 },
2597 { "Terminal-Emulation", 7, 0 },
2598 { "Using-The-Dialer", 4, 0 },
2599 { "What-Is-K95", 1, 0 },
2602 static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1);
2606 /* Remote Command Table */
2608 struct keytab remcmd[] = {
2610 { "as", XZASG, CM_INV|CM_ABR },
2611 { "asg", XZASG, CM_INV },
2612 { "assign", XZASG, 0 },
2615 { "cdup", XZCDU, CM_INV },
2616 { "copy", XZCPY, 0 },
2617 { "cwd", XZCWD, CM_INV },
2618 { "delete", XZDEL, 0 },
2619 { "directory", XZDIR, 0 },
2620 { "e", XZXIT, CM_ABR|CM_INV },
2621 { "erase", XZDEL, CM_INV },
2622 { "exit", XZXIT, 0 },
2623 { "help", XZHLP, 0 },
2625 { "host", XZHOS, 0 },
2628 { "kermit", XZKER, 0 },
2629 { "l", XZLGI, CM_ABR|CM_INV },
2630 { "lo", XZLGI, CM_ABR|CM_INV },
2631 { "log", XZLGI, CM_ABR|CM_INV },
2632 { "login", XZLGI, 0 },
2633 { "logout", XZLGO, 0 },
2634 { "mkdir", XZMKD, 0 },
2635 { "print", XZPRI, 0 },
2636 #endif /* NOFRILLS */
2637 { "pwd", XZPWD, 0 },
2639 { "query", XZQUE, 0 },
2641 { "rename", XZREN, 0 },
2642 { "rmdir", XZRMD, 0 },
2643 { "set", XZSET, 0 },
2644 { "space", XZSPA, 0 },
2646 { "type", XZTYP, 0 },
2647 { "who", XZWHO, 0 },
2648 #endif /* NOFRILLS */
2651 int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1;
2654 struct keytab logtab[] = {
2656 { "connections", LOGM, CM_INV },
2658 #endif /* CKLOGDIAL */
2660 { "debugging", LOGD, 0 },
2662 { "packets", LOGP, 0 },
2664 { "session", LOGS, 0 },
2665 #endif /* NOLOCAL */
2667 { "transactions", LOGT, 0 },
2671 int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1;
2673 struct keytab writab[] = {
2675 { "append-file", LOGW, CM_INV },
2677 { "debug-log", LOGD, 0 },
2678 { "error", LOGE, 0 },
2680 { "file", LOGW, 0 },
2682 { "packet-log", LOGP, 0 },
2683 { "screen", LOGX, 0 },
2685 { "session-log", LOGS, 0 },
2686 #endif /* NOLOCAL */
2687 { "sys$output", LOGX, CM_INV },
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 }
2702 int nwri = (sizeof(writab) / sizeof(struct keytab));
2704 #ifdef COMMENT /* INPUT switches not used yet... */
2705 static struct keytab inswtab[] = {
2707 { "/assign", IN_ASG, CM_ARG },
2708 #endif /* COMMENT */
2709 { "/autodownload", IN_ADL, CM_ARG },
2710 { "/case", IN_CAS, CM_ARG },
2711 { "/echo", IN_ECH, CM_ARG },
2712 { "/interrupts", IN_NOI, CM_ARG },
2713 { "/silence", IN_SIL, CM_ARG },
2715 { "/pattern", IN_PAT, CM_ARG },
2716 #endif /* COMMENT */
2719 static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1;
2720 #endif /* COMMENT */
2722 static struct keytab clrtab[] = { /* Keywords for CLEAR command */
2724 { "alarm", CLR_ALR, 0 },
2726 { "apc", CLR_APC, 0 },
2729 { "binary-patterns", CLR_BIN, 0 },
2730 #endif /* PATTERNS */
2731 { "both", CLR_DEV|CLR_INP, CM_INV },
2734 { "command-screen", CLR_CMD, 0 },
2737 { "device", CLR_DEV, CM_INV|CM_ABR },
2738 { "device-and-input", CLR_DEV|CLR_INP, 0 },
2740 { "device-buffer", CLR_DEV, 0 },
2742 { "dial-status", CLR_DIA, 0 },
2745 { "input-buffer", CLR_INP, 0 },
2747 { "keyboard-buffer", CLR_KBD, 0 },
2748 { "send-list", CLR_SFL, 0 },
2750 { "scr", CLR_SCL, CM_INV|CM_ABR },
2752 { "screen", CLR_SCR, 0 },
2754 { "scrollback", CLR_SCL, CM_INV },
2755 { "terminal-screen", CLR_TRM, 0 },
2758 { "text-patterns", CLR_TXT, 0 },
2759 #endif /* PATTERNS */
2762 int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1;
2764 struct keytab clstab[] = { /* Keywords for CLOSE command */
2766 { "!read", LOGR, CM_INV },
2767 { "!write", LOGW, CM_INV },
2772 { "append-file", LOGW, CM_INV },
2775 { "connection", 9999, 0 },
2776 #endif /* NOLOCAL */
2778 { "cx-log", LOGM, 0 },
2779 #endif /* CKLOGDIAL */
2781 { "debug-log", LOGD, 0 },
2783 { "host", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
2784 { "line", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
2785 { "p", LOGP, CM_INV|CM_ABR },
2786 { "packet-log", LOGP, 0 },
2787 { "port", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
2789 { "read-file", LOGR, 0 },
2792 { "session-log", LOGS, 0 },
2793 #endif /* NOLOCAL */
2795 { "t", LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
2796 { "tr", LOGT, CM_ABR|CM_INV }, /* the book... */
2797 { "tra", LOGT, CM_ABR|CM_INV },
2798 { "tran", LOGT, CM_ABR|CM_INV },
2799 { "trans", LOGT, CM_ABR|CM_INV },
2800 { "transa", LOGT, CM_ABR|CM_INV },
2801 { "transac", LOGT, CM_ABR|CM_INV },
2802 { "transact", LOGT, CM_ABR|CM_INV },
2803 { "transacti", LOGT, CM_ABR|CM_INV },
2804 { "transactio", LOGT, CM_ABR|CM_INV },
2805 { "transaction", LOGT, CM_ABR|CM_INV },
2806 { "transaction-log", LOGT, 0 },
2807 { "transactions", LOGT, CM_INV },
2810 { "write-file", LOGW, 0 },
2814 int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1;
2816 /* SHOW command arguments */
2819 struct keytab shotab[] = {
2821 { "alarm", SHALRM, 0 },
2822 { "arg", SHARG, CM_INV|CM_ABR },
2823 { "arguments", SHARG, 0 },
2824 { "args", SHARG, CM_INV },
2825 { "arrays", SHARR, 0 },
2829 { "associations", SHASSOC, 0 },
2830 #endif /* NOCSETS */
2833 { "attributes", SHATT, 0 },
2836 #ifdef CK_AUTHENTICATION
2837 { "authentication", SHOAUTH, CM_INV },
2838 #endif /* CK_AUTHENTICATION */
2842 { "browser", SHBROWSE, CM_PSH|CM_LOC },
2843 #endif /* BROWSER */
2846 { "character-sets", SHCSE, 0 },
2847 { "cmd", SHCMD, CM_INV },
2849 { "com", SHCOM, CM_INV|CM_ABR },
2850 { "comm", SHCOM, CM_INV|CM_ABR },
2851 { "communications", SHCOM, 0 },
2852 #endif /* NOLOCAL */
2853 { "command", SHCMD, 0 },
2854 { "connection", SHCONNX, 0 },
2856 { "control-prefixing", SHCTL, 0 },
2857 #endif /* CK_SPEED */
2859 { "cx", SHCONNX, CM_INV },
2860 #endif /* CKLOGDIAL */
2862 { "count", SHCOU, 0 },
2864 { "d", SHDIA, CM_INV|CM_ABR },
2866 { "default", SHDFLT, 0 },
2868 { "default", SHDFLT, CM_INV },
2871 { "dial", SHDIA, CM_LOC },
2873 { "double/ignore",SHDBL, 0 },
2876 { "editor", SHEDIT, CM_PSH },
2877 #endif /* NOFRILLS */
2880 { "escape", SHESC, CM_LOC },
2881 #endif /* NOLOCAL */
2882 { "exit", SHEXI, 0 },
2883 { "extended-options", SHXOPT, CM_INV },
2884 { "features", SHFEA, 0 },
2885 { "file", SHFIL, 0 },
2887 { "flow-control", SHOFLO, 0 },
2888 #endif /* NOLOCAL */
2890 { "ftp", SHOFTP, CM_PSH|CM_LOC },
2895 { "ftp", SHOFTP, 0 }, /* (built-in ftp) */
2896 #endif /* TCPSOCKET */
2899 #endif /* BROWSER */
2901 { "functions", SHFUN, 0 },
2902 { "globals", SHVAR, 0 },
2905 { "gui", SHOGUI, 0 },
2908 { "history", SHHISTORY, 0 },
2909 #endif /* CK_RECALL */
2910 { "ignore/double",SHDBL, CM_INV },
2911 { "iksd", SHOIKS, CM_INV },
2913 { "input", SHINP, 0 },
2916 { "k", SHKEY, CM_INV|CM_ABR },
2917 { "key", SHKEY, 0 },
2919 { "kverbs", SHKVB, 0 },
2920 #endif /* NOKVERBS */
2921 #endif /* NOSETKEY */
2923 { "labeled-file-info", SHLBL, 0 },
2924 #endif /* CK_LABELED */
2926 { "languages", SHLNG, 0 },
2927 #endif /* NOCSETS */
2928 { "logs", SHLOG, 0 },
2930 { "macros", SHMAC, 0 },
2933 { "modem", SHMOD, CM_LOC },
2935 { "modem-signals",SHCOM, CM_INV|CM_LOC },
2939 { "mouse", SHMOU, CM_LOC },
2940 #endif /* OS2MOUSE */
2941 #endif /* NOLOCAL */
2943 { "network", SHNET, CM_LOC },
2945 { "network", SHNET, CM_INV|CM_LOC },
2946 #endif /* NETCONN */
2947 { "options", SHOPTS, 0 },
2949 { "output", SHOUTP, CM_INV },
2953 { "pad", SHPAD, CM_LOC },
2956 { "parameters", SHPAR, CM_INV },
2958 { "patterns", SHOPAT, 0 },
2959 #endif /* PATTERNS */
2960 { "printer", SHPRT, 0 },
2962 { "prefixing", SHCTL, CM_INV },
2963 #endif /* CK_SPEED */
2965 { "protocol", SHPRO, 0 },
2968 { "scripts", SHSCR, CM_LOC },
2970 { "send-list", SHSFL, 0 },
2972 { "server", SHSER, 0 },
2973 #endif /* NOSERVER */
2975 { "sexpression", SHSEXP, 0 },
2978 { "ssh", SHOSSH, 0 },
2980 { "stack", SHSTK, 0 },
2981 { "status", SHSTA, 0 },
2983 { "streaming", SHOSTR, 0 },
2984 #endif /* STREAMING */
2987 { "tabs", SHTAB, CM_INV|CM_LOC },
2990 { "tapi", SHTAPI, CM_LOC },
2991 { "tapi-comm", SHTAPI_C, CM_INV|CM_LOC },
2992 { "tapi-location", SHTAPI_L, CM_INV|CM_LOC },
2993 { "tapi-modem", SHTAPI_M, CM_INV|CM_LOC },
2994 #endif /* CK_TAPI */
2995 { "tcp", SHTCP, CM_LOC },
2997 { "tel", SHTEL, CM_INV|CM_ABR },
2998 { "telnet", SHTEL, 0 },
2999 { "telopt", SHTOPT, 0 },
3001 { "terminal", SHTER, CM_LOC },
3002 #endif /* NOLOCAL */
3004 { "tr", SHXMI, CM_INV|CM_ABR },
3005 { "tra", SHXMI, CM_INV|CM_ABR },
3006 { "tran", SHXMI, CM_INV|CM_ABR },
3007 { "trans", SHXMI, CM_INV|CM_ABR },
3010 { "transfer", SHOXFER, 0 },
3013 { "transmit", SHXMI, 0 },
3016 { "trigger", SHTRIG, CM_LOC },
3017 #endif /* CK_TRIGGER */
3021 { "udk", SHUDK, CM_LOC },
3023 #endif /* NOKVERBS */
3024 #endif /* NOSETKEY */
3026 { "variables", SHBUI, 0 },
3029 { "versions", SHVER, 0 },
3030 #endif /* NOFRILLS */
3032 { "vscrn", SHVSCRN, CM_INV|CM_LOC },
3034 { "xfer", SHOXFER, CM_INV },
3036 { "xmit", SHXMI, CM_INV },
3040 int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1;
3045 struct keytab padtab[] = { /* PAD commands */
3046 { "clear", XYPADL, 0 },
3047 { "interrupt", XYPADI, 0 },
3048 { "reset", XYPADR, 0 },
3049 { "status", XYPADS, 0 }
3051 int npadc = (sizeof(padtab) / sizeof(struct keytab));
3056 static struct keytab kmstab[] = {
3062 static struct keytab enatab[] = { /* ENABLE commands */
3063 { "all", EN_ALL, 0 },
3065 { "as", EN_ASG, CM_INV|CM_ABR },
3066 { "asg", EN_ASG, CM_INV },
3067 { "assign", EN_ASG, 0 },
3070 { "bye", EN_BYE, 0 },
3071 #endif /* datageneral */
3072 { "cd", EN_CWD, 0 },
3074 { "copy", EN_CPY, 0 },
3076 { "cwd", EN_CWD, CM_INV },
3077 { "delete", EN_DEL, 0 },
3078 { "directory", EN_DIR, 0 },
3079 { "enable", EN_ENA, CM_INV },
3080 { "exit", EN_XIT, 0 },
3081 { "finish", EN_FIN, 0 },
3082 { "get", EN_GET, 0 },
3083 { "host", EN_HOS, 0 },
3084 { "mail", EN_MAI, 0 },
3085 { "mkdir", EN_MKD, 0 },
3086 { "print", EN_PRI, 0 },
3088 { "query", EN_QUE, 0 },
3090 { "rename", EN_REN, 0 },
3091 { "retrieve", EN_RET, CM_INV },
3092 { "rmdir", EN_RMD, 0 },
3093 { "send", EN_SEN, 0 },
3094 { "set", EN_SET, 0 },
3095 { "space", EN_SPA, 0 },
3096 { "type", EN_TYP, 0 },
3097 { "who", EN_WHO, 0 }
3099 static int nena = (sizeof(enatab) / sizeof(struct keytab));
3100 #endif /* NOSERVER */
3102 struct keytab txtbin[] = {
3109 static struct keytab sndtab[] = { /* SEND command options */
3110 { "/after", SND_AFT, CM_ARG },
3112 { "/array", SND_ARR, CM_ARG },
3114 { "/as-name", SND_ASN, CM_ARG },
3115 { "/b", SND_BIN, CM_INV|CM_ABR },
3116 { "/before", SND_BEF, CM_ARG },
3117 { "/binary", SND_BIN, 0 },
3119 { "/c", SND_CMD, CM_INV|CM_ABR },
3120 { "/calibrate", SND_CAL, CM_INV|CM_ARG },
3121 #endif /* CALIBRATE */
3122 { "/command", SND_CMD, CM_PSH },
3123 { "/delete", SND_DEL, 0 },
3125 { "/dotfiles", SND_DOT, 0 },
3126 #endif /* UNIXOROSK */
3127 { "/except", SND_EXC, CM_ARG },
3129 { "/filter", SND_FLT, CM_ARG|CM_PSH },
3130 #endif /* PIPESEND */
3131 { "/filenames", SND_NAM, CM_ARG },
3133 { "/followlinks", SND_LNK, 0 },
3134 #endif /* CKSYMLINK */
3136 { "/image", SND_IMG, 0 },
3138 { "/image", SND_BIN, CM_INV },
3141 { "/labeled", SND_LBL, 0 },
3142 #endif /* CK_LABELED */
3143 { "/larger-than", SND_LAR, CM_ARG },
3144 { "/listfile", SND_FIL, CM_ARG },
3146 { "/mail", SND_MAI, CM_ARG },
3147 #endif /* NOFRILLS */
3149 { "/move-to", SND_MOV, CM_ARG },
3150 #endif /* CK_TMPDIR */
3151 { "/nobackupfiles", SND_NOB, 0 },
3153 { "/nodotfiles", SND_NOD, 0 },
3154 #endif /* UNIXOROSK */
3156 { "/nofollowlinks", SND_NLK, 0 },
3157 #endif /* CKSYMLINK */
3158 { "/not-after", SND_NAF, CM_ARG },
3159 { "/not-before", SND_NBE, CM_ARG },
3160 { "/pathnames", SND_PTH, CM_ARG },
3161 { "/print", SND_PRI, CM_ARG },
3163 { "/protocol", SND_PRO, CM_ARG },
3165 { "/protocol", SND_PRO, CM_ARG|CM_INV },
3167 { "/quiet", SND_SHH, 0 },
3168 { "/recover", SND_RES, 0 },
3170 /* Systems where we do recursion */
3171 { "/recursive", SND_REC, 0 },
3174 /* Systems that do recursion themselves without our assistance */
3175 /* if we give them the right kind of wildcard */
3176 { "/recursive", SND_REC, 0 },
3179 { "/recursive", SND_REC, 0 },
3181 { "/recursive", SND_REC, CM_INV },
3182 #endif /* datageneral */
3184 #endif /* RECURSIVE */
3185 { "/rename-to", SND_REN, CM_ARG },
3186 { "/since", SND_AFT, CM_INV|CM_ARG },
3187 { "/smaller-than", SND_SMA, CM_ARG },
3188 { "/starting-at", SND_STA, CM_ARG },
3190 { "/su", SND_ASN, CM_ARG|CM_INV|CM_ABR },
3191 { "/sub", SND_ASN, CM_ARG|CM_INV|CM_ABR },
3192 { "/subject", SND_ASN, CM_ARG },
3193 #endif /* NOFRILLS */
3195 { "/subdirectories", SND_REC, CM_INV },
3196 #endif /* RECURSIVE */
3197 { "/text", SND_TXT, 0 },
3198 { "/transparent", SND_XPA, 0 },
3199 { "/type", SND_TYP, CM_ARG }
3201 #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab)
3202 static int nsndtab = NSNDTAB;
3205 static struct keytab msndtab[] = { /* MSEND options */
3206 { "/after", SND_AFT, CM_ARG },
3207 { "/before", SND_BEF, CM_ARG },
3208 { "/binary", SND_BIN, 0 },
3209 { "/delete", SND_DEL, 0 },
3210 { "/except", SND_EXC, CM_ARG },
3211 { "/filenames", SND_NAM, CM_ARG },
3213 { "/followlinks", SND_LNK, 0 },
3214 #endif /* CKSYMLINK */
3216 { "/image", SND_IMG, 0 },
3218 { "/image", SND_BIN, CM_INV },
3221 { "/labeled", SND_LBL, 0 },
3222 #endif /* CK_LABELED */
3223 { "/larger-than", SND_LAR, CM_ARG },
3224 { "/list", SND_FIL, CM_ARG },
3226 { "/mail", SND_MAI, CM_ARG },
3227 #endif /* NOFRILLS */
3229 { "/move-to", SND_MOV, CM_ARG },
3230 #endif /* CK_TMPDIR */
3232 { "/nofollowlinks", SND_NLK, 0 },
3233 #endif /* CKSYMLINK */
3234 { "/not-after", SND_NAF, CM_ARG },
3235 { "/not-before", SND_NBE, CM_ARG },
3236 { "/pathnames", SND_PTH, CM_ARG },
3237 { "/print", SND_PRI, CM_ARG },
3239 { "/protocol", SND_PRO, CM_ARG },
3241 { "/quiet", SND_SHH, 0 },
3242 { "/recover", SND_RES, 0 },
3243 { "/rename-to", SND_REN, CM_ARG },
3244 { "/since", SND_AFT, CM_INV|CM_ARG },
3245 { "/smaller-than", SND_SMA, CM_ARG },
3246 { "/starting-at", SND_STA, CM_ARG },
3248 { "/subject", SND_ASN, CM_ARG },
3249 #endif /* NOFRILLS */
3250 { "/text", SND_TXT, 0 },
3251 { "/transparent", SND_XPA, 0 },
3252 { "/type", SND_TYP, CM_ARG }
3254 #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab)
3255 static int nmsndtab = NMSNDTAB;
3256 #endif /* NOMSEND */
3259 /* CONNECT command switches */
3261 #define CONN_II 0 /* Idle interval */
3262 #define CONN_IS 1 /* Idle string */
3263 #define CONN_IL 2 /* Idle limit */
3264 #define CONN_NV 3 /* Non-Verbose */
3265 #define CONN_TL 4 /* Time limit */
3266 #define CONN_TS 5 /* Trigger string */
3267 #define CONN_AS 6 /* Asynchronous */
3268 #define CONN_SY 7 /* Synchronous */
3269 #define CONN_MAX 7 /* Number of CONNECT switches */
3272 static struct keytab conntab[] = {
3274 { "/asynchronous", CONN_AS, CM_INV },
3277 { "/idle-interval", CONN_II, CM_ARG },
3278 { "/idle-limit", CONN_IL, CM_ARG },
3279 { "/idle-string", CONN_IS, CM_ARG },
3280 { "/quietly", CONN_NV, CM_INV },
3282 { "/quietly", CONN_NV, 0 },
3283 #endif /* XLIMITS */
3285 { "/synchronous", CONN_SY, CM_INV },
3288 { "/time-limit", CONN_TL, CM_ARG },
3289 #endif /* XLIMITS */
3291 { "/trigger", CONN_TS, CM_ARG },
3292 #endif /* CK_TRIGGER */
3295 #define NCONNTAB sizeof(conntab)/sizeof(struct keytab)
3296 static int nconntab = NCONNTAB;
3297 #endif /* NOLOCAL */
3300 static struct keytab stattab[] = { /* STATISTICS command switches */
3302 { "/verbose", 0, 0 }
3308 struct mtab mactab[MAC_MAX] = { /* Preinitialized macro table */
3312 struct mtab *mactab; /* Dynamically allocated macro table */
3313 #endif /* COMMENT */
3316 struct keytab mackey[MAC_MAX]; /* Macro names as command keywords */
3321 struct keytab beeptab[] = { /* Beep options */
3322 { "error", BP_FAIL, 0 },
3323 { "information", BP_NOTE, 0 },
3324 { "warning", BP_WARN, 0 }
3326 int nbeeptab = sizeof(beeptab)/sizeof(struct keytab);
3328 /* CLEAR COMMMAND-SCREEN options */
3338 struct keytab clrcmdtab[] = {
3339 { "all", CLR_C_ALL, 0 },
3340 { "bol", CLR_C_BOL, 0 },
3341 { "bos", CLR_C_BOS, 0 },
3342 { "eol", CLR_C_EOL, 0 },
3343 { "eos", CLR_C_EOS, 0 },
3344 { "line", CLR_C_LIN, 0 },
3345 { "scrollback", CLR_C_SCR, 0 }
3347 int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab);
3352 /* Not used at present */
3353 static struct keytab pagetab[] = {
3354 { "/more", 1, CM_INV },
3355 { "/nopage", 0, 0 },
3358 int npagetab = sizeof(pagetab)/sizeof(struct keytab);
3359 #endif /* COMMENT */
3361 #define TYP_NOP 0 /* /NOPAGE */
3362 #define TYP_PAG 1 /* /PAGE */
3363 #define TYP_HEA 2 /* /HEAD:n */
3364 #define TYP_TAI 3 /* /TAIL:n */
3365 #define TYP_PAT 4 /* /MATCH:pattern */
3366 #define TYP_WID 5 /* /WIDTH:cols */
3367 #define TYP_COU 6 /* /COUNT */
3368 #define TYP_OUT 7 /* /OUTPUT:file */
3369 #define TYP_PFX 8 /* /PREFIX:string */
3371 #define TYP_XIN 9 /* /TRANSLATE-FROM:charset */
3372 #define TYP_XUT 10 /* /TRANSLATE-TO:charset */
3373 #define TYP_XPA 11 /* /TRANSPARENT */
3374 #endif /* UNICODE */
3376 #define TYP_GUI 12 /* /GUI:title */
3377 #define TYP_HIG 13 /* /HEIGHT:rows */
3379 #define TYP_NUM 14 /* /NUMBER */
3381 static struct keytab typetab[] = { /* TYPE command switches */
3382 { "/count", TYP_COU, 0 },
3384 { "/character-set", TYP_XIN, CM_ARG },
3385 #endif /* UNICODE */
3387 { "/gui", TYP_GUI, CM_ARG },
3389 { "/head", TYP_HEA, CM_ARG },
3391 { "/height", TYP_HIG, CM_ARG },
3393 { "/match", TYP_PAT, CM_ARG },
3395 { "/more", TYP_PAG, CM_INV },
3396 { "/nopage", TYP_NOP, 0 },
3397 { "/number", TYP_NUM, 0 },
3398 { "/output", TYP_OUT, CM_ARG },
3399 { "/page", TYP_PAG, 0 },
3400 #endif /* CK_TTGWSIZ */
3401 { "/prefix", TYP_PFX, CM_ARG },
3402 { "/tail", TYP_TAI, CM_ARG },
3404 { "/translate-to", TYP_XUT, CM_ARG },
3405 { "/transparent", TYP_XPA, 0 },
3406 #endif /* UNICODE */
3407 { "/width", TYP_WID, CM_ARG },
3409 { "/xlate-to", TYP_XUT, CM_INV|CM_ARG },
3410 #endif /* UNICODE */
3413 int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1;
3415 int typ_page = -1; /* TYPE /[NO]PAGE default */
3419 #define TRA_ALL 999 /* TRACE command */
3426 static struct keytab tracetab[] = { /* TRACE options */
3427 { "all", TRA_ALL, 0 },
3428 { "assignments", TRA_ASG, 0 },
3429 { "command-level", TRA_CMD, 0 }
3431 static int ntracetab = sizeof(tracetab)/sizeof(struct keytab);
3438 if (typ_page > -1) {
3439 prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE");
3441 prtopt(&optlines,"(no options set)");
3443 ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL);
3444 prtopt(&optlines,tmpbuf);
3446 prtopt(&optlines,"");
3451 /* isauto == 1 if locus is being switched automatically */
3454 setlocus(x, isauto) int x, isauto; {
3455 extern int quitting;
3457 if (x && locus) return;
3458 if (!x && !locus) return;
3459 /* Get here if it actually needs to be changed */
3461 if (isauto && /* Automatically switching */
3462 !quitting && /* not exiting */
3463 autolocus == 2) { /* and AUTOLOCUS is set to ASK */
3465 ckmakmsg(locmsg,300,
3466 "Switching Locus to ",
3467 x ? "LOCAL" : "REMOTE",
3468 " for file management commands\n"
3469 "such as CD, DIRECTORY, DELETE, RENAME. Type HELP SET\n"
3470 "LOCUS at the K-95> prompt for further info. Use the\n"
3472 "Actions menu or SET LOCUS command to disable automatic\n"
3473 "Locus switching or to disable these queries.",
3475 "SET LOCUS command to disable automatic locus switching\n"
3476 "or to disable these queries.",
3479 if (uq_ok(locmsg,"OK to switch Locus?",3,NULL,1)) {
3482 KuiSetProperty(KUI_LOCUS,x,0);
3488 if (isauto && msgflg && !quitting)
3489 printf("Switching LOCUS for file-management commands to %s.\n",
3490 x ? "LOCAL" : "REMOTE"
3495 KuiSetProperty(KUI_LOCUS,x,0);
3502 setautolocus(x) int x; {
3505 KuiSetProperty(KUI_AUTO_LOCUS,x,0);
3511 settypopts() { /* Set TYPE option defaults */
3515 if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) {
3522 if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
3523 printf("?This switch does not take an argument\n");
3527 case TYP_NOP: xp = 0; break;
3528 case TYP_PAG: xp = 1; break;
3531 if ((x = cmnum("Column at which to truncate",
3532 ckitoa(cmd_cols),10,&y,xxstring)) < 0)
3538 printf("?Sorry, this option can not be set\n");
3542 if ((x = cmcfm()) < 0) /* Get confirmation */
3544 if (xp > -1) typ_page = xp; /* Confirmed, save defaults */
3545 return(success = 1);
3548 /* Forward declarations of functions local to this module */
3551 _PROTOTYP (int douchmod, ( void ) );
3554 _PROTOTYP (int dopurge, ( void ) );
3555 #endif /* CKPURGE */
3557 _PROTOTYP (int doundef, ( int ) );
3558 _PROTOTYP (int doask, ( int ) );
3559 _PROTOTYP (int dodef, ( int ) );
3560 _PROTOTYP (int doelse, ( void ) );
3561 _PROTOTYP (int dofor, ( void ) );
3562 _PROTOTYP (int doincr, ( int ) );
3565 _PROTOTYP (int dodial, ( int ) );
3567 _PROTOTYP (int dodel, ( void ) );
3568 _PROTOTYP (int dopaus, ( int ) );
3571 _PROTOTYP (int doping, ( void ) );
3572 _PROTOTYP (int doftp, ( void ) );
3573 #endif /* TCPSOCKET */
3577 _PROTOTYP (int dorenam, ( void ) );
3578 #endif /* NOFRILLS */
3579 #endif /* NORENAME */
3581 _PROTOTYP (int docopy, ( void ) );
3584 _PROTOTYP (int dolink, ( void ));
3587 _PROTOTYP (int dorexx, ( void ) );
3588 #endif /* CK_REXX */
3591 static struct keytab telcmd[] = {
3592 { "abort", TN_ABORT, CM_INV }, /* Emotionally toned - don't show */
3594 { "ayt", TN_AYT, 0 },
3595 { "break", BREAK, 0 },
3596 { "cancel",TN_ABORT, 0 },
3597 { "dmark", TN_DM, 0 },
3599 { "dont", DONT, 0 },
3602 { "eof", TN_EOF, 0 },
3603 { "eor", TN_EOR, 0 },
3607 { "forward", TN_FWD, CM_INV },
3609 #endif /* CK_KERBEROS */
3612 { "nop", TN_NOP, 0 },
3613 { "sak", TN_SAK, CM_INV },
3616 { "susp", TN_SUSP, 0 },
3617 { "will", WILL, 0 },
3620 static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab));
3622 static struct keytab tnopts[] = {
3623 #ifdef CK_AUTHENTICATION
3624 { "auth", TELOPT_AUTHENTICATION, 0 },
3626 { "auth", TELOPT_AUTHENTICATION, CM_INV },
3627 #endif /* CK_AUTHENTICATION */
3628 { "binary", TELOPT_BINARY, 0 },
3630 { "c", TELOPT_COMPORT, CM_INV|CM_ABR},
3631 { "co", TELOPT_COMPORT, CM_INV|CM_ABR},
3632 { "com", TELOPT_COMPORT, CM_INV|CM_ABR},
3633 { "com-port-control", TELOPT_COMPORT, 0 },
3634 { "comport-control", TELOPT_COMPORT, CM_INV},
3635 #else /* TN_COMPORT */
3636 { "com-port-control", TELOPT_COMPORT, CM_INV },
3637 { "comport-control", TELOPT_COMPORT, CM_INV},
3638 #endif /* TN_COMPORT */
3639 { "echo", TELOPT_ECHO, 0 },
3640 #ifdef CK_ENCRYPTION
3641 { "encrypt", TELOPT_ENCRYPTION, 0 },
3643 { "encrypt", TELOPT_ENCRYPTION, CM_INV },
3644 #endif /* CK_ENCRYPTION */
3646 { "forward-x", TELOPT_FORWARD_X, 0 },
3648 { "forward-x", TELOPT_FORWARD_X, CM_INV },
3649 #endif /* CK_FORWARD_X */
3651 { "kermit", TELOPT_KERMIT, 0 },
3653 { "kermit", TELOPT_KERMIT, CM_INV },
3654 #endif /* IKS_OPTION */
3655 { "lflow", TELOPT_LFLOW, CM_INV },
3656 { "logout", TELOPT_LOGOUT, CM_INV },
3658 { "naws", TELOPT_NAWS, 0 },
3660 { "naws", TELOPT_NAWS, CM_INV },
3661 #endif /* CK_NAWS */
3662 #ifdef CK_ENVIRONMENT
3663 { "new-environment", TELOPT_NEWENVIRON, 0 },
3665 { "new-environment", TELOPT_NEWENVIRON, CM_INV },
3666 #endif /* CK_ENVIRONMENT */
3667 { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT, CM_INV },
3668 { "pragma-logon", TELOPT_PRAGMA_LOGON, CM_INV },
3669 { "pragma-sspi", TELOPT_SSPI_LOGON, CM_INV },
3670 { "sak", TELOPT_IBM_SAK, CM_INV },
3672 { "send-location", TELOPT_SNDLOC, 0 },
3674 { "send-location", TELOPT_SNDLOC, CM_INV },
3675 #endif /* CK_SNDLOC */
3676 { "sga", TELOPT_SGA, 0 },
3678 { "start-tls", TELOPT_START_TLS, 0 },
3680 { "start-tls", TELOPT_START_TLS, CM_INV },
3682 { "ttype", TELOPT_TTYPE, 0 },
3683 #ifdef CK_ENVIRONMENT
3684 { "xdisplay-location", TELOPT_XDISPLOC, 0 },
3686 { "xdisplay-location", TELOPT_XDISPLOC, CM_INV },
3687 #endif /* CK_ENVIRONMENT */
3690 static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1;
3692 static struct keytab tnsbopts[] = {
3694 { "naws", TELOPT_NAWS, 0 },
3695 #endif /* CK_NAWS */
3698 static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1;
3705 doftp() { /* (External) FTP command */
3706 char *p, *f; /* (See doxftp() for internal one) */
3709 if (network) /* If we have a current connection */
3710 ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */
3711 else *line = '\0'; /* as default host */
3712 for (p = line; *p; p++) /* Remove ":service" from end. */
3713 if (*p == ':') { *p = '\0'; break; }
3714 if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
3717 printf("?Sorry, FTP command disabled\n");
3718 return(success = 0);
3720 /* Construct FTP command */
3722 #ifdef MULTINET /* TGV MultiNet */
3723 ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL);
3725 ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
3726 #endif /* MULTINET */
3732 if (!f[0]) f = "ftp";
3733 ckmakmsg(line,LINBUFSIZ,f," ",s,NULL);
3735 p = line + strlen(ftpapp);
3737 if (*p == '/') *p = '\\';
3742 ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
3744 #else /* OS2ORUNIX */
3745 ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
3746 #endif /* OS2ORUNIX */
3748 conres(); /* Make console normal */
3750 printf("\n"); /* Prevent prompt-stomping */
3751 #endif /* DEC_TCPIP */
3753 concb((char)escape);
3754 return(success = x);
3759 doping() { /* PING command */
3760 char *p; /* just runs ping program */
3763 if (network) /* If we have a current connection */
3764 ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */
3765 else *line = '\0'; /* as default host to be pinged. */
3766 for (p = line; *p; p++) /* Remove ":service" from end. */
3767 if (*p == ':') { *p = '\0'; break; }
3768 if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
3771 printf("?Sorry, PING command disabled\n");
3772 return(success = 0);
3775 /* Construct PING command */
3777 #ifdef MULTINET /* TGV MultiNet */
3778 ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL);
3780 ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */
3781 #endif /* MULTINET */
3783 ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL);
3785 conres(); /* Make console normal */
3787 printf("\n"); /* Prevent prompt-stomping */
3788 #endif /* DEC_TCPIP */
3790 concb((char)escape);
3791 return(success = x);
3794 #endif /* TCPSOCKET */
3799 /* Pop from all FOR/WHILE/XIF/SWITCH's */
3800 debug(F101,"doend maclvl 1","",maclvl);
3801 while ((maclvl > 0) &&
3802 (m_arg[maclvl-1][0]) &&
3803 (cmdstk[cmdlvl].src == CMD_MD) &&
3804 (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
3805 !strncmp(m_arg[maclvl-1][0],"_for",4) ||
3806 !strncmp(m_arg[maclvl-1][0],"_whi",4) ||
3807 !strncmp(m_arg[maclvl-1][0],"_swi",4))) {
3808 debug(F110,"END popping",m_arg[maclvl-1][0],0);
3809 dogta(XXPTA); /* Put args back */
3810 popclvl(); /* Pop up two levels */
3812 debug(F101,"doend maclvl 2","",maclvl);
3815 if (mrval[maclvl]) /* Free previous retval if any */
3816 free(mrval[maclvl]);
3817 mrval[maclvl] = malloc(16); /* Room for up to 15 digits */
3818 if (mrval[maclvl]) /* Record current retval */
3819 ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL);
3822 popclvl(); /* Now pop out of macro or TAKE file */
3826 debug(F101,"END maclvl 3","",maclvl);
3827 debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl);
3828 debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1);
3837 if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) {
3839 printf("?Directory name required\n");
3844 ckstrncpy(line,s,LINBUFSIZ);
3846 if ((x = cmcfm()) < 0) return(x);
3853 case -2: m = "Not a directory"; break;
3854 case -3: m = "Internal error"; break;
3855 case -4: m = "Access denied"; break;
3856 case -5: m = "Off limits"; break;
3858 if (m) printf("%s: \"%s\"\n", m, s);
3859 return(m ? -9 : -2);
3862 return(success = 1);
3868 static char * asnbuf = NULL; /* As-name buffer pointer */
3870 char sndxnam[] = { "_array_x_" }; /* (with replaceable x!) */
3873 The new SEND command, replacing BSEND, CSEND, PSEND, etc etc.
3874 Call with cx = top-level keyword value. Returns:
3876 0 On other type of failure (e.g. requested operation not allowed).
3877 1 On success with sstate set to 's' so protocol will begin.
3880 /* D O X S E N D -- Parse SEND and related commands with switches */
3883 doxsend(cx) int cx; {
3884 int c, i, n, wild, confirmed = 0; /* Workers */
3885 int x, y; /* of the world... */
3886 int getval = 0; /* Whether to get switch value */
3887 extern char * snd_move; /* Directory to move sent files to */
3888 extern char * snd_rename; /* What to rename sent files to */
3889 extern char * filefile; /* File containing filenames to send */
3890 extern int xfiletype; /* Send only text (or binary) files */
3891 extern struct keytab pathtab[]; /* PATHNAMES option keywords */
3892 extern int npathtab; /* How many of them */
3893 extern int recursive; /* Recursive directory traversal */
3894 extern int rprintf; /* REMOTE PRINT flag */
3895 extern int fdispla; /* TRANSFER DISPLAY setting */
3896 extern int skipbup; /* Skip backup files when sending */
3897 struct stringint { /* Temporary array for switch values */
3901 struct FDB sf, sw, fl, cm; /* FDBs for each parse function */
3902 int mlist = 0; /* Flag for MSEND or MMOVE */
3903 char * m; /* For making help messages */
3904 extern struct keytab protos[]; /* File transfer protocols */
3905 extern int xfrxla, g_xfrxla, nprotos;
3906 extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */
3907 extern char sndnbefore[], sndnafter[];
3908 extern long sndsmaller, sndlarger, calibrate;
3910 int range[2]; /* Array range */
3911 char ** ap = NULL; /* Array pointer */
3912 int arrayx = -1; /* Array index */
3916 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
3918 printf("?Sorry, No MAIL with FTP\n");
3921 return(doftpput(cx,0));
3925 for (i = 0; i <= SND_MAX; i++) { /* Initialize switch values */
3926 pv[i].sval = NULL; /* to null pointers */
3927 pv[i].ival = -1; /* and -1 int values */
3932 sndxin = -1; /* Array index */
3934 sndarray = NULL; /* Array pointer */
3937 g_matchdot = matchdot; /* Match dot files */
3938 #endif /* UNIXOROSK */
3939 g_recursive = recursive; /* Recursive sending */
3940 recursive = 0; /* Save global value, set local */
3941 debug(F101,"xsend entry fncnv","",fncnv);
3943 /* Preset switch values based on top-level command that called us */
3946 case XXMSE: /* MSEND */
3948 case XXCSEN: /* CSEND */
3949 pv[SND_CMD].ival = 1; break;
3950 case XXMMOVE: /* MMOVE */
3952 case XXMOVE: /* MOVE */
3953 pv[SND_DEL].ival = 1; break;
3954 case XXRSEN: /* RESEND */
3955 pv[SND_BIN].ival = 1; /* Implies /BINARY */
3956 pv[SND_RES].ival = 1; break;
3957 case XXMAI: /* MAIL */
3958 pv[SND_MAI].ival = 1; break;
3961 /* Set up chained parse functions... */
3963 cmfdbi(&sw, /* First FDB - command switches */
3965 "Filename, or switch", /* hlpmsg */
3967 "", /* addtl string data */
3969 nsndtab, /* addtl numeric data 1: tbl size */
3971 mlist ? nmsndtab : nsndtab, /* addtl numeric data 1: tbl size */
3972 #endif /* NOMSEND */
3973 4, /* addtl numeric data 2: 4 = cmswi */
3974 xxstring, /* Processing function */
3976 sndtab, /* Keyword table */
3978 mlist ? msndtab : sndtab,
3979 #endif /* NOMSEND */
3980 &sf /* Pointer to next FDB */
3982 cmfdbi(&sf, /* 2nd FDB - file to send */
3984 "File(s) to send", /* hlpmsg */
3986 "", /* addtl string data */
3987 nolinks, /* addtl numeric data 1 */
3988 0, /* addtl numeric data 2 */
3993 cmfdbi(&fl, /* 3rd FDB - command to send from */
3995 "Command", /* hlpmsg */
3997 "", /* addtl string data */
3998 0, /* addtl numeric data 1 */
3999 0, /* addtl numeric data 2 */
4004 cmfdbi(&cm, /* 4th FDB - Confirmation */
4008 "", /* addtl string data */
4009 0, /* addtl numeric data 1 */
4010 0, /* addtl numeric data 2 */
4016 while (1) { /* Parse 0 or more switches */
4017 x = cmfdb(&sw); /* Parse something */
4018 debug(F101,"xsend cmfdb","",x);
4019 if (x < 0) /* Error */
4020 goto xsendx; /* or reparse needed */
4021 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
4024 They gave a switch, but let's see how they terminated it.
4025 If they ended it with : or =, then we must parse a value.
4026 If they ended it with anything else, then we must NOT parse a value.
4028 c = cmgbrk(); /* Get break character */
4029 getval = (c == ':' || c == '='); /* to see how they ended the switch */
4030 if (getval && !(cmresult.kflags & CM_ARG)) {
4031 printf("?This switch does not take arguments\n");
4035 if (!getval && (cmgkwflgs() & CM_ARG)) {
4036 printf("?This switch requires an argument\n");
4040 n = cmresult.nresult; /* Numeric result = switch value */
4041 debug(F101,"xsend switch","",n);
4043 switch (n) { /* Process the switch */
4044 case SND_CMD: /* These take no args */
4046 printf("?Sorry, system command access is disabled\n");
4051 else if (sndfilter) {
4053 "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n");
4057 #endif /* PIPESEND */
4058 sw.hlpmsg = "Command, or switch"; /* Change help message */
4059 pv[n].ival = 1; /* Just set the flag */
4060 pv[SND_ARR].ival = 0;
4063 case SND_REC: /* /RECURSIVE */
4064 recursive = 2; /* Set the real variable */
4065 pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */
4066 pv[n].ival = 1; /* Just set the flag */
4069 case SND_RES: /* /RECOVER (resend) */
4070 pv[SND_ARR].ival = 0;
4071 pv[SND_BIN].ival = 1; /* Implies /BINARY */
4072 case SND_NOB: /* /NOBACKUP */
4073 case SND_DEL: /* /DELETE */
4074 case SND_SHH: /* /QUIET */
4075 pv[n].ival = 1; /* Just set the flag */
4079 /* Like recursive, these are set immediately because they affect cmifi() */
4080 case SND_DOT: /* /DOTFILES */
4083 case SND_NOD: /* /NODOTFILES */
4086 #endif /* UNIXOROSK */
4088 /* File transfer modes - each undoes the others */
4090 case SND_BIN: /* Binary */
4091 case SND_TXT: /* Text */
4092 case SND_IMG: /* Image */
4093 case SND_LBL: /* Labeled */
4094 pv[SND_BIN].ival = 0;
4095 pv[SND_TXT].ival = 0;
4096 pv[SND_IMG].ival = 0;
4097 pv[SND_LBL].ival = 0;
4104 nolinks = (n == SND_NLK) ? 2 : 0;
4105 cmfdbi(&sf, /* Redo cmifi() */
4107 "File(s) to send", /* hlpmsg */
4109 "", /* addtl string data */
4110 nolinks, /* addtl numeric data 1 */
4111 0, /* addtl numeric data 2 */
4117 #endif /* CKSYMLINK */
4119 case SND_EXC: /* Excludes */
4121 if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
4123 printf("?Pattern required\n");
4128 if (pv[n].sval) free(pv[n].sval);
4131 printf("?Pattern too long - 256 max\n");
4135 pv[n].sval = malloc(y+1);
4137 strcpy(pv[n].sval,s); /* safe */
4142 case SND_MOV: /* MOVE after */
4143 case SND_REN: /* RENAME after */
4145 if ((x = cmfld(n == SND_MOV ?
4146 "device and/or directory for source file after sending" :
4147 "new name for source file after sending",
4150 n == SND_MOV ? xxstring : NULL
4153 printf("%s\n", n == SND_MOV ?
4154 "?Destination required" :
4155 "?New name required"
4161 if (pv[n].sval) free(pv[n].sval);
4165 pv[n].sval = malloc(y+1);
4167 strcpy(pv[n].sval,s); /* safe */
4173 case SND_SMA: /* Smaller / larger than */
4176 if ((x = cmnum("Size in bytes","0",10,&y,xxstring)) < 0)
4181 case SND_AFT: /* Send /AFTER:date-time */
4182 case SND_BEF: /* Send /BEFORE:date-time */
4183 case SND_NAF: /* Send /NOT-AFTER:date-time */
4184 case SND_NBE: /* Send /NOT-BEFORE:date-time */
4186 if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) {
4188 printf("?Date-time required\n");
4193 if (pv[n].sval) free(pv[n].sval);
4194 pv[n].sval = malloc((int)strlen(s)+1);
4196 strcpy(pv[n].sval,s); /* safe */
4201 case SND_MAI: /* Send as mail (= MAIL) */
4203 if (inserver && !ENABLED(en_mai)) {
4204 printf("?Sorry, sending files as mail is disabled\n");
4210 if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) {
4212 printf("?address required\n");
4218 if (pv[n].sval) free(pv[n].sval);
4219 pv[n].sval = malloc((int)strlen(s)+1);
4221 strcpy(pv[n].sval,s); /* safe */
4224 case SND_PRI: /* Send to be printed (REMOTE PRINT) */
4226 if (inserver && !ENABLED(en_mai)) {
4227 printf("?Sorry, sending files for printing is disabled\n");
4233 if ((x = cmfld("Print options","",&s,xxstring)) < 0)
4234 if (x != -3) goto xsendx;
4236 if (pv[n].sval) free(pv[n].sval);
4237 pv[n].sval = malloc((int)strlen(s)+1);
4239 strcpy(pv[n].sval,s); /* safe */
4242 case SND_ASN: /* As-name */
4243 debug(F101,"xsend /as-name getval","",getval);
4245 if ((x = cmfld("Name to send under","",&s,NULL)) < 0) {
4247 printf("?name required\n");
4253 if ((y = strlen(s)) > 0) {
4254 if (pv[n].sval) free(pv[n].sval);
4255 pv[n].sval = malloc(y+1);
4257 strcpy(pv[n].sval,s); /* safe */
4263 case SND_STA: /* Starting position (= PSEND) */
4265 if ((x = cmnum("0-based position","0",10,&y,xxstring)) < 0)
4270 case SND_PRO: /* Protocol to use */
4272 if ((x = cmkey(protos,nprotos,"File-transfer protocol","",
4275 printf("?name of protocol required\n");
4284 case SND_FLT: /* Filter */
4285 debug(F101,"xsend /filter getval","",getval);
4287 if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) {
4293 if (*s) s = brstrip(s);
4295 for (x = 0; x < y; x++) { /* Make sure they included "\v(...)" */
4296 if (s[x] != '\\') continue;
4297 if (s[x+1] == 'v') break;
4301 "?Filter must contain a replacement variable for filename.\n"
4311 if ((y = strlen(s)) > 0) {
4312 if ((pv[n].sval = malloc(y+1)))
4313 strcpy(pv[n].sval,s); /* safe */
4316 #endif /* PIPESEND */
4318 case SND_PTH: /* Pathnames */
4320 pv[n].ival = PATH_REL;
4323 if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0)
4328 case SND_NAM: /* Filenames */
4330 if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0)
4332 debug(F101,"xsend /filenames","",x);
4337 case SND_CAL: /* /CALIBRATE */
4339 if ((x = cmnum("number of Kbytes to send",
4340 "1024",10,&y,xxstring)) < 0)
4345 pv[SND_ARR].ival = 0;
4347 #endif /* CALIBRATE */
4349 case SND_FIL: /* Name of file containing filnames */
4351 if ((x = cmifi("Name of file containing list of filenames",
4352 "",&s,&y,xxstring)) < 0) {
4354 printf("?Filename required\n");
4359 printf("?Wildcards not allowed\n");
4366 if ((pv[n].sval = malloc((int)strlen(s)+1))) {
4367 strcpy(pv[n].sval,s);
4369 pv[SND_ARR].ival = 0;
4375 case SND_ARR: /* SEND /ARRAY: */
4378 if ((x = cmfld("Array name (a single letter will do)",
4388 if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
4389 printf("?Bad array: %s\n",s);
4392 if (!(ap = a_ptr[x])) {
4393 printf("?No such array: %s\n",s);
4397 pv[SND_CMD].ival = 0; /* Undo any conflicting ones... */
4398 pv[SND_RES].ival = 0;
4399 pv[SND_CAL].ival = 0;
4400 pv[SND_FIL].ival = 0;
4405 case SND_XPA: /* /TRANSPARENT */
4409 case SND_TYP: /* Only files of given type */
4411 if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0)
4413 pv[n].ival = (x == 2) ? -1 : x;
4417 printf("?Unexpected switch value - %d\n",cmresult.nresult);
4422 debug(F101,"xsend cmresult fcode","",cmresult.fcode);
4425 /* List switch parsing results in debug log */
4426 for (i = 0; i <= SND_MAX; i++) {
4427 ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL);
4428 debug(F111,line, pv[i].sval, pv[i].ival);
4430 #endif /* COMMENT */
4432 /* Now we have all switches, plus maybe a filename or command, or nothing */
4435 if (protocol != PROTO_K && pv[SND_CMD].ival > 0) {
4436 printf("?Sorry, %s works only with Kermit protocol\n",
4437 (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND");
4441 if (pv[SND_RES].ival > 0 || /* /RECOVER */
4442 pv[SND_STA].ival > 0) { /* or /STARTING */
4443 if (sndfilter || pv[SND_FLT].ival > 0) {
4444 printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n");
4449 #endif /* PIPESEND */
4457 switch (cmresult.fcode) { /* How did we get out of switch loop */
4458 case _CMIFI: /* Input filename */
4459 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
4460 if (pv[SND_ARR].ival > 0)
4463 wild = cmresult.nresult; /* Wild flag */
4464 if (!recursive && !wild)
4467 case _CMFLD: /* Field */
4468 /* Only allowed with /COMMAND and /ARRAY */
4469 if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) {
4472 printf("?Off limits: %s\n",cmresult.sresult);
4475 printf("?%s - \"%s\"\n",
4476 iswild(cmresult.sresult) ?
4477 "No files match" : "File not found",
4483 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
4484 if (pv[SND_ARR].ival > 0)
4487 case _CMCFM: /* Confirmation */
4492 printf("?Unexpected function code: %d\n",cmresult.fcode);
4496 debug(F110,"xsend string",s,0);
4497 debug(F101,"xsend confirmed","",confirmed);
4499 /* Save and change protocol and transfer mode */
4500 /* Global values are restored in main parse loop */
4502 g_proto = protocol; /* Save current global protocol */
4509 g_prefixing = prefixing;
4512 g_fnspath = fnspath;
4513 g_fnrpath = fnrpath;
4516 if (pv[SND_PRO].ival > -1) { /* Change according to switch */
4517 protocol = pv[SND_PRO].ival;
4518 if (ptab[protocol].rpktlen > -1) /* copied from initproto() */
4519 urpsiz = ptab[protocol].rpktlen;
4520 if (ptab[protocol].spktflg > -1)
4521 spsizf = ptab[protocol].spktflg;
4522 if (ptab[protocol].spktlen > -1) {
4523 spsiz = ptab[protocol].spktlen;
4525 spsizr = spmax = spsiz;
4527 if (ptab[protocol].winsize > -1)
4528 wslotr = ptab[protocol].winsize;
4529 if (ptab[protocol].prefix > -1)
4530 prefixing = ptab[protocol].prefix;
4531 if (ptab[protocol].fnca > -1)
4532 fncact = ptab[protocol].fnca;
4533 if (ptab[protocol].fncn > -1)
4534 fncnv = ptab[protocol].fncn;
4535 if (ptab[protocol].fnsp > -1)
4536 fnspath = ptab[protocol].fnsp;
4537 if (ptab[protocol].fnrp > -1)
4538 fnrpath = ptab[protocol].fnrp;
4540 debug(F101,"xsend protocol","",protocol);
4542 if (pv[SND_NOB].ival > -1) { /* /NOBACKUP (skip backup file) */
4543 g_skipbup = skipbup;
4546 if (pv[SND_REC].ival > 0) /* /RECURSIVE */
4549 if (pv[SND_TYP].ival > -1) { /* /TYPE */
4550 xfiletype = pv[SND_TYP].ival;
4554 g_binary = binary; /* Save global transfer mode */
4556 g_patterns = patterns; /* Save FILE PATTERNS setting */
4557 #endif /* PATTERNS */
4558 if (pv[SND_BIN].ival > 0) { /* Change according to switch */
4559 /* If they said /BINARY they mean /BINARY */
4560 patterns = 0; /* So no pattern-based switching */
4561 g_xfermode = xfermode; /* or automatic transfer mode */
4564 debug(F101,"doxsend /BINARY xfermode","",xfermode);
4565 } else if (pv[SND_TXT].ival > 0) { /* Ditto for /TEXT */
4567 g_xfermode = xfermode;
4570 debug(F101,"doxsend /TEXT xfermode","",xfermode);
4571 } else if (pv[SND_IMG].ival > 0) {
4579 else if (pv[SND_LBL].ival > 0) {
4582 #endif /* CK_LABELED */
4583 debug(F101,"xsend binary","",binary);
4585 if (pv[SND_XPA].ival > 0) /* /TRANSPARENT */
4586 xfrxla = 0; /* Don't translate character sets */
4588 /* Check for legal combinations of switches, filenames, etc */
4591 if (pv[SND_CMD].ival > 0) { /* COMMAND - strip any braces */
4592 debug(F110,"SEND /COMMAND before stripping",s,0);
4594 debug(F110,"SEND /COMMAND after stripping",s,0);
4596 printf("?Sorry, a command to send from is required\n");
4602 #endif /* PIPESEND */
4604 /* Set up /MOVE and /RENAME */
4606 if (pv[SND_DEL].ival > 0 &&
4607 (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) {
4608 printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n");
4613 if (pv[SND_MOV].ival > 0) {
4615 char * p = pv[SND_MOV].sval;
4618 printf("?Sorry, /MOVE-TO not available to guests\n");
4622 #endif /* CK_LOGIN */
4624 if (!isdir(p)) { /* Check directory */
4627 s = (char *)malloc(len + 4);
4629 strcpy(s,p); /* safe */
4631 if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; }
4633 if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; }
4634 #endif /* datageneral */
4640 printf("?Can't create \"%s\"\n",p);
4646 printf("?Directory \"%s\" not found\n",p);
4649 #endif /* CK_MKDIR */
4651 zfnqfp(p,LINBUFSIZ,tmpbuf);
4652 makestr(&snd_move,tmpbuf);
4654 #endif /* CK_TMPDIR */
4656 if (pv[SND_REN].ival > 0) { /* /RENAME */
4657 char * p = pv[SND_REN].sval;
4660 printf("?Sorry, /RENAME-TO not available to guests\n");
4664 #endif /* CK_LOGIN */
4667 printf("?New name required for /RENAME\n");
4673 /* If name given is wild, rename string must contain variables */
4678 if (!strcmp(tmpbuf,p)) {
4680 "?/RENAME for file group must contain variables such as \\v(filename)\n"
4687 makestr(&snd_rename,p);
4690 /* Handle /RECOVER and /START */
4693 if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek
4698 /* VMS sets text/binary automatically later when it opens the file */
4701 #endif /* PATTERNS */
4703 printf("?Sorry, /BINARY required\n");
4707 if (pv[SND_STA].ival > 0) { /* /START */
4709 printf("?Sorry, wildcards not permitted with /START\n");
4713 if (sizeof(int) < 4) {
4714 printf("?Sorry, this command needs 32-bit integers\n");
4719 if (protocol != PROTO_K) {
4720 printf("?Sorry, SEND /START works only with Kermit protocol\n");
4727 if (pv[SND_RES].ival > 0) {
4728 if (protocol != PROTO_K && protocol != PROTO_Z) {
4730 "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n"
4737 #endif /* CK_RESEND */
4739 if (protocol == PROTO_K) {
4740 if ((pv[SND_MAI].ival > 0 || /* MAIL */
4741 pv[SND_PRI].ival > 0 || /* PRINT */
4742 pv[SND_RES].ival > 0 /* RESEND */
4744 (!atdiso || !atcapr)) { /* Disposition attribute off? */
4745 printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n");
4752 if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) {
4754 "Sorry, you can only send one file at a time with XMODEM protocol\n"
4761 if (!confirmed) { /* CR not typed yet, get more fields */
4763 if (mlist) { /* MSEND or MMOVE */
4764 nfils = 0; /* We already have the first one */
4766 msfiles[nfils++] = line; /* Store pointer */
4767 lp = line + (int)strlen(line) + 1; /* Point past it */
4768 debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
4769 while (1) { /* Get more filenames */
4771 if ((x = cmifi("Names of files to send, separated by spaces",
4772 "", &s,&y,xxstring)) < 0) {
4775 if ((x = cmcfm()) < 0)
4779 msfiles[nfils++] = lp; /* Got one, count it, point to it, */
4780 p = lp; /* remember pointer, */
4781 while ((*lp++ = *s++)) /* and copy it into buffer */
4782 if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
4783 printf("?MSEND list too long\n");
4788 debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
4789 if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */
4791 zfnqfp(p,TMPBUFSIZ,tmpbuf);
4794 if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
4795 strcat(fspec,p); /* safe */
4796 strcat(fspec," "); /* safe */
4799 printf("WARNING - \\v(filespec) buffer overflow\n");
4801 debug(F101,"doxsend filespec buffer overflow","",0);
4802 #endif /* COMMENT */
4804 #endif /* NOMSEND */
4805 } else { /* Regular SEND */
4808 if (pv[SND_MAI].ival > 0)
4809 m = (pv[SND_MAI].sval) ?
4810 "e-mail address (optional)" :
4811 "e-mail address (required)";
4812 else if (pv[SND_PRI].ival > 0)
4813 m = "printer options (optional)";
4816 "\nOptional as-name template containing replacement variables \
4817 like \\v(filename)";
4819 m = "Optional name to send it with";
4820 if ((x = cmtxt(m,"",&p,NULL)) < 0)
4823 if (*p) { /* If some text was given... */
4824 p = brstrip(p); /* Replace /AS-NAME: value if any */
4825 if ((y = strlen(p)) > 0) {
4826 if (pv[SND_MAI].ival > 0) {
4827 makestr(&pv[SND_MAI].sval, p);
4829 if (pv[SND_ASN].sval) free(pv[SND_ASN].sval);
4830 pv[SND_ASN].sval = malloc(y+1);
4831 if (pv[SND_ASN].sval) {
4832 strcpy(pv[SND_ASN].sval,p); /* safe */
4833 pv[SND_ASN].ival = 1;
4840 /* Set cmarg2 from as-name, however we got it. */
4842 if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) {
4845 ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1);
4847 debug(F110,"doxsend cmarg2",cmarg2,0);
4851 if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) {
4852 printf("Sorry, /MAIL and /PRINT are conflicting options\n");
4856 n = 0; /* /MAIL or /PRINT? */
4857 if (pv[SND_MAI].ival > 0)
4859 else if (pv[SND_PRI].ival > 0)
4861 if (n) { /* Yes... */
4868 debug(F111,"xsend",p,n);
4871 if (protocol != PROTO_K) {
4872 printf("Sorry, %s available only with Kermit protocol\n",
4873 (n == SND_MAI) ? "/MAIL" : "/PRINT"
4879 debug(F101,"xsend print/mail wild","",wild);
4880 *optbuf = NUL; /* Wipe out any old options */
4881 s = pv[n].sval; /* mail address or print switch val */
4883 debug(F110,"doxsend mail address or printer options",s,0);
4884 if (n == SND_MAI && !*s) {
4885 printf("?E-mail address required\n");
4888 } else if ((int)strlen(s) > 94) { /* Ensure legal size */
4889 printf("?%s too long\n",
4892 "Print option string"
4897 ckstrncpy(optbuf,s,OPTBUFLEN); /* OK, copy to option buffer */
4898 cmarg = line; /* File to send */
4900 debug(F110,"xsend mailing",cmarg,0);
4901 debug(F110,"xsend address:",optbuf,0);
4904 debug(F110,"xsend printing",cmarg,0);
4905 debug(F110,"xsend options",optbuf,0);
4909 #endif /* NOFRILLS */
4912 if (pv[SND_CAL].ival > 0) { /* Handle /CALIBRATE */
4914 calibrate = pv[SND_CAL].ival * 1024L;
4920 #endif /* NOMSEND */
4921 ckstrncpy(line,"CALIBRATION",LINBUFSIZ);
4923 if (!cmarg2) cmarg2 = "";
4924 debug(F110,"doxsend cmarg2 calibrate",cmarg2,0);
4925 } else if (line[0]) {
4927 pv[SND_CAL].ival = 0L;
4930 #endif /* CALIBRATE */
4932 if (pv[SND_FIL].ival > 0) {
4933 if (confirmed && !calibrate) {
4934 if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) {
4935 debug(F110,"xsend can't open",pv[SND_FIL].sval,0);
4936 printf("?Failure to open %s\n",filefile);
4940 makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */
4941 debug(F110,"xsend opened",filefile,0);
4949 if (confirmed && pv[SND_ARR].ival > 0) {
4951 sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE);
4959 if (confirmed && !line[0] && !filefile && !calibrate) {
4961 if (filehead) { /* OK if we have a SEND-LIST */
4962 nfils = filesinlist;
4963 sndsrc = nfils; /* Like MSEND */
4964 addlist = 1; /* But using a different list... */
4965 filenext = filehead;
4968 #endif /* NOMSEND */
4969 printf("?Filename required but not given\n");
4974 /* Not send-list or array */
4977 addlist = 0; /* Don't use SEND-LIST. */
4979 #endif /* NOMSEND */
4981 if (mlist) { /* MSEND or MMOVE */
4983 cmlist = msfiles; /* List of files to send */
4987 #endif /* NOMSEND */
4990 #endif /* PIPESEND */
4991 } else if (filefile) { /* File contains list of filenames */
4999 } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) {
5001 nfils = sndsrc = -1; /* Not MSEND, MMOVE, /LIST, or /ARRAY */
5002 if ( /* or /COMMAND */
5005 !rmailf && !rprintf /* Not MAIL or PRINT */
5008 #endif /* NOFRILLS */
5014 printf("?Read access denied - \"%s\"\n", s);
5018 if (s != line) /* We might already have done this. */
5019 ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */
5021 debug(F110,"doxsend line=s",line,0);
5022 cmarg = line; /* File to send */
5024 zfnqfp(cmarg,fspeclen,fspec);
5026 if (!mlist) { /* For all but MSEND... */
5028 if (pv[SND_CMD].ival > 0) /* /COMMAND sets pipesend flag */
5030 debug(F101,"xsend /COMMAND pipesend","",pipesend);
5031 if (pipesend && filefile) {
5032 printf("?Invalid switch combination\n");
5036 #endif /* PIPESEND */
5039 /* If as-name given and filespec is wild, as-name must contain variables */
5040 debug(F111,"doxsend cmarg2 wild",cmarg2,wild);
5041 if (wild && *cmarg2) {
5044 zzstring(cmarg2,&s,&x);
5045 if (!strcmp(tmpbuf,cmarg2)) {
5047 "?As-name for file group must contain variables such as \\v(filename)\n"
5055 /* Strip braces from as-name */
5056 debug(F110,"xsend cmarg2 before stripping",cmarg2,0);
5057 cmarg2 = brstrip(cmarg2);
5058 debug(F110,"xsend filename",cmarg,0);
5059 debug(F110,"xsend as-name",cmarg2,0);
5061 /* Copy as-name to a safe place */
5067 if ((y = strlen(cmarg2)) > 0) {
5068 asnbuf = (char *) malloc(y + 1);
5070 strcpy(asnbuf,cmarg2); /* safe */
5076 debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival);
5077 if (pv[SND_STA].ival > -1) { /* /START position */
5079 printf("?/STARTING-AT may not be used with multiple files.\n");
5083 sendstart = pv[SND_STA].ival;
5086 debug(F101,"xsend /STARTING","",sendstart);
5087 #endif /* CK_RESEND */
5090 sendend: /* Common successful exit */
5092 if (pv[SND_SHH].ival > 0) { /* SEND /QUIET... */
5095 debug(F101,"xsend display","",fdispla);
5098 #ifndef NOSPL /* SEND /ARRAY... */
5099 if (pv[SND_ARR].ival > 0) {
5100 if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */
5101 if (range[0] == -1) /* If low end of range not specified */
5102 range[0] = 1; /* default to 1 */
5103 if (range[1] == -1) /* If high not specified */
5104 range[1] = a_dim[arrayx]; /* default to size of array */
5105 if ((range[0] < 0) || /* Check range */
5106 (range[0] > a_dim[arrayx]) ||
5107 (range[1] < range[0]) ||
5108 (range[1] > a_dim[arrayx])) {
5109 printf("?Bad array range - [%d:%d]\n",range[0],range[1]);
5113 sndarray = ap; /* Array pointer */
5114 sndxin = arrayx; /* Array index */
5115 sndxlo = range[0]; /* Array range */
5117 sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE);
5120 printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */
5121 (sndxin == 1) ? 64 : sndxin + ARRAYBASE);
5122 printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi);
5123 printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2);
5124 while ((x = agnbyte()) > -1) {
5128 #endif /* COMMENT */
5132 if (pv[SND_ARR].ival < 1) { /* File selection & disposition... */
5134 if (pv[SND_DEL].ival > 0) /* /DELETE was specified */
5136 debug(F101,"xsend /DELETE","",moving);
5137 if (pv[SND_AFT].ival > 0) /* Copy SEND criteria */
5138 ckstrncpy(sndafter,pv[SND_AFT].sval,19);
5139 if (pv[SND_BEF].ival > 0)
5140 ckstrncpy(sndbefore,pv[SND_BEF].sval,19);
5141 if (pv[SND_NAF].ival > 0)
5142 ckstrncpy(sndnafter,pv[SND_NAF].sval,19);
5143 if (pv[SND_NBE].ival > 0)
5144 ckstrncpy(sndnbefore,pv[SND_NBE].sval,19);
5145 if (pv[SND_EXC].ival > 0)
5146 makelist(pv[SND_EXC].sval,sndexcept,NSNDEXCEPT);
5147 if (pv[SND_SMA].ival > -1)
5148 sndsmaller = pv[SND_SMA].ival;
5149 if (pv[SND_LAR].ival > -1)
5150 sndlarger = pv[SND_LAR].ival;
5151 if (pv[SND_NAM].ival > -1) {
5152 g_fncnv = fncnv; /* Save global value */
5153 fncnv = pv[SND_NAM].ival;
5154 debug(F101,"xsend fncnv","",fncnv);
5156 if (pv[SND_PTH].ival > -1) {
5157 g_spath = fnspath; /* Save global values */
5158 fnspath = pv[SND_PTH].ival;
5160 if (fnspath != PATH_OFF) {
5161 g_fncnv = fncnv; /* Bad bad... */
5165 debug(F101,"xsend fnspath","",fnspath);
5166 debug(F101,"xsend fncnv","",fncnv);
5171 if (pv[SND_FLT].ival > 0) {
5172 makestr(&sndfilter,pv[SND_FLT].sval);
5173 debug(F110,"xsend /FILTER", sndfilter, 0);
5175 #endif /* PIPESEND */
5178 /* MOVE not allowed in APCs */
5180 (apcactive == APC_LOCAL || apcactive == APC_REMOTE)
5181 && !(apcstatus & APC_UNCH))
5182 return(success = 0);
5187 protocol == PROTO_K &&
5189 !iks_wait(KERMIT_REQ_START,1)) {
5190 printf("?A Kermit Server is not available to process this command.\n");
5191 printf("?Start a RECEIVE command to complement this command.\n");
5193 #endif /* IKS_OPTION */
5197 if (moving && inserver && isguest) {
5198 printf("?File deletion not allowed for guests.\n");
5201 #endif /* CK_LOGIN */
5204 sstate = 's'; /* Set start state to SEND */
5207 if (pv[SND_RES].ival > 0) /* Send sendmode appropriately */
5208 sendmode = SM_RESEND;
5209 else if (pv[SND_STA].ival > 0)
5210 sendmode = SM_PSEND;
5212 #endif /* CK_RESEND */
5214 sendmode = SM_MSEND;
5221 if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */
5222 displa = 1; /* turn on file transfer display */
5226 xsendx: /* Common exit, including failure */
5227 debug(F101,"doxsend sndsrc","",sndsrc);
5228 for (i = 0; i <= SND_MAX; i++) { /* Free malloc'd memory */
5237 /* D O X C O N N -- CONNECT command parsing with switches */
5240 #define XLIMORTRIGGER
5243 #define XLIMORTRIGGER
5244 #endif /* CK_TRIGGER */
5245 #endif /* XLIMITS */
5248 int tt_idlelimit = 0; /* Terminal idle limit */
5249 int tt_idleact = IDLE_RET; /* Terminal idle action */
5250 #endif /* CKTIDLE */
5252 #ifdef OS2 /* K95 only: */
5254 tt_idlesnd_tmo; /* Idle interval */
5255 int tt_timelimit = 0; /* Time limit, 0 = none */
5256 extern char * /* Parse results - strings: */
5257 tt_idlesnd_str; /* Idle string */
5261 extern char *tt_trigger[];
5262 extern CHAR *tt_trmatch[];
5263 extern char *triggerval;
5264 static char *g_tt_trigger[TRIGGERS];
5265 #endif /* CK_TRIGGER */
5268 static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */
5269 static int g_tt_idlelimit, g_tt_saved = 0;
5270 static char * g_tt_idlesnd_str; /* global settings */
5273 static struct stringint { /* Temporary array for switch values */
5284 tt_idlelimit = g_tt_idlelimit;
5285 tt_idlesnd_tmo = g_tt_idlesnd_tmo;
5286 tt_timelimit = g_tt_timelimit;
5287 tt_idlesnd_str = g_tt_idlesnd_str;
5293 for (i = 0; i < TRIGGERS; i++)
5294 tt_trigger[i] = g_tt_trigger[i];
5295 #endif /* CK_TRIGGER */
5297 for (i = 0; i <= CONN_MAX; i++) { /* Free malloc'd memory */
5305 doxconn(cx) int cx; {
5306 int c, i, n; /* Workers */
5308 int getval = 0; /* Whether to get switch value */
5309 int async = 0; /* Make an async connect */
5310 struct FDB sw, cm; /* FDBs for each parse function */
5311 extern FILE * tfile[];
5312 extern char * macp[];
5315 g_tt_idlesnd_tmo = tt_idlesnd_tmo; /* Save global settings */
5316 g_tt_timelimit = tt_timelimit;
5317 g_tt_idlelimit = tt_idlelimit;
5318 g_tt_idlesnd_str = tt_idlesnd_str;
5323 if (!tt_trigger[0]) { /* First initialization */
5324 for (i = 1; i < TRIGGERS; i++)
5325 tt_trigger[i] = NULL;
5327 for (i = 0; i < TRIGGERS; i++)
5328 g_tt_trigger[i] = tt_trigger[i];
5333 #endif /* CK_TRIGGER */
5335 for (i = 0; i <= CONN_MAX; i++) { /* Initialize switch values */
5336 pv[i].sval = NULL; /* to null pointers */
5337 pv[i].ival = -1; /* and -1 int values */
5339 if (cx == XXCQ) /* CQ == CONNECT /QUIETLY */
5340 pv[CONN_NV].ival = 1;
5342 /* Set up chained parse functions... */
5344 cmfdbi(&sw, /* First FDB - command switches */
5346 "Switch", /* hlpmsg */
5348 "", /* addtl string data */
5349 nconntab, /* addtl numeric data 1: tbl size */
5350 4, /* addtl numeric data 2: 4 = cmswi */
5351 xxstring, /* Processing function */
5352 conntab, /* Keyword table */
5353 &cm /* Pointer to next FDB */
5355 cmfdbi(&cm, /* 2nd FDB - Confirmation */
5359 "", /* addtl string data */
5360 0, /* addtl numeric data 1 */
5361 0, /* addtl numeric data 2 */
5367 while (1) { /* Parse 0 or more switches */
5368 x = cmfdb(&sw); /* Parse switch or confirmation */
5369 debug(F101,"doxconn cmfdb","",x);
5370 if (x < 0) { /* Error */
5371 if (x == -9 || x == -2)
5372 printf("?No switches match - \"%s\"\n",atmbuf);
5373 goto xconnx; /* or reparse needed */
5375 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
5377 c = cmgbrk(); /* Get break character */
5378 getval = (c == ':' || c == '='); /* to see how they ended the switch */
5379 if (getval && !(cmresult.kflags & CM_ARG)) {
5380 printf("?This switch does not take arguments\n");
5384 if (!getval && (cmgkwflgs() & CM_ARG)) {
5385 printf("?This switch requires an argument\n");
5388 n = cmresult.nresult; /* Numeric result = switch value */
5389 debug(F101,"doxconn switch","",n);
5391 switch (n) { /* Process the switch */
5393 case CONN_AS: /* Asynchronous */
5394 pv[CONN_AS].ival = 1;
5395 pv[CONN_SY].ival = 0;
5397 case CONN_SY: /* Synchronous */
5398 pv[CONN_SY].ival = 1;
5399 pv[CONN_AS].ival = 0;
5402 case CONN_NV: /* Non-verbal */
5406 case CONN_II: /* Idle-interval */
5407 case CONN_IL: /* Idle-limit */
5408 case CONN_TL: /* Time-limit */
5410 if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
5414 case CONN_IS: /* Idle-string */
5415 #endif /* XLIMITS */
5417 case CONN_TS: /* Trigger-string */
5418 #endif /* CK_TRIGGER */
5419 #ifdef XLIMORTRIGGER
5421 if ((x = cmfld("String (enclose in braces if it contains spaces)",
5422 "",&s,xxstring)) < 0) {
5424 printf("?String required\n");
5431 if ((y = strlen(s)) > 0) {
5432 if (pv[n].sval) free(pv[n].sval);
5433 pv[n].sval = malloc(y+1);
5435 strcpy(pv[n].sval,s); /* safe */
5440 #endif /* XLIMORTRIGGER */
5442 printf("?Unexpected switch value - %d\n",cmresult.nresult);
5447 debug(F101,"doxconn cmresult.fcode","",cmresult.fcode);
5448 if (cmresult.fcode != _CMCFM) {
5449 printf("?Unexpected function code: %d\n",cmresult.fcode);
5454 /* Command was confirmed so we can pre-pop command level. */
5455 /* This is so CONNECT module won't think we're executing a script */
5456 /* if CONNECT was the final command in the script. */
5461 #ifdef OS2 /* Make results available globally */
5462 if (pv[CONN_IL].ival > -1) /* Idle limit */
5463 tt_idlelimit = pv[CONN_IL].ival;
5464 if (pv[CONN_II].ival > -1) /* Idle limit */
5465 tt_idlesnd_tmo = pv[CONN_II].ival;
5466 if (pv[CONN_IS].sval) /* Idle string */
5467 if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1))
5468 strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */
5469 if (pv[CONN_TL].ival > -1) /* Session limit */
5470 tt_timelimit = pv[CONN_TL].ival;
5471 async = (pv[CONN_AS].ival > 0 ||
5472 pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0;
5476 if (pv[CONN_TS].sval) /* Trigger strings */
5477 makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS);
5478 for (i = 0; i < TRIGGERS; i++) /* Trigger match pointers */
5479 tt_trmatch[i] = NULL;
5480 if (triggerval) { /* Reset trigger value */
5484 #endif /* CK_TRIGGER */
5486 x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async);
5489 debug(F101,"doxconn doconect returns","",x);
5490 if ((xx = ttchk()) < 0) dologend();
5491 debug(F101,"doxconn ttchk returns","",xx);
5495 debug(F111,"doxconn doconect triggerval",triggerval,x);
5496 #endif /* CK_TRIGGER */
5499 /* Back from CONNECT -- Restore global settings */
5504 success = (x > 0) ? 1 : 0;
5507 #endif /* NOLOCAL */
5510 /* cx == XXADD or XXREMV */
5511 /* fc == ADD_BIN or ADD_TXT */
5513 doadd(cx,fc) int cx, fc; {
5515 char * tmp[FTPATTERNS];
5517 int i, j, k, n = 0, x = 0, last;
5519 #endif /* PATTERNS */
5520 if (cx != XXADD && cx != XXREMV) {
5521 printf("?Unexpected function code: %d\n",cx);
5525 while (n < FTPATTERNS) { /* Collect new patterns */
5527 if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
5529 ckstrncpy(line,s,LINBUFSIZ);
5531 makestr(&(tmp[n++]),s);
5537 p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */
5539 for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */
5545 if (cx == XXADD) { /* Adding */
5546 if (last + n > FTPATTERNS) { /* Check if too many */
5547 printf("?Too many patterns - %d is the maximum\n", FTPATTERNS);
5550 for (i = 0; i < n; i++) { /* Copy in the new ones. */
5551 for (j = 0, x = 0; x == 0 && j < last ; j++ )
5552 x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
5554 makestr(&(p[last++]),tmp[i]);
5556 makestr(&(p[last]),NULL); /* Null-terminate the list */
5558 goto xdoadd; /* Done */
5559 } else if (cx == XXREMV) { /* Remove something(s) */
5561 if (last == 0) /* List is empty */
5562 goto xdoadd; /* Nothing to remove */
5563 for (i = 0; i < n; i++) { /* i = Patterns they typed */
5564 for (j = 0; j < last; j++) { /* j = Patterns in list */
5565 /* Change this to ckstrcmp()... */
5567 x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
5569 x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */
5570 if (x) { /* This one matches */
5571 makestr(&(p[j]),NULL); /* Free it */
5572 for (k = j; k < last; k++) /* Move the rest up */
5574 p[k] = NULL; /* Erase last one */
5581 xdoadd: /* Common exit */
5582 for (i = 0; i < n; i++)
5586 #endif /* PATTERNS */
5592 addsend(cx) int cx; {
5594 extern struct keytab fttab[];
5596 struct filelist * flp;
5600 #endif /* NOMSEND */
5603 printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n");
5605 #endif /* NOMSEND */
5607 printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n");
5611 #ifndef XYZ_INTERNAL
5612 if (protocol != PROTO_K) {
5613 printf("?Sorry, ADD SEND-LIST does not work with external protocols\n");
5616 #endif /* XYZ_INTERNAL */
5618 x = cmifi("File specification to add","", &s,&y,xxstring);
5621 printf("?A file specification is required\n");
5626 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
5628 if (filesinlist == 0) /* Take care of \v(filespec) */
5630 zfnqfp(s,LINBUFSIZ,line);
5632 if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) {
5633 strcat(fspec,s); /* safe */
5634 strcat(fspec," "); /* safe */
5636 printf("WARNING - \\v(filespec) buffer overflow\n");
5640 if ((patterns || filepeek) /* FILE PATTERNS or SCAN is ON */
5642 && binary != XYFT_L /* And not if FILE TYPE LABELED */
5643 #endif /* CK_LABELED */
5645 && binary != XYFT_I /* or FILE TYPE IMAGE */
5650 k = scanfile(line,&x,nscanfile);
5651 if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
5653 fmode = gfmode(xbinary,0);
5654 if ((x = cmkey(fttab,nfttyp,
5655 "type of file transfer", fmode, xxstring)) < 0)
5661 "\nAs-name template containing replacement variables such as \\v(filename)" :
5662 "Name to send it with", "",&s,NULL)) < 0)
5670 if (!strcmp(tmpbuf,s)) {
5672 "?As-name for file group must contain variables such as \\v(filename)\n"
5678 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
5681 if ((x = cmcfm()) < 0)
5683 flp = (struct filelist *) malloc(sizeof(struct filelist));
5686 filetail->fl_next = flp;
5690 x = (int) strlen(line); /* Length of filename */
5691 s = (char *) malloc(x + 1);
5693 strcpy(s,line); /* safe */
5695 flp->fl_mode = xmode;
5696 x = (int) strlen(cmarg2); /* Length of as-name */
5698 flp->fl_alias = NULL;
5700 s = (char *) malloc(x + 1);
5702 strcpy(s,cmarg2); /* safe */
5705 printf("Sorry, can't allocate space for as-name");
5709 flp->fl_next = NULL;
5710 filesinlist++; /* Count this node */
5711 return(success = 1); /* Finished adding this node */
5713 printf("Sorry, can't allocate space for name");
5717 printf("Sorry, can't allocate file list node");
5720 #endif /* NOMSEND */
5724 #ifndef NOHTTP /* HTTP ops... */
5726 #define HTTP_GET 0 /* GET */
5727 #define HTTP_PUT 1 /* PUT */
5728 #define HTTP_POS 2 /* POST */
5729 #define HTTP_IDX 3 /* INDEX */
5730 #define HTTP_HED 4 /* HEAD */
5731 #define HTTP_DEL 5 /* DELETE */
5732 #define HTTP_CON 6 /* CONNECT */
5733 #define HTTP_OPN 7 /* OPEN */
5734 #define HTTP_CLS 8 /* CLOSE */
5736 static struct keytab httptab[] = {
5737 { "close", HTTP_CLS, 0 },
5738 { "connect", HTTP_CON, 0 },
5739 { "delete", HTTP_DEL, 0 },
5740 { "get", HTTP_GET, 0 },
5741 { "head", HTTP_HED, 0 },
5742 { "index", HTTP_IDX, 0 },
5743 { "open", HTTP_OPN, 0 },
5744 { "put", HTTP_PUT, 0 },
5745 { "post", HTTP_POS, 0 }
5747 static int nhttptab = sizeof(httptab)/sizeof(struct keytab);
5750 #define HT_SW_AG 0 /* /AGENT */
5751 #define HT_SW_HD 1 /* /HEADER */
5752 #define HT_SW_US 2 /* /USER */
5753 #define HT_SW_PW 3 /* /PASSWORD */
5754 #define HT_SW_AR 4 /* /ARRAY */
5755 #define HT_SW_TP 5 /* /TOSCREEN */
5757 static struct keytab httpswtab[] = {
5758 { "/agent", HT_SW_AG, CM_ARG },
5760 { "/array", HT_SW_AR, CM_ARG },
5762 { "/header", HT_SW_HD, CM_ARG },
5763 { "/password", HT_SW_PW, CM_ARG },
5764 { "/toscreen", HT_SW_TP, 0 },
5765 { "/user", HT_SW_US, CM_ARG },
5768 static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1;
5770 /* HTTP PUT/POST switches */
5771 #define HT_PP_MT 0 /* /MIME-TYPE */
5773 static struct keytab httpptab[] = {
5774 { "/mime-type", HT_PP_MT, CM_ARG },
5777 static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1;
5779 #define HTTP_MAXHDR 8
5782 xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type)
5784 char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array;
5788 char * hdrlist[HTTP_MAXHDR];
5789 char rfile[CKMAXPATH+1];
5792 /* Check for a valid state to execute the command */
5794 printf("?The HTTP command may not be used from the IKS\r\n");
5795 } else if (httpfd == -1) {
5796 if (http_reopen() < 0)
5797 printf("?No connection\n");
5804 /* If the command is not valid, exit with failure */
5806 return(success = 0);
5808 if (action != HTTP_CON && rf[0] != '/') {
5810 ckstrncpy(&rfile[1],rf,CKMAXPATH);
5812 ckstrncpy(rfile,rf,CKMAXPATH);
5814 for (i = 0; i < HTTP_MAXHDR; i++) /* Initialize header list */
5816 makelist(hdr,hdrlist,HTTP_MAXHDR); /* Make header list */
5819 for (i = 0; i < nhttptab; i++) /* Find action keyword */
5820 if (httptab[i].kwval == action)
5822 if (i == nhttptab) { /* Shouldn't happen... */
5823 printf("?Invalid action - %d\n",action);
5824 return(0); /* Failure */
5827 printf("HTTP action: %s\n",httptab[i].kwd);
5828 printf(" Agent: %s\n",agent ? agent : "(null)");
5831 printf(" Header list: 1. %s\n",hdrlist[0]);
5832 for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++)
5833 printf("%15d. %s\n",i+1,hdrlist[i]);
5835 printf(" Header: %s\n",hdrlist[0] ? hdrlist[0] : "(null)");
5837 printf(" User: %s\n",user ? user : "(null)");
5839 printf(" Password: %s\n",pass ? pass : "(null)");
5840 #endif /* COMMENT */
5844 printf(" Array: \\%%%c[]\n", array);
5846 printf(" Array: (none)\n");
5849 if (action == HTTP_PUT || action == HTTP_POS)
5850 printf(" Mime-type: %s\n",mime ? mime : "(null)");
5852 printf(" Local file: %s\n",lfile ? lfile : "(null)");
5853 printf(" Remote file: %s\n",rfile ? rfile : "(null)");
5854 printf(" Destination file: %s\n",dfile ? dfile : "(null)");
5855 #endif /* BETADEBUG */
5857 /* The http_xxxx() functions return 0 on success, -1 on failure */
5861 rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile);
5865 rc = http_delete(agent,hdrlist,user,pass,array,rfile);
5868 rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type);
5871 rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type);
5874 rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
5878 rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
5882 rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type);
5887 return(rc == 0 ? 1 : 0); /* Success is set by caller */
5889 #endif /* TCPSOCKET */
5892 #ifndef NOSPL /* ARRAY ops... */
5893 static struct keytab arraytab[] = {
5894 { "clear", ARR_CLR, 0 },
5895 { "copy", ARR_CPY, 0 },
5896 { "dcl", ARR_DCL, CM_INV },
5897 { "declare", ARR_DCL, 0 },
5898 { "destroy", ARR_DST, CM_INV },
5899 { "equate", ARR_EQU, CM_INV },
5900 { "link", ARR_EQU, 0 },
5901 { "resize", ARR_RSZ, 0 },
5902 { "set", ARR_SET, 0 },
5904 { "show", ARR_SHO, 0 },
5906 { "sort", ARR_SRT, 0 },
5907 { "undeclare", ARR_DST, 0 },
5910 static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1;
5913 static struct keytab learnswi[] = {
5918 #endif /* CKLEARN */
5921 arrayitoa(x) int x; { /* Array index to array letter */
5924 else if (x < 0 || x > (122 - ARRAYBASE))
5927 return(x + ARRAYBASE);
5931 arrayatoi(c) int c; { /* Array letter to array index */
5934 if (c > 63 && c < 91)
5936 if (c < ARRAYBASE || c > 122)
5938 return(c - ARRAYBASE);
5941 static int /* Declare an array */
5943 int i, n, v, lo, hi, rc = 0;
5947 char tmp[64]; /* Local temporary string buffer */
5948 if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
5950 printf("?Array name required\n");
5954 ckstrncpy(line,s,LINBUFSIZ);
5956 x = arraybounds(s,&lo,&hi); /* Check syntax and get bounds */
5957 debug(F111,"dodcl arraybounds",s,x);
5958 if (x < 0) { /* Error - Maybe it's a variable */
5959 char * p; /* whose value is an array name */
5964 if (s[0] == CMDQ && s[1] == '&')
5966 if (zzstring(s,&p,&n) > -1) {
5968 x = arraybounds(s,&lo,&hi);
5969 debug(F111,"dodcl arraybounds 2",s,x);
5972 printf("?Bad array name - \"%s\"\n",s);
5976 debug(F101,"dodcl hi","",hi);
5977 debug(F101,"dodcl lo","",lo);
5978 debug(F101,"dodcl lo+1","",lo+1);
5980 if (lo == -1 && hi == -1) { /* Have good array name and bounds */
5983 } else if (hi > -1) {
5984 printf("?Segment notation not allowed in array declarations\n");
5986 } else if ((lo+1) < 0) {
5987 debug(F101,"dodcl underflow","",lo+1);
5988 printf("?Dimension underflow\n");
5993 if (cx == XXUNDCL) {
5996 if ((y = cmcfm()) < 0)
5999 p = (char **)malloc(sizeof(char **)*(n+1));
6001 printf("?Memory allocation error\n");
6004 v = 0; /* Highest initialized member */
6005 p[0] = NULL; /* Element 0 */
6007 while (n > 0 && v < n) { /* Parse initializers */
6011 "Initial value for \\&",
6016 NULL,NULL,NULL,NULL,NULL,NULL,NULL
6018 if ((rc = cmfld((char *)tmp,"",&s,xxstring)) < 0) { /* Get field */
6019 if (rc == -3) /* If answer is empty, we're done */
6021 else /* Parse error, free temp pointers */
6025 if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */
6027 s = brstrip(s); /* Strip any braces */
6028 makestr(&(p[++v]),s);
6031 if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0)
6036 if (dclarray((char)x,n) < 0) { /* Declare the array */
6037 printf("?Declare failed\n");
6040 for (i = 1; i <= v; i++) { /* Add any initial values */
6042 ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]");
6043 if (addmac(tmp,p[i]) < 0) {
6044 printf("Array initialization error: %s %s\n",tmp,p[i]);
6051 for (i = 1; i <= v; i++)
6052 if (p[i]) free(p[i]);
6055 debug(F101,"DCL rc","",rc);
6056 return(success = rc);
6061 int i, x, y, n, lo, hi, islink = -1;
6062 char c, * s, ** ap = NULL;
6063 if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
6065 printf("?Array name required\n");
6069 ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
6071 x = arraybounds(s,&lo,&hi);
6072 if (x < 0) { /* Parse the name, get index */
6073 printf("?Bad array reference - \"%s\"\n", s);
6076 if (lo < 0 && hi < 0) {
6077 y = cmnum("New size","",10,&lo,xxstring);
6080 printf("?New size required\n");
6084 if ((y = cmcfm()) < 0)
6086 if (a_link[x] > -1) { /* Link? */
6087 islink = x; /* Yes follow it */
6088 x = a_link[x]; /* and remember */
6091 printf("?Array not declared - \"%s\"\n", s);
6095 printf("?New size required\n");
6099 printf("?Array segments not allowed for this operation\n");
6102 c = arrayitoa(x); /* Get array letter */
6103 if (c == '@') { /* Argument vector array off limits */
6104 printf("?Sorry, \\&@[] is read-only\n");
6107 if (lo == 0) { /* If new size is 0... */
6108 dclarray(c,0); /* Undeclare the array */
6109 return(success = 1);
6111 n = a_dim[x]; /* Current size */
6112 ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */
6113 y = (n < lo) ? n : lo;
6114 for (i = 0; i <= y; i++) /* Copy the part that fits */
6115 ap[i] = a_ptr[x][i];
6116 if (n < lo) { /* If original array smaller */
6117 for (; i <= lo; i++) /* initialize extra elements in */
6118 ap[i] = NULL; /* new array to NULL. */
6119 } else if (n > lo) { /* If new array smaller */
6120 for (; i <= lo; i++) /* deallocate leftover elements */
6121 makestr(&(a_ptr[x][i]),NULL); /* from original array. */
6123 free((char *)a_ptr[x]); /* Free original array list */
6124 a_ptr[x] = ap; /* Replace with new one */
6125 a_dim[x] = lo; /* Record the new dimension */
6126 if (islink > -1) { /* Was this a link? */
6127 a_ptr[islink] = ap; /* If so point to the resized array */
6129 } else { /* If not are there links to here? */
6130 for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
6131 if (i != x && a_link[i] == x) { /* Find and update them */
6137 return(success = 1);
6142 int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0;
6143 char c1, c2, * a1, * a2;
6144 if ((y = cmfld("Name of source array","",&s,NULL)) < 0)
6146 ckstrncpy(line,s,LINBUFSIZ);
6148 if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) {
6149 printf("?Bad array reference - \"%s\"\n", a1);
6151 } else if (!a_ptr[x1]) {
6152 printf("?Array not declared - \"%s\"\n", a1);
6157 if ((y = cmfld("Name of destination array","",&s,NULL)) < 0)
6159 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
6161 if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) {
6162 printf("?Bad array reference - \"%s\"\n", a2);
6167 if ((x = cmcfm()) < 0)
6170 if (c2 == '@') { /* Argument vector array off limits */
6171 printf("?Sorry, \\&@[] is read-only\n");
6174 if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */
6175 whole = 1; /* whole array... */
6177 if (lo1 < 0) lo1 = whole ? 0 : 1; /* Supply lower bound of source */
6178 if (hi1 < 0) hi1 = a_dim[x1]; /* Supply upper bound of source */
6179 if (lo2 < 0) lo2 = whole ? 0 : 1; /* Lower bound of target */
6180 if (hi2 < 0) hi2 = lo2 + hi1 - lo1; /* Upper bound of target */
6181 if (a_ptr[x2]) { /* Target array is already declared? */
6182 if (hi2 > a_dim[x2]) /* If upper bound out of range */
6183 hi2 = a_dim[x2]; /* shrink to fit */
6184 } else { /* Otherwise... */
6185 x2 = dclarray(c2, hi2); /* declare the target array */
6187 for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */
6188 makestr(&(a_ptr[x2][j]),a_ptr[x1][i]);
6190 return(success = 1);
6193 static int /* Undeclare an array */
6195 int x, y, n, rc = 0;
6198 if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
6200 printf("?Array name required\n");
6204 ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
6206 if ((y = cmcfm()) < 0)
6208 if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */
6209 printf("?Bad array reference - \"%s\"\n", s);
6212 if (y > 0 || n > 0) {
6213 printf("?Partial arrays can not be destroyed\n");
6216 c = arrayitoa(x); /* Get array letter */
6217 if (a_ptr[x]) { /* If array is declared */
6218 if (c == '@') { /* Argument vector array off limits */
6219 printf("?Sorry, \\&@[] is read-only\n");
6222 rc = dclarray(c,0); /* Undeclare the array */
6223 } else /* It wasn't declared */
6225 if (rc > -1) { /* Set return code and success */
6230 printf("?Failed - destroy \"\\&%c[]\"\n", c);
6237 clrarray(cx) int cx; {
6239 char c, * s, * val = NULL;
6241 if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
6243 printf("?Array name required\n");
6247 ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
6249 if (cx == ARR_SET) { /* SET */
6250 if ((x = cmtxt("Value","",&val,xxstring)) < 0)
6252 ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */
6254 if (!*val) val = NULL;
6255 } else if ((x = cmcfm()) < 0) /* CLEAR */
6258 if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */
6259 printf("?Bad array reference - \"%s\"\n", s);
6262 c = arrayitoa(x); /* Get array letter */
6263 if (!a_ptr[x]) { /* If array is declared */
6264 printf("?Array %s is not declared\n", s);
6266 } else if (c == '@') { /* Argument vector array off limits */
6267 printf("?Sorry, \\&@[] is read-only\n");
6271 if (hi < 0) hi = a_dim[x];
6272 for (i = lo; i <= hi; i++) /* Clear/Set selected range */
6273 makestr(&(a_ptr[x][i]),val);
6275 return(success = 1);
6278 extern char **aa_ptr[CMDSTKL][28];
6279 extern int aa_dim[CMDSTKL][28];
6281 static int /* Create symbolic link to an array */
6283 int i = 0, x, y, lo, hi, flag = 0;
6286 if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) {
6288 printf("?Array name required\n");
6292 ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of link name */
6294 if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) {
6296 printf("?Array name required\n");
6300 ckstrncpy(tmpbuf,p,TMPBUFSIZ); /* Make safe copy of array name */
6302 if ((x = cmcfm()) < 0)
6305 if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */
6306 printf("?Bad array reference - \"%s\"\n", s);
6309 if (a_ptr[x]) { /* Must not already exist */
6311 printf("?Array already exists: \\&%c[]\n", c);
6314 if (lo > -1 || hi > -1) {
6315 printf("?Sorry, whole arrays only: %s\n",s);
6318 if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */
6319 printf("?Bad array reference - \"%s\"\n", s);
6322 if (lo > -1 || hi > -1) {
6323 printf("?Sorry, whole arrays only: %s\n",p);
6327 for (i = cmdlvl; i >= 0; i--)
6334 a_ptr[x] = aa_ptr[i][y]; /* Link to saved copy */
6335 a_dim[x] = aa_dim[i][y];
6336 } else { /* Otherwise... */
6337 c = arrayitoa(y); /* Check if it's declared */
6339 printf("?Array is not declared: \\&%c[]\n", c);
6342 if (a_link[y] > -1) { /* And if it's a link itself */
6343 printf("?Links to links not allowed: \\&%c[]\n", c);
6346 a_ptr[x] = a_ptr[y]; /* All OK, make the link */
6347 a_dim[x] = a_dim[y];
6350 return(success = 1);
6355 static char * dcsetname = NULL;
6357 /* Get Display Character-Set Name */
6364 extern int tt_font, ntermfont;
6365 extern struct keytab term_font[];
6366 #endif /* PCFONTS */
6370 y = os2getcp(); /* Default is current code page */
6372 case 437: s = "cp437"; break;
6373 case 850: s = "cp850"; break;
6374 case 852: s = "cp852"; break;
6375 case 857: s = "cp857"; break;
6376 case 858: s = "cp858"; break;
6377 case 862: s = "cp862"; break;
6378 case 866: s = "cp866"; break;
6379 case 869: s = "cp869"; break;
6380 case 1250: s = "cp1250"; break;
6381 case 1251: s = "cp1251"; break;
6382 case 1252: s = "cp1252"; break;
6383 case 1253: s = "cp1253"; break;
6384 case 1254: s = "cp1254"; break;
6385 case 1255: s = "cp1255"; break;
6386 case 1256: s = "cp1256"; break;
6387 case 1257: s = "cp1257"; break;
6388 case 1258: s = "cp1258"; break;
6392 If the user has loaded a font with SET TERMINAL FONT then we want
6393 to change the default code page to the font that was loaded.
6395 if (tt_font != TTF_ROM) {
6396 for (y = 0; y < ntermfont; y++ ) {
6397 if (term_font[y].kwval == tt_font) {
6398 s = term_font[y].kwd;
6403 #endif /* PCFONTS */
6406 /* Hack not needed as of C-Kermit 7.1 */
6407 if (fcharset == FC_1LATIN) {
6408 s = "latin1-iso"; /* Hack to avoid reporting "cp1252" */
6409 } else { /* Report current file character set */
6410 #endif /* COMMENT */
6411 for (y = 0; y <= nfilc; y++)
6412 if (fcstab[y].kwval == fcharset) {
6418 #endif /* COMMENT */
6420 makestr(&dcsetname,s); /* Return stable pointer */
6421 return((char *)dcsetname);
6423 #endif /* NOCSETS */
6428 if ((x = cmkey(clrtab,nclear,"item to clear",
6434 ,xxstring)) < 0) return(x);
6437 if (x == CLR_CMD || x == CLR_TRM) {
6438 if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n",
6439 "all",xxstring)) < 0)
6444 if ((y = cmcfm()) < 0)
6447 /* Clear device input buffer if requested */
6448 y = (x & CLR_DEV) ? ttflui() : 0;
6450 if (x & CLR_SCR) /* CLEAR SCREEN */
6451 y = ck_cls(); /* (= SCREEN CLEAR = CLS) */
6453 if (x & CLR_KBD) { /* CLEAR KEYBOARD */
6457 while (n-- > 0 && (y = coninc(0) > -1))
6459 y = (y > -1) ? 0 : -1;
6463 /* Clear INPUT command buffer if requested */
6465 for (z = 0; z < inbufsize; z++)
6472 debug(F101,"Executing CLEAR APC","",apcactive);
6484 if (x & (CLR_TXT|CLR_BIN)) {
6486 for (i = 0; i < FTPATTERNS; i++) {
6488 makestr(&txtpatterns[i],NULL);
6490 makestr(&binpatterns[i],NULL);
6494 #endif /* PATTERNS */
6504 if (x & CLR_SFL) { /* CLEAR SEND-LIST */
6506 struct filelist * flp, * next;
6512 free(flp->fl_alias);
6513 next = flp->fl_next;
6524 #endif /* NOMSEND */
6530 clearscrollback(VTERM);
6538 clrboscr_escape(VCMD,SP);
6541 clrbol_escape(VCMD,SP);
6547 clreoscr_escape(VCMD,SP);
6550 clrline_escape(VCMD,SP);
6553 clearscrollback(VCMD);
6556 printf("Not implemented yet, sorry.\n");
6565 if (VscrnGetBufferSize(VTERM) > 0 ) {
6566 VscrnScroll(VTERM, UPWARD, 0,
6567 VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1),
6568 VscrnGetHeight(VTERM) -
6569 (tt_status[VTERM]?1:0), TRUE, SP
6571 cleartermscreen(VTERM);
6575 clrboscr_escape(VTERM,SP);
6578 clrbol_escape(VTERM,SP);
6581 clrtoeoln(VTERM,SP);
6584 clreoscr_escape(VTERM,SP);
6587 clrline_escape(VTERM,SP);
6590 clearscrollback(VTERM);
6593 printf("Not implemented yet, sorry.\n");
6600 #endif /* NOLOCAL */
6602 return(success = (y == 0));
6604 #endif /* NOFRILLS */
6608 doeval(cx) int cx; {
6610 char vnambuf[VNAML], * vnp = NULL; /* These must be on the stack */
6612 if ((y = cmfld("Variable name","",&s,
6613 ((cx == XX_EVAL) ? xxstring : NULL))) < 0) {
6615 printf("?Variable name required\n");
6619 ckstrncpy(vnambuf,s,VNAML); /* Make a copy. */
6621 if (vnambuf[0] == CMDQ &&
6622 (vnambuf[1] == '%' || vnambuf[1] == '&'))
6625 if (*vnp == '%' || *vnp == '&') {
6626 if ((y = parsevar(vnp,&x,&z)) < 0)
6630 if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0)
6636 ckstrncpy(evalbuf,p,32);
6638 return(success = addmac(vnambuf,p));
6640 return(success = *p ? 1 : 0);
6647 if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 )
6654 if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0)
6656 if ((z = cmcfm()) < 0) return(z);
6660 if (TELOPT_UNANSWERED_WILL(y))
6661 return(success = 0);
6664 if (TELOPT_UNANSWERED_WONT(y))
6665 return(success = 0);
6668 if (TELOPT_UNANSWERED_DO(y))
6669 return(success = 0);
6672 if (TELOPT_UNANSWERED_DONT(y))
6673 return(success = 0);
6677 success = ((tn_sopt(x,y) > -1) ? 1 : 0);
6679 printf("ff%02x%02x\n",x,y);
6685 TELOPT_UNANSWERED_WILL(y) = 1;
6689 TELOPT_UNANSWERED_WONT(y) = 1;
6692 TELOPT_UNANSWERED_DO(y) = 1;
6696 TELOPT_UNANSWERED_DONT(y) = 1;
6699 if (tn_wait("XXTELOP") < 0) {
6706 if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0)
6710 /* Some compilers require switch() to have at least 1 case */
6712 TELOPT_SB(TELOPT_NAWS).naws.x = 0;
6713 TELOPT_SB(TELOPT_NAWS).naws.y = 0;
6715 return(success = ((tn_snaws() > -1) ? 1 : 0));
6717 return(success = 0);
6719 return(success = 0);
6720 #endif /* CK_NAWS */
6722 return(success = 0);
6727 success = (kerberos5_forward() == AUTH_SUCCESS);
6730 #endif /* CK_KERBEROS */
6733 if ((z = cmcfm()) < 0) return(z);
6737 if (network && IS_TELNET()) { /* TELNET */
6738 temp[0] = (CHAR) IAC;
6741 success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0);
6742 if (tn_deb || debses || deblog) {
6743 /* TN_MSG_LEN is in ckctel.h */
6744 ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL);
6745 debug(F101,tn_msg,"",x);
6746 if (debses || tn_deb) tn_debug(tn_msg);
6750 return(success = 0);
6752 #endif /* NOLOCAL */
6753 printf("ff%02x\n",x);
6754 return(success = 1);
6757 #endif /* NOLOCAL */
6771 s = getenv("EDITOR");
6772 if (s) ckstrncpy(editor,s,CKMAXPATH);
6773 editor[CKMAXPATH] = NUL;
6775 printf("?Editor not defined - use SET EDITOR to define\n");
6779 ckstrncpy(tmpbuf,editfile,TMPBUFSIZ);
6781 cmiofi() lets us parse the name of an existing file, or the name of
6782 a nonexistent file to be created.
6784 x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring);
6788 printf("Can't create \"%s\"\n",s);
6797 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
6798 if (iswild((char *)tmpbuf)) {
6799 printf("?A single file please\n");
6803 if ((z = cmcfm()) < 0) return(z);
6805 printf("?Sorry, editing not allowed\n");
6806 return(success = 0);
6809 /* Get full path in case we change directories between EDIT commands */
6810 zfnqfp(tmpbuf, CKMAXPATH, editfile);
6811 editfile[CKMAXPATH] = NUL;
6813 p = editfile; /* Flip the stupid slashes */
6815 if (*p == '/') *p = '\\';
6824 x = ckindex("%1",(char *)editopts,0,0,1);
6829 x = ckindex("%s",(char *)editopts,0,0,1);
6831 if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) {
6833 sprintf(tmpbuf,editopts,editfile);
6835 sprintf(tmpbuf,"%s %s",editopts,editfile);
6838 ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL);
6840 p = s + strlen(editor); /* And again with the slashes */
6842 if (*p == '/') *p = '\\';
6848 concb((char)escape);
6851 #endif /* NOFRILLS */
6861 printf("?Sorry, browsing not allowed\n");
6862 return(success = 0);
6865 /* Windows lets the Shell Execute the URL if no Browser is defined */
6867 s = getenv("BROWSER");
6868 if (s) ckstrncpy(browser,s,CKMAXPATH);
6869 browser[CKMAXPATH] = NUL;
6871 printf("?Browser not defined - use SET BROWSER to define\n");
6876 ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ);
6877 if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0)
6879 ckstrncpy(browsurl,s,4096);
6883 x = ckindex("%1",(char *)browsopts,0,0,1);
6888 x = ckindex("%s",(char *)browsopts,0,0,1);
6890 if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) {
6892 sprintf(tmpbuf,browsopts,browsurl);
6894 sprintf(tmpbuf,"%s %s",browsopts,browsurl);
6898 return(success = Win32ShellExecute(browsurl));
6901 ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL);
6903 p = line + strlen(browser); /* Flip slashes */
6905 if (*p == '/') *p = '\\';
6911 concb((char)escape);
6914 #endif /* BROWSER */
6918 doredo() { /* Find a previous cmd and redo it */
6919 extern int on_recall, in_recall;
6924 "pattern, or first few characters of a previous command",
6925 "*",&s,xxstring)) < 0)
6927 ckstrncpy(line,s,LINBUFSIZ);
6930 if (*s == '{') { /* Braces disable adding * to end */
6931 if (s[x-1] == '}') {
6936 } else { /* No braces, add * to end. */
6941 while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL;
6943 if (!on_recall || !in_recall) {
6944 printf("?Sorry, command recall can't be used now.\n");
6947 if ((p = cmgetcmd(s))) { /* Look for it history buffer */
6948 ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */
6949 if (!quiet) /* Echo it */
6950 printf("%s\n",cmdbuf);
6951 cmaddnext(); /* Force re-add to history buffer */
6952 return(cmflgs = -1); /* Force reparse */
6954 printf("?Sorry - \"%s\" not found\n", s);
6958 #endif /* CK_RECALL */
6963 doassoc() { /* ASSOCIATE */
6964 extern struct keytab tcstab[];
6966 if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 )
6969 switch (x) { /* Associate what? */
6971 case ASSOC_TC: /* Transfer character-set... */
6972 if ((x = cmkey(tcstab, ntcs,
6973 "transfer character-set name","",xxstring)) < 0)
6975 if ((y = cmkey(fcstab, nfilc,
6976 "with file character-set","", xxstring)) < 0)
6979 if ((z = cmcfm()) < 0)
6982 return(success = 1);
6984 case ASSOC_FC: /* File character-set... */
6985 if ((x = cmkey(fcstab, nfilc,
6986 "file character-set name","",xxstring)) < 0)
6988 if ((y = cmkey(tcstab, ntcs,
6989 "with transfer character-set","", xxstring)) < 0)
6992 if ((z = cmcfm()) < 0)
6995 return(success = 1);
7001 #endif /* NOCSETS */
7008 if ((x = cmcfm()) < 0)
7011 printf("?Sorry, access to system commands is disabled.\n");
7014 y = mxlook(mactab,"manual",nmac);
7016 z = maclvl; /* Save the current maclvl */
7017 dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */
7018 while (maclvl > z) {
7019 debug(F101,"XXMAN loop maclvl 1","",maclvl);
7020 sstate = (CHAR) parser(1);
7021 debug(F101,"XXMAN loop maclvl 2","",maclvl);
7022 if (sstate) proto();
7024 debug(F101,"XXMAN loop exit maclvl","",maclvl);
7027 return(success = 0);
7031 "Carriage return to confirm the command, or manual topic",
7033 "Carriage return to confirm the command, or help topic",
7044 ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL);
7046 ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL);
7048 debug(F110,"MANUAL",tmpbuf,0);
7050 printf("?Sorry, access to system commands is disabled.\n");
7053 conres(); /* Restore the console */
7054 success = zshcmd(tmpbuf);
7055 concb((char)escape); /* Restore CBREAK mode */
7063 static struct keytab sslswtab[] = {
7069 struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
7073 dohttp() { /* HTTP */
7074 struct FDB sw, kw, fi;
7075 int n, getval, allinone = 0;
7079 char * http_agent = NULL; /* Parse results */
7080 char * http_hdr = NULL;
7081 char * http_user = NULL;
7082 char * http_pass = NULL;
7083 char * http_mime = NULL;
7084 char * http_lfile = NULL;
7085 char * http_rfile = NULL;
7086 char * http_dfile = NULL;
7087 char http_array = NUL;
7088 int http_action = -1;
7090 char * http_host = NULL;
7091 char * http_srv = NULL;
7094 static char * http_d_agent = NULL;
7095 static char * http_d_user = NULL;
7096 static char * http_d_pass = NULL;
7098 static int http_d_type = 0;
7099 int http_type = http_d_type;
7102 p = "Kermit 95"; /* Default user agent */
7106 makestr(&http_agent,p);
7107 makestr(&http_mime,"text/HTML"); /* MIME type default */
7110 cmfdbi(&sw, /* 1st FDB - general switches */
7112 "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */
7114 "", /* addtl string data */
7115 nhttpswtab, /* addtl numeric data 1: tbl size */
7116 4, /* addtl numeric data 2: 4 = cmswi */
7117 xxstring, /* Processing function */
7118 httpswtab, /* Keyword table */
7119 &kw /* Pointer to next FDB */
7121 cmfdbi(&kw, /* 2nd FDB - commands */
7123 "Command", /* hlpmsg */
7125 "", /* addtl string data */
7126 nhttptab, /* addtl numeric data 1: tbl size */
7127 0, /* addtl numeric data 2: 0 = keyword */
7128 xxstring, /* Processing function */
7129 httptab, /* Keyword table */
7130 NULL /* Pointer to next FDB */
7134 x = cmfdb(&sw); /* Parse something */
7135 if (x < 0) /* Error */
7137 n = cmresult.nresult;
7138 if (cmresult.fdbaddr == &kw) /* Command - exit this loop */
7140 c = cmgbrk(); /* Switch... */
7141 getval = (c == ':' || c == '=');
7143 if (getval && !(cmgkwflgs() & CM_ARG)) {
7144 printf("?This switch does not take an argument\n");
7147 switch (cmresult.nresult) { /* Handle each switch */
7148 case HT_SW_TP: /* /TOSCREEN */
7151 case HT_SW_AG: /* /AGENT */
7153 if ((x = cmfld("User agent",p,&s,xxstring)) < 0)
7158 makestr(&http_agent,s);
7160 case HT_SW_HD: /* /HEADER */
7163 if ((x = cmfld("Header line","",&s,xxstring)) < 0) {
7170 makestr(&http_hdr,s);
7172 case HT_SW_US: /* /USER */
7175 if ((x = cmfld("User ID","",&s,xxstring)) < 0) {
7182 makestr(&http_user,s);
7184 case HT_SW_PW: /* /PASSWORD */
7188 if ((x = cmfld("Password","",&s,xxstring)) < 0)
7191 makestr(&http_pass,s);
7194 case HT_SW_AR: { /* /ARRAY: */
7195 char * s2, array = NUL;
7197 printf("?This switch requires an argument\n");
7201 if ((x = cmfld("Array name (a single letter will do)",
7207 printf("?Array name required\n");
7214 printf("?Array name required\n");
7219 if (*s == CMDQ) s++;
7222 printf("?Bad array name - \"%s\"\n",s2);
7228 array = tolower(array);
7229 if (*s && (*s != '[' || *(s+1) != ']')) {
7230 printf("?Bad array name - \"%s\"\n",s2);
7244 http_action = n; /* Save the action */
7245 if (http_action == HTTP_PUT || http_action == HTTP_POS) {
7246 cmfdbi(&sw, /* 1st FDB - switch */
7248 "Local filename\n Or switch", /* help */
7250 "", /* addtl string data */
7251 nhttpptab, /* keyword table size */
7252 4, /* addtl numeric data 2: 4 = cmswi */
7253 xxstring, /* Processing function */
7254 httpptab, /* Keyword table */
7255 &fi /* Pointer to next FDB */
7257 cmfdbi(&fi, /* 2nd FDB - filename */
7259 "Local filename", /* hlpmsg */
7261 "", /* addtl string data */
7262 0, /* addtl numeric data 1 */
7263 0, /* addtl numeric data 2 */
7271 goto xhttp; /* Free any malloc'd temp strings */
7272 n = cmresult.nresult;
7273 if (cmresult.fcode != _CMKEY)
7275 c = cmgbrk(); /* Switch... */
7276 getval = (c == ':' || c == '=');
7277 if (getval && !(cmgkwflgs() & CM_ARG)) {
7278 printf("?This switch does not take an argument\n");
7286 if ((x = cmfld("MIME type",
7287 "text/HTML",&s,xxstring)) < 0)
7290 makestr(&http_mime,s);
7297 makestr(&http_lfile,cmresult.sresult);
7298 n = ckindex("/",http_lfile,-1,1,0);
7303 if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) {
7305 printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post");
7311 makestr(&http_rfile,s);
7313 if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) {
7318 makestr(&http_dfile,s);
7320 switch (http_action) {
7321 case HTTP_DEL: /* DELETE */
7322 if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
7324 printf("?Delete what?\n");
7329 makestr(&http_rfile,s);
7331 case HTTP_CON: /* CONNECT */
7332 if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) {
7334 printf("?Remote host[:port] is required\n");
7339 makestr(&http_rfile,s);
7341 case HTTP_HED: { /* HEAD */
7342 char buf[CKMAXPATH+1];
7343 if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
7345 printf("?Head of what?\n");
7350 makestr(&http_rfile,s);
7352 if (http_array || http_type) { /* Default result filename */
7353 p = ""; /* None if /ARRAY or /TOSCREEN */
7355 n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */
7356 if (n) /* and add ".head" */
7360 ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL);
7363 if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) {
7367 makestr(&http_lfile,s);
7370 case HTTP_GET: /* GET */
7371 case HTTP_IDX: { /* INDEX */
7373 if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
7375 printf("?Get what?\n");
7380 makestr(&http_rfile,s);
7381 if (http_action == HTTP_GET && !http_type)
7382 zstrip(http_rfile,&lfile);
7383 if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0)
7386 makestr(&http_lfile,s);
7395 "IP host name or address, or switch", /* hlpmsg */
7397 "", /* addtl string data */
7398 2, /* addtl numeric data 1: tbl size */
7399 4, /* addtl numeric data 2: 4 = cmswi */
7400 xxstring, /* Processing function */
7401 sslswtab, /* Keyword table */
7402 &fl /* Pointer to next FDB */
7404 cmfdbi(&fl, /* 2nd FDB - host */
7408 "", /* addtl string data */
7409 0, /* addtl numeric data 1 */
7410 0, /* addtl numeric data 2 */
7415 x = cmfdb(&sw); /* Parse switch or host */
7416 if (x < 0) /* Error */
7418 if (cmresult.fcode == _CMFLD) { /* Host */
7419 s = cmresult.sresult; /* Set up expected pointer */
7420 goto havehost; /* Go parse rest of command */
7422 sslswitch = 1; /* /SSL or /TLS switch - set flag */
7427 if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) {
7429 printf("?Open what?\n");
7435 havehost: /* Come here with s -> host */
7437 x = urlparse(s,&http_url); /* Was a URL given? */
7438 if (x < 1) { /* Not a URL */
7440 makestr(&http_host,s);
7442 cmfld("Service name or port number",
7443 sslswitch ? "https" : "http",&s,xxstring)) < 0)
7446 makestr(&http_srv,s);
7448 } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */
7449 ckstrcmp(http_url.svc,"https",-1,0)) {
7450 printf("?Non-HTTP URL\n");
7453 } else { /* Have HTTP URL */
7454 makestr(&http_srv, http_url.svc);
7455 makestr(&http_user,http_url.usr);
7456 makestr(&http_pass,http_url.psw);
7457 makestr(&http_host,http_url.hos);
7459 makestr(&http_srv,http_url.por);
7460 makestr(&http_rfile,http_url.pth);
7462 if (http_rfile) { /* Open, GET, and Close */
7463 printf("?Directory/file path not allowed in HTTP OPEN URL\n");
7467 if (!ckstrcmp("https",http_srv,-1,0) || sslswitch ||
7468 !ckstrcmp("443",http_srv,-1,0))
7476 if ((x = cmcfm()) < 0)
7479 if (http_action == HTTP_OPN) {
7480 x = (http_open(http_host,http_srv,http_ssl,rdns,128,http_agent) == 0);
7484 printf("Connected to %s [%s]\r\n",http_host,rdns);
7486 printf("Connected to %s\r\n",http_host);
7491 http_d_agent = http_agent;
7497 http_d_user = http_user;
7502 memset(http_d_pass,0,strlen(http_d_pass));
7505 http_d_pass = http_pass;
7508 http_d_type = http_type;
7511 printf("?HTTP Connection failed.\r\n");
7513 } else if (http_action == HTTP_CLS) {
7516 http_d_agent = NULL;
7523 memset(http_d_pass,0,strlen(http_d_pass));
7528 x = (http_close() == 0);
7530 if ((http_action != HTTP_CLS) &&
7531 (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */
7533 /* All-in-one actions when a URL is given... */
7536 if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */
7537 if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */
7538 ckstrcmp(http_url.svc,"https",-1,0)) {
7539 printf("?Non-HTTP URL\n");
7542 } else { /* Yes, collect the pieces */
7543 makestr(&http_srv, http_url.svc);
7544 makestr(&http_user,http_url.usr);
7545 makestr(&http_pass,http_url.psw);
7546 makestr(&http_host,http_url.hos);
7548 makestr(&http_srv,http_url.por);
7549 makestr(&http_rfile,http_url.pth);
7551 if (!http_rfile) { /* Still have a path? */
7552 makestr(&http_rfile,"/");
7554 if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */
7555 !ckstrcmp("443",http_srv,-1,0))
7557 if (http_isconnected()) /* Close any open HTTP connection */
7559 if (http_pass == NULL && http_d_pass != NULL)
7560 makestr(&http_pass,http_d_pass);
7561 x = (http_open(http_host,
7562 http_srv,http_ssl,rdns,128,http_d_agent) == 0);
7570 if (http_pass == NULL && http_d_pass != NULL)
7571 makestr(&http_pass,http_d_pass);
7573 if (http_action == HTTP_OPN && allinone) {
7574 http_action = HTTP_GET;
7576 x = xdohttp(http_action,
7580 http_agent ? http_agent : http_d_agent,
7582 http_user ? http_user : http_d_user,
7583 http_pass ? http_pass : http_d_pass,
7589 x = (http_close() == 0);
7593 if (http_agent) free(http_agent);
7594 if (http_hdr) free(http_hdr);
7595 if (http_user) free(http_user);
7597 memset(http_pass,0,strlen(http_pass));
7600 if (http_mime) free(http_mime);
7601 if (http_lfile) free(http_lfile);
7602 if (http_rfile) free(http_rfile);
7603 if (http_dfile) free(http_dfile);
7604 if (http_host) free(http_host);
7605 if (http_srv) free(http_srv);
7611 #endif /* TCPSOCKET */
7620 cmfdbi(&sw, /* 1st FDB - switch */
7622 "Trace object;\n Or switch", /* help */
7624 "", /* addtl string data */
7625 2, /* keyword table size */
7626 4, /* addtl numeric data 2: 4 = cmswi */
7627 xxstring, /* Processing function */
7628 onoffsw, /* Keyword table */
7629 &kw /* Pointer to next FDB */
7631 cmfdbi(&kw, /* 2nd FDB - Trace object */
7633 "Trace object", /* help */
7634 "all", /* default */
7635 "", /* addtl string data */
7636 ntracetab, /* keyword table size */
7637 0, /* addtl numeric data 2: 0 = keyword */
7638 xxstring, /* Processing function */
7639 tracetab, /* Keyword table */
7640 NULL /* Pointer to next FDB */
7642 if ((x = cmfdb(&sw)) < 0)
7644 if (cmresult.fdbaddr == &sw) {
7645 on = cmresult.nresult;
7646 if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0)
7649 x = cmresult.nresult;
7651 if ((y = cmcfm()) < 0)
7668 printf("TRACE %s\n", on ? "ON" : "OFF");
7669 return(success = 1);
7677 if ((x = cmtxt("Optional message","",&s,xxstring)) < 0)
7680 printf("?Sorry, PROMPT requires script programming language\n");
7683 debug(F101,"Prompt cmdlvl","",cmdlvl);
7685 if (cmdlvl > CMDSTKL) {
7686 printf("?Command stack overflow: %d\n",cmdlvl);
7691 cmdstk[cmdlvl].src = CMD_KB; /* Say we're at the prompt */
7692 cmdstk[cmdlvl].lvl = 0;
7693 cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs;
7695 printf("[%d] +P: \"(prompt)\"\n",cmdlvl);
7696 concb((char)escape);
7699 "(Recursive command prompt: Resume script with CONTINUE, STOP to stop...)\n"
7701 if (*s) { /* If prompt given */
7702 makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */
7703 cmsetp(s); /* Set new one */
7705 return(success = 1);
7711 learncmd(s) char *s; { /* Record commands in learned script */
7714 if (learnfp && learning) { /* Only if open and on */
7715 k = ckstrncpy(buf,s,64);
7716 for (i = 0; i < k; i++) { /* Get top-level command keyword */
7722 k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */
7723 if (k == XXCON || k == XXLEARN) /* Don't record CONNECT or LEARN */
7726 fputs("SET HOST /NETWORK:TCP",learnfp);
7727 fputs(&s[i],learnfp);
7728 fputs(" TELNET /TELNET",learnfp);
7729 fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp);
7732 fputs("\n",learnfp);
7736 #endif /* CKLEARN */
7739 /* D O C M D -- Do a command */
7743 -2: user typed an illegal command
7745 0: parse was successful (even tho command may have failed).
7748 int cmdstats[256] = { -1, -1 };
7753 extern int nolocal, cmkwflgs;
7755 debug(F101,"docmd entry, cx","",cx);
7757 doconx = ((activecmd == XXCON) || (activecmd == XXTEL) ||
7758 (activecmd == XXRLOG) || (activecmd == XXPIPE) ||
7759 (activecmd == XXIKSD) || (activecmd == XXPTY));
7761 Originally all commands were handled with a big switch() statement,
7762 but eventually this started blowing up compilers. Now we have a series
7763 of separate if statements and small switches, with the commands that are
7764 most commonly executed in scipts and loops coming first, to speed up
7765 compute-bound scripts.
7769 if (cmdstats[0] == -1) { /* Count commands */
7770 int i; /* for tuning... */
7771 for (i = 0; i < 256; i++)
7779 if (msgflg) printf("\n");
7781 if (msgflg) printf("\r\n");
7783 doexit(GOOD_EXIT,xitsta);
7784 case -3: /* Null command */
7786 case -9: /* Like -2, but errmsg already done */
7787 case -1: /* Reparse needed */
7789 case -6: /* Special */
7790 case -2: /* Error, maybe */
7794 Maybe they typed a macro name. Let's look it up and see.
7796 if (cx == -6) /* If they typed CR */
7797 ckstrncat(cmdbuf,"\015",CMDBL); /* add it back to command buffer. */
7798 if (ifcmd[cmdlvl] == 2) /* Watch out for IF commands. */
7800 repars = 1; /* Force reparse */
7802 cx = XXDO; /* Try DO command */
7816 if ((cmkwflgs & CM_PSH)
7821 printf("?Access to system disabled\n");
7824 if ((cmkwflgs & CM_LOC)
7827 #endif /* NOLOCAL */
7829 printf("?Connections disabled\n");
7834 /* Used in FOR loops */
7836 if (cx == XX_INCR || cx == XXINC || /* _INCREMENT, INCREMENT */
7837 cx == XX_DECR || cx == XXDEC) /* _DECREMENT, DECREMENT */
7840 /* Define (or change the definition of) a macro or variable */
7842 if (cx == XXUNDEF || cx == XXUNDFX) {
7844 if (inserver && !ENABLED(en_asg)) {
7845 printf("?Sorry, DEFINE/ASSIGN disabled\n");
7849 return(doundef(cx)); /* [_]UNDEFINE */
7851 if (cx == XXDEF || cx == XXASS ||
7852 cx == XXDFX || cx == XXASX) {
7854 if (inserver && !ENABLED(en_asg)) {
7855 printf("?Sorry, DEFINE/ASSIGN disabled\n");
7859 if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */
7860 xxdot = 1; /* i.e. with space after it... */
7861 return(dodef(cx)); /* DEFINE, ASSIGN, etc... */
7864 /* IF, WHILE, and friends */
7866 if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) {
7869 if (cx == XXSWIT) { /* SWITCH */
7873 /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */
7875 if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */
7876 /* Note, here we don't set SUCCESS/FAILURE flag */
7878 if ((y = cmfld("label","",&s,xxstring)) < 0) {
7881 printf("?Label name required\n");
7887 ckstrncpy(lblbuf,s,LBLSIZ);
7888 if ((x = cmcfm()) < 0) return(x);
7890 if ((y = cmtxt("label","",&s,xxstring)) < 0) {
7893 printf("?GOTO: Label name required: \"%s\" \"%s\"\n",
7901 ckstrncpy(lblbuf,brstrip(s),LBLSIZ);
7902 #endif /* COMMENT */
7904 debug(F111,"GOTO target",s,cx);
7905 return(dogoto(s,cx));
7907 if (cx == XXDO || cx == XXMACRO) { /* DO (a macro) */
7908 char mnamebuf[16]; /* (buffer for controlled temp name) */
7910 int mx; /* Macro index (on stack!) */
7912 debug(F101,"XXMACRO 0",line,cx);
7915 printf("\n?No macros defined\n");
7918 for (y = 0; y < nmac; y++) { /* copy the macro table into a */
7919 mackey[y].kwd = mactab[y].kwd; /* regular keyword table */
7920 mackey[y].kwval = y; /* with value = pointer to macro tbl */
7921 mackey[y].flgs = mactab[y].flgs;
7923 cmfdbi(&kw, /* First FDB - macro name */
7925 "Macro", /* hlpmsg */
7927 "", /* addtl string data */
7928 nmac, /* addtl numeric data 1: tbl size */
7929 0, /* addtl numeric data 2: 0 = cmkey */
7930 xxstring, /* Processing function */
7931 mackey, /* Keyword table */
7932 &fl /* Pointer to next FDB */
7934 cmfdbi(&fl, /* 2nd FDB - for "{" */
7938 "", /* addtl string data */
7939 0, /* addtl numeric data 1 */
7940 0, /* addtl numeric data 2 */
7945 x = cmfdb(&kw); /* Parse something */
7946 if (x < 0) { /* Error */
7948 printf("?Macro name required\n");
7953 if (cmresult.fcode == _CMKEY) {
7954 extern int mtchanged;
7955 char * macroname = NULL;
7957 /* In case args include an \fexec() that changes the macro table */
7959 mx = x; /* Save macro index on stack */
7960 mtchanged = 0; /* Mark state of macro table */
7961 makestr(¯oname,mactab[mx].kwd); /* Save name */
7963 if ((y = cmtxt("optional arguments","",&s,xxstring)) < 0)
7964 return(y); /* Get macro args */
7966 if (mtchanged) { /* Macro table changed? */
7967 mx = mlook(mactab,macroname,nmac); /* Look up name again */
7972 return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ?
7975 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* _CMFLD */
7976 if (atmbuf[0] == '{') {
7977 if ((y = cmcfm()) < 0)
7980 } else { /* XXMACRO ("immediate macro") */
7985 debug(F111,"XXMACRO A",line,k);
7986 /* Defer evaluation of variables until the commands are exec'd */
7987 if ((y = cmtxt("Braced list of commands","",&s,NULL)) < 0)
7989 k = ckstrncpy(line+k,s,LINBUFSIZ-k);
7990 debug(F111,"XXMACRO B",line,k);
7993 if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
7995 if (line[0] != '{' && line[x-1] != '}') {
7996 /* Unknown command. If ON_UNKNOWN_COMMAND macro is defined, */
7997 /* parse args and then execute it, but only if it is not */
7998 /* already active. */
8001 k = mxlook(mactab,"on_unknown_command",nmac);
8004 ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
8005 z = maclvl; /* Save the current maclvl */
8006 if ((y = cmtxt("text","",&s,xxstring)) < 0)
8008 ckstrncat(tmpbuf," ",TMPBUFSIZ);
8009 ckstrncat(tmpbuf,s,TMPBUFSIZ);
8011 debug(F110,"ON_UNKNOWN_COMMAND",s,0);
8012 dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
8013 while (maclvl > z) {
8014 sstate = (CHAR) parser(1);
8015 if (sstate) proto();
8017 debug(F101,"UNKMAC loop exit maclvl","",maclvl);
8022 printf("?Not a command or macro name: \"%s\"\n",line);
8024 printf("?Not a command or macro name.\n");
8028 sprintf(mnamebuf," ..tmp:%03d",cmdlvl); /* safe (16) */
8029 x = addmac(mnamebuf,s);
8030 return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
8033 if (cx == XXLBL) { /* LABEL */
8034 if ((x = cmfld("label","",&s,xxstring)) < 0) {
8037 printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
8041 #endif /* COMMENT */
8045 debug(F111,"LABEL",s,x);
8046 if ((x = cmcfm()) < 0) return(x);
8050 if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE, EVALUATE */
8054 if (cx == XXSEXP) { /* Lisp-like S-Expression */
8055 struct stringarray * q;
8056 char /* *p, *r, */ *tmp, *m;
8057 int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
8058 extern int sexprc, sexppv;
8060 tmp = tmpbuf; /* Buffer to collect SEXP */
8061 tmpbuf[0] = NUL; /* Clear it */
8062 size = TMPBUFSIZ; /* Capacity of buffer */
8063 sexprc = -1; /* Assume bad input */
8064 n = 0; /* Paren balance counter */
8066 while (1) { /* Allow SEXP on multiple lines */
8068 "Continuation of S-Expression" :
8069 "S-Expression (\"help sexp\" for details)";
8070 x = cmtxt(m,"",&s,xxstring);
8073 if (!*s) /* Needed for (=) and (:) */
8075 k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
8077 printf("?SEXP too long - %d max\n",TMPBUFSIZ);
8080 debug(F111,contd ? "sexp contd" : "sexp",s,k);
8082 for (i = len; i < len+k; i++) { /* Check balance */
8083 if (!quote && tmpbuf[i] == CMDQ) {
8091 if (tmpbuf[i] == '(')
8093 else if (tmpbuf[i] == ')')
8096 if (n == 0) { /* Break when balanced */
8099 if (n < 0) { /* Too many right parens */
8100 printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
8103 contd++; /* Need more right parens */
8104 cmini(ckxech); /* so keep parsing */
8105 tmp += k; /* adjust buffer pointer */
8106 size -= k; /* and capacity */
8107 len += k; /* and length so far */
8110 makestr(&lastsexp,s);
8111 q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */
8112 debug(F101,"sexp split","",q->a_size);
8114 if (q->a_size == 1) { /* We should get exactly one back */
8115 char * result, * dosexp();
8116 sexprc = 0; /* Reset out-of-band return code */
8117 result = dosexp(s); /* Get result */
8118 debug(F111,"sexp result",result,sexprc);
8119 if (sexprc == 0) { /* Success */
8120 /* Echo the result if desired */
8121 if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
8122 printf(" %s\n",result ? result : "");
8123 makestr(&sexpval,result);
8124 success = sexppv > -1 ? sexppv : 1;
8129 printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
8136 if (cx == XXECH || cx == XXXECH || cx == XXVOID
8140 ) { /* ECHO or APC */
8141 if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
8142 "Text to be echoed" :
8143 ((cx == XXVOID) ? "Text" :
8144 "Application Program Command text"),
8153 /* This is to preserver the pre-8.0 behavior but it's too confusing */
8155 x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
8156 #endif /* COMMENT */
8157 s = brstrip(s); /* Strip braces and doublequotes */
8158 if (cx == XXECH) { /* ECHO */
8160 if (!fndiags || fnsuccess) {
8163 /* The "if (x)" business preserves previous behavior */
8164 /* by putting back the doublequotes if they were included. */
8166 printf("\"%s\"\n",s);
8168 #endif /* COMMENT */
8173 } else if (cx == XXXECH) { /* XECHO */
8181 } else if (cx == XXAPC) { /* APC */
8183 if (apcactive == APC_LOCAL ||
8184 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
8185 return(success = 0);
8188 printf("%c_%s%c\\",ESC,s,ESC);
8193 } else { /* Local mode - have connection */
8195 if (ckmakxmsg(tmpbuf, /* Form APC string in buffer */
8202 NULL,NULL,NULL,NULL,NULL,NULL,NULL
8204 return(success = dooutput(tmpbuf, XXOUT));
8205 printf("?Too long\n");
8208 printf("%c_%s%c\\",ESC,s,ESC);
8212 return(success = 1);
8216 /* Copy macro args from/to two levels up, used internally by _floop et al. */
8217 if (cx == XXGTA || cx == XXPTA) { /* _GETARGS, _PUTARGS */
8219 debug(F101,"docmd XXGTA","",XXGTA);
8220 debug(F101,"docmd cx","",cx);
8221 debug(F101,"docmd XXGTA maclvl","",maclvl);
8223 debug(F101,"docmd dogta returns","",x);
8224 debug(F101,"docmd dogta maclvl","",maclvl);
8233 else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
8234 cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
8235 cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
8237 #endif /* CKCHANNELIO */
8239 /* ASK, ASKQ, READ */
8240 if (cx == XXASK || cx == XXASKQ || cx == XXREA ||
8241 cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
8247 if (cx == XXBUG) { /* BUG */
8248 if ((x = cmcfm()) < 0) return(x);
8251 #endif /* NOFRILLS */
8254 if (cx == XXBYE) { /* BYE */
8255 extern int ftp_cmdlin;
8256 if ((x = cmcfm()) < 0) return(x);
8259 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
8260 extern int stayflg, ftp_fai;
8262 if (ftp_cmdlin && !stayflg && !local)
8263 doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
8270 printf("?No connection - use EXIT to quit.\n");
8275 if (protocol != PROTO_K) {
8276 printf("?Sorry, BYE only works with Kermit protocol\n");
8284 protocol == PROTO_K &&
8286 !iks_wait(KERMIT_REQ_START,1)) {
8288 "?A Kermit Server is not available to process this command\n");
8289 return(-9); /* Correct the return code */
8291 #endif /* IKS_OPTION */
8294 sstate = setgen('L',"","","");
8295 if (local) ttflui(); /* If local, flush tty input buffer */
8300 if (cx == XXBEEP) { /* BEEP */
8304 if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
8307 if ((x = cmcfm()) < 0) return(x);
8308 bleep((short)y); /* y is one of the BP_ values */
8310 if ((x = cmcfm()) < 0) return(x);
8321 if (cx == XXCLE) /* CLEAR */
8322 return(success = doclear());
8323 #endif /* NOFRILLS */
8325 if (cx == XXCOM) { /* COMMENT */
8326 if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
8328 /* Don't change SUCCESS flag for this one */
8333 if (cx == XXCON || cx == XXCQ) /* CONNECT or CONNECT /QUIETLY */
8334 return(doxconn(cx));
8335 #endif /* NOLOCAL */
8339 if (cx == XXCPY) { /* COPY a file */
8341 if (inserver && !ENABLED(en_cpy)) {
8342 printf("?Sorry, COPY is disabled\n");
8347 if (apcactive == APC_LOCAL ||
8348 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
8350 return(success = 0);
8356 if ( cx == XXLINK ) {
8358 if (inserver && !ENABLED(en_cpy)) {
8359 printf("?Sorry, LINK (COPY) is disabled\n");
8364 if (apcactive == APC_LOCAL ||
8365 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
8367 return(success = 0);
8372 #endif /* NOFRILLS */
8374 /* CD and friends */
8375 if (cx == XXCWD || cx == XXCDUP || cx == XXBACK ||
8376 cx == XXLCWD || cx == XXLCDU || cx == XXKCD) {
8383 return(dormt(XZCWD));
8385 } else if (cx == XXCDUP) {
8389 return(dormt(XZCDU));
8395 if (inserver && !ENABLED(en_cwd)) {
8396 printf("?Sorry, changing directories is disabled\n");
8400 return(success = docd(cx));
8403 if (cx == XXCHK) /* CHECK */
8404 return(success = dochk());
8406 if (cx == XXCLO) { /* CLOSE */
8407 x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
8408 "connection",xxstring);
8410 printf("?You must say which file or log\n");
8413 if (x < 0) return(x);
8414 if ((y = cmcfm()) < 0) return(y);
8416 if (x == 9999) { /* CLOSE CONNECTION */
8420 if (msgflg) printf("?Connection was not open\n");
8424 whyclosed = WC_CLOS;
8429 #endif /* NOLOCAL */
8436 if (cx == XXDCL || cx == XXUNDCL) { /* DECLARE an array */
8442 if (cx == XXRED || cx == XXDIAL || cx == XXPDIA ||
8443 cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
8449 #endif /* UNIXOROSK */
8452 debug(F101,"dodial returns","",x);
8453 if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
8454 (x > 0) && /* If DIAL or REDIAL succeeded */
8455 (dialsta != DIA_PART) && /* and it wasn't partial */
8457 if ((dialcon == 1 || /* And DIAL CONNECT is ON, */
8458 ((dialcon == 2) && /* or DIAL CONNECT is AUTO */
8459 !xcmdsrc /* and we're at top level... */
8461 && !batch /* Not if running from batch */
8464 && !backgrd /* Not if running in background */
8465 #endif /* UNIXOROSK */
8468 x = doconect(dialcq, /* Then also CONNECT */
8474 return(success = x);
8480 if (cx == XXREXX) { /* REXX */
8486 #endif /* CK_REXX */
8490 if (cx == XXDEL || cx == XXLDEL) { /* DELETE */
8492 if (!locus && cx != XXLDEL) {
8496 return(dormt(XZDEL));
8501 if (inserver && (!ENABLED(en_del)
8504 #endif /* CK_LOGIN */
8506 printf("?Sorry, DELETE is disabled\n");
8511 if ((apcactive == APC_LOCAL) ||
8512 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8513 return(success = 0);
8517 #endif /* NOFRILLS */
8519 if (cx == XXDIR || cx == XXLS || cx == XXLDIR) { /* DIRECTORY or LS */
8521 if (!locus && cx != XXLDIR) {
8525 return(dormt(XZDIR));
8530 if (inserver && !ENABLED(en_dir)) {
8531 printf("?Sorry, DIRECTORY is disabled\n");
8539 if (cx == XXELS) /* ELSE */
8545 if (cx == XXENA || cx == XXDIS) { /* ENABLE, DISABLE */
8547 "Server function to enable" :
8548 "Server function to disable";
8550 if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
8552 printf("?Name of server function required\n");
8556 if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
8558 printf("?Please specify remote, local, or both\n");
8562 if (cx == XXDIS) /* Disabling, not enabling */
8564 if ((z = cmcfm()) < 0) return(z);
8566 if ((apcactive == APC_LOCAL) ||
8567 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8568 return(success = 0);
8571 /* This may seem like it duplicates the work in doenable() */
8572 /* but this code returns failure whereas doenable() returns */
8577 #endif /* IKSDCONF */
8578 (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
8580 return(success = 0);
8582 return(doenable(y,x));
8584 #endif /* NOFRILLS */
8585 #endif /* NOSERVER */
8588 if (cx == XXRET) { /* RETURN */
8589 if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
8591 s = brstrip(s); /* Strip braces */
8592 if (cmdlvl == 0) /* At top level, nothing happens... */
8593 return(success = 1);
8594 switch (cmdstk[cmdlvl].src) { /* Action depends on command source */
8595 case CMD_TF: /* Command file */
8596 popclvl(); /* Pop command level */
8597 return(success = 1); /* always succeeds */
8598 case CMD_MD: /* Macro */
8599 case CMD_KB: /* Prompt */
8600 return(doreturn(s)); /* Trailing text is return value. */
8601 default: /* Shouldn't happen */
8608 if (cx == XXOPE) /* OPEN */
8613 if (cx == XXOUT || cx == XXLNOUT) { /* OUTPUT or LINEOUT */
8614 if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
8617 if ((apcactive == APC_LOCAL) ||
8618 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8619 return(success = 0);
8621 debug(F110,"OUTPUT 1",s,0);
8622 s = brstrip(s); /* Strip enclosing braces, */
8623 debug(F110,"OUTPUT 2",s,0);
8625 I don't think I could ever fully explain this in a million years...
8626 We have read the user's string without calling the variable-expander
8627 function. Now, before we call it, we have to double backslashes that
8628 appear before \N, \B, \L, and \ itself, so the expander function will
8629 reduce them back to single backslashes, so when we call dooutput()...
8630 But it's more complicated than that.
8632 if (cmdgquo()) { /* Only if COMMAND QUOTING ON ... */
8633 for (x = 0, y = 0; s[x]; x++, y++) {
8636 if (c == 'n' || c == 'N' ||
8637 c == 'b' || c == 'B' ||
8638 c == 'l' || c == 'L' ||
8644 line[y++] = '\0'; /* Now expand variables, etc. */
8645 debug(F110,"OUTPUT 3",line,0);
8647 x = LINBUFSIZ - (int) strlen(line) - 1;
8648 debug(F101,"OUTPUT size","",x);
8649 if (zzstring(line,&s,&x) < 0)
8650 return(success = 0);
8652 debug(F110,"OUTPUT 4",s,0);
8654 success = dooutput(s,cx);
8661 if (cx == XXPAD) { /* PAD commands */
8662 x = cmkey(padtab,npadc,"PAD command","",xxstring);
8664 printf("?You must specify a PAD command to execute\n");
8667 if (x < 0) return(x);
8672 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8680 printf("Not connected\r\n");
8682 extern int linkid, lcn;
8683 conol("Connected thru ");
8685 printf(", Link id %d, Logical channel number %d\r\n",
8691 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8697 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8707 if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
8715 if (inserver && (isguest || !ENABLED(en_pri))) {
8716 printf("?Sorry, printing is disabled\n");
8719 #endif /* CK_LOGIN */
8721 if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
8723 printf("?A file specification is required\n");
8728 printf("?Wildcards not allowed\n");
8731 ckstrncpy(line,s,LINBUFSIZ);
8734 if ((x = cmtxt("Local print command options, or carriage return","",&s,
8738 if ((x = cmcfm()) < 0)
8740 return(success = (zprint(s,line) == 0) ? 1 : 0);
8742 #endif /* NOFRILLS */
8746 if (cx == XXPNG) /* PING an IP host */
8751 if (cx == XXFTP) /* FTP */
8754 return(doftp()); /* Just runs system's ftp program */
8762 #endif /* TCPSOCKET */
8764 if (cx == XXPWD || cx == XXLPWD) { /* PWD */
8768 if ((x = cmcfm()) < 0)
8771 if (!locus && cx != XXLPWD) {
8775 return(dormt(XZPWD));
8783 printf("%s\n",zgtdir());
8787 return(success = 1); /* Blind faith */
8789 if (pwp = zgtdir()) {
8793 ckGetLongPathName(pwp,line,LINBUFSIZ);
8794 line[LINBUFSIZ-1] = NUL;
8796 GetShortPathName(pwp,tmpbuf,TMPBUFSIZ);
8797 tmpbuf[TMPBUFSIZ-1] = NUL;
8799 if (!strcmp(line,tmpbuf)) {
8804 printf(" Long name: %s\n",line);
8805 printf(" Short name: %s\n",tmpbuf);
8809 return(success = ((int)strlen(pwp) > 0));
8810 } else return(success = 0);
8813 if (pwp = zgtdir()) {
8815 return(success = ((int)strlen(pwp) > 0));
8816 } else return(success = 0);
8820 if (cx == XXQUI || cx == XXEXI) { /* EXIT, QUIT */
8821 extern int quitting;
8823 if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
8825 if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
8828 ckstrncpy(line,s,LINBUFSIZ);
8830 if (!hupok(0)) /* Check if connection still open */
8831 return(success = 0);
8833 if (line[0]) /* Print EXIT message if given */
8834 printf("%s\n",(char *)line);
8836 quitting = 1; /* Flag that we are quitting. */
8839 doexit(GOOD_EXIT,x);
8842 /* Returning any codes here makes the OS-9 shell print an error message. */
8843 doexit(GOOD_EXIT,-1);
8846 doexit(GOOD_EXIT,x);
8849 #endif /* datageneral */
8856 if (cx == XXERR) { /* ERROR */
8858 if (protocol != PROTO_K) {
8859 printf("Sorry, E-PACKET only works with Kermit protocol\n");
8863 if ((x = cmcfm()) < 0) return(x);
8869 #endif /* NOFRILLS */
8871 if (cx == XXFIN) { /* FINISH */
8873 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
8877 if (protocol != PROTO_K) {
8878 printf("Sorry, FINISH only works with Kermit protocol\n");
8882 if ((x = cmcfm()) < 0) return(x);
8887 protocol == PROTO_K &&
8889 !iks_wait(KERMIT_REQ_START,1)) {
8891 "?A Kermit Server is not available to process this command\n");
8892 return(-9); /* Correct the return code */
8894 #endif /* IKS_OPTION */
8896 sstate = setgen('F',"","","");
8897 if (local) ttflui(); /* If local, flush tty input buffer */
8903 if (cx == XXFOR) /* FOR loop */
8908 /* GET MGET REGET RETRIEVE etc */
8909 if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
8911 if (inserver && !ENABLED(en_sen)) {
8912 printf("?Sorry, reception of files is disabled\n");
8922 if (cx == XXGOK) { /* GETOK */
8923 return(success = doask(cx));
8925 #endif /* NOFRILLS */
8928 if (cx == XXHLP) { /* HELP */
8930 return(dohlp(XXHLP));
8932 x = cmkey2(cmdtab,ncmd,"\nCommand or topic","help",toktab,xxstring,3);
8933 debug(F101,"HELP command x","",x);
8936 debug(F101,"HELP cmkey token","",y);
8940 case '!': x = XXSHE; break;
8942 case '#': x = XXCOM; break;
8943 case ';': x = XXCOM; break;
8945 case '.': x = XXDEF; break;
8946 case ':': x = XXLBL; break;
8948 case '(': x = XXSEXP; break;
8951 case '&': x = XXECH; break;
8953 printf("\n?Invalid - %s\n",cmdbuf);
8957 makestr(&hlptok,atmbuf);
8958 debug(F111,"HELP token",hlptok,x);
8964 if (cx == XXINT) /* INTRO */
8965 return(hmsga(introtxt));
8966 if (cx == XXNEW) { /* NEWS */
8968 extern char * k_info_dir;
8974 if (cx == XXUPD) { /* View UPDATE file */
8975 extern char exedir[];
8978 if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
8982 "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
8983 %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
8984 exedir,exedir,exedir,exedir,pTopic
8987 if (ckmakxmsg(updstr,
8993 "\\docs\\using_ck.inf+",
8995 "\\docs\\dialing.inf+",
8997 "\\docs\\modems.inf ",
9002 #endif /* COMMENT */
9004 return(success = 1);
9006 #endif /* OS2ONLY */
9010 if (cx == XXHAN) { /* HANGUP */
9011 if ((x = cmcfm()) < 0) return(x);
9013 if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
9014 return(success = ftpbye());
9017 if ((x = mdmhup()) < 1) {
9018 debug(F101,"HANGUP mdmup","",x);
9021 debug(F101,"HANGUP tthang","",x);
9027 whyclosed = WC_CLOS;
9028 ttchk(); /* In case of CLOSE-ON-DISCONNECT */
9032 DialerSend(OPT_KERMIT_HANGUP, 0);
9034 if (x) haveline = 0;
9035 return(success = x);
9037 #endif /* NOLOCAL */
9040 /* INPUT, REINPUT, and MINPUT */
9042 if (cx == XXINP || cx == XXREI || cx == XXMINP) {
9044 extern int ispattern, isjoin;
9046 struct FDB sw, nu, fl;
9047 int fc, havetime = 0;
9051 m = "Timeout in seconds (ignored)";
9053 m = "Seconds to wait for input,\n or time of day hh:mm:ss, \
9056 innomatch = 0; /* Initialize switch value(s) */
9058 cmfdbi(&sw, /* First FDB - command switches */
9061 ckitoa(indef), /* default */
9062 "", /* addtl string data */
9063 ninputsw, /* addtl numeric data 1: tbl size */
9064 4, /* addtl numeric data 2: 4 = cmswi */
9065 xxstring, /* Processing function */
9066 inputsw, /* Keyword table */
9067 &nu /* Pointer to next FDB */
9070 _CMNUM, /* Number */
9071 m, /* Help message */
9072 ckitoa(indef), /* default */
9074 10, /* Radix = 10 */
9076 xxstring, /* Processing function */
9080 cmfdbi(&fl, /* Time of day hh:mm:ss */
9084 "", /* addtl string data */
9085 0, /* addtl numeric data 1 */
9086 0, /* addtl numeric data 2 */
9091 fc = (cx == XXREI) ? cmfdb(&nu) : cmfdb(&sw); /* Parse something */
9094 if (fc < 0) { /* Error */
9096 printf("?Syntax error in INPUT-class command\n");
9101 switch (cmresult.fcode) {
9102 case _CMKEY: /* Switch */
9103 if (cmresult.nresult == INPSW_NOM) /* /NOMATCH */
9105 m = "Seconds to wait for input,\n or time of day hh:mm:ss";
9106 cmfdbi(&nu,_CMNUM,m,"","",10,0,xxstring,NULL,&fl);
9107 cmfdbi(&fl,_CMFLD,"","","",0,0,xxstring,NULL,NULL);
9108 fc = cmfdb(&nu); /* Parse something */
9111 case _CMNUM: /* Seconds to time out */
9112 x = cmresult.nresult;
9114 if (inscale != 1.0) /* Scale */
9116 #endif /* CKFLOAT */
9121 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
9123 printf("?Number, expression, or time of day required\n");
9126 char now[32]; /* Current time */
9131 tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
9132 if (zz < tnow) /* User's time before now */
9133 zz += 86400L; /* So make it tomorrow */
9134 zz -= tnow; /* Seconds from now. */
9137 if (zz != (long) x) {
9139 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
9148 printf("?Internal error\n");
9152 /* Now parse the search text */
9155 for (y = 0; y < MINPMAX; y++) { /* Initialize strings */
9156 mp[y] = 0; /* Assume it's not a pattern */
9158 free(ms[y]); /* Free old strings, if any */
9162 if (cx == XXMINP) { /* MINPUT */
9163 int i, k = 0, n = 0;
9164 struct stringarray * q;
9166 while (k < MINPMAX) {
9167 if ((y = cmfld("String or pattern","",&s,xxstring)) < 0) {
9169 if ((y = cmcfm()) < 0)
9176 debug(F111,"MINPUT field",s,k);
9178 if ((q = cksplit(1,0,s," ",(char *)c1chars,3,0,0))) {
9179 char ** ap = q->a_head;
9181 debug(F101,"minput cksplit size","",n);
9182 for (i = 1; i <= n && k < MINPMAX; i++) {
9183 if (!ap[i]) /* Add non-empty elements */
9187 makestr(&(ms[k]),ap[i]);
9188 debug(F111,"MINPUT JOIN",ms[k],k);
9194 makestr(&(ms[k]),brstrip(s));
9195 if (ispattern) mp[k] = 1;
9196 debug(F111,"MINPUT",ms[k],ispattern);
9203 #endif /* CK_MINPUT */
9205 /* INPUT or REINPUT */
9207 if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
9209 mp[0] = ispattern ? 1 : 0;
9210 makestr(&(ms[0]),brstrip(s));
9215 #endif /* CK_MINPUT */
9218 printf("/NOMATCH=%d\n",innomatch);
9219 printf("Timeout=%d\n",x);
9221 #endif /* COMMENT */
9223 if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
9225 /* Go try to input the search string */
9226 success = doinput(x,ms,mp,innomatch);
9228 } else { /* REINPUT */
9229 success = doreinp(x,ms[0],ispattern);
9231 if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
9232 popclvl(); /* If so, pop command level. */
9233 if (pflag && cmdlvl == 0) {
9234 if (cx == XXINP) printf("?INPUT timed out\n");
9235 if (cx == XXMINP) printf("?MINPUT timed out\n");
9236 if (cx == XXREI) printf("?REINPUT failed\n");
9239 return(success); /* Return do(re)input's return code */
9244 if (cx == XXLOG) { /* LOG */
9245 x = cmkey(logtab,nlog,"What to log","",xxstring);
9247 printf("?Type of log required\n");
9250 if (x < 0) return(x);
9255 return(success = x);
9258 if (cx == XXLOGIN) { /* (REMOTE) LOGIN */
9260 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9261 return(success = doftpusr());
9265 printf("?Already logged in\n");
9273 return(dormt(XZLGI));
9277 if (cx == XXLOGOUT) { /* (REMOTE) LOGOUT */
9279 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9280 return(success = doftpres());
9285 if ((x = cmcfm()) < 0)
9287 doexit(GOOD_EXIT,xitsta);
9290 if (!local || (network && ttchk() < 0)) {
9291 printf("?No connection.\n");
9297 return(dormt(XZLGO));
9303 if (cx == XXLOGI) { /* UUCP-style script */
9304 if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
9307 if ((apcactive == APC_LOCAL) ||
9308 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9309 return(success = 0);
9312 conres(); /* For Ctrl-C to work... */
9314 return(success = dologin(s)); /* Return 1=completed, 0=failed */
9316 #endif /* NOSCRIPT */
9320 if (cx == XXCREC) { /* CRECEIVE */
9321 if (protocol != PROTO_K) {
9322 printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
9327 if (cx == XXCGET) { /* CGET */
9330 #endif /* PIPESEND */
9332 if (cx == XXREC) /* RECEIVE */
9337 if (cx == XXREM) { /* REMOTE */
9339 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9340 return(doftprmt(0,0));
9343 if (protocol != PROTO_K) {
9344 printf("Sorry, REMOTE commands only work with Kermit protocol\n");
9348 x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
9350 printf("?You must specify a command for the remote server\n");
9359 if (cx == XXREN || cx == XXLREN) { /* RENAME */
9361 if (!locus && cx != XXLREN) {
9365 return(dormt(XZREN));
9370 if (inserver && (!ENABLED(en_ren)
9373 #endif /* CK_LOGIN */
9375 printf("?Sorry, renaming of files is disabled\n");
9380 if ((apcactive == APC_LOCAL) ||
9381 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9382 return(success = 0);
9386 #endif /* NOFRILLS */
9387 #endif /* NORENAME */
9389 if (cx == XXEIGHT) { /* EIGHTBIT */
9390 extern int parity, cmask, cmdmsk;
9391 if ((x = cmcfm()) < 0)
9396 return(success = 1);
9400 /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
9402 if (cx == XXSEN /* SEND */
9404 || cx == XXCSEN /* CSEND */
9405 #endif /* PIPESEND */
9406 || cx == XXMOVE /* MOVE */
9407 || cx == XXMAI /* MAIL */
9409 || cx == XXRSEN /* RESEND */
9410 #endif /* CK_RESEND */
9413 if (inserver && !ENABLED(en_get)) {
9414 printf("?Sorry, sending files is disabled\n");
9418 return(doxsend(cx));
9421 /* PSEND, ADD, and REMOVE use special parsing */
9424 /* ADD and REMOVE */
9425 if (cx == XXADD || cx == XXREMV) {
9427 m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
9428 x = cmkey(addtab,naddtab,m,"",xxstring);
9433 return(addsend(cx));
9435 #endif /* NOMSEND */
9436 return(doadd(cx,x));
9441 if (cx == XXPSEN) { /* PSEND */
9444 cmarg = cmarg2 = "";
9445 x = cmifi("File to partially send", "", &s, &y, xxstring);
9448 printf("?A file specification is required\n");
9452 nfils = -1; /* Files come from internal list. */
9454 addlist = 0; /* Don't use SEND-LIST. */
9456 #endif /* NOMSEND */
9457 ckstrncpy(line,s,LINBUFSIZ); /* Save copy of string just parsed. */
9458 debug(F110,"PSEND line",line,0);
9460 printf("?Sorry, wildcards not permitted in this command\n");
9463 if (sizeof(int) < 4) {
9464 printf("?Sorry, this command needs 32-bit integers\n");
9467 x = cmnum("starting position (byte number)",
9468 "",10,&seekto,xxstring);
9471 zfnqfp(s,fspeclen,fspec); /* Get full path */
9472 if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
9474 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
9477 if (inserver && !ENABLED(en_get)) {
9478 printf("?Sorry, sending files is disabled\n");
9484 printf("?Sorry, no PSEND while SEND FILTER selected\n");
9487 #endif /* PIPESEND */
9489 if ((protocol == PROTO_X || protocol == PROTO_XC)) {
9490 printf("Sorry, PSEND works only with Kermit protocol\n");
9495 cmarg2 = brstrip(tmpbuf); /* Strip braces */
9496 cmarg = line; /* File to send */
9497 debug(F110,"PSEND filename",cmarg,0);
9498 debug(F110,"PSEND as-name",cmarg2,0);
9500 sstate = 's'; /* Set start state to SEND */
9504 #endif /* NOMSEND */
9505 sendmode = SM_PSEND;
9510 if (local) { /* If in local mode, */
9511 displa = 1; /* enable file transfer display */
9515 #endif /* CK_RESEND */
9520 if (cx == XXMSE || cx == XXMMOVE) {
9522 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9523 return(doftpput(cx,0));
9526 if (protocol == PROTO_X || protocol == PROTO_XC) {
9528 "Sorry, you can only send one file at a time with XMODEM protocol\n"
9533 return(doxsend(cx));
9536 #ifdef COMMENT /* (moved to doxsend) */
9537 if (cx == XXMSE || cx == XXMMOVE) { /* MSEND and MMOVE commands */
9538 nfils = 0; /* Like getting a list of */
9539 lp = line; /* files on the command line */
9540 addlist = 0; /* Do not use SEND-LIST */
9541 filenext = NULL; /* Ditto ! */
9545 if ((x = cmifi("Names of files to send, separated by spaces","",
9546 &s,&y,xxstring)) < 0) {
9549 printf("?A file specification is required\n");
9555 msfiles[nfils++] = lp; /* Got one, count it, point to it, */
9556 p = lp; /* remember pointer, */
9557 while (*lp++ = *s++) /* and copy it into buffer */
9558 if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
9559 printf("?MSEND list too long\n");
9563 debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
9564 if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
9566 zfnqfp(p,TMPBUFSIZ,tmpbuf);
9569 if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
9570 strcat(fspec,p); /* safe */
9571 strcat(fspec," "); /* safe */
9572 } else printf("WARNING - \\v(filespec) buffer overflow\n");
9574 cmlist = msfiles; /* Point cmlist to pointer array */
9575 cmarg2 = ""; /* No internal expansion list (yet) */
9576 sndsrc = nfils; /* Filenames come from cmlist */
9577 sendmode = SM_MSEND; /* Remember this kind of SENDing */
9578 sstate = 's'; /* Set start state for SEND */
9579 if (cx == XXMMOVE) /* If MMOVE'ing, */
9580 moving = 1; /* set this flag. */
9585 if (local) { /* If in local mode, */
9586 displa = 1; /* turn on file transfer display */
9587 ttflui(); /* and flush tty input buffer. */
9591 #endif /* COMMENT */
9592 #endif /* NOMSEND */
9596 if (cx == XXSER) { /* SERVER */
9598 if (protocol != PROTO_K) {
9599 printf("Sorry, SERVER only works with Kermit protocol\n");
9605 Parse for time limit, but since we don't use it yet,
9606 the parsing is commented out.
9608 x_ifnum = 1; /* Turn off internal complaints */
9609 y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
9610 "0", 10, &x, xxstring
9614 if (y == -2) { /* Invalid number or expression */
9615 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
9617 printf("?Number, expression, or time of day required\n");
9620 char now[32]; /* Current time */
9625 tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
9626 if (zz < tnow) /* User's time before now */
9627 zz += 86400L; /* So make it tomorrow */
9628 zz -= tnow; /* Seconds from now. */
9635 if (zz != (long) x) {
9637 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
9644 #endif /* COMMENT */
9646 if ((x = cmcfm()) < 0) return(x);
9652 if (local) displa = 1;
9654 reqoff(); /* No DOS requestors while server */
9658 #endif /* NOSERVER */
9660 if (cx == XXSAVE) { /* SAVE command */
9661 x = cmkey(savtab,nsav,"option","keymap",xxstring);
9663 printf("?You must specify an option to save\n");
9666 if (x < 0) return(x);
9667 /* have to set success separately for each item in doprm()... */
9668 /* actually not really, could have just had doprm return 0 or 1 */
9669 /* and set success here... */
9672 printf("?More fields required\n");
9677 if (cx == XXSET) { /* SET command */
9678 x = cmkey(prmtab,nprm,"Parameter","",xxstring);
9680 printf("?You must specify a parameter to set\n");
9683 if (x < 0) return(x);
9684 /* have to set success separately for each item in doprm()... */
9685 /* actually not really, could have just had doprm return 0 or 1 */
9686 /* and set success here... */
9689 printf("?More fields required\n");
9695 if (cx == XXSHE /* SHELL (system) command */
9696 || cx == XXEXEC /* exec() */
9703 #endif /* UNIXOROSK */
9706 if (inserver && (nopush || !ENABLED(en_hos))) {
9707 printf("?Sorry, host command access is disabled\n");
9713 if (cx == XXEXEC) { /* EXEC (overlay ourselves) */
9715 cmfdbi(&sw, /* First FDB - command switches */
9717 "Command to overlay C-Kermit\n or switch", /* hlpmsg */
9719 "", /* addtl string data */
9720 1, /* addtl numeric data 1: tbl size */
9721 4, /* addtl numeric data 2: 4 = cmswi */
9722 xxstring, /* Processing function */
9723 redirsw, /* Keyword table */
9724 &fl /* Pointer to next FDB */
9726 cmfdbi(&fl, /* 2nd FDB - command to exec */
9728 "Command to overlay C-Kermit", /* hlpmsg */
9730 "", /* addtl string data */
9731 0, /* addtl numeric data 1 */
9732 0, /* addtl numeric data 2 */
9735 NULL /* No more after this */
9738 x = cmfdb(&sw); /* Parse something */
9739 debug(F101,"exec cmfdb","",x);
9742 /* Generalize this if we add more switches */
9743 if (cmresult.fcode == _CMKEY) {
9747 if (cmresult.fcode == _CMFLD)
9751 ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
9753 printf("?Command required\n");
9756 p = brstrip(tmpbuf);
9757 args[0] = NULL; /* Set argv[0] to it */
9758 makestr(&args[0],p);
9759 for (i = 1; i < 255; i++) { /* Get arguments for command */
9760 if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
9762 if ((x = cmcfm()) < 0)
9770 makestr(&args[i],s);
9775 if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
9781 return(success = 0);
9783 if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
9784 return(success = 0);
9786 conres(); /* Make console normal */
9790 return(success = 1);
9795 debug(F101,"RUN zshcmd code","",x);
9796 concb((char)escape);
9797 return(success = x);
9802 debug(F111,"EXEC cmd",p,0);
9803 for (i = 0; i < 256 && args[i]; i++)
9804 debug(F111,"EXEC arg",args[i],i);
9808 z_exec(p,args,rx); /* Overlay ourself */
9809 debug(F100,"EXEC fails","",0);
9810 concb((char)escape); /* In case it returns */
9812 return(success = 0);
9818 if (cx == XXFUN) { /* REDIRECT */
9820 if ((apcactive == APC_LOCAL) ||
9821 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9822 return(success = 0);
9826 "Local command to run,\n",
9827 "with its standard input/output redirected to ",
9828 local ? ttname : "the communications connection",
9831 if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
9834 printf("?REDIRECT disabled\n");
9838 printf("?SET LINE or SET HOST required first\n");
9842 printf("?REDIRECT requires a command to redirect\n");
9845 return(success = ttruncmd(s));
9847 #endif /* CK_REDIR */
9851 if (cx == XXSHO) { /* SHOW */
9852 x = cmkey(shotab,nsho,"","parameters",xxstring);
9853 if (x < 0) return(x);
9859 if (cx == XXSPA) { /* SPACE */
9861 if (inserver && !ENABLED(en_spa)) {
9862 printf("?Sorry, SPACE command disabled\n");
9867 /* AOS/VS can take an argument after its "space" command. */
9868 if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0)
9871 printf("?Sorry, SPACE command disabled\n");
9873 } else if (*s == NUL) {
9876 ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL);
9881 if ((x = cmtxt("Press Enter for current disk,\n\
9882 or specify a disk letter like A:","",&s,xxstring)) < 0)
9884 if (*s == NUL) { /* Current disk */
9885 unsigned long space = zdskspace(0);
9886 if (space > 0 && space < 1024)
9887 printf(" Free space: unknown\n");
9889 printf(" Free space: %ldK\n", space/1024L);
9891 int drive = toupper(*s);
9892 unsigned long space = zdskspace(drive - 'A' + 1);
9893 if (space > 0 && space < 1024)
9894 printf(" Drive %c: unknown free\n");
9896 printf(" Drive %c: %ldK free\n", drive,space / 1024L);
9900 x = cmdir("Confirm for current disk,\n\
9901 or specify a disk device or directory","",&s,xxstring);
9906 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
9908 if ((x = cmcfm()) < 0) return(x);
9910 printf("?Sorry, SPACE command disabled\n");
9913 if (!*s) { /* Current disk */
9915 } else { /* Specified disk */
9916 ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL);
9920 if ((x = cmcfm()) < 0) return(x);
9922 printf("?Sorry, SPACE command disabled\n");
9926 #endif /* UNIXOROSK */
9928 #endif /* datageneral */
9929 return(success = 1); /* Pretend it worked */
9934 if (cx == XXSTA) { /* STATISTICS */
9935 if ((x = cmkey(stattab,2,"Carriage return, or option",
9936 "/brief",xxstring)) < 0)
9938 if ((y = cmcfm()) < 0) return(y);
9939 return(success = dostat(x));
9943 if (cx == XXSTO || cx == XXEND) { /* STOP, END, or POP */
9944 if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0)
9946 if ((y = cmtxt("Message to print","",&s,xxstring)) < 0)
9949 if (*s) printf("%s\n",s);
9955 return(success = (x == 0));
9957 if (cx == XXSUS) { /* SUSPEND */
9958 if ((y = cmcfm()) < 0) return(y);
9960 printf("Sorry, this version of Kermit cannot be suspended\n");
9964 printf("?Sorry, IKSD can not be suspended\n");
9969 printf("?Sorry, access to system is disabled\n");
9977 if (cx == XXTAK) { /* TAKE */
9978 char * scriptenv = NULL;
9980 char * GetAppData(int);
9981 extern char startupdir[],exedir[],inidir[];
9982 char * keymapenv = NULL;
9983 char * appdata0 = NULL, *appdata1 = NULL;
9985 #define TAKEPATHLEN 4096
9987 #define TAKEPATHLEN 1024
9989 char takepath[TAKEPATHLEN];
9991 if (tlevel >= MAXTAKE-1) {
9992 printf("?Take files nested too deeply\n");
9997 scriptenv = getenv("K95SCRIPTS");
9998 keymapenv = getenv("K95KEYMAPS");
9999 makestr(&appdata0,(char *)GetAppData(0));
10000 makestr(&appdata1,(char *)GetAppData(1));
10002 scriptenv = getenv("K2SCRIPTS");
10003 keymapenv = getenv("K2KEYMAPS");
10007 if (!scriptenv) /* Let this work for Unix etc too */
10008 scriptenv = getenv("CK_SCRIPTS"); /* Use this if defined */
10010 if (!scriptenv) /* Otherwise use home directory */
10011 scriptenv = homepath();
10015 ckstrncpy(takepath,scriptenv,TAKEPATHLEN);
10016 debug(F110,"TAKE initial takepath",takepath,0);
10020 keymapenv = getenv("CK_KEYMAPS");
10024 ckstrncat(takepath,
10025 (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
10028 ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN);
10029 ckstrncat(takepath,
10030 (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
10033 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10034 ckstrncat(takepath,";",TAKEPATHLEN);
10035 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10036 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10037 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10038 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10040 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10041 ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
10042 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10043 ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
10044 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10045 ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
10047 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10048 ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
10049 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10050 ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
10051 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10052 ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
10054 ckstrncat(takepath,inidir,TAKEPATHLEN);
10055 ckstrncat(takepath,";",TAKEPATHLEN);
10056 ckstrncat(takepath,inidir,TAKEPATHLEN);
10057 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10058 ckstrncat(takepath,inidir,TAKEPATHLEN);
10059 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10061 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10062 ckstrncat(takepath,";",TAKEPATHLEN);
10063 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10064 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10065 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10066 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10068 ckstrncat(takepath,exedir,TAKEPATHLEN);
10069 ckstrncat(takepath,";",TAKEPATHLEN);
10070 ckstrncat(takepath,exedir,TAKEPATHLEN);
10071 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10072 ckstrncat(takepath,exedir,TAKEPATHLEN);
10073 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10075 debug(F110,"TAKE final takepath",takepath,0);
10077 if ((y = cmifip("Commands from file",
10078 "",&s,&x,0,takepath,xxstring)) < 0) {
10080 printf("?A file name is required\n");
10086 printf("?Wildcards not allowed in command file name\n");
10089 ckstrncpy(line,s,LINBUFSIZ);
10090 debug(F110,"TAKE file",s,0);
10092 printf("?Can't execute a directory - \"%s\"\n", s);
10099 debug(F111,"TAKE args",line,x);
10101 if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0)
10103 if (*s) { /* Args given? */
10104 ckstrncpy(p,s,LINBUFSIZ-x-1);
10106 zfnqfp(line,TMPBUFSIZ,tmpbuf);
10110 #endif /* ZFNQFP */
10111 debug(F110,"TAKE filename",s,0);
10113 debug(F101,"TAKE new len",s,x);
10117 This was added in C-Kermit 7.0 to allow args to be passed from the TAKE
10118 command to the command file. But it overwrites the current argument vector,
10119 which is at best surprising, and at worst unsafe.
10121 addmac("%0",s); /* Define %0 = name of file */
10124 debug(F110,"take arg 0",s,0);
10125 debug(F110,"take args",p,0);
10126 for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */
10127 varnam[1] = (char) (y + '0');
10130 xwords(p,MAXARGLIST,NULL,0); /* Assign new args */
10131 debug(F110,"take args",p,0);
10134 This method is used in 8.0. If the TAKE command includes arguments, we
10135 insert an intermediate temporary macro between the current level; we pass
10136 the arguments to the macro and then the macro TAKEs the command file.
10137 If the user Ctrl-C's out of the TAKE file, some temporary macro definitions
10138 and other small malloc'd bits might be left behind.
10145 q = (char *)malloc(x+24);
10147 r = (char *)malloc(x+24);
10149 sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */
10150 sprintf(r,"take %s",s); /* safe */
10154 while (maclvl > m) {
10155 sstate = (CHAR) parser(1);
10156 if (sstate) proto();
10166 return(success = 0);
10167 #endif /* COMMENT */
10171 if ((y = cmcfm()) < 0) return(y);
10172 #endif /* NOTAKEARGS */
10173 return(success = dotake(line));
10178 if (cx == XXVIEW) { /* VIEW Only Terminal mode */
10180 success = doconect(0, 0);
10187 if (cx == XXTEL || cx == XXIKSD) { /* TELNET */
10191 printf("?Sorry, either TCP/IP is not available on this system or\n\
10192 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
10198 x = nettype; /* Save net type in case of failure */
10199 z = ttnproto; /* Save protocol in case of failure */
10200 nettype = NET_TCPB;
10201 ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT;
10202 if ((y = setlin(XYHOST,0,1)) <= 0) {
10203 nettype = x; /* Failed, restore net type. */
10204 ttnproto = z; /* and protocol */
10218 #endif /* NETPTY */
10219 #endif /* NETCMD */
10220 #endif /* PTYORPIPE */
10223 if (cx == XXPIPE || cx == XXPTY) { /* PIPE or PTY */
10225 extern int netsave;
10226 x = nettype; /* Save net type in case of failure */
10227 nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY;
10228 if ((y = setlin(XYHOST,0,1)) < 0) {
10229 nettype = x; /* Failed, restore net type. */
10230 ttnproto = z; /* and protocol */
10237 #endif /* PTYORPIPE */
10240 if (cx == XXSSH) { /* SSH (Secure Shell) */
10241 extern int netsave;
10243 int k, x, havehost = 0, trips = 0;
10244 int tmpver = -1, tmpxfw = -1;
10246 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
10247 extern int sl_ssh_ver, sl_ssh_ver_saved;
10248 #endif /* SSHTEST */
10249 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
10250 extern char * slmsg;
10251 extern char uidbuf[], sl_uidbuf[];
10252 extern char pwbuf[], * g_pswd;
10253 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
10254 struct FDB sw, kw, fl;
10257 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
10258 makestr(&ssh_tmpstr,NULL);
10259 makestr(&ssh_tmpuid,NULL);
10260 makestr(&ssh_tmpcmd,NULL);
10261 makestr(&ssh_tmpport,NULL);
10263 cmfdbi(&kw, /* 1st FDB - commands */
10264 _CMKEY, /* fcode */
10265 "host [ port ],\n or action", /* hlpmsg */
10267 "", /* addtl string data */
10268 nsshcmd, /* addtl numeric data 1: tbl size */
10269 0, /* addtl numeric data 2: 0 = keyword */
10270 xxstring, /* Processing function */
10271 sshkwtab, /* Keyword table */
10272 &fl /* Pointer to next FDB */
10274 cmfdbi(&fl, /* Host */
10275 _CMFLD, /* fcode */
10278 "", /* addtl string data */
10279 0, /* addtl numeric data 1 */
10280 0, /* addtl numeric data 2 */
10288 printf("?ssh what?\n");
10294 if (cmresult.fcode == _CMFLD) {
10296 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
10297 cmresult.nresult = XSSH_OPN;
10299 switch (cmresult.nresult) { /* SSH keyword */
10300 case XSSH_OPN: /* SSH OPEN */
10302 if ((x = cmfld("Host","",&s,xxstring)) < 0)
10304 ckstrncpy(line,s,LINBUFSIZ);
10306 /* Parse [ port ] [ switches ] */
10307 cmfdbi(&kw, /* Switches */
10309 "Port number or service name,\nor switch",
10318 cmfdbi(&fl, /* Port number or service name */
10329 trips = 0; /* Explained below */
10330 while (1) { /* Parse port and switches */
10331 x = cmfdb(&kw); /* Get a field */
10332 if (x == -3) /* User typed CR so quit from loop */
10334 if (x < 0) /* Other parse error, pass it back */
10336 switch (cmresult.fcode) { /* Field or Keyword? */
10337 case _CMFLD: /* Field */
10338 makestr(&ssh_tmpport,cmresult.sresult);
10340 case _CMKEY: /* Keyword */
10341 switch (cmresult.nresult) { /* Which one? */
10342 case SSHSW_USR: /* /USER: */
10344 printf("?This switch requires an argument\n");
10347 if ((y = cmfld("Username","",&s,xxstring)) < 0)
10350 makestr(&ssh_tmpuid,s);
10354 printf("?This switch requires an argument\n");
10358 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
10360 makestr(&ssh_tmpstr,"");
10366 if ((x = (int)strlen(s)) > PWBUFL) {
10367 makestr(&slmsg,"Internal error");
10368 printf("?Sorry, too long - max = %d\n",PWBUFL);
10371 makestr(&ssh_tmpstr,s);
10376 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
10378 if (z < 1 || z > 2) {
10379 printf("?Out of range: %d\n",z);
10386 if ((x = cmfld("Text","",&s,xxstring)) < 0)
10388 makestr(&ssh_tmpcmd,s);
10389 ssh_cas = (cmresult.nresult == SSHSW_SUB);
10392 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
10400 if (trips++ == 0) { /* After first time through */
10401 cmfdbi(&kw, /* only parse switches, not port. */
10414 if ((x = cmcfm()) < 0) /* Get confirmation */
10416 if (clskconnx(1) < 0) { /* Close current Kermit connection */
10417 if ( ssh_tmpstr ) {
10418 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
10419 makestr(&ssh_tmpstr,NULL);
10421 return(success = 0);
10423 makestr(&ssh_hst,line); /* Stash everything */
10425 if (!sl_uid_saved) {
10426 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
10429 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
10430 makestr(&ssh_tmpuid,NULL);
10433 makestr(&ssh_prt,ssh_tmpport);
10434 makestr(&ssh_tmpport,NULL);
10436 makestr(&ssh_prt,NULL);
10439 makestr(&ssh_cmd,brstrip(ssh_tmpcmd));
10440 makestr(&ssh_tmpcmd,NULL);
10442 makestr(&ssh_cmd,NULL);
10446 if (!sl_ssh_ver_saved) {
10447 sl_ssh_ver = ssh_ver;
10448 sl_ssh_ver_saved = 1;
10450 #endif /* SSHTEST */
10455 if (!sl_ssh_xfw_saved) {
10456 sl_ssh_xfw = ssh_xfw;
10457 sl_ssh_xfw_saved = 1;
10459 #endif /* SSHTEST */
10463 if (ssh_tmpstr[0]) {
10464 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
10469 makestr(&ssh_tmpstr,NULL);
10478 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
10479 g_pflg = pwflg; /* and flag */
10483 /* Line parameter to ttopen() is ignored */
10484 k = ttopen(line,&x,mdmtyp, 0);
10486 printf("?Unable to connect to %s\n",ssh_hst);
10489 return(success = 0);
10491 duplex = 0; /* Remote echo */
10492 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
10493 debug(F110,"ssh ttname",ttname,0);
10494 makestr(&slmsg,NULL); /* No SET LINE error message */
10498 #endif /* NODIAL */
10499 success = 1; /* SET LINE succeeded */
10500 network = 1; /* Network connection (not serial) */
10501 local = 1; /* Local mode (not remote) */
10502 if ((reliable != SET_OFF || !setreliable))
10503 reliable = SET_ON; /* Transport is reliable end to end */
10505 DialerSend(OPT_KERMIT_CONNECT, 0);
10507 setflow(); /* Set appropriate flow control */
10513 #endif /* NETCONN */
10514 #endif /* CKLOGDIAL */
10518 if (nmac) { /* Any macros defined? */
10520 k = mlook(mactab,"on_open",nmac); /* Look this up */
10521 if (k >= 0) { /* If found, */
10522 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
10523 parser(1); /* and execute it */
10533 /* Command was confirmed so we can pre-pop command level. */
10534 /* This is so CONNECT module won't think we're executing a */
10535 /* script if CONNECT was the final command in the script. */
10538 success = doconect(0,cmdlvl == 0 ? 1 : 0);
10544 if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) {
10546 printf("?clear what?\n");
10551 if ((x = cmcfm()) < 0)
10563 return(success = 1); /* or whatever */
10565 case XSSH_AGT: { /* SSH AGENT */
10567 if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0)
10570 case SSHA_ADD: /* SSH AGENT ADD ... */
10571 if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
10573 if (x == -3) /* No name given */
10574 doeach = 1; /* so do them all */
10576 #endif /* SSHTEST */
10579 ckstrncpy(line,s,LINBUFSIZ);
10580 if ((x = cmcfm()) < 0)
10588 for (i = 0; i < ssh_idf_n; i++)
10589 x += ssh_agent_add_file(ssh_idf[i]);
10591 x = ssh_agent_add_file(line);
10592 #endif /* SSHTEST */
10593 return(success = (x == 0));
10595 case SSHA_DEL: { /* SSH AGENT DELETE ... */
10597 if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
10599 if (x == -3) /* No name given */
10600 doall = 1; /* so do them all */
10602 #endif /* SSHTEST */
10605 ckstrncpy(line,s,LINBUFSIZ);
10606 if ((x = cmcfm()) < 0)
10612 x = ssh_agent_delete_all();
10614 x = ssh_agent_delete_file(line);
10615 #endif /* SSHTEST */
10616 return(success = (x == 0));
10619 int fingerprint = 0;
10620 if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) {
10623 } else if (cmgbrk() > SP) {
10624 printf("?This switch does not take an argument\n");
10626 } else if (y == SSHASW_FP) {
10629 if ((x = cmcfm()) < 0)
10632 return(success = 1);
10635 (ssh_agent_list_identities(fingerprint) == 0));
10636 #endif /* SSHTEST */
10642 case XSSH_ADD: { /* SSH ADD */
10643 /* ssh add { local, remote } port host port */
10646 if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0)
10648 if ((x = cmnum((cx == SSHF_LCL) ?
10649 "Local port number" : "Remote port number",
10650 "",10,&j,xxstring)) < 0)
10652 if ((x = cmfld("Host","",&s,xxstring)) < 0)
10655 if ((x = cmnum("Port","",10,&k,xxstring)) < 0)
10657 if ((x = cmcfm()) < 0)
10662 if (ssh_pf_lcl_n == 32) {
10664 "?Maximum number of local port forwardings already specified\n"
10667 return(success = 0);
10669 ssh_pf_lcl[ssh_pf_lcl_n].p1 = j;
10670 makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h);
10672 ssh_pf_lcl[ssh_pf_lcl_n].p2 = k;
10676 if (ssh_pf_rmt_n == 32) {
10678 "?Maximum number of remote port forwardings already specified\n"
10681 return(success = 0);
10683 ssh_pf_rmt[ssh_pf_rmt_n].p1 = j;
10684 makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h);
10686 ssh_pf_rmt[ssh_pf_rmt_n].p2 = k;
10689 return(success = 1);
10691 /* Not supporting arbitrary forwarding yet */
10692 case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */
10693 case XSSH_FRP: { /* SSH FORWARD-REMOTE-PORT */
10696 char * fw_host = NULL;
10698 if ((x = cmnum(cmresult.nresult == XSSH_FLP ?
10699 "local-port":"remote-port",
10700 "",10,&li_port,xxstring)) < 0)
10702 if (li_port < 1 || li_port > 65535) {
10703 printf("?Out range - min: 1, max: 65535\n");
10706 if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0)
10708 n = ckstrncpy(tmpbuf,s,TMPBUFSIZ);
10710 if ((x = cmnum("host-port",ckuitoa(li_port),10,
10711 &to_port,xxstring)) < 0)
10713 if (to_port < 1 || to_port > 65535) {
10714 printf("?Out range - min: 1, max: 65535\n");
10717 if ((x = cmcfm()) < 0)
10719 switch (cmresult.nresult) {
10720 case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */
10722 ssh_fwd_local_port(li_port,fw_host,to_port);
10723 #endif /* SSHTEST */
10724 return(success = 1);
10725 case XSSH_FRP: /* SSH FORWARD-REMOTE-PORT */
10727 ssh_fwd_remote_port(li_port,fw_host,to_port);
10728 #endif /* SSHTEST */
10729 return(success = 1);
10731 return(success = 1);
10733 case XSSH_V2: /* SSH V2 */
10734 if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0)
10738 if ((x = cmcfm()) < 0)
10742 #endif /* SSHTEST */
10743 return(success = 1);
10748 if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0)
10751 case SSHK_PASS: { /* Change passphrase */
10752 char * oldp = NULL, * newp = NULL;
10755 _CMKEY, /* fcode */
10756 "Filename, or switch", /* hlpmsg */
10758 "", /* addtl string data */
10759 2, /* addtl numeric data 1: tbl size */
10760 4, /* addtl numeric data 2: 4 = cmswi */
10761 xxstring, /* Processing function */
10762 sshkpsw, /* Keyword table */
10763 &df /* Pointer to next FDB */
10765 cmfdbi(&df, /* 2nd FDB - file for display */
10766 _CMIFI, /* output file */
10769 "", /* addtl string data */
10770 0, /* addtl numeric data 1 */
10771 0, /* addtl numeric data 2 */
10780 if (x == -3) break;
10783 if (cmresult.fcode != _CMKEY)
10786 printf("?This switch requires an argument\n");
10789 if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
10791 switch (cmresult.nresult) {
10799 if (cmresult.fcode == _CMIFI) { /* Filename */
10800 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10801 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10802 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10804 if ((x = cmcfm()) < 0) return(x);
10807 x = sshkey_change_passphrase(line[0] ? line : NULL,
10809 #endif /* SSHTEST */
10810 makestr(&oldp,NULL);
10811 makestr(&newp,NULL);
10812 success = (x == 0);
10815 case SSHK_CREA: { /* SSH KEY CREATE /switches... */
10816 int bits = 1024, keytype = SSHKT_2R;
10817 char * pass = NULL, * comment = NULL;
10821 * char * sshkey_default_file(int keytype)
10822 * will provide the default filename for a given keytype
10823 * is it possible to have the default value for the 2nd
10824 * FDB set and changed when a /TYPE switch is provided?
10825 * Would this allow for tab completion of the filename?
10828 _CMKEY, /* fcode */
10829 "Filename, or switch", /* hlpmsg */
10831 "", /* addtl string data */
10832 nsshkcrea, /* addtl numeric data 1: tbl size */
10833 4, /* addtl numeric data 2: 4 = cmswi */
10834 xxstring, /* Processing function */
10835 sshkcrea, /* Keyword table */
10836 &df /* Pointer to next FDB */
10838 cmfdbi(&df, /* 2nd FDB - file for display */
10839 _CMOFI, /* output file */
10842 "", /* addtl string data */
10843 0, /* addtl numeric data 1 */
10844 0, /* addtl numeric data 2 */
10853 if (x == -3) break;
10856 if (cmresult.fcode != _CMKEY)
10859 printf("?This switch requires an argument\n");
10862 switch (cmresult.nresult) {
10863 case SSHKC_BI: /* /BITS:n */
10864 if ((y = cmnum("","1024",10,&z,xxstring)) < 0)
10866 if (z < 512 || z > 4096) {
10867 printf("?Out range - min: 512, max: 4096\n");
10872 case SSHKC_PP: /* /PASSPHRASE:blah */
10873 if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
10877 case SSHKC_TY: /* /TYPE:keyword */
10878 if ((y = cmkey(sshkcty,nsshkcty,"",
10879 "v2-rsa",xxstring)) < 0)
10883 case SSHKC_1R: /* /COMMENT */
10884 if ((y = cmfld("Text","",&s,xxstring)) < 0)
10886 makestr(&comment,s);
10890 if (cmresult.fcode == _CMOFI) { /* Filename */
10891 if (cmresult.sresult) {
10892 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10893 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10894 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10897 if ((y = cmcfm()) < 0) /* Confirm */
10900 x = sshkey_create(line[0] ? line : NULL,
10901 bits, pass, keytype, comment);
10903 memset(pass,0,strlen(pass));
10904 #endif /* SSHTEST */
10905 makestr(&pass,NULL);
10906 makestr(&comment,NULL);
10907 return(success = (x == 0));
10909 case SSHK_DISP: { /* SSH KEY DISPLAY /switches... */
10911 int infmt = 0, outfmt = 0;
10914 _CMKEY, /* fcode */
10915 "Filename, or switch", /* hlpmsg */
10917 "", /* addtl string data */
10918 nsshdswi, /* addtl numeric data 1: tbl size */
10919 4, /* addtl numeric data 2: 4 = cmswi */
10920 xxstring, /* Processing function */
10921 sshdswi, /* Keyword table */
10922 &df /* Pointer to next FDB */
10924 cmfdbi(&df, /* 2nd FDB - file for display */
10925 _CMIFI, /* fcode */
10928 "", /* addtl string data */
10929 0, /* addtl numeric data 1 */
10930 0, /* addtl numeric data 2 */
10939 if (x == -3) break;
10942 if (cmresult.fcode != _CMKEY)
10945 printf("?This switch requires an argument\n");
10948 switch (cmresult.nresult) {
10950 case SSHKD_IN: /* /IN-FORMAT: */
10951 if ((y = cmkey(sshdifmt,nsshdifmt,
10952 "","",xxstring)) < 0)
10956 #endif /* COMMENT */
10957 case SSHKD_OUT: /* /FORMAT: */
10958 if ((y = cmkey(sshdofmt,nsshdofmt,
10959 "","",xxstring)) < 0)
10965 if (cmresult.fcode == _CMIFI) { /* Filename */
10966 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10967 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10968 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10972 printf("?Key filename required\n");
10975 #endif /* COMMENT */
10976 if ((y = cmcfm()) < 0) /* Confirm */
10981 /* 2nd param is optional passphrase */
10982 x = sshkey_display_public(line[0] ? line : NULL, NULL);
10985 /* 2nd param is optional passphrase */
10986 x = sshkey_display_public_as_ssh2(line[0] ? line : NULL,
10990 x = sshkey_display_fingerprint(line[0] ? line : NULL, 1);
10993 x = sshkey_display_fingerprint(line[0] ? line : NULL, 0);
10996 #endif /* SSHTEST */
10997 return(success = (x == 0));
10999 case SSHK_V1: /* SSH KEY V1 SET-COMMENT */
11000 if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0)
11002 if (x != 1) return(-2);
11003 if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) {
11005 printf("?Name of key file required\n");
11009 ckstrncpy(line,s,LINBUFSIZ);
11010 if ((x = cmtxt("Comment text","",&s,xxstring)) < 0)
11013 x = sshkey_v1_change_comment(line, /* filename */
11014 s, /* new comment */
11015 NULL /* passphrase */
11017 #endif /* SSHTEST */
11018 success = (x == 0);
11024 #else /* SSHBUILTIN */
11027 if ((y = setlin(XXSSH,0,1)) < 0) {
11029 printf("?%s\n",ck_errstr());
11032 /* This isn't right either because it catches command editing */
11033 printf("?Sorry, pseudoterminal open failed\n");
11035 printf("Hint: Try \"ssh -t %s\"\n",line);
11038 #endif /* COMMENT */
11039 nettype = x; /* Failed, restore net type. */
11040 ttnproto = z; /* and protocol */
11046 #endif /* SSHCMD */
11047 #endif /* SSHBUILTIN */
11049 #endif /* ANYSSH */
11052 if (cx == XXSKRM) { /* SKERMIT (Secure Shell Kermit) */
11053 extern int netsave;
11054 int k, x, havehost = 0, trips = 0;
11055 int tmpver = -1, tmpxfw = -1;
11057 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
11058 extern int sl_ssh_ver, sl_ssh_ver_saved;
11059 #endif /* SSHTEST */
11060 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
11061 extern char * slmsg;
11062 extern char uidbuf[], sl_uidbuf[];
11063 extern char pwbuf[], * g_pswd;
11064 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
11065 struct FDB sw, kw, fl;
11068 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11069 makestr(&ssh_tmpstr,NULL);
11070 makestr(&ssh_tmpuid,NULL);
11071 makestr(&ssh_tmpcmd,NULL);
11072 makestr(&ssh_tmpport,NULL);
11074 cmfdbi(&kw, /* 1st FDB - commands */
11075 _CMKEY, /* fcode */
11076 "host [ port ],\n or action", /* hlpmsg */
11078 "", /* addtl string data */
11079 nsshkermit, /* addtl numeric data 1: tbl size */
11080 0, /* addtl numeric data 2: 0 = keyword */
11081 xxstring, /* Processing function */
11082 sshkermit, /* Keyword table */
11083 &fl /* Pointer to next FDB */
11085 cmfdbi(&fl, /* Host */
11086 _CMFLD, /* fcode */
11089 "", /* addtl string data */
11090 0, /* addtl numeric data 1 */
11091 0, /* addtl numeric data 2 */
11099 printf("?skermit what?\n");
11105 if (cmresult.fcode == _CMFLD) {
11107 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
11108 cmresult.nresult = SKRM_OPN;
11110 switch (cmresult.nresult) { /* SSH keyword */
11111 case SKRM_OPN: /* SSH OPEN */
11113 if ((x = cmfld("Host","",&s,xxstring)) < 0)
11115 ckstrncpy(line,s,LINBUFSIZ);
11117 /* Parse [ port ] [ switches ] */
11118 cmfdbi(&kw, /* Switches */
11120 "Port number or service name,\nor switch",
11129 cmfdbi(&fl, /* Port number or service name */
11140 trips = 0; /* Explained below */
11141 while (1) { /* Parse port and switches */
11142 x = cmfdb(&kw); /* Get a field */
11143 if (x == -3) /* User typed CR so quit from loop */
11145 if (x < 0) /* Other parse error, pass it back */
11147 switch (cmresult.fcode) { /* Field or Keyword? */
11148 case _CMFLD: /* Field */
11149 makestr(&ssh_tmpport,cmresult.sresult);
11151 case _CMKEY: /* Keyword */
11152 switch (cmresult.nresult) { /* Which one? */
11153 case SSHSW_USR: /* /USER: */
11155 printf("?This switch requires an argument\n");
11158 if ((y = cmfld("Username","",&s,xxstring)) < 0)
11161 makestr(&ssh_tmpuid,s);
11165 printf("?This switch requires an argument\n");
11169 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
11171 makestr(&ssh_tmpstr,"");
11177 if ((x = (int)strlen(s)) > PWBUFL) {
11178 makestr(&slmsg,"Internal error");
11179 printf("?Sorry, too long - max = %d\n",PWBUFL);
11182 makestr(&ssh_tmpstr,s);
11187 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
11189 if (z < 1 || z > 2) {
11190 printf("?Out of range: %d\n",z);
11199 if (trips++ == 0) { /* After first time through */
11200 cmfdbi(&kw, /* only parse switches, not port. */
11213 if ((x = cmcfm()) < 0) /* Get confirmation */
11215 if (clskconnx(1) < 0) { /* Close current Kermit connection */
11216 if ( ssh_tmpstr ) {
11217 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11218 makestr(&ssh_tmpstr,NULL);
11220 return(success = 0);
11222 makestr(&ssh_hst,line); /* Stash everything */
11224 if (!sl_uid_saved) {
11225 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
11228 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
11229 makestr(&ssh_tmpuid,NULL);
11232 makestr(&ssh_prt,ssh_tmpport);
11233 makestr(&ssh_tmpport,NULL);
11235 makestr(&ssh_prt,NULL);
11237 /* Set the Subsystem to Kermit */
11239 makestr(&ssh_cmd,"kermit");
11243 if (!sl_ssh_ver_saved) {
11244 sl_ssh_ver = ssh_ver;
11245 sl_ssh_ver_saved = 1;
11247 #endif /* SSHTEST */
11250 /* Disable X11 Forwarding */
11252 if (!sl_ssh_xfw_saved) {
11253 sl_ssh_xfw = ssh_xfw;
11254 sl_ssh_xfw_saved = 1;
11256 #endif /* SSHTEST */
11260 if (ssh_tmpstr[0]) {
11261 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
11266 makestr(&ssh_tmpstr,NULL);
11275 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
11276 g_pflg = pwflg; /* and flag */
11280 /* Line parameter to ttopen() is ignored */
11281 k = ttopen(line,&x,mdmtyp, 0);
11283 printf("?Unable to connect to %s\n",ssh_hst);
11286 return(success = 0);
11288 duplex = 0; /* Remote echo */
11289 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
11290 debug(F110,"ssh ttname",ttname,0);
11291 makestr(&slmsg,NULL); /* No SET LINE error message */
11295 #endif /* NODIAL */
11296 success = 1; /* SET LINE succeeded */
11297 network = 1; /* Network connection (not serial) */
11298 local = 1; /* Local mode (not remote) */
11299 if ((reliable != SET_OFF || !setreliable))
11300 reliable = SET_ON; /* Transport is reliable end to end */
11302 DialerSend(OPT_KERMIT_CONNECT, 0);
11304 setflow(); /* Set appropriate flow control */
11310 #endif /* NETCONN */
11311 #endif /* CKLOGDIAL */
11315 if (nmac) { /* Any macros defined? */
11317 k = mlook(mactab,"on_open",nmac); /* Look this up */
11318 if (k >= 0) { /* If found, */
11319 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
11320 parser(1); /* and execute it */
11330 /* Command was confirmed so we can pre-pop command level. */
11331 /* This is so CONNECT module won't think we're executing a */
11332 /* script if CONNECT was the final command in the script. */
11335 return(success = 1);
11341 #endif /* SSHBUILTIN */
11343 #ifdef SFTP_BUILTIN
11344 if (cx == XXSFTP) { /* SFTP (Secure Shell File Transfer) */
11345 extern int netsave;
11346 int k, x, havehost = 0, trips = 0;
11347 int tmpver = -1, tmpxfw = -1;
11349 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
11350 extern int sl_ssh_ver, sl_ssh_ver_saved;
11351 #endif /* SSHTEST */
11352 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
11353 extern char * slmsg;
11354 extern char uidbuf[], sl_uidbuf[];
11355 extern char pwbuf[], * g_pswd;
11356 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
11357 struct FDB sw, kw, fl;
11360 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11361 makestr(&ssh_tmpstr,NULL);
11362 makestr(&ssh_tmpuid,NULL);
11363 makestr(&ssh_tmpcmd,NULL);
11364 makestr(&ssh_tmpport,NULL);
11366 cmfdbi(&kw, /* 1st FDB - commands */
11367 _CMKEY, /* fcode */
11368 "host [ port ],\n or action", /* hlpmsg */
11370 "", /* addtl string data */
11371 nsftpkwtab, /* addtl numeric data 1: tbl size */
11372 0, /* addtl numeric data 2: 0 = keyword */
11373 xxstring, /* Processing function */
11374 sftpkwtab, /* Keyword table */
11375 &fl /* Pointer to next FDB */
11377 cmfdbi(&fl, /* Host */
11378 _CMFLD, /* fcode */
11381 "", /* addtl string data */
11382 0, /* addtl numeric data 1 */
11383 0, /* addtl numeric data 2 */
11391 printf("?sftp what?\n");
11397 if (cmresult.fcode == _CMFLD) {
11399 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
11400 cmresult.nresult = SFTP_OPN;
11402 switch (cmresult.nresult) { /* SFTP keyword */
11403 case SFTP_OPN: /* SFTP OPEN */
11405 if ((x = cmfld("Host","",&s,xxstring)) < 0)
11407 ckstrncpy(line,s,LINBUFSIZ);
11409 /* Parse [ port ] [ switches ] */
11410 cmfdbi(&kw, /* Switches */
11412 "Port number or service name,\nor switch",
11421 cmfdbi(&fl, /* Port number or service name */
11432 trips = 0; /* Explained below */
11433 while (1) { /* Parse port and switches */
11434 x = cmfdb(&kw); /* Get a field */
11435 if (x == -3) /* User typed CR so quit from loop */
11437 if (x < 0) /* Other parse error, pass it back */
11439 switch (cmresult.fcode) { /* Field or Keyword? */
11440 case _CMFLD: /* Field */
11441 makestr(&ssh_tmpport,cmresult.sresult);
11443 case _CMKEY: /* Keyword */
11444 switch (cmresult.nresult) { /* Which one? */
11445 case SSHSW_USR: /* /USER: */
11447 printf("?This switch requires an argument\n");
11450 if ((y = cmfld("Username","",&s,xxstring)) < 0)
11453 makestr(&ssh_tmpuid,s);
11457 printf("?This switch requires an argument\n");
11461 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
11463 makestr(&ssh_tmpstr,"");
11469 if ((x = (int)strlen(s)) > PWBUFL) {
11470 makestr(&slmsg,"Internal error");
11471 printf("?Sorry, too long - max = %d\n",PWBUFL);
11474 makestr(&ssh_tmpstr,s);
11479 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
11481 if (z < 1 || z > 2) {
11482 printf("?Out of range: %d\n",z);
11491 if (trips++ == 0) { /* After first time through */
11492 cmfdbi(&kw, /* only parse switches, not port. */
11505 if ((x = cmcfm()) < 0) /* Get confirmation */
11507 if (clskconnx(1) < 0) { /* Close current Kermit connection */
11508 if ( ssh_tmpstr ) {
11509 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11510 makestr(&ssh_tmpstr,NULL);
11512 return(success = 0);
11514 makestr(&ssh_hst,line); /* Stash everything */
11516 if (!sl_uid_saved) {
11517 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
11520 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
11521 makestr(&ssh_tmpuid,NULL);
11524 makestr(&ssh_prt,ssh_tmpport);
11525 makestr(&ssh_tmpport,NULL);
11527 makestr(&ssh_prt,NULL);
11529 /* Set the Subsystem to Kermit */
11531 makestr(&ssh_cmd,"sftp");
11535 if (!sl_ssh_ver_saved) {
11536 sl_ssh_ver = ssh_ver;
11537 sl_ssh_ver_saved = 1;
11539 #endif /* SSHTEST */
11542 /* Disable X11 Forwarding */
11544 if (!sl_ssh_xfw_saved) {
11545 sl_ssh_xfw = ssh_xfw;
11546 sl_ssh_xfw_saved = 1;
11548 #endif /* SSHTEST */
11552 if (ssh_tmpstr[0]) {
11553 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
11558 makestr(&ssh_tmpstr,NULL);
11567 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
11568 g_pflg = pwflg; /* and flag */
11572 /* Line parameter to ttopen() is ignored */
11573 k = ttopen(line,&x,mdmtyp, 0);
11575 printf("?Unable to connect to %s\n",ssh_hst);
11578 return(success = 0);
11580 duplex = 0; /* Remote echo */
11581 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
11582 debug(F110,"ssh ttname",ttname,0);
11583 makestr(&slmsg,NULL); /* No SET LINE error message */
11587 #endif /* NODIAL */
11588 success = 1; /* SET LINE succeeded */
11589 network = 1; /* Network connection (not serial) */
11590 local = 1; /* Local mode (not remote) */
11591 if ((reliable != SET_OFF || !setreliable))
11592 reliable = SET_ON; /* Transport is reliable end to end */
11594 DialerSend(OPT_KERMIT_CONNECT, 0);
11596 setflow(); /* Set appropriate flow control */
11602 #endif /* NETCONN */
11603 #endif /* CKLOGDIAL */
11607 if (nmac) { /* Any macros defined? */
11609 k = mlook(mactab,"on_open",nmac); /* Look this up */
11610 if (k >= 0) { /* If found, */
11611 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
11612 parser(1); /* and execute it */
11622 /* Command was confirmed so we can pre-pop command level. */
11623 /* This is so CONNECT module won't think we're executing a */
11624 /* script if CONNECT was the final command in the script. */
11628 success = sftp_do_init();
11629 return(success = 1);
11645 if ((y = cmtxt("command parameters","",&s,xxstring)) < 0)
11647 if (ssh_tchk() < 0 || !ssh_cas || strcmp(ssh_cmd,"sftp")) {
11648 printf("?Not connected to SFTP Service\n");
11649 return(success = 0);
11651 success = sftp_do_cmd(cmresult.nresult,s);
11657 #endif /* SFTP_BUILTIN */
11659 if (cx == XXRLOG) { /* RLOGIN */
11664 printf("?Sorry, either TCP/IP is not available on this system or\n\
11665 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"
11671 x = nettype; /* Save net type in case of failure */
11672 z = ttnproto; /* Save protocol in case of failure */
11673 nettype = NET_TCPB;
11674 ttnproto = NP_RLOGIN;
11675 if ((y = setlin(XYHOST,0,1)) <= 0) {
11676 nettype = x; /* Failed, restore net type. */
11677 ttnproto = z; /* and protocol */
11686 printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n");
11688 #endif /* RLOGCODE */
11690 #endif /* NETCONN */
11691 #endif /* NOLOCAL */
11694 if (cx == XXTRA) { /* TRANSMIT */
11696 int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval;
11700 struct FDB sf, sw, tx; /* FDBs for parse functions */
11702 extern int tcs_transp; /* Term charset is transparent */
11704 int tcs_transp = 1;
11705 #endif /* NOCSETS */
11708 xbinary = binary; /* Default text/binary mode */
11710 xbinary = 0; /* Default is text */
11711 #endif /* COMMENT */
11714 cmfdbi(&sw, /* First FDB - command switches */
11715 _CMKEY, /* fcode */
11716 "Filename, or switch", /* hlpmsg */
11718 "", /* addtl string data */
11719 nxmitsw, /* addtl numeric data 1: tbl size */
11720 4, /* addtl numeric data 2: 4 = cmswi */
11721 xxstring, /* Processing function */
11722 xmitsw, /* Keyword table */
11723 &sf /* Pointer to next FDB */
11725 cmfdbi(&sf, /* 2nd FDB - file to send */
11726 _CMIFI, /* fcode */
11727 "File to transmit", /* hlpmsg */
11729 "", /* addtl string data */
11730 0, /* addtl numeric data 1 */
11731 0, /* addtl numeric data 2 */
11738 #endif /* PIPESEND */
11742 _CMTXT, /* fcode */
11743 "Command", /* hlpmsg */
11745 "", /* addtl string data */
11746 0, /* addtl numeric data 1 */
11747 0, /* addtl numeric data 2 */
11752 #endif /* PIPESEND */
11758 if (cmresult.fcode != _CMKEY)
11760 c = cmgbrk(); /* Have switch, get break character */
11761 if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
11762 printf("?This switch does not take an argument\n");
11765 if (!getval && (cmgkwflgs() & CM_ARG)) {
11766 printf("?This switch requires an argument\n");
11769 n = cmresult.nresult; /* Numeric result = switch ID */
11770 switch (n) { /* Process the switch */
11772 case XMI_CMD: /* Transmit from a command */
11774 printf("?Sorry, system command access is disabled\n");
11777 sw.hlpmsg = "Command, or switch"; /* Change help message */
11778 xpipe = 1; /* (No way to undo this one) */
11780 #endif /* PIPESEND */
11782 case XMI_BIN: /* Binary */
11784 xxlate = 0; /* Don't translate charsets */
11788 case XMI_TXT: /* Text */
11790 xxlate = !tcs_transp; /* Translate if TERM CHAR not TRANSP */
11794 case XMI_TRA: /* Transparent text */
11796 xxlate = 0; /* But don't translate charsets */
11801 case XMI_VRB: /* /VERBOSE */
11802 case XMI_QUI: /* /QUIET */
11803 break; /* (not implemented yet) */
11804 #endif /* COMMENT */
11806 case XMI_NOW: /* /NOWAIT */
11810 case XMI_NOE: /* /NOWAIT */
11819 if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT)
11821 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */
11822 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
11823 ckstrncpy(line,tmpbuf,LINBUFSIZ);
11825 if ((y = cmcfm()) < 0) /* Confirm */
11828 if ((apcactive == APC_LOCAL) ||
11829 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
11830 return(success = 0);
11831 #endif /* CK_APC */
11832 if (cmresult.nresult != 0) {
11833 printf("?Only a single file may be transmitted\n");
11840 printf("?Sorry, a command to send from is required\n");
11845 #endif /* PIPESEND */
11847 if (scan && (filepeek
11850 #endif /* NOXFER */
11851 )) { /* If user didn't specify type */
11852 int k, x; /* scan the file to see */
11854 k = scanfile(s,&x,nscanfile);
11855 if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
11857 if (!xfrxla) xxlate = 0;
11858 success = transmit(s,
11859 (char) (xxnowait ? '\0' : (char)xmitp),
11866 #endif /* NOXMIT */
11869 if (cx == XXTYP || cx == XXCAT || cx == XXMORE ||
11870 cx == XXHEAD || cx == XXTAIL) {
11871 int paging = 0, havename = 0, head = 0, width = 0;
11872 int height = 0, count = 0;
11873 char pfxbuf[64], * prefix = NULL;
11874 char outfile[CKMAXPATH+1];
11877 int incs = 0, outcs = 0, cset = -1, number = 0;
11880 extern int fileorder;
11883 char guibuf[128], * gui_title = NULL;
11887 extern int tcsr, tcsl;
11888 #endif /* NOCSETS */
11890 #endif /* UNICODE */
11896 else if (cx == XXCAT)
11899 paging = (typ_page < 0) ? xaskmore : typ_page;
11903 if (cx == XXHEAD) {
11906 } else if (cx == XXTAIL) {
11912 if (inserver && !ENABLED(en_typ)) {
11913 printf("?Sorry, TYPE command disabled\n");
11918 cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */
11919 _CMKEY, /* fcode */
11920 "Filename or switch", /* hlpmsg */
11922 "", /* addtl string data */
11923 ntypetab, /* addtl numeric data 1: tbl size */
11924 4, /* addtl numeric data 2: 4 = cmswi */
11925 xxstring, /* Processing function */
11926 typetab, /* Keyword table */
11927 &sf /* Pointer to next FDB */
11929 cmfdbi(&sf, /* 1st FDB - file to type */
11930 _CMIFI, /* fcode */
11933 "", /* addtl string data */
11934 0, /* addtl numeric data 1 */
11935 0, /* addtl numeric data 2 */
11941 while (!havename) {
11942 x = cmfdb(&sw); /* Parse something */
11943 debug(F101,"type cmfdb","",x);
11944 debug(F101,"type cmresult.fcode","",cmresult.fcode);
11945 debug(F101,"type cmresult.nresult","",cmresult.nresult);
11946 if (x < 0) { /* Error */
11949 printf("?Filename required\n");
11952 } else if (cmresult.fcode == _CMKEY) {
11953 char c; int getval;
11955 getval = (c == ':' || c == '=');
11956 if (getval && !(cmgkwflgs() & CM_ARG)) {
11957 printf("?This switch does not take an argument\n");
11961 if (!getval && (cmgkwflgs() & CM_ARG)) {
11962 printf("?This switch requires an argument\n");
11963 /* Not if it has a default! */
11966 #endif /* COMMENT */
11967 switch (cmresult.nresult) {
11976 #endif /* CK_TTGWSIZ */
11987 if ((x = cmnum("Number of lines",
11988 "10",10,&y,xxstring)) < 0)
11990 head = (cmresult.nresult == TYP_TAI) ? -y : y;
11994 y = typ_wid > -1 ? typ_wid : cmd_cols;
11996 if ((x = cmnum("Column at which to truncate",
11997 ckitoa(y),10,&y,xxstring)) < 0)
12005 if ((x = cmnum("Height of GUI dialog",
12006 ckitoa(y),10,&y,xxstring)) < 0)
12013 if (!getval && (cmgkwflgs() & CM_ARG)) {
12014 printf("?This switch requires an argument\n");
12017 if ((x = cmfld("pattern","",&s,xxstring)) < 0)
12019 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12024 if (!getval && (cmgkwflgs() & CM_ARG)) {
12025 printf("?This switch requires an argument\n");
12028 if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0)
12030 if ((int)strlen(s) > 63) {
12031 printf("?Too long - 63 max\n");
12034 ckstrncpy(pfxbuf,s,64);
12035 prefix = brstrip(pfxbuf);
12041 if (!getval && (cmgkwflgs() & CM_ARG)) {
12042 printf("?This switch requires an argument\n");
12045 if ((x = cmfld("Dialog box title","",&s,xxstring)) < 0) {
12049 if ((int)strlen(s) > 127) {
12050 printf("?Too long - 127 max\n");
12053 ckstrncpy(guibuf,s,128);
12054 gui_title = brstrip(guibuf);
12060 case TYP_NUM: /* /NUMBER */
12066 case TYP_XPA: /* /TRANSPARENT */
12072 case TYP_XIN: /* /CHARACTER-SET: */
12073 if (!getval && (cmgkwflgs() & CM_ARG)) {
12074 printf("?This switch requires an argument\n");
12077 if ((incs = cmkey(fcstab,nfilc,
12078 "character-set name","",xxstring)) < 0) {
12079 if (incs == -3) /* Note: No default */
12086 case TYP_XUT: /* /TRANSLATE-TO: */
12087 if (!getval && (cmgkwflgs() & CM_ARG)) {
12088 printf("?This switch requires an argument\n");
12092 if (!inserver && !k95stdout) {
12096 tocs = rlookup(txrtab,ntxrtab,tcsl);
12098 extern struct keytab ttcstab[];
12099 extern int ntxrtab;
12100 tocs = rlookup(ttcstab,ntermc,tocs);
12103 #endif /* CKOUNI */
12108 if ((outcs = cmkey(fcstab,nfilc,
12109 "character-set",tocs,xxstring)) < 0)
12112 #endif /* UNICODE */
12114 if ((x = cmofi("File for result lines","",
12117 ckstrncpy(outfile,s,CKMAXPATH);
12120 } else if (cmresult.fcode == _CMIFI)
12126 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
12127 y = cmresult.nresult;
12129 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
12131 printf("?Name of an existing file required\n");
12135 ckstrncpy(line,s,LINBUFSIZ);
12138 printf("?A single file please\n");
12142 if ( outfile[0] && gui ) {
12143 printf("?/GUI and /OUTPUT are incompatible\n");
12148 if ((y = cmcfm()) < 0) /* Confirm the command */
12153 if (cset < 0 && filepeek) { /* If no charset switches given */
12155 k = scanfile(line,&x,nscanfile); /* Call file analyzer */
12156 debug(F111,"type scanfile",line,k);
12157 debug(F101,"type scanfile flag","",x);
12159 case FT_UTF8: /* which can detect UTF-8... */
12163 case FT_UCS2: /* and UCS-2... */
12166 fileorder = x; /* even if there is no BOM. */
12167 debug(F101,"type fileorder","",fileorder);
12172 if (cset < 0) { /* If input charset still not known */
12174 tocs = rlookup(txrtab,ntxrtab,tcsl);
12176 extern struct keytab ttcstab[];
12177 extern int ntxrtab;
12178 tocs = rlookup(ttcstab,ntermc,incs);
12181 #endif /* CKOUNI */
12182 incs = lookup(fcstab,tocs,nfilc,&x);
12186 if (outcs == 0 && incs != 0) { /* Supply default target charset */
12187 int x = 0; /* if switch not given. */
12189 outcs = lookup(fcstab,tocs,nfilc,&x);
12191 #else /* !UNICODE */
12192 if (cset < 0) incs = outcs = 0;
12193 #endif /* UNICODE */
12195 if (outfile[0] && paging) /* This combination makes no sense */
12196 paging = 0; /* so turn off paging */
12199 /* No paging when dialog is used */
12200 if ( gui && paging )
12203 if ( !gui && height ) {
12204 printf("?The /HEIGHT switch is not supported without /GUI\n");
12209 if (count) paging = -1;
12210 debug(F111,"type",line,paging);
12213 s = (char *)1; /* ok, its an ugly hack */
12214 if (gui_text_popup_create(gui_title ?
12215 gui_title : line, height,width) < 0) {
12216 printf("?/GUI not supported on this system\n");
12225 dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number);
12228 #endif /* NOFRILLS */
12231 if (cx == XXXLA) { /* TRANSLATE file's charset */
12232 _PROTOTYP (int doxlate, ( void ) );
12235 #endif /* NOCSETS */
12237 if (cx == XXVER) { /* VERSION */
12239 extern char * ck_patch, * ck_s_test;
12241 extern int hmtopline;
12242 #endif /* COMMENT */
12243 if ((y = cmcfm()) < 0)
12246 printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum);
12248 printf("Authors:\n");
12249 printf(" Frank da Cruz, Columbia University\n");
12250 printf(" Jeffrey Eric Altman, Secure Endpoints, Inc. %s\n",
12251 "<jaltman@secure-endpoints.com>"
12253 printf(" Contributions from many others.\n");
12256 printf("\nTHIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n");
12260 printf(" Patches: %s\n", ck_patch);
12263 printf(" Type COPYRIGHT for copyright and license.\n\n");
12271 #endif /* COMMENT */
12273 return(success = 1);
12276 if (cx == XXCPR) { /* COPYRIGHT or LICENSE */
12277 if ((y = cmcfm()) < 0)
12280 if (inserver) { /* Free WIKSD */
12281 extern char * wiksdcpr[];
12286 return(success = 1);
12289 #ifndef MAC /* Only for multiuser systems */
12292 if (cx == XXWHO) { /* WHO */
12295 if (inserver && !ENABLED(en_who)) {
12296 printf("?Sorry, WHO command disabled\n");
12301 if ((z = cmcfm()) < 0) return(z);
12303 printf("?Sorry, who not allowed\n");
12304 return(success = 0);
12308 if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y);
12310 printf("?Sorry, WHO command disabled\n");
12311 return(success = 0);
12313 if (!(wc = getenv("CK_WHO"))) wc = WHOCMD;
12315 if ((int) strlen(wc) > 0) {
12316 ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL);
12319 #endif /* datageneral */
12320 return(success = 1);
12322 #endif /* NOFRILLS */
12327 if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */
12328 int x,y; /* On stack in case of \fexec() */
12329 if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) {
12330 if (x == -3) printf("?Write to what?\n");
12333 if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y);
12336 case LOGD: y = ZDFILE; break;
12337 case LOGP: y = ZPFILE; break;
12339 case LOGS: y = ZSFILE; break;
12340 #endif /* NOLOCAL */
12341 case LOGT: y = ZTFILE; break;
12343 case LOGW: y = ZWFILE; break;
12345 case LOGX: /* SCREEN (stdout) */
12346 case LOGE: /* ERROR (stderr) */
12349 (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0);
12350 fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : "");
12353 (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0);
12354 printf("%s%s",s,(cx == XXWRL) ? "\n" : "");
12356 return(success = 1);
12357 default: return(-2);
12359 if (chkfn(y) > 0) {
12360 x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s);
12361 if (x < 0) printf("?Write error\n");
12364 printf("?File or log not open\n");
12366 return(success = (x == 0) ? 1 : 0);
12368 #endif /* NOFRILLS */
12371 if (cx == XXASC || cx == XXBIN) {
12372 if ((x = cmcfm()) < 0) return(x);
12374 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
12375 return(success = doftptyp((cx == XXASC) ? 0 : 1));
12376 #endif /* NEWFTP */
12377 binary = (cx == XXASC) ? XYFT_T : XYFT_B;
12378 return(success = 1);
12380 #endif /* NOXFER */
12383 if ((x = cmcfm()) < 0) return(x);
12385 return(success = (y > -1) ? 1 : 0);
12389 if (cx == XXMKDIR || cx == XXLMKD) {
12392 if (!locus && cx != XXLMKD) {
12396 return(dormt(XZMKD));
12397 #endif /* NOXFER */
12401 if (inserver && !ENABLED(en_mkd)) {
12402 printf("?Sorry, directory creation is disabled\n");
12406 if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) {
12410 printf("?Directory name required\n");
12414 ckstrncpy(line,s,LINBUFSIZ);
12416 if ((x = cmcfm()) < 0) return(x);
12418 bgchk(); /* Set msgflg */
12419 x = ckmkdir(0,s,&p,msgflg,0);
12421 if (msgflg && x == 0)
12422 printf("?Directory already exists\n");
12423 #endif /* COMMENT */
12424 return(success = (x < 0) ? 0 : 1);
12426 if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */
12429 if (!locus && cx != XXLRMD) {
12433 return(dormt(XZRMD));
12434 #endif /* NOXFER */
12438 if (inserver && !ENABLED(en_rmd)) {
12439 printf("?Sorry, directory removal is disabled\n");
12443 if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0)
12445 ckstrncpy(line,s,LINBUFSIZ);
12447 if ((x = cmcfm()) < 0) return(x);
12449 x = ckmkdir(1,s,&p,msgflg,0);
12450 return(success = (x < 0) ? 0 : 1);
12452 #endif /* CK_MKDIR */
12456 return(dotelopt());
12457 #endif /* TNCODE */
12460 if (cx == XXNPSH) {
12461 if ((z = cmcfm()) < 0) return(z);
12465 #endif /* NOSERVER */
12468 #endif /* PIPESEND */
12469 return(success = 1);
12471 #endif /* NOPUSH */
12474 if (cx == XXNSCR) {
12475 if ((z = cmcfm()) < 0) return(z);
12477 return(success = 1);
12482 if (cx == XXLOCAL) /* LOCAL variable declarations */
12483 return(success = dolocal());
12486 if (cx == XXKERMI) { /* The KERMIT command */
12488 extern char **xargv;
12491 if ((y = cmtxt("kermit command-line arguments, -h for help",
12492 "",&s,xxstring)) < 0)
12494 ckstrncpy(line,"kermit ",LINBUFSIZ);
12495 ckstrncat(line,s,LINBUFSIZ-8);
12496 xwords(line,64,list,0);
12497 for (i = 1; i < 64; i++) {
12507 extern int justone;
12508 debug(F000,"KERMIT sstate","",sstate);
12509 justone = 1; /* Force return to command mode */
12510 proto(); /* after protocol */
12513 debug(F101,"KERMIT sstate","",sstate);
12514 return(success = 1); /* Not exactly right, but... */
12517 if (cx == XXDATE) { /* DATE command */
12518 extern char cmdatebuf[], * cmdatemsg;
12522 if ((y = cmtxt("date and/or time, or carriage return for current",
12523 "",&s,xxstring)) < 0)
12526 dp = cmcvtdate(s,1);
12528 printf("?%s\n",cmdatemsg ? cmdatemsg : "Date conversion error");
12535 /* This works fine but messes up my "dates" torture-test script */
12537 if ((x = cmdate("Date and/or time, or carriage return for current",
12538 "",&s,0,xxstring)) < 0) {
12541 printf("%s\n",cmdatebuf);
12544 #endif /* COMMENT */
12551 #endif /* NOFRILLS */
12552 #endif /* NOPUSH */
12554 #ifdef BROWSER /* Defined only ifndef NOPUSH */
12556 return(dobrowse());
12557 #endif /* BROWSER */
12560 if (cx == XXTAPI) { /* Microsoft TAPI */
12561 return (success = dotapi());
12563 #endif /* CK_TAPI */
12566 if (cx == XXWHERE) {
12567 extern char * rfspec, * sfspec, * srfspec, * rrfspec;
12568 if ((x = cmcfm()) < 0) return(x);
12569 printf("\nFile most recently...\n\n");
12570 printf(" Sent: %s\n", sfspec ? sfspec : "(none)");
12571 if (sfspec && srfspec) {
12572 printf(" Stored as: %s\n", srfspec);
12575 printf(" Received: %s\n", rrfspec ? rrfspec : "(none)");
12576 if (rfspec && rrfspec)
12577 printf(" Stored as: %s\n", rfspec);
12579 "\nIf the full path is not shown, then the file is probably in your current\n"
12582 "directory or your download directory (if any - SHOW FILE to find out).\n\n"
12584 return(success = 1);
12586 #endif /* NOXFER */
12591 #endif /* CK_RECALL */
12594 if (cx == XXCHRT) /* Change Kermit's root directory */
12595 return(dochroot());
12596 #endif /* CKROOT */
12599 if (cx == XXAUTH) { /* KERBEROS */
12600 x = cp_auth(); /* Parse it */
12603 printf("?Command disabled in IKSD.\r\n");
12604 return(success = 0);
12607 if (x < 0) /* Pass parse errors back */
12609 return(success = doauth(cx));
12611 #endif /* CK_KERBEROS */
12614 if (cx == XXTERM) {
12615 return(settrmtyp());
12617 #endif /* NOLOCAL */
12619 if (cx == XXSTATUS) {
12620 if ((x = cmcfm()) < 0) return(x);
12621 printf( " %s\n", success ? "SUCCESS" : "FAILURE" );
12622 return(0); /* Don't change it */
12625 if (cx == XXFAIL) {
12626 if ((x = cmcfm()) < 0) return(x);
12627 return(success = 0);
12630 if (cx == XXSUCC) {
12631 if ((x = cmcfm()) < 0) return(x);
12632 return(success = 1);
12635 if (cx == XXNLCL) {
12636 extern int nolocal;
12637 if ((x = cmcfm()) < 0) return(x);
12639 return(success = 1);
12643 if (cx == XXRASG) /* Shortcuts for REMOTE commands */
12644 return(dormt(XZASG));
12646 return(dormt(XZCWD));
12648 return(dormt(XZCPY));
12650 return(dormt(XZDEL));
12652 return(dormt(XZDIR));
12654 return(dormt(XZXIT));
12656 return(dormt(XZHLP));
12658 return(dormt(XZHOS));
12660 return(dormt(XZKER));
12662 return(dormt(XZPWD));
12664 return(dormt(XZQUE));
12666 return(dormt(XZREN));
12668 return(dormt(XZMKD));
12670 return(dormt(XZRMD));
12672 return(dormt(XZSET));
12674 return(dormt(XZSPA));
12676 return(dormt(XZTYP));
12678 return(dormt(XZWHO));
12680 return(dormt(XZCDU));
12682 return(dormt(XZPRI));
12683 #endif /* NOXFER */
12685 if (cx == XXRESET) { /* RESET */
12686 if ((x = cmcfm()) < 0)
12688 doclean(0); /* Close all files */
12689 return(success = 1);
12694 if (cx == XXASSOC) /* ASSOCIATE */
12696 #endif /* NOCSETS */
12697 #endif /* NOXFER */
12700 if (cx == XXSHIFT) { /* SHIFT */
12701 if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0)
12703 if ((z = cmcfm()) < 0)
12705 return(success = doshift(x));
12711 return(domanual());
12712 #endif /* NOHELP */
12715 if (cx == XXSORT) /* SORT an array */
12719 if (cx == XXPURGE) {
12721 if (inserver && (!ENABLED(en_del)
12724 #endif /* CK_LOGIN */
12726 printf("?Sorry, DELETE is disabled\n");
12731 if ((apcactive == APC_LOCAL) ||
12732 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
12733 return(success = 0);
12734 #endif /* CK_APC */
12739 if ((x = cmtxt("optional switches followed by filespec",
12740 "",&s,xxstring)) < 0)
12743 printf("?Sorry, DCL access is disabled\n");
12746 ckstrncpy(line,s,LINBUFSIZ);
12748 x = mlook(mactab,"purge",nmac);
12749 return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs));
12753 #endif /* CKPURGE */
12757 if (cx == XXFAST) {
12758 if ((x = cmcfm()) < 0) return(x);
12759 x = mlook(mactab,"fast",nmac);
12760 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12763 if ((x = cmcfm()) < 0) return(x);
12764 x = mlook(mactab,"cautious",nmac);
12765 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12768 if ((x = cmcfm()) < 0) return(x);
12769 x = mlook(mactab,"robust",nmac);
12770 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12774 if (cx == XXSCRN) { /* SCREEN */
12776 if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0)
12778 switch (x) { /* MOVE-TO (cursor position) */
12780 if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0)
12783 y = cmnum("Column (1-based)","1",10,&z,xxstring);
12787 if ((y = cmcfm()) < 0)
12789 if (row < 0 || col < 0) {
12790 printf("?Row and Column must be 1 or greater\n");
12793 if (cmd_rows > 0 && row > cmd_rows)
12795 if (cmd_cols > 0 && col > cmd_cols)
12797 y = ck_curpos(row,col);
12798 return(success = (y > -1) ? 1 : 0);
12800 case SCN_CLR: /* CLEAR */
12801 if ((y = cmcfm()) < 0)
12803 debug(F100,"screen calling ck_cls()","",0);
12805 return(success = (y > -1) ? 1 : 0);
12807 case SCN_CLE: /* CLEOL */
12808 if ((y = cmcfm()) < 0)
12811 return(success = (y > -1) ? 1 : 0);
12819 #endif /* TCPSOCKET */
12820 #endif /* NOHTTP */
12823 if (cx == XXARRAY) { /* ARRAY */
12825 extern int showarray();
12826 #endif /* NOSHOW */
12827 if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0)
12831 return(dodcl(XXDCL));
12836 return(showarray());
12837 #endif /* NOSHOW */
12839 return(copyarray());
12842 return(clrarray(x));
12846 return(rszarray());
12848 return(linkarray());
12851 printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf);
12862 return(douchmod()); /* Do Unix chmod */
12864 #endif /* CK_PERMS */
12867 return(doprompt());
12872 if (cx == XXDEBUG) { /* DEBUG */
12875 return(seton(&dummy));
12877 return(seton(&deblog));
12882 if (cx == XXLEARN) { /* LEARN */
12883 struct FDB of, sw, cm;
12884 int closing = 0, off = 0, on = 0, confirmed = 0;
12887 cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */
12888 _CMKEY, /* fcode */
12889 "Script file name, or switch", /* hlpmsg */
12891 "", /* addtl string data */
12892 3, /* addtl numeric data 1: tbl size */
12893 4, /* addtl numeric data 2: 4 = cmswi */
12894 xxstring, /* Processing function */
12895 learnswi, /* Keyword table */
12896 &of /* Pointer to next FDB */
12898 cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm);
12899 cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL);
12902 while (!confirmed) {
12903 x = cmfdb(&sw); /* Parse something */
12906 switch (cmresult.fcode) { /* What was it? */
12907 case _CMOFI: /* Output file name */
12908 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
12910 case _CMKEY: /* Switch */
12912 if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) {
12913 printf("?This switch does not take an argument\n");
12916 switch (cmresult.nresult) {
12917 case 2: /* /CLOSE */
12918 closing = 1; /* Fall thru on purpose */
12929 case _CMCFM: /* Confirmation */
12939 makestr(&learnfile,NULL);
12948 makestr(&learnfile,line);
12950 char * modes = "w";
12951 learnfp = fopen(learnfile,modes);
12953 debug(F110,"LEARN file open error",learnfile,0);
12958 if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf))
12959 makestr(&learnfile,tmpbuf);
12960 #endif /* ZFNQFP */
12961 debug(F110,"LEARN file open ok",learnfile,0);
12963 printf("Recording to %s...\n\n",learnfile);
12965 " WARNING: If you type your password during script recording, it will appear\n\
12966 in the file. Be sure to edit it or take other appropriate precautions.\n\n"
12969 fputs( "; Scriptfile: ",learnfp);
12970 fputs(learnfile,learnfp);
12971 fputs("\n; Directory: ",learnfp);
12972 fputs(zgtdir(),learnfp);
12973 fputs("\n; Recorded: ",learnfp);
12974 fputs(ckdate(),learnfp);
12975 fputs("\n",learnfp);
12984 debug(F101,"LEARN learning","",learning);
12985 return(success = 1);
12987 #endif /* CKLEARN */
12990 if (cx == XXUSER || cx == XXACCT) {
12991 if (!ftpisopen()) {
12992 printf("?FTP connection is not open\n");
12995 return(success = (cx == XXUSER) ? doftpusr() : doftpacct());
12997 if (cx == XXSITE || cx == XXPASV) {
12998 if (!ftpisopen()) {
12999 printf("?FTP connection is not open\n");
13002 return(success = (cx == XXSITE) ? doftpsite() : dosetftppsv());
13004 #endif /* NEWFTP */
13006 if (cx == XXORIE) { /* ORIENTATION */
13007 extern char * myname;
13009 char * s, *p, vbuf[32];
13010 char * vars[16]; char * legend[16];
13012 if ((y = cmcfm()) < 0)
13015 printf("\nProgram name:\n %s\n\n",myname);
13019 vars[0] = "home"; legend[0] = "Your home directory";
13020 vars[1] = "directory"; legend[1] = "K95's current directory";
13021 vars[2] = "exedir"; legend[2] = "K95 Program directory";
13022 vars[3] = "inidir"; legend[3] = "K95 Initialization file directory";
13023 vars[4] = "startup"; legend[4] = "Current directory when started";
13025 vars[5] = "common";
13026 legend[5] = "K95 data for all users and K95SITE.INI file";
13028 vars[6] = "personal"; legend[6] = "Your personal data directory tree";
13029 vars[7] = "desktop"; legend[7] = "Your deskop directory tree";
13031 vars[8] = "appdata";
13032 legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file";
13034 vars[9] = "download"; legend[9] = "Your K95 download directory";
13035 vars[10] = "tmpdir"; legend[10] = "Your TEMP directory";
13036 vars[11] = NULL; legend[11] = NULL;
13038 for (i = 0; i < 16 && vars[i]; i++) {
13039 printf("%s:\n",legend[i]);
13040 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13041 ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
13042 printf(" Variable: %s\n",vbuf);
13043 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13046 zzstring(vbuf,&s,&y);
13048 ckGetLongPathName(tmpbuf,line,LINBUFSIZ);
13049 printf(" Long name: %s\n",line);
13050 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13052 GetShortPathName(tmpbuf,line,LINBUFSIZ);
13053 printf(" Short name: %s\n",line);
13054 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13056 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13060 vars[0] = "home"; legend[0] = "Your home directory";
13061 vars[1] = "directory"; legend[1] = "Kermit's current directory";
13062 vars[2] = "exedir"; legend[2] = "Kermit's program directory";
13063 vars[3] = "inidir"; legend[3] = "Initialization file directory";
13064 vars[4] = "startup"; legend[4] = "Current directory when started";
13065 vars[5] = "download"; legend[5] = "Kermit download directory";
13066 vars[6] = NULL; legend[6] = NULL;
13068 for (i = 0; i < 16 && vars[i]; i++) {
13069 printf("%s:\n",legend[i]);
13070 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13071 ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
13072 printf(" Variable: %s\n",vbuf);
13073 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13076 zzstring(vbuf,&s,&y);
13077 printf(" Value: %s\n",tmpbuf);
13078 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13080 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13083 return(success = 1);
13087 if (cx == XXDIALER) {
13089 return(success = 1);
13093 if (cx == XXCONT) { /* CONTINUE */
13094 if ((x = cmcfm()) < 0)
13096 if (!xcmdsrc) { /* At prompt: continue script */
13098 popclvl(); /* Pop command level */
13099 return(success = 1); /* always succeeds */
13101 } else { /* In script: whatever... */
13102 x = mlook(mactab,"continue",nmac);
13103 /* Don't set success */
13104 return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
13108 if (cx == XXNOTAV) { /* Command in table not available */
13109 ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
13110 if ((x = cmtxt("Rest of command","",&s,NULL)) < 0)
13112 printf("Sorry, \"%s\" not configured in this version of Kermit.\n",
13115 return(success = 0);
13117 return(-2); /* None of the above */
13119 } /* end of docmd() */