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 if ((y = cmtxt("Braced list of commands","",&s,xxstring)) < 0)
7988 k = ckstrncpy(line+k,s,LINBUFSIZ-k);
7989 debug(F111,"XXMACRO B",line,k);
7992 if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
7994 if (line[0] != '{' && line[x-1] != '}') {
7995 /* Unknown command. If ON_UNKNOWN_COMMAND macro is defined, */
7996 /* parse args and then execute it, but only if it is not */
7997 /* already active. */
8000 k = mxlook(mactab,"on_unknown_command",nmac);
8003 ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
8004 z = maclvl; /* Save the current maclvl */
8005 if ((y = cmtxt("text","",&s,xxstring)) < 0)
8007 ckstrncat(tmpbuf," ",TMPBUFSIZ);
8008 ckstrncat(tmpbuf,s,TMPBUFSIZ);
8010 debug(F110,"ON_UNKNOWN_COMMAND",s,0);
8011 dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
8012 while (maclvl > z) {
8013 sstate = (CHAR) parser(1);
8014 if (sstate) proto();
8016 debug(F101,"UNKMAC loop exit maclvl","",maclvl);
8021 printf("?Not a command or macro name: \"%s\"\n",line);
8023 printf("?Not a command or macro name.\n");
8027 sprintf(mnamebuf," ..tmp:%03d",cmdlvl); /* safe (16) */
8028 x = addmac(mnamebuf,s);
8029 return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
8032 if (cx == XXLBL) { /* LABEL */
8033 if ((x = cmfld("label","",&s,xxstring)) < 0) {
8036 printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
8040 #endif /* COMMENT */
8044 debug(F111,"LABEL",s,x);
8045 if ((x = cmcfm()) < 0) return(x);
8049 if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE, EVALUATE */
8053 if (cx == XXSEXP) { /* Lisp-like S-Expression */
8054 struct stringarray * q;
8055 char /* *p, *r, */ *tmp, *m;
8056 int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
8057 extern int sexprc, sexppv;
8059 tmp = tmpbuf; /* Buffer to collect SEXP */
8060 tmpbuf[0] = NUL; /* Clear it */
8061 size = TMPBUFSIZ; /* Capacity of buffer */
8062 sexprc = -1; /* Assume bad input */
8063 n = 0; /* Paren balance counter */
8065 while (1) { /* Allow SEXP on multiple lines */
8067 "Continuation of S-Expression" :
8068 "S-Expression (\"help sexp\" for details)";
8069 x = cmtxt(m,"",&s,xxstring);
8072 if (!*s) /* Needed for (=) and (:) */
8074 k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
8076 printf("?SEXP too long - %d max\n",TMPBUFSIZ);
8079 debug(F111,contd ? "sexp contd" : "sexp",s,k);
8081 for (i = len; i < len+k; i++) { /* Check balance */
8082 if (!quote && tmpbuf[i] == CMDQ) {
8090 if (tmpbuf[i] == '(')
8092 else if (tmpbuf[i] == ')')
8095 if (n == 0) { /* Break when balanced */
8098 if (n < 0) { /* Too many right parens */
8099 printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
8102 contd++; /* Need more right parens */
8103 cmini(ckxech); /* so keep parsing */
8104 tmp += k; /* adjust buffer pointer */
8105 size -= k; /* and capacity */
8106 len += k; /* and length so far */
8109 makestr(&lastsexp,s);
8110 q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0); /* Precheck for > 1 SEXP */
8111 debug(F101,"sexp split","",q->a_size);
8113 if (q->a_size == 1) { /* We should get exactly one back */
8114 char * result, * dosexp();
8115 sexprc = 0; /* Reset out-of-band return code */
8116 result = dosexp(s); /* Get result */
8117 debug(F111,"sexp result",result,sexprc);
8118 if (sexprc == 0) { /* Success */
8119 /* Echo the result if desired */
8120 if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
8121 printf(" %s\n",result ? result : "");
8122 makestr(&sexpval,result);
8123 success = sexppv > -1 ? sexppv : 1;
8128 printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
8135 if (cx == XXECH || cx == XXXECH || cx == XXVOID
8139 ) { /* ECHO or APC */
8140 if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
8141 "Text to be echoed" :
8142 ((cx == XXVOID) ? "Text" :
8143 "Application Program Command text"),
8152 /* This is to preserver the pre-8.0 behavior but it's too confusing */
8154 x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
8155 #endif /* COMMENT */
8156 s = brstrip(s); /* Strip braces and doublequotes */
8157 if (cx == XXECH) { /* ECHO */
8159 if (!fndiags || fnsuccess) {
8162 /* The "if (x)" business preserves previous behavior */
8163 /* by putting back the doublequotes if they were included. */
8165 printf("\"%s\"\n",s);
8167 #endif /* COMMENT */
8172 } else if (cx == XXXECH) { /* XECHO */
8180 } else if (cx == XXAPC) { /* APC */
8182 if (apcactive == APC_LOCAL ||
8183 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
8184 return(success = 0);
8187 printf("%c_%s%c\\",ESC,s,ESC);
8192 } else { /* Local mode - have connection */
8194 if (ckmakxmsg(tmpbuf, /* Form APC string in buffer */
8201 NULL,NULL,NULL,NULL,NULL,NULL,NULL
8203 return(success = dooutput(tmpbuf, XXOUT));
8204 printf("?Too long\n");
8207 printf("%c_%s%c\\",ESC,s,ESC);
8211 return(success = 1);
8215 /* Copy macro args from/to two levels up, used internally by _floop et al. */
8216 if (cx == XXGTA || cx == XXPTA) { /* _GETARGS, _PUTARGS */
8218 debug(F101,"docmd XXGTA","",XXGTA);
8219 debug(F101,"docmd cx","",cx);
8220 debug(F101,"docmd XXGTA maclvl","",maclvl);
8222 debug(F101,"docmd dogta returns","",x);
8223 debug(F101,"docmd dogta maclvl","",maclvl);
8232 else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
8233 cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
8234 cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
8236 #endif /* CKCHANNELIO */
8238 /* ASK, ASKQ, READ */
8239 if (cx == XXASK || cx == XXASKQ || cx == XXREA ||
8240 cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
8246 if (cx == XXBUG) { /* BUG */
8247 if ((x = cmcfm()) < 0) return(x);
8250 #endif /* NOFRILLS */
8253 if (cx == XXBYE) { /* BYE */
8254 extern int ftp_cmdlin;
8255 if ((x = cmcfm()) < 0) return(x);
8258 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
8259 extern int stayflg, ftp_fai;
8261 if (ftp_cmdlin && !stayflg && !local)
8262 doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
8269 printf("?No connection - use EXIT to quit.\n");
8274 if (protocol != PROTO_K) {
8275 printf("?Sorry, BYE only works with Kermit protocol\n");
8283 protocol == PROTO_K &&
8285 !iks_wait(KERMIT_REQ_START,1)) {
8287 "?A Kermit Server is not available to process this command\n");
8288 return(-9); /* Correct the return code */
8290 #endif /* IKS_OPTION */
8293 sstate = setgen('L',"","","");
8294 if (local) ttflui(); /* If local, flush tty input buffer */
8299 if (cx == XXBEEP) { /* BEEP */
8303 if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
8306 if ((x = cmcfm()) < 0) return(x);
8307 bleep((short)y); /* y is one of the BP_ values */
8309 if ((x = cmcfm()) < 0) return(x);
8320 if (cx == XXCLE) /* CLEAR */
8321 return(success = doclear());
8322 #endif /* NOFRILLS */
8324 if (cx == XXCOM) { /* COMMENT */
8325 if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
8327 /* Don't change SUCCESS flag for this one */
8332 if (cx == XXCON || cx == XXCQ) /* CONNECT or CONNECT /QUIETLY */
8333 return(doxconn(cx));
8334 #endif /* NOLOCAL */
8338 if (cx == XXCPY) { /* COPY a file */
8340 if (inserver && !ENABLED(en_cpy)) {
8341 printf("?Sorry, COPY is disabled\n");
8346 if (apcactive == APC_LOCAL ||
8347 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
8349 return(success = 0);
8355 if ( cx == XXLINK ) {
8357 if (inserver && !ENABLED(en_cpy)) {
8358 printf("?Sorry, LINK (COPY) is disabled\n");
8363 if (apcactive == APC_LOCAL ||
8364 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
8366 return(success = 0);
8371 #endif /* NOFRILLS */
8373 /* CD and friends */
8374 if (cx == XXCWD || cx == XXCDUP || cx == XXBACK ||
8375 cx == XXLCWD || cx == XXLCDU || cx == XXKCD) {
8382 return(dormt(XZCWD));
8384 } else if (cx == XXCDUP) {
8388 return(dormt(XZCDU));
8394 if (inserver && !ENABLED(en_cwd)) {
8395 printf("?Sorry, changing directories is disabled\n");
8399 return(success = docd(cx));
8402 if (cx == XXCHK) /* CHECK */
8403 return(success = dochk());
8405 if (cx == XXCLO) { /* CLOSE */
8406 x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
8407 "connection",xxstring);
8409 printf("?You must say which file or log\n");
8412 if (x < 0) return(x);
8413 if ((y = cmcfm()) < 0) return(y);
8415 if (x == 9999) { /* CLOSE CONNECTION */
8419 if (msgflg) printf("?Connection was not open\n");
8423 whyclosed = WC_CLOS;
8428 #endif /* NOLOCAL */
8435 if (cx == XXDCL || cx == XXUNDCL) { /* DECLARE an array */
8441 if (cx == XXRED || cx == XXDIAL || cx == XXPDIA ||
8442 cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
8448 #endif /* UNIXOROSK */
8451 debug(F101,"dodial returns","",x);
8452 if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
8453 (x > 0) && /* If DIAL or REDIAL succeeded */
8454 (dialsta != DIA_PART) && /* and it wasn't partial */
8456 if ((dialcon == 1 || /* And DIAL CONNECT is ON, */
8457 ((dialcon == 2) && /* or DIAL CONNECT is AUTO */
8458 !xcmdsrc /* and we're at top level... */
8460 && !batch /* Not if running from batch */
8463 && !backgrd /* Not if running in background */
8464 #endif /* UNIXOROSK */
8467 x = doconect(dialcq, /* Then also CONNECT */
8473 return(success = x);
8479 if (cx == XXREXX) { /* REXX */
8485 #endif /* CK_REXX */
8489 if (cx == XXDEL || cx == XXLDEL) { /* DELETE */
8491 if (!locus && cx != XXLDEL) {
8495 return(dormt(XZDEL));
8500 if (inserver && (!ENABLED(en_del)
8503 #endif /* CK_LOGIN */
8505 printf("?Sorry, DELETE is disabled\n");
8510 if ((apcactive == APC_LOCAL) ||
8511 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8512 return(success = 0);
8516 #endif /* NOFRILLS */
8518 if (cx == XXDIR || cx == XXLS || cx == XXLDIR) { /* DIRECTORY or LS */
8520 if (!locus && cx != XXLDIR) {
8524 return(dormt(XZDIR));
8529 if (inserver && !ENABLED(en_dir)) {
8530 printf("?Sorry, DIRECTORY is disabled\n");
8538 if (cx == XXELS) /* ELSE */
8544 if (cx == XXENA || cx == XXDIS) { /* ENABLE, DISABLE */
8546 "Server function to enable" :
8547 "Server function to disable";
8549 if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
8551 printf("?Name of server function required\n");
8555 if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
8557 printf("?Please specify remote, local, or both\n");
8561 if (cx == XXDIS) /* Disabling, not enabling */
8563 if ((z = cmcfm()) < 0) return(z);
8565 if ((apcactive == APC_LOCAL) ||
8566 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8567 return(success = 0);
8570 /* This may seem like it duplicates the work in doenable() */
8571 /* but this code returns failure whereas doenable() returns */
8576 #endif /* IKSDCONF */
8577 (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
8579 return(success = 0);
8581 return(doenable(y,x));
8583 #endif /* NOFRILLS */
8584 #endif /* NOSERVER */
8587 if (cx == XXRET) { /* RETURN */
8588 if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
8590 s = brstrip(s); /* Strip braces */
8591 if (cmdlvl == 0) /* At top level, nothing happens... */
8592 return(success = 1);
8593 switch (cmdstk[cmdlvl].src) { /* Action depends on command source */
8594 case CMD_TF: /* Command file */
8595 popclvl(); /* Pop command level */
8596 return(success = 1); /* always succeeds */
8597 case CMD_MD: /* Macro */
8598 case CMD_KB: /* Prompt */
8599 return(doreturn(s)); /* Trailing text is return value. */
8600 default: /* Shouldn't happen */
8607 if (cx == XXOPE) /* OPEN */
8612 if (cx == XXOUT || cx == XXLNOUT) { /* OUTPUT or LINEOUT */
8613 if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
8616 if ((apcactive == APC_LOCAL) ||
8617 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
8618 return(success = 0);
8620 debug(F110,"OUTPUT 1",s,0);
8621 s = brstrip(s); /* Strip enclosing braces, */
8622 debug(F110,"OUTPUT 2",s,0);
8624 I don't think I could ever fully explain this in a million years...
8625 We have read the user's string without calling the variable-expander
8626 function. Now, before we call it, we have to double backslashes that
8627 appear before \N, \B, \L, and \ itself, so the expander function will
8628 reduce them back to single backslashes, so when we call dooutput()...
8629 But it's more complicated than that.
8631 if (cmdgquo()) { /* Only if COMMAND QUOTING ON ... */
8632 for (x = 0, y = 0; s[x]; x++, y++) {
8635 if (c == 'n' || c == 'N' ||
8636 c == 'b' || c == 'B' ||
8637 c == 'l' || c == 'L' ||
8643 line[y++] = '\0'; /* Now expand variables, etc. */
8644 debug(F110,"OUTPUT 3",line,0);
8646 x = LINBUFSIZ - (int) strlen(line) - 1;
8647 debug(F101,"OUTPUT size","",x);
8648 if (zzstring(line,&s,&x) < 0)
8649 return(success = 0);
8651 debug(F110,"OUTPUT 4",s,0);
8653 success = dooutput(s,cx);
8660 if (cx == XXPAD) { /* PAD commands */
8661 x = cmkey(padtab,npadc,"PAD command","",xxstring);
8663 printf("?You must specify a PAD command to execute\n");
8666 if (x < 0) return(x);
8671 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8679 printf("Not connected\r\n");
8681 extern int linkid, lcn;
8682 conol("Connected thru ");
8684 printf(", Link id %d, Logical channel number %d\r\n",
8690 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8696 printf("Sorry, you must 'set network' & 'set host' first\r\n");
8706 if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
8714 if (inserver && (isguest || !ENABLED(en_pri))) {
8715 printf("?Sorry, printing is disabled\n");
8718 #endif /* CK_LOGIN */
8720 if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
8722 printf("?A file specification is required\n");
8727 printf("?Wildcards not allowed\n");
8730 ckstrncpy(line,s,LINBUFSIZ);
8733 if ((x = cmtxt("Local print command options, or carriage return","",&s,
8737 if ((x = cmcfm()) < 0)
8739 return(success = (zprint(s,line) == 0) ? 1 : 0);
8741 #endif /* NOFRILLS */
8745 if (cx == XXPNG) /* PING an IP host */
8750 if (cx == XXFTP) /* FTP */
8753 return(doftp()); /* Just runs system's ftp program */
8761 #endif /* TCPSOCKET */
8763 if (cx == XXPWD || cx == XXLPWD) { /* PWD */
8767 if ((x = cmcfm()) < 0)
8770 if (!locus && cx != XXLPWD) {
8774 return(dormt(XZPWD));
8782 printf("%s\n",zgtdir());
8786 return(success = 1); /* Blind faith */
8788 if (pwp = zgtdir()) {
8792 ckGetLongPathName(pwp,line,LINBUFSIZ);
8793 line[LINBUFSIZ-1] = NUL;
8795 GetShortPathName(pwp,tmpbuf,TMPBUFSIZ);
8796 tmpbuf[TMPBUFSIZ-1] = NUL;
8798 if (!strcmp(line,tmpbuf)) {
8803 printf(" Long name: %s\n",line);
8804 printf(" Short name: %s\n",tmpbuf);
8808 return(success = ((int)strlen(pwp) > 0));
8809 } else return(success = 0);
8812 if (pwp = zgtdir()) {
8814 return(success = ((int)strlen(pwp) > 0));
8815 } else return(success = 0);
8819 if (cx == XXQUI || cx == XXEXI) { /* EXIT, QUIT */
8820 extern int quitting;
8822 if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
8824 if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
8827 ckstrncpy(line,s,LINBUFSIZ);
8829 if (!hupok(0)) /* Check if connection still open */
8830 return(success = 0);
8832 if (line[0]) /* Print EXIT message if given */
8833 printf("%s\n",(char *)line);
8835 quitting = 1; /* Flag that we are quitting. */
8838 doexit(GOOD_EXIT,x);
8841 /* Returning any codes here makes the OS-9 shell print an error message. */
8842 doexit(GOOD_EXIT,-1);
8845 doexit(GOOD_EXIT,x);
8848 #endif /* datageneral */
8855 if (cx == XXERR) { /* ERROR */
8857 if (protocol != PROTO_K) {
8858 printf("Sorry, E-PACKET only works with Kermit protocol\n");
8862 if ((x = cmcfm()) < 0) return(x);
8868 #endif /* NOFRILLS */
8870 if (cx == XXFIN) { /* FINISH */
8872 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
8876 if (protocol != PROTO_K) {
8877 printf("Sorry, FINISH only works with Kermit protocol\n");
8881 if ((x = cmcfm()) < 0) return(x);
8886 protocol == PROTO_K &&
8888 !iks_wait(KERMIT_REQ_START,1)) {
8890 "?A Kermit Server is not available to process this command\n");
8891 return(-9); /* Correct the return code */
8893 #endif /* IKS_OPTION */
8895 sstate = setgen('F',"","","");
8896 if (local) ttflui(); /* If local, flush tty input buffer */
8902 if (cx == XXFOR) /* FOR loop */
8907 /* GET MGET REGET RETRIEVE etc */
8908 if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
8910 if (inserver && !ENABLED(en_sen)) {
8911 printf("?Sorry, reception of files is disabled\n");
8921 if (cx == XXGOK) { /* GETOK */
8922 return(success = doask(cx));
8924 #endif /* NOFRILLS */
8927 if (cx == XXHLP) { /* HELP */
8929 return(dohlp(XXHLP));
8931 x = cmkey2(cmdtab,ncmd,"\nCommand or topic","help",toktab,xxstring,3);
8932 debug(F101,"HELP command x","",x);
8935 debug(F101,"HELP cmkey token","",y);
8939 case '!': x = XXSHE; break;
8941 case '#': x = XXCOM; break;
8942 case ';': x = XXCOM; break;
8944 case '.': x = XXDEF; break;
8945 case ':': x = XXLBL; break;
8947 case '(': x = XXSEXP; break;
8950 case '&': x = XXECH; break;
8952 printf("\n?Invalid - %s\n",cmdbuf);
8956 makestr(&hlptok,atmbuf);
8957 debug(F111,"HELP token",hlptok,x);
8963 if (cx == XXINT) /* INTRO */
8964 return(hmsga(introtxt));
8965 if (cx == XXNEW) { /* NEWS */
8967 extern char * k_info_dir;
8973 if (cx == XXUPD) { /* View UPDATE file */
8974 extern char exedir[];
8977 if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
8981 "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
8982 %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
8983 exedir,exedir,exedir,exedir,pTopic
8986 if (ckmakxmsg(updstr,
8992 "\\docs\\using_ck.inf+",
8994 "\\docs\\dialing.inf+",
8996 "\\docs\\modems.inf ",
9001 #endif /* COMMENT */
9003 return(success = 1);
9005 #endif /* OS2ONLY */
9009 if (cx == XXHAN) { /* HANGUP */
9010 if ((x = cmcfm()) < 0) return(x);
9012 if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
9013 return(success = ftpbye());
9016 if ((x = mdmhup()) < 1) {
9017 debug(F101,"HANGUP mdmup","",x);
9020 debug(F101,"HANGUP tthang","",x);
9026 whyclosed = WC_CLOS;
9027 ttchk(); /* In case of CLOSE-ON-DISCONNECT */
9031 DialerSend(OPT_KERMIT_HANGUP, 0);
9033 if (x) haveline = 0;
9034 return(success = x);
9036 #endif /* NOLOCAL */
9039 /* INPUT, REINPUT, and MINPUT */
9041 if (cx == XXINP || cx == XXREI || cx == XXMINP) {
9043 extern int ispattern, isjoin;
9045 struct FDB sw, nu, fl;
9046 int fc, havetime = 0;
9050 m = "Timeout in seconds (ignored)";
9052 m = "Seconds to wait for input,\n or time of day hh:mm:ss, \
9055 innomatch = 0; /* Initialize switch value(s) */
9057 cmfdbi(&sw, /* First FDB - command switches */
9060 ckitoa(indef), /* default */
9061 "", /* addtl string data */
9062 ninputsw, /* addtl numeric data 1: tbl size */
9063 4, /* addtl numeric data 2: 4 = cmswi */
9064 xxstring, /* Processing function */
9065 inputsw, /* Keyword table */
9066 &nu /* Pointer to next FDB */
9069 _CMNUM, /* Number */
9070 m, /* Help message */
9071 ckitoa(indef), /* default */
9073 10, /* Radix = 10 */
9075 xxstring, /* Processing function */
9079 cmfdbi(&fl, /* Time of day hh:mm:ss */
9083 "", /* addtl string data */
9084 0, /* addtl numeric data 1 */
9085 0, /* addtl numeric data 2 */
9090 fc = (cx == XXREI) ? cmfdb(&nu) : cmfdb(&sw); /* Parse something */
9093 if (fc < 0) { /* Error */
9095 printf("?Syntax error in INPUT-class command\n");
9100 switch (cmresult.fcode) {
9101 case _CMKEY: /* Switch */
9102 if (cmresult.nresult == INPSW_NOM) /* /NOMATCH */
9104 m = "Seconds to wait for input,\n or time of day hh:mm:ss";
9105 cmfdbi(&nu,_CMNUM,m,"","",10,0,xxstring,NULL,&fl);
9106 cmfdbi(&fl,_CMFLD,"","","",0,0,xxstring,NULL,NULL);
9107 fc = cmfdb(&nu); /* Parse something */
9110 case _CMNUM: /* Seconds to time out */
9111 x = cmresult.nresult;
9113 if (inscale != 1.0) /* Scale */
9115 #endif /* CKFLOAT */
9120 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
9122 printf("?Number, expression, or time of day required\n");
9125 char now[32]; /* Current time */
9130 tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
9131 if (zz < tnow) /* User's time before now */
9132 zz += 86400L; /* So make it tomorrow */
9133 zz -= tnow; /* Seconds from now. */
9136 if (zz != (long) x) {
9138 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
9147 printf("?Internal error\n");
9151 /* Now parse the search text */
9154 for (y = 0; y < MINPMAX; y++) { /* Initialize strings */
9155 mp[y] = 0; /* Assume it's not a pattern */
9157 free(ms[y]); /* Free old strings, if any */
9161 if (cx == XXMINP) { /* MINPUT */
9162 int i, k = 0, n = 0;
9163 struct stringarray * q;
9165 while (k < MINPMAX) {
9166 if ((y = cmfld("String or pattern","",&s,xxstring)) < 0) {
9168 if ((y = cmcfm()) < 0)
9175 debug(F111,"MINPUT field",s,k);
9177 if ((q = cksplit(1,0,s," ",(char *)c1chars,3,0,0))) {
9178 char ** ap = q->a_head;
9180 debug(F101,"minput cksplit size","",n);
9181 for (i = 1; i <= n && k < MINPMAX; i++) {
9182 if (!ap[i]) /* Add non-empty elements */
9186 makestr(&(ms[k]),ap[i]);
9187 debug(F111,"MINPUT JOIN",ms[k],k);
9193 makestr(&(ms[k]),brstrip(s));
9194 if (ispattern) mp[k] = 1;
9195 debug(F111,"MINPUT",ms[k],ispattern);
9202 #endif /* CK_MINPUT */
9204 /* INPUT or REINPUT */
9206 if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
9208 mp[0] = ispattern ? 1 : 0;
9209 makestr(&(ms[0]),brstrip(s));
9214 #endif /* CK_MINPUT */
9217 printf("/NOMATCH=%d\n",innomatch);
9218 printf("Timeout=%d\n",x);
9220 #endif /* COMMENT */
9222 if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
9224 /* Go try to input the search string */
9225 success = doinput(x,ms,mp,innomatch);
9227 } else { /* REINPUT */
9228 success = doreinp(x,ms[0],ispattern);
9230 if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
9231 popclvl(); /* If so, pop command level. */
9232 if (pflag && cmdlvl == 0) {
9233 if (cx == XXINP) printf("?INPUT timed out\n");
9234 if (cx == XXMINP) printf("?MINPUT timed out\n");
9235 if (cx == XXREI) printf("?REINPUT failed\n");
9238 return(success); /* Return do(re)input's return code */
9243 if (cx == XXLOG) { /* LOG */
9244 x = cmkey(logtab,nlog,"What to log","",xxstring);
9246 printf("?Type of log required\n");
9249 if (x < 0) return(x);
9254 return(success = x);
9257 if (cx == XXLOGIN) { /* (REMOTE) LOGIN */
9259 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9260 return(success = doftpusr());
9264 printf("?Already logged in\n");
9272 return(dormt(XZLGI));
9276 if (cx == XXLOGOUT) { /* (REMOTE) LOGOUT */
9278 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9279 return(success = doftpres());
9284 if ((x = cmcfm()) < 0)
9286 doexit(GOOD_EXIT,xitsta);
9289 if (!local || (network && ttchk() < 0)) {
9290 printf("?No connection.\n");
9296 return(dormt(XZLGO));
9302 if (cx == XXLOGI) { /* UUCP-style script */
9303 if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
9306 if ((apcactive == APC_LOCAL) ||
9307 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9308 return(success = 0);
9311 conres(); /* For Ctrl-C to work... */
9313 return(success = dologin(s)); /* Return 1=completed, 0=failed */
9315 #endif /* NOSCRIPT */
9319 if (cx == XXCREC) { /* CRECEIVE */
9320 if (protocol != PROTO_K) {
9321 printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
9326 if (cx == XXCGET) { /* CGET */
9329 #endif /* PIPESEND */
9331 if (cx == XXREC) /* RECEIVE */
9336 if (cx == XXREM) { /* REMOTE */
9338 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9339 return(doftprmt(0,0));
9342 if (protocol != PROTO_K) {
9343 printf("Sorry, REMOTE commands only work with Kermit protocol\n");
9347 x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
9349 printf("?You must specify a command for the remote server\n");
9358 if (cx == XXREN || cx == XXLREN) { /* RENAME */
9360 if (!locus && cx != XXLREN) {
9364 return(dormt(XZREN));
9369 if (inserver && (!ENABLED(en_ren)
9372 #endif /* CK_LOGIN */
9374 printf("?Sorry, renaming of files is disabled\n");
9379 if ((apcactive == APC_LOCAL) ||
9380 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9381 return(success = 0);
9385 #endif /* NOFRILLS */
9386 #endif /* NORENAME */
9388 if (cx == XXEIGHT) { /* EIGHTBIT */
9389 extern int parity, cmask, cmdmsk;
9390 if ((x = cmcfm()) < 0)
9395 return(success = 1);
9399 /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
9401 if (cx == XXSEN /* SEND */
9403 || cx == XXCSEN /* CSEND */
9404 #endif /* PIPESEND */
9405 || cx == XXMOVE /* MOVE */
9406 || cx == XXMAI /* MAIL */
9408 || cx == XXRSEN /* RESEND */
9409 #endif /* CK_RESEND */
9412 if (inserver && !ENABLED(en_get)) {
9413 printf("?Sorry, sending files is disabled\n");
9417 return(doxsend(cx));
9420 /* PSEND, ADD, and REMOVE use special parsing */
9423 /* ADD and REMOVE */
9424 if (cx == XXADD || cx == XXREMV) {
9426 m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
9427 x = cmkey(addtab,naddtab,m,"",xxstring);
9432 return(addsend(cx));
9434 #endif /* NOMSEND */
9435 return(doadd(cx,x));
9440 if (cx == XXPSEN) { /* PSEND */
9443 cmarg = cmarg2 = "";
9444 x = cmifi("File to partially send", "", &s, &y, xxstring);
9447 printf("?A file specification is required\n");
9451 nfils = -1; /* Files come from internal list. */
9453 addlist = 0; /* Don't use SEND-LIST. */
9455 #endif /* NOMSEND */
9456 ckstrncpy(line,s,LINBUFSIZ); /* Save copy of string just parsed. */
9457 debug(F110,"PSEND line",line,0);
9459 printf("?Sorry, wildcards not permitted in this command\n");
9462 if (sizeof(int) < 4) {
9463 printf("?Sorry, this command needs 32-bit integers\n");
9466 x = cmnum("starting position (byte number)",
9467 "",10,&seekto,xxstring);
9470 zfnqfp(s,fspeclen,fspec); /* Get full path */
9471 if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
9473 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
9476 if (inserver && !ENABLED(en_get)) {
9477 printf("?Sorry, sending files is disabled\n");
9483 printf("?Sorry, no PSEND while SEND FILTER selected\n");
9486 #endif /* PIPESEND */
9488 if ((protocol == PROTO_X || protocol == PROTO_XC)) {
9489 printf("Sorry, PSEND works only with Kermit protocol\n");
9494 cmarg2 = brstrip(tmpbuf); /* Strip braces */
9495 cmarg = line; /* File to send */
9496 debug(F110,"PSEND filename",cmarg,0);
9497 debug(F110,"PSEND as-name",cmarg2,0);
9499 sstate = 's'; /* Set start state to SEND */
9503 #endif /* NOMSEND */
9504 sendmode = SM_PSEND;
9509 if (local) { /* If in local mode, */
9510 displa = 1; /* enable file transfer display */
9514 #endif /* CK_RESEND */
9519 if (cx == XXMSE || cx == XXMMOVE) {
9521 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
9522 return(doftpput(cx,0));
9525 if (protocol == PROTO_X || protocol == PROTO_XC) {
9527 "Sorry, you can only send one file at a time with XMODEM protocol\n"
9532 return(doxsend(cx));
9535 #ifdef COMMENT /* (moved to doxsend) */
9536 if (cx == XXMSE || cx == XXMMOVE) { /* MSEND and MMOVE commands */
9537 nfils = 0; /* Like getting a list of */
9538 lp = line; /* files on the command line */
9539 addlist = 0; /* Do not use SEND-LIST */
9540 filenext = NULL; /* Ditto ! */
9544 if ((x = cmifi("Names of files to send, separated by spaces","",
9545 &s,&y,xxstring)) < 0) {
9548 printf("?A file specification is required\n");
9554 msfiles[nfils++] = lp; /* Got one, count it, point to it, */
9555 p = lp; /* remember pointer, */
9556 while (*lp++ = *s++) /* and copy it into buffer */
9557 if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
9558 printf("?MSEND list too long\n");
9562 debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
9563 if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
9565 zfnqfp(p,TMPBUFSIZ,tmpbuf);
9568 if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
9569 strcat(fspec,p); /* safe */
9570 strcat(fspec," "); /* safe */
9571 } else printf("WARNING - \\v(filespec) buffer overflow\n");
9573 cmlist = msfiles; /* Point cmlist to pointer array */
9574 cmarg2 = ""; /* No internal expansion list (yet) */
9575 sndsrc = nfils; /* Filenames come from cmlist */
9576 sendmode = SM_MSEND; /* Remember this kind of SENDing */
9577 sstate = 's'; /* Set start state for SEND */
9578 if (cx == XXMMOVE) /* If MMOVE'ing, */
9579 moving = 1; /* set this flag. */
9584 if (local) { /* If in local mode, */
9585 displa = 1; /* turn on file transfer display */
9586 ttflui(); /* and flush tty input buffer. */
9590 #endif /* COMMENT */
9591 #endif /* NOMSEND */
9595 if (cx == XXSER) { /* SERVER */
9597 if (protocol != PROTO_K) {
9598 printf("Sorry, SERVER only works with Kermit protocol\n");
9604 Parse for time limit, but since we don't use it yet,
9605 the parsing is commented out.
9607 x_ifnum = 1; /* Turn off internal complaints */
9608 y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
9609 "0", 10, &x, xxstring
9613 if (y == -2) { /* Invalid number or expression */
9614 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
9616 printf("?Number, expression, or time of day required\n");
9619 char now[32]; /* Current time */
9624 tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
9625 if (zz < tnow) /* User's time before now */
9626 zz += 86400L; /* So make it tomorrow */
9627 zz -= tnow; /* Seconds from now. */
9634 if (zz != (long) x) {
9636 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
9643 #endif /* COMMENT */
9645 if ((x = cmcfm()) < 0) return(x);
9651 if (local) displa = 1;
9653 reqoff(); /* No DOS requestors while server */
9657 #endif /* NOSERVER */
9659 if (cx == XXSAVE) { /* SAVE command */
9660 x = cmkey(savtab,nsav,"option","keymap",xxstring);
9662 printf("?You must specify an option to save\n");
9665 if (x < 0) return(x);
9666 /* have to set success separately for each item in doprm()... */
9667 /* actually not really, could have just had doprm return 0 or 1 */
9668 /* and set success here... */
9671 printf("?More fields required\n");
9676 if (cx == XXSET) { /* SET command */
9677 x = cmkey(prmtab,nprm,"Parameter","",xxstring);
9679 printf("?You must specify a parameter to set\n");
9682 if (x < 0) return(x);
9683 /* have to set success separately for each item in doprm()... */
9684 /* actually not really, could have just had doprm return 0 or 1 */
9685 /* and set success here... */
9688 printf("?More fields required\n");
9694 if (cx == XXSHE /* SHELL (system) command */
9695 || cx == XXEXEC /* exec() */
9702 #endif /* UNIXOROSK */
9705 if (inserver && (nopush || !ENABLED(en_hos))) {
9706 printf("?Sorry, host command access is disabled\n");
9712 if (cx == XXEXEC) { /* EXEC (overlay ourselves) */
9714 cmfdbi(&sw, /* First FDB - command switches */
9716 "Command to overlay C-Kermit\n or switch", /* hlpmsg */
9718 "", /* addtl string data */
9719 1, /* addtl numeric data 1: tbl size */
9720 4, /* addtl numeric data 2: 4 = cmswi */
9721 xxstring, /* Processing function */
9722 redirsw, /* Keyword table */
9723 &fl /* Pointer to next FDB */
9725 cmfdbi(&fl, /* 2nd FDB - command to exec */
9727 "Command to overlay C-Kermit", /* hlpmsg */
9729 "", /* addtl string data */
9730 0, /* addtl numeric data 1 */
9731 0, /* addtl numeric data 2 */
9734 NULL /* No more after this */
9737 x = cmfdb(&sw); /* Parse something */
9738 debug(F101,"exec cmfdb","",x);
9741 /* Generalize this if we add more switches */
9742 if (cmresult.fcode == _CMKEY) {
9746 if (cmresult.fcode == _CMFLD)
9750 ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
9752 printf("?Command required\n");
9755 p = brstrip(tmpbuf);
9756 args[0] = NULL; /* Set argv[0] to it */
9757 makestr(&args[0],p);
9758 for (i = 1; i < 255; i++) { /* Get arguments for command */
9759 if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
9761 if ((x = cmcfm()) < 0)
9769 makestr(&args[i],s);
9774 if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
9780 return(success = 0);
9782 if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
9783 return(success = 0);
9785 conres(); /* Make console normal */
9789 return(success = 1);
9794 debug(F101,"RUN zshcmd code","",x);
9795 concb((char)escape);
9796 return(success = x);
9801 debug(F111,"EXEC cmd",p,0);
9802 for (i = 0; i < 256 && args[i]; i++)
9803 debug(F111,"EXEC arg",args[i],i);
9807 z_exec(p,args,rx); /* Overlay ourself */
9808 debug(F100,"EXEC fails","",0);
9809 concb((char)escape); /* In case it returns */
9811 return(success = 0);
9817 if (cx == XXFUN) { /* REDIRECT */
9819 if ((apcactive == APC_LOCAL) ||
9820 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
9821 return(success = 0);
9825 "Local command to run,\n",
9826 "with its standard input/output redirected to ",
9827 local ? ttname : "the communications connection",
9830 if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
9833 printf("?REDIRECT disabled\n");
9837 printf("?SET LINE or SET HOST required first\n");
9841 printf("?REDIRECT requires a command to redirect\n");
9844 return(success = ttruncmd(s));
9846 #endif /* CK_REDIR */
9850 if (cx == XXSHO) { /* SHOW */
9851 x = cmkey(shotab,nsho,"","parameters",xxstring);
9852 if (x < 0) return(x);
9858 if (cx == XXSPA) { /* SPACE */
9860 if (inserver && !ENABLED(en_spa)) {
9861 printf("?Sorry, SPACE command disabled\n");
9866 /* AOS/VS can take an argument after its "space" command. */
9867 if ((x = cmtxt("Confirm, or local directory name","",&s,xxstring)) < 0)
9870 printf("?Sorry, SPACE command disabled\n");
9872 } else if (*s == NUL) {
9875 ckmakmsg(line,LINBUFSIZ,"space ",s,NULL,NULL);
9880 if ((x = cmtxt("Press Enter for current disk,\n\
9881 or specify a disk letter like A:","",&s,xxstring)) < 0)
9883 if (*s == NUL) { /* Current disk */
9884 unsigned long space = zdskspace(0);
9885 if (space > 0 && space < 1024)
9886 printf(" Free space: unknown\n");
9888 printf(" Free space: %ldK\n", space/1024L);
9890 int drive = toupper(*s);
9891 unsigned long space = zdskspace(drive - 'A' + 1);
9892 if (space > 0 && space < 1024)
9893 printf(" Drive %c: unknown free\n");
9895 printf(" Drive %c: %ldK free\n", drive,space / 1024L);
9899 x = cmdir("Confirm for current disk,\n\
9900 or specify a disk device or directory","",&s,xxstring);
9905 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
9907 if ((x = cmcfm()) < 0) return(x);
9909 printf("?Sorry, SPACE command disabled\n");
9912 if (!*s) { /* Current disk */
9914 } else { /* Specified disk */
9915 ckmakmsg(line,LINBUFSIZ,SPACM2," ",s,NULL);
9919 if ((x = cmcfm()) < 0) return(x);
9921 printf("?Sorry, SPACE command disabled\n");
9925 #endif /* UNIXOROSK */
9927 #endif /* datageneral */
9928 return(success = 1); /* Pretend it worked */
9933 if (cx == XXSTA) { /* STATISTICS */
9934 if ((x = cmkey(stattab,2,"Carriage return, or option",
9935 "/brief",xxstring)) < 0)
9937 if ((y = cmcfm()) < 0) return(y);
9938 return(success = dostat(x));
9942 if (cx == XXSTO || cx == XXEND) { /* STOP, END, or POP */
9943 if ((y = cmnum("exit status code","0",10,&x,xxstring)) < 0)
9945 if ((y = cmtxt("Message to print","",&s,xxstring)) < 0)
9948 if (*s) printf("%s\n",s);
9954 return(success = (x == 0));
9956 if (cx == XXSUS) { /* SUSPEND */
9957 if ((y = cmcfm()) < 0) return(y);
9959 printf("Sorry, this version of Kermit cannot be suspended\n");
9963 printf("?Sorry, IKSD can not be suspended\n");
9968 printf("?Sorry, access to system is disabled\n");
9976 if (cx == XXTAK) { /* TAKE */
9977 char * scriptenv = NULL;
9979 char * GetAppData(int);
9980 extern char startupdir[],exedir[],inidir[];
9981 char * keymapenv = NULL;
9982 char * appdata0 = NULL, *appdata1 = NULL;
9984 #define TAKEPATHLEN 4096
9986 #define TAKEPATHLEN 1024
9988 char takepath[TAKEPATHLEN];
9990 if (tlevel >= MAXTAKE-1) {
9991 printf("?Take files nested too deeply\n");
9996 scriptenv = getenv("K95SCRIPTS");
9997 keymapenv = getenv("K95KEYMAPS");
9998 makestr(&appdata0,(char *)GetAppData(0));
9999 makestr(&appdata1,(char *)GetAppData(1));
10001 scriptenv = getenv("K2SCRIPTS");
10002 keymapenv = getenv("K2KEYMAPS");
10006 if (!scriptenv) /* Let this work for Unix etc too */
10007 scriptenv = getenv("CK_SCRIPTS"); /* Use this if defined */
10009 if (!scriptenv) /* Otherwise use home directory */
10010 scriptenv = homepath();
10014 ckstrncpy(takepath,scriptenv,TAKEPATHLEN);
10015 debug(F110,"TAKE initial takepath",takepath,0);
10019 keymapenv = getenv("CK_KEYMAPS");
10023 ckstrncat(takepath,
10024 (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";",
10027 ckstrncat(takepath,keymapenv?keymapenv:"",TAKEPATHLEN);
10028 ckstrncat(takepath,
10029 (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";",
10032 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10033 ckstrncat(takepath,";",TAKEPATHLEN);
10034 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10035 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10036 ckstrncat(takepath,startupdir,TAKEPATHLEN);
10037 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10039 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10040 ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
10041 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10042 ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
10043 ckstrncat(takepath,appdata1,TAKEPATHLEN);
10044 ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
10046 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10047 ckstrncat(takepath,"Kermit 95/;",TAKEPATHLEN);
10048 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10049 ckstrncat(takepath,"Kermit 95/SCRIPTS/;",TAKEPATHLEN);
10050 ckstrncat(takepath,appdata0,TAKEPATHLEN);
10051 ckstrncat(takepath,"Kermit 95/KEYMAPS/;",TAKEPATHLEN);
10053 ckstrncat(takepath,inidir,TAKEPATHLEN);
10054 ckstrncat(takepath,";",TAKEPATHLEN);
10055 ckstrncat(takepath,inidir,TAKEPATHLEN);
10056 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10057 ckstrncat(takepath,inidir,TAKEPATHLEN);
10058 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10060 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10061 ckstrncat(takepath,";",TAKEPATHLEN);
10062 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10063 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10064 ckstrncat(takepath,zhome(),TAKEPATHLEN);
10065 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10067 ckstrncat(takepath,exedir,TAKEPATHLEN);
10068 ckstrncat(takepath,";",TAKEPATHLEN);
10069 ckstrncat(takepath,exedir,TAKEPATHLEN);
10070 ckstrncat(takepath,"SCRIPTS/;",TAKEPATHLEN);
10071 ckstrncat(takepath,exedir,TAKEPATHLEN);
10072 ckstrncat(takepath,"KEYMAPS/;",TAKEPATHLEN);
10074 debug(F110,"TAKE final takepath",takepath,0);
10076 if ((y = cmifip("Commands from file",
10077 "",&s,&x,0,takepath,xxstring)) < 0) {
10079 printf("?A file name is required\n");
10085 printf("?Wildcards not allowed in command file name\n");
10088 ckstrncpy(line,s,LINBUFSIZ);
10089 debug(F110,"TAKE file",s,0);
10091 printf("?Can't execute a directory - \"%s\"\n", s);
10098 debug(F111,"TAKE args",line,x);
10100 if ((y = cmtxt("Optional arguments","",&s,xxstring)) < 0)
10102 if (*s) { /* Args given? */
10103 ckstrncpy(p,s,LINBUFSIZ-x-1);
10105 zfnqfp(line,TMPBUFSIZ,tmpbuf);
10109 #endif /* ZFNQFP */
10110 debug(F110,"TAKE filename",s,0);
10112 debug(F101,"TAKE new len",s,x);
10116 This was added in C-Kermit 7.0 to allow args to be passed from the TAKE
10117 command to the command file. But it overwrites the current argument vector,
10118 which is at best surprising, and at worst unsafe.
10120 addmac("%0",s); /* Define %0 = name of file */
10123 debug(F110,"take arg 0",s,0);
10124 debug(F110,"take args",p,0);
10125 for (y = 1; y < 10; y++) { /* Clear current args %1..%9 */
10126 varnam[1] = (char) (y + '0');
10129 xwords(p,MAXARGLIST,NULL,0); /* Assign new args */
10130 debug(F110,"take args",p,0);
10133 This method is used in 8.0. If the TAKE command includes arguments, we
10134 insert an intermediate temporary macro between the current level; we pass
10135 the arguments to the macro and then the macro TAKEs the command file.
10136 If the user Ctrl-C's out of the TAKE file, some temporary macro definitions
10137 and other small malloc'd bits might be left behind.
10144 q = (char *)malloc(x+24);
10146 r = (char *)malloc(x+24);
10148 sprintf(q,"_file[%s](%d)",s,cmdlvl); /* safe */
10149 sprintf(r,"take %s",s); /* safe */
10153 while (maclvl > m) {
10154 sstate = (CHAR) parser(1);
10155 if (sstate) proto();
10165 return(success = 0);
10166 #endif /* COMMENT */
10170 if ((y = cmcfm()) < 0) return(y);
10171 #endif /* NOTAKEARGS */
10172 return(success = dotake(line));
10177 if (cx == XXVIEW) { /* VIEW Only Terminal mode */
10179 success = doconect(0, 0);
10186 if (cx == XXTEL || cx == XXIKSD) { /* TELNET */
10190 printf("?Sorry, either TCP/IP is not available on this system or\n\
10191 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
10197 x = nettype; /* Save net type in case of failure */
10198 z = ttnproto; /* Save protocol in case of failure */
10199 nettype = NET_TCPB;
10200 ttnproto = (cx == XXTEL) ? NP_TELNET : NP_KERMIT;
10201 if ((y = setlin(XYHOST,0,1)) <= 0) {
10202 nettype = x; /* Failed, restore net type. */
10203 ttnproto = z; /* and protocol */
10217 #endif /* NETPTY */
10218 #endif /* NETCMD */
10219 #endif /* PTYORPIPE */
10222 if (cx == XXPIPE || cx == XXPTY) { /* PIPE or PTY */
10224 extern int netsave;
10225 x = nettype; /* Save net type in case of failure */
10226 nettype = (cx == XXPIPE) ? NET_CMD : NET_PTY;
10227 if ((y = setlin(XYHOST,0,1)) < 0) {
10228 nettype = x; /* Failed, restore net type. */
10229 ttnproto = z; /* and protocol */
10236 #endif /* PTYORPIPE */
10239 if (cx == XXSSH) { /* SSH (Secure Shell) */
10240 extern int netsave;
10242 int k, x, havehost = 0, trips = 0;
10243 int tmpver = -1, tmpxfw = -1;
10245 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
10246 extern int sl_ssh_ver, sl_ssh_ver_saved;
10247 #endif /* SSHTEST */
10248 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
10249 extern char * slmsg;
10250 extern char uidbuf[], sl_uidbuf[];
10251 extern char pwbuf[], * g_pswd;
10252 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
10253 struct FDB sw, kw, fl;
10256 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
10257 makestr(&ssh_tmpstr,NULL);
10258 makestr(&ssh_tmpuid,NULL);
10259 makestr(&ssh_tmpcmd,NULL);
10260 makestr(&ssh_tmpport,NULL);
10262 cmfdbi(&kw, /* 1st FDB - commands */
10263 _CMKEY, /* fcode */
10264 "host [ port ],\n or action", /* hlpmsg */
10266 "", /* addtl string data */
10267 nsshcmd, /* addtl numeric data 1: tbl size */
10268 0, /* addtl numeric data 2: 0 = keyword */
10269 xxstring, /* Processing function */
10270 sshkwtab, /* Keyword table */
10271 &fl /* Pointer to next FDB */
10273 cmfdbi(&fl, /* Host */
10274 _CMFLD, /* fcode */
10277 "", /* addtl string data */
10278 0, /* addtl numeric data 1 */
10279 0, /* addtl numeric data 2 */
10287 printf("?ssh what?\n");
10293 if (cmresult.fcode == _CMFLD) {
10295 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
10296 cmresult.nresult = XSSH_OPN;
10298 switch (cmresult.nresult) { /* SSH keyword */
10299 case XSSH_OPN: /* SSH OPEN */
10301 if ((x = cmfld("Host","",&s,xxstring)) < 0)
10303 ckstrncpy(line,s,LINBUFSIZ);
10305 /* Parse [ port ] [ switches ] */
10306 cmfdbi(&kw, /* Switches */
10308 "Port number or service name,\nor switch",
10317 cmfdbi(&fl, /* Port number or service name */
10328 trips = 0; /* Explained below */
10329 while (1) { /* Parse port and switches */
10330 x = cmfdb(&kw); /* Get a field */
10331 if (x == -3) /* User typed CR so quit from loop */
10333 if (x < 0) /* Other parse error, pass it back */
10335 switch (cmresult.fcode) { /* Field or Keyword? */
10336 case _CMFLD: /* Field */
10337 makestr(&ssh_tmpport,cmresult.sresult);
10339 case _CMKEY: /* Keyword */
10340 switch (cmresult.nresult) { /* Which one? */
10341 case SSHSW_USR: /* /USER: */
10343 printf("?This switch requires an argument\n");
10346 if ((y = cmfld("Username","",&s,xxstring)) < 0)
10349 makestr(&ssh_tmpuid,s);
10353 printf("?This switch requires an argument\n");
10357 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
10359 makestr(&ssh_tmpstr,"");
10365 if ((x = (int)strlen(s)) > PWBUFL) {
10366 makestr(&slmsg,"Internal error");
10367 printf("?Sorry, too long - max = %d\n",PWBUFL);
10370 makestr(&ssh_tmpstr,s);
10375 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
10377 if (z < 1 || z > 2) {
10378 printf("?Out of range: %d\n",z);
10385 if ((x = cmfld("Text","",&s,xxstring)) < 0)
10387 makestr(&ssh_tmpcmd,s);
10388 ssh_cas = (cmresult.nresult == SSHSW_SUB);
10391 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
10399 if (trips++ == 0) { /* After first time through */
10400 cmfdbi(&kw, /* only parse switches, not port. */
10413 if ((x = cmcfm()) < 0) /* Get confirmation */
10415 if (clskconnx(1) < 0) { /* Close current Kermit connection */
10416 if ( ssh_tmpstr ) {
10417 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
10418 makestr(&ssh_tmpstr,NULL);
10420 return(success = 0);
10422 makestr(&ssh_hst,line); /* Stash everything */
10424 if (!sl_uid_saved) {
10425 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
10428 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
10429 makestr(&ssh_tmpuid,NULL);
10432 makestr(&ssh_prt,ssh_tmpport);
10433 makestr(&ssh_tmpport,NULL);
10435 makestr(&ssh_prt,NULL);
10438 makestr(&ssh_cmd,brstrip(ssh_tmpcmd));
10439 makestr(&ssh_tmpcmd,NULL);
10441 makestr(&ssh_cmd,NULL);
10445 if (!sl_ssh_ver_saved) {
10446 sl_ssh_ver = ssh_ver;
10447 sl_ssh_ver_saved = 1;
10449 #endif /* SSHTEST */
10454 if (!sl_ssh_xfw_saved) {
10455 sl_ssh_xfw = ssh_xfw;
10456 sl_ssh_xfw_saved = 1;
10458 #endif /* SSHTEST */
10462 if (ssh_tmpstr[0]) {
10463 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
10468 makestr(&ssh_tmpstr,NULL);
10477 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
10478 g_pflg = pwflg; /* and flag */
10482 /* Line parameter to ttopen() is ignored */
10483 k = ttopen(line,&x,mdmtyp, 0);
10485 printf("?Unable to connect to %s\n",ssh_hst);
10488 return(success = 0);
10490 duplex = 0; /* Remote echo */
10491 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
10492 debug(F110,"ssh ttname",ttname,0);
10493 makestr(&slmsg,NULL); /* No SET LINE error message */
10497 #endif /* NODIAL */
10498 success = 1; /* SET LINE succeeded */
10499 network = 1; /* Network connection (not serial) */
10500 local = 1; /* Local mode (not remote) */
10501 if ((reliable != SET_OFF || !setreliable))
10502 reliable = SET_ON; /* Transport is reliable end to end */
10504 DialerSend(OPT_KERMIT_CONNECT, 0);
10506 setflow(); /* Set appropriate flow control */
10512 #endif /* NETCONN */
10513 #endif /* CKLOGDIAL */
10517 if (nmac) { /* Any macros defined? */
10519 k = mlook(mactab,"on_open",nmac); /* Look this up */
10520 if (k >= 0) { /* If found, */
10521 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
10522 parser(1); /* and execute it */
10532 /* Command was confirmed so we can pre-pop command level. */
10533 /* This is so CONNECT module won't think we're executing a */
10534 /* script if CONNECT was the final command in the script. */
10537 success = doconect(0,cmdlvl == 0 ? 1 : 0);
10543 if ((y = cmkey(sshclr,nsshclr,"","", xxstring)) < 0) {
10545 printf("?clear what?\n");
10550 if ((x = cmcfm()) < 0)
10562 return(success = 1); /* or whatever */
10564 case XSSH_AGT: { /* SSH AGENT */
10566 if ((y = cmkey(sshagent,nsshagent,"","",xxstring)) < 0)
10569 case SSHA_ADD: /* SSH AGENT ADD ... */
10570 if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
10572 if (x == -3) /* No name given */
10573 doeach = 1; /* so do them all */
10575 #endif /* SSHTEST */
10578 ckstrncpy(line,s,LINBUFSIZ);
10579 if ((x = cmcfm()) < 0)
10587 for (i = 0; i < ssh_idf_n; i++)
10588 x += ssh_agent_add_file(ssh_idf[i]);
10590 x = ssh_agent_add_file(line);
10591 #endif /* SSHTEST */
10592 return(success = (x == 0));
10594 case SSHA_DEL: { /* SSH AGENT DELETE ... */
10596 if ((x = cmifi("Identity file","",&s,&y,xxstring)) < 0) {
10598 if (x == -3) /* No name given */
10599 doall = 1; /* so do them all */
10601 #endif /* SSHTEST */
10604 ckstrncpy(line,s,LINBUFSIZ);
10605 if ((x = cmcfm()) < 0)
10611 x = ssh_agent_delete_all();
10613 x = ssh_agent_delete_file(line);
10614 #endif /* SSHTEST */
10615 return(success = (x == 0));
10618 int fingerprint = 0;
10619 if ((y = cmswi(sshagtsw,nsshagtsw,"","",xxstring)) < 0) {
10622 } else if (cmgbrk() > SP) {
10623 printf("?This switch does not take an argument\n");
10625 } else if (y == SSHASW_FP) {
10628 if ((x = cmcfm()) < 0)
10631 return(success = 1);
10634 (ssh_agent_list_identities(fingerprint) == 0));
10635 #endif /* SSHTEST */
10641 case XSSH_ADD: { /* SSH ADD */
10642 /* ssh add { local, remote } port host port */
10645 if ((cx = cmkey(addfwd,naddfwd,"","", xxstring)) < 0)
10647 if ((x = cmnum((cx == SSHF_LCL) ?
10648 "Local port number" : "Remote port number",
10649 "",10,&j,xxstring)) < 0)
10651 if ((x = cmfld("Host","",&s,xxstring)) < 0)
10654 if ((x = cmnum("Port","",10,&k,xxstring)) < 0)
10656 if ((x = cmcfm()) < 0)
10661 if (ssh_pf_lcl_n == 32) {
10663 "?Maximum number of local port forwardings already specified\n"
10666 return(success = 0);
10668 ssh_pf_lcl[ssh_pf_lcl_n].p1 = j;
10669 makestr(&(ssh_pf_lcl[ssh_pf_lcl_n].host),h);
10671 ssh_pf_lcl[ssh_pf_lcl_n].p2 = k;
10675 if (ssh_pf_rmt_n == 32) {
10677 "?Maximum number of remote port forwardings already specified\n"
10680 return(success = 0);
10682 ssh_pf_rmt[ssh_pf_rmt_n].p1 = j;
10683 makestr(&(ssh_pf_rmt[ssh_pf_rmt_n].host),h);
10685 ssh_pf_rmt[ssh_pf_rmt_n].p2 = k;
10688 return(success = 1);
10690 /* Not supporting arbitrary forwarding yet */
10691 case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */
10692 case XSSH_FRP: { /* SSH FORWARD-REMOTE-PORT */
10695 char * fw_host = NULL;
10697 if ((x = cmnum(cmresult.nresult == XSSH_FLP ?
10698 "local-port":"remote-port",
10699 "",10,&li_port,xxstring)) < 0)
10701 if (li_port < 1 || li_port > 65535) {
10702 printf("?Out range - min: 1, max: 65535\n");
10705 if ((x = cmfld("host",ssh_hst?ssh_hst:"",&s,xxstring)) < 0)
10707 n = ckstrncpy(tmpbuf,s,TMPBUFSIZ);
10709 if ((x = cmnum("host-port",ckuitoa(li_port),10,
10710 &to_port,xxstring)) < 0)
10712 if (to_port < 1 || to_port > 65535) {
10713 printf("?Out range - min: 1, max: 65535\n");
10716 if ((x = cmcfm()) < 0)
10718 switch (cmresult.nresult) {
10719 case XSSH_FLP: /* SSH FORWARD-LOCAL-PORT */
10721 ssh_fwd_local_port(li_port,fw_host,to_port);
10722 #endif /* SSHTEST */
10723 return(success = 1);
10724 case XSSH_FRP: /* SSH FORWARD-REMOTE-PORT */
10726 ssh_fwd_remote_port(li_port,fw_host,to_port);
10727 #endif /* SSHTEST */
10728 return(success = 1);
10730 return(success = 1);
10732 case XSSH_V2: /* SSH V2 */
10733 if ((cx = cmkey(ssh2tab,nssh2tab,"","", xxstring)) < 0)
10737 if ((x = cmcfm()) < 0)
10741 #endif /* SSHTEST */
10742 return(success = 1);
10747 if ((cx = cmkey(sshkey,nsshkey,"","", xxstring)) < 0)
10750 case SSHK_PASS: { /* Change passphrase */
10751 char * oldp = NULL, * newp = NULL;
10754 _CMKEY, /* fcode */
10755 "Filename, or switch", /* hlpmsg */
10757 "", /* addtl string data */
10758 2, /* addtl numeric data 1: tbl size */
10759 4, /* addtl numeric data 2: 4 = cmswi */
10760 xxstring, /* Processing function */
10761 sshkpsw, /* Keyword table */
10762 &df /* Pointer to next FDB */
10764 cmfdbi(&df, /* 2nd FDB - file for display */
10765 _CMIFI, /* output file */
10768 "", /* addtl string data */
10769 0, /* addtl numeric data 1 */
10770 0, /* addtl numeric data 2 */
10779 if (x == -3) break;
10782 if (cmresult.fcode != _CMKEY)
10785 printf("?This switch requires an argument\n");
10788 if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
10790 switch (cmresult.nresult) {
10798 if (cmresult.fcode == _CMIFI) { /* Filename */
10799 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10800 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10801 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10803 if ((x = cmcfm()) < 0) return(x);
10806 x = sshkey_change_passphrase(line[0] ? line : NULL,
10808 #endif /* SSHTEST */
10809 makestr(&oldp,NULL);
10810 makestr(&newp,NULL);
10811 success = (x == 0);
10814 case SSHK_CREA: { /* SSH KEY CREATE /switches... */
10815 int bits = 1024, keytype = SSHKT_2R;
10816 char * pass = NULL, * comment = NULL;
10820 * char * sshkey_default_file(int keytype)
10821 * will provide the default filename for a given keytype
10822 * is it possible to have the default value for the 2nd
10823 * FDB set and changed when a /TYPE switch is provided?
10824 * Would this allow for tab completion of the filename?
10827 _CMKEY, /* fcode */
10828 "Filename, or switch", /* hlpmsg */
10830 "", /* addtl string data */
10831 nsshkcrea, /* addtl numeric data 1: tbl size */
10832 4, /* addtl numeric data 2: 4 = cmswi */
10833 xxstring, /* Processing function */
10834 sshkcrea, /* Keyword table */
10835 &df /* Pointer to next FDB */
10837 cmfdbi(&df, /* 2nd FDB - file for display */
10838 _CMOFI, /* output file */
10841 "", /* addtl string data */
10842 0, /* addtl numeric data 1 */
10843 0, /* addtl numeric data 2 */
10852 if (x == -3) break;
10855 if (cmresult.fcode != _CMKEY)
10858 printf("?This switch requires an argument\n");
10861 switch (cmresult.nresult) {
10862 case SSHKC_BI: /* /BITS:n */
10863 if ((y = cmnum("","1024",10,&z,xxstring)) < 0)
10865 if (z < 512 || z > 4096) {
10866 printf("?Out range - min: 512, max: 4096\n");
10871 case SSHKC_PP: /* /PASSPHRASE:blah */
10872 if ((y = cmfld("Passphrase","",&s,xxstring)) < 0)
10876 case SSHKC_TY: /* /TYPE:keyword */
10877 if ((y = cmkey(sshkcty,nsshkcty,"",
10878 "v2-rsa",xxstring)) < 0)
10882 case SSHKC_1R: /* /COMMENT */
10883 if ((y = cmfld("Text","",&s,xxstring)) < 0)
10885 makestr(&comment,s);
10889 if (cmresult.fcode == _CMOFI) { /* Filename */
10890 if (cmresult.sresult) {
10891 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10892 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10893 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10896 if ((y = cmcfm()) < 0) /* Confirm */
10899 x = sshkey_create(line[0] ? line : NULL,
10900 bits, pass, keytype, comment);
10902 memset(pass,0,strlen(pass));
10903 #endif /* SSHTEST */
10904 makestr(&pass,NULL);
10905 makestr(&comment,NULL);
10906 return(success = (x == 0));
10908 case SSHK_DISP: { /* SSH KEY DISPLAY /switches... */
10910 int infmt = 0, outfmt = 0;
10913 _CMKEY, /* fcode */
10914 "Filename, or switch", /* hlpmsg */
10916 "", /* addtl string data */
10917 nsshdswi, /* addtl numeric data 1: tbl size */
10918 4, /* addtl numeric data 2: 4 = cmswi */
10919 xxstring, /* Processing function */
10920 sshdswi, /* Keyword table */
10921 &df /* Pointer to next FDB */
10923 cmfdbi(&df, /* 2nd FDB - file for display */
10924 _CMIFI, /* fcode */
10927 "", /* addtl string data */
10928 0, /* addtl numeric data 1 */
10929 0, /* addtl numeric data 2 */
10938 if (x == -3) break;
10941 if (cmresult.fcode != _CMKEY)
10944 printf("?This switch requires an argument\n");
10947 switch (cmresult.nresult) {
10949 case SSHKD_IN: /* /IN-FORMAT: */
10950 if ((y = cmkey(sshdifmt,nsshdifmt,
10951 "","",xxstring)) < 0)
10955 #endif /* COMMENT */
10956 case SSHKD_OUT: /* /FORMAT: */
10957 if ((y = cmkey(sshdofmt,nsshdofmt,
10958 "","",xxstring)) < 0)
10964 if (cmresult.fcode == _CMIFI) { /* Filename */
10965 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
10966 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
10967 ckstrncpy(line,tmpbuf,LINBUFSIZ);
10971 printf("?Key filename required\n");
10974 #endif /* COMMENT */
10975 if ((y = cmcfm()) < 0) /* Confirm */
10980 /* 2nd param is optional passphrase */
10981 x = sshkey_display_public(line[0] ? line : NULL, NULL);
10984 /* 2nd param is optional passphrase */
10985 x = sshkey_display_public_as_ssh2(line[0] ? line : NULL,
10989 x = sshkey_display_fingerprint(line[0] ? line : NULL, 1);
10992 x = sshkey_display_fingerprint(line[0] ? line : NULL, 0);
10995 #endif /* SSHTEST */
10996 return(success = (x == 0));
10998 case SSHK_V1: /* SSH KEY V1 SET-COMMENT */
10999 if ((x = cmkey(sshkv1,1,"","set-comment", xxstring)) < 0)
11001 if (x != 1) return(-2);
11002 if ((x = cmifi("Key file name","",&s,&y,xxstring)) < 0) {
11004 printf("?Name of key file required\n");
11008 ckstrncpy(line,s,LINBUFSIZ);
11009 if ((x = cmtxt("Comment text","",&s,xxstring)) < 0)
11012 x = sshkey_v1_change_comment(line, /* filename */
11013 s, /* new comment */
11014 NULL /* passphrase */
11016 #endif /* SSHTEST */
11017 success = (x == 0);
11023 #else /* SSHBUILTIN */
11026 if ((y = setlin(XXSSH,0,1)) < 0) {
11028 printf("?%s\n",ck_errstr());
11031 /* This isn't right either because it catches command editing */
11032 printf("?Sorry, pseudoterminal open failed\n");
11034 printf("Hint: Try \"ssh -t %s\"\n",line);
11037 #endif /* COMMENT */
11038 nettype = x; /* Failed, restore net type. */
11039 ttnproto = z; /* and protocol */
11045 #endif /* SSHCMD */
11046 #endif /* SSHBUILTIN */
11048 #endif /* ANYSSH */
11051 if (cx == XXSKRM) { /* SKERMIT (Secure Shell Kermit) */
11052 extern int netsave;
11053 int k, x, havehost = 0, trips = 0;
11054 int tmpver = -1, tmpxfw = -1;
11056 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
11057 extern int sl_ssh_ver, sl_ssh_ver_saved;
11058 #endif /* SSHTEST */
11059 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
11060 extern char * slmsg;
11061 extern char uidbuf[], sl_uidbuf[];
11062 extern char pwbuf[], * g_pswd;
11063 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
11064 struct FDB sw, kw, fl;
11067 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11068 makestr(&ssh_tmpstr,NULL);
11069 makestr(&ssh_tmpuid,NULL);
11070 makestr(&ssh_tmpcmd,NULL);
11071 makestr(&ssh_tmpport,NULL);
11073 cmfdbi(&kw, /* 1st FDB - commands */
11074 _CMKEY, /* fcode */
11075 "host [ port ],\n or action", /* hlpmsg */
11077 "", /* addtl string data */
11078 nsshkermit, /* addtl numeric data 1: tbl size */
11079 0, /* addtl numeric data 2: 0 = keyword */
11080 xxstring, /* Processing function */
11081 sshkermit, /* Keyword table */
11082 &fl /* Pointer to next FDB */
11084 cmfdbi(&fl, /* Host */
11085 _CMFLD, /* fcode */
11088 "", /* addtl string data */
11089 0, /* addtl numeric data 1 */
11090 0, /* addtl numeric data 2 */
11098 printf("?skermit what?\n");
11104 if (cmresult.fcode == _CMFLD) {
11106 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
11107 cmresult.nresult = SKRM_OPN;
11109 switch (cmresult.nresult) { /* SSH keyword */
11110 case SKRM_OPN: /* SSH OPEN */
11112 if ((x = cmfld("Host","",&s,xxstring)) < 0)
11114 ckstrncpy(line,s,LINBUFSIZ);
11116 /* Parse [ port ] [ switches ] */
11117 cmfdbi(&kw, /* Switches */
11119 "Port number or service name,\nor switch",
11128 cmfdbi(&fl, /* Port number or service name */
11139 trips = 0; /* Explained below */
11140 while (1) { /* Parse port and switches */
11141 x = cmfdb(&kw); /* Get a field */
11142 if (x == -3) /* User typed CR so quit from loop */
11144 if (x < 0) /* Other parse error, pass it back */
11146 switch (cmresult.fcode) { /* Field or Keyword? */
11147 case _CMFLD: /* Field */
11148 makestr(&ssh_tmpport,cmresult.sresult);
11150 case _CMKEY: /* Keyword */
11151 switch (cmresult.nresult) { /* Which one? */
11152 case SSHSW_USR: /* /USER: */
11154 printf("?This switch requires an argument\n");
11157 if ((y = cmfld("Username","",&s,xxstring)) < 0)
11160 makestr(&ssh_tmpuid,s);
11164 printf("?This switch requires an argument\n");
11168 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
11170 makestr(&ssh_tmpstr,"");
11176 if ((x = (int)strlen(s)) > PWBUFL) {
11177 makestr(&slmsg,"Internal error");
11178 printf("?Sorry, too long - max = %d\n",PWBUFL);
11181 makestr(&ssh_tmpstr,s);
11186 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
11188 if (z < 1 || z > 2) {
11189 printf("?Out of range: %d\n",z);
11198 if (trips++ == 0) { /* After first time through */
11199 cmfdbi(&kw, /* only parse switches, not port. */
11212 if ((x = cmcfm()) < 0) /* Get confirmation */
11214 if (clskconnx(1) < 0) { /* Close current Kermit connection */
11215 if ( ssh_tmpstr ) {
11216 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11217 makestr(&ssh_tmpstr,NULL);
11219 return(success = 0);
11221 makestr(&ssh_hst,line); /* Stash everything */
11223 if (!sl_uid_saved) {
11224 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
11227 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
11228 makestr(&ssh_tmpuid,NULL);
11231 makestr(&ssh_prt,ssh_tmpport);
11232 makestr(&ssh_tmpport,NULL);
11234 makestr(&ssh_prt,NULL);
11236 /* Set the Subsystem to Kermit */
11238 makestr(&ssh_cmd,"kermit");
11242 if (!sl_ssh_ver_saved) {
11243 sl_ssh_ver = ssh_ver;
11244 sl_ssh_ver_saved = 1;
11246 #endif /* SSHTEST */
11249 /* Disable X11 Forwarding */
11251 if (!sl_ssh_xfw_saved) {
11252 sl_ssh_xfw = ssh_xfw;
11253 sl_ssh_xfw_saved = 1;
11255 #endif /* SSHTEST */
11259 if (ssh_tmpstr[0]) {
11260 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
11265 makestr(&ssh_tmpstr,NULL);
11274 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
11275 g_pflg = pwflg; /* and flag */
11279 /* Line parameter to ttopen() is ignored */
11280 k = ttopen(line,&x,mdmtyp, 0);
11282 printf("?Unable to connect to %s\n",ssh_hst);
11285 return(success = 0);
11287 duplex = 0; /* Remote echo */
11288 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
11289 debug(F110,"ssh ttname",ttname,0);
11290 makestr(&slmsg,NULL); /* No SET LINE error message */
11294 #endif /* NODIAL */
11295 success = 1; /* SET LINE succeeded */
11296 network = 1; /* Network connection (not serial) */
11297 local = 1; /* Local mode (not remote) */
11298 if ((reliable != SET_OFF || !setreliable))
11299 reliable = SET_ON; /* Transport is reliable end to end */
11301 DialerSend(OPT_KERMIT_CONNECT, 0);
11303 setflow(); /* Set appropriate flow control */
11309 #endif /* NETCONN */
11310 #endif /* CKLOGDIAL */
11314 if (nmac) { /* Any macros defined? */
11316 k = mlook(mactab,"on_open",nmac); /* Look this up */
11317 if (k >= 0) { /* If found, */
11318 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
11319 parser(1); /* and execute it */
11329 /* Command was confirmed so we can pre-pop command level. */
11330 /* This is so CONNECT module won't think we're executing a */
11331 /* script if CONNECT was the final command in the script. */
11334 return(success = 1);
11340 #endif /* SSHBUILTIN */
11342 #ifdef SFTP_BUILTIN
11343 if (cx == XXSFTP) { /* SFTP (Secure Shell File Transfer) */
11344 extern int netsave;
11345 int k, x, havehost = 0, trips = 0;
11346 int tmpver = -1, tmpxfw = -1;
11348 extern int sl_ssh_xfw, sl_ssh_xfw_saved;
11349 extern int sl_ssh_ver, sl_ssh_ver_saved;
11350 #endif /* SSHTEST */
11351 extern int mdmtyp, mdmsav, cxtype, sl_uid_saved;
11352 extern char * slmsg;
11353 extern char uidbuf[], sl_uidbuf[];
11354 extern char pwbuf[], * g_pswd;
11355 extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
11356 struct FDB sw, kw, fl;
11359 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11360 makestr(&ssh_tmpstr,NULL);
11361 makestr(&ssh_tmpuid,NULL);
11362 makestr(&ssh_tmpcmd,NULL);
11363 makestr(&ssh_tmpport,NULL);
11365 cmfdbi(&kw, /* 1st FDB - commands */
11366 _CMKEY, /* fcode */
11367 "host [ port ],\n or action", /* hlpmsg */
11369 "", /* addtl string data */
11370 nsftpkwtab, /* addtl numeric data 1: tbl size */
11371 0, /* addtl numeric data 2: 0 = keyword */
11372 xxstring, /* Processing function */
11373 sftpkwtab, /* Keyword table */
11374 &fl /* Pointer to next FDB */
11376 cmfdbi(&fl, /* Host */
11377 _CMFLD, /* fcode */
11380 "", /* addtl string data */
11381 0, /* addtl numeric data 1 */
11382 0, /* addtl numeric data 2 */
11390 printf("?sftp what?\n");
11396 if (cmresult.fcode == _CMFLD) {
11398 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Hostname */
11399 cmresult.nresult = SFTP_OPN;
11401 switch (cmresult.nresult) { /* SFTP keyword */
11402 case SFTP_OPN: /* SFTP OPEN */
11404 if ((x = cmfld("Host","",&s,xxstring)) < 0)
11406 ckstrncpy(line,s,LINBUFSIZ);
11408 /* Parse [ port ] [ switches ] */
11409 cmfdbi(&kw, /* Switches */
11411 "Port number or service name,\nor switch",
11420 cmfdbi(&fl, /* Port number or service name */
11431 trips = 0; /* Explained below */
11432 while (1) { /* Parse port and switches */
11433 x = cmfdb(&kw); /* Get a field */
11434 if (x == -3) /* User typed CR so quit from loop */
11436 if (x < 0) /* Other parse error, pass it back */
11438 switch (cmresult.fcode) { /* Field or Keyword? */
11439 case _CMFLD: /* Field */
11440 makestr(&ssh_tmpport,cmresult.sresult);
11442 case _CMKEY: /* Keyword */
11443 switch (cmresult.nresult) { /* Which one? */
11444 case SSHSW_USR: /* /USER: */
11446 printf("?This switch requires an argument\n");
11449 if ((y = cmfld("Username","",&s,xxstring)) < 0)
11452 makestr(&ssh_tmpuid,s);
11456 printf("?This switch requires an argument\n");
11460 if ((x = cmfld("Password","",&s,xxstring)) < 0) {
11462 makestr(&ssh_tmpstr,"");
11468 if ((x = (int)strlen(s)) > PWBUFL) {
11469 makestr(&slmsg,"Internal error");
11470 printf("?Sorry, too long - max = %d\n",PWBUFL);
11473 makestr(&ssh_tmpstr,s);
11478 if ((x = cmnum("Number","",10,&z,xxstring)) < 0)
11480 if (z < 1 || z > 2) {
11481 printf("?Out of range: %d\n",z);
11490 if (trips++ == 0) { /* After first time through */
11491 cmfdbi(&kw, /* only parse switches, not port. */
11504 if ((x = cmcfm()) < 0) /* Get confirmation */
11506 if (clskconnx(1) < 0) { /* Close current Kermit connection */
11507 if ( ssh_tmpstr ) {
11508 memset(ssh_tmpstr,0,strlen(ssh_tmpstr));
11509 makestr(&ssh_tmpstr,NULL);
11511 return(success = 0);
11513 makestr(&ssh_hst,line); /* Stash everything */
11515 if (!sl_uid_saved) {
11516 ckstrncpy(sl_uidbuf,uidbuf,UIDBUFLEN);
11519 ckstrncpy(uidbuf,ssh_tmpuid,UIDBUFLEN);
11520 makestr(&ssh_tmpuid,NULL);
11523 makestr(&ssh_prt,ssh_tmpport);
11524 makestr(&ssh_tmpport,NULL);
11526 makestr(&ssh_prt,NULL);
11528 /* Set the Subsystem to Kermit */
11530 makestr(&ssh_cmd,"sftp");
11534 if (!sl_ssh_ver_saved) {
11535 sl_ssh_ver = ssh_ver;
11536 sl_ssh_ver_saved = 1;
11538 #endif /* SSHTEST */
11541 /* Disable X11 Forwarding */
11543 if (!sl_ssh_xfw_saved) {
11544 sl_ssh_xfw = ssh_xfw;
11545 sl_ssh_xfw_saved = 1;
11547 #endif /* SSHTEST */
11551 if (ssh_tmpstr[0]) {
11552 ckstrncpy(pwbuf,ssh_tmpstr,PWBUFL+1);
11557 makestr(&ssh_tmpstr,NULL);
11566 makestr(&g_pswd,pwbuf); /* Save global pwbuf */
11567 g_pflg = pwflg; /* and flag */
11571 /* Line parameter to ttopen() is ignored */
11572 k = ttopen(line,&x,mdmtyp, 0);
11574 printf("?Unable to connect to %s\n",ssh_hst);
11577 return(success = 0);
11579 duplex = 0; /* Remote echo */
11580 ckstrncpy(ttname,line,TTNAMLEN); /* Record the command */
11581 debug(F110,"ssh ttname",ttname,0);
11582 makestr(&slmsg,NULL); /* No SET LINE error message */
11586 #endif /* NODIAL */
11587 success = 1; /* SET LINE succeeded */
11588 network = 1; /* Network connection (not serial) */
11589 local = 1; /* Local mode (not remote) */
11590 if ((reliable != SET_OFF || !setreliable))
11591 reliable = SET_ON; /* Transport is reliable end to end */
11593 DialerSend(OPT_KERMIT_CONNECT, 0);
11595 setflow(); /* Set appropriate flow control */
11601 #endif /* NETCONN */
11602 #endif /* CKLOGDIAL */
11606 if (nmac) { /* Any macros defined? */
11608 k = mlook(mactab,"on_open",nmac); /* Look this up */
11609 if (k >= 0) { /* If found, */
11610 if (dodo(k,ssh_hst,0) > -1) /* set it up, */
11611 parser(1); /* and execute it */
11621 /* Command was confirmed so we can pre-pop command level. */
11622 /* This is so CONNECT module won't think we're executing a */
11623 /* script if CONNECT was the final command in the script. */
11627 success = sftp_do_init();
11628 return(success = 1);
11644 if ((y = cmtxt("command parameters","",&s,xxstring)) < 0)
11646 if (ssh_tchk() < 0 || !ssh_cas || strcmp(ssh_cmd,"sftp")) {
11647 printf("?Not connected to SFTP Service\n");
11648 return(success = 0);
11650 success = sftp_do_cmd(cmresult.nresult,s);
11656 #endif /* SFTP_BUILTIN */
11658 if (cx == XXRLOG) { /* RLOGIN */
11663 printf("?Sorry, either TCP/IP is not available on this system or\n\
11664 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n"
11670 x = nettype; /* Save net type in case of failure */
11671 z = ttnproto; /* Save protocol in case of failure */
11672 nettype = NET_TCPB;
11673 ttnproto = NP_RLOGIN;
11674 if ((y = setlin(XYHOST,0,1)) <= 0) {
11675 nettype = x; /* Failed, restore net type. */
11676 ttnproto = z; /* and protocol */
11685 printf("?Sorry, RLOGIN is not configured in this copy of C-Kermit.\n");
11687 #endif /* RLOGCODE */
11689 #endif /* NETCONN */
11690 #endif /* NOLOCAL */
11693 if (cx == XXTRA) { /* TRANSMIT */
11695 int i, n, xpipe = 0, xbinary = 0, xxlate = 1, xxnowait = 0, getval;
11699 struct FDB sf, sw, tx; /* FDBs for parse functions */
11701 extern int tcs_transp; /* Term charset is transparent */
11703 int tcs_transp = 1;
11704 #endif /* NOCSETS */
11707 xbinary = binary; /* Default text/binary mode */
11709 xbinary = 0; /* Default is text */
11710 #endif /* COMMENT */
11713 cmfdbi(&sw, /* First FDB - command switches */
11714 _CMKEY, /* fcode */
11715 "Filename, or switch", /* hlpmsg */
11717 "", /* addtl string data */
11718 nxmitsw, /* addtl numeric data 1: tbl size */
11719 4, /* addtl numeric data 2: 4 = cmswi */
11720 xxstring, /* Processing function */
11721 xmitsw, /* Keyword table */
11722 &sf /* Pointer to next FDB */
11724 cmfdbi(&sf, /* 2nd FDB - file to send */
11725 _CMIFI, /* fcode */
11726 "File to transmit", /* hlpmsg */
11728 "", /* addtl string data */
11729 0, /* addtl numeric data 1 */
11730 0, /* addtl numeric data 2 */
11737 #endif /* PIPESEND */
11741 _CMTXT, /* fcode */
11742 "Command", /* hlpmsg */
11744 "", /* addtl string data */
11745 0, /* addtl numeric data 1 */
11746 0, /* addtl numeric data 2 */
11751 #endif /* PIPESEND */
11757 if (cmresult.fcode != _CMKEY)
11759 c = cmgbrk(); /* Have switch, get break character */
11760 if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
11761 printf("?This switch does not take an argument\n");
11764 if (!getval && (cmgkwflgs() & CM_ARG)) {
11765 printf("?This switch requires an argument\n");
11768 n = cmresult.nresult; /* Numeric result = switch ID */
11769 switch (n) { /* Process the switch */
11771 case XMI_CMD: /* Transmit from a command */
11773 printf("?Sorry, system command access is disabled\n");
11776 sw.hlpmsg = "Command, or switch"; /* Change help message */
11777 xpipe = 1; /* (No way to undo this one) */
11779 #endif /* PIPESEND */
11781 case XMI_BIN: /* Binary */
11783 xxlate = 0; /* Don't translate charsets */
11787 case XMI_TXT: /* Text */
11789 xxlate = !tcs_transp; /* Translate if TERM CHAR not TRANSP */
11793 case XMI_TRA: /* Transparent text */
11795 xxlate = 0; /* But don't translate charsets */
11800 case XMI_VRB: /* /VERBOSE */
11801 case XMI_QUI: /* /QUIET */
11802 break; /* (not implemented yet) */
11803 #endif /* COMMENT */
11805 case XMI_NOW: /* /NOWAIT */
11809 case XMI_NOE: /* /NOWAIT */
11818 if (cmresult.fcode != _CMIFI && cmresult.fcode != _CMTXT)
11820 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Filename */
11821 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
11822 ckstrncpy(line,tmpbuf,LINBUFSIZ);
11824 if ((y = cmcfm()) < 0) /* Confirm */
11827 if ((apcactive == APC_LOCAL) ||
11828 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
11829 return(success = 0);
11830 #endif /* CK_APC */
11831 if (cmresult.nresult != 0) {
11832 printf("?Only a single file may be transmitted\n");
11839 printf("?Sorry, a command to send from is required\n");
11844 #endif /* PIPESEND */
11846 if (scan && (filepeek
11849 #endif /* NOXFER */
11850 )) { /* If user didn't specify type */
11851 int k, x; /* scan the file to see */
11853 k = scanfile(s,&x,nscanfile);
11854 if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
11856 if (!xfrxla) xxlate = 0;
11857 success = transmit(s,
11858 (char) (xxnowait ? '\0' : (char)xmitp),
11865 #endif /* NOXMIT */
11868 if (cx == XXTYP || cx == XXCAT || cx == XXMORE ||
11869 cx == XXHEAD || cx == XXTAIL) {
11870 int paging = 0, havename = 0, head = 0, width = 0;
11871 int height = 0, count = 0;
11872 char pfxbuf[64], * prefix = NULL;
11873 char outfile[CKMAXPATH+1];
11876 int incs = 0, outcs = 0, cset = -1, number = 0;
11879 extern int fileorder;
11882 char guibuf[128], * gui_title = NULL;
11886 extern int tcsr, tcsl;
11887 #endif /* NOCSETS */
11889 #endif /* UNICODE */
11895 else if (cx == XXCAT)
11898 paging = (typ_page < 0) ? xaskmore : typ_page;
11902 if (cx == XXHEAD) {
11905 } else if (cx == XXTAIL) {
11911 if (inserver && !ENABLED(en_typ)) {
11912 printf("?Sorry, TYPE command disabled\n");
11917 cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */
11918 _CMKEY, /* fcode */
11919 "Filename or switch", /* hlpmsg */
11921 "", /* addtl string data */
11922 ntypetab, /* addtl numeric data 1: tbl size */
11923 4, /* addtl numeric data 2: 4 = cmswi */
11924 xxstring, /* Processing function */
11925 typetab, /* Keyword table */
11926 &sf /* Pointer to next FDB */
11928 cmfdbi(&sf, /* 1st FDB - file to type */
11929 _CMIFI, /* fcode */
11932 "", /* addtl string data */
11933 0, /* addtl numeric data 1 */
11934 0, /* addtl numeric data 2 */
11940 while (!havename) {
11941 x = cmfdb(&sw); /* Parse something */
11942 debug(F101,"type cmfdb","",x);
11943 debug(F101,"type cmresult.fcode","",cmresult.fcode);
11944 debug(F101,"type cmresult.nresult","",cmresult.nresult);
11945 if (x < 0) { /* Error */
11948 printf("?Filename required\n");
11951 } else if (cmresult.fcode == _CMKEY) {
11952 char c; int getval;
11954 getval = (c == ':' || c == '=');
11955 if (getval && !(cmgkwflgs() & CM_ARG)) {
11956 printf("?This switch does not take an argument\n");
11960 if (!getval && (cmgkwflgs() & CM_ARG)) {
11961 printf("?This switch requires an argument\n");
11962 /* Not if it has a default! */
11965 #endif /* COMMENT */
11966 switch (cmresult.nresult) {
11975 #endif /* CK_TTGWSIZ */
11986 if ((x = cmnum("Number of lines",
11987 "10",10,&y,xxstring)) < 0)
11989 head = (cmresult.nresult == TYP_TAI) ? -y : y;
11993 y = typ_wid > -1 ? typ_wid : cmd_cols;
11995 if ((x = cmnum("Column at which to truncate",
11996 ckitoa(y),10,&y,xxstring)) < 0)
12004 if ((x = cmnum("Height of GUI dialog",
12005 ckitoa(y),10,&y,xxstring)) < 0)
12012 if (!getval && (cmgkwflgs() & CM_ARG)) {
12013 printf("?This switch requires an argument\n");
12016 if ((x = cmfld("pattern","",&s,xxstring)) < 0)
12018 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12023 if (!getval && (cmgkwflgs() & CM_ARG)) {
12024 printf("?This switch requires an argument\n");
12027 if ((x = cmfld("prefix for each line","",&s,xxstring)) < 0)
12029 if ((int)strlen(s) > 63) {
12030 printf("?Too long - 63 max\n");
12033 ckstrncpy(pfxbuf,s,64);
12034 prefix = brstrip(pfxbuf);
12040 if (!getval && (cmgkwflgs() & CM_ARG)) {
12041 printf("?This switch requires an argument\n");
12044 if ((x = cmfld("Dialog box title","",&s,xxstring)) < 0) {
12048 if ((int)strlen(s) > 127) {
12049 printf("?Too long - 127 max\n");
12052 ckstrncpy(guibuf,s,128);
12053 gui_title = brstrip(guibuf);
12059 case TYP_NUM: /* /NUMBER */
12065 case TYP_XPA: /* /TRANSPARENT */
12071 case TYP_XIN: /* /CHARACTER-SET: */
12072 if (!getval && (cmgkwflgs() & CM_ARG)) {
12073 printf("?This switch requires an argument\n");
12076 if ((incs = cmkey(fcstab,nfilc,
12077 "character-set name","",xxstring)) < 0) {
12078 if (incs == -3) /* Note: No default */
12085 case TYP_XUT: /* /TRANSLATE-TO: */
12086 if (!getval && (cmgkwflgs() & CM_ARG)) {
12087 printf("?This switch requires an argument\n");
12091 if (!inserver && !k95stdout) {
12095 tocs = rlookup(txrtab,ntxrtab,tcsl);
12097 extern struct keytab ttcstab[];
12098 extern int ntxrtab;
12099 tocs = rlookup(ttcstab,ntermc,tocs);
12102 #endif /* CKOUNI */
12107 if ((outcs = cmkey(fcstab,nfilc,
12108 "character-set",tocs,xxstring)) < 0)
12111 #endif /* UNICODE */
12113 if ((x = cmofi("File for result lines","",
12116 ckstrncpy(outfile,s,CKMAXPATH);
12119 } else if (cmresult.fcode == _CMIFI)
12125 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
12126 y = cmresult.nresult;
12128 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
12130 printf("?Name of an existing file required\n");
12134 ckstrncpy(line,s,LINBUFSIZ);
12137 printf("?A single file please\n");
12141 if ( outfile[0] && gui ) {
12142 printf("?/GUI and /OUTPUT are incompatible\n");
12147 if ((y = cmcfm()) < 0) /* Confirm the command */
12152 if (cset < 0 && filepeek) { /* If no charset switches given */
12154 k = scanfile(line,&x,nscanfile); /* Call file analyzer */
12155 debug(F111,"type scanfile",line,k);
12156 debug(F101,"type scanfile flag","",x);
12158 case FT_UTF8: /* which can detect UTF-8... */
12162 case FT_UCS2: /* and UCS-2... */
12165 fileorder = x; /* even if there is no BOM. */
12166 debug(F101,"type fileorder","",fileorder);
12171 if (cset < 0) { /* If input charset still not known */
12173 tocs = rlookup(txrtab,ntxrtab,tcsl);
12175 extern struct keytab ttcstab[];
12176 extern int ntxrtab;
12177 tocs = rlookup(ttcstab,ntermc,incs);
12180 #endif /* CKOUNI */
12181 incs = lookup(fcstab,tocs,nfilc,&x);
12185 if (outcs == 0 && incs != 0) { /* Supply default target charset */
12186 int x = 0; /* if switch not given. */
12188 outcs = lookup(fcstab,tocs,nfilc,&x);
12190 #else /* !UNICODE */
12191 if (cset < 0) incs = outcs = 0;
12192 #endif /* UNICODE */
12194 if (outfile[0] && paging) /* This combination makes no sense */
12195 paging = 0; /* so turn off paging */
12198 /* No paging when dialog is used */
12199 if ( gui && paging )
12202 if ( !gui && height ) {
12203 printf("?The /HEIGHT switch is not supported without /GUI\n");
12208 if (count) paging = -1;
12209 debug(F111,"type",line,paging);
12212 s = (char *)1; /* ok, its an ugly hack */
12213 if (gui_text_popup_create(gui_title ?
12214 gui_title : line, height,width) < 0) {
12215 printf("?/GUI not supported on this system\n");
12224 dotype(line,paging,0,head,pat,width,prefix,incs,outcs,s,number);
12227 #endif /* NOFRILLS */
12230 if (cx == XXXLA) { /* TRANSLATE file's charset */
12231 _PROTOTYP (int doxlate, ( void ) );
12234 #endif /* NOCSETS */
12236 if (cx == XXVER) { /* VERSION */
12238 extern char * ck_patch, * ck_s_test;
12240 extern int hmtopline;
12241 #endif /* COMMENT */
12242 if ((y = cmcfm()) < 0)
12245 printf("\n%s, for%s\n Numeric: %ld",versio,ckxsys,vernum);
12247 printf("Authors:\n");
12248 printf(" Frank da Cruz, Columbia University\n");
12249 printf(" Jeffrey Eric Altman, Secure Endpoints, Inc. %s\n",
12250 "<jaltman@secure-endpoints.com>"
12252 printf(" Contributions from many others.\n");
12255 printf("\nTHIS IS A TEST VERSION, NOT FOR PRODUCTION USE.\n");
12259 printf(" Patches: %s\n", ck_patch);
12262 printf(" Type COPYRIGHT for copyright and license.\n\n");
12270 #endif /* COMMENT */
12272 return(success = 1);
12275 if (cx == XXCPR) { /* COPYRIGHT or LICENSE */
12276 if ((y = cmcfm()) < 0)
12279 if (inserver) { /* Free WIKSD */
12280 extern char * wiksdcpr[];
12285 return(success = 1);
12288 #ifndef MAC /* Only for multiuser systems */
12291 if (cx == XXWHO) { /* WHO */
12294 if (inserver && !ENABLED(en_who)) {
12295 printf("?Sorry, WHO command disabled\n");
12300 if ((z = cmcfm()) < 0) return(z);
12302 printf("?Sorry, who not allowed\n");
12303 return(success = 0);
12307 if ((y = cmtxt("user name","",&s,xxstring)) < 0) return(y);
12309 printf("?Sorry, WHO command disabled\n");
12310 return(success = 0);
12312 if (!(wc = getenv("CK_WHO"))) wc = WHOCMD;
12314 if ((int) strlen(wc) > 0) {
12315 ckmakmsg(line,LINBUFSIZ,wc," ",s,NULL);
12318 #endif /* datageneral */
12319 return(success = 1);
12321 #endif /* NOFRILLS */
12326 if (cx == XXWRI || cx == XXWRL || cx == XXWRBL) { /* WRITE */
12327 int x,y; /* On stack in case of \fexec() */
12328 if ((x = cmkey(writab,nwri,"to file or log","",xxstring)) < 0) {
12329 if (x == -3) printf("?Write to what?\n");
12332 if ((y = cmtxt("text","",&s,xxstring)) < 0) return(y);
12335 case LOGD: y = ZDFILE; break;
12336 case LOGP: y = ZPFILE; break;
12338 case LOGS: y = ZSFILE; break;
12339 #endif /* NOLOCAL */
12340 case LOGT: y = ZTFILE; break;
12342 case LOGW: y = ZWFILE; break;
12344 case LOGX: /* SCREEN (stdout) */
12345 case LOGE: /* ERROR (stderr) */
12348 (cx == XXWRL) ? "WRITELN ERROR" : "WRITE ERROR", s,0);
12349 fprintf(stderr,"%s%s",s,(cx == XXWRL) ? "\n" : "");
12352 (cx == XXWRL) ? "WRITELN SCREEN" : "WRITE SCREEN", s,0);
12353 printf("%s%s",s,(cx == XXWRL) ? "\n" : "");
12355 return(success = 1);
12356 default: return(-2);
12358 if (chkfn(y) > 0) {
12359 x = (cx == XXWRI) ? zsout(y,s) : zsoutl(y,s);
12360 if (x < 0) printf("?Write error\n");
12363 printf("?File or log not open\n");
12365 return(success = (x == 0) ? 1 : 0);
12367 #endif /* NOFRILLS */
12370 if (cx == XXASC || cx == XXBIN) {
12371 if ((x = cmcfm()) < 0) return(x);
12373 if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
12374 return(success = doftptyp((cx == XXASC) ? 0 : 1));
12375 #endif /* NEWFTP */
12376 binary = (cx == XXASC) ? XYFT_T : XYFT_B;
12377 return(success = 1);
12379 #endif /* NOXFER */
12382 if ((x = cmcfm()) < 0) return(x);
12384 return(success = (y > -1) ? 1 : 0);
12388 if (cx == XXMKDIR || cx == XXLMKD) {
12391 if (!locus && cx != XXLMKD) {
12395 return(dormt(XZMKD));
12396 #endif /* NOXFER */
12400 if (inserver && !ENABLED(en_mkd)) {
12401 printf("?Sorry, directory creation is disabled\n");
12405 if ((x = cmfld("Name for new directory","",&s,xxstring)) < 0) {
12409 printf("?Directory name required\n");
12413 ckstrncpy(line,s,LINBUFSIZ);
12415 if ((x = cmcfm()) < 0) return(x);
12417 bgchk(); /* Set msgflg */
12418 x = ckmkdir(0,s,&p,msgflg,0);
12420 if (msgflg && x == 0)
12421 printf("?Directory already exists\n");
12422 #endif /* COMMENT */
12423 return(success = (x < 0) ? 0 : 1);
12425 if (cx == XXRMDIR || cx == XXLRMD) { /* RMDIR */
12428 if (!locus && cx != XXLRMD) {
12432 return(dormt(XZRMD));
12433 #endif /* NOXFER */
12437 if (inserver && !ENABLED(en_rmd)) {
12438 printf("?Sorry, directory removal is disabled\n");
12442 if ((x = cmdir("Name of directory to be removed","",&s,xxstring)) < 0)
12444 ckstrncpy(line,s,LINBUFSIZ);
12446 if ((x = cmcfm()) < 0) return(x);
12448 x = ckmkdir(1,s,&p,msgflg,0);
12449 return(success = (x < 0) ? 0 : 1);
12451 #endif /* CK_MKDIR */
12455 return(dotelopt());
12456 #endif /* TNCODE */
12459 if (cx == XXNPSH) {
12460 if ((z = cmcfm()) < 0) return(z);
12464 #endif /* NOSERVER */
12467 #endif /* PIPESEND */
12468 return(success = 1);
12470 #endif /* NOPUSH */
12473 if (cx == XXNSCR) {
12474 if ((z = cmcfm()) < 0) return(z);
12476 return(success = 1);
12481 if (cx == XXLOCAL) /* LOCAL variable declarations */
12482 return(success = dolocal());
12485 if (cx == XXKERMI) { /* The KERMIT command */
12487 extern char **xargv;
12490 if ((y = cmtxt("kermit command-line arguments, -h for help",
12491 "",&s,xxstring)) < 0)
12493 ckstrncpy(line,"kermit ",LINBUFSIZ);
12494 ckstrncat(line,s,LINBUFSIZ-8);
12495 xwords(line,64,list,0);
12496 for (i = 1; i < 64; i++) {
12506 extern int justone;
12507 debug(F000,"KERMIT sstate","",sstate);
12508 justone = 1; /* Force return to command mode */
12509 proto(); /* after protocol */
12512 debug(F101,"KERMIT sstate","",sstate);
12513 return(success = 1); /* Not exactly right, but... */
12516 if (cx == XXDATE) { /* DATE command */
12517 extern char cmdatebuf[], * cmdatemsg;
12521 if ((y = cmtxt("date and/or time, or carriage return for current",
12522 "",&s,xxstring)) < 0)
12525 dp = cmcvtdate(s,1);
12527 printf("?%s\n",cmdatemsg ? cmdatemsg : "Date conversion error");
12534 /* This works fine but messes up my "dates" torture-test script */
12536 if ((x = cmdate("Date and/or time, or carriage return for current",
12537 "",&s,0,xxstring)) < 0) {
12540 printf("%s\n",cmdatebuf);
12543 #endif /* COMMENT */
12550 #endif /* NOFRILLS */
12551 #endif /* NOPUSH */
12553 #ifdef BROWSER /* Defined only ifndef NOPUSH */
12555 return(dobrowse());
12556 #endif /* BROWSER */
12559 if (cx == XXTAPI) { /* Microsoft TAPI */
12560 return (success = dotapi());
12562 #endif /* CK_TAPI */
12565 if (cx == XXWHERE) {
12566 extern char * rfspec, * sfspec, * srfspec, * rrfspec;
12567 if ((x = cmcfm()) < 0) return(x);
12568 printf("\nFile most recently...\n\n");
12569 printf(" Sent: %s\n", sfspec ? sfspec : "(none)");
12570 if (sfspec && srfspec) {
12571 printf(" Stored as: %s\n", srfspec);
12574 printf(" Received: %s\n", rrfspec ? rrfspec : "(none)");
12575 if (rfspec && rrfspec)
12576 printf(" Stored as: %s\n", rfspec);
12578 "\nIf the full path is not shown, then the file is probably in your current\n"
12581 "directory or your download directory (if any - SHOW FILE to find out).\n\n"
12583 return(success = 1);
12585 #endif /* NOXFER */
12590 #endif /* CK_RECALL */
12593 if (cx == XXCHRT) /* Change Kermit's root directory */
12594 return(dochroot());
12595 #endif /* CKROOT */
12598 if (cx == XXAUTH) { /* KERBEROS */
12599 x = cp_auth(); /* Parse it */
12602 printf("?Command disabled in IKSD.\r\n");
12603 return(success = 0);
12606 if (x < 0) /* Pass parse errors back */
12608 return(success = doauth(cx));
12610 #endif /* CK_KERBEROS */
12613 if (cx == XXTERM) {
12614 return(settrmtyp());
12616 #endif /* NOLOCAL */
12618 if (cx == XXSTATUS) {
12619 if ((x = cmcfm()) < 0) return(x);
12620 printf( " %s\n", success ? "SUCCESS" : "FAILURE" );
12621 return(0); /* Don't change it */
12624 if (cx == XXFAIL) {
12625 if ((x = cmcfm()) < 0) return(x);
12626 return(success = 0);
12629 if (cx == XXSUCC) {
12630 if ((x = cmcfm()) < 0) return(x);
12631 return(success = 1);
12634 if (cx == XXNLCL) {
12635 extern int nolocal;
12636 if ((x = cmcfm()) < 0) return(x);
12638 return(success = 1);
12642 if (cx == XXRASG) /* Shortcuts for REMOTE commands */
12643 return(dormt(XZASG));
12645 return(dormt(XZCWD));
12647 return(dormt(XZCPY));
12649 return(dormt(XZDEL));
12651 return(dormt(XZDIR));
12653 return(dormt(XZXIT));
12655 return(dormt(XZHLP));
12657 return(dormt(XZHOS));
12659 return(dormt(XZKER));
12661 return(dormt(XZPWD));
12663 return(dormt(XZQUE));
12665 return(dormt(XZREN));
12667 return(dormt(XZMKD));
12669 return(dormt(XZRMD));
12671 return(dormt(XZSET));
12673 return(dormt(XZSPA));
12675 return(dormt(XZTYP));
12677 return(dormt(XZWHO));
12679 return(dormt(XZCDU));
12681 return(dormt(XZPRI));
12682 #endif /* NOXFER */
12684 if (cx == XXRESET) { /* RESET */
12685 if ((x = cmcfm()) < 0)
12687 doclean(0); /* Close all files */
12688 return(success = 1);
12693 if (cx == XXASSOC) /* ASSOCIATE */
12695 #endif /* NOCSETS */
12696 #endif /* NOXFER */
12699 if (cx == XXSHIFT) { /* SHIFT */
12700 if ((y = cmnum("Number of arguments to shift","1",10,&x,xxstring)) < 0)
12702 if ((z = cmcfm()) < 0)
12704 return(success = doshift(x));
12710 return(domanual());
12711 #endif /* NOHELP */
12714 if (cx == XXSORT) /* SORT an array */
12718 if (cx == XXPURGE) {
12720 if (inserver && (!ENABLED(en_del)
12723 #endif /* CK_LOGIN */
12725 printf("?Sorry, DELETE is disabled\n");
12730 if ((apcactive == APC_LOCAL) ||
12731 ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
12732 return(success = 0);
12733 #endif /* CK_APC */
12738 if ((x = cmtxt("optional switches followed by filespec",
12739 "",&s,xxstring)) < 0)
12742 printf("?Sorry, DCL access is disabled\n");
12745 ckstrncpy(line,s,LINBUFSIZ);
12747 x = mlook(mactab,"purge",nmac);
12748 return(success = dodo(x,s,cmdstk[cmdlvl].ccflgs));
12752 #endif /* CKPURGE */
12756 if (cx == XXFAST) {
12757 if ((x = cmcfm()) < 0) return(x);
12758 x = mlook(mactab,"fast",nmac);
12759 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12762 if ((x = cmcfm()) < 0) return(x);
12763 x = mlook(mactab,"cautious",nmac);
12764 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12767 if ((x = cmcfm()) < 0) return(x);
12768 x = mlook(mactab,"robust",nmac);
12769 return(success = dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
12773 if (cx == XXSCRN) { /* SCREEN */
12775 if ((x = cmkey(scntab, nscntab,"screen action","", xxstring)) < 0)
12777 switch (x) { /* MOVE-TO (cursor position) */
12779 if ((y = cmnum("Row (1-based)","",10,&z,xxstring)) < 0)
12782 y = cmnum("Column (1-based)","1",10,&z,xxstring);
12786 if ((y = cmcfm()) < 0)
12788 if (row < 0 || col < 0) {
12789 printf("?Row and Column must be 1 or greater\n");
12792 if (cmd_rows > 0 && row > cmd_rows)
12794 if (cmd_cols > 0 && col > cmd_cols)
12796 y = ck_curpos(row,col);
12797 return(success = (y > -1) ? 1 : 0);
12799 case SCN_CLR: /* CLEAR */
12800 if ((y = cmcfm()) < 0)
12802 debug(F100,"screen calling ck_cls()","",0);
12804 return(success = (y > -1) ? 1 : 0);
12806 case SCN_CLE: /* CLEOL */
12807 if ((y = cmcfm()) < 0)
12810 return(success = (y > -1) ? 1 : 0);
12818 #endif /* TCPSOCKET */
12819 #endif /* NOHTTP */
12822 if (cx == XXARRAY) { /* ARRAY */
12824 extern int showarray();
12825 #endif /* NOSHOW */
12826 if ((x = cmkey(arraytab, narraytab,"Array operation","",xxstring)) < 0)
12830 return(dodcl(XXDCL));
12835 return(showarray());
12836 #endif /* NOSHOW */
12838 return(copyarray());
12841 return(clrarray(x));
12845 return(rszarray());
12847 return(linkarray());
12850 printf("?Sorry, not implemented yet - \"%s\"\n",cmdbuf);
12861 return(douchmod()); /* Do Unix chmod */
12863 #endif /* CK_PERMS */
12866 return(doprompt());
12871 if (cx == XXDEBUG) { /* DEBUG */
12874 return(seton(&dummy));
12876 return(seton(&deblog));
12881 if (cx == XXLEARN) { /* LEARN */
12882 struct FDB of, sw, cm;
12883 int closing = 0, off = 0, on = 0, confirmed = 0;
12886 cmfdbi(&sw, /* 2nd FDB - optional /PAGE switch */
12887 _CMKEY, /* fcode */
12888 "Script file name, or switch", /* hlpmsg */
12890 "", /* addtl string data */
12891 3, /* addtl numeric data 1: tbl size */
12892 4, /* addtl numeric data 2: 4 = cmswi */
12893 xxstring, /* Processing function */
12894 learnswi, /* Keyword table */
12895 &of /* Pointer to next FDB */
12897 cmfdbi(&of,_CMOFI,"","","",0,0,xxstring,NULL,&cm);
12898 cmfdbi(&cm,_CMCFM,"","","",0,0,NULL,NULL,NULL);
12901 while (!confirmed) {
12902 x = cmfdb(&sw); /* Parse something */
12905 switch (cmresult.fcode) { /* What was it? */
12906 case _CMOFI: /* Output file name */
12907 ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
12909 case _CMKEY: /* Switch */
12911 if ((c == ':' || c == '=') && !(cmgkwflgs() & CM_ARG)) {
12912 printf("?This switch does not take an argument\n");
12915 switch (cmresult.nresult) {
12916 case 2: /* /CLOSE */
12917 closing = 1; /* Fall thru on purpose */
12928 case _CMCFM: /* Confirmation */
12938 makestr(&learnfile,NULL);
12947 makestr(&learnfile,line);
12949 char * modes = "w";
12950 learnfp = fopen(learnfile,modes);
12952 debug(F110,"LEARN file open error",learnfile,0);
12957 if (zfnqfp(learnfile,TMPBUFSIZ,tmpbuf))
12958 makestr(&learnfile,tmpbuf);
12959 #endif /* ZFNQFP */
12960 debug(F110,"LEARN file open ok",learnfile,0);
12962 printf("Recording to %s...\n\n",learnfile);
12964 " WARNING: If you type your password during script recording, it will appear\n\
12965 in the file. Be sure to edit it or take other appropriate precautions.\n\n"
12968 fputs( "; Scriptfile: ",learnfp);
12969 fputs(learnfile,learnfp);
12970 fputs("\n; Directory: ",learnfp);
12971 fputs(zgtdir(),learnfp);
12972 fputs("\n; Recorded: ",learnfp);
12973 fputs(ckdate(),learnfp);
12974 fputs("\n",learnfp);
12983 debug(F101,"LEARN learning","",learning);
12984 return(success = 1);
12986 #endif /* CKLEARN */
12989 if (cx == XXUSER || cx == XXACCT) {
12990 if (!ftpisopen()) {
12991 printf("?FTP connection is not open\n");
12994 return(success = (cx == XXUSER) ? doftpusr() : doftpacct());
12996 if (cx == XXSITE || cx == XXPASV) {
12997 if (!ftpisopen()) {
12998 printf("?FTP connection is not open\n");
13001 return(success = (cx == XXSITE) ? doftpsite() : dosetftppsv());
13003 #endif /* NEWFTP */
13005 if (cx == XXORIE) { /* ORIENTATION */
13006 extern char * myname;
13008 char * s, *p, vbuf[32];
13009 char * vars[16]; char * legend[16];
13011 if ((y = cmcfm()) < 0)
13014 printf("\nProgram name:\n %s\n\n",myname);
13018 vars[0] = "home"; legend[0] = "Your home directory";
13019 vars[1] = "directory"; legend[1] = "K95's current directory";
13020 vars[2] = "exedir"; legend[2] = "K95 Program directory";
13021 vars[3] = "inidir"; legend[3] = "K95 Initialization file directory";
13022 vars[4] = "startup"; legend[4] = "Current directory when started";
13024 vars[5] = "common";
13025 legend[5] = "K95 data for all users and K95SITE.INI file";
13027 vars[6] = "personal"; legend[6] = "Your personal data directory tree";
13028 vars[7] = "desktop"; legend[7] = "Your deskop directory tree";
13030 vars[8] = "appdata";
13031 legend[8] = "Your personal K95 data tree and K95CUSTOM.INI file";
13033 vars[9] = "download"; legend[9] = "Your K95 download directory";
13034 vars[10] = "tmpdir"; legend[10] = "Your TEMP directory";
13035 vars[11] = NULL; legend[11] = NULL;
13037 for (i = 0; i < 16 && vars[i]; i++) {
13038 printf("%s:\n",legend[i]);
13039 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13040 ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
13041 printf(" Variable: %s\n",vbuf);
13042 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13045 zzstring(vbuf,&s,&y);
13047 ckGetLongPathName(tmpbuf,line,LINBUFSIZ);
13048 printf(" Long name: %s\n",line);
13049 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13051 GetShortPathName(tmpbuf,line,LINBUFSIZ);
13052 printf(" Short name: %s\n",line);
13053 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13055 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13059 vars[0] = "home"; legend[0] = "Your home directory";
13060 vars[1] = "directory"; legend[1] = "Kermit's current directory";
13061 vars[2] = "exedir"; legend[2] = "Kermit's program directory";
13062 vars[3] = "inidir"; legend[3] = "Initialization file directory";
13063 vars[4] = "startup"; legend[4] = "Current directory when started";
13064 vars[5] = "download"; legend[5] = "Kermit download directory";
13065 vars[6] = NULL; legend[6] = NULL;
13067 for (i = 0; i < 16 && vars[i]; i++) {
13068 printf("%s:\n",legend[i]);
13069 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13070 ckmakmsg(vbuf,32,"\\v(",vars[i],")",NULL);
13071 printf(" Variable: %s\n",vbuf);
13072 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13075 zzstring(vbuf,&s,&y);
13076 printf(" Value: %s\n",tmpbuf);
13077 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13079 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
13082 return(success = 1);
13086 if (cx == XXDIALER) {
13088 return(success = 1);
13092 if (cx == XXCONT) { /* CONTINUE */
13093 if ((x = cmcfm()) < 0)
13095 if (!xcmdsrc) { /* At prompt: continue script */
13097 popclvl(); /* Pop command level */
13098 return(success = 1); /* always succeeds */
13100 } else { /* In script: whatever... */
13101 x = mlook(mactab,"continue",nmac);
13102 /* Don't set success */
13103 return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs));
13107 if (cx == XXNOTAV) { /* Command in table not available */
13108 ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
13109 if ((x = cmtxt("Rest of command","",&s,NULL)) < 0)
13111 printf("Sorry, \"%s\" not configured in this version of Kermit.\n",
13114 return(success = 0);
13116 return(-2); /* None of the above */
13118 } /* end of docmd() */