5 #include "ckcsym.h" /* Symbol definitions */
7 /* C K U U S 3 -- "User Interface" for C-Kermit, part 3 */
11 Frank da Cruz <fdc@columbia.edu>,
12 The Kermit Project, Columbia University, New York City
13 Jeffrey E Altman <jaltman@secure-endpoints.com>
14 Secure Endpoints Inc., New York City
16 Copyright (C) 1985, 2009,
17 Trustees of Columbia University in the City of New York.
18 All rights reserved. See the C-Kermit COPYING.TXT file or the
19 copyright text in the ckcmai.c module for disclaimer and permissions.
22 /* SET command (but much material has been split off into ckuus7.c). */
25 Kermit-specific includes.
26 Definitions here supersede those from system include files.
28 #include "ckcdeb.h" /* Debugging & compiler things */
29 #include "ckcasc.h" /* ASCII character symbols */
30 #include "ckcker.h" /* Kermit application definitions */
31 #include "ckcxla.h" /* Character set translation */
32 #include "ckcnet.h" /* Network symbols */
34 char pwbuf[PWBUFL+1] = { NUL, NUL };
40 #ifdef CK_AUTHENTICATION
42 #endif /* CK_AUTHENTICATION */
46 #include "ckuusr.h" /* User interface symbols */
51 #endif /* SSHBUILTIN */
54 #ifdef COMMENT /* Would you believe */
55 #undef COMMENT /* <os2.h> defines this ? */
58 extern UCHAR NetBiosAdapter;
59 #endif /* CK_NETBIOS */
63 extern unsigned char colorcmd; /* Command-screen colors */
64 extern struct keytab ttyclrtab[];
66 extern int tt_cols[], tt_rows[], tt_szchng[], tt_status[];
68 _PROTOTYP(int setprty, (void));
69 extern char startupdir[], exedir[];
70 extern int tt_modechg;
74 #include "ckntap.h" /* Microsoft TAPI */
84 #endif /* CK_RECALL */
87 extern int ftpisopen();
94 extern CKFLOAT floatval; /* (see isfloat()) */
100 char editor[CKMAXPATH + 1] = "edit";
102 char editor[CKMAXPATH + 1] = { NUL, NUL };
104 char editopts[128] = { NUL, NUL };
105 char editfile[CKMAXPATH + 1] = { NUL, NUL };
107 char browser[CKMAXPATH + 1] = { NUL, NUL };
108 char browsopts[128] = { NUL, NUL };
109 char browsurl[4096] = { NUL, NUL };
111 #endif /* NOFRILLS */
116 _PROTOTYP(int setrename, (void));
117 #endif /* NORENAME */
118 #endif /* NOFRILLS */
124 extern int hints, xcmdsrc;
127 char * k4pwprompt = NULL; /* Kerberos 4 password prompt */
128 char * k4prprompt = NULL; /* Kerberos 4 principal prompt */
129 char * k5pwprompt = NULL; /* Kerberos 5 password prompt */
130 char * k5prprompt = NULL; /* Kerberos 5 principal prompt */
131 #endif /* CK_KERBEROS */
133 char * srppwprompt = NULL;
136 extern char * ckprompt, * ikprompt; /* Default prompt */
137 extern xx_strp xxstring;
139 extern char * cdmsgfile[], * cdmsgstr;
142 local, server, success, dest, sleepcan, inserver, flow, autoflow, binary,
143 parity, escape, what, turn, duplex, backgrd, hwparity, stopbits, turnch,
144 mdmtyp, network, quiet, nettype, carrier, debses, debtim, cdtimo, nlangs,
145 bgset, pflag, msgflg, cmdmsk, xsuspend, techo, pacing, xitwarn, xitsta,
146 outesc, cmd_cols, cmd_rows, ckxech, xaskmore, haveline, didsetlin, isguest,
147 mdmsav, clearrq, saveask, debmsg;
149 extern int reliable, setreliable, matchdot, matchfifo, dir_dots;
153 #endif /* NOSERVER */
157 #endif /* IKSDCONF */
160 #endif /* TCPSOCKET */
162 char * tn_pr_uid = NULL;
164 extern int exitonclose;
168 extern struct keytab kverbs[];
169 #endif /* NOKVERBS */
171 extern int ttnproto; /* Network protocol */
173 extern char *ccntab[]; /* Names of control chars */
176 extern int apcactive, apcstatus;
180 extern int secho; /* Whether SCRIPT cmd should echo */
181 #endif /* NOSCRIPT */
184 extern char *atmbuf, *atxbuf;
186 extern char atmbuf[], atxbuf[];
191 extern char uidbuf[];
192 extern int sl_uid_saved;
193 int DeleteStartupFile = 0;
195 extern int cmdlvl; /* Overall command level */
198 _PROTOTYP( static int parsdir, (int) );
199 char prmbuf[PWBUFL+1] = { NUL, NUL };
200 int fndiags = 1; /* Function diagnostics on/off */
201 int fnerror = 1; /* Function error treatment */
204 extern int *count, *takerr, *merror, *inpcas;
206 extern int count[], takerr[], merror[], inpcas[];
208 extern int mecho; /* Macro echo */
209 extern long ck_alarm;
210 extern char alrm_date[], alrm_time[];
216 extern int bigsbsiz, bigrbsiz; /* Packet buffers */
218 extern long speed; /* Terminal speed */
220 extern char ttname[]; /* Communication device name */
221 extern char myhost[] ;
222 extern char inidir[]; /* Ini File directory */
225 extern KEY *keymap; /* Character map for SET KEY (1:1) */
226 extern MACRO *macrotab; /* Macro map for SET KEY (1:string) */
227 #endif /* NOSETKEY */
229 int wideresult; /* For wide OS/2 scan codes/cmnum() */
234 extern int tt_scrsize[]; /* Scrollback buffer Sizes */
238 /* Printer settings */
240 extern char * printername; /* NULL if printer not redirected */
241 extern int printpipe;
242 extern int noprinter;
245 char * printterm = NULL;
246 char * printsep = NULL;
249 int printbidi = 0; /* SET BPRINTER (bidirectional) */
250 long pportspeed = 0L; /* Bidirection printer port speed, */
251 int pportparity = 0; /* parity, */
252 int pportflow = FLO_KEEP; /* and flow control */
255 extern int txt2ps; /* Text2PS conversion? */
256 extern int ps_width, ps_length; /* Text2PS dimensions */
258 #endif /* PRINTSWI */
261 extern int tcp_avail; /* Nonzero if TCP/IP is available */
263 extern int dnet_avail; /* Ditto for DECnet */
266 extern int slat_avail;
267 #endif /* SUPERLAT */
270 static struct keytab logintab[] = {
271 { "password", LOGI_PSW, CM_INV },
272 { "prompt", LOGI_PRM, CM_INV },
273 { "userid", LOGI_UID, 0 }
277 /* system-independent character sets, defined in ckcxla.[ch] */
278 extern struct csinfo tcsinfo[];
279 extern struct langinfo langs[];
281 /* Other character-set related variables */
282 extern int tcharset, tslevel, language;
285 /* File-transfer variable declarations */
290 #endif /* CK_AUTODL */
294 extern char * getpath[];
295 #endif /* NOSERVER */
297 extern struct ck_p ptab[];
299 extern CHAR sstate; /* Protocol start state */
300 extern CHAR myctlq; /* Control-character prefix */
301 extern CHAR myrptq; /* Repeat-count prefix */
303 extern int protocol, size, spsiz, spmax, urpsiz, srvtim, srvcdmsg, slostart,
304 srvdis, xfermode, ckdelay, keep, maxtry, unkcs, bctr, bctf, ebqflg, swcapr,
305 wslotr, lscapr, lscapu, spsizr, rptena, rptmin, docrc, xfrcan, xfrchr,
306 xfrnum, xfrbel, xfrint, srvping, g_xfermode, xfrxla;
310 #endif /* PIPESEND */
312 #ifdef CKXXCHAR /* DOUBLE / IGNORE char table */
313 extern int dblflag, ignflag, dblchar;
315 #endif /* CKXXCHAR */
318 extern short ctlp[]; /* Control-prefix table */
319 extern int prefixing;
320 static struct keytab pfxtab[] = {
322 "cautious", PX_CAU, 0,
323 "minimal", PX_WIL, 0,
326 #endif /* CK_SPEED */
329 /* Declarations from cmd package */
332 extern char *cmdbuf; /* Command buffer */
336 extern char cmdbuf[]; /* Command buffer */
337 extern char line[]; /* Character buffer for anything */
338 extern char tmpbuf[];
341 /* From main ckuser module... */
343 extern char *tp, *lp; /* Temporary buffer */
345 extern int tlevel; /* Take Command file level */
348 extern int sessft; /* Session-log file type */
349 extern int slogts; /* Session-log timestamps on/off */
350 extern int slognul; /* Lines null-terminated */
353 char * tempdir = NULL;
356 int vms_msgs = 1; /* SET MESSAGES */
360 /* Keyword tables for SET commands */
363 struct keytab ctltab[] = {
364 "prefixed", 1, 0, /* Note, the values are important. */
367 #endif /* CK_SPEED */
369 static struct keytab oldnew[] = {
376 struct keytab matchtab[] = {
377 { "dotfile", MCH_DOTF, 0 },
378 { "fifo", MCH_FIFO, 0 }
380 int nmatchtab = (sizeof(matchtab) / sizeof(struct keytab));
383 static struct keytab functab[] = {
384 "diagnostics", FUNC_DI, 0,
387 static int nfunctab = (sizeof(functab) / sizeof(struct keytab));
389 struct keytab outptab[] = { /* SET OUTPUT parameters */
390 "pacing", 0, 0, /* only one so far... */
391 "special-escapes", 1, 0
393 int noutptab = (sizeof(outptab) / sizeof(struct keytab)); /* How many */
396 struct keytab chktab[] = { /* Block check types */
397 "1", 1, 0, /* 1 = 6-bit checksum */
398 "2", 2, 0, /* 2 = 12-bit checksum */
399 "3", 3, 0, /* 3 = 16-bit CRC */
400 "4", 4, 0, /* Same as B */
401 "5", 5, 0, /* Same as F */
402 "blank-free-2", 4, CM_INV, /* B = 12-bit checksum, no blanks */
403 "force-3", 5, CM_INV /* F = Force CRC on ALL packets */
405 static int nchkt = (sizeof(chktab) / sizeof(struct keytab));
407 struct keytab rpttab[] = { /* SET REPEAT */
408 "counts", 0, 0, /* On or Off */
410 "minimum", 1, 0, /* Threshhold */
412 "prefix", 2, 0 /* Repeat-prefix character value */
416 /* For SET [ MODEM ] CARRIER, and also for SET DIAL CONNECT */
418 struct keytab crrtab[] = {
419 "automatic", CAR_AUT, 0, /* 2 */
420 "off", CAR_OFF, 0, /* 0 */
421 "on", CAR_ON, 0 /* 1 */
426 struct keytab ooatab[] = { /* On/Off/Auto table */
427 "automatic", SET_AUTO, 0, /* 2 */
428 "off", SET_OFF, 0, /* 0 */
429 "on", SET_ON, 0 /* 1 */
432 struct keytab ooetab[] = { /* On/Off/Stderr table 2010/03/12 */
433 "off", SET_OFF, 0, /* for SET DEBUG MESSAGES */
435 "s", 2, CM_ABR|CM_INV,
436 "st", 2, CM_ABR|CM_INV,
437 "std", 2, CM_ABR|CM_INV,
439 "stdout", SET_ON, CM_INV
441 static int nooetab = (sizeof(ooetab) / sizeof(struct keytab));
443 struct keytab ooktab[] = { /* On/Off/Ask table */
445 "off", SET_OFF, 0, /* 0 */
446 "on", SET_ON, 0 /* 1 */
449 struct keytab qvtab[] = { /* Quiet/Verbose table */
464 struct keytab dbgtab[] = {
465 "linelength", DEB_LEN, CM_INV,
466 "m", DEB_MSG, CM_ABR|CM_INV,
467 "message", DEB_MSG, 0,
468 "msg", DEB_MSG, CM_INV,
471 "session", DEB_SES, 0,
472 "timestamps", DEB_TIM, 0
474 int ndbg = (sizeof(dbgtab) / sizeof(struct keytab));
477 /* Transmission speeds */
479 #ifdef TTSPDLIST /* Speed table constructed at runtime . . . */
481 struct keytab * spdtab = NULL;
486 Note, the values are encoded in cps rather than bps because 19200 and higher
487 are too big for some ints. All but 75bps are multiples of ten. Result of
488 lookup in this table must be multiplied by 10 to get actual speed in bps.
489 If this number is 70, it must be changed to 75. If it is 888, this means
492 The values are generic, rather than specific to UNIX. We can't use B75,
493 B1200, B9600, etc, because non-UNIX versions of C-Kermit will not
494 necessarily have these symbols defined. The BPS_xxx symbols are
495 Kermit-specific, and are defined in ckcdeb.h or on the CC command line.
497 Like all other keytabs, this one must be in "alphabetical" order,
498 rather than numeric order.
500 struct keytab spdtab[] = {
505 #endif /* BPS_115K */
527 #endif /* BPS_230K */
535 #endif /* BPS_3600 */
540 "460800", 46080, 0, /* Need 32 bits for this... */
541 #endif /* BPS_460K */
552 #endif /* BPS_7200 */
557 "75/1200",888, 0, /* Code "888" for split speed */
558 #endif /* BPS_7512 */
563 "921600", 92160,0, /* Need 32 bits for this... */
564 #endif /* BPS_921K */
567 int nspd = (sizeof(spdtab) / sizeof(struct keytab)); /* How many speeds */
568 #endif /* TTSPDLIST */
571 struct keytab tnspdtab[] = { /* RFC 2217 TELNET COMPORT Option */
572 "115200", 11520, 0, /* (add any other defined speeds) */
587 int ntnspd = (sizeof(tnspdtab) / sizeof(struct keytab)); /* How many speeds */
588 #endif /* TN_COMPORT */
592 extern struct keytab lngtab[]; /* Languages for SET LANGUAGE */
597 /* Duplex keyword table */
599 struct keytab dpxtab[] = {
607 struct keytab cxtypesw[] = {
609 "/decnet", CXT_DECNET, 0,
611 "/direct-serial", CXT_DIRECT, 0,
617 #endif /* SUPERLAT */
619 "/modem", CXT_MODEM, 0,
621 "/named-pipe", CXT_NPIPE, 0,
624 "/netbios", CXT_NETBIOS, 0,
626 "/remote", CXT_REMOTE, 0,
628 "/tcpip", CXT_TCPIP, 0,
629 #endif /* TCPSOCKET */
635 int ncxtypesw = (sizeof(cxtypesw) / sizeof(struct keytab));
638 struct keytab tnflotab[] = { /* SET FLOW-CONTROL keyword table */
639 "dtr/cd", FLO_DTRC, 0, /* for RFC 2217 Telnet COMPORT */
640 "dtr/cts", FLO_DTRT, 0,
643 "rts/cts", FLO_RTSC, 0,
644 "xon/xoff", FLO_XONX, 0
646 int ntnflo = (sizeof(tnflotab) / sizeof(struct keytab));
647 #endif /* TN_COMPORT */
649 struct keytab flotab[] = { /* SET FLOW-CONTROL keyword table */
650 "automatic", FLO_AUTO, CM_INV, /* Not needed any more */
652 "dtr/cd", FLO_DTRC, 0,
653 #endif /* CK_DTRCD */
655 "dtr/cts", FLO_DTRT, 0,
656 #endif /* CK_DTRCTS */
660 "rts/cts", FLO_RTSC, 0,
661 #endif /* CK_RTSCTS */
663 "xon/xoff", FLO_XONX, 0,
667 int nflo = (sizeof(flotab) / sizeof(struct keytab)) - 1;
669 /* Handshake characters */
671 struct keytab hshtab[] = {
677 "none", 999, 0, /* (can't use negative numbers) */
681 int nhsh = (sizeof(hshtab) / sizeof(struct keytab));
684 static struct keytab sfttab[] = { /* File types for SET SESSION-LOG */
685 "ascii", XYFT_T, CM_INV,
688 "null-padded-lines", 998, 0,
690 "timestamped-text", 999, 0
692 static int nsfttab = (sizeof(sfttab) / sizeof(struct keytab));
697 #ifdef NETCONN /* Networks directory depends */
698 int nnetdir = 0; /* on DIAL code -- fix later... */
699 char *netdir[MAXDDIR+2];
702 _PROTOTYP( static int setdial, (int) );
703 _PROTOTYP( static int setdcd, (void) );
704 _PROTOTYP( static int cklogin, (void) );
708 extern int tbmodel; /* Telebit model ID */
709 #endif /* OLDTBCODE */
710 #endif /* MINIDIAL */
712 extern MDMINF *modemp[]; /* Pointers to modem info structs */
713 extern struct keytab mdmtab[]; /* Modem types (in module ckudia.c) */
714 extern int nmdm; /* Number of them */
716 _PROTOTYP(static int dialstr,(char **, char *));
718 extern int dialhng, dialtmo, dialksp, dialdpy, dialmhu, dialec, dialdc;
719 extern int dialrtr, dialint, dialudt, dialsrt, dialrstr, mdmwaitd;
720 extern int mdmspd, dialfc, dialmth, dialesc, dialfld, dialidt, dialpace;
721 extern int mdmspk, mdmvol, dialtest;
723 int dialcvt = 2; /* DIAL CONVERT-DIRECTORY */
724 int dialcnf = 0; /* DIAL CONFIRMATION */
725 int dialcon = 2; /* DIAL CONNECT */
726 int dialcq = 0; /* DIAL CONNECT AUTO quiet/verbose */
727 extern long dialmax, dialcapas;
730 extern char *dialini, *dialmstr, *dialmprmt, *dialdir[], *dialcmd, *dialnpr,
731 *dialdcon, *dialdcoff, *dialecon, *dialecoff, *dialhcmd, *dialx3,
732 *dialhwfc, *dialswfc, *dialnofc, *dialtone, *dialpulse, *dialname, *diallac;
733 extern char *diallcc, *dialixp, *dialixs, *dialldp, *diallds, *dialtfp,
734 *dialpxi, *dialpxo, *dialsfx, *dialaaon, *dialaaoff;
735 extern char *diallcp, *diallcs, *dialini2, *dialmac;
736 extern char *dialspoff, *dialspon, *dialvol1, *dialvol2, *dialvol3;
738 char *dialtocc[MAXTPCC] = { NULL, NULL };
740 char *dialpucc[MAXTPCC] = { NULL, NULL };
743 char *dialtfc[MAXTOLLFREE] = {
744 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
748 char *dialpxx[MAXPBXEXCH] = {
749 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
753 char *diallcac[MAXLOCALAC] = {
754 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
755 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
756 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
757 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
761 static struct keytab drstrtab[] = {
762 "international", 5, 0,
764 "long-distance", 4, 0,
768 static struct keytab dcnvtab[] = {
774 struct keytab setmdm[] = {
775 "capabilities", XYDCAP, 0,
776 "carrier-watch", XYDMCD, 0,
777 "command", XYDSTR, 0,
778 "compression", XYDDC, CM_INV,
779 "data-compression", XYDDC, 0,
780 "dial-command", XYDDIA, 0,
781 "error-correction", XYDEC, 0,
782 "escape-character", XYDESC, 0,
783 "flow-control", XYDFC, 0,
784 "hangup-method", XYDMHU, 0,
786 "kermit-spoof", XYDKSP, 0,
788 "maximum-speed", XYDMAX, 0,
790 "speaker", XYDSPK, 0,
791 "speed-matching", XYDSPD, 0,
795 int nsetmdm = (sizeof(setmdm) / sizeof(struct keytab));
797 struct keytab voltab[] = {
803 struct keytab mdmcap[] = {
804 "at-commands", CKD_AT, 0,
805 "compression", CKD_DC, 0,
806 "dc", CKD_DC, CM_INV,
807 "ec", CKD_EC, CM_INV,
808 "error-correction", CKD_EC, 0,
809 "hardware-flow", CKD_HW, 0,
810 "hwfc", CKD_HW, CM_INV,
811 "itu", CKD_V25, CM_INV,
812 "kermit-spoof", CKD_KS, 0,
813 "ks", CKD_KS, CM_INV,
814 "sb", CKD_SB, CM_INV,
815 "software-flow", CKD_SW, 0,
816 "speed-buffering", CKD_SB, 0,
817 "swfc", CKD_SW, CM_INV,
818 "tb", CKD_TB, CM_INV,
819 "telebit", CKD_TB, 0,
820 "v25bis-commands", CKD_V25, 0
822 int nmdmcap = (sizeof(mdmcap) / sizeof(struct keytab));
824 #ifdef COMMENT /* SET ANSWER not implemented yet */
825 static struct keytab answertab[] = {
826 { "caller-id", XYA_CID, 0 };
827 { "rings", XYA_RNG, 0 };
830 static int nanswertab = (sizeof(answertab) / sizeof(struct keytab)) - 1;
833 struct keytab dialtab[] = { /* SET DIAL table */
834 "area-code", XYDLAC, 0, /* Also still includes items */
835 "compression", XYDDC, CM_INV, /* that were moved to SET MODEM, */
836 "confirmation", XYDCNF, 0, /* but they are CM_INVisible... */
837 "connect", XYDCON, 0,
838 "convert-directory",XYDCVT, 0,
839 "country-code", XYDLCC, 0,
840 "dial-command", XYDDIA, CM_INV,
841 "directory", XYDDIR, 0,
842 "display", XYDDPY, 0,
843 "escape-character", XYDESC, CM_INV,
844 "error-correction", XYDEC, CM_INV,
845 "flow-control", XYDFC, CM_INV,
846 "force-long-distance", XYDFLD, 0,
848 "ignore-dialtone", XYDIDT, 0,
849 "interval", XYDINT, 0,
850 "in", XYDINI, CM_INV|CM_ABR,
851 "init-string", XYDINI, CM_INV,
852 "intl-prefix", XYDIXP, 0,
853 "intl-suffix", XYDIXS, 0,
855 "kermit-spoof", XYDKSP, CM_INV,
857 "lc-area-codes", XYDLLAC, 0,
858 "lc-prefix", XYDLCP, 0,
859 "lc-suffix", XYDLCS, 0,
860 "ld-prefix", XYDLDP, 0,
861 "ld-suffix", XYDLDS, 0,
862 "local-area-code", XYDLAC, CM_INV,
863 "local-prefix", XYDLCP, CM_INV,
864 "local-suffix", XYDLCS, CM_INV,
865 "m", XYDMTH, CM_INV|CM_ABR,
867 "macro", XYDMAC, 0, /* 195 */
870 "me", XYDMTH, CM_INV|CM_ABR,
873 "mnp-enable", XYDMNP, CM_INV, /* obsolete but still accepted */
875 "modem-hangup", XYDMHU, CM_INV,
878 "pbx-exchange", XYDPXX, 0,
879 "pbx-inside-prefix",XYDPXI, 0,
880 "pbx-outside-prefix",XYDPXO, 0,
882 "pulse-countries", XYDPUCC, 0,
883 "restrict", XYDRSTR, 0,
884 "retries", XYDRTM, 0,
886 "speed-matching", XYDSPD, CM_INV,
887 "string", XYDSTR, CM_INV,
890 "timeout", XYDTMO, 0,
891 "tf-area-code", XYDTFC, CM_INV,
892 "tf-prefix", XYDTFP, CM_INV,
893 "toll-free-area-code",XYDTFC,0,
894 "toll-free-prefix", XYDTFP, 0,
895 "tone-countries", XYDTOCC, 0
897 int ndial = (sizeof(dialtab) / sizeof(struct keytab));
900 struct keytab mdmhang[] = {
902 "modem-command", 1, 0,
903 "rs232-signal", 0, 0,
904 "v24-signal", 0, CM_INV
908 static struct keytab mdmcmd[] = {
909 "autoanswer", XYDS_AN, 0, /* autoanswer */
910 "compression", XYDS_DC, 0, /* data compression */
911 "dial-mode-prompt", XYDS_MP, 0, /* dial mode prompt */
912 "dial-mode-string", XYDS_MS, 0, /* dial mode string */
913 "error-correction", XYDS_EC, 0, /* error correction */
914 "hangup-command", XYDS_HU, 0, /* hangup command */
915 "hardware-flow", XYDS_HW, 0, /* hwfc */
916 "ignore-dialtone", XYDS_ID, 0, /* ignore dialtone */
917 "init-string", XYDS_IN, 0, /* init string */
918 "no-flow-control", XYDS_NF, 0, /* no flow control */
919 "predial-init", XYDS_I2, 0, /* last-minute setup commands */
920 "pulse", XYDS_DP, 0, /* pulse */
921 "software-flow", XYDS_SW, 0, /* swfc */
922 "speaker", XYDS_SP, 0, /* Speaker */
923 "tone", XYDS_DT, 0, /* tone */
924 "volume", XYDS_VO, 0 /* Volume */
926 static int nmdmcmd = (sizeof(mdmcmd) / sizeof(struct keytab));
928 struct keytab dial_fc[] = {
931 "rts/cts", FLO_RTSC, 0,
932 "xon/xoff", FLO_XONX, 0
935 struct keytab dial_m[] = { /* DIAL METHOD */
937 "default", XYDM_D, 0,
941 int ndial_m = (sizeof(dial_m)/sizeof(struct keytab));
945 struct keytab tapitab[] = { /* Top-Level Microsoft TAPI */
946 "configure-line", XYTAPI_CFG, 0,
947 "dialing-properties", XYTAPI_DIAL, 0
949 int ntapitab = (sizeof(tapitab)/sizeof(struct keytab));
951 struct keytab settapitab[] = { /* SET Microsoft TAPI */
952 "inactivity-timeout", XYTAPI_INA, 0,
953 "line", XYTAPI_LIN, 0,
954 "location", XYTAPI_LOC, 0,
955 "manual-dialing", XYTAPI_MAN, 0,
956 "modem-dialing", XYTAPI_PASS, 0,
957 "modem-lights", XYTAPI_LGHT, 0,
958 "phone-number-conversions", XYTAPI_CON, 0,
959 "port", XYTAPI_LIN, CM_INV,
960 "post-dial-terminal", XYTAPI_PST, 0,
961 "pre-dial-terminal", XYTAPI_PRE, 0,
962 "use-windows-configuration", XYTAPI_USE, 0,
963 "wait-for-credit-card-tone", XYTAPI_BNG, 0
965 int nsettapitab = (sizeof(settapitab)/sizeof(struct keytab));
967 struct keytab * tapiloctab = NULL; /* Microsoft TAPI Locations */
969 extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
970 extern int ntapiline;
971 extern int tttapi; /* TAPI in use */
972 extern int tapipass; /* TAPI Passthrough mode */
973 extern int tapiconv; /* TAPI Conversion mode */
974 extern int tapilights;
975 extern int tapipreterm;
976 extern int tapipostterm;
977 extern int tapimanual;
978 extern int tapiinactivity;
980 extern int tapiusecfg;
987 struct keytab wildtab[] = { /* SET WILDCARD-EXPANSION */
989 "kermit", WILD_KER, 0, /* By Kermit */
991 "off", WILD_OFF, 0, /* Disabled */
992 "on", WILD_ON, 0, /* Enabled */
994 "shell", WILD_SHE, 0, /* By Shell */
998 int nwild = (sizeof(wildtab) / sizeof(struct keytab)) - 1;
1000 struct keytab wdottab[] = { /* cont'd */
1001 "/match-dot-files", 1, 0,
1002 "/no-match-dot-files", 0, 0
1004 extern int wildxpand;
1009 extern struct keytab netcmd[], netkey[];
1010 extern int nnets, nnetkey;
1012 extern struct keytab tcpopt[];
1014 #endif /* TCPSOCKET */
1016 char pipename[PIPENAML+1] = { NUL, NUL };
1019 extern unsigned char NetBiosName[];
1020 #endif /* CK_NETBIOS */
1021 #endif /* NETCONN */
1024 struct keytab x25tab[] = {
1025 "call-user-data", XYUDAT, 0,
1026 "closed-user-group", XYCLOS, 0,
1027 "reverse-charge", XYREVC, 0
1029 int nx25 = (sizeof(x25tab) / sizeof(struct keytab));
1032 struct keytab padx3tab[] = {
1033 "break-action", PAD_BREAK_ACTION, 0,
1034 "break-character", PAD_BREAK_CHARACTER, 0,
1035 "character-delete", PAD_CHAR_DELETE_CHAR, 0,
1036 "cr-padding", PAD_PADDING_AFTER_CR, 0,
1037 "discard-output", PAD_SUPPRESSION_OF_DATA, 0,
1038 "echo", PAD_ECHO, 0,
1039 "editing", PAD_EDITING, 0,
1040 "escape", PAD_ESCAPE, 0,
1041 "forward", PAD_DATA_FORWARD_CHAR, 0,
1042 "lf-padding", PAD_PADDING_AFTER_LF, 0,
1043 "lf-insert", PAD_LF_AFTER_CR, 0,
1044 "line-delete", PAD_BUFFER_DELETE_CHAR, 0,
1045 "line-display", PAD_BUFFER_DISPLAY_CHAR, 0,
1046 "line-fold", PAD_LINE_FOLDING, 0,
1047 "pad-flow-control", PAD_FLOW_CONTROL_BY_PAD, 0,
1048 "service-signals", PAD_SUPPRESSION_OF_SIGNALS, 0,
1049 "timeout", PAD_DATA_FORWARD_TIMEOUT, 0,
1050 /* Speed is read-only */
1051 "transmission-rate", PAD_LINE_SPEED, 0,
1052 "user-flow-control", PAD_FLOW_CONTROL_BY_USER, 0
1054 int npadx3 = (sizeof(padx3tab) / sizeof(struct keytab));
1059 static struct keytab vbtab[] = {
1066 #endif /* def VMS */
1067 #endif /* OS2ORUNIX */
1070 int nvb = (sizeof(vbtab) / sizeof(struct keytab));
1074 static struct keytab syslogtab[] = {
1076 "commands", SYSLG_CM, 0,
1077 "connection", SYSLG_AC, 0,
1078 "debug", SYSLG_DB, 0,
1079 "dial", SYSLG_DI, 0,
1080 "file-access", SYSLG_FA, 0,
1081 "file-create", SYSLG_FC, 0,
1082 "login", SYSLG_LI, 0,
1083 "none", SYSLG_NO, 0,
1084 "protocol", SYSLG_PR, 0
1086 int nsyslog = (sizeof(syslogtab) / sizeof(struct keytab));
1087 #endif /* CKSYSLOG */
1089 /* Parity keyword table */
1091 struct keytab partbl[] = {
1095 #endif /* HWPARITY */
1101 int npar = (sizeof(partbl) / sizeof(struct keytab));
1104 struct keytab hwpartbl[] = {
1105 /* Add mark and space if needed and possible */
1116 int nhwpar = (sizeof(hwpartbl) / sizeof(struct keytab)) - 1;
1117 #endif /* HWPARITY */
1121 struct keytab onoff[] = {
1126 #define XYCD_M 0 /* CD MESSAGE */
1127 #define XYCD_P 1 /* CD PATH */
1128 #define XYCD_H 2 /* CD HOME */
1130 struct keytab cdtab[] = {
1132 "message", XYCD_M, 0,
1135 int ncdtab = (sizeof(cdtab) / sizeof(struct keytab));
1137 struct keytab cdmsg[] = {
1142 int ncdmsg = (sizeof(cdmsg) / sizeof(struct keytab));
1145 struct keytab xittab[] = { /* SET EXIT */
1146 "hangup", 3, 0, /* ...HANGUP */
1147 "on-disconnect", 2, 0, /* ...ON-DISCONNECT */
1148 "status", 0, 0, /* ...STATUS */
1149 "warning", 1, 0 /* ...WARNING */
1151 int nexit = (sizeof(xittab) / sizeof(struct keytab));
1153 struct keytab xitwtab[] = { /* SET EXIT WARNING */
1154 "always", 2, 0, /* even when not connected */
1155 "off", 0, 0, /* no warning */
1156 "on", 1, 0 /* when connected */
1158 int nexitw = (sizeof(xitwtab) / sizeof(struct keytab));
1160 struct keytab rltab[] = {
1161 "local", 1, 0, /* ECHO values */
1166 int nrlt = (sizeof(rltab) / sizeof(struct keytab));
1168 /* Incomplete File Disposition table */
1170 struct keytab ifdtab[] = {
1171 "discard", SET_OFF, 0,
1175 struct keytab ifdatab[] = {
1176 "auto", SET_AUTO, 0,
1177 "discard", SET_OFF, 0,
1181 char * ifdnam[] = { "discard", "keep", "auto" };
1183 /* SET TAKE parameters table */
1185 struct keytab taktab[] = {
1188 "off", 2, CM_INV, /* For compatibility */
1189 "on", 3, CM_INV /* with MS-DOS Kermit... */
1196 struct keytab suftab[] = { /* (what to do with) STARTUP-FILE */
1200 #endif /* COMMENT */
1202 /* SET MACRO parameters table */
1204 struct keytab smactab[] = {
1212 struct keytab scrtab[] = {
1215 #endif /* NOSCRIPT */
1217 /* SET COMMAND table */
1219 /* SET COMMAND items... */
1221 #define SCMD_BSZ 0 /* BYTESIZE */
1222 #define SCMD_RCL 1 /* RECALL */
1223 #define SCMD_RTR 2 /* RETRY */
1224 #define SCMD_QUO 3 /* QUOTING */
1225 #define SCMD_COL 4 /* COLOR */
1226 #define SCMD_HIG 5 /* HEIGHT */
1227 #define SCMD_WID 6 /* WIDTH */
1228 #define SCMD_CUR 7 /* CURSOR-POSITION */
1229 #define SCMD_SCR 8 /* SCROLLBACK */
1230 #define SCMD_MOR 9 /* MORE-PROMPTING */
1231 #define SCMD_INT 10 /* INTERRUPTION */
1232 #define SCMD_ADL 11 /* AUTODOWNLOAD */
1233 #define SCMD_STA 12 /* STATUSLINE */
1234 #define SCMD_DBQ 13 /* DOUBLEQUOTING */
1235 #define SCMD_CBR 14 /* CBREAK */
1236 #define SCMD_BFL 15 /* BUFFER-SIZE (not used) */
1237 #define SCMD_ERR 16 /* ERROR */
1238 #define SCMD_VAR 17 /* VARIABLE-EVALUATION */
1240 static struct keytab scmdtab[] = {
1242 "autodownload", SCMD_ADL, 0,
1243 #endif /* CK_AUTODL */
1246 To implement this requires that we change CMDBL and ATMBL
1247 from compile-time symbols to runtime variables. Not a big deal,
1248 but not trivial either.
1250 "buffer-size", SCMD_BFL, 0,
1251 #endif /* COMMENT */
1252 "bytesize", SCMD_BSZ, 0,
1253 "cbreak", SCMD_CBR, CM_INV,
1255 "color", SCMD_COL, 0,
1256 "cursor-position", SCMD_CUR, 0,
1258 #ifdef DOUBLEQUOTING
1259 "doublequoting", SCMD_DBQ, 0,
1260 #endif /* DOUBLEQUOTING */
1261 "error-display", SCMD_ERR, 0,
1262 "height", SCMD_HIG, 0,
1263 "interruption", SCMD_INT, 0,
1264 "more-prompting", SCMD_MOR, 0,
1265 "quoting", SCMD_QUO, 0,
1267 "recall-buffer-size", SCMD_RCL, 0,
1268 #endif /* CK_RECALL */
1270 "retry", SCMD_RTR, 0,
1271 #endif /* CK_RECALL */
1274 "scrollback", SCMD_SCR, 0,
1275 "statusline", SCMD_STA, 0,
1276 #endif /* ONETERMUPD */
1278 "variable-evaluation", SCMD_VAR,0,
1279 "width", SCMD_WID, 0
1281 static int nbytt = (sizeof(scmdtab) / sizeof(struct keytab));
1284 /* Server parameters table */
1285 static struct keytab srvtab[] = {
1286 "cd-message", XYSERC, 0,
1287 "display", XYSERD, 0,
1288 "get-path", XYSERP, 0,
1289 "idle-timeout", XYSERI, 0,
1290 "keepalive", XYSERK, 0,
1292 "timeout", XYSERT, 0
1294 static int nsrvt = (sizeof(srvtab) / sizeof(struct keytab));
1295 #endif /* NOSERVER */
1297 static struct keytab sleeptab[] = { /* SET SLEEP table */
1298 "cancellation", 0, 0
1301 static struct keytab tstab[] = { /* SET TRANSFER/XFER table */
1304 "cancellation", XYX_CAN, 0,
1307 "character-set", XYX_CSE, 0,
1308 #endif /* NOCSETS */
1310 "crc-calculation", XYX_CRC, 0,
1312 "display", XYX_DIS, 0,
1313 "interruption", XYX_INT, 0,
1314 "locking-shift", XYX_LSH, 0,
1315 "message", XYX_MSG, 0,
1317 "msg", XYX_MSG, CM_INV,
1319 "pipes", XYX_PIP, 0,
1320 #endif /* PIPESEND */
1322 "protocol", XYX_PRO, 0,
1324 "report", XYX_RPT, 0,
1325 "slow-start", XYX_SLO, 0,
1327 "translation", XYX_XLA, 0,
1329 "translation", XYX_XLA, CM_INV,
1330 #endif /* NOCSETS */
1331 "xlation", XYX_XLA, CM_INV,
1334 static int nts = (sizeof(tstab) / sizeof(struct keytab)) - 1;
1336 static struct keytab rtstab[] = { /* REMOTE SET TRANSFER/XFER table */
1338 "character-set", XYX_CSE, 0,
1339 #endif /* NOCSETS */
1342 static int nrts = (sizeof(rtstab) / sizeof(struct keytab));
1344 struct keytab xfrmtab[] = { /* TRANSFER MODE table */
1345 "automatic", XMODE_A, 0,
1346 "manual", XMODE_M, 0
1350 extern int locus, autolocus;
1352 static struct keytab locustab[] = {
1354 { "ask", 3, 0 }, /* Presently implemented in GUI only */
1360 static int nlocustab = (sizeof(locustab) / sizeof(struct keytab));
1365 /* SET TRANSFER CHARACTER-SET table */
1367 extern struct keytab tcstab[];
1369 #endif /* NOCSETS */
1371 /* SET TRANSFER LOCKING-SHIFT table */
1372 struct keytab lstab[] = {
1377 int nls = (sizeof(lstab) / sizeof(struct keytab));
1379 /* SET TELNET tables */
1381 extern int tn_nlm, tn_b_nlm, tn_b_meu, tn_b_ume, tn_b_xfer, tn_sb_bug;
1382 extern int tn_no_encrypt_xfer, tn_auth_krb5_des_bug;
1383 extern int tn_wait_flg, tn_duplex, tn_delay_sb, tn_sfu;
1384 extern int sl_tn_saved;
1385 extern int tn_infinite;
1386 extern int tn_rem_echo;
1388 extern int tn_auth_how;
1389 extern int tn_auth_enc;
1391 extern char * tn_fwdx_xauthority;
1392 #endif /* CK_FORWARD_X */
1393 #ifdef CK_AUTHENTICATION
1394 static struct keytab setauth[] = {
1396 "k4", AUTH_KRB4, CM_INV,
1397 "k5", AUTH_KRB5, CM_INV,
1398 "kerberos4", AUTH_KRB4, 0,
1399 "kerberos5", AUTH_KRB5, 0,
1400 "kerberos_iv",AUTH_KRB4, CM_INV,
1401 "kerberos_v", AUTH_KRB5, CM_INV,
1402 "krb4", AUTH_KRB4, CM_INV,
1403 "krb5", AUTH_KRB5, CM_INV,
1404 #endif /* CK_KERBEROS */
1414 static int nsetauth = sizeof(setauth)/sizeof(struct keytab) - 1;
1416 extern char * krb5_d_principal; /* Default principal */
1417 extern char * krb5_d_instance;
1418 extern char * krb5_d_realm; /* Default realm */
1419 extern char * krb5_d_cc; /* Default credentials cache */
1420 extern char * krb5_d_srv; /* Default service name */
1421 extern int krb5_d_lifetime; /* Default lifetime */
1422 extern int krb5_d_forwardable;
1423 extern int krb5_d_proxiable;
1424 extern int krb5_d_renewable;
1425 extern int krb5_autoget;
1426 extern int krb5_autodel;
1427 extern int krb5_d_getk4;
1428 extern int krb5_checkaddrs; /* Check TGT Addrs */
1429 extern int krb5_d_no_addresses;
1430 extern char * krb5_d_addrs[];
1431 extern char * k5_keytab; /* Keytab file */
1433 extern struct krb4_init_data krb4_init;
1434 extern char * krb4_d_principal; /* Default principal */
1435 extern char * krb4_d_realm; /* Default realm */
1436 extern char * krb4_d_srv; /* Default service name */
1437 extern int krb4_d_lifetime; /* Default lifetime */
1438 extern int krb4_d_preauth;
1439 extern char * krb4_d_instance;
1440 extern int krb4_autoget;
1441 extern int krb4_autodel;
1442 extern int krb4_checkaddrs; /* Check TGT Addrs */
1443 extern char * k4_keytab; /* Keytab file */
1447 static struct keytab krbver[] = {
1453 static int nkrbver = sizeof(krbver)/sizeof(struct keytab);
1455 static struct keytab kdestab[] = {
1456 "never", KRB_DEL_NO, 0,
1457 "no", KRB_DEL_NO, CM_INV,
1458 "on-close", KRB_DEL_CL, 0,
1459 "on-exit", KRB_DEL_EX, 0
1461 static int nkdestab = sizeof(kdestab)/sizeof(struct keytab);
1463 static struct keytab k4tab[] = {
1464 "autodel", XYKRBDEL, CM_INV,
1465 "autodestroy", XYKRBDEL, 0,
1466 "autoget", XYKRBGET, 0,
1467 "check-address", XYKRBADR, 0,
1468 "debug", XYKRBDBG, CM_INV,
1469 "instance", XYKRBINS, 0,
1470 "keytab", XYKRBKTB, 0,
1471 "lifetime", XYKRBLIF, 0,
1472 "preauth", XYKRBPRE, 0,
1473 "principal", XYKRBPR, 0,
1474 "prompt", XYKRBPRM, 0,
1475 "realm", XYKRBRL, 0,
1476 "service-name", XYKRBSRV, 0
1478 static int nk4tab = sizeof(k4tab)/sizeof(struct keytab);
1480 static struct keytab k5tab[] = {
1481 "addresses", XYKRBADD, 0,
1482 "autodelete", XYKRBDEL, CM_INV,
1483 "autodestroy", XYKRBDEL, 0,
1484 "autoget", XYKRBGET, 0,
1485 "cc", XYKRBCC, CM_INV,
1486 "check-address", XYKRBADR, 0,
1487 "credentials-cache", XYKRBCC, 0,
1488 "forwardable", XYKRBFWD, 0,
1489 "get-k4-tgt", XYKRBK5K4,0,
1490 "instance", XYKRBINS, 0,
1491 "keytab", XYKRBKTB, 0,
1492 "lifetime", XYKRBLIF, 0,
1493 "no-addresses", XYKRBNAD, 0,
1494 "principal", XYKRBPR, 0,
1495 "prompt", XYKRBPRM, 0,
1496 "proxiable", XYKRBPRX, 0,
1497 "realm", XYKRBRL, 0,
1498 "renewable", XYKRBRNW, 0,
1499 "service-name", XYKRBSRV, 0
1501 static int nk5tab = sizeof(k5tab)/sizeof(struct keytab);
1503 #define KRB_PW_PRM 1
1504 #define KRB_PR_PRM 2
1506 static struct keytab krbprmtab[] = {
1507 "password", KRB_PW_PRM, 0,
1508 "principal", KRB_PR_PRM, 0
1511 #endif /* CK_KERBEROS */
1513 static struct keytab srptab[] = {
1514 "prompt", XYSRPPRM, 0
1516 static int nsrptab = sizeof(srptab)/sizeof(struct keytab);
1517 #define SRP_PW_PRM 1
1519 static struct keytab srpprmtab[] = {
1520 "password", SRP_PW_PRM, 0
1524 static struct keytab ssltab[] = {
1525 "certs-ok", XYSSLCOK, CM_INV,
1526 "cipher-list", XYSSLCL, 0,
1527 "crl-dir", XYSSLCRLD, 0,
1528 "crl-file", XYSSLCRL, 0,
1529 "debug", XYSSLDBG, 0,
1530 "dh-key-file", XYSSLDKFL, CM_INV,
1531 "dh-param-file", XYSSLDPFL, 0,
1532 "dsa-cert-chain-file", XYSSLDCCF, 0,
1533 "dsa-cert-file", XYSSLDCFL, 0,
1534 "dsa-key-file", XYSSLDKFL, 0,
1535 "dummy", XYSSLDUM, CM_INV,
1536 "only", XYSSLON, CM_INV,
1537 "random-file", XYSSLRND, 0,
1538 "rsa-cert-chain-file", XYSSLRCCF, 0,
1539 "rsa-cert-file", XYSSLRCFL, 0,
1540 "rsa-key-file", XYSSLRKFL, 0,
1541 "verbose", XYSSLVRB, 0,
1542 "verify", XYSSLVRF, 0,
1543 "verify-dir", XYSSLVRFD, 0,
1544 "verify-file", XYSSLVRFF, 0
1546 static int nssltab = sizeof(ssltab)/sizeof(struct keytab);
1547 static struct keytab sslvertab[] = {
1548 "fail-if-no-peer-cert", SSL_VERIFY_PEER |
1549 SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0,
1550 "no", SSL_VERIFY_NONE, 0,
1551 "none", SSL_VERIFY_NONE, CM_INV,
1552 "off", SSL_VERIFY_NONE, CM_INV,
1553 "on", SSL_VERIFY_PEER, CM_INV,
1554 "peer-cert", SSL_VERIFY_PEER, 0
1556 static int nsslvertab = sizeof(sslvertab)/sizeof(struct keytab);
1558 #endif /* CK_AUTHENTICATION */
1559 #ifdef CK_ENCRYPTION
1560 int cx_type = CX_AUTO;
1561 extern int sl_cx_type;
1562 #endif /* CK_ENCRYPTION */
1563 extern char *tcp_address;
1565 extern char * tcp_http_proxy;
1566 extern char * tcp_http_proxy_user;
1567 extern char * tcp_http_proxy_pwd;
1568 extern char * tcp_http_proxy_agent;
1572 extern char *tcp_socks_svr;
1573 extern char *tcp_socks_user;
1575 extern char *tcp_socks_ns;
1576 #endif /* CK_SOCKS_NS */
1577 #endif /* CK_SOCKS */
1584 static struct keytab userpass[] = {
1585 { "/agent", UPW_AGENT, CM_ARG },
1586 { "/password", UPW_PASS, CM_ARG },
1587 { "/user", UPW_USER, CM_ARG },
1589 static int nuserpass = sizeof(userpass)/sizeof(struct keytab);
1591 static struct keytab tnnegtab[] = { /* TELNET NEGOTIATION table */
1592 "accepted", TN_NG_AC, 0,
1593 "refused", TN_NG_RF, 0,
1594 "req", TN_NG_RQ, CM_INV|CM_ABR,
1595 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1596 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1597 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1598 "request", TN_NG_RQ, CM_INV|CM_ABR,
1599 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1600 "requested", TN_NG_RQ, 0,
1601 "required", TN_NG_MU, 0
1603 static int ntnnegtab = sizeof(tnnegtab)/sizeof(struct keytab);
1605 #ifdef CK_ENCRYPTION
1606 static struct keytab typkwd[] = {
1610 static struct keytab tnenctab[] = { /* TELNET ENCRYPTION table */
1611 "accepted", TN_NG_AC, CM_INV,
1612 "refused", TN_NG_RF, CM_INV,
1613 "req", TN_NG_RQ, CM_INV|CM_ABR,
1614 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1615 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1616 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1617 "request", TN_NG_RQ, CM_INV|CM_ABR,
1618 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1619 "requested", TN_NG_RQ, CM_INV,
1620 "required", TN_NG_MU, CM_INV,
1621 "start", TN_EN_START, CM_INV,
1622 "stop", TN_EN_STOP, CM_INV,
1623 "type", TN_EN_TYP, 0
1625 static int ntnenc = sizeof(tnenctab)/sizeof(struct keytab) ;
1626 #endif /* CK_ENCRYPTION */
1629 static struct keytab tnfwdxtab[] = { /* TELNET FORWARD-X table */
1630 "no-encryption", 1, CM_INV,
1631 "xauthority-file", 0, 0
1633 static int ntnfwdx = sizeof(tnfwdxtab)/sizeof(struct keytab) ;
1634 #endif /* CK_FORWARD_X */
1636 static struct keytab tnbugtab[] = { /* TELNET BUG table */
1637 "auth-krb5-des", 4, 0,
1638 "binary-me-means-u-too", 0, 0,
1639 "binary-u-means-me-too", 1, 0,
1640 "infinite-loop-check", 2, 0,
1641 "sb-implies-will-do", 3, 0
1644 #ifdef CK_ENVIRONMENT
1645 static struct keytab tnenvtab[] = { /* TELNET ENVIRONMENT table */
1646 "acct", TN_ENV_ACCT, 0,
1647 "display", TN_ENV_DISP, 0,
1648 "job", TN_ENV_JOB, 0,
1649 "location", TN_ENV_LOC, 0,
1650 "off", TN_ENV_OFF, CM_INV,
1651 "on", TN_ENV_ON, CM_INV,
1652 "printer", TN_ENV_PRNT, 0,
1653 "systemtype",TN_ENV_SYS, 0,
1654 "user", TN_ENV_USR, 0,
1655 "uservar", TN_ENV_UVAR, 0,
1658 static int ntnenv = sizeof(tnenvtab)/sizeof(struct keytab) - 1;
1659 #endif /* CK_ENVIRONMENT */
1661 #ifdef CK_AUTHENTICATION
1662 static struct keytab tnauthtab[] = { /* TELNET AUTHENTICATION table */
1663 "accepted", TN_NG_AC, CM_INV,
1664 "encrypt-flag", TN_AU_ENC, 0,
1665 "forwarding", TN_AU_FWD, 0,
1666 "how-flag", TN_AU_HOW, 0,
1667 "refused", TN_NG_RF, CM_INV,
1668 "req", TN_NG_RQ, CM_INV|CM_ABR,
1669 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1670 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1671 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1672 "request", TN_NG_RQ, CM_INV|CM_ABR,
1673 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1674 "requested", TN_NG_RQ, CM_INV,
1675 "required", TN_NG_MU, CM_INV,
1676 "type", TN_AU_TYP, 0
1678 static int ntnauth = sizeof(tnauthtab)/sizeof(struct keytab) ;
1680 struct keytab autyptab[] = { /* TELNET AUTHENTICATION TYPE table */
1681 "automatic", AUTH_AUTO, 0,
1683 "k4", AUTH_KRB4, CM_INV,
1684 "k5", AUTH_KRB5, CM_INV,
1685 "kerberos4", AUTH_KRB4, 0,
1686 "kerberos5", AUTH_KRB5, 0,
1687 "kerberos_iv",AUTH_KRB4, CM_INV,
1688 "kerberos_v", AUTH_KRB5, CM_INV,
1689 "krb4", AUTH_KRB4, CM_INV,
1690 "krb5", AUTH_KRB5, CM_INV,
1691 #endif /* CK_KERBEROS */
1692 "none", AUTH_NONE, 0,
1694 "ntlm", AUTH_NTLM, 0,
1704 int nautyp = sizeof(autyptab)/sizeof(struct keytab) - 1;
1706 struct keytab auhowtab[] = { /* TELNET AUTHENTICATION HOW table */
1707 "any", TN_AUTH_HOW_ANY, 0,
1708 "mutual", TN_AUTH_HOW_MUTUAL, 0,
1709 "one-way", TN_AUTH_HOW_ONE_WAY, 0,
1712 int nauhow = sizeof(auhowtab)/sizeof(struct keytab) - 1;
1714 struct keytab auenctab[] = { /* TELNET AUTHENTICATION ENCRYPT table */
1715 "any", TN_AUTH_ENC_ANY, 0,
1716 "none", TN_AUTH_ENC_NONE, 0,
1717 "telopt", TN_AUTH_ENC_TELOPT, 0,
1719 "tls", TN_AUTH_ENC_TLS, 0,
1723 int nauenc = sizeof(auenctab)/sizeof(struct keytab) - 1;
1724 #endif /* CK_AUTHENTICATION */
1728 static struct keytab tn_nlmtab[] = { /* TELNET NEWLINE-MODE table */
1729 "binary-mode", TN_NL_BIN, 0, /* Binary mode */
1730 "nvt", TN_NL_NVT, 0, /* NVT mode */
1731 "off", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
1732 "on", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
1733 "raw", TNL_CR, CM_INV /* CR only (out of spec) */
1735 static int ntn_nlm = (sizeof(tn_nlmtab) / sizeof(struct keytab));
1737 static struct keytab tnlmtab[] = { /* TELNET NEWLINE-MODE table */
1738 "cr", TNL_CR, CM_INV, /* CR only (out of spec) */
1739 "cr-lf", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
1740 "cr-nul", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
1741 "lf", TNL_LF, CM_INV, /* LF instead of CR-LF */
1742 "off", TNL_CRNUL, 0, /* CR-NUL (TELNET spec) */
1743 "on", TNL_CRLF, 0, /* CR-LF (TELNET spec) */
1744 "raw", TNL_CR, 0 /* CR only (out of spec) */
1746 static int ntnlm = (sizeof(tnlmtab) / sizeof(struct keytab));
1748 struct keytab tntab[] = {
1749 #ifdef CK_AUTHENTICATION
1750 "authentication", CK_TN_AU, 0,
1751 #endif /* CK_AUTHENTICATION */
1752 "b", CK_TN_BM, CM_INV|CM_ABR,
1753 "bi", CK_TN_BM, CM_INV|CM_ABR,
1754 "bin", CK_TN_BM, CM_INV|CM_ABR,
1755 "bina", CK_TN_BM, CM_INV|CM_ABR,
1756 "binar", CK_TN_BM, CM_INV|CM_ABR,
1757 "binary", CK_TN_BM, CM_INV|CM_ABR,
1758 "binary-", CK_TN_BM, CM_INV|CM_ABR,
1759 "binary-mode", CK_TN_BM, CM_INV,
1760 "binary-transfer-mode", CK_TN_XF, 0,
1761 "binary-xfer-mode", CK_TN_XF, CM_INV,
1762 "bug", CK_TN_BUG, 0,
1763 "debug", CK_TN_DB, 0,
1764 "delay-sb", CK_TN_DL, 0,
1765 "echo", CK_TN_EC, 0,
1766 #ifdef CK_ENCRYPTION
1767 "encryption", CK_TN_ENC, 0,
1768 #endif /* CK_ENCRYPTION */
1769 #ifdef CK_ENVIRONMENT
1770 "environment", CK_TN_ENV, 0,
1771 #endif /* CK_ENVIRONMENT */
1773 "forward-x", CK_TN_FX, 0,
1774 #endif /* CK_FORWARD_X */
1776 "kermit", CK_TN_IKS, CM_INV,
1777 #endif /* IKS_OPTION */
1779 "location", CK_TN_LOC, 0,
1780 #endif /* CK_SNDLOC */
1782 "naws", CK_TN_NAWS, CM_INV,
1783 #endif /* CK_NAWS */
1784 "newline-mode", CK_TN_NL, 0,
1785 "no-encrypt-during-xfer", CK_TN_NE, CM_INV,
1786 "prompt-for-userid",CK_TN_PUID,0,
1787 "remote-echo", CK_TN_RE, 0,
1789 "start-tls", CK_TN_TLS, CM_INV,
1792 "sfu-compatibility", CK_TN_SFU, 0,
1794 "sfu-compatibility", CK_TN_SFU, CM_INV,
1796 "terminal-type", CK_TN_TT, 0,
1797 "wait-for-negotiations", CK_TN_WAIT, 0,
1798 #ifdef CK_ENVIRONMENT
1799 "xdisplay-location",CK_TN_XD, CM_INV,
1800 #endif /* CK_ENVIRONMENT */
1803 int ntn = (sizeof(tntab) / sizeof(struct keytab)) - 1;
1805 struct keytab tnopttab[] = {
1806 #ifdef CK_AUTHENTICATION
1807 "authentication", CK_TN_AU, 0,
1809 "authentication", CK_TN_AU, CM_INV,
1810 #endif /* CK_AUTHENTICATION */
1811 "binary-mode", CK_TN_BM, 0,
1813 "c", CK_TN_CPC, CM_INV|CM_ABR,
1814 "co", CK_TN_CPC, CM_INV|CM_ABR,
1815 "com", CK_TN_CPC, CM_INV|CM_ABR,
1816 "com-port-control",CK_TN_CPC, 0,
1817 "comport-control", CK_TN_CPC, CM_INV,
1818 #else /* TN_COMPORT */
1819 "com-port-control",CK_TN_CPC, CM_INV,
1820 "comport-control", CK_TN_CPC, CM_INV,
1821 #endif /* TN_COMPORT */
1822 "echo", CK_TN_EC, 0,
1823 #ifdef CK_ENCRYPTION
1824 "encryption", CK_TN_ENC, 0,
1826 "encryption", CK_TN_ENC, CM_INV,
1827 #endif /* CK_ENCRYPTION */
1829 "forward-x", CK_TN_FX, 0,
1830 #else /* CK_FORWARD_X */
1831 "forward-x", CK_TN_FX, CM_INV,
1832 #endif /* CK_FORWARD_X */
1833 "ibm-sak", CK_TN_SAK, CM_INV,
1835 "kermit", CK_TN_IKS, 0,
1837 "kermit", CK_TN_IKS, CM_INV,
1838 #endif /* IKS_OPTION */
1839 "lflow", CK_TN_FLW, CM_INV,
1840 "logout", CK_TN_LOG, 0,
1842 "naws", CK_TN_NAWS, 0,
1844 "naws", CK_TN_NAWS, CM_INV,
1845 #endif /* CK_NAWS */
1846 #ifdef CK_ENVIRONMENT
1847 "new-environment", CK_TN_ENV, 0,
1849 "new-environment", CK_TN_ENV, CM_INV,
1850 #endif /* CK_ENVIRONMENT */
1851 "pragma-heartbeat",CK_TN_PHR, CM_INV,
1852 "pragma-logon", CK_TN_PLG, CM_INV,
1853 "pragma-sspi", CK_TN_PSP, CM_INV,
1854 "sak", CK_TN_SAK, CM_INV,
1856 "send-location", CK_TN_LOC, 0,
1858 "send-location", CK_TN_LOC, CM_INV,
1859 #endif /* CK_SNDLOC */
1860 "sga", CK_TN_SGA, CM_INV|CM_ABR,
1862 "start-tls", CK_TN_TLS, 0,
1864 "start-tls", CK_TN_TLS, CM_INV,
1866 "suppress-go-aheads", CK_TN_SGA, 0,
1867 "terminal-type", CK_TN_TT, 0,
1868 "ttype", CK_TN_TT, CM_INV|CM_ABR,
1869 #ifdef CK_ENVIRONMENT
1870 "xdisplay-location", CK_TN_XD, 0,
1872 "xdisplay-location", CK_TN_XD, CM_INV,
1873 #endif /* CK_ENVIRONMENT */
1876 int ntnopt = (sizeof(tnopttab) / sizeof(struct keytab)) - 1;
1878 struct keytab tnoptsw[] = {
1879 "/client", CK_TN_CLIENT, 0,
1880 "/server", CK_TN_SERVER, 0
1882 int ntnoptsw = (sizeof(tnoptsw) / sizeof(struct keytab));
1885 struct keytab ftrtab[] = { /* Feature table */
1886 #ifndef NOCSETS /* 0 = we have it, 1 = we don't */
1887 "character-sets", 0, 0,
1889 "character-sets", 1, 0,
1890 #endif /* NOCSETS */
1895 #endif /* NOCYRIL */
1901 #endif /* NOLOGDIAL */
1907 #endif /* NODEBUG */
1916 "dynamic-memory", 0, 0,
1918 "dynamic-memory", 1, 0,
1919 #endif /* DYNAMIC */
1922 "file-transfer", 0, 0,
1924 "file-transfer", 1, 0,
1940 "fullscreen-display", 0, 0,
1942 "fullscreen-display", 1, 0,
1943 #endif /* CK_CURSES */
1973 "job-control", 0, 0,
1975 "job-control", 1, 0,
1978 "job-control", 1, 0,
1996 #endif /* CK_KERBEROS */
2002 #endif /* NOCSETS */
2010 "learned-scripts", 0, 0,
2012 "learned-scripts", 1, 0,
2013 #endif /* CKLEARN */
2016 "making-connections", 0, 0,
2018 "making-connections", 1, 0,
2019 #endif /* NOLOCAL */
2025 #endif /* NETCONN */
2028 #ifdef CK_AUTHENTICATION
2030 #else /* CK_AUTHENTICATION */
2032 #endif /* CK_AUTHENTICATION */
2043 #endif /* PIPESEND */
2047 #endif /* PIPESEND */
2066 #endif /* CK_REDIR */
2072 #endif /* RTS/CTS */
2075 "script-command", 0, 0,
2077 "script-command", 1, 0,
2078 #endif /* NOSCRIPT */
2080 "server-mode", 0, 0,
2082 "server-mode", 1, 0,
2083 #endif /* NOSERVER */
2086 "sexpression", 0, 0,
2088 "sexpression", 1, 0,
2095 #endif /* SFTP_BUILTIN */
2098 "show-command", 0, 0,
2100 "show-command", 1, 0,
2111 #else /* SSHBUILTIN */
2113 #endif /* SSHBUILTIN */
2131 #endif /* UNICODE */
2141 int nftr = (sizeof(ftrtab) / sizeof(struct keytab)) - 1;
2143 struct keytab desttab[] = { /* SET DESTINATION */
2145 "calibrate", DEST_N, CM_INV,
2146 #endif /* CALIBRATE */
2149 "nowhere", DEST_N, 0,
2150 #endif /* CALIBRATE */
2151 "printer", DEST_P, 0,
2154 int ndests = (sizeof(desttab) / sizeof(struct keytab));
2156 #ifndef NOSPL /* Used only with script programming items... */
2158 #ifndef NOSERVER /* This is just to avoid some */
2159 #define CK_PARSDIR /* "statement not reached" */
2160 #else /* complaints... */
2164 #endif /* NOSERVER */
2167 cx == 0 means dial directory
2168 cx == 1 means network directory
2169 cx == 2 means a directory path list
2172 parsdir(cx) int cx; {
2173 int i, x, y, dd; /* Workers */
2177 char *pp[MAXGETPATH]; /* Temporary name pointers */
2184 char dirpath[1024]; /* For fully qualified filenames */
2188 int max = 0; /* Maximum number of things to parse */
2192 if (cx == 0) { /* Dialing */
2198 if (cx == 1) { /* Network */
2203 #endif /* NETCONN */
2206 if (cx == 2) { /* GET path */
2210 } else /* Called with invalid function code */
2211 #endif /* NOSERVER */
2214 for (i = 0; i < MAXGETPATH; i++) /* Init these. */
2218 dd = 0; /* Temporary name counter */
2220 if (cx != 2) { /* Dialing or Network Directory */
2223 char * appdata0 = NULL, * appdata1 = NULL;
2225 env = getenv("K95PHONES");
2226 makestr(&appdata0,(char *)GetAppData(0));
2227 makestr(&appdata1,(char *)GetAppData(1));
2229 env = getenv("K2PHONES");
2232 env = getenv("K95PHONES");
2237 len = strlen(env) + 2*strlen(startupdir) + 2*strlen(inidir)
2238 + (appdata0?2*strlen(appdata0):0)
2239 + (appdata1?2*strlen(appdata1):0)
2240 + 2*strlen(zhome()) + 2*strlen(exedir) + 8*strlen("PHONES/")
2242 if (len < 4096) /* SAFE */
2244 "%s%s%s;%s%s;%s%s%s%s%s%s%s%s%s;%s%s;%s;%s%s",
2245 /* Semicolon-separated path list */
2247 (env[0] && env[strlen(env)-1] == ';') ? "" : ";",
2249 startupdir, "PHONES/",
2250 appdata1 ? appdata1 : "",
2251 appdata1 ? "Kermit 95;" : "",
2252 appdata1 ? appdata1 : "",
2253 appdata1 ? "Kermit 95/PHONES/;" : "",
2254 appdata0 ? appdata0 : "",
2255 appdata0 ? "Kermit 95;" : "",
2256 appdata0 ? appdata0 : "",
2257 appdata0 ? "Kermit 95/PHONES/;" : "",
2266 makestr(&appdata0,NULL);
2267 makestr(&appdata1,NULL);
2273 zzstring("\\v(home)",&s,&y);
2277 "Names of one or more directory files, separated by spaces",
2283 #endif /* OS2ORUNIX */
2286 } else { /* List of directory names */
2288 y = cmdir("Directory name","",&s,xxstring);
2291 if (y == -3) { /* EOL or user typed <CR> */
2292 if ((y = cmcfm()) < 0) return(y);
2293 for (i = 0; i < max; i++) { /* Clear these */
2294 if (i < nxdir && xdir[i]) {
2297 xdir[i] = (i < dd) ? pp[i] : NULL;
2305 #endif /* NETCONN */
2310 #endif /* NOSERVER */
2311 return(success = 1);
2313 } else { /* Parse error */
2314 for (i = 0; i < dd; i++) { /* Free temp storage */
2315 if (pp[i]) free(pp[i]); /* but don't change */
2316 pp[i] = NULL; /* anything else */
2322 printf("?Wildcards not allowed\n");
2326 if (cx == 2 && !isdir(s)) {
2327 printf("?Not a directory - %s\n", s);
2330 #endif /* CK_TMPDIR */
2334 if (!isabsolute(s)) { /* If not relative get full path */
2335 if ((fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf))) {
2337 if ((int) strlen(fnp->fpath) > 0)
2345 if (x > 0) /* Get last char */
2347 debug(F000,"parsdir s",s,c);
2348 if ((pp[dd] = malloc(strlen(s)+2)) == NULL) {
2349 printf("?Internal error - malloc\n");
2350 for (i = 0; i < dd; i++) { /* Free temp storage */
2351 if (pp[i]) free(pp[i]);
2355 } else { /* Have storage for name */
2356 strcpy(pp[dd],s); /* Copy string into new storage */
2357 debug(F111,"parsdir pp[dd] 1",pp[dd],dd);
2359 if (cx == 2) { /* If we are parsing directories */
2361 extern int myindex; /* Append directory separator if */
2362 extern struct sysdata sysidlist[]; /* it is missing... */
2363 debug(F101,"parsdir myindex","",myindex);
2365 if (sysidlist[myindex].sid_unixlike)
2366 if (c != sysidlist[myindex].sid_dirsep) {
2367 dirsep[0] = sysidlist[myindex].sid_dirsep;
2369 strcat(pp[dd], (char *) dirsep); /* safe */
2373 debug(F111,"parsdir pp[dd] 2",pp[dd],dd);
2375 printf("?Too many directories - %d max\n", max);
2376 for (i = 0; i < dd; i++) { /* Free temp storage */
2377 if (pp[i]) free(pp[i]);
2383 #endif /* CK_PARSDIR */
2392 char username[LOGINLEN+1];
2393 char password[LOGINLEN+1];
2394 char account[LOGINLEN+1];
2395 extern char * x_user, * x_passwd, * x_acct;
2396 extern int x_login, x_logged;
2402 x = cmfld("username", "", &s, xxstring);
2406 if ((int)strlen(s) > LOGINLEN) {
2407 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2410 ckstrncpy(username,s,LOGINLEN+1);
2411 x = cmfld("password", "", &s, xxstring);
2415 if ((int)strlen(s) > LOGINLEN) {
2416 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2419 ckstrncpy(password,s,LOGINLEN+1);
2420 x = cmfld("account", "", &s, xxstring);
2424 if ((int)strlen(s) > LOGINLEN) {
2425 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2428 ckstrncpy(account,s,LOGINLEN+1);
2429 if ((x = cmcfm()) < 0)
2434 makestr(&x_user,username);
2435 makestr(&x_passwd,password);
2436 makestr(&x_acct,account);
2437 x_login = (x_user) ? 1 : 0;
2441 #endif /* NOSERVER */
2447 if ((y = cmkey(crrtab,ncrr,"","automatic",xxstring)) < 0) return(y);
2449 x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring);
2450 if (x < 0) return(x);
2452 if ((x = cmcfm()) < 0) return(x);
2453 carrier = ttscarr(y);
2457 #endif /* NOLOCAL */
2459 extern struct keytab yesno[];
2462 /* g e t y e s n o */
2464 static struct keytab q0yesno[] = { /* Yes/No/Quit keyword table */
2469 static int nq0yesno = (sizeof(q0yesno) / sizeof(struct keytab));
2471 static struct keytab q1yesno[] = { /* Yes/No/Quit keyword table */
2477 static int nq1yesno = (sizeof(q1yesno) / sizeof(struct keytab));
2479 static struct keytab q2yesno[] = { /* Yes/No/Quit keyword table */
2485 static int nq2yesno = (sizeof(q2yesno) / sizeof(struct keytab));
2487 static struct keytab q3yesno[] = { /* Yes/No/Quit keyword table */
2494 static int nq3yesno = (sizeof(q3yesno) / sizeof(struct keytab));
2497 /* Ask question, get yes/no answer */
2500 getyesno(msg, flags) char * msg; int flags; {
2502 extern int on_recall; /* around Password prompting */
2503 #endif /* CK_RECALL */
2508 extern int vmode, win95_popup, startflags;
2509 int vmode_sav = vmode;
2511 #endif /* NOLOCAL */
2514 if ( apcactive != APC_INACTIVE && (apcstatus & APC_NOINP) ) {
2515 return(success = 0);
2522 if (win95_popup && !(startflags & 96)
2527 return(popup_readyesno(vmode,NULL,msg,flags));
2528 #endif /* COMMENT */
2529 if (vmode == VTERM) {
2531 VscrnIsDirty(VTERM);
2535 #endif /* NOLOCAL */
2538 In VMS, whenever a TAKE file or macro is active, we restore the
2539 original console modes so Ctrl-C/Ctrl-Y can work. But here we
2540 go interactive again, so we have to temporarily put them back.
2543 concb((char)escape);
2548 #endif /* CK_RECALL */
2549 cmsavp(psave,PROMPTL); /* Save old prompt */
2550 cmsetp(msg); /* Make new prompt */
2551 z = 0; /* Initialize answer to No. */
2552 cmini(ckxech); /* Initialize parser. */
2554 prompt(NULL); /* Issue prompt. */
2556 case 0: y = cmkey(q0yesno,nq0yesno,"","",NULL); break;
2557 case 1: y = cmkey(q1yesno,nq1yesno,"","",NULL); break;
2558 case 2: y = cmkey(q2yesno,nq2yesno,"","",NULL); break;
2559 default: y = cmkey(q3yesno,nq3yesno,"","",NULL);
2562 if (y == -4) { /* EOF */
2565 } else if (y == -3) /* No answer? */
2566 printf(" Please respond; type '?' to see valid answers.\n");
2569 z = y; /* Save answer */
2570 y = cmcfm(); /* Get confirmation */
2572 } while (y < 0); /* Continue till done */
2573 cmsetp(psave); /* Restore real prompt */
2575 if (cmdlvl > 0) /* In VMS and not at top level, */
2576 conres(); /* restore console again. */
2580 if (vmode != vmode_sav) {
2583 VscrnIsDirty(VTERM);
2586 #endif /* NOLOCAL */
2591 extern HWND hwndConsole;
2592 _PROTOTYP(int gui_txt_dialog,(char *,char *,int,char *,int,char *,int));
2593 _PROTOTYP(int gui_mtxt_dialog,(char *,int,struct txtbox []));
2594 _PROTOTYP(int gui_position,(int, int));
2595 _PROTOTYP(int gui_resize_mode,(int));
2596 _PROTOTYP(int gui_win_run_mode,(int));
2597 _PROTOTYP(int gui_saveas_dialog,(char *,char *, int, char *, char *, int));
2598 extern int gui_dialog;
2601 /* u q _ o k -- User Query, get Yes/No or OK Cancel */
2604 preface: Explanatory text to print, or NULL.
2606 mask: Bitmask for legal responses: 1 = OK or Yes; 2 = No or Cancel.
2607 help: Help text (array of strings or NULL) [not used by parser].
2608 dflt: Default response (1 or 2) [not used by parser].
2610 -1: Invalid argument(s).
2611 0: User said No or Cancel.
2612 1 User said Yes or OK.
2614 preface and prompt should not include final line terminator but may
2615 include embedded ones. Help text is in case GUI dialog needs a Help
2616 button; final element of help-string array is "". dflt is used by GUI
2617 to highlight the default response button.
2621 uq_ok(char * preface, char * prompt, int mask,char ** help, int dflt)
2622 #else /* CK_ANSIC */
2623 uq_ok(preface,prompt,mask,help,dflt)
2624 char * preface, * prompt, ** help;
2626 #endif /* CK_ANSIC */
2634 if ((mask & 3) == 1) { /* OK (GUI only) */
2637 /* This one is for popup help, alerts, etc */
2639 len = strlen(preface) + strlen(prompt) + 4;
2640 text = (char *)malloc(len);
2641 ckmakmsg(text,len,preface,"\n",prompt,NULL);
2643 rc = MessageBox(hwndConsole,
2644 text ? text : prompt,
2646 MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
2647 ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
2648 SetForegroundWindow(hwndConsole);
2658 if (preface) /* Just display the text, if any */
2659 printf("%s\n",preface);
2661 printf("%s\n",prompt);
2664 } else if ((mask & 3) == 3) { /* Yes/No or OK/Cancel */
2668 len = strlen(preface) + strlen(prompt) + 4;
2669 text = (char *)malloc(len);
2670 ckmakmsg(text,len,preface,"\n",prompt,NULL);
2672 rc = MessageBox(hwndConsole,
2673 text ? text : prompt,
2675 MB_YESNO | MB_ICONINFORMATION | MB_TASKMODAL |
2676 (dflt == 2 ? MB_DEFBUTTON2 : MB_DEFBUTTON1));
2677 ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
2678 SetForegroundWindow(hwndConsole);
2683 else if (rc == IDNO || rc == IDCANCEL)
2691 printf("%s\n",preface);
2692 return(getyesno(prompt,0));
2695 printf("?Internal error: uq_ok()\n");
2700 /* u q _ t x t -- User Query, get single text response */
2703 preface: Explanatory text to print, or NULL.
2705 echo: 0 = don't echo; 1 = echo; 2 = echo with asterisks.
2706 help: Help text (array of strings or NULL) [not used by parser].
2707 buf: Pointer to result buffer.
2708 buflen: Length of result buffer.
2709 dflt: Default response text or NULL [not used by parser].
2710 timer: Optional Timeout
2712 0: User said No or Cancel.
2713 1 User said Yes or OK.
2715 preface, prompt, and help as for uq_ok().
2719 uq_txt(char * preface, char * prompt, int echo, char ** help, char * buf,
2720 int buflen, char *dflt, int timer)
2721 #else /* CK_ANSIC */
2722 uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer)
2723 char * preface, * prompt, ** help, * buf, * dflt;
2724 int buflen, echo, timer;
2725 #endif /* CK_ANSIC */
2730 extern int startflags;
2731 extern int win95_popup;
2733 #endif /* NOLOCAL */
2736 if (buflen < 1 || !buf)
2740 rc = gui_txt_dialog(preface,prompt,echo,buf,buflen,dflt,timer);
2743 /* Otherwise, the dialog could not be created. Fallback to text mode */
2748 if (win95_popup && !(startflags & 96)
2753 debok = 0; /* Don't log */
2755 popup_readtext(vmode,preface,prompt,buf,buflen,0);
2757 popup_readpass(vmode,preface,prompt,buf,buflen,0);
2762 #endif /* NOLOCAL */
2765 printf("%s\n",preface);
2767 readtext(prompt,buf,buflen);
2769 readpass(prompt,buf,buflen);
2770 return(1); /* (no buttons in parser) */
2773 /* u q _ m t x t -- User Query, get multiple text responses */
2776 preface: Explanatory text to print, or NULL.
2777 help: Help text (array of strings or NULL) [not used by parser].
2778 n: Number of responses wanted.
2779 field: Array of struct txtbox, one element per field, see ckuusr.h.
2781 0: User said No or Cancel.
2782 1 User said Yes or OK.
2784 preface and help as for uq_ok().
2788 uq_mtxt(char * preface,char **help, int n, struct txtbox field[])
2789 #else /* CK_ANSIC */
2790 uq_mtxt(preface,help,n,field)
2791 char * preface; char ** help; int n; struct txtbox field[];
2792 #endif /* CK_ANSIC */
2797 extern int startflags;
2798 extern int win95_popup;
2800 #endif /* NOLOCAL */
2803 if (n < 1 || !field)
2807 rc = gui_mtxt_dialog(preface, n, field);
2810 /* Otherwise, the dialog could not be created. Fallback to text mode */
2815 if (win95_popup && !(startflags & 96)
2820 debok = 0; /* Don't log */
2821 for (i = 0; i < n; i++) {
2822 if (field[i].t_echo == 1)
2823 popup_readtext(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
2825 popup_readpass(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
2831 #endif /* NOLOCAL */
2834 printf("%s\n",preface);
2835 for (i = 0; i < n; i++) {
2836 if (field[i].t_echo == 1)
2837 readtext(field[i].t_lbl,field[i].t_buf,field[i].t_len);
2839 readpass(field[i].t_lbl,field[i].t_buf,field[i].t_len);
2844 /* u q _ f i l e -- User Query, get file or directory name */
2847 preface: Explanatory text to print, or NULL.
2848 prompt: Prompt string.
2850 1 = input (existing) file
2851 2 = existing directory
2852 3 = create new output file
2853 4 = output file allowing append access
2854 help: Help text (array of strings or NULL) [not used by parser].
2855 dflt: Default response.
2856 result: Pointer to result buffer.
2857 rlength: Length of result buffer.
2860 -1: Invalid argument, result too long, or other error.
2862 1: OK, with file/pathname copied to result buffer.
2863 2: Like 1, but for output file that is to be appended to.
2866 1. preface and prompt should not include final line terminator but may
2867 include embedded ones. Help text is in case GUI dialog needs a Help
2868 button; final element of help-string array is "".
2870 2. The default might be a filename, a directory name, a relative
2871 pathname, or an absolute pathname. This routine must convert it into
2872 into a fully qualified (absolute) pathname so the user knows exactly
2873 where the file is to be found or stored. In addition, the Windows
2874 version of this routine must separate the directory part from the
2875 name part, so it can display the given directory in the file dialog,
2876 and put name in the filename box to be edited, replaced, or
2879 3. When called with FC 4, the Windows version should include "New" and
2880 "Append" buttons in the dialog. so the user can say whether the file
2881 should overwrite any file of the same name, or be appended to it.
2886 uq_file(char * preface, char * fprompt, int fc, char ** help,
2887 char * dflt, char * result, int rlength)
2888 #else /* CK_ANSIC */
2889 uq_file(preface,fprompt,fc,help,dflt,result,rlength)
2890 char * preface, * fprompt, ** help, * dflt, * result;
2892 #endif /* CK_ANSIC */
2895 int rc = -1, x, y, z;
2896 char * s, * p, * fullpath;
2897 char filebuf[CKMAXPATH+1];
2900 extern int on_recall;
2901 #endif /* CK_RECALL */
2905 rc = gui_saveas_dialog(preface,fprompt,fc,dflt,result,rlength);
2912 #endif /* CK_RECALL */
2914 if (preface) /* If prefatory text given... */
2915 printf("%s\n",preface); /* display it. */
2917 cmsavp(psave,PROMPTL); /* Save old prompt */
2919 /* We get the full pathname of the proposed output file just so */
2920 /* we can show it to the user but we don't use it ourselves. */
2922 p = NULL; /* Build new prompt */
2923 if (!dflt) dflt = "";
2924 if (*dflt) /* Have default filename */
2925 zfnqfp(dflt,CKMAXPATH+1,filebuf); /* Get full path */
2927 ckmakmsg(filebuf,CKMAXPATH+1,zgtdir(),"newfile",NULL,NULL);
2929 x = strlen(fullpath);
2931 /* If no prompt given, build one that shows the proposed full pathname. */
2933 if (!fprompt) fprompt = "";
2934 if (!*fprompt) fprompt = x ? " Filename" : " Filename: ";
2935 y = strlen(fprompt);
2936 if (x > 0) { /* Have default pathname? */
2937 p = (char *)malloc(x + y + 7); /* Get temp storage */
2938 if (p) { /* Build prompt */
2939 ckmakmsg(p,x+y+7,fprompt," [",fullpath,"]: ");
2943 cmsetp(fprompt); /* Make new prompt */
2944 if (p) free(p); /* Free temp storage */
2945 cmini(ckxech); /* Initialize parser. */
2948 prompt(NULL); /* Issue prompt. */
2949 switch (fc) { /* Parse depends on function code */
2950 case 1: /* Input file */
2951 x = cmifi("Name of existing file",dflt,&s,&y,xxstring);
2954 case 2: /* Directory */
2955 x = cmdir("Directory name",dflt,&s,xxstring);
2958 case 3: /* New output file */
2960 case 4: /* Output file - Append allowed */
2961 x = cmofi("Output file specification",dflt,&s,xxstring);
2962 rc = (fc == 4) ? 1 : 2;
2964 default: /* Bad function code */
2967 if (x < 0) { /* Parse error */
2969 if (x == -4) { /* EOF */
2971 } else if (x == -3) /* No answer? */
2973 " Please enter a directory name.\n" :
2974 " Please enter a filename.\n"
2979 if (z > rlength || ckstrncpy(filebuf,brstrip(s),CKMAXPATH+1) < z) {
2980 printf("?Name too long\n");
2983 x = cmcfm(); /* Get confirmation */
2985 if (fc == 1 && x > -1 && y > 0) {
2986 printf("?Wildcards not allowed\n");
2989 } while (x < 0); /* Continue till done */
2995 cmsetp(psave); /* Restore real prompt */
2998 ckstrncpy(result,filebuf,rlength);
3006 _PROTOTYP( int zsetperm, (char *, int));
3008 /* CHMOD command for UNIX only */
3023 static struct keytab uchmodsw[] = {
3024 "/directories", CHM_DIR, 0,
3025 "/dotfiles", CHM_DOT, 0,
3026 "/files", CHM_FIL, 0,
3027 "/list", CHM_LIS, 0,
3028 "/nolist", CHM_NOL, 0,
3029 "/nopage", CHM_NOP, 0,
3030 "/page", CHM_PAG, 0,
3031 "/quiet", CHM_QUI, CM_INV,
3032 "/recursive", CHM_REC, 0,
3033 "/simulate", CHM_SIM, 0,
3034 "/type", CHM_TYP, CM_ARG,
3035 "/verbose", CHM_VRB, CM_INV,
3037 static int nchmodsw = (sizeof(uchmodsw) / sizeof(struct keytab));
3041 extern int recursive, nscanfile, diractive;
3043 extern int tt_rows, tt_cols;
3045 #endif /* CK_TTGWSIZ */
3046 int i, files = 1, t1 = 1, t2 = 0, x, y, z, verbose = 0, rc = 1, paging;
3047 int xmode = -1, fs = 0, getval = 0, simulate = 0, wild = 0;
3056 #endif /* CK_TTGWSIZ */
3060 cmfdbi(&sw, /* First FDB - command switches */
3062 "Octal file permission code, or switch",
3064 "", /* addtl string data */
3065 nchmodsw, /* addtl numeric data 1: tbl size */
3066 4, /* addtl numeric data 2: 4 = cmswi */
3067 xxstring, /* Processing function */
3068 uchmodsw, /* Keyword table */
3069 &nu /* Pointer to next FDB */
3072 _CMNUM, /* Number */
3073 "", /* Help message */
3078 xxstring, /* Processing function */
3084 if ((x = cmfdb(&sw)) < 0) {
3087 printf("?Filename required\n");
3091 if (cmresult.fcode != _CMKEY)
3094 getval = (c == ':' || c == '=');
3095 if (getval && !(cmgkwflgs() & CM_ARG)) {
3096 printf("?This switch does not take an argument\n");
3099 if (!getval && (cmgkwflgs() & CM_ARG)) {
3100 printf("?This switch requires an argument\n");
3103 switch (cmresult.nresult) {
3137 extern struct keytab txtbin[];
3138 if ((x = cmkey(txtbin,3,"","",xxstring)) < 0)
3140 if (x == 2) { /* ALL */
3142 } else { /* TEXT or BINARY only */
3150 z = cmresult.nresult;
3151 x = cmifi2("File specification","",&s,&wild,t1,NULL,xxstring,t2);
3154 printf("?A file specification is required\n");
3159 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
3161 if ((x = cmcfm()) < 0)
3164 if (wild) files = zxrewind();
3166 if (wild) files = nzxpand(s,0);
3167 #endif /* ZXREWIND */
3173 if (verbose && paging) {
3177 if (ttgwsiz() > 0) {
3178 if (tt_rows > 0 && tt_cols > 0) {
3185 #endif /* CK_TTGWSIZ */
3187 for (i = 0; i < files; i++) {
3188 if (files == 1 && wild == 0) { /* For "chmod 777 ." */
3189 ckstrncpy(line,s,LINBUFSIZ);
3194 printf("?No files match - \"%s\"\n",line);
3202 /* If /TYPE:TEXT or BINARY given, skip directories and links */
3203 /* since they are neither text nor binary. */
3204 extern int zgfs_dir, zgfs_link;
3206 if (zgfs_dir || zgfs_link)
3209 if (zchki(line) < 0)
3211 #endif /* VMSORUNIX */
3212 /* Regular file, scan it */
3213 switch (scanfile(line,&y,nscanfile)) {
3224 #endif /* UNICODE */
3231 extern int zchkod; /* Unidentified Flying */
3232 int xx = zchkod; /* API Extension... */
3235 if (zchko(line) < 0)
3236 printf("%s - Access denied\n",line);
3238 printf("%s - OK\n",line);
3243 if (zsetperm(line,z) < 1) {
3244 if (verbose || files < 2) {
3245 printf("%s: %s\n",line,ck_errstr());
3248 } else if (verbose) {
3249 printf("%s %s\n",ziperm(line),line);
3253 if (verbose && paging) { /* Pause at end of screen */
3254 if (cmd_rows > 0 && cmd_cols > 0) {
3255 if (++n > cmd_rows - 3) {
3263 #endif /* CK_TTGWSIZ */
3266 return(success = rc);
3269 #endif /* CK_PERMS */
3271 #ifndef NOSPL /* S-Expressions */
3274 struct keytab sexptab[] = {
3275 "depth-limit", 1, 0,
3276 "echo-result", 0, 0,
3277 "truncate-all-results", 2
3280 static int sexpmaxdep = 1000; /* Maximum depth */
3282 #define xxfloat(s,x) \
3283 ((isdigit(*s)||(*s=='-')||(*s=='+')||(*s=='.')||(*s=='\040'))?isfloat(s,x):0)
3285 #define SX_ADD 1 /* Symbols for built-in operators */
3329 /* Operator flags */
3331 #define SXF_PRE 256 /* Predicate */
3332 #define SXF_ONE 512 /* Requires one arg */
3333 #define SXF_TWO 1024 /* Requires two args or more */
3334 #define SXF_FLO 2048 /* Coerce to floating-point */
3336 /* Built-in constants */
3338 #define SXC_NIL 1 /* NIL */
3339 #define SXC_PI 2 /* PI */
3340 #define SXC_T 3 /* T */
3343 This is an xlookup() table and so need not be in "alhabetical" order.
3344 Therefore entries are arranged to minimize search for most common
3347 static struct keytab sexpops[] = { /* Built-in operators */
3348 "setq", SX_SET, 0, /* Global assignment */
3349 "+", SX_ADD, 0, /* Simple arithmetic */
3352 "/", SX_DIV, SXF_TWO,
3353 "^", SX_POW, SXF_TWO,
3355 "if", SX_IFC, SXF_TWO, /* IF */
3356 "let", SX_LET, 0, /* Local assignment */
3357 "not", SX_NOT, SXF_ONE, /* NOT */
3358 "mod", SX_MOD, SXF_TWO, /* Modulus */
3360 "<", SX_ALT, SXF_PRE, /* Comparisons */
3361 ">", SX_AGT, SXF_PRE,
3362 "<=", SX_ALE, SXF_PRE,
3363 "=", SX_AEQ, SXF_PRE,
3364 ">=", SX_AGE, SXF_PRE,
3365 "!=", SX_NEQ, SXF_PRE,
3367 "++", SX_INC, SXF_ONE|SXF_TWO, /* Increment */
3368 "--", SX_DEC, SXF_ONE|SXF_TWO, /* Decrement */
3370 "**", SX_POW, SXF_TWO, /* Common synonyms */
3371 "==", SX_AEQ, SXF_PRE,
3372 "!", SX_NOT, SXF_ONE,
3375 "and", SX_AND, 0, /* Logical operators */
3377 "xor", SX_XOR, SXF_TWO,
3379 "max", SX_MAX, SXF_ONE|SXF_TWO, /* Max and min */
3380 "min", SX_MIN, SXF_ONE|SXF_TWO,
3382 "%", SX_MOD, SXF_TWO, /* More synonyms */
3386 "quote", SX_QUO, SXF_ONE,
3387 "string", SX_STR, SXF_ONE,
3389 "eval", SX_EVA, 0, /* Assorted commands */
3390 "abs", SX_ABS, SXF_ONE,
3391 "truncate",SX_TRU, SXF_ONE|SXF_FLO,
3392 "round", SX_ROU, SXF_ONE|SXF_FLO,
3393 "ceiling", SX_CEI, SXF_ONE|SXF_FLO,
3394 "floor", SX_FLR, SXF_ONE|SXF_FLO,
3395 "float", SX_FLO, SXF_ONE|SXF_FLO,
3398 "sqrt", SX_SQR, SXF_ONE|SXF_FLO, /* Floating point functions */
3399 "exp", SX_EXP, SXF_ONE|SXF_FLO,
3400 "sin", SX_SIN, SXF_ONE|SXF_FLO,
3401 "cos", SX_COS, SXF_ONE|SXF_FLO,
3402 "tan", SX_TAN, SXF_ONE|SXF_FLO,
3403 "log", SX_LGN, SXF_ONE|SXF_FLO,
3404 "log10", SX_LGX, SXF_ONE|SXF_FLO,
3405 #endif /* FNFLOAT */
3407 "#", SX_BWX, SXF_TWO, /* Bitwise operators */
3410 "~", SX_BWN, SXF_ONE,
3411 "", 0, 0 /* (end) */
3413 static int nsexpops = (sizeof(sexpops) / sizeof(struct keytab)) - 1;
3415 static struct keytab sexpconsts[] = { /* Built-in constants */
3416 "nil", SXC_NIL, 0, /* NIL (false) */
3417 "pi", SXC_PI, 0, /* Pi (3.1415926...) */
3418 "t", SXC_T, 0, /* T (true) */
3421 static int nsexpconsts = (sizeof(sexpconsts) / sizeof(struct keytab)) - 1;
3423 int sexprc = 0; /* S-Expression error flag */
3424 int sexppv = -1; /* Predicate value */
3425 static int sexptrunc = 0; /* Flag to force all results to int */
3427 #define SXMLEN 64 /* Macro arg list initial length */
3428 #include <math.h> /* Floating-point functions */
3430 _PROTOTYP( char * fpformat, (CKFLOAT, int, int) );
3432 extern char math_pi[]; /* Value of Pi */
3433 extern int sexpecho; /* SET SEXPRESSION ECHO value */
3434 extern char * sexpval; /* Last top-level S-Expression value */
3435 extern char * lastsexp; /* Last S-Expression */
3436 int sexprmax = 0; /* Longest result (for stats) */
3437 int sexpdmax = 0; /* Max depth reached (for stats) */
3438 int sexpdep = 0; /* dosexp() recursion depth */
3439 static int * sxrlen = NULL; /* Result stack string sizes */
3440 static char ** sxresult = NULL; /* Result stack */
3442 /* s h o s e x p -- Show S-Expression info */
3447 printf(" sexpression echo-result: %s\n",showooa(sexpecho));
3448 printf(" sexpression depth-limit: %d\n",sexpmaxdep);
3450 printf(" maximum depth reached: %d\n",sexpdmax);
3451 printf(" longest result returned: %d\n",sexprmax);
3453 printf(" truncate all results: %s\n",showoff(sexptrunc));
3455 printf(" last sexpression: %s\n",lastsexp ? lastsexp : "(none)");
3456 printf(" last value: %s\n",sexpval ? sexpval : "(none)");
3462 sexpdebug(s) char * s; {
3463 /* For debugging -- includes recursion depth in each debug entry */
3464 static char buf[64];
3465 ckmakmsg(buf,64,"dosexp[",ckitoa(sexpdep),"] ",s);
3466 return((char *)buf);
3469 /* d o s e x p -- S-Expression Reader */
3471 /* Returns value as string (empty, numeric, or non-numeric) */
3474 dosexp(s) char *s; { /* s = S-Expression */
3475 extern struct mtab *mactab; /* Macro table */
3476 extern int maclvl, nmac;
3477 extern char *mrval[];
3478 extern int makestrlen; /* (see makestr()) */
3479 struct stringarray * q = NULL; /* cksplit() return type */
3480 char * p[SEXPMAX+1], ** p2; /* List items (must be on stack) */
3481 char * line = NULL; /* For building macro argument list */
3485 int quote = 0; /* LISP quote flag */
3486 char * s2; /* Workers */
3487 int kw, kwflags, mx = 0, x = 0;
3488 int not = 0, truncate = 0, builtin = 0;
3489 int fpflag = 0, quit = 0, macro = 0;
3490 CK_OFF_T result = 0, i, j, k, n = 0;
3491 CKFLOAT fpj, fpresult = 0.0; /* Floating-point results */
3492 int pflag = 0; /* Have predicate */
3493 int presult = 0; /* Predicate result */
3494 int mustfree = 0; /* If we malloc'd we must free */
3496 sexppv = -1; /* Predicate value */
3497 s2 = ""; /* Default return value */
3499 debug(F111,sexpdebug("entry 1"),s,sexprc);
3501 if (++sexpdep > sexpmaxdep) { /* Keep track of depth */
3502 printf("?S-Expression depth limit exceeded: %d\n",sexpmaxdep);
3504 debug(F111,sexpdebug("max depth exceeded"),s,sexprc);
3506 if (sexpdep > sexpdmax) /* For stats */
3509 if (sexprc) /* Error, quit all levels */
3510 goto xdosexp; /* Always goto common exit point */
3512 debug(F111,sexpdebug("entry 2"),s,sexprc);
3514 if (!s) s = ""; /* Null or empty arg */
3516 while (*s == SP) s++; /* Strip leading spaces */
3517 if (!*s) /* so empty result */
3520 Allocate result stack upon first use, or after it has been resized with
3521 SET SEXP DEPTH-LIMIT.
3524 sxresult = (char **)malloc(sexpmaxdep * sizeof(char *));
3526 printf("?Memory allocation failure - \"%s\"\n", s);
3530 sxrlen = (int *)malloc(sexpmaxdep * sizeof(int));
3532 printf("?Memory allocation failure - \"%s\"\n", s);
3536 for (i = 0; i < sexpmaxdep; i++) {
3537 sxresult[i] = NULL; /* Result pointers */
3538 sxrlen[i] = 0; /* Buffer sizes */
3541 s2 = s; /* s2 is the result pointer */
3542 k = 0; /* Length accumulator */
3543 if (s[0] == '(') { /* Starts with open paren? */
3544 while (*s2++) k++; /* Get length */
3545 if (s[k-1] == ')') { /* Strip outer parens if any */
3549 while (*s == SP) { /* Strip leading spaces from result */
3553 while (k > 0 && s[k-1] == SP) { /* And trailing spaces. */
3558 if (!*s) { /* If nothing remains */
3559 s2 = ""; /* return empty result. */
3563 /* Break result up into "words" (an SEXP counts as a word) */
3565 p[0] = NULL; /* (We don't use element 0) */
3566 if (!*(s+1) || !*(s+2)) { /* No need to call cksplit() */
3567 n = 1; /* if it's one or two chars. */
3568 p[1] = s; /* No need to malloc this either. */
3570 debug(F101,sexpdebug("nosplit"),"",n);
3571 if (s[0] == '(') { /* () empty */
3577 q = cksplit(1,SEXPMAX,s,NULL,"\\%[]&$+-/=*^_@!{}/<>|.#~'`:;?",8,39,0);
3580 n = q->a_size; /* Number of items */
3581 debug(F101,sexpdebug("split"),"",n);
3582 if (n < 0 || n > SEXPMAX) { /* Check for too many */
3583 printf("?Too many operands: max = %d\n",SEXPMAX);
3587 if (n == 0) /* None, result is NULL, done. */
3589 if (n == 1 && s[0] == '(') { /* One but it's another SEXP */
3593 p2 = q->a_head; /* Point to result array. */
3594 for (i = 1; i <= n; i++) { /* We must copy it because */
3595 p[i] = NULL; /* recursive calls to dosexp() */
3596 if (p2[i]) /* write over the same array */
3597 makestr(&(p[i]),p2[i]);
3599 if (s[0] == '(') { /* Operator is an S-Expression */
3600 s2 = dosexp(p[1]); /* Replace it by its value */
3601 makestr(&(p[1]),s2);
3603 mustfree++; /* Remember to free it */
3605 debug(F110,sexpdebug("head"),p[1],0);
3607 if (n == 1 && p[1]) {
3608 if (*(p[1]) == '\047') {
3614 This section sidesteps xlookup() of the most common operators.
3615 It's not necessary but it speeds up SEXP-heavy loops by about 10%.
3618 if (n > 0) { /* Look up the operator */
3619 s2 = p[1]; /* Prelookup optimization... */
3626 if (isdigit(*s2)) { /* Digit */
3629 } else if (isalpha(*s2) && !*(s2+1)) { /* Single letter */
3632 } else if (*s2 == 's' || *s2 == 'S') { /* SETQ */
3634 if (*s2 == 'e' || *s2 == 'E') {
3636 if (*s2 == 't' || *s2 == 'T') {
3638 if (*s2 == 'q' || *s2 == 'Q') {
3649 if (!*(s2+1)) { /* Common single-character ops */
3654 } else if (*s2 == '-') {
3658 } else if (*s2 == '*') {
3662 } else if (*s2 == '/') {
3668 if (!x) { /* None of the above, look it up */
3669 x = xlookup(sexpops,p[1],nsexpops,&kw);
3671 kwflags = sexpops[kw].flgs;
3677 /* If none of the above, check built-in constants */
3680 x = xlookup(sexpconsts,p[1],nsexpconsts,&kw);
3695 if (n == 1) { /* Not an expression */
3696 if (builtin) { /* Built-in operand? */
3697 switch (x) { /* Operators with default values */
3701 case SX_MUL: /* (*) */
3702 s2 = sexpval ? sexpval : "1";
3704 case SX_AND: /* (AND) */
3705 case SX_BWA: /* Bitwise (&) */
3707 case SX_LOR: /* (OR) */
3708 case SX_BWO: /* Bitwise (|) */
3709 case SX_ADD: /* (+) */
3710 case SX_SUB: /* (-) */
3711 s2 = result ? "1" : "0";
3715 } else { /* Not a built-in operand */
3718 while (*p1 == SP) p1++;
3719 if (!isalpha(*p1)) {
3720 if (xxfloat(p1,0) > 0) { /* Is it a number? */
3722 while (*s2 == '+') s2++;
3723 } else if (*p1 == '(') { /* An S-Expression? */
3729 #endif /* COMMENT */
3732 } else if (x < 1) { /* Is it a variable? */
3733 j = mxlook(mactab,p[1],nmac); /* Look it up */
3734 debug(F111,sexpdebug("n==1 mxlook"),p[1],j);
3735 s2 = (j > -1) ? mactab[j].mval : "";
3737 if (xxfloat(s2,0) > 0) /* Macro value is a number */
3739 if (j > -1) { /* It's a macro */
3741 x = j; /* whose definition is not numeric */
3742 if (*s2 == '(') { /* Is it an S-Expression? */
3743 /* We have to allocate memory on the stack */
3744 /* to call ourselves recursively on it */
3745 /* otherwise we'll wipe out the macro definition */
3750 s3 = (char *)malloc(k + 4);
3752 strcpy(s3,s2); /* SAFE */
3753 s2 = dosexp(s3); /* Evaluate it */
3756 printf("?Memory allocation failure - \"%s\"\n",s2);
3761 if (*s2 == '\047') {
3764 /* Dumps core if petty optimization was taken */
3765 makestr(&(p[1]),s2);
3767 if (!nosplit && p[1]) free(p[1]);
3768 p[1] = (char *)malloc((int)strlen(s2) + 1);
3769 #endif /* COMMENT */
3773 if (s2[makestrlen-1] == ')') {
3774 s2[makestrlen-1] = NUL;
3778 debug(F110,sexpdebug("'A"),s2,0);
3781 macro++; /* Not an S-Expression */
3782 } else { /* Not found in macro table */
3783 printf("?Not defined - \"%s\"\n", p[1]);
3789 } else if (x < 1 && !macro) { /* n > 1 and not a built-in operator */
3790 x = mxlook(mactab,p[1],nmac); /* See if it's a macro */
3791 debug(F111,sexpdebug("n!=1 mxlook"),p[1],x);
3793 printf("?Invalid operand - \"%s\"\n",p[1]);
3800 if (builtin) { /* Built-in operator... */
3803 if ((flgs = (kwflags & (SXF_ONE|SXF_TWO)))) {
3805 case (SXF_ONE|SXF_TWO):
3807 printf("?Too few operands - \"%s\"\n",s);
3814 printf("?Too few operands - \"%s\"\n",s);
3821 printf("?Too %s operands - \"%s\"\n",
3822 (n > 2) ? "many" : "few", s);
3828 if (kwflags & SXF_PRE) { /* Predicate? */
3830 printf("?Too few operands - \"%s\"\n",s);
3837 if (kwflags & SXF_FLO) /* Operator requires floating point */
3838 fpflag++; /* Force it */
3840 if (x == SX_SET || x == SX_LET || /* Assignment is special */
3841 x == SX_INC || x == SX_DEC) {
3849 for (i = 1; i < n; i += 2) { /* Loop thru operand pairs */
3853 debug(F110,sexpdebug("target p"),s3,0);
3855 /* Make sure target doesn't have multiple words */
3856 while (*s3) { if (*s3 < '!') { rc = 1; break; }; s3++; }
3858 if (rc) { /* If it does it must have been */
3859 char * s4; /* an SEXP so evaluate it */
3863 while (*s4) { if (*s4 < '!') { rc = 1; break; }; s4++; }
3864 if (rc == 0) makestr(&(p[i+1]),s3);
3867 /* And that it's not a number, etc. */
3868 if (rc > 0 || isdigit(c) || c == '(') {
3869 printf("?Invalid assignment - \"%s\"\n",s);
3872 } else if (isalpha(c)) {
3873 rc = xlookup(sexpconsts,s3,nsexpconsts,NULL);
3875 printf("?Assignment to constant - \"%s\"\n",s);
3881 /* If ++ or --, get current value of variable */
3882 if (x == SX_INC || x == SX_DEC) {
3885 if (c == CMDQ) { /* A backslash variable */
3889 if (zzstring(s3,&s,&n) < 0 || !buf[0])
3892 } else { /* A macro */
3893 if ((k = mxlook(mactab,s3,nmac)) < 0)
3896 s2 = mactab[k].mval;
3899 printf("?Not defined - \"%s\"\n",p[i+1]);
3906 printf("?Not numeric - \"%s\"\n",p[i+1]);
3910 while (*s2 == '+') s2++;
3911 result = ckatofs(s2);
3912 fpresult = floatval;
3913 if (k > 1 || fpresult != result)
3916 if (n < i+2) { /* Variable with no value */
3918 if (x == SX_SET || x == SX_LET) {
3919 delmac(p[i+1],1); /* Delete the variable */
3924 } else { /* Variable with value */
3925 k = xxfloat(p[i+2],0); /* Is it a number? */
3928 while (*s2 == '+') s2++;
3930 s2 = dosexp(p[i+2]); /* Have value, evaluate it */
3931 if (sexprc) goto xdosexp;
3933 if (!*s2 && (x == SX_INC || x == SX_DEC))
3937 if (x == SX_INC || x == SX_DEC) {
3940 printf("?Not numeric - \"%s\"\n",s2);
3944 while (*s2 == '+') s2++;
3955 } else if (x == SX_DEC) {
3960 if (result != fpresult) fpflag++;
3961 #endif /* FNFLOAT */
3962 s2 = (fpflag && !sexptrunc) ?
3963 fpformat(fpresult,0,0) : ckfstoa(result);
3965 if (x == SX_LET && cmdlvl > 0) /* LET makes var local */
3967 if ((rc = addmac(p[i+1],s2)) < 0) { /* Add the value */
3969 case -3: m = "Array not declared"; break;
3970 case -2: m = "Subscript out of range"; break;
3971 case -4: m = "Out of memory"; break;
3972 default: m = "Error creating variable";
3974 printf("?%s - \"%s\"\n",m,s);
3978 if (s2) result = ckatofs(s2);
3981 } else if (x == SX_IFC) { /* Conditional expression */
3984 printf("?Too many operands: IF - \"%s\"\n",s);
3989 if (sexprc) goto xdosexp;
3992 if (xxfloat(s2,0) == 2) {
3994 fpresult = (CKFLOAT)result;
3999 true = ((fpj != 0.0) ? 1 : 0);
4001 if (!true && n < 4) {
4004 s2 = dosexp(true ? p[3] : p[4]);
4005 if (sexprc) goto xdosexp;
4006 j = s2 ? ckatofs(s2) : 0;
4007 if (xxfloat(s2,0) == 2) {
4009 fpresult = (CKFLOAT)result;
4012 fpj = s2 ? atof(s2) : 0.0;
4018 } else if (x == SX_QUO) {
4022 p[3] = (char *)malloc(xx+4);
4024 ckmakmsg(p[3],xx+4,"'(",p[2],")",NULL);
4028 #endif /* COMMENT */
4030 } else if (x == SX_STR) {
4033 if (sexprc) goto xdosexp;
4035 p[3] = (char *)malloc(xx+4);
4036 ckmakmsg(p[3],xx+4,"'(",s2,")",NULL);
4042 /* Arithmetic operator or macro - Loop thru operands */
4044 quit = 0; /* Short-circuit flag. */
4045 if (macro && n > 1) { /* If operator is a macro */
4046 if (!line) { /* allocate local buffer for */
4047 line = (char *)malloc(SXMLEN); /* the evaluated argument list. */
4049 printf("?Memory allocation failure - \"%s\"\n",p[1]);
4054 /* debug(F101,"dosexp macro arg buffer","",linelen); */
4057 line[linepos] = NUL;
4059 for (i = 1; ((i < n) && !sexprc && !quit); i++) { /* Loop thru operands */
4061 s2 = p[i+1]; /* Get operand */
4064 if (*s2 == '\047') { /* Is it quoted? */
4065 debug(F110,sexpdebug("'B"),s2,0);
4066 s2++; /* Space past the quote */
4068 if (*s2 == '(') { /* Quoted S-Expression? */
4069 char c4, * s4 = s2+1; /* Strip outer parens */
4070 while ((c4 = *s4++)) {
4071 if (c4 == ')' && !*s4) {
4078 debug(F110,sexpdebug("'C"),s2,0);
4080 } else { /* Not quoted */
4081 s2 = dosexp(p[i+1]); /* evaluate it */
4082 if (sexprc) goto xdosexp;
4084 if (!macro && x == SX_EVA)
4088 if (*s2 != '\047') { /* Is it quoted? */
4089 s2 = dosexp(p[i+1]); /* No, evaluate it */
4090 if (sexprc) goto xdosexp;
4092 if (!macro && x == SX_EVA)
4095 if (*s2 == '\047') { /* Is result quoted? */
4096 debug(F110,sexpdebug("'B"),s2,0);
4097 s2++; /* Space past the quote */
4099 if (*s2 == '(') { /* Quoted S-Expression? */
4100 char c4, * s4 = s2+1; /* Strip outer parens */
4101 while ((c4 = *s4++)) {
4102 if (c4 == ')' && !*s4) {
4109 debug(F110,sexpdebug("'C"),s2,0);
4111 #endif /* COMMENT */
4113 debug(F111,sexpdebug("macro arg"),s2,i);
4116 register char c4, * s4 = s2;
4117 while ((c4 = *s4++)) if (c4 == SP) { quote++; break; }
4119 if (quote) line[linepos++] = '{';
4120 while ((line[linepos++] = *s2++)) {
4121 if (linepos > linelen - 3) {
4123 line[linepos] = NUL;
4125 tmp = (char *) malloc(linelen);
4127 printf("?Memory re-allocation failure - \"%s...\"\n",
4137 linepos--; /* Back up over NUL */
4139 line[linepos++] = '}'; /* End quote group */
4140 line[linepos++] = SP; /* add a space */
4141 line[linepos] = NUL; /* and a NUL */
4144 if (!quote) { /* Built-in operator... */
4146 if (sexprc) goto xdosexp;
4153 /* An empty value is not a legal number */
4154 /* but it is a legal truth value */
4155 if (x != SX_AND && x != SX_LOR && x != SX_NOT) {
4156 printf("?Not Numeric - \"%s\"\n",p[i+1]);
4164 /* Switch to floating-point upon encountering any f.p. arg */
4165 /* OR... if integer is too big */
4166 if (!fpflag) if (xxfloat(s2,0) == 2)
4170 if (i == 1) { /* Initial result is first operand */
4171 result = (n == 2 && x == SX_SUB) ? 0-j : j;
4172 fpresult = (n == 2 && x == SX_SUB) ? -fpj : fpj;
4173 if ((x == SX_AND && result == 0) || /* Short circuit */
4174 (x == SX_LOR && result != 0))
4176 if (!(kwflags & SXF_ONE)) /* Command with single arg */
4179 if (x == SX_MOD || x == SX_DIV) {
4183 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4188 switch (x) { /* Accumulate result */
4190 case SX_EVA: /* EVAL */
4195 case SX_ADD: /* + */
4199 if (result != fpresult)
4201 #endif /* FNFLOAT */
4204 case SX_SUB: /* - */
4208 if (result != fpresult)
4210 #endif /* FNFLOAT */
4213 case SX_MUL: /* * */
4217 if (result != fpresult)
4219 #endif /* FNFLOAT */
4222 case SX_AND: /* AND */
4223 result = result && j;
4224 if (!result) quit++;
4225 fpresult = fpresult && fpj;
4228 case SX_LOR: /* OR */
4229 result = result || j;
4230 if (!result) quit++;
4231 fpresult = fpresult || fpj;
4234 case SX_MOD: /* Modulus */
4235 result = result % j;
4237 fpresult = (CKFLOAT)fmod(fpresult,fpj);
4238 if (result != fpresult)
4242 #endif /* FNFLOAT */
4245 case SX_DIV: /* / */
4250 if (result != fpresult)
4252 #endif /* FNFLOAT */
4258 #endif /* FNFLOAT */
4262 case SX_AEQ: /* Test for equality */
4264 if (fpresult != fpj)
4272 case SX_NEQ: /* Test for ineqality */
4274 if (fpresult == fpj)
4282 case SX_ALE: /* Arithmetic less-equal */
4294 case SX_ALT: /* Arithmetic less-than */
4296 if (fpj <= fpresult)
4306 case SX_AGT: /* Arithmetic greater-than */
4308 if (fpj >= fpresult)
4318 case SX_AGE: /* Arithmetic greater-equal */
4330 case SX_POW: /* Raise to power */
4336 } else if ((!fpresult && fpj <= 0.0)) {
4337 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4340 } else if (fpresult < 0.0 && modf(fpj,&dummy)) {
4341 printf("?Domain error - \"%s\"\n",cmdbuf);
4345 fpresult = (CKFLOAT)pow(fpresult,fpj);
4348 #endif /* FNFLOAT */
4352 CK_OFF_T z, sign = 0;
4355 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4366 result = 1 / result;
4369 if (result != fpresult)
4371 #endif /* FNFLOAT */
4375 case SX_EXP: /* e to the given power */
4376 fpresult = (CKFLOAT) exp(fpj);
4379 case SX_LGN: /* Natural log */
4380 case SX_LGX: /* Log base 10 */
4381 case SX_SQR: /* Square root */
4383 printf("?Argument out of range - \"%s\"\n",cmdbuf);
4388 fpresult = (CKFLOAT) sqrt(fpj);
4389 else if (x == SX_LGN)
4390 fpresult = (CKFLOAT) log(fpj);
4392 fpresult = (CKFLOAT) log10(fpj);
4395 case SX_SIN: /* sine */
4396 fpresult = (CKFLOAT) sin(fpj);
4399 case SX_COS: /* cosine */
4400 fpresult = (CKFLOAT) cos(fpj);
4403 case SX_TAN: /* tangent */
4404 fpresult = (CKFLOAT) tan(fpj);
4406 #endif /* FNFLOAT */
4408 case SX_CEI: /* Ceiling */
4417 case SX_FLR: /* Floor */
4426 case SX_TRU: /* Truncate */
4432 case SX_ROU: /* Round */
4442 case SX_ABS: /* Absolute value */
4443 result = (j < 0) ? 0 - j : j;
4445 fpresult = (fpj < 0.0) ? 0.0 - fpj : fpj;
4446 if (result != fpresult)
4448 #endif /* FNFLOAT */
4451 case SX_MAX: /* Max */
4462 case SX_MIN: /* Min */
4473 case SX_FLO: /* Float */
4479 case SX_NOT: /* NOT (reverse truth value) */
4484 case SX_BWA: /* Bitwise AND */
4489 case SX_BWO: /* Bitwise OR */
4494 case SX_BWX: /* Bitwise XOR */
4495 case SX_XOR: /* Logical XOR */
4497 printf("?Too many operands - \"%s\"\n",s);
4505 result = (result && !j) || (!result && j);
4506 if (result) result = 1;
4510 case SX_BWN: /* Bitwise Not */
4516 printf("BAD OP [%s]\n",p[1]);
4520 if (!pflag) /* Not a predicate */
4521 sexppv = -1; /* So unset this */
4525 if (macro) { /* User-defined macro */
4526 extern int fsexpflag; /* (see fneval():ckuus4.c) */
4527 int lookagain = 0; /* Maybe the macro table changed */
4528 if (mactab[mx].kwd) { /* Check and see */
4529 if (ckstrcmp(mactab[mx].kwd,p[1],-1,0))
4533 if (lookagain) { /* The table changed */
4534 mx = mxlook(mactab,p[1],nmac); /* Get the macro's new index */
4535 debug(F111,sexpdebug("macro moved"),p[1],mx);
4536 if (mx < 0) { /* Yikes! */
4537 printf("?Macro disappeared! - \"%s\"\n",p[1]);
4542 debug(F111,sexpdebug("macro mx"),mactab[mx].kwd,mx);
4543 if (fsexpflag) { /* If embedded in a function call */
4544 if (cmpush() > -1) { /* get a new copy of the parsing */
4545 extern int ifc; /* environment, */
4546 int k, ifcsav = ifc; /* save the IF state */
4547 dodo(mx,line,0); /* Set up the macro */
4548 k = parser(1); /* Call the parser to execute it */
4549 cmpop(); /* Pop back to previous level */
4550 ifc = ifcsav; /* restore IF state */
4551 if (k == 0) /* If no error */
4552 s2 = mrval[maclvl+1]; /* get return value, if any */
4554 debug(F110,sexpdebug("macro return"),s2,0);
4556 printf("?Resources exhausted - \"%s\"\n",s);
4559 } else { /* Not embedded in a function call */
4560 dodo(mx,line,0); /* As above but without cmpush/pop() */
4563 s2 = mrval[maclvl+1];
4566 } else if (pflag) { /* Predicate */
4567 if (not) presult = presult ? 0 : 1;
4568 sexppv = presult; /* So set predicate value (0 or 1) */
4569 s2 = presult ? "1" : "0";
4570 } else if (fpflag && !sexptrunc) { /* Result is floating-point */
4571 if (not) fpresult = fpresult ? 0.0 : 1.0;
4572 s2 = fpformat(fpresult,0,0);
4573 } else if (x != SX_EVA) {
4574 if (not) result = result ? 0 : 1;
4575 s2 = ckfstoa(result);
4578 /* Common exit point. Always come here to exit. */
4583 if (!sexprc && s2) { /* Have a result */
4585 char * q2 = s2; int xx = 0;
4587 while (*q2++) xx++; /* Get length */
4588 if (xx > sexprmax) /* (stats) */
4592 if (xx > sxrlen[sexpdep] || !sxresult[sexpdep]) {
4596 if (sxresult[sexpdep])
4597 free(sxresult[sexpdep]);
4598 if ((sxresult[sexpdep] = (char *)malloc(k))) {
4599 sxrlen[sexpdep] = k;
4601 printf("?Memory allocation failure - \"%s\"\n",s2);
4605 sx = sxresult[sexpdep]; /* Point to result buffer */
4606 while ((*sx++ = *s2++)) ; /* copy result. */
4607 if (fpflag && truncate) { /* Floating point + truncate */
4608 sx = sxresult[sexpdep]; /* at decimal point */
4609 for (i = xx - 1; i >= 0; i--) {
4612 if (i == 0) { /* If nothing left */
4613 sx[0] = '0'; /* put a zero. */
4620 if (line) /* If macro arg buffer allocated */
4621 free(line); /* free it. */
4622 if (mustfree) { /* And free local copy of split list */
4623 for (i = 1; i <= n; i++) {
4624 if (p[i]) free(p[i]);
4627 debug(F111,sexpdebug("exit"),sxresult[sexpdep],sexprc);
4628 return(sxresult[sexpdep--]);
4633 int /* CHECK command */
4636 if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0)
4638 ckstrncpy(line,atmbuf,LINBUFSIZ);
4639 if ((y = cmcfm()) < 0)
4642 if (!ckstrcmp(line,"push",(int)strlen(line),0)) {
4643 if (msgflg) /* If at top level... */
4644 printf(" push%s available\n", nopush ? " not" : "");
4645 else if (nopush && !backgrd)
4646 printf(" CHECK: push not available\n");
4647 return(success = 1 - nopush);
4651 if (!ckstrcmp(line,"pipes",(int)strlen(line),0)) {
4652 if (msgflg) /* If at top level... */
4653 printf(" pipes%s available\n",
4654 (nopush || protocol != PROTO_K) ? " not" : "");
4655 else if ((nopush || protocol != PROTO_K) && !backgrd)
4656 printf(" CHECK: pipes not available\n");
4657 return(success = 1 - nopush);
4659 #endif /* PIPESEND */
4660 y = lookup(ftrtab,line,nftr,&x); /* Look it up */
4661 debug(F111,"dochk",ftrtab[x].kwd,y);
4662 if (msgflg) /* If at top level... */
4663 printf(" %s%s available\n", ftrtab[x].kwd, y ? " not" : "");
4664 else if (y && !backgrd)
4665 printf(" CHECK: %s not available\n", ftrtab[x].kwd);
4666 return(success = 1 - y);
4672 /* Connection log and elapsed-time reporting */
4674 extern char cxlogbuf[]; /* Log record buffer */
4675 extern char diafil[]; /* Log file name */
4676 extern int dialog, cx_active; /* Flags */
4677 static long cx_prev = 0L; /* Elapsed time of previous session */
4679 #endif /* CKLOGDIAL */
4680 #endif /* NOLOCAL */
4683 dologend() { /* Write record to connection log */
4685 extern int locus, autolocus;
4690 long d1, d2, t1, t2;
4692 #endif /* CKLOGDIAL */
4693 #endif /* NOLOCAL */
4699 debug(F101,"dologend ftpisconnected","",ftpisconnected());
4700 setlocus(ftpisconnected() ? 0 : 1, 1);
4709 debug(F101,"dologend dialog","",dialog);
4710 debug(F101,"dologend cxlogbuf[0]","",cxlogbuf[0]);
4712 debug(F101,"dologend ckxlogging","",ckxlogging);
4713 #endif /* CKSYSLOG */
4715 if (!cx_active || !cxlogbuf[0]) /* No active record */
4718 cx_active = 0; /* Record is not active */
4719 debug(F111,"dologend cxlogbuf 1",cxlogbuf,cx_active);
4721 d1 = mjd((char *)cxlogbuf); /* Get start date of this session */
4722 ckstrncpy(buf,ckdate(),31); /* Get current date */
4723 d2 = mjd(buf); /* Convert them to mjds */
4724 p = cxlogbuf; /* Get start time */
4726 p[14] = NUL; /* Convert to seconds */
4727 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4730 p = buf; /* Get end time */
4733 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4734 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */
4735 debug(F101,"dologend t2","",t2);
4739 debug(F110,"dologend hhmmss",p,0);
4740 ckstrncat(cxlogbuf,"E=",CXLOGBUFL); /* Append to log record */
4741 ckstrncat(cxlogbuf,p,CXLOGBUFL);
4742 debug(F110,"dologend cxlogbuf 2",cxlogbuf,0);
4745 debug(F101,"dologend cx_prev","",cx_prev);
4746 if (dialog) { /* If logging */
4748 x = diaopn(diafil,1,1); /* Open log in append mode */
4749 debug(F101,"dologend diaopn","",x);
4750 x = zsoutl(ZDIFIL,cxlogbuf); /* Write the record */
4751 debug(F101,"dologend zsoutl","",x);
4752 x = zclose(ZDIFIL); /* Close the log */
4753 debug(F101,"dologend zclose","",x);
4756 debug(F101,"dologend ckxlogging","",ckxlogging);
4759 x = ckindex("T=DIAL",cxlogbuf,0,0,1);
4760 debug(F111,"dologend ckxsyslog",cxlogbuf,ckxsyslog);
4761 debug(F111,"dologend ckindex","T=DIAL",x);
4763 if (ckxsyslog >= SYSLG_DI) {
4764 debug(F110,"dologend syslog",cxlogbuf+18,0);
4765 cksyslog(SYSLG_DI,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4766 } else if (ckxsyslog >= SYSLG_AC) {
4767 debug(F110,"dologend syslog",cxlogbuf+18,0);
4768 cksyslog(SYSLG_AC,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4772 #endif /* CKSYSLOG */
4773 #endif /* CKLOGDIAL */
4774 #endif /* NOLOCAL */
4780 /* D O L O G S H O W -- Show session/connection info */
4782 /* Call with fc == 1 to show, fc == 0 to only calculate. */
4783 /* Returns session elapsed time in seconds. */
4784 /* If no session active, returns elapsed time of previous session, if any, */
4788 dologshow(fc) int fc; { /* SHOW (current) CONNECTION */
4789 long d1, d2, t1, t2 = 0, prev;
4790 char c, buf1[32], buf2[32], * info[32], * p, * s;
4791 char * xlogbuf, xbuf[CXLOGBUFL+1];
4792 int i, x = 0, z, ftp = 0, active = 0;
4795 extern char ftplogbuf[];
4796 extern long ftplogprev;
4797 extern int ftplogactive;
4801 xlogbuf = ftplogbuf;
4803 active = ftplogactive;
4814 debug(F101,"dologshow local","",local);
4815 debug(F101,"dologshow ftp","",ftp);
4816 debug(F111,"dologshow active",xlogbuf,active);
4820 if (didsetlin || ftp)
4821 printf(" %s: No record.\n", ftp ? "FTP" : "Kermit");
4823 printf(" %s: No connection.\n", ftp ? "FTP" : "Kermit");
4830 z = ftpisconnected() ? 1 : -1;
4833 if (local) { /* See if we have an open connection */
4835 debug(F101,"dologshow ttchk","",z);
4836 z = (z > -1) ? 1 : -2;
4838 z = active ? 1 : -2;
4849 /* Note: NOT ckstrncpy! */
4850 strncpy(buf1,xlogbuf,17); /* Copy of just the timestamp */
4851 buf1[17] = NUL; /* Terminate it */
4852 ckstrncpy(xbuf,xlogbuf+18,CXLOGBUFL); /* Copy that can be poked */
4853 debug(F111,"dologshow prev",xbuf,prev);
4855 xwords(xbuf,31,info,1); /* Break up into fields */
4856 d1 = mjd(buf1); /* Convert start time to MJD */
4857 ckstrncpy(buf2,ckdate(),31); /* Current date */
4858 d2 = mjd(buf2); /* Convert to MJD */
4859 p = buf1; /* Point to start time */
4861 p[14] = NUL; /* Convert to seconds */
4862 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4865 p = buf2; /* Ditto for current time */
4869 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4870 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Elapsed time so far */
4874 if (t2 > -1L) /* Convert seconds to hh:mm:ss */
4882 printf("\n"); /* Show results */
4883 printf(" Status: %s\n",s);
4884 printf(" Opened: %s\n",buf1);
4885 printf(" User: %s\n",info[1] ? info[1] : "");
4886 printf(" PID: %s\n",info[2] ? info[2] : "");
4887 for (i = 3; info[i]; i++) {
4889 s = (info[i]) ? info[i]+2 : "";
4891 case 'T': printf(" Type: %s\n", s); break;
4892 case 'N': printf(" To: %s\n", s); break;
4893 case 'P': printf(" Port: %s\n", s); break;
4894 case 'H': printf(" From: %s\n", s); break;
4895 case 'D': printf(" Device: %s\n", s); break;
4896 case 'O': printf(" Origin: %s\n", s); break;
4898 default: printf(" %s\n",info[i] ? info[i] : "");
4902 printf(" Elapsed time: %s\n", hhmmss(t2));
4904 printf(" Elapsed time: %s\n", p ? p : "(unknown)");
4908 if ( IS_SSH() ) x++;
4909 #endif /* SSHBUILTIN */
4910 #ifdef CK_ENCRYPTION
4911 if (ck_tn_encrypting() && ck_tn_decrypting()) x++;
4912 #endif /* CK_ENCRYPTION */
4914 if (tls_active_flag || ssl_active_flag) x++;
4918 #ifdef CK_ENCRYPTION
4919 if (ttnproto == NP_EK4LOGIN || ttnproto == NP_EK5LOGIN) x++;
4920 #endif /* CK_ENCRYPTION */
4921 #endif /* CK_KERBEROS */
4922 #endif /* RLOGCODE */
4923 #endif /* NETCONN */
4925 printf(" Encrypted: %s\n", x ? "Yes" : "No");
4926 printf(" Log: %s\n", dialog ? diafil : "(none)");
4929 return(t2 > -1L ? t2 : 0L);
4937 dologend(); /* Previous session not closed out? */
4938 cx_active = 1; /* Record is active */
4940 p = ckdate(); /* Get timestamp */
4941 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL-1); /* Start record off with it */
4943 debug(F100,"dologline uidbuf empty","",0);
4944 #ifdef UNIX /* Who has whoami()... */
4945 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4948 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4950 ckstrncpy(uidbuf,"UNKNOWN",UIDBUFLEN);
4951 #endif /* STRATUS */
4954 m = strlen(uidbuf) + strlen(myhost) + strlen(ttname) + 32;
4955 if (n+m < CXLOGBUFL-1) { /* Add serial device info */
4957 sprintf(p," %s %s T=SERIAL H=%s D=%s ", /* SAFE */
4964 ckstrncpy(cxlogbuf,"LOGLINE BUFFER OVERFLOW",CXLOGBUFL);
4965 debug(F110,"dologline",cxlogbuf,0);
4971 char * p, * s = "NET", * uu = uidbuf;
4976 dologend(); /* Previous session not closed out? */
4978 cx_active = 1; /* Record is active */
4980 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL);
4982 if (nettype == NET_TCPB || nettype == NET_TCPA) {
4985 } else if (nettype == NET_SSH) {
4989 #endif /* TCPSOCKET */
4991 if (nettype == NET_SX25 || nettype == NET_VX25 || nettype == NET_IX25)
4995 if (nettype == NET_DEC)
4999 if (nettype == NET_SLAT)
5001 #endif /* SUPERLAT */
5003 if (nettype == NET_BIOS)
5005 #endif /* CK_NETBIOS */
5008 debug(F100,"dolognet uidbuf empty","",0);
5009 #ifdef OS2ORUNIX /* Who has whoami()... */
5010 uu = (char *)whoami();
5013 uu = (char *)whoami();
5016 #endif /* STRATUS */
5023 if ((k = ckindex(":",h,0,0,0)) > 0) {
5027 int svcnum = gettcpport();
5029 port = ckitoa(svcnum);
5034 #endif /* TCPSOCKET */
5035 m = strlen(uu) + strlen(myhost) + strlen(ttname) + strlen(s) + 32;
5036 if (n+m < CXLOGBUFL-1) { /* SAFE */
5038 sprintf(p," %s %s T=%s N=%s H=%s P=%s ",
5047 ckstrncpy(cxlogbuf,"LOGNET BUFFER OVERFLOW",CXLOGBUFL);
5048 debug(F110,"dolognet cxlogbuf",cxlogbuf,0);
5049 if (h) makestr(&h,NULL);
5051 #endif /* NETCONN */
5052 #endif /* CKLOGDIAL */
5056 Parse a DIAL-related string, stripping enclosing braces, if any.
5059 dialstr(p,msg) char **p; char *msg; {
5063 if ((x = cmtxt(msg, "", &s, xxstring)) < 0)
5065 s = brstrip(s); /* Strip braces around. */
5066 debug(F110,"dialstr",s,0);
5067 makestr(p,*s?s:NULL);
5068 return(success = 1);
5076 mdmtyp = x; /* Set global modem type */
5077 debug(F101,"initmdm mdmtyp","",mdmtyp);
5078 debug(F101,"initmdm usermdm","",usermdm);
5081 m = usermdm ? usermdm : mdmtyp;
5083 p = modemp[m]; /* Point to modem info struct, and */
5084 /* debug(F101,"initmdm p","",p); */
5086 dialec = p->capas & CKD_EC; /* set DIAL ERROR-CORRECTION, */
5087 dialdc = p->capas & CKD_DC; /* DIAL DATA-COMPRESSION, and */
5088 mdmspd = p->capas & CKD_SB ? 0 : 1; /* DIAL SPEED-MATCHING from it. */
5089 dialfc = FLO_AUTO; /* Modem's local flow control.. */
5090 dialmax = p->max_speed;
5091 dialcapas = p->capas;
5092 dialesc = p->esc_char;
5093 } else if (mdmtyp > 0) {
5094 printf("WARNING: modem info for \"%s\" not filled in yet\n",
5099 /* Reset or set the SET DIAL STRING items ... */
5103 debug(F110,"initmdm dialini",dialini,0);
5104 debug(F110,"initmdm dialmstr ",dialmstr,0);
5105 debug(F110,"initmdm dialmprmt",dialmprmt,0);
5106 debug(F110,"initmdm dialcmd",dialcmd,0);
5107 debug(F110,"initmdm dialdcon",dialdcon,0);
5108 debug(F110,"initmdm dialdcoff",dialdcoff,0);
5109 debug(F110,"initmdm dialecon",dialecon,0);
5110 debug(F110,"initmdm dialecoff",dialecoff,0);
5111 debug(F110,"initmdm dialhcmd",dialhcmd,0);
5112 debug(F110,"initmdm dialhwfc",dialhwfc,0);
5113 debug(F110,"initmdm dialswfc",dialswfc,0);
5114 debug(F110,"initmdm dialnofc",dialnofc,0);
5115 debug(F110,"initmdm dialtone",dialtone,0);
5116 debug(F110,"initmdm dialpulse",dialpulse,0);
5117 debug(F110,"initmdm dialname",dialname,0);
5118 debug(F110,"initmdm dialaaon",dialaaon,0);
5119 debug(F110,"initmdm dialaaoff",dialaaoff,0);
5120 debug(F110,"initmdm dialx3",dialx3,0);
5121 debug(F110,"initmdm dialspon",dialspon,0);
5122 debug(F110,"initmdm dialspoff",dialspoff,0);
5123 debug(F110,"initmdm dialvol1",dialvol1,0);
5124 debug(F110,"initmdm dialvol2",dialvol2,0);
5125 debug(F110,"initmdm dialvol3",dialvol3,0);
5126 debug(F110,"initmdm dialini2",dialini2,0);
5130 if (usermdm && p) { /* USER-DEFINED: copy info from specified template */
5132 makestr(&dialini ,p->wake_str);
5133 makestr(&dialmstr ,p->dmode_str);
5134 makestr(&dialmprmt,p->dmode_prompt);
5135 makestr(&dialcmd ,p->dial_str);
5136 makestr(&dialdcon ,p->dc_on_str);
5137 makestr(&dialdcoff,p->dc_off_str);
5138 makestr(&dialecon ,p->ec_on_str);
5139 makestr(&dialecoff,p->ec_off_str);
5140 makestr(&dialhcmd ,p->hup_str);
5141 makestr(&dialhwfc ,p->hwfc_str);
5142 makestr(&dialswfc ,p->swfc_str);
5143 makestr(&dialnofc ,p->nofc_str);
5144 makestr(&dialtone ,p->tone);
5145 makestr(&dialpulse,p->pulse);
5146 makestr(&dialname ,"This space available (use SET MODEM NAME)");
5147 makestr(&dialaaon ,p->aa_on_str);
5148 makestr(&dialaaoff,p->aa_off_str);
5149 makestr(&dialx3 ,p->ignoredt);
5150 makestr(&dialspon ,p->sp_on_str);
5151 makestr(&dialspoff,p->sp_off_str);
5152 makestr(&dialvol1 ,p->vol1_str);
5153 makestr(&dialvol2 ,p->vol2_str);
5154 makestr(&dialvol3 ,p->vol3_str);
5155 makestr(&dialini2 ,p->ini2);
5157 } else { /* Not user-defined, so wipe out overrides */
5159 if (dialini) makestr(&dialini,NULL); /* Init-string */
5160 if (dialmstr) makestr(&dialmstr,NULL); /* Dial-mode-str */
5161 if (dialmprmt) makestr(&dialmprmt,NULL); /* Dial-mode-pro */
5162 if (dialcmd) makestr(&dialcmd,NULL); /* Dial-command */
5163 if (dialdcon) makestr(&dialdcon,NULL); /* DC ON command */
5164 if (dialdcoff) makestr(&dialdcoff,NULL); /* DC OFF command */
5165 if (dialecon) makestr(&dialecon,NULL); /* EC ON command */
5166 if (dialecoff) makestr(&dialecoff,NULL); /* EC OFF command */
5167 if (dialhcmd) makestr(&dialhcmd,NULL); /* Hangup command */
5168 if (dialhwfc) makestr(&dialhwfc,NULL); /* Flow control... */
5169 if (dialswfc) makestr(&dialswfc,NULL); /* */
5170 if (dialnofc) makestr(&dialnofc,NULL); /* */
5171 if (dialtone) makestr(&dialtone,NULL); /* Dialing method */
5172 if (dialpulse) makestr(&dialpulse,NULL); /* */
5173 if (dialname) makestr(&dialname,NULL); /* Modem name */
5174 if (dialaaon) makestr(&dialaaon,NULL); /* Autoanswer On */
5175 if (dialaaoff) makestr(&dialaaoff,NULL); /* Autoanswer Off */
5176 if (dialx3) makestr(&dialx3,NULL); /* Ignore dialtone */
5177 if (dialspon) makestr(&dialspon,NULL); /* Speaker On */
5178 if (dialspoff) makestr(&dialspoff,NULL); /* Speaker Off */
5179 if (dialvol1) makestr(&dialvol1,NULL); /* Low volume */
5180 if (dialvol2) makestr(&dialvol2,NULL); /* Medium volume */
5181 if (dialvol3) makestr(&dialvol3,NULL); /* High volume */
5182 if (dialini2) makestr(&dialini2,NULL); /* Init string 2 */
5184 if (autoflow) /* Maybe change flow control */
5189 tbmodel = 0; /* If it's a Telebit, we don't know the model yet */
5190 #endif /* OLDTBCODE */
5191 #endif /* MINIDIAL */
5195 /* Not implemented yet */
5199 extern int ans_cid, ans_ring;
5200 if ((x = cmkey(answertab,nanswertab,"","",xxstring)) < 0)
5204 return(seton(&ans_cid));
5206 y = cmnum("How many rings before answering","1",10,&x,xxstring);
5207 y = setnum(&ans_rings,x,y,254);
5211 #endif /* COMMENT */
5214 setmodem() { /* SET MODEM */
5222 "Modem parameter","","",nsetmdm, 0, xxstring, setmdm, &k2);
5223 cmfdbi(&k2,_CMKEY,"","","",nmdm,0,xxstring,mdmtab,NULL);
5225 if (x < 0) { /* Error */
5226 if (x == -2 || x == -9)
5227 printf("?No keywords match: \"%s\"\n",atmbuf);
5230 y = cmresult.nresult; /* Keyword value */
5231 if (cmresult.fdbaddr == &k2) { /* Modem-type keyword table */
5232 if ((x = cmcfm()) < 0)
5235 initmdm(cmresult.nresult); /* Set the modem type. */
5236 return(success = 1); /* Done */
5238 switch (cmresult.nresult) { /* SET MODEM keyword table. */
5240 case XYDMHU: /* DIAL MODEM-HANGUP */
5241 if ((y = cmkey(mdmhang,4,"how to hang up modem",
5242 "modem-command", xxstring)) < 0)
5244 if ((x = cmcfm()) < 0)
5248 /* Nope, I fixed it (2001 11 08) */
5250 if (dialmhu == 0 && !quiet) {
5252 "\n WARNING: RS-232 signal sampling and manipulation do not work\n"
5255 " in the standard SCO OSR5 serial i/o drivers. SET MODEM HANGUP-METHOD\n"
5258 " MODEM-COMMAND is recommended for OSR5.\n\n"
5261 #endif /* CK_SCOV5 */
5262 #endif /* COMMENT */
5263 return(success = 1);
5270 if ((y = cmkey(mdmcap,nmdmcap,
5271 "capability of modem", "", xxstring)) < 0) {
5279 if ((x = cmcfm()) < 0)
5282 debug(F101,"setmodem autoflow","",autoflow);
5283 debug(F101,"setmodem flow 1","",flow);
5284 if (autoflow) /* Maybe change flow control */
5286 debug(F101,"setmodem flow 2","",flow);
5287 mdmspd = zz & CKD_SB ? 0 : 1; /* Set MODEM SPEED-MATCHING from it. */
5288 return(success = 1);
5292 if (network && istncomport())
5293 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
5295 #endif /* TN_COMPORT */
5296 x = cmkey(spdtab,nspd,line,"",xxstring);
5298 if (x == -3) printf("?value required\n");
5301 if ((y = cmcfm()) < 0) return(y);
5302 dialmax = (long) x * 10L;
5303 if (dialmax == 70) dialmax = 75;
5304 return(success = 1);
5306 case XYDSTR: /* These moved from SET DIAL */
5317 if ((y = cmkey(mdmtab,nmdm,"modem type","none", xxstring)) < 0)
5319 if (y == dialudt) { /* User-defined modem type */
5320 if ((x = cmkey(mdmtab,nmdm,"based on existing modem type",
5321 "unknown", xxstring)) < 0)
5324 if ((z = cmcfm()) < 0)
5327 usermdm = (y == dialudt) ? x : 0;
5329 mdmset = (mdmtyp > 0);
5330 return(success = 1);
5333 return(dialstr(&dialname,"Descriptive name for modem"));
5335 case XYDMCD: /* SET MODEM CARRIER-WATCH */
5338 case XYDSPK: /* SET MODEM SPEAKER */
5339 return(seton(&mdmspk));
5341 case XYDVOL: /* SET MODEM VOLUME */
5342 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0)
5344 if ((y = cmcfm()) < 0)
5347 return(success = 1);
5350 printf("Unexpected SET MODEM parameter\n");
5355 static int /* Set DIAL command options */
5361 if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0)
5364 case XYDHUP: /* DIAL HANGUP */
5365 return(seton(&dialhng));
5366 case XYDINI: /* DIAL INIT-STRING */
5367 return(dialstr(&dialini,"Modem initialization string"));
5368 case XYDNPR: /* DIAL PREFIX */
5369 return(dialstr(&dialnpr,"Telephone number prefix"));
5370 case XYDDIA: /* DIAL DIAL-COMMAND */
5371 x = cmtxt("Dialing command for modem,\n\
5372 include \"%s\" to stand for phone number,\n\
5373 for example, \"set dial dial-command ATDT%s\\13\"",
5377 if (x < 0 && x != -3) /* Handle parse errors */
5379 s = brstrip(s); /* Strip braces or quotes */
5380 y = x = strlen(s); /* Get length of text */
5381 if (y > 0) { /* If there is any text (left), */
5382 for (x = 0; x < y; x++) { /* make sure they included "%s" */
5383 if (s[x] != '%') continue;
5384 if (s[x+1] == 's') break;
5388 "?Dial-command must contain \"%cs\" for phone number.\n",'%');
5392 if (dialcmd) { /* Free any previous string. */
5394 dialcmd = (char *) 0;
5397 dialcmd = malloc(y + 1); /* Allocate space for it */
5399 strcpy(dialcmd,s); /* and make a safe copy. */
5401 return(success = 1);
5403 case XYDKSP: /* DIAL KERMIT-SPOOF */
5404 return(seton(&dialksp));
5406 case XYDTMO: /* DIAL TIMEOUT */
5407 y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);
5408 if (y < 0) return(y);
5409 y = cmnum("Kermit/modem timeout differential","10",10,&z,xxstring);
5410 if (y < 0) return(y);
5411 if ((y = cmcfm()) < 0)
5415 case XYDESC: /* DIAL ESCAPE-CHARACTER */
5416 y = cmnum("ASCII value of character to escape back to modem",
5417 "43",10,&x,xxstring);
5418 y = setnum(&dialesc,x,y,128);
5419 if (y > -1 && dialesc < 0) /* No escape character */
5420 dialmhu = 0; /* So no hangup by modem command */
5422 case XYDDPY: /* DIAL DISPLAY */
5423 return(seton(&dialdpy));
5424 case XYDSPD: /* DIAL SPEED-MATCHING */
5425 /* used to be speed-changing */
5426 if ((y = seton(&mdmspd)) < 0) return(y);
5428 mdmspd = 1 - mdmspd; /* so here we reverse the meaning */
5429 #endif /* COMMENT */
5430 return(success = 1);
5431 case XYDMNP: /* DIAL MNP-ENABLE */
5432 case XYDEC: /* DIAL ERROR-CORRECTION */
5435 if (!dialec) dialdc = 0; /* OFF also turns off compression */
5438 case XYDDC: /* DIAL COMPRESSION */
5441 if (dialdc) dialec = 1; /* ON also turns on error correction */
5445 case XYDMHU: /* DIAL MODEM-HANGUP */
5446 return(seton(&dialmhu));
5450 case XYDDIR: /* DIAL DIRECTORY (zero or more) */
5451 return(parsdir(0)); /* 0 means DIAL */
5454 case XYDSTR: /* DIAL STRING */
5455 if ((y = cmkey(mdmcmd,nmdmcmd,"","",xxstring)) < 0) return(y);
5457 case XYDS_AN: /* Autoanswer ON/OFF */
5458 case XYDS_DC: /* Data compression ON/OFF */
5459 case XYDS_EC: /* Error correction ON/OFF */
5460 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
5462 sprintf(tmpbuf,"Modem's command to %sable %s", /* SAFE */
5464 (y == XYDS_DC) ? "compression" :
5465 ((y == XYDS_EC) ? "error-correction" :
5470 return(dialstr(&dialdcon,tmpbuf));
5471 else if (y == XYDS_EC)
5472 return(dialstr(&dialecon,tmpbuf));
5474 return(dialstr(&dialaaon,tmpbuf));
5477 return(dialstr(&dialdcoff,tmpbuf));
5478 else if (y == XYDS_EC)
5479 return(dialstr(&dialecoff,tmpbuf));
5481 return(dialstr(&dialaaoff,tmpbuf));
5483 case XYDS_HU: /* hangup command */
5484 return(dialstr(&dialhcmd,"Modem's hangup command"));
5485 case XYDS_HW: /* hwfc */
5486 return(dialstr(&dialhwfc,
5487 "Modem's command to enable hardware flow control"));
5488 case XYDS_IN: /* init */
5489 return(dialstr(&dialini,"Modem's initialization string"));
5490 case XYDS_NF: /* no flow control */
5491 return(dialstr(&dialnofc,
5492 "Modem's command to disable local flow control"));
5493 case XYDS_PX: /* prefix */
5494 return(dialstr(&dialnpr,"Telephone number prefix for dialing"));
5495 case XYDS_SW: /* swfc */
5496 return(dialstr(&dialswfc,
5497 "Modem's command to enable local software flow control"));
5498 case XYDS_DT: /* tone dialing */
5499 return(dialstr(&dialtone,
5500 "Command to configure modem for tone dialing"));
5501 case XYDS_DP: /* pulse dialing */
5502 return(dialstr(&dialpulse,
5503 "Command to configure modem for pulse dialing"));
5504 case XYDS_MS: /* dial mode string */
5505 return(dialstr(&dialmstr,
5506 "Command to enter dial mode"));
5507 case XYDS_MP: /* dial mode prompt */
5508 return(dialstr(&dialmprmt,
5509 "Modem response upon entering dial mode"));
5510 case XYDS_SP: /* SPEAKER OFF */
5511 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x);
5513 return(dialstr(&dialspon,"Command to turn modem speaker on"));
5515 return(dialstr(&dialspoff,"Command to turn modem speaker off"));
5517 case XYDS_VO: /* VOLUME LOW */
5518 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0) return(x);
5522 return(dialstr(&dialvol1,
5523 "Command for low modem speaker volume"));
5525 return(dialstr(&dialvol2,
5526 "Command for medium modem speaker volume"));
5529 return(dialstr(&dialvol3,
5530 "Command for high modem speaker volume"));
5535 case XYDS_ID: /* IGNORE-DIALTONE */
5536 return(dialstr(&dialx3,
5537 "Command to tell modem to ignore dialtone"));
5539 case XYDS_I2: /* PREDIAL-INIT */
5540 return(dialstr(&dialini2,
5541 "Command to send to modem just prior to dialing"));
5544 printf("?Unexpected SET DIAL STRING parameter\n");
5547 case XYDFC: /* DIAL FLOW-CONTROL */
5548 if ((y = cmkey(dial_fc,4,"","auto",xxstring)) < 0) return(y);
5549 if ((x = cmcfm()) < 0) return(x);
5551 return(success = 1);
5553 case XYDMTH: { /* DIAL METHOD */
5554 extern int dialmauto;
5555 if ((y = cmkey(dial_m,ndial_m,"","default",xxstring)) < 0)
5557 if ((x = cmcfm()) < 0)
5559 if (y == XYDM_A) { /* AUTO */
5560 dialmauto = 1; /* local country code, if known. */
5563 dialmauto = 0; /* use the method specified */
5566 return(success = 1);
5569 y = cmnum("Number of times to try dialing a number",
5570 "1",10,&x,xxstring);
5571 z = setnum(&dialrtr,x,y,-1);
5572 if (z > -1 && dialrtr < 0) {
5573 printf("?Sorry, negative dial retries not valid: %d\n",dialrtr);
5579 y = cmnum("Seconds to wait between redial attempts",
5580 "30",10,&x,xxstring);
5581 z = setnum(&dialint,x,y,-1);
5582 if (z > -1 && dialint < 0) {
5583 printf("?Sorry, negative dial interval not valid: %d\n",dialint);
5588 case XYDLAC: /* DIAL AREA-CODE */
5589 if ((x = dialstr(&diallac,"Area code you are calling from")) < 0)
5592 if (!rdigits(diallac)) {
5593 printf("?Sorry, area code must be numeric\n");
5594 if (*diallac == '(')
5595 printf("(please omit the parentheses)\n");
5596 if (*diallac == '/')
5597 printf("(no slashes, please)\n");
5598 if (diallac) free(diallac);
5605 case XYDCNF: /* CONFIRMATION */
5606 return(success = seton(&dialcnf));
5608 case XYDCVT: /* CONVERT-DIRECTORY */
5609 if ((y = cmkey(dcnvtab,3,"","ask",xxstring)) < 0)
5611 if ((x = cmcfm()) < 0)
5614 return(success = 1);
5616 case XYDLCC: /* DIAL COUNTRY-CODE */
5617 x = dialstr(&diallcc,"Country code you are calling from");
5618 if (x < 1) return(x);
5620 if (!rdigits(diallcc)) {
5621 printf("?Sorry, country code must be numeric\n");
5622 if (*diallcc == '+')
5623 printf("(please omit the plus sign)\n");
5624 if (diallcc) free(diallcc);
5628 if (!strcmp(diallcc,"1")) { /* Set defaults for USA and Canada */
5629 if (!dialldp) /* Long-distance prefix */
5630 makestr(&dialldp,"1");
5631 if (!dialixp) /* International dialing prefix */
5632 makestr(&dialixp,"011");
5633 if (ntollfree == 0) { /* Toll-free area codes */
5634 if ((dialtfc[0] = malloc(4))) {
5635 strcpy(dialtfc[0],"800"); /* 1970-something */
5637 if ((dialtfc[1] = malloc(4))) {
5638 strcpy(dialtfc[1],"888"); /* 1996 */
5640 if ((dialtfc[2] = malloc(4))) {
5641 strcpy(dialtfc[2],"877"); /* 5 April 1998 */
5643 if ((dialtfc[3] = malloc(4))) {
5644 strcpy(dialtfc[3],"866"); /* 2000? */
5651 if (!dialtfp) /* Toll-free dialing prefix */
5652 makestr(&dialtfp,"1");
5654 /* The time for this is past */
5655 } else if (!strcmp(diallcc,"358") &&
5656 ((int) strcmp(zzndate(),"19961011") > 0)
5658 if (!dialldp) /* Long-distance prefix */
5659 makestr(&dialldp,"9");
5660 if (!dialixp) /* International dialing prefix */
5661 makestr(&dialixp,"990");
5662 #endif /* COMMENT */
5663 } else { /* Everywhere else ... */
5665 if ((dialldp = malloc(4)))
5666 strcpy(dialldp,"0");
5669 if ((dialixp = malloc(4)))
5670 strcpy(dialixp,"00");
5673 if (!strcmp(diallcc,"33")) /* France */
5674 dialfld = 1; /* Long-distance dialing is forced */
5676 return(success = 1);
5678 case XYDIXP: /* DIAL INTL-PREFIX */
5679 return(dialstr(&dialixp,"International dialing prefix"));
5681 case XYDIXS: /* DIAL INTL-SUFFIX */
5682 return(dialstr(&dialixs,"International dialing suffix"));
5684 case XYDLDP: /* DIAL LD-PREFIX */
5685 return(dialstr(&dialldp,"Long-distance dialing prefix"));
5687 case XYDLDS: /* DIAL LD-SUFFIX */
5688 return(dialstr(&diallds,"Long-distance dialing suffix"));
5690 case XYDLCP: /* DIAL LC-PREFIX */
5691 return(dialstr(&diallcp,"Local dialing prefix"));
5693 case XYDLCS: /* DIAL LC-SUFFIX */
5694 return(dialstr(&diallcs,"Local dialing suffix"));
5697 case XYDPXX: /* DIAL PBX-EXCHANGE */
5698 return(dialstr(&dialpxx,"Exchange of PBX you are calling from"));
5699 #endif /* COMMENT */
5701 case XYDPXI: { /* DIAL PBX-INTERNAL-PREFIX */
5703 return(dialstr(&dialpxi,
5704 "Internal-call prefix of PBX you are calling from"));
5707 if ((x = cmtxt("Internal-call prefix of PBX you are calling from",
5708 "",&s,NULL)) < 0) /* Don't evaluate */
5712 char c, * p = tmpbuf;
5715 if (isupper(c)) c = tolower(c);
5717 ckstrcmp(s,"\\v(d$px)",8,0) &&
5718 ckstrcmp(s,"\\v(d$pxx)",9,0) &&
5719 ckstrcmp(s,"\\v(d$p)",7,0)) {
5727 makestr(&dialpxi,s);
5730 #endif /* COMMENT */
5732 case XYDPXO: /* DIAL PBX-OUTSIDE-PREFIX */
5733 return(dialstr(&dialpxo,
5734 "Outside-line prefix of PBX you are calling from"));
5736 case XYDSFX: /* DIAL INTL-SUFFIX */
5737 return(dialstr(&dialsfx," Telephone number suffix for dialing"));
5739 case XYDSRT: /* DIAL SORT */
5740 return(success = seton(&dialsrt));
5742 case XYDPXX: /* DIAL PBX-EXCHANGE */
5743 case XYDTFC: { /* DIAL TOLL-FREE-AREA-CODE */
5744 int n, i; /* (zero or more of them...) */
5745 char * p[MAXTOLLFREE]; /* Temporary pointers */
5747 for (n = 0; n < MAXTOLLFREE; n++) {
5750 "Toll-free area code(s) in the country you are calling from"
5751 : "Exchange(s) of PBX you are calling from";
5754 "Another toll-free area code"
5755 : "Another PBX exchange";
5757 if ((x = cmfld(m,"",&s,xxstring)) < 0)
5761 k = (int) strlen(s);
5763 if ((p[n] = malloc(k + 1)))
5764 strcpy(p[n], s); /* safe */
5768 if (x == -3) { /* Command was successful */
5770 m = (y == XYDTFC) ? ntollfree : ndialpxx;
5771 if ((x = cmcfm()) < 0)
5774 for (i = 0; i < m; i++) { /* Remove old list, if any */
5776 makestr(&(dialtfc[i]),NULL);
5778 makestr(&(dialpxx[i]),NULL);
5781 ntollfree = n; /* New count */
5784 for (i = 0; i < n; i++) { /* New list */
5786 makestr(&(dialtfc[i]),p[i]);
5788 makestr(&(dialpxx[i]),p[i]);
5792 for (i = 0; i < n; i++)
5793 if (p[i]) free(p[i]);
5797 case XYDTFP: /* TOLL-FREE-PREFIX */
5798 return(dialstr(&dialtfp,
5799 " Long-distance prefix for toll-free dialing"));
5801 case XYDCON: /* CONNECT */
5803 if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);
5804 if (y != CAR_OFF) /* AUTO or ON? */
5805 if ((z = cmkey(qvtab,nqvt,"","verbose",xxstring)) < 0) return(z);
5806 if ((x = cmcfm()) < 0) return(x);
5810 return(success = 1);
5812 case XYDRSTR: /* RESTRICT */
5813 if ((y = cmkey(drstrtab,4,"","none",xxstring)) < 0) return(y);
5814 if ((x = cmcfm()) < 0) return(x);
5816 return(success = 1);
5818 case XYDLLAC: { /* Local area-code list */
5819 int n, i; /* (zero or more of them...) */
5820 char * p[MAXLOCALAC]; /* Temporary pointers */
5821 for (n = 0; n < MAXLOCALAC; n++) {
5823 "Area code to which calls from your area are local",
5824 "",&s,xxstring)) < 0)
5828 k = (int) strlen(s);
5830 if ((p[n] = malloc(k + 1)))
5831 strcpy(p[n], s); /* safe */
5835 if (x == -3) { /* Command was successful */
5836 if ((x = cmcfm()) < 0)
5838 for (i = 0; i < nlocalac; i++) /* Remove old list, if any */
5843 nlocalac = n; /* New count */
5844 for (i = 0; i < nlocalac; i++) /* New list */
5846 return(success = 1);
5847 } else { /* Parse error, undo everything */
5848 for (i = 0; i < n; i++)
5849 if (p[i]) free(p[i]);
5855 return(success = seton(&dialfld));
5857 case XYDIDT: /* DIAL IGNORE-DIALTONE */
5858 return(seton(&dialidt));
5862 "Milliseconds to pause between each character sent to dialer",
5864 return(setnum(&dialpace,x,y,9999));
5868 if ((x = cmfld("Name of macro to execute just prior to dialing",
5869 "",&s,xxstring)) < 0) {
5879 ckstrncpy(line,s,LINBUFSIZ);
5883 if ((x = cmcfm()) < 0)
5885 makestr(&dialmac,s);
5886 return(success = 1);
5889 case XYDPUCC: /* Pulse country codes */
5890 case XYDTOCC: { /* Tone country codes */
5894 for (n = 0; n < MAXTPCC; n++) {
5896 m = (y == XYDPUCC) ?
5897 "Country code where Pulse dialing is required"
5898 : "Country code where Tone dialing is available";
5900 m = "Another country code";
5901 if ((x = cmfld(m,"",&s,xxstring)) < 0)
5905 k = (int) strlen(s);
5907 if ((p[n] = malloc(k + 1)))
5908 strcpy(p[n], s); /* safe */
5912 if (x == -3) { /* Command was successful */
5914 m = (y == XYDPUCC) ? ndialpucc : ndialtocc;
5915 if ((x = cmcfm()) < 0)
5918 for (i = 0; i < m; i++) { /* Remove old list, if any */
5920 makestr(&(dialpucc[i]),NULL);
5922 makestr(&(dialtocc[i]),NULL);
5925 ndialpucc = n; /* New count */
5929 for (i = 0; i < n; i++) { /* New list */
5931 makestr(&(dialpucc[i]),p[i]);
5933 makestr(&(dialtocc[i]),p[i]);
5938 for (i = 0; i < n; i++)
5939 if (p[i]) free(p[i]);
5943 return(seton(&dialtest));
5946 printf("?Unexpected SET DIAL parameter\n");
5952 int /* SHOW MODEM */
5961 printf("Sorry, command disabled\r\n");
5962 return(success = 0);
5969 mdm = (mdmtyp > 0) ? mdmtyp : mdmsav;
5970 p = (mdm > 0) ? modemp[mdm] : NULL;
5973 printf(" %s\n\n", dialname ? dialname : p->name);
5975 printf(" Modem capabilities: ");
5976 zz = dialcapas ? dialcapas : p->capas;
5980 if (zz & CKD_AT) printf(" AT");
5981 if (zz & CKD_V25) printf(" ITU");
5982 if (zz & CKD_SB) printf(" SB");
5983 if (zz & CKD_EC) printf(" EC");
5984 if (zz & CKD_DC) printf(" DC");
5985 if (zz & CKD_HW) printf(" HWFC");
5986 if (zz & CKD_SW) printf(" SWFC");
5987 if (zz & CKD_KS) printf(" KS");
5988 if (zz & CKD_TB) printf(" TB");
5990 printf("\n Modem carrier-watch: ");
5991 if (carrier == CAR_OFF) printf("off\n");
5992 else if (carrier == CAR_ON) printf("on\n");
5993 else if (carrier == CAR_AUT) printf("auto\n");
5994 else printf("unknown\n");
5996 printf(" Modem maximum-speed: ");
5997 zz = (dialmax > 0L) ? dialmax : p->max_speed;
5999 printf("%ld bps\n", zz);
6001 printf("(unknown)\n");
6002 printf(" Modem error-correction: %s\n", dialec ? "on" : "off");
6003 printf(" Modem compression: %s\n", dialdc ? "on" : "off");
6004 printf(" Modem speed-matching: %s", mdmspd ? "on" : "off");
6005 printf(" (interface speed %s)\n", mdmspd ? "changes" : "is locked");
6006 printf(" Modem flow-control: ");
6007 if (dialfc == FLO_NONE) printf("none\n");
6008 else if (dialfc == FLO_XONX) printf("xon/xoff\n");
6009 else if (dialfc == FLO_RTSC) printf("rts/cts\n");
6010 else if (dialfc == FLO_AUTO) printf("auto\n");
6011 printf(" Modem hangup-method: %s\n",
6016 printf(" Modem speaker: %s\n", showoff(mdmspk));
6017 printf(" Modem volume: %s\n",
6018 (mdmvol == 2) ? "medium" : ((mdmvol <= 1) ? "low" : "high"));
6019 printf(" Modem kermit-spoof: %s\n", dialksp ? "on" : "off");
6020 c = (char) (x = (dialesc ? dialesc : p->esc_char));
6021 printf(" Modem escape-character: %d", x);
6023 printf(" (= \"%c\")",c);
6025 "\n\nMODEM COMMANDs (* = set automatically by SET MODEM TYPE):\n\n");
6026 debug(F110,"show dialini",dialini,0);
6027 printf(" %c Init-string: ", dialini ? ' ' : '*' );
6028 shods(dialini ? dialini : p->wake_str);
6029 printf(" %c Dial-mode-string: ", dialmstr ? ' ' : '*' );
6030 shods(dialmstr ? dialmstr : p->dmode_str);
6031 n = local ? 19 : 20;
6032 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6033 printf(" %c Dial-mode-prompt: ", dialmprmt ? ' ' : '*' );
6034 shods(dialmprmt ? dialmprmt : p->dmode_prompt);
6035 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6036 printf(" %c Dial-command: ", dialcmd ? ' ' : '*' );
6037 shods(dialcmd ? dialcmd : p->dial_str);
6038 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6039 printf(" %c Compression on: ", dialdcon ? ' ' : '*' );
6041 debug(F110,"dialdcon","(null)",0);
6043 debug(F110,"dialdcon",dialdcon,0);
6044 shods(dialdcon ? dialdcon : p->dc_on_str);
6045 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6046 printf(" %c Compression off: ", dialdcoff ? ' ' : '*' );
6047 shods(dialdcoff ? dialdcoff : p->dc_off_str);
6048 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6049 printf(" %c Error-correction on: ", dialecon ? ' ' : '*' );
6050 shods(dialecon ? dialecon : p->ec_on_str);
6051 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6052 printf(" %c Error-correction off: ", dialecoff ? ' ' : '*' );
6053 shods(dialecoff ? dialecoff : p->ec_off_str);
6054 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6055 printf(" %c Autoanswer on: ", dialaaon ? ' ' : '*' );
6056 shods(dialaaon ? dialaaon : p->aa_on_str);
6057 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6058 printf(" %c Autoanswer off: ", dialaaoff ? ' ' : '*' );
6059 shods(dialaaoff ? dialaaoff : p->aa_off_str);
6060 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6062 printf(" %c Speaker on: ", dialspon ? ' ' : '*' );
6063 shods(dialspon ? dialspon : p->sp_on_str);
6064 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6065 printf(" %c Speaker off: ", dialspoff ? ' ' : '*' );
6066 shods(dialspoff ? dialspoff : p->sp_off_str);
6067 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6068 printf(" %c Volume low: ", dialvol1 ? ' ' : '*' );
6069 shods(dialvol1 ? dialvol1 : p->vol1_str);
6070 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6071 printf(" %c Volume medium: ", dialvol2 ? ' ' : '*' );
6072 shods(dialvol2 ? dialvol2 : p->vol2_str);
6073 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6074 printf(" %c Volume high: ", dialvol3 ? ' ' : '*' );
6075 shods(dialvol3 ? dialvol3 : p->vol3_str);
6076 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6078 printf(" %c Hangup-command: ", dialhcmd ? ' ' : '*' );
6079 shods(dialhcmd ? dialhcmd : p->hup_str);
6080 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6081 printf(" %c Hardware-flow: ", dialhwfc ? ' ' : '*' );
6082 shods(dialhwfc ? dialhwfc : p->hwfc_str);
6083 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6084 printf(" %c Software-flow: ", dialswfc ? ' ' : '*' );
6085 shods(dialswfc ? dialswfc : p->swfc_str);
6086 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6087 printf(" %c No-flow-control: ", dialnofc ? ' ' : '*' );
6088 shods(dialnofc ? dialnofc : p->nofc_str);
6089 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6090 printf(" %c Pulse: ", dialpulse ? ' ' : '*');
6091 shods(dialpulse ? dialpulse : p->pulse);
6092 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6093 printf(" %c Tone: ", dialtone ? ' ' : '*');
6094 shods(dialtone ? dialtone : p->tone);
6096 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6097 printf(" %c Ignore-dialtone: ", dialx3 ? ' ' : '*');
6098 shods(dialx3 ? dialx3 : p->ignoredt);
6100 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6101 printf(" %c Predial-init: ", dialini2 ? ' ' : '*');
6102 shods(dialini2 ? dialini2 : p->ini2);
6104 if (++n > cmd_rows - 4) if (!askmore()) return(0); else n = 0;
6105 printf("\n For more info: SHOW DIAL and SHOW COMMUNICATIONS\n");
6107 } else if (mdm > 0) {
6108 printf("Modem info for \"%s\" not filled in yet\n", gmdmtyp());
6110 " No modem selected, so DIAL and most SET MODEM commands have no effect.\n\
6111 Use SET MODEM TYPE to select a modem.\n");
6112 return(success = 1);
6118 int /* TAPI action commands */
6124 printf("\nTAPI is unavailable on this system.\n");
6127 if ((y = cmkey(tapitab,ntapitab,"MS TAPI command","",xxstring)) < 0)
6130 case XYTAPI_CFG: { /* TAPI CONFIGURE-LINE */
6131 extern struct keytab * tapilinetab;
6132 extern struct keytab * _tapilinetab;
6133 extern int ntapiline;
6134 extern int LineDeviceId;
6135 int lineID=LineDeviceId;
6137 cktapiBuildLineTable(&tapilinetab, &_tapilinetab, &ntapiline);
6138 if (tapilinetab && _tapilinetab && ntapiline > 0) {
6139 int i=0, j = 9999, k = -1;
6141 if ( LineDeviceId == -1 ) {
6142 /* Find out what the lowest numbered TAPI device is */
6143 /* and use it as the default. */
6144 for (i = 0; i < ntapiline; i++ ) {
6145 if (tapilinetab[i].kwval < j) {
6150 /* Find the LineDeviceId in the table and use that entry */
6151 for (i = 0; i < ntapiline; i++ ) {
6152 if (tapilinetab[i].kwval == LineDeviceId) {
6159 s = _tapilinetab[k].kwd;
6163 if ((y = cmkey(_tapilinetab,ntapiline,
6164 "TAPI device name",s,xxstring)) < 0)
6168 if ((x = cmcfm()) < 0) return(x);
6171 printf("Sorry, command disabled\r\n");
6172 return(success = 0);
6175 cktapiConfigureLine(lineID);
6178 case XYTAPI_DIAL: /* TAPI DIALING-PROPERTIES */
6179 if ((x = cmcfm()) < 0)
6183 printf("Sorry, command disabled\r\n");
6184 return(success = 0);
6187 cktapiDialingProp();
6190 return(success = 1);
6193 static int /* SET TAPI command options */
6199 printf("\nTAPI is unavailable on this system.\n");
6202 if ((y = cmkey(settapitab,nsettapitab,"MS TAPI option","",xxstring)) < 0)
6206 return (success = seton(&tapiusecfg));
6208 return (success = seton(&tapilights));
6210 return (success = seton(&tapipreterm));
6212 return (success = seton(&tapipostterm));
6214 y = cmnum("seconds of inactivity before auto-disconnect",
6215 "0",10,&x,xxstring);
6216 return(setnum(&tapiinactivity,x,y,65535));
6218 y = cmnum("seconds to wait for credit card tone",
6219 "8",10,&x,xxstring);
6220 return(setnum(&tapibong,x,y,90));
6222 return (success = seton(&tapimanual));
6223 case XYTAPI_CON: /* TAPI CONVERSIONS */
6224 return (success = setonaut(&tapiconv));
6225 case XYTAPI_LIN: /* TAPI LINE */
6226 x = setlin(XYTAPI_LIN,1,0);
6227 if (x > -1) didsetlin++;
6229 case XYTAPI_PASS: { /* TAPI PASSTHROUGH */
6231 printf("\n?Modem-dialing not supported\n");
6234 /* Passthrough became Modem-dialing which is an antonym */
6235 success = seton(&tapipass);
6236 tapipass = !tapipass;
6240 case XYTAPI_LOC: { /* TAPI LOCATION */
6241 extern char tapiloc[];
6242 extern int tapilocid;
6243 int i = 0, j = 9999, k = -1;
6245 cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
6246 if (!tapiloctab || !ntapiloc) {
6247 printf("\nNo TAPI Locations are configured for this system\n");
6250 if (tapilocid == -1)
6251 tapilocid = cktapiGetCurrentLocationID();
6253 /* Find the current tapiloc entry */
6254 /* and use it as the default. */
6255 for (k = 0; k < ntapiloc; k++) {
6256 if (tapiloctab[k].kwval == tapilocid)
6259 if (k >= 0 && k < ntapiloc)
6260 s = tapiloctab[k].kwd;
6264 if ((y = cmkey(tapiloctab,ntapiloc, "TAPI location",s,xxstring)) < 0)
6267 if ((x = cmcfm()) < 0)
6271 printf("Sorry, command disabled\r\n");
6272 return(success = 0);
6275 cktapiFetchLocationInfoByID( y );
6277 CopyTapiLocationInfoToKermitDialCmd();
6284 #endif /* CK_TAPI */
6285 #endif /* NOLOCAL */
6288 /* Method for evaluating \%x and \&x[] variables */
6290 static struct keytab varevaltab[] = {
6291 { "recursive", 1, 0 },
6294 static int nvarevaltab = (sizeof(varevaltab) / sizeof(struct keytab));
6301 extern int * xvarev;
6303 extern int xvarev[];
6304 #endif /* DCMDBUF */
6306 if ((x = cmkey(varevaltab,
6308 "Method for evaluating \\%x and \\&x[] variables",
6312 if ((y = cmcfm()) < 0)
6316 return(success = 1);
6319 #ifdef CK_ANSIC /* SET ALARM */
6324 setalarm(xx) long xx;
6325 #endif /* CK_ANSIC */
6328 int yyyy, mm, dd, x;
6332 #endif /* COMMENT */
6336 debug(F101,"setalarm xx","",xx);
6337 ck_alarm = 0L; /* 0 = no alarm (in case of error) */
6339 printf("%ld - illegal value, must be 0 or positive\n", xx);
6342 if (xx == 0L) { /* CLEAR ALARM */
6348 x = 8; /* Get current date */
6350 if (zzstring("\\v(ndate)",&s,&x) < 0) {
6351 printf("Internal date error, sorry.\n");
6355 x = 5; /* Get current time */
6357 if (zzstring("\\v(ntime)",&s,&x) < 0) {
6358 printf("Internal time error, sorry.\n");
6362 sprintf(buf,"%05ld",atol(alrm_time)); /* SAFE (20) */
6363 ckstrncpy(alrm_time,buf,8);
6364 debug(F110,"SET ALARM date (1)",alrm_date,0);
6365 debug(F110,"SET ALARM time (1)",alrm_time,0);
6367 if ((zz = atol(alrm_time) + xx) < 0L) {
6368 printf("Internal time conversion error, sorry.\n");
6371 if (zz >= 86400L) { /* Alarm crosses midnight */
6372 char d[10]; /* Local date buffer */
6373 int lastday; /* Last day of this month */
6375 ckstrncpy(d,alrm_date,8); /* We'll have to change the date */
6377 x = (zz / 86400L); /* How many days after today */
6379 dd = atoi((char *)(d+6)); /* Parse yyyymmdd */
6380 d[6] = NUL; /* into yyyy, mm, dd ... */
6381 mm = atoi((char *)(d+4));
6383 yyyy = atoi((char *)d);
6385 /* How many days in this month */
6387 lastday = mdays[mm];
6388 if (mm == 2 && yyyy % 4 == 0) /* Works thru 2099 AD... */
6391 if (dd + x > lastday) { /* Dumb loop */
6394 x -= (mdays[mm] - dd); /* Deduct rest of this month's days */
6396 /* There's a more elegant way to do this... */
6399 mm++; /* Next month */
6400 if (mm > 12) { /* Wrap around */
6401 mm = 1; /* Jan, next year */
6404 y = mdays[mm]; /* Days in new month */
6405 if (mm == 2 && yyyy % 4 == 0) /* Feb in leap year */
6406 y++; /* Works until 2100 AD */
6411 dd = x; /* Day of alarm month */
6414 sprintf(alrm_date,"%04d%02d%02d",yyyy,mm,dd); /* SAFE (24) */
6417 sprintf(alrm_time,"%ld",zz); /* SAFE (24) */
6418 debug(F110,"SET ALARM date (2)",alrm_date,0);
6419 debug(F110,"SET ALARM time (2)",alrm_time,0);
6423 ckstrncpy(xbuf,ckcvtdate("",1),20); /* Get current date and time */
6425 ckstrncpy(alrm_date,xbuf,10);
6427 sec = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
6428 debug(F110,"SET ALARM date (1)",alrm_date,0);
6429 debug(F101,"SET ALARM time (1)","",sec);
6430 if ((sec += xx) < 0L) {
6431 printf("Internal time conversion error, sorry.\n");
6434 if (sec >= 86400L) { /* Alarm crosses midnight */
6436 days = sec / 86400L;
6437 jd = mjd(p) + days; /* Get modified Julian date */
6438 ckstrncpy(alrm_date,mjd2date(jd),10);
6441 sprintf(alrm_time,"%05ld",sec); /* SAFE (24) */
6442 debug(F110,"SET ALARM date (2)",alrm_date,0);
6443 debug(F110,"SET ALARM time (2)",alrm_time,0);
6444 ck_alarm = 1; /* Alarm is set */
6446 #endif /* COMMENT */
6447 return(success = 1);
6453 dosetkey() { /* SET KEY */
6456 int kc; /* Key code */
6457 char *s; /* Key binding */
6459 char *p; /* Worker */
6460 #endif /* NOKVERBS */
6468 y = cmnum("numeric key code, or the word CLEAR,","",10,&kc,xxstring);
6471 debug(F111,"SET KEY",atmbuf,y);
6472 if (y == -2) { /* Not a valid number */
6473 if ((y = strlen(atmbuf)) < 0) /* Check for SET KEY CLEAR */
6475 if (ckstrcmp(atmbuf,"clear",y,0))
6477 if ((x = cmcfm()) < 0)
6479 for (y = 0; y < KMSIZE; y++) {
6480 keymap[y] = (KEY) y;
6484 keymapinit(); /* Special OS/2 initializations */
6485 initvik = 1; /* Update the VIK table */
6488 } else if (y == -3) { /* SET KEY <Return> */
6489 printf(" Press key to be defined: "); /* Prompt for a keystroke */
6493 #endif /* NOSETBUF */
6495 conbin((char)escape); /* Put terminal in binary mode */
6497 os2gks = 0; /* Turn off Kverb preprocessing */
6499 kc = congks(0); /* Get character or scan code */
6501 os2gks = 1; /* Turn on Kverb preprocessing */
6503 concb((char)escape); /* Restore terminal to cbreak mode */
6504 if (kc < 0) { /* Check for error */
6505 printf("?Error reading key\n");
6509 shokeycode(kc,-1); /* Show current definition */
6511 shokeycode(kc); /* Show current definition */
6513 flag = 1; /* Remember it's a multiline command */
6518 /* Normal SET KEY <scancode> <value> command... */
6525 if (kc < 0 || kc >= KMSIZE) {
6526 printf("?key code must be between 0 and %d\n", KMSIZE - 1);
6530 printf("Sorry, %d is the CONNECT-mode escape character\n",kc);
6537 cmsavp(psave,PROMPTL);
6538 cmsetp(" Enter new definition: ");
6546 if ((y = cmtxt("key definition,\n\
6547 or Ctrl-C to cancel this command,\n\
6548 or Enter to restore default definition",
6550 if (flag) /* Handle parse errors */
6557 p = s; /* Save this place */
6558 #endif /* NOKVERBS */
6560 If the definition included any \Kverbs, quote the backslash so the \Kverb
6561 will still be in the definition when the key is pressed. We don't do this
6562 in zzstring(), because \Kverbs are valid only in this context and nowhere
6565 We use this code active for all versions that support SET KEY, even if they
6566 don't support \Kverbs, because otherwise \K would behave differently for
6569 for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
6571 (s[x] == 'K' || s[x] == 'k')
6574 if ((x == 1 && s[x-1] == CMDQ) ||
6575 (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
6576 line[y++] = CMDQ; /* Make it \\K */
6578 if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
6579 line[y-1] = CMDQ; /* Have \{K */
6580 line[y++] = '{'; /* Make it \\{K */
6585 line[y++] = NUL; /* Terminate */
6586 s = line + y + 1; /* Point to after it */
6587 x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
6588 if ((x < (LINBUFSIZ / 2)) ||
6589 (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
6590 printf("?Key definition too long\n");
6591 if (flag) cmsetp(psave);
6594 s = line + y + 1; /* Point to result. */
6598 Special case: see if the definition starts with a \Kverb.
6599 If it does, point to it with p, otherwise set p to NULL.
6604 p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
6606 #endif /* NOKVERBS */
6608 if (macrotab[kc]) { /* Possibly free old macro from key. */
6609 free((char *)macrotab[kc]);
6610 macrotab[kc] = NULL;
6612 switch (strlen(s)) { /* Action depends on length */
6613 case 0: /* Reset to default binding */
6614 keymap[kc] = (KEY) kc;
6616 case 1: /* Single character */
6617 keymap[kc] = (CHAR) *s;
6619 default: /* Character string */
6622 y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
6623 debug(F101,"set key kverb lookup",0,y); /* exact match required */
6625 keymap[kc] = F_KVERB | y;
6629 #endif /* NOKVERBS */
6630 keymap[kc] = (KEY) kc;
6631 macrotab[kc] = (MACRO) malloc(strlen(s)+1);
6633 strcpy((char *) macrotab[kc], s); /* safe */
6636 if (flag) cmsetp(psave);
6638 initvik = 1; /* Update VIK table */
6642 #endif /* NOSETKEY */
6645 struct keytab stoptbl[] = {
6649 #endif /* STOPBITS */
6651 static struct keytab sertbl[] = {
6663 #endif /* HWPARITY */
6669 #endif /* HWPARITY */
6672 static int nsertbl = (sizeof(sertbl) / sizeof(struct keytab)) - 1;
6674 static char * sernam[] = { /* Keep this in sync with sertbl[] */
6675 "7E1", "7E2", "7M1", "7M2", "7O1", "7O2", "7S1", "7S2",
6676 "8N1", "8E1", "8E2", "8N2", "8O1", "8O2"
6679 static struct keytab optstab[] = { /* SET OPTIONS table */
6681 { "delete", XXDEL, 0}, /* DELETE */
6682 #endif /* NOFRILLS */
6683 { "directory", XXDIR, 0}, /* DIRECTORY */
6685 { "purge", XXPURGE, 0}, /* PURGE */
6686 #endif /* CKPURGE */
6687 { "type", XXTYP, 0}, /* TYPE */
6690 static int noptstab = (sizeof(optstab) / sizeof(struct keytab)) - 1;
6694 PROTOCOL SELECTION. Kermit is always available. If CK_XYZ is defined at
6695 compile time, then the others become selections also. In OS/2 and
6696 Windows, they are integrated and the various SET commands (e.g. "set file
6697 type") affect them as they would Kermit. In other OS's (UNIX, VMS, etc),
6698 they are external protocols which are run via Kermit's REDIRECT mechanism.
6699 All we do is collect and verify the filenames and pass them along to the
6702 struct keytab protos[] = {
6704 "g", PROTO_G, CM_INV,
6706 "kermit", PROTO_K, 0,
6708 "other", PROTO_O, 0,
6709 "x", PROTO_X, CM_INV|CM_ABR,
6710 "xmodem", PROTO_X, 0,
6711 "xmodem-crc", PROTO_XC, 0,
6712 "y", PROTO_Y, CM_INV|CM_ABR,
6713 "ymodem", PROTO_Y, 0,
6714 "ymodem-g", PROTO_G, 0,
6715 "zmodem", PROTO_Z, 0
6718 int nprotos = (sizeof(protos) / sizeof(struct keytab));
6720 #ifndef XYZ_INTERNAL
6722 #define EXP_HANDLER 1
6723 #define EXP_STDERR 2
6726 static struct keytab extprotab[] = {
6727 { "handler", EXP_HANDLER, 0 },
6728 { "redirect-stderr", EXP_STDERR, 0 },
6729 { "timeout", EXP_TIMO, 0 }
6731 static int nxtprotab = (sizeof(extprotab) / sizeof(struct keytab));
6733 #endif /* XYZ_INTERNAL */
6737 _PROTOTYP(static int protofield, (char *, char *, char *));
6738 _PROTOTYP(static int setproto, (void));
6741 protofield(current, help, px) char * current, * help, * px; {
6743 char *s, tmpbuf[XPCMDLEN+1];
6746 if (current) /* Put braces around default */
6747 ckmakmsg(tmpbuf,TMPBUFSIZ,"{",current,"}",NULL);
6751 if ((x = cmfld(help, (char *)tmpbuf, &s, xxstring)) < 0)
6753 if ((int)strlen(s) > XPCMDLEN) {
6754 printf("?Sorry - maximum length is %d\n", XPCMDLEN);
6757 strcpy(px,s); /* safe */
6765 setproto() { /* Select a file transfer protocol */
6766 /* char * s = NULL; */
6768 char s1[XPCMDLEN+1], s2[XPCMDLEN+1], s3[XPCMDLEN+1];
6769 char s4[XPCMDLEN+1], s5[XPCMDLEN+1], s6[XPCMDLEN+1], s7[XPCMDLEN+1];
6770 char * p1 = s1, * p2 = s2, *p3 = s3;
6771 char * p4 = s4, * p5 = s5, *p6 = s6, *p7 = s7;
6778 #endif /* CK_REDIR */
6779 #endif /* XYZ_INTERNAL */
6787 if ((y = cmkey(protos,nprotos,"","kermit",xxstring)) < 0)
6790 if (x && y != PROTO_K) {
6792 "?Sorry, REDIRECT capability required for external protocols.\n");
6795 if ((x = protofield(ptab[y].h_b_init,
6796 "Optional command to send to host prior to uploading in binary mode",
6799 protocol = y; /* Set protocol but don't change */
6800 return(1); /* anything else */
6804 if ((x = protofield(ptab[y].h_t_init,
6805 "Optional command to send to host prior to uploading in text mode",
6814 if ((x = protofield(ptab[y].h_x_init,
6815 "Optional command to send to host to start Kermit server",
6825 #ifndef XYZ_INTERNAL /* If XYZMODEM are external... */
6828 if ((x = protofield(ptab[y].p_b_scmd,
6829 "External command to SEND in BINARY mode with this protocol",
6836 if ((x = protofield(ptab[y].p_t_scmd,
6837 "External command to SEND in TEXT mode with this protocol",
6844 if ((x = protofield(ptab[y].p_b_rcmd,
6845 "External command to RECEIVE in BINARY mode with this protocol",
6852 if ((x = protofield(ptab[y].p_t_rcmd,
6853 "External command to RECEIVE in TEXT mode with this protocol",
6861 #endif /* XYZ_INTERNAL */
6863 if ((x = cmcfm()) < 0) /* Confirm the command */
6866 protoexit: /* Common exit from this routine */
6871 printf("\n?X,Y, and Zmodem are unavailable\n");
6872 return(success = 0);
6874 #endif /* XYZ_INTERNAL */
6883 initproto(y,p1,p2,p3,p4,p5,p6,p7);
6884 return(success = 1);
6888 #ifndef XYZ_INTERNAL
6890 #define DEF_EXP_TIMO 12 /* Default timeout for external protocol (seconds) */
6892 int exp_handler = 0; /* These are exported */
6893 int exp_timo = DEF_EXP_TIMO;
6894 int exp_stderr = SET_AUTO;
6897 shoextern() { /* Invoked by SHOW PROTOCOL */
6898 printf("\n External-protocol handler: %s\n",
6899 exp_handler ? (exp_handler == 1 ? "pty" : "system") : "automatic");
6901 printf(" External-protocol redirect-stderr: %s\n", showooa(exp_stderr));
6902 #endif /* COMMENT */
6903 printf(" External-protocol timeout: %d (sec)\n", exp_timo);
6906 static struct keytab setexternhandler[] = {
6907 { "automatic", 0, 0 },
6913 setextern() { /* SET EXTERNAL-PROTOCOL */
6915 if ((x = cmkey(extprotab,nxtprotab,"","",xxstring)) < 0)
6919 if ((x = cmkey(setexternhandler,3,"","automatic",xxstring)) < 0)
6921 if ((y = cmcfm()) < 0)
6928 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
6930 if ((y = cmcfm()) < 0)
6934 #endif /* COMMENT */
6937 y = cmnum("Inactivity timeout, seconds,",ckitoa(DEF_EXP_TIMO),
6939 return(setnum(&exp_timo,x,y,-1));
6941 return(success = 1);
6943 #endif /* XYZ_INTERNAL */
6949 if ((y = cmkey(desttab,ndests,"","disk",xxstring)) < 0) return(y);
6950 if ((x = cmcfm()) < 0) return(x);
6957 struct keytab dnettab[] = {
6959 "cterm", NP_CTERM, 0,
6960 #endif /* OS2ONLY */
6963 int ndnet = (sizeof(dnettab) / sizeof(struct keytab));
6966 /* S E T P R I N T E R -- SET PRINTER command */
6969 static struct keytab prntab[] = { /* SET PRINTER switches */
6970 "/bidirectional", PRN_BID, 0,
6972 "/character-set", PRN_CS, CM_ARG,
6974 "/command", PRN_PIP, CM_ARG,
6975 "/dos-device", PRN_DOS, CM_ARG,
6976 "/end-of-job-string",PRN_TRM, CM_ARG,
6977 "/file", PRN_FIL, CM_ARG,
6979 "/flow-control", PRN_FLO, CM_ARG,
6981 "/job-header-file", PRN_SEP, CM_ARG,
6983 "/length", PRN_LEN, CM_ARG,
6985 "/none", PRN_NON, 0,
6987 "/nopostscript", PRN_RAW, 0,
6988 "/nops", PRN_RAW, CM_INV,
6990 "/output-only", PRN_OUT, 0,
6992 "/parity", PRN_PAR, CM_ARG,
6994 "/pipe", PRN_PIP, CM_ARG|CM_INV,
6996 "/postscript", PRN_PS, 0,
6997 "/ps", PRN_PS, CM_INV,
6999 "/separator", PRN_SEP, CM_ARG|CM_INV,
7001 "/speed", PRN_SPD, CM_ARG,
7003 "/timeout", PRN_TMO, CM_ARG,
7004 "/terminator", PRN_TRM, CM_ARG|CM_INV,
7007 "/w", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
7008 "/wi", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
7010 "/width", PRN_WID, CM_ARG,
7013 "/windows-queue", PRN_WIN, CM_ARG,
7017 int nprnswi = (sizeof(prntab) / sizeof(struct keytab)) - 1;
7018 #endif /* PRINTSWI */
7021 setprinter(xx) int xx; {
7024 char * defname = NULL;
7031 long portspeed = 0L;
7037 int c, i, n, wild, confirmed = 0; /* Workers */
7038 int getval = 0; /* Whether to get switch value */
7039 struct stringint pv[PRN_MAX+1]; /* Temporary array for switch values */
7040 struct FDB sw, of, cm; /* FDBs for each parse function */
7043 #endif /* PRINTSWI */
7046 struct keytab * printtab = NULL, * _printtab = NULL;
7047 int nprint = 0, printdef=0;
7051 defname = "PRN"; /* default */
7064 haveque = Win32EnumPrt(&printtab,&_printtab,&nprint,&printdef);
7065 haveque = haveque && nprint;
7068 for (i = 0; i <= PRN_MAX; i++) { /* Initialize switch values */
7069 pv[i].sval = NULL; /* to null pointers */
7070 pv[i].ival = -1; /* and -1 int values */
7071 pv[i].wval = (CK_OFF_T)-1; /* and -1 wide values */
7073 if (xx == XYBDCP) { /* SET BPRINTER == /BIDIRECTIONAL */
7074 pv[PRN_BID].ival = 1;
7075 pv[PRN_OUT].ival = 0;
7078 /* Initialize defaults based upon current printer settings */
7080 defname = printername;
7081 switch (printertype) {
7082 case PRT_WIN: pv[PRN_WIN].ival = 1; break;
7083 case PRT_DOS: pv[PRN_DOS].ival = 1; break;
7084 case PRT_PIP: pv[PRN_PIP].ival = 1; break;
7085 case PRT_FIL: pv[PRN_FIL].ival = 1; break;
7086 case PRT_NON: pv[PRN_NON].ival = 1; break;
7090 /* only set the BIDI flag if we are bidi */
7092 pv[PRN_BID].ival = 1;
7094 /* serial port parameters may be set for non-bidi devices */
7095 pv[PRN_SPD].ival = pportspeed / 10L;
7096 pv[PRN_PAR].ival = pportparity;
7097 pv[PRN_FLO].ival = pportflow;
7100 pv[PRN_TMO].ival = printtimo;
7102 pv[PRN_TRM].ival = 1;
7103 makestr(&pv[PRN_TRM].sval,printterm);
7106 pv[PRN_SEP].ival = 1;
7107 makestr(&pv[PRN_SEP].sval,printsep);
7110 pv[PRN_PS].ival = 1;
7111 pv[PRN_WID].ival = ps_width;
7112 pv[PRN_LEN].ival = ps_length;
7114 pv[PRN_RAW].ival = 1;
7117 /* Set up chained parse functions... */
7119 cmfdbi(&sw, /* First FDB - command switches */
7121 "Switch", /* hlpmsg */
7123 "", /* addtl string data */
7124 nprnswi, /* addtl numeric data 1: tbl size */
7125 4, /* addtl numeric data 2: 4 = cmswi */
7126 xxstring, /* Processing function */
7127 prntab, /* Keyword table */
7128 &cm /* Pointer to next FDB */
7130 cmfdbi(&cm, /* Second fdb for confirmation */
7134 "", /* addtl string data */
7135 0, /* addtl numeric data 1 */
7136 0, /* addtl numeric data 2 */
7141 cmfdbi(&of, /* Third FDB for printer name */
7143 "Printer or file name", /* hlpmsg */
7144 defname, /* default */
7145 "", /* addtl string data */
7146 0, /* addtl numeric data 1: tbl size */
7147 0, /* addtl numeric data 2: 4 = cmswi */
7148 xxstring, /* Processing function */
7153 while (1) { /* Parse 0 or more switches */
7154 x = cmfdb(&sw); /* Parse switch or other thing */
7155 debug(F101,"setprinter cmfdb","",x);
7156 if (x < 0) /* Error */
7157 goto xsetprn; /* or reparse needed */
7158 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
7160 if (cmresult.fdbaddr != &sw) /* Advanced usage :-) */
7162 c = cmgbrk(); /* Get break character */
7163 getval = (c == ':' || c == '='); /* to see how they ended the switch */
7164 n = cmresult.nresult; /* Numeric result = switch value */
7165 debug(F101,"setprinter switch","",n);
7167 switch (n) { /* Process the switch */
7168 case PRN_PS: /* Text to Postscript */
7169 pv[PRN_PS].ival = 1;
7170 pv[PRN_BID].ival = 0;
7171 pv[PRN_OUT].ival = 1;
7172 pv[PRN_RAW].ival = 0;
7175 case PRN_RAW: /* Non-Postscript */
7176 pv[PRN_PS].ival = 0;
7177 pv[PRN_RAW].ival = 1;
7180 case PRN_BID: /* Bidirectional */
7181 pv[PRN_BID].ival = 1;
7182 pv[PRN_OUT].ival = 0;
7183 pv[PRN_PS].ival = 0;
7184 pv[PRN_RAW].ival = 1;
7187 case PRN_OUT: /* Output-only */
7188 pv[PRN_OUT].ival = 1;
7189 pv[PRN_BID].ival = 0;
7190 pv[PRN_PS].ival = 0;
7191 pv[PRN_RAW].ival = 1;
7194 case PRN_NON: /* NONE */
7197 pv[PRN_SPD].ival = 0;
7198 pv[PRN_PAR].ival = 0;
7199 pv[PRN_FLO].ival = FLO_KEEP;
7205 case PRN_DOS: /* DOS printer name */
7206 case PRN_FIL: /* Or filename */
7209 if (pv[n].sval) free(pv[n].sval);
7211 pv[PRN_NON].ival = 0; /* Zero any previous selections */
7212 pv[PRN_WIN].ival = 0;
7213 pv[PRN_DOS].ival = 0;
7214 pv[PRN_FIL].ival = 0;
7215 pv[PRN_PIP].ival = 0;
7216 pv[n].ival = 1; /* Flag this one */
7217 if (!getval) break; /* No value wanted */
7219 if (n == PRN_FIL) { /* File, check accessibility */
7221 if ((x = cmiofi("Filename","kermit.prn",&s,&wild,xxstring))< 0)
7224 printf("Can't create \"%s\"\n",s);
7227 } else goto xsetprn;
7229 printf("?A single file please\n");
7232 pv[PRN_SPD].ival = 0;
7233 pv[PRN_PAR].ival = 0;
7234 pv[PRN_FLO].ival = FLO_KEEP;
7235 } else if ((x = cmfld(n == PRN_DOS ? /* Value wanted - parse it */
7236 "DOS printer device name" : /* Help message */
7241 "PRN" : /* Default */
7247 s = brstrip(s); /* Strip enclosing braces */
7248 while (*s == SP) /* Strip leading blanks */
7250 if (n == PRN_PIP) { /* If /PIPE: */
7251 if (*s == '|') { /* strip any extraneous pipe sign */
7256 pv[PRN_SPD].ival = 0;
7257 pv[PRN_PAR].ival = 0;
7258 pv[PRN_FLO].ival = FLO_KEEP;
7260 if ((y = strlen(s)) > 0) /* Anything left? */
7261 if (pv[n].sval = (char *) malloc(y+1)) /* Yes, keep it */
7262 strcpy(pv[n].sval,s); /* safe */
7265 case PRN_WIN: /* Windows queue name */
7267 if (pv[n].sval) free(pv[n].sval);
7269 pv[PRN_NON].ival = 0;
7270 pv[PRN_DOS].ival = 0;
7271 pv[PRN_FIL].ival = 0;
7273 pv[PRN_SPD].ival = 0;
7274 pv[PRN_PAR].ival = 0;
7275 pv[PRN_FLO].ival = FLO_KEEP;
7277 if (!getval || !haveque)
7279 if ((x = cmkey(_printtab,nprint,"Print queue name",
7280 _printtab[printdef].kwd,xxstring)) < 0) {
7284 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7286 if ((y = strlen(s)) > 0)
7287 if (pv[n].sval = (char *)malloc(y+1))
7288 strcpy(pv[n].sval,s); /* safe */
7290 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7291 for (i = 0; i < nprint; i++) {
7292 if (x == printtab[i].kwval) {
7293 s = printtab[i].kwd;
7297 if ((y = strlen(s)) > 0)
7298 if (pv[n].sval = (char *)malloc(y+1))
7299 strcpy(pv[n].sval,s); /* safe */
7304 case PRN_SEP: /* /JOB-HEADER (separator) */
7305 if (pv[n].sval) free(pv[n].sval);
7309 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0)
7312 printf("?Wildcards not allowed\n");
7316 if ((y = strlen(s)) > 0)
7317 if (pv[n].sval = (char *) malloc(y+1))
7318 strcpy(pv[n].sval,s); /* safe */
7321 case PRN_TMO: /* /TIMEOUT:number */
7324 if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
7327 printf("?Sorry - 999 is the maximum\n");
7334 case PRN_TRM: /* /END-OF-JOB:string */
7335 if (pv[n].sval) free(pv[n].sval);
7339 if ((x = cmfld("String (enclose in braces if it contains spaces)",
7340 "",&s,xxstring)) < 0)
7343 if ((y = strlen(s)) > 0)
7344 if (pv[n].sval = (char *) malloc(y+1))
7345 strcpy(pv[n].sval,s); /* safe */
7351 if ((x = cmkey(flotab,nflo,
7352 "Serial printer-port flow control",
7353 "rts/cts",xxstring)) < 0)
7362 /* TN_COMPORT here too? */
7364 if ((x = cmkey(spdtab, /* Speed (no default) */
7366 "Serial printer-port interface speed",
7373 #endif /* NOLOCAL */
7378 if ((x = cmkey(partbl,npar,"Serial printer-port parity",
7379 "none",xxstring)) < 0)
7388 if ((x = cmnum("PS page length", "66",10,&y,xxstring)) < 0)
7395 if ((x = cmnum("PS page width", "80",10,&y,xxstring)) < 0)
7409 "auto-print/printscreen character-set",
7410 "cp437",xxstring)) < 0)
7417 printf("?Unexpected switch value - %d\n",cmresult.nresult);
7422 line[0] = NUL; /* Initialize printer name value */
7423 switch (cmresult.fcode) { /* How did we get here? */
7424 case _CMOFI: /* They typed a filename */
7425 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
7426 wild = cmresult.nresult; /* Wild flag */
7427 if (!typeset) { /* A printer name without a type */
7428 pv[PRN_NON].ival = 0; /* is supposed to be treated as */
7429 pv[PRN_WIN].ival = 0; /* a DOS or Pipe printer. We */
7430 pv[PRN_FIL].ival = 0; /* clear all the flags and let */
7431 pv[PRN_PIP].ival = 0; /* the code below dope out the */
7432 pv[PRN_DOS].ival = 0; /* type. */
7435 else if (pv[PRN_WIN].ival && lookup(_printtab,line,nprint,&y)) {
7436 /* invalid Window Queue name */
7437 printf("?invalid Windows Printer Queue name: \"%s\"\r\n",line);
7442 if ((x = cmcfm()) < 0) /* Confirm the command */
7445 case _CMCFM: /* They entered the command */
7446 if (pv[PRN_DOS].ival > 0)
7447 ckstrncpy(line,pv[PRN_DOS].sval ? pv[PRN_DOS].sval : "",LINBUFSIZ);
7448 else if (pv[PRN_WIN].ival > 0)
7449 ckstrncpy(line,pv[PRN_WIN].sval ? pv[PRN_WIN].sval : "",LINBUFSIZ);
7450 else if (pv[PRN_FIL].ival > 0)
7451 ckstrncpy(line,pv[PRN_FIL].sval ? pv[PRN_FIL].sval : "",LINBUFSIZ);
7452 else if (pv[PRN_PIP].ival > 0)
7453 ckstrncpy(line,pv[PRN_PIP].sval ? pv[PRN_PIP].sval : "",LINBUFSIZ);
7455 default: /* By mistake */
7456 printf("?Unexpected function code: %d\n",cmresult.fcode);
7461 #else /* No PRINTSWI */
7463 if ((x = cmofi("Printer or file name",defname,&s,xxstring)) < 0)
7466 printf("?Directory names not allowed\n");
7469 while (*s == SP || *s == HT) s++; /* Trim leading whitespace */
7470 ckstrncpy(line,s,LINBUFSIZ); /* Make a temporary safe copy */
7471 if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
7472 #endif /* PRINTSWI */
7475 if (inserver && (isguest
7478 #endif /* NOSERVER */
7480 printf("Sorry, printing disabled\r\n");
7481 return(success = 0);
7487 if (printbidi) { /* If bidi printing active */
7489 bprtstop(); /* Stop it before proceeding */
7493 if (pv[PRN_SPD].ival > 0) {
7494 portspeed = (long) pv[PRN_SPD].ival * 10L;
7495 if (portspeed == 70L) portspeed = 75L;
7497 if (pv[PRN_PAR].ival > 0)
7498 portparity = pv[PRN_PAR].ival;
7499 if (pv[PRN_FLO].ival > 0)
7500 portflow = pv[PRN_FLO].ival;
7502 #endif /* PRINTSWI */
7504 s = line; /* Printer name, if given */
7508 if (pv[PRN_PIP].ival > 0) { /* /PIPE was given? */
7511 if (*s == '|') { /* It might still have a pipe sign */
7512 s++; /* if name give later */
7513 while (*s == SP) /* so remove it and spaces */
7517 #endif /* PRINTSWI */
7518 if (*s == '|') { /* Or pipe implied by name? */
7519 s++; /* Point past pipe sign */
7520 while (*s == SP) /* Gobble whitespace */
7532 if (printpipe && pv[PRN_BID].ival > 0) {
7533 printf("?Sorry, pipes not allowed for bidirectional printer\n");
7537 #endif /* PRINTSWI */
7538 #endif /* OS2ORUNIX */
7541 if ( pv[PRN_CS].ival > 0 )
7542 prncs = pv[PRN_CS].ival;
7544 if ( pv[PRN_PS].ival > 0 ) {
7546 ps_width = pv[PRN_WID].ival <= 0 ? 80 : pv[PRN_WID].ival;
7547 ps_length = pv[PRN_LEN].ival <= 0 ? 66 : pv[PRN_LEN].ival;
7551 y = strlen(s); /* Length of name of new print file */
7554 && ((y != 3) || (ckstrcmp(s,"PRN",3,0) != 0))
7557 if (printername) { /* Had a print file before? */
7558 free(printername); /* Remove its name */
7561 printername = (char *) malloc(y + 1); /* Allocate space for it */
7563 printf("?Memory allocation failure\n");
7566 strcpy(printername,s); /* (safe) Copy new name to new space */
7567 debug(F110,"printername",printername,0);
7571 /* Set printer type from switches that were given explicitly */
7573 if (pv[PRN_NON].ival > 0) { /* No printer */
7574 printertype = PRT_NON;
7577 } else if (pv[PRN_FIL].ival > 0) { /* File */
7578 printertype = PRT_FIL;
7581 } else if (pv[PRN_PIP].ival > 0) { /* Pipe */
7582 printertype = PRT_PIP;
7585 } else if (pv[PRN_WIN].ival > 0) { /* Windows print queue */
7586 printertype = PRT_WIN;
7589 } else if (pv[PRN_DOS].ival > 0) { /* DOS device */
7590 printertype = PRT_DOS;
7593 } else if (line[0]) { /* Name given without switches */
7595 printertype = printpipe ? PRT_PIP : PRT_DOS;
7597 /* was the command SET PRINTER windows-queue ? */
7598 y = lookup(_printtab,line,nprint,&x);
7600 printertype = PRT_WIN;
7601 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7602 if (printername) { /* Had a print file before? */
7603 free(printername); /* Remove its name */
7606 pv[PRN_WIN].sval = NULL;
7607 pv[PRN_WIN].ival = 1;
7608 s = printtab[x].kwd; /* Get full new name */
7609 if ((y = strlen(s)) > 0) {
7610 makestr(&pv[PRN_WIN].sval,s);
7611 makestr(&printername,s);
7613 printf("?Memory allocation failure\n");
7616 debug(F110,"printername",printername,0);
7618 } else if ( y == -2 ) {
7619 /* Ambiguous Print Queue Name */
7620 printf("?Ambiguous printer name provided.\n");
7627 /* Port parameters may be set for non-bidi mode */
7629 pportspeed = portspeed; /* Set parameters */
7630 pportparity = portparity;
7631 pportflow = portflow;
7633 if (pv[PRN_BID].ival > 0) { /* Bidirectional */
7635 printbidi = 1; /* (just to test parsing...) */
7637 printbidi = bprtstart(); /* Start bidirectional printer */
7639 return(success = printbidi);
7641 printbidi = 0; /* Not BPRINTER, unset flag */
7644 if (pv[PRN_TMO].ival > -1) { /* Take care of timeout */
7645 printtimo = pv[PRN_TMO].ival;
7647 if (pv[PRN_TRM].ival > 0) { /* Termination string */
7652 if (pv[PRN_TRM].sval)
7653 makestr(&printterm,pv[PRN_TRM].sval);
7655 if (pv[PRN_SEP].ival > 0) { /* and separator file */
7660 if (pv[PRN_SEP].sval)
7661 makestr(&printsep,pv[PRN_SEP].sval);
7663 #endif /* PRINTSWI */
7669 #endif /* PRINTSWI */
7670 ) { /* File - check access */
7672 printf("?Access denied - %s\n",s);
7677 #endif /* UNIXOROSK */
7679 x = 1; /* Return code */
7681 xsetprn: /* Common exit */
7683 for (i = 0; i <= PRN_MAX; i++) { /* Free malloc'd memory */
7687 #endif /* PRINTSWI */
7688 success = (x > 0) ? 1 : 0;
7693 /* The SET SSH command */
7695 #define SSH_CMD 1 /* SET SSH COMMAND */
7697 #ifdef SSHBUILTIN /* Built-in SET SSH options */
7698 #define SSH_ADD 2 /* Add */
7699 #define SSH_AFW 3 /* Agent-forwarding */
7700 #define SSH_CHI 4 /* Check Host IP */
7701 #define SSH_XFW 5 /* X11-forwarding */
7702 #define SSH_DYF 6 /* Dynamic forwarding */
7703 #define SSH_GWP 7 /* Gatewa portgs */
7704 #define SSH_GSS 8 /* GSSAPI */
7705 #define SSH_KBD 9 /* KBD Interactive Devices */
7706 #define SSH_K4 10 /* Kerberos 4 */
7707 #define SSH_K5 11 /* Kerberos 5 */
7708 #define SSH_SHK 12 /* Strict Host Key Check */
7709 #define SSH_V1 13 /* SSH V1 */
7710 #define SSH_V2 14 /* SSH V2 */
7711 #define SSH_PRP 15 /* Privd port */
7712 #define SSH_CMP 16 /* Compression */
7713 #define SSH_XAL 17 /* X Auth Location */
7714 #define SSH_SHH 18 /* Quiet */
7715 #define SSH_VER 19 /* Version */
7716 #define SSH_VRB 20 /* Verbosity level */
7717 #define SSH_IDF 21 /* Identity File */
7718 #define SSH_CFG 22 /* Use OpenSSH Config */
7719 #define SSH_HBT 23 /* Heartbeat Interval */
7720 #endif /* SSHBUILTIN */
7722 static struct keytab sshtab[] = { /* SET SSH command table */
7724 { "agent-forwarding", SSH_AFW, 0 },
7725 { "check-host-ip", SSH_CHI, 0 },
7726 { "compression", SSH_CMP, 0 },
7727 { "dynamic-forwarding", SSH_DYF, 0 },
7728 { "gateway-ports", SSH_GWP, 0 },
7729 { "gssapi", SSH_GSS, 0 },
7730 { "heartbeat-interval", SSH_HBT, 0 },
7731 { "identity-file", SSH_IDF, 0 },
7733 { "kbd-interactive-devices", SSH_KBD, 0 },
7734 #endif /* COMMENT */
7735 { "k4", SSH_K4, CM_INV },
7736 { "k5", SSH_K5, CM_INV },
7737 { "kerberos4", SSH_K4, 0 },
7738 { "kerberos5", SSH_K5, 0 },
7739 { "krb4", SSH_K4, CM_INV },
7740 { "krb5", SSH_K5, CM_INV },
7741 { "privileged-port", SSH_PRP, 0 },
7742 { "quiet", SSH_SHH, 0 },
7743 { "strict-host-key-check", SSH_SHK, 0 },
7744 { "use-openssh-config", SSH_CFG, 0 },
7745 { "v1", SSH_V1, 0 },
7746 { "v2", SSH_V2, 0 },
7747 { "verbose", SSH_VRB, 0 },
7748 { "version", SSH_VER, 0 },
7749 { "x11-forwarding", SSH_XFW, 0 },
7750 { "xauth-location", SSH_XAL, 0 },
7753 { "command", SSH_CMD, 0 },
7755 #endif /* SSHBUILTIN */
7758 static int nsshtab = (sizeof(sshtab) / sizeof(struct keytab)) - 1;
7761 static struct keytab sshver[] = { /* SET SSH VERSION command table */
7764 { "automatic", 0, 0 }
7781 static struct keytab ssh2aut[] = { /* SET SSH V2 AUTH command table */
7782 { "external-keyx", SSHA_EXT, 0 },
7783 { "gssapi", SSHA_GSS, 0 },
7784 { "hostbased", SSHA_HOS, 0 },
7785 { "keyboard-interactive", SSHA_KBD, 0 },
7786 { "password", SSHA_PSW, 0 },
7787 { "publickey", SSHA_PK, 0 },
7788 { "srp-gex-sha1", SSHA_SRP, 0 },
7791 static int nssh2aut = (sizeof(ssh2aut) / sizeof(struct keytab)) - 1;
7796 static struct keytab addfwd[] = { /* SET SSH ADD command table */
7797 { "local-port-forward", SSHF_LCL, 0 },
7798 { "remote-port-forward", SSHF_RMT, 0 },
7801 static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
7816 static struct keytab sshv1tab[] = { /* SET SSH V1 command table */
7817 { "cipher", SSH1_CIF, 0 },
7818 { "global-known-hosts-file", SSH1_GNH, 0 },
7819 { "k5-reuse-k4-messages", SSH1_K54, CM_INV },
7820 { "user-known-hosts-file", SSH1_UNH, 0 },
7823 static int nsshv1tab = (sizeof(sshv1tab) / sizeof(struct keytab)) - 1;
7825 static struct keytab sshv2tab[] = { /* SET SSH V2 command table */
7826 { "authentication", SSH2_AUT, 0 },
7827 { "auto-rekey", SSH2_ARK, 0 },
7828 { "ciphers", SSH2_CIF, 0 },
7829 { "global-known-hosts-file", SSH2_GNH, 0 },
7830 { "hostkey-algorithms", SSH2_HKA, 0 },
7831 { "macs", SSH2_MAC, 0 },
7832 { "user-known-hosts-file", SSH2_UNH, 0 },
7835 static int nsshv2tab = (sizeof(sshv2tab) / sizeof(struct keytab)) - 1;
7837 #define SSHC_3DES 1 /* 3DES */
7838 #define SSHC_3CBC 2 /* 3DES-CBC */
7839 #define SSHC_A128 3 /* AES128-CBC */
7840 #define SSHC_A192 4 /* AES192-CBC */
7841 #define SSHC_A256 5 /* AES256-CBC */
7842 #define SSHC_ARC4 6 /* ARCFOUR */
7843 #define SSHC_FISH 7 /* BLOWFISH */
7844 #define SSHC_BCBC 9 /* BLOWFISH-CBC */
7845 #define SSHC_C128 8 /* CAST128-CBC */
7846 #define SSHC_1DES 10 /* DES */
7848 static struct keytab ssh1ciphers[] = {
7849 { "3des", SSHC_3DES, 0 },
7850 { "blowfish", SSHC_FISH, 0 },
7851 { "des", SSHC_1DES, 0 },
7854 static int nssh1ciphers = (sizeof(ssh1ciphers) / sizeof(struct keytab)) - 1;
7856 static struct keytab ssh2ciphers[] = { /* SET SSH V2 CIPHERS command table */
7857 { "3des-cbc", SSHC_3DES, 0 },
7858 { "aes128-cbc", SSHC_A128, 0 },
7859 { "aes192-cbc", SSHC_A192, 0 },
7860 { "aes256-cbc", SSHC_A256, 0 },
7861 { "arcfour", SSHC_ARC4, 0 },
7862 { "blowfish-cbc", SSHC_FISH, 0 },
7863 { "cast128-cbc", SSHC_C128, 0 },
7864 { "rijndael128-cbc", SSHC_A128, 0 },
7865 { "rijndael192-cbc", SSHC_A192, 0 },
7866 { "rijndael256-cbc", SSHC_A256, 0 },
7869 static int nssh2ciphers = (sizeof(ssh2ciphers) / sizeof(struct keytab)) - 1;
7871 #define SSHM_SHA 1 /* HMAC-SHA1 */
7872 #define SSHM_SHA_96 2 /* HMAC-SHA1-96 */
7873 #define SSHM_MD5 3 /* HMAC-MD5 */
7874 #define SSHM_MD5_96 4 /* HMAC-MD5-96 */
7875 #define SSHM_RIPE 5 /* HMAC-RIPEMD160 */
7877 static struct keytab ssh2macs[] = { /* SET SSH V2 MACS command table */
7878 { "hmac-md5", SSHM_MD5, 0 },
7879 { "hmac-md5-96", SSHM_MD5_96, 0 },
7880 { "hmac-ripemd160", SSHM_RIPE, 0 },
7881 { "hmac-sha1", SSHM_SHA, 0 },
7882 { "hmac-sha1-96", SSHM_SHA_96, 0 },
7885 static int nssh2macs = (sizeof(ssh2macs) / sizeof(struct keytab)) - 1;
7887 static struct keytab tgtpass[] = {
7888 { "tgt-passing", 1, 0, },
7891 static int ntgtpass = (sizeof(tgtpass) / sizeof(struct keytab)) - 1;
7893 static struct keytab gssapitab[] = {
7894 { "delegate-credentials", 1, 0, },
7895 { "key-exchange", 2, CM_INV, },
7898 static int ngssapitab = (sizeof(gssapitab) / sizeof(struct keytab)) - 1;
7903 static struct keytab hkatab[] = {
7904 { "ssh-dss", HKA_DSS, 0, },
7905 { "ssh-rsa", HKA_RSA, 0, },
7908 static int nhkatab = (sizeof(hkatab) / sizeof(struct keytab)) - 1;
7910 int /* SET SSH variables */
7911 ssh_afw = 0, /* agent forwarding */
7912 ssh_xfw = 0, /* x11 forwarding */
7913 ssh_prp = SET_OFF, /* privileged ports */
7914 ssh_cmp = 1, /* compression */
7915 ssh_shh = 0, /* quiet */
7916 ssh_ver = 0, /* protocol version (auto,1,2) */
7917 ssh_vrb = 2, /* Report errors */
7918 ssh_chkip = 0, /* SSH Check Host IP flag */
7919 ssh_gwp = 0, /* gateway ports */
7920 ssh_dyf = 0, /* dynamic forwarding */
7921 ssh_gsd = 0, /* gssapi delegate credentials */
7922 ssh_k4tgt = 0, /* k4 tgt passing */
7923 ssh_k5tgt = 0, /* k5 tgt passing */
7924 ssh_shk = 2, /* Strict host key (no, yes, ask) */
7925 ssh2_ark = 1, /* Auto re-key */
7926 ssh_cas = 0, /* command as subsys */
7927 ssh_cfg = 0, /* use OpenSSH config? */
7928 ssh_gkx = 1, /* gssapi key exchange */
7929 ssh_k5_is_k4 = 1, /* some SSH v1 use same codes */
7930 ssh_hbt = 0, /* heartbeat (seconds) */
7931 ssh_dummy = 0; /* bottom of list */
7933 char /* The following are to be malloc'd */
7934 * ssh1_cif = NULL, /* v1 cipher */
7935 * ssh2_cif = NULL, /* v2 cipher list */
7936 * ssh2_mac = NULL, /* v2 mac list */
7937 * ssh2_auth = NULL, /* v2 authentication list */
7938 * ssh_hst = NULL, /* hostname */
7939 * ssh_prt = NULL, /* port/service */
7940 * ssh_cmd = NULL, /* command to execute */
7941 * ssh_xal = NULL, /* xauth-location */
7942 * ssh1_gnh = NULL, /* v1 global known hosts file */
7943 * ssh1_unh = NULL, /* v1 user known hosts file */
7944 * ssh2_gnh = NULL, /* v2 global known hosts file */
7945 * ssh2_unh = NULL, /* v2 user known hosts file */
7946 * ssh2_hka = NULL, /* Host Key Algorithms */
7949 char * ssh_idf[32] = { /* Identity file list */
7950 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7951 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7952 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7953 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7955 char * ssh_tmp[32] = { /* Temp identity file list */
7956 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7957 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7958 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7959 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7963 extern int ssh_pf_lcl_n,
7965 extern struct ssh_pf ssh_pf_lcl[32]; /* Port forwarding structs */
7966 extern struct ssh_pf ssh_pf_rmt[32]; /* (declared in ckuusr.c) */
7967 #endif /* SSHBUILTIN */
7970 static struct keytab sftptab[] = {
7971 { "end-of-line", XY_SFTP_EOL, 0, },
7972 { "remote-character-set", XY_SFTP_RCS, 0, },
7975 static int nsftptab = (sizeof(sftptab) / sizeof(struct keytab)) - 1;
7976 #endif /* SFTP_BUILTIN */
7981 int i, n = 0; /* ADD askmore()! */
7983 printf("\nSSH is built in:\n\n");
7985 printf(" ssh host: %s\n",showstring(ssh_hst));
7986 printf(" ssh port: %s\n",showstring(ssh_prt));
7987 printf(" ssh command: %s\n",showstring(ssh_cmd));
7988 printf(" ssh agent-forwarding: %s\n",showoff(ssh_afw));
7989 printf(" ssh check-host-ip: %s\n",showoff(ssh_chkip));
7990 printf(" ssh compression: %s\n",showoff(ssh_cmp));
7991 printf(" ssh dynamic-forwarding: %s\n",showoff(ssh_dyf));
7992 if (ssh_pf_lcl[0].p1 && ssh_pf_lcl[0].host && ssh_pf_lcl[0].p2) {
7993 printf(" ssh forward-local-port: %d %s %d\n",
7994 ssh_pf_lcl[0].p1, ssh_pf_lcl[0].host, ssh_pf_lcl[0].p2);
7995 for ( n=1;n<ssh_pf_lcl_n;n++ )
7996 printf(" : %d %s %d\n",
7997 ssh_pf_lcl[n].p1, ssh_pf_lcl[n].host, ssh_pf_lcl[n].p2);
7999 printf(" ssh forward-local-port: (none)\n");
8000 if (ssh_pf_rmt[0].p1 && ssh_pf_rmt[0].host && ssh_pf_rmt[0].p2) {
8001 printf(" ssh forward-remote-port: %d %s %d\n",
8002 ssh_pf_rmt[0].p1, ssh_pf_rmt[0].host, ssh_pf_rmt[0].p2);
8003 for ( n=1;n<ssh_pf_rmt_n;n++ )
8004 printf(" : %d %s %d\n",
8005 ssh_pf_rmt[n].p1, ssh_pf_rmt[n].host, ssh_pf_rmt[n].p2);
8007 printf(" ssh forward-remote-port: (none)\n");
8008 printf(" ssh gateway-ports: %s\n",showoff(ssh_gwp));
8009 printf(" ssh gssapi delegate-credentials: %s\n",showoff(ssh_gsd));
8010 printf(" ssh gssapi key-exchange : %s\n",showoff(ssh_gkx));
8011 printf(" ssh identity-file: %d\n",ssh_idf_n);
8012 for (i = 0; i < ssh_idf_n; i++)
8013 printf(" %2d. %s\n",i+1,showstring(ssh_idf[i]));
8014 printf(" ssh heartbeat interval: %d\n", ssh_hbt);
8015 printf(" ssh k4 tgt-passing: %s\n",showoff(ssh_k4tgt));
8016 printf(" ssh k5 tgt-passing: %s\n",showoff(ssh_k5tgt));
8018 printf(" ssh privileged-port: %s\n",showooa(ssh_prp));
8019 printf(" ssh quiet: %s\n",showoff(ssh_shh));
8020 printf(" ssh strict-host-key-check: %d\n",ssh_shk);
8021 printf(" ssh use-openssh-config: %s\n",showoff(ssh_cfg));
8022 printf(" ssh verbose: %d\n",ssh_vrb);
8023 printf(" ssh version: %s\n",
8024 ssh_ver ? ckitoa(ssh_ver) : "automatic"
8026 printf(" ssh x11-forwarding: %s\n",showooa(ssh_xfw));
8027 printf(" ssh xauth-location: %s\n",showstring(ssh_xal));
8029 printf(" ssh v1 cipher: %s\n",showstring(ssh1_cif));
8030 printf(" ssh v1 global-known-hosts-file: %s\n",showstring(ssh1_gnh));
8031 printf(" ssh v1 user-known-hosts-file: %s\n",showstring(ssh1_unh));
8033 printf(" ssh v2 authentication: %s\n",showstring(ssh2_auth));
8034 printf(" ssh v2 auto-rekey: %s\n",showoff(ssh2_ark));
8035 printf(" ssh v2 ciphers: %s\n",showstring(ssh2_cif));
8036 printf(" ssh v2 command-as-subsystem: %s\n",showoff(ssh_cas));
8037 printf(" ssh v2 global-known-hosts-file: %s\n",showstring(ssh2_gnh));
8038 printf(" ssh v2 hostkey-algorithms: %s\n",showstring(ssh2_hka));
8039 printf(" ssh v2 mac: %s\n",showstring(ssh2_mac));
8040 printf(" ssh v2 user-known-hosts-file: %s\n",showstring(ssh2_unh));
8043 extern char * sshcmd, * defsshcmd;
8045 s = sshcmd ? sshcmd : defsshcmd;
8046 printf("\n SSH is external.\n\n");
8047 printf(" ssh command: %s\n",showstring(s));
8049 #endif /* SSHBUILTIN */
8056 extern char * sshcmd;
8060 extern int sl_ssh_xfw_saved, sl_ssh_ver_saved;
8061 #endif /* SSHTEST */
8062 #endif /* SSHBUILTIN */
8066 if ((cx = cmkey(sshtab,nsshtab,"","command", xxstring)) < 0)
8070 case SSH_CMD: /* Command */
8071 if ((x = cmtxt("Command to start ssh","ssh -e none",
8075 return(success = 1);
8079 case SSH_AFW: /* Agent-forwarding */
8080 return(success = seton(&ssh_afw));
8082 case SSH_CHI: /* Check Host IP */
8083 return(success = seton(&ssh_chkip));
8086 case SSH_CMP: /* Compression */
8087 return(success = seton(&ssh_cmp));
8089 case SSH_DYF: /* Dynamic Forwarding */
8090 return(success = seton(&ssh_dyf));
8092 case SSH_GWP: /* Gateway ports */
8093 return(success = seton(&ssh_gwp));
8095 case SSH_GSS: /* GSSAPI */
8096 if ((y = cmkey(gssapitab,ngssapitab,"","", xxstring)) < 0)
8099 case 1: /* Delegate credentials */
8100 return(success = seton(&ssh_gsd));
8101 case 2: /* key-exchange */
8102 return(success = seton(&ssh_gkx));
8104 if ((x = cmcfm()) < 0)
8106 return(success = 0);
8109 case SSH_KBD: /* Kbd Interactive Devices */
8110 if ((x = cmcfm()) < 0)
8112 /* TO BE FILLED IN */
8114 #endif /* COMMENT */
8116 case SSH_K4: /* Kerberos IV */
8117 case SSH_K5: /* Kerberos V */
8118 if ((y = cmkey(tgtpass,1,"","tgt-passing", xxstring)) < 0)
8122 return(success = (cx == SSH_K4) ?
8123 seton(&ssh_k4tgt) : seton(&ssh_k5tgt));
8125 if ((x = cmcfm()) < 0)
8127 return(success = 0);
8129 case SSH_PRP: /* Privd port */
8130 return(success = seton(&ssh_prp));
8132 case SSH_SHH: /* Quiet */
8133 return(success = seton(&ssh_shh));
8135 case SSH_SHK: /* Strict Host Key Check */
8136 if ((y = cmkey(ooktab,3,"","", xxstring)) < 0)
8138 if ((x = cmcfm()) < 0)
8141 return(success = 1);
8144 x = cmnum("Heartbeat interval, seconds","0",10,&z,xxstring);
8145 if (x < 0) return(x);
8146 if ((x = cmcfm()) < 0) return(x);
8148 return(success = 1);
8150 case SSH_V1: /* SSH V1 */
8151 if ((y = cmkey(sshv1tab,nsshv1tab,"","", xxstring)) < 0)
8155 return(success = seton(&ssh_k5_is_k4));
8156 case SSH1_CIF: /* Not a list */
8157 if ((y = cmkey(ssh1ciphers,nssh1ciphers,"","", xxstring)) < 0)
8160 if ((x = cmcfm()) < 0) return(x);
8162 makestr(&ssh1_cif,NULL);
8164 for (x = 0; x < nssh1ciphers; x++)
8165 if (ssh1ciphers[x].kwval == y)
8167 makestr(&ssh1_cif,ssh1ciphers[x].kwd);
8172 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
8176 ckstrncpy(line,s,LINBUFSIZ);
8177 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8178 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8180 s = (x == -3) ? NULL : line;
8181 if ((x = cmcfm()) < 0)
8184 case SSH1_GNH: makestr(&ssh1_gnh,s); break;
8185 case SSH1_UNH: makestr(&ssh1_unh,s); break;
8190 case SSH_V2: /* SSH V2 */
8191 if ((y = cmkey(sshv2tab,nsshv2tab,"","", xxstring)) < 0)
8195 return(success = seton(&ssh2_ark));
8196 case SSH2_AUT: { /* Authentication */
8198 int i, j, tmp[TMPCNT];
8199 for (i = 0; i < TMPCNT; i++)
8201 for (i = 0; i < TMPCNT; i++) {
8202 if ((y = cmkey(ssh2aut,nssh2aut,
8203 "Authentication method","",xxstring)) < 0) {
8208 for (j = 0; j < i; j++) {
8210 printf("\r\n?Choice has already been used.\r\n");
8216 if ((z = cmcfm()) < 0)
8225 for (j = 0; j < i; j++) {
8226 for (x = 0; x < nssh2aut; x++)
8227 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8229 len += strlen(ssh2aut[x].kwd) + 1;
8231 ssh2_auth = malloc(len);
8232 ssh2_auth[0] = '\0';
8233 for (j = 0; j < i; j++) {
8234 for (x = 0; x < nssh2aut; x++)
8235 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8237 ckstrncat(ssh2_auth,ssh2aut[x].kwd,len);
8239 ckstrncat(ssh2_auth,",",len);
8242 return(success = 1);
8247 int i, j, tmp[TMPCNT];
8248 for (i = 0; i < TMPCNT; i++)
8251 for (i = 0; i < TMPCNT; i++) {
8252 if ((y = cmkey(ssh2ciphers,nssh2ciphers,
8253 "","", xxstring)) < 0) {
8258 for (j = 0; j < i; j++) {
8260 printf("\r\n?Choice has already been used.\r\n");
8266 if ((z = cmcfm()) < 0)
8275 for (j=0; j < i; j++) {
8276 for (x = 0; x < nssh2ciphers; x++)
8277 if (ssh2ciphers[x].kwval == tmp[j] &&
8278 !ssh2ciphers[x].flgs)
8280 len += strlen(ssh2ciphers[x].kwd) + 1;
8282 ssh2_cif = malloc(len);
8284 for (j = 0; j < i; j++) {
8285 for (x = 0; x < nssh2ciphers; x++)
8286 if (ssh2ciphers[x].kwval == tmp[j] && !ssh2ciphers[x].flgs)
8288 ckstrncat(ssh2_cif,ssh2ciphers[x].kwd,len);
8290 ckstrncat(ssh2_cif,",",len);
8293 return(success = 1);
8298 int i, j, tmp[TMPCNT];
8299 for (i = 0; i < TMPCNT; i++)
8302 for (i = 0; i < TMPCNT; i++) {
8303 if ((y = cmkey(ssh2macs,nssh2macs,"","", xxstring)) < 0) {
8308 for (j = 0; j < i; j++) {
8310 printf("\r\n?Choice has already been used.\r\n");
8316 if ((z = cmcfm()) < 0)
8325 for (j = 0; j < i; j++) {
8326 for (x = 0; x < nssh2macs; x++)
8327 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8329 len += strlen(ssh2macs[x].kwd) + 1;
8331 ssh2_mac = malloc(len);
8333 for (j=0; j < i; j++) {
8334 for (x = 0; x < nssh2macs; x++)
8335 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8337 ckstrncat(ssh2_mac,ssh2macs[x].kwd,len);
8339 ckstrncat(ssh2_mac,",",len);
8342 return(success = 1);
8347 int i, j, tmp[TMPCNT];
8348 for (i = 0; i < TMPCNT; i++)
8351 for (i = 0; i < TMPCNT; i++) {
8352 if ((y = cmkey(hkatab,nhkatab,
8353 "","", xxstring)) < 0) {
8358 for (j = 0; j < i; j++) {
8360 printf("\r\n?Choice has already been used.\r\n");
8366 if ((z = cmcfm()) < 0)
8375 for (j=0; j < i; j++) {
8376 for (x = 0; x < nhkatab; x++)
8377 if (hkatab[x].kwval == tmp[j] &&
8380 len += strlen(hkatab[x].kwd) + 1;
8382 ssh2_hka = malloc(len);
8384 for (j = 0; j < i; j++) {
8385 for (x = 0; x < nhkatab; x++)
8386 if (hkatab[x].kwval == tmp[j] && !hkatab[x].flgs)
8388 ckstrncat(ssh2_hka,hkatab[x].kwd,len);
8390 ckstrncat(ssh2_hka,",",len);
8393 return(success = 1);
8398 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
8402 ckstrncpy(line,s,LINBUFSIZ);
8403 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8404 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8406 s = (x == -3) ? NULL : line;
8407 if ((x = cmcfm()) < 0)
8410 case SSH2_GNH: makestr(&ssh2_gnh,s); break;
8411 case SSH2_UNH: makestr(&ssh2_unh,s); break;
8412 default: return(success = 0);
8414 return(success = 1);
8417 case SSH_VRB: /* Verbosity level */
8418 y = cmnum("SSH verbosity level, 0-7","2",10,&x,xxstring);
8419 return(setnum(&ssh_vrb,x,y,7));
8421 case SSH_VER: /* Version */
8422 if ((y = cmkey(sshver,3,"","auto", xxstring)) < 0)
8424 if ((x = cmcfm()) < 0)
8426 ssh_ver = y; /* 0 == AUTO */
8428 sl_ssh_ver_saved = 0;
8429 #endif /* SSHTEST */
8430 return(success = 1);
8432 case SSH_IDF: { /* Identity file */
8434 for (i = 0; i < 32; i++) {
8435 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
8440 if (!zfnqfp(s,LINBUFSIZ,line))
8441 ckstrncpy(line,s,LINBUFSIZ);
8442 makestr(&ssh_tmp[i],line);
8445 if ((x = cmcfm()) < 0) {
8446 for (i = 0; i < n; i++)
8447 makestr(&(ssh_tmp[i]),NULL);
8450 for (i = 0; i < 32; i++) {
8451 makestr(&(ssh_idf[i]),NULL);
8453 ssh_idf[i] = ssh_tmp[i];
8456 makestr(&(ssh_tmp[i]),NULL);
8460 return(success = 1);
8462 case SSH_XFW: /* X11-forwarding */
8463 success = seton(&ssh_xfw);
8466 sl_ssh_xfw_saved = 0;
8467 #endif /* SSHTEST */
8470 case SSH_XAL: /* SSH Xauth Location */
8471 if ((x = cmifi("Path to executable", "",&s,&y,xxstring)) < 0) {
8475 ckstrncpy(line,s,LINBUFSIZ);
8476 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8477 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8479 s = (x == -3) ? NULL : line;
8480 if ((x = cmcfm()) < 0) return(x);
8481 makestr(&ssh_xal,s);
8482 return(success = 1);
8484 case SSH_CFG: /* Use OpenSSH Config */
8485 return(success = seton(&ssh_cfg));
8486 #endif /* SSHBUILTIN */
8500 if ((cx = cmkey(sftptab,nsftptab,"","", xxstring)) < 0)
8509 #endif /* SFTP_BUILTIN */
8513 extern ULONG RGBTable[16];
8533 static struct keytab guitab[] = {
8534 { "close", GUI_CLS, 0 },
8535 { "dialogs", GUI_DIA, 0 },
8536 { "font", GUI_FON, 0 },
8537 { "menubar", GUI_MNB, 0 },
8538 { "rgbcolor", GUI_RGB, 0 },
8539 { "toolbar", GUI_TLB, 0 },
8540 { "window", GUI_WIN, 0 },
8543 static int nguitab = (sizeof(guitab) / sizeof(struct keytab));
8545 static struct keytab guiwtab[] = {
8546 { "position", GUIW_POS, 0 },
8547 { "resize-mode", GUIW_RES, 0 },
8548 { "run-mode", GUIW_RUN, 0 },
8551 static int nguiwtab = (sizeof(guiwtab) / sizeof(struct keytab));
8553 static struct keytab guiwrtab[] = {
8554 { "change-dimensions", GUIWR_DIM, 0 },
8555 { "none", GUIWR_NON, 0 },
8556 { "scale-font", GUIWR_FON, 0 },
8559 static int nguiwrtab = (sizeof(guiwrtab) / sizeof(struct keytab));
8561 static struct keytab guiwntab[] = {
8562 { "maximize", GUIWN_MAX, 0 },
8563 { "minimize", GUIWN_MIN, 0 },
8564 { "restore", GUIWN_RES, 0 },
8567 static int nguiwntab = (sizeof(guiwntab) / sizeof(struct keytab));
8569 static struct keytab rgbtab[] = {
8574 { "darkgray", 8, 0 },
8575 { "dgray", 8, CM_INV },
8577 { "lblue", 9, CM_INV },
8578 { "lcyan", 11, CM_INV },
8579 { "lgreen", 10, CM_INV },
8580 { "lgray", 7, CM_INV },
8581 { "lightblue", 9, 0 },
8582 { "lightcyan", 11, 0 },
8583 { "lightgreen", 10, 0 },
8584 { "lightgray", 7, 0 },
8585 { "lightmagenta", 13, 0 },
8586 { "lightred", 12, 0 },
8587 { "lmagenta", 13, CM_INV },
8588 { "lred", 12, CM_INV },
8589 { "magenta", 5, 0 },
8592 { "yellow", 14, 0 },
8595 int nrgb = (sizeof(rgbtab) / sizeof(struct keytab));
8600 extern HWND getHwndKUI();
8601 unsigned char cmdsav = colorcmd;
8602 int i, red, green, blue, lines=0;
8606 printf("GUI paramters:\n");
8607 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8608 printf(" Dialogs: %s\n",showoff(gui_dialog));
8609 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8610 printf(" Position: %d,%d\n",get_gui_window_pos_x(),
8611 get_gui_window_pos_y());
8612 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8613 printf(" Resolution: %d x %d\n",GetSystemMetrics(SM_CXSCREEN),
8614 GetSystemMetrics(SM_CYSCREEN));
8615 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8616 printf(" Run-mode: %s\n",IsIconic(getHwndKUI()) ? "minimized" :
8617 IsZoomed(getHwndKUI()) ? "maximized" : "restored");
8618 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8619 switch ( get_gui_resize_mode() ) {
8627 s= "changes dimensions";
8630 printf(" Resize-mode: %s\n",s);
8631 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8633 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8635 printf("RGB Color Table:\n");
8636 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8637 printf(" Color Red Green Blue\n");
8638 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8639 printf(" ------------------------------------------\n");
8640 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8641 for (i = 0; i < nrgb; i++) {
8642 if (!rgbtab[i].flgs) {
8643 blue = (RGBTable[rgbtab[i].kwval] & 0x00FF0000)>>16;
8644 green = (RGBTable[rgbtab[i].kwval] & 0x0000FF00)>>8;
8645 red = (RGBTable[rgbtab[i].kwval] & 0x000000FF);
8646 printf(" %-18s %3d %3d %3d ",rgbtab[i].kwd,red,green,blue);
8647 colorcmd = rgbtab[i].kwval << 4;
8651 if (++lines > cmd_rows - 3) {
8664 int cx, red = 0, blue = 0, green = 0, z, x;
8666 if ((cx = cmkey(rgbtab,nrgb,"","",xxstring)) < 0)
8668 if ((z = cmnum("Red value, 0-255","",10,&red,xxstring)) < 0)
8670 if ((z = cmnum("Green value, 0-255","",10,&green,xxstring)) < 0)
8672 if ((z = cmnum("Blue value, 0-255","",10,&blue,xxstring)) < 0)
8674 if ((x = cmcfm()) < 0) return(x);
8675 if (cx > 15 || red > 255 || blue > 255 || green > 255)
8677 RGBTable[cx] = (unsigned)(((unsigned)blue << 16) |
8678 (unsigned)((unsigned)green << 8) |
8680 return(success = 1);
8684 Set GUI window position: XY coordinates of upper left corner,
8685 expressed as pixel numbers in the current screen resolution.
8686 (0,0) means put ourselves in the upper left corner.
8687 Can we check for out of bounds?
8693 if ((cx = cmkey(guiwtab,nguiwtab,"","",xxstring)) < 0)
8697 if ((z = cmnum("X coordinate (pixel number)","",10,&x,xxstring)) < 0)
8699 if ((z = cmnum("Y coordinate (pixel number)","",10,&y,xxstring)) < 0)
8701 if ((z = cmcfm()) < 0)
8703 if (x < 0 || y < 0) {
8704 printf("?Coordinates must be 0 or greater\n");
8708 return(success = 1);
8710 if ((x = cmkey(guiwrtab,nguiwrtab,"","",xxstring)) < 0)
8712 if ((z = cmcfm()) < 0)
8715 return(success = 1);
8717 if ((x = cmkey(guiwntab,nguiwntab,"","",xxstring)) < 0)
8719 if ((z = cmcfm()) < 0)
8721 gui_win_run_mode(x);
8722 return(success = 1);
8729 setguifont() { /* Assumes that CKFLOAT is defined! */
8731 extern struct keytab * term_font;
8732 extern struct keytab * _term_font;
8733 extern int tt_font, tt_font_size, ntermfont;
8738 BuildFontTable(&term_font, &_term_font, &ntermfont);
8739 if (!(term_font && _term_font && ntermfont > 0)) {
8740 printf("?Internal error: Failure to enumerate fonts\n");
8743 if ((x = cmkey(_term_font,ntermfont,"","",xxstring)) < 0)
8745 if ((z = cmfld("Height of font in points","12",&s,xxstring)) < 0)
8747 if (isfloat(s,0) < 1) { /* (sets floatval) */
8748 printf("?Integer or floating-point number required\n");
8751 if (floatval < 0.5) {
8752 printf("?Positive number required\n");
8755 if ((z = cmcfm()) < 0)
8757 tt_font = x; /* Font index */
8758 tt_font_size = (int)(floatval * 2); /* Font size in half points */
8759 KuiSetProperty(KUI_TERM_FONT, (long)tt_font, (long)tt_font_size);
8760 return(success = 1);
8764 setguidialog(x) int x;
8766 extern int gui_dialog;
8768 KuiSetProperty(KUI_GUI_DIALOGS, (long)x, 0L);
8772 setguimenubar(x) int x;
8774 KuiSetProperty(KUI_GUI_MENUBAR, (long)x, 0L);
8778 setguitoolbar(x) int x;
8780 KuiSetProperty(KUI_GUI_TOOLBAR, (long)x, 0L);
8784 setguiclose(x) int x;
8786 KuiSetProperty(KUI_GUI_CLOSE, (long)x, 0L);
8792 if ((cx = cmkey(guitab,nguitab,"","",xxstring)) < 0)
8801 return(setguifont());
8805 return(setguiwin());
8828 setexitwarn(x) int x;
8832 KuiSetProperty(KUI_EXIT_WARNING, (long)x, 0L);
8838 setdebses(x) int x; {
8840 if ((debses != 0) && (x == 0)) /* It was on and we turned it off? */
8841 os2debugoff(); /* Fix OS/2 coloration */
8845 KuiSetProperty(KUI_TERM_DEBUG,x,0);
8848 #endif /* NOLOCAL */
8850 /* D O P R M -- Set a parameter. */
8858 doprm(xx,rmsflg) int xx, rmsflg; {
8859 int i = 0, x = 0, y = 0, z = 0;
8861 char *s = NULL, *p = NULL;
8864 long portspeed = 0L;
8874 #endif /* NOSETKEY */
8876 if (xx == XYFLAG) { /* SET FLAG */
8878 return(success = seton(&ooflag));
8880 if (xx == XYPRTR /* SET PRINTER (or BPRINTER) */
8885 return(setprinter(xx));
8889 #ifdef ANYX25 /* SET X25 ... */
8894 case XYPAD: /* SET PAD ... */
8900 case XYEOL: /* These have all been moved to set send/receive... */
8901 case XYLEN: /* Let the user know what to do. */
8906 printf("...Use SET SEND or SET RECEIVE instead.\n");
8907 printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n");
8908 return(success = 0);
8910 case XYATTR: /* File Attribute packets */
8911 return(setat(rmsflg));
8913 case XYIFD: /* Incomplete file disposition */
8914 if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
8915 if ((x = cmcfm()) < 0) return(x);
8917 sstate = setgen('S',
8919 y == 0 ? "0" : (y == 1 ? "1" : "2"),
8922 return((int) sstate);
8925 return(success = 1);
8929 case XYMATCH: /* [ REMOTE ] SET MATCH... */
8931 if ((z = cmkey(matchtab,nmatchtab,"","",xxstring)) < 0)
8934 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
8935 if ((x = cmcfm()) < 0) return(x);
8938 return(sstate = setgen('S',"330", y == 0 ? "0" : "1", ""));
8940 return(sstate = setgen('S',"331", y == 0 ? "0" : "1", ""));
8948 return(success = seton(&matchfifo));
8950 x = seton(&matchdot);
8951 if (x < 0) return(x);
8953 return(success = x);
8959 case XYINPU: /* SET INPUT */
8964 case XYNET: { /* SET NETWORK */
8968 cmfdbi(&k1,_CMKEY,"","","",nnetkey, 0, xxstring, netkey, &k2);
8969 cmfdbi(&k2,_CMKEY,"","","",nnets, 0, xxstring, netcmd, NULL);
8971 #ifdef OS2 /* Hide network-type keywords for networks not installed */
8972 for (z = 0; z < nnets; z++) {
8973 if (netcmd[z].kwval == NET_TCPB && tcp_avail == 0)
8974 netcmd[z].flgs = CM_INV;
8976 if (netcmd[z].kwval == NET_SSH &&
8977 !ck_ssleay_is_installed())
8978 netcmd[z].flgs = CM_INV;
8979 #endif /* SSHBUILTIN */
8981 else if (netcmd[z].kwval == NET_DEC && dnet_avail == 0)
8982 netcmd[z].flgs = CM_INV;
8985 else if (netcmd[z].kwval == NET_BIOS && netbiosAvail == 0)
8986 netcmd[z].flgs = CM_INV;
8987 #endif /* CK_NETBIOS */
8989 else if (netcmd[z].kwval == NET_SLAT && slat_avail == 0)
8990 netcmd[z].flgs = CM_INV;
8991 #endif /* SUPERLAT */
8993 if (tcp_avail) /* Default network type */
8994 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
8996 else if ( ck_ssleay_is_installed() )
8997 ckstrncpy(tmpbuf,"ssh",TMPBUFSIZ);
8998 #endif /* SSHBUILTIN */
9000 else if (dnet_avail)
9001 ckstrncpy(tmpbuf,"decnet",TMPBUFSIZ);
9004 else if (slat_avail)
9005 ckstrncpy(tmpbuf,"superlat",TMPBUFSIZ);
9006 #endif /* SUPERLAT */
9008 else if (netbiosAvail)
9009 ckstrncpy(tmpbuf,"netbios",TMPBUFSIZ);
9010 #endif /* CK_NETBIOS */
9011 else ckstrncpy(tmpbuf,"named-pipe",TMPBUFSIZ);
9014 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
9017 ckstrncpy(tmpbuf,"x.25",TMPBUFSIZ);
9019 ckstrncpy(tmpbuf,"",TMPBUFSIZ);
9021 #endif /* TCPSOCKET */
9025 if (x < 0) { /* Error */
9026 if (x == -2 || x == -9)
9027 printf("?No keywords match: \"%s\"\n",atmbuf);
9030 z = cmresult.nresult; /* Keyword value */
9031 if (cmresult.fdbaddr == &k1) { /* Which table? */
9038 if ((z = cmkey(netcmd,nnets,"",tmpbuf,xxstring)) < 0)
9043 if (z == NET_CMD && nopush) {
9044 printf("\n?Sorry, access to external commands is disabled\n");
9051 if (z == NET_PTY && nopush) {
9052 printf("\n?Sorry, access to external commands is disabled\n");
9059 if (z == NET_TCPB && tcp_avail == 0) {
9061 "\n?Sorry, either TCP/IP is not available on this system or\n\
9062 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
9065 } else if (z == NET_SSH && !ck_ssleay_is_installed()) {
9066 printf("\n?Sorry, SSH is not available on this system.\n") ;
9068 #endif /* SSHBUILTIN */
9070 } else if (z == NET_BIOS && netbiosAvail == 0) {
9071 printf("\n?Sorry, NETBIOS is not available on this system.\n") ;
9073 #endif /* CK_NETBIOS */
9075 } else if (z == NET_DEC && dnet_avail == 0) {
9076 printf("\n?Sorry, DECnet is not available on this system.\n") ;
9080 } else if (z == NET_SLAT && slat_avail == 0) {
9081 printf("\n?Sorry, SuperLAT is not available on this system.\n") ;
9083 #endif /* SUPERLAT */
9088 if (z == NET_PIPE || /* Named pipe -- also get pipename */
9089 z == NET_BIOS) { /* NETBIOS -- also get local name */
9092 char tmpnbnam[NETBIOS_NAME_LEN+1];
9093 #endif /* CK_NETBIOS */
9094 /* Construct default name */
9095 if (z == NET_PIPE) { /* Named pipe */
9096 defnam = "kermit"; /* Default name is always "kermit" */
9099 else { /* NetBIOS */
9100 if (NetBiosName[0] != SP) { /* If there is already a name, */
9102 int n; /* use it as the default. */
9103 ckstrncpy(tmpnbnam,NetBiosName,NETBIOS_NAME_LEN+1);
9104 /* convert trailing spaces to NULs */
9105 p = &tmpnbnam[NETBIOS_NAME_LEN-1];
9111 } else if (*myhost) /* Otherwise use this PC's host name */
9112 defnam = (char *) myhost;
9113 else /* Otherwise use "kermit" */
9116 #endif /* CK_NETBIOS */
9117 if ((y = cmtxt((z == NET_PIPE) ? "name of named-pipe" :
9118 "local NETBIOS name",
9119 defnam, &s, xxstring)) < 0)
9124 if ((y = (int) strlen(s)) < 1) {
9125 printf("?You must also specify a %s name\n",
9126 (z == NET_PIPE) ? "pipe" : "local NETBIOS" );
9130 if (z == NET_BIOS) {
9131 if (!netbiosAvail) {
9132 printf("?NETBIOS is not available on this system.\n") ;
9135 if (y - NETBIOS_NAME_LEN > 0) {
9136 printf("?NETBIOS name too long, %ld maximum\n",
9139 } else if ( !strcmp(s,tmpnbnam) ) {
9140 nettype = z; /* Returning to old connection... */
9141 return(success = 1); /* Done */
9142 } else if (strcmp(" ",NetBiosName)) {
9143 printf("?NETBIOS name already assigned to \"%s\"\n",
9149 ckstrncpy(NetBiosName,s,16);
9150 for (x = y; x < NETBIOS_NAME_LEN; x++)
9151 NetBiosName[x] = SP;
9152 NetBiosName[NETBIOS_NAME_LEN] = NUL;
9153 printf("Checking \"%s\" as a unique NetBIOS name...\n",
9155 rc = NCBAddName( NetbeuiAPI,
9156 &ncb, NetBiosAdapter, NetBiosName );
9159 "?Sorry, \"%s\" is already in use by another NetBIOS node.\n",
9161 for (x = 0; x < NETBIOS_NAME_LEN; x++)
9162 NetBiosName[x] = SP;
9167 #endif /* CK_NETBIOS */
9170 ckstrncpy(pipename,s,PIPENAML);
9173 #endif /* NPIPEORBIOS */
9176 /* Determine if we are using LAT or CTERM */
9177 if ((y = cmkey(dnettab,
9178 ndnet,"DECNET protocol","lat",xxstring)) < 0)
9180 if ((x = cmcfm()) < 0) return(x);
9186 /* Find out which DLL they are using */
9187 char dllname[256]="";
9189 if ((x = cmifi("Dynamic load library",
9190 "",&p,&y,xxstring)) < 0) {
9192 printf("?Name of DLL required\n");
9197 ckstrncpy(dllname,p,256);
9198 if ((x = cmcfm()) < 0) return(x);
9200 if (netdll_load(dllname) < 0) /* Try to load the dll */
9201 return(success = 0);
9204 return(success = 1);
9208 if ((x = cmcfm()) < 0) return(x);
9212 (nettype != NET_DEC) &&
9215 (nettype != NET_PIPE) &&
9218 (nettype != NET_BIOS) &&
9219 #endif /* CK_NETBIOS */
9221 (nettype != NET_FILE) &&
9222 #endif /* NETFILE */
9224 (nettype != NET_CMD) &&
9227 (nettype != NET_PTY) &&
9230 (nettype != NET_DLL) &&
9233 (nettype != NET_SLAT) &&
9234 #endif /* SUPERLAT */
9235 (nettype != NET_SX25) &&
9236 (nettype != NET_VX25) &&
9238 (nettype != NET_IX25) &&
9241 (nettype != NET_SSH) &&
9242 #endif /* SSHBUILTIN */
9243 (nettype != NET_TCPB)) {
9244 printf("?Network type not supported\n");
9245 return(success = 0);
9247 return(success = 1);
9256 if ((z = cmkey(tcpopt,ntcpopt,"TCP option","nodelay",xxstring)) < 0)
9261 case XYTCP_HTTP_PROXY: {
9264 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1], abuf[256];
9265 ubuf[0] = pbuf[0] = abuf[0] = 0;
9267 cmfdbi(&sw, /* First FDB - switches */
9269 "HTTP proxy server host[:port] or switch",
9271 "", /* addtl string data */
9272 nuserpass, /* addtl numeric data 1: tbl size */
9273 4, /* addtl numeric data 2: 4 = cmswi */
9274 xxstring, /* Processing function */
9275 userpass, /* Keyword table */
9276 &tx /* Pointer to next FDB */
9280 "HTTP proxy server host[:port]",
9282 "", /* addtl string data */
9283 0, /* addtl numeric data 1 */
9284 0, /* addtl numeric data 2 */
9290 if ((x = cmfdb(&sw)) < 0) {
9293 printf("?Hostname required\n");
9297 if (cmresult.fcode != _CMKEY)
9299 n = cmresult.nresult;
9304 if ((x = cmfld((n == UPW_USER) ?
9306 ((n == UPW_PASS) ? "Password" : "Agent"),
9307 "", &s, xxstring)) < 0) {
9311 ckstrncpy((n == UPW_USER) ? ubuf :
9312 ((n == UPW_PASS) ? pbuf : abuf), s,
9313 (n == UPW_AGENT) ? 256 : (LOGINLEN+1));
9316 if (cmresult.fcode != _CMTXT)
9318 s = cmresult.sresult;
9319 if (s) if (!*s) s = NULL;
9323 return(success = 0);
9324 #endif /* IKSDCONF */
9325 makestr(&tcp_http_proxy_user,ubuf[0]?ubuf:NULL);
9326 makestr(&tcp_http_proxy_pwd,pbuf[0]?pbuf:NULL);
9327 makestr(&tcp_http_proxy_agent,abuf[0]?abuf:NULL);
9328 makestr(&tcp_http_proxy,s);
9329 memset(pbuf,0,sizeof(pbuf));
9330 return(success = 1);
9334 It would have been easy to combine XYTCP_SOCKS_SVR with the previous
9335 one except for the #ifdefs...
9339 case XYTCP_SOCKS_SVR: {
9340 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1];
9341 char * p = getenv("SOCKS_SERVER");
9347 cmfdbi(&sw, /* First FDB - switches */
9349 "SOCKS server host[:port] or switch",
9351 "", /* addtl string data */
9352 nuserpass, /* addtl numeric data 1: tbl size */
9353 4, /* addtl numeric data 2: 4 = cmswi */
9354 xxstring, /* Processing function */
9355 userpass, /* Keyword table */
9356 &tx /* Pointer to next FDB */
9360 "SOCKS server host[:port]",
9362 "", /* addtl string data */
9363 0, /* addtl numeric data 1 */
9364 0, /* addtl numeric data 2 */
9370 if ((x = cmfdb(&sw)) < 0) {
9373 printf("?Hostname required\n");
9377 if (cmresult.fcode != _CMKEY)
9379 n = cmresult.nresult;
9383 if ((x = cmfld((n == UPW_USER) ? "Username" : "Password",
9384 "", &s, xxstring)) < 0) {
9388 ckstrncpy((n == UPW_USER) ? ubuf : pbuf, s, LOGINLEN+1);
9391 if (cmresult.fcode != _CMTXT)
9393 s = cmresult.sresult;
9394 if (s) if (!*s) s = NULL;
9398 return(success = 0);
9399 #endif /* IKSDCONF */
9400 makestr(&tcp_socks_user,ubuf);
9401 memset(pbuf,0,sizeof(pbuf));
9402 makestr(&tcp_socks_svr,s);
9403 return(success = 1);
9407 case XYTCP_SOCKS_NS: {
9408 char * p = getenv("SOCKS_NS");
9410 if ((y = cmtxt("hostname or IP of SOCKS Name Server",p,
9414 if (iksdcf) return(success = 0);
9415 #endif /* IKSDCONF */
9417 free(tcp_socks_ns); /* Free any previous storage */
9418 tcp_socks_ns = NULL;
9420 if (s == NULL || *s == NUL) { /* If none given */
9421 tcp_socks_ns = NULL; /* remove the override string */
9422 return(success = 1);
9423 } else if ((tcp_socks_ns = malloc(strlen(s)+1))) {
9424 strcpy(tcp_socks_ns,s);
9425 return(success = 1);
9427 return(success = 0);
9429 #endif /* CK_SOCKS_NS */
9430 #endif /* CK_SOCKS */
9433 if ((y = cmtxt("preferred IP Address for TCP connections","",
9437 if (iksdcf) return(success = 0);
9438 #endif /* IKSDCONF */
9440 free(tcp_address); /* Free any previous storage */
9443 if (s == NULL || *s == NUL) { /* If none given */
9444 tcp_address = NULL; /* remove the override string */
9445 return(success = 1);
9446 } else if ((tcp_address = malloc(strlen(s)+1))) {
9447 strcpy(tcp_address,s);
9448 return(success = 1);
9450 return(success = 0);
9452 case XYTCP_KEEPALIVE:
9453 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9454 if ((y = cmcfm()) < 0) return(y);
9456 if (iksdcf) return(success = 0);
9457 #endif /* IKSDCONF */
9459 if (network && nettype == NET_SSH && ssh_sock != -1)
9460 success = keepalive(ssh_sock,z);
9462 #endif /* SSHBUILTIN */
9463 success = keepalive(ttyfd,z);
9465 #endif /* SO_KEEPALIVE */
9467 case XYTCP_DONTROUTE:
9468 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9469 if ((y = cmcfm()) < 0) return(y);
9471 if (iksdcf) return(success = 0);
9472 #endif /* IKSDCONF */
9474 if (network && nettype == NET_SSH && ssh_sock != -1)
9475 success = dontroute(ssh_sock,z);
9477 #endif /* SSHBUILTIN */
9478 success = dontroute(ttyfd,z);
9480 #endif /* SO_DONTROUTE */
9483 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9484 if ((y = cmcfm()) < 0) return(y);
9486 if (iksdcf) return(success = 0);
9487 #endif /* IKSDCONF */
9489 if (network && nettype == NET_SSH && ssh_sock != -1)
9490 success = no_delay(ssh_sock,z);
9492 #endif /* SSHBUILTIN */
9493 success = no_delay(ttyfd,z);
9495 case XYTCP_NAGLE: /* The inverse of NODELAY */
9496 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9497 if ((y = cmcfm()) < 0) return(y);
9499 if (iksdcf) return(success = 0);
9500 #endif /* IKSDCONF */
9502 if (network && nettype == NET_SSH && ssh_sock != -1)
9503 success = no_delay(ssh_sock,z);
9505 #endif /* SSHBUILTIN */
9506 success = no_delay(ttyfd,!z);
9508 #endif /* TCP_NODELAY */
9511 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0)
9513 if (z) { /* if on, we need a timeout value */
9514 if ((x = cmnum("Linger timeout in 10th of a millisecond",
9515 "0",10,&y,xxstring)) < 0)
9519 if ((x = cmcfm()) < 0)
9522 if (iksdcf) return(success = 0);
9523 #endif /* IKSDCONF */
9525 if (network && nettype == NET_SSH && ssh_sock != -1)
9526 success = ck_linger(ssh_sock,z,y);
9528 #endif /* SSHBUILTIN */
9529 success = ck_linger(ttyfd,z,y);
9531 #endif /* SO_LINGER */
9534 x = cmnum("Send buffer size, bytes","8192",10,&z,xxstring);
9535 if (x < 0) return(x);
9536 if ((x = cmcfm()) < 0) return(x);
9538 if (iksdcf) return(success = 0);
9539 #endif /* IKSDCONF */
9541 if (network && nettype == NET_SSH && ssh_sock != -1)
9542 success = sendbuf(ssh_sock,z);
9544 #endif /* SSHBUILTIN */
9545 success = sendbuf(ttyfd,z);
9547 #endif /* SO_SNDBUF */
9550 x = cmnum("Receive buffer size, bytes","8192",10,&z,xxstring);
9551 if (x < 0) return(x);
9552 if ((x = cmcfm()) < 0) return(x);
9554 if (iksdcf) return(success = 0);
9555 #endif /* IKSDCONF */
9557 /* Note: The following is not 16-bit safe */
9561 printf("?Warning: receive buffers larger than 52248 bytes\n");
9562 printf(" may not be understood by all hosts. Performance\n");
9563 printf(" may suffer.\n");
9568 if (network && nettype == NET_SSH && ssh_sock != -1)
9569 success = recvbuf(ssh_sock,z);
9571 #endif /* SSHBUILTIN */
9572 success = recvbuf(ttyfd,z);
9574 #endif /* SO_RCVBUF */
9578 case XYTCP_UCX: { /* UCX 2.0 port swabbing bug */
9579 extern int ucx_port_bug;
9580 return(success = seton(&ucx_port_bug));
9582 #endif /* DEC_TCPIP */
9586 extern int tcp_rdns;
9587 return(success = setonaut(&tcp_rdns));
9591 case XYTCP_DNS_SRV: {
9592 extern int tcp_dns_srv;
9593 return(success = seton(&tcp_dns_srv));
9595 #endif /* CK_DNS_SRV */
9601 #endif /* TCPSOCKET */
9602 #endif /* NOTCPOPTS */
9603 #endif /* NETCONN */
9610 case XYHOST: { /* SET HOST */
9611 z = ttnproto; /* Save protocol in case of failure */
9613 if (nettype != NET_DEC)
9616 if ((y = setlin(XYHOST,1,0)) <= 0) { /* Sets success to 1 */
9617 debug(F101,"SET HOST fail mdmtyp","",mdmtyp);
9618 ttnproto = z; /* Failed, restore protocol */
9622 debug(F101,"SET HOST OK mdmtyp","",mdmtyp);
9623 debug(F101,"SET HOST reliable","",reliable);
9626 #endif /* NETCONN */
9628 case XYLINE: /* SET LINE (= SET PORT) */
9629 debug(F101,"setlin flow 1","",flow);
9631 if (x > -1) didsetlin++;
9632 debug(F101,"SET LINE setlin","",x);
9633 debug(F101,"SET LINE flow","",flow);
9634 debug(F101,"SET LINE local","",local);
9635 debug(F101,"SET LINE reliable","",reliable);
9637 #endif /* NOLOCAL */
9640 case XYKEY: /* SET KEY */
9642 #endif /* NOSETKEY */
9645 case XYLANG: /* Language */
9646 if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0)
9648 if ((x = cmcfm()) < 0) return(x);
9650 /* Look up language and get associated character sets */
9651 for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ;
9653 printf("?internal error, sorry\n");
9654 return(success = 0);
9656 language = i; /* All good, set the language, */
9657 return(success = 1);
9658 #endif /* NOCSETS */
9661 case XYBACK: /* BACKGROUND */
9662 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
9663 if ((y = cmcfm()) < 0) return(y);
9665 bgset = z; /* 0 = off (foreground) */
9666 #ifdef VMS /* 1 = on (background) */
9667 if (batch && bgset == 0) /* To enable echoing of commands */
9668 ckxech = 1; /* in VMS batch logs */
9671 if (z) { /* 1 = Background */
9677 } else { /* 0 = Foreground */
9684 #endif /* COMMENT */
9690 case XYQUIE: { /* QUIET */
9692 extern int * xquiet;
9694 extern int xquiet[];
9695 #endif /* DCMDBUF */
9697 if (x < 0) return(x);
9698 xquiet[cmdlvl] = quiet;
9699 return(success = x);
9703 case XYBUF: { /* BUFFERS */
9706 if ((y = cmnum("Send buffer size","",10,&sb,xxstring)) < 0) {
9707 if (y == -3) printf("?Buffer size required\n");
9712 printf("?Negative numbers can't be used here\n");
9713 else printf("?Integer overflow, use a smaller number please\n");
9715 } else if (sb < 80) {
9716 printf("?Too small\n");
9719 if ((y=cmnum("Receive buffer size",ckitoa(sb),10,&rb,xxstring)) < 0)
9723 printf("?Negative numbers can't be used here\n");
9724 else printf("?Integer overflow, use a smaller number please\n");
9726 } else if (rb < 80) {
9727 printf("?Too small\n");
9730 if ((y = cmcfm()) < 0) return(y);
9731 if ((y = inibufs(sb,rb)) < 0) return(y);
9732 y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */
9733 if (y != urpsiz) urpsiz = y;
9734 y = adjpkl(spsiz,wslotr,bigsbsiz);
9735 if (y != spsiz) spsiz = spmax = spsizr = y;
9736 return(success = 1);
9738 printf("?Sorry, not available\n");
9739 return(success = 0);
9740 #endif /* DYNAMIC */
9743 case XYCHKT: /* BLOCK-CHECK */
9744 if ((x = cmkey(chktab,nchkt,"","3",xxstring)) < 0) return(x);
9745 if ((y = cmcfm()) < 0) return(y);
9749 printf("?5 - Not implemented yet\n");
9750 return(success = 0);
9751 #endif /* COMMENT */
9753 bctr = x; /* Set local too even if REMOTE SET */
9760 ckstrncpy(tmpbuf,ckitoa(x),TMPBUFSIZ);
9761 sstate = setgen('S', "400", tmpbuf, "");
9762 return((int) sstate);
9764 return(success = 1);
9769 #ifndef MAC /* The Mac has no RS-232 */
9770 case XYCARR: /* CARRIER-WATCH */
9773 #endif /* NOLOCAL */
9777 switch (xx) { /* Avoid long switch statements... */
9779 int c, n; /* Workers */
9780 int getval = 0; /* Whether to get switch value */
9781 int tnserver = 0; /* Client by default */
9782 int opt = -1; /* Telnet Option */
9783 struct FDB sw, op; /* FDBs for each parse function */
9784 #ifdef CK_AUTHENTICATION
9785 extern int sl_topt_a_s_saved;
9786 extern int sl_topt_a_c_saved;
9787 extern int sl_topt_e_s_saved;
9788 extern int sl_topt_e_c_saved;
9789 #endif /* CK_AUTHENTICATION */
9791 if (inserver) /* Server by default when IKSD */
9795 /* Set up chained parse functions... */
9797 cmfdbi(&op, /* First fdb - telopts*/
9799 "/client, /server or", /* hlpmsg */
9801 "", /* addtl string data */
9802 ntnopt, /* addtl numeric data 1 */
9803 0, /* addtl numeric data 2 */
9808 cmfdbi(&sw, /* Second FDB - command switches */
9812 "", /* addtl string data */
9813 ntnoptsw, /* addtl numeric data 1: tbl size */
9814 4, /* addtl numeric data 2: 4 = cmswi */
9815 xxstring, /* Processing function */
9816 tnoptsw, /* Keyword table */
9817 NULL /* Pointer to next FDB */
9820 while (opt < 0) { /* Parse 0 or more switches */
9821 x = cmfdb(&op); /* Parse switch or other thing */
9822 debug(F101,"XYTELOP cmfdb","",x);
9823 if (x < 0) /* Error */
9824 return(x); /* or reparse needed */
9825 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
9827 c = cmgbrk(); /* Get break character */
9828 getval = (c == ':' || c == '='); /* see how switch ended */
9829 if (getval && !(cmresult.kflags & CM_ARG)) {
9830 printf("?This switch does not take arguments\n");
9833 z = cmresult.nresult; /* Numeric result = switch value */
9834 debug(F101,"XYTELOP switch","",z);
9836 switch (z) { /* Process the switch */
9850 opt = TELOPT_BINARY;
9853 opt = TELOPT_NEWENVIRON;
9856 opt = TELOPT_SNDLOC;
9859 opt = TELOPT_AUTHENTICATION;
9862 opt = TELOPT_FORWARD_X;
9865 opt = TELOPT_ENCRYPTION;
9868 opt = TELOPT_KERMIT;
9871 opt = TELOPT_START_TLS;
9874 opt = TELOPT_XDISPLOC;
9883 opt = TELOPT_PRAGMA_HEARTBEAT;
9886 opt = TELOPT_SSPI_LOGON;
9889 opt = TELOPT_PRAGMA_LOGON;
9892 opt = TELOPT_IBM_SAK;
9895 opt = TELOPT_COMPORT;
9898 opt = TELOPT_LOGOUT;
9904 printf("?Unexpected value - %d\n",z);
9908 if (cmresult.fdbaddr == &op)
9910 #endif /* COMMENT */
9913 case TELOPT_ECHO: /* Options only the Server WILL */
9914 case TELOPT_FORWARD_X:
9915 case TELOPT_SEND_URL:
9916 case TELOPT_IBM_SAK:
9918 if ((x = cmkey(tnnegtab,
9920 "desired server state",
9921 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
9925 if ((z = cmcfm()) < 0)
9928 TELOPT_DEF_S_ME_MODE(opt) = x;
9929 TELOPT_ME_MODE(opt) = x;
9931 TELOPT_DEF_C_U_MODE(opt) = x;
9932 TELOPT_U_MODE(opt) = x;
9936 case TELOPT_TTYPE: /* Options only the Client WILL */
9937 case TELOPT_NEWENVIRON:
9939 case TELOPT_AUTHENTICATION:
9940 case TELOPT_START_TLS:
9941 case TELOPT_XDISPLOC:
9944 case TELOPT_COMPORT:
9945 if ((x = cmkey(tnnegtab,
9947 "desired client state",
9948 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
9952 if ((z = cmcfm()) < 0)
9955 TELOPT_DEF_S_U_MODE(opt) = x;
9956 TELOPT_U_MODE(opt) = x;
9957 #ifdef CK_AUTHENTICATION
9958 if (opt == TELOPT_AUTHENTICATION)
9959 sl_topt_a_s_saved = 0;
9960 #endif /* CK_AUTHENTICATION */
9962 TELOPT_DEF_C_ME_MODE(opt) = x;
9963 TELOPT_ME_MODE(opt) = x;
9964 #ifdef CK_AUTHENTICATION
9965 if (opt == TELOPT_AUTHENTICATION)
9966 sl_topt_a_c_saved = 0;
9967 #endif /* CK_AUTHENTICATION */
9972 if ((x = cmkey(tnnegtab,
9975 "desired server state" :
9976 "desired client state",
9977 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
9982 if ((y = cmkey(tnnegtab,
9984 !tnserver ? "desired server state" :
9985 "desired client state",
9986 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
9991 if ((z = cmcfm()) < 0)
9994 TELOPT_DEF_S_ME_MODE(opt) = x;
9995 TELOPT_ME_MODE(opt) = x;
9996 TELOPT_DEF_S_U_MODE(opt) = y;
9997 TELOPT_U_MODE(opt) = y;
9998 #ifdef CK_ENCRYPTION
9999 if (opt == TELOPT_ENCRYPTION)
10000 sl_topt_e_s_saved = 0;
10001 #endif /* CK_ENCRYPTION */
10003 TELOPT_DEF_C_ME_MODE(opt) = x;
10004 TELOPT_ME_MODE(opt) = x;
10005 TELOPT_DEF_C_U_MODE(opt) = y;
10006 TELOPT_U_MODE(opt) = y;
10007 #ifdef CK_ENCRYPTION
10008 if (opt == TELOPT_ENCRYPTION)
10009 sl_topt_e_c_saved = 0;
10010 #endif /* CK_ENCRYPTION */
10013 return(success = 1);
10016 case XYTEL: /* TELNET */
10017 if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "",
10021 case CK_TN_EC: /* ECHO */
10022 if ((x = cmkey(rltab,nrlt,
10023 "initial TELNET echoing state",
10024 "local",xxstring)) < 0)
10026 if ((y = cmcfm()) < 0) return(y);
10028 return(success = 1);
10030 case CK_TN_RE: /* REMOTE-ECHO */
10031 return(success = seton(&tn_rem_echo));
10033 case CK_TN_DB: /* DEBUG */
10034 return(success = seton(&tn_deb));
10036 case CK_TN_TT: /* TERMINAL TYPE */
10037 if ((y = cmtxt("terminal type for TELNET connections","",
10041 free(tn_term); /* Free any previous storage */
10044 if (s == NULL || *s == NUL) { /* If none given */
10045 tn_term = NULL; /* remove the override string */
10046 return(success = 1);
10047 } else if ((tn_term = malloc(strlen(s)+1))) {
10049 return(success = 1);
10050 } else return(success = 0);
10052 #ifdef CK_FORWARD_X
10053 case CK_TN_FX: /* FORWARD-X */
10054 if ((x=cmkey(tnfwdxtab,ntnfwdx,"","xauthority-file",xxstring)) < 0)
10057 case 0: { /* Xauthority-File */
10058 x = cmifi("Full path of .Xauthority file","",&s,&y,xxstring);
10059 if (x < 0 && x != -3)
10061 makestr(&tn_fwdx_xauthority,s);
10062 return(success = 1);
10064 case 1: { /* No-Encryption */
10065 extern int fwdx_no_encrypt;
10066 return(success = seton(&fwdx_no_encrypt));
10069 return(success = 0);
10070 #endif /* CK_FORWARD_X */
10072 case CK_TN_NL: /* TELNET NEWLINE-MODE */
10073 if ((x = cmkey(tn_nlmtab,ntn_nlm,"","nvt",xxstring)) < 0)
10075 if (x == TN_NL_BIN) {
10076 if ((x = cmkey(tnlmtab,ntnlm,"","raw",xxstring)) < 0)
10078 if ((y = cmcfm()) < 0)
10081 return(success = 1);
10082 } else if (x == TN_NL_NVT) {
10083 if ((x = cmkey(tnlmtab,ntnlm,"","on",xxstring)) < 0)
10085 if ((y = cmcfm()) < 0)
10088 return(success = 1);
10090 if ((y = cmcfm()) < 0)
10093 return(success = 1);
10096 case CK_TN_XF: /* BINARY-TRANSFER-MODE */
10097 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10098 if ((y = cmcfm()) < 0) return(y);
10100 return(success = 1);
10102 case CK_TN_NE: /* NO-ENCRYPT-DURING-XFER */
10103 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10104 if ((y = cmcfm()) < 0) return(y);
10106 /* Don't let this be set remotely */
10107 if (apcactive == APC_LOCAL ||
10108 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
10109 return(success = 0);
10110 #endif /* CK_APC */
10111 tn_no_encrypt_xfer = z;
10112 return(success = 1);
10114 case CK_TN_BM: /* BINARY-MODE */
10115 if ((x = cmkey(tnnegtab,ntnnegtab,"","refused",xxstring)) < 0)
10117 if ((y = cmcfm()) < 0)
10119 TELOPT_DEF_S_ME_MODE(TELOPT_BINARY) = x;
10120 TELOPT_DEF_S_U_MODE(TELOPT_BINARY) = x;
10121 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = x;
10122 TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = x;
10123 return(success = 1);
10126 case CK_TN_IKS: /* KERMIT */
10127 if ((x = cmkey(tnnegtab,ntnnegtab,"DO","accept",xxstring)) < 0)
10129 if ((y = cmkey(tnnegtab,ntnnegtab,"WILL","accept",xxstring)) < 0)
10131 if ((z = cmcfm()) < 0)
10133 TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = y;
10134 TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = x;
10135 TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = y;
10136 TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = x;
10137 return(success = 1);
10138 #endif /* IKS_OPTION */
10141 case CK_TN_TLS: /* START_TLS */
10142 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10144 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10146 if ((z = cmcfm()) < 0)
10148 TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = x;
10149 TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = y;
10150 TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = x;
10151 TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = y;
10152 return(success = 1);
10153 #endif /* CK_SSL */
10156 case CK_TN_NAWS: /* NAWS */
10157 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10159 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10161 if ((z = cmcfm()) < 0)
10163 TELOPT_DEF_S_ME_MODE(TELOPT_NAWS) = x;
10164 TELOPT_DEF_S_U_MODE(TELOPT_NAWS) = y;
10165 TELOPT_DEF_C_ME_MODE(TELOPT_NAWS) = x;
10166 TELOPT_DEF_C_U_MODE(TELOPT_NAWS) = y;
10167 return(success = 1);
10168 #endif /* CK_NAWS */
10170 #ifdef CK_AUTHENTICATION
10171 case CK_TN_AU: /* AUTHENTICATION */
10172 if ((x = cmkey(tnauthtab,ntnauth,"","",xxstring)) < 0)
10174 if (x == TN_AU_FWD) {
10175 extern int forward_flag;
10176 return(success = seton(&forward_flag));
10177 } else if (x == TN_AU_TYP) {
10178 extern int auth_type_user[];
10179 extern int sl_auth_type_user[];
10180 extern int sl_auth_saved;
10181 int i, j, atypes[AUTHTYPLSTSZ];
10183 for (i = 0; i < AUTHTYPLSTSZ; i++) {
10184 if ((y = cmkey(autyptab,nautyp,"",
10185 i == 0 ? "automatic" : "" ,
10191 if (i > 0 && (y == AUTHTYPE_AUTO || y == AUTHTYPE_NULL)) {
10193 "\r\n?Choice may only be used in first position.\r\n");
10196 for (j = 0; j < i; j++) {
10197 if (atypes[j] == y) {
10198 printf("\r\n?Choice has already been used.\r\n");
10203 if (y == AUTHTYPE_NULL || y == AUTHTYPE_AUTO) {
10208 if (i < AUTHTYPLSTSZ)
10209 atypes[i] = AUTHTYPE_NULL;
10210 if ((z = cmcfm()) < 0)
10213 for (i = 0; i < AUTHTYPLSTSZ; i++) {
10214 auth_type_user[i] = atypes[i];
10215 sl_auth_type_user[i] = 0;
10217 } else if (x == TN_AU_HOW) {
10218 if ((y = cmkey(auhowtab,nauhow,"","any",xxstring)) < 0)
10220 if ((z = cmcfm()) < 0)
10223 } else if (x == TN_AU_ENC) {
10224 if ((y = cmkey(auenctab,nauenc,"","encrypt",xxstring)) < 0)
10226 if ((z = cmcfm()) < 0)
10230 if ((y = cmcfm()) < 0)
10232 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = x;
10233 TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = x;
10235 return(success = 1);
10236 #endif /* CK_AUTHENTICATION */
10238 #ifdef CK_ENCRYPTION
10239 case CK_TN_ENC: { /* ENCRYPTION */
10242 static struct keytab * tnetbl = NULL;
10243 static int ntnetbl = 0;
10245 if ((y = cmkey(tnenctab,ntnenc,"","",xxstring)) < 0)
10249 x = ck_get_crypt_table(&tnetbl,&ntnetbl);
10250 debug(F101,"ck_get_crypt_table x","",x);
10251 debug(F101,"ck_get_crypt_table n","",ntnetbl);
10252 if (x < 1 || !tnetbl || ntnetbl < 1) /* Didn't get it */
10255 printf("?Oops, types not loaded\n");
10258 if ((x = cmkey(tnetbl,ntnetbl,"type of encryption",
10259 "automatic",xxstring)) < 0)
10261 if ((z = cmcfm()) < 0)
10267 if ((z = cmcfm()) < 0)
10270 /* Don't let this be set remotely */
10271 if (apcactive == APC_LOCAL ||
10272 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10273 return(success = 0);
10274 #endif /* CK_APC */
10278 if ((z = cmcfm()) < 0)
10281 /* Don't let this be set remotely */
10282 if (apcactive == APC_LOCAL ||
10283 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10284 return(success = 0);
10285 #endif /* CK_APC */
10289 if ((z = cmcfm()) < 0)
10291 TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = y;
10292 TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = y;
10293 TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = y;
10294 TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = y;
10296 return(success = 1);
10298 #endif /* CK_ENCRYPTION */
10300 case CK_TN_BUG: /* BUG */
10301 if ((x = cmkey(tnbugtab,4,"",
10302 "binary-me-means-u-too",xxstring)) < 0)
10304 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
10305 if ((y = cmcfm()) < 0) return(y);
10320 tn_auth_krb5_des_bug = z;
10323 return(success = 1);
10325 #ifdef CK_ENVIRONMENT
10326 case CK_TN_XD: /* XDISPLOC */
10327 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10329 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10331 if ((z = cmcfm()) < 0)
10333 TELOPT_DEF_S_ME_MODE(TELOPT_XDISPLOC) = x;
10334 TELOPT_DEF_S_U_MODE(TELOPT_XDISPLOC) = y;
10335 TELOPT_DEF_C_ME_MODE(TELOPT_XDISPLOC) = x;
10336 TELOPT_DEF_C_U_MODE(TELOPT_XDISPLOC) = y;
10337 return(success = 1);
10340 char * msg = "value of telnet environment variable";
10341 extern int tn_env_flg;
10342 extern char tn_env_acct[], tn_env_disp[], tn_env_job[],
10343 tn_env_prnt[], tn_env_sys[];
10344 extern char * tn_loc;
10345 if ((x = cmkey(tnenvtab,ntnenv,"","",xxstring)) < 0)
10347 if (x == TN_ENV_UVAR) { /* User variables */
10351 extern char * tn_env_uservar[8][2];
10353 /* Get the user variable name */
10354 if ((x = cmfld("Name of Environment Variable","",&s,
10359 env = getenv(uvar);
10360 if (!env) env = "";
10362 if ((x = cmtxt("Value of Environment Variable",env,
10368 /* Now that we have the variable and perhaps a value */
10369 /* there are three possibilities: (1) new variable */
10370 /* and associated value; (2) variable already exists */
10371 /* but we have a new value; (3) variable already */
10372 /* exists but no new value therefore the user wants */
10373 /* to clear variable. */
10375 /* Try to find an existing variable */
10376 for (x = 0; x < 8; x++) {
10377 if (!ckstrcmp(tn_env_uservar[x][0],uvar,-1,0)) {
10379 free(tn_env_uservar[x][1]);
10380 tn_env_uservar[x][1] = uval;
10382 return(success = 1);
10384 free(tn_env_uservar[x][0]);
10385 tn_env_uservar[x][0] = NULL;
10386 free(tn_env_uservar[x][1]);
10387 tn_env_uservar[x][1] = NULL;
10389 return(success = 1);
10394 /* Couldn't find one; look for empty location to insert */
10395 for (x = 0; x < 8; x++) {
10396 if (!tn_env_uservar[x][0]) {
10397 tn_env_uservar[x][0] = uvar;
10398 tn_env_uservar[x][1] = uval;
10399 return(success = 1);
10402 printf("?Sorry, no space for variable.\n");
10403 return(success = 0);
10405 if (x == TN_ENV_OFF || x == TN_ENV_ON) {
10406 if ((y = cmcfm()) < 0) return(y);
10409 printf("?Sorry, command disabled.\r\n");
10410 return(success = 0);
10413 tn_env_flg = x == TN_ENV_OFF ? 0 : 1;
10414 return(success = 1);
10417 /* Not ON/OFF - Get the value */
10420 if ((y = cmtxt(msg, "", &s, xxstring)) < 0) {
10427 return(success = 0);
10429 if ((int)strlen(s) > 63) {
10430 printf("Sorry, too long\n");
10435 ckstrncpy(uidbuf,s,UIDBUFLEN);
10439 ckstrncpy(tn_env_acct,s,64);
10442 ckstrncpy(tn_env_disp,s,64);
10445 ckstrncpy(tn_env_job,s,64);
10448 ckstrncpy(tn_env_prnt,s,64);
10451 ckstrncpy(tn_env_sys,s,64);
10455 makestr(&tn_loc,s);
10458 printf("\n?Not yet implemented\n");
10461 return(success = 1);
10463 #endif /* CK_ENVIRONMENT */
10466 case CK_TN_LOC: { /* LOCATION */
10467 extern char * tn_loc;
10468 if ((y = cmtxt("Location string","",&s,xxstring)) < 0)
10471 makestr(&tn_loc,s);
10472 return(success = 1);
10474 #endif /* CK_SNDLOC */
10475 case CK_TN_SFU: /* Microsoft SFU compatibility */
10476 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10477 if ((y = cmcfm()) < 0) return(y);
10479 return(success = 1);
10482 case CK_TN_WAIT: /* WAIT-FOR-NEGOTIATIONS */
10483 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10484 if ((y = cmcfm()) < 0) return(y);
10491 #endif /* IKSDCONF */
10493 printf("?Sorry, command disabled.\r\n");
10494 return(success = 0);
10499 return(success = 1);
10501 case CK_TN_DL: /* DELAY SUBNEGOTIATIONS */
10502 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10503 if ((y = cmcfm()) < 0) return(y);
10510 #endif /* IKSDCONF */
10512 printf("?Sorry, command disabled.\r\n");
10513 return(success = 0);
10517 return(success = 1);
10519 case CK_TN_PUID: { /* PROMPT-FOR-USERID */
10521 if ((y = cmtxt("Prompt string","",&s,xxstring)) < 0)
10524 /* we must check to make sure there are no % fields */
10526 for (i = 0; i < len; i++) {
10528 if (s[i+1] != '%') {
10529 printf("%% fields are not used in this command.\n");
10535 makestr(&tn_pr_uid,s);
10536 return(success = 1);
10542 #endif /* TNCODE */
10546 case XYCOUN: /* SET COUNT */
10547 x = cmnum("Positive number","0",10,&z,xxstring);
10548 if (x < 0) return(x);
10549 if ((x = cmcfm()) < 0) return(x);
10551 printf("?A positive number, please\n");
10554 debug(F101,"XYCOUN: z","",z);
10555 return(success = setnum(&count[cmdlvl],z,0,10000));
10560 return(success = seton(&inpcas[cmdlvl]));
10563 case XYCMD: /* COMMAND ... */
10564 if ((y = cmkey(scmdtab,nbytt,"","",xxstring)) < 0)
10568 if ((y = cmcfm()) < 0)
10570 concb((char)escape);
10571 return(success = 1);
10574 if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x,
10577 if (x != 7 && x != 8) {
10578 printf("\n?The choices are 7 and 8\n");
10579 return(success = 0);
10581 if ((y = cmcfm()) < 0) return(y);
10582 if (x == 7) cmdmsk = 0177;
10583 else if (x == 8) cmdmsk = 0377;
10584 return(success = 1);
10587 if ((y = cmnum("maximum number of commands in recall buffer","10",
10588 10,&x,xxstring)) < 0)
10590 if ((y = cmcfm()) < 0) return(y);
10591 return(success = cmrini(x));
10592 #endif /* CK_RECALL */
10595 return(success = seton(&cm_retry));
10596 #endif /* CK_RECALL */
10597 case SCMD_MOR: /* More-prompting */
10598 success = seton(&xaskmore);
10600 saveask = xaskmore;
10603 if ((x = seton(&y)) < 0) return(x);
10604 cmdsquo(y); /* Do it the right way */
10605 cmd_quoting = y; /* Also keep a global copy */
10606 /* Set string-processing function */
10608 xxstring = y ? zzstring : (xx_strp) NULL;
10611 xxstring = y ? zzstring : (xx_strp) NULL;
10613 xxstring = y ? zzstring : (xx_strp) NULL;
10614 #endif /* CK_ANSIC */
10615 #endif /* datageneral */
10616 return(success = 1);
10620 case SCMD_COL: { /* Command-screen colors */
10622 fg = cmkey(ttyclrtab, nclrs,
10623 "foreground color and then background color",
10628 if ((bg = cmkey(ttyclrtab,nclrs,
10629 "background color","black",xxstring)) < 0)
10631 if ((y = cmcfm()) < 0)
10633 colorcmd = fg | bg << 4;
10634 return(success = 1);
10636 case SCMD_SCR: /* Command Scrollback size */
10637 if ((y = cmnum("COMMAND scrollback buffer size, lines","512",10,&x,
10640 /* The max number of lines is the RAM */
10641 /* we can actually dedicate to a */
10642 /* scrollback buffer given the maximum */
10643 /* process memory space of 512MB */
10644 if (x < 256 || x > 2000000L) {
10645 printf("\n?The size must be between 256 and 2,000,000.\n");
10646 return(success = 0);
10648 if ((y = cmcfm()) < 0) return(y);
10649 tt_scrsize[VCMD] = x;
10651 return(success = 1);
10654 if ((y = cmnum("Number of columns in display window",
10655 "80",10,&x,xxstring)) < 0)
10657 if ((y = cmcfm()) < 0) return(y);
10659 os2_setcmdwidth(x);
10660 return(success = 1);
10663 if ((y = cmnum("Number of rows in display window",
10664 "24",10,&x,xxstring)) < 0)
10666 if ((y = cmcfm()) < 0) return(y);
10667 os2_setcmdheight(x);
10668 return(success = 1);
10671 extern int marginbot;
10672 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
10673 if ((x = cmcfm()) < 0) return(x);
10674 if (y != tt_status[VCMD]) {
10675 /* Might need to fixup the margins */
10676 tt_status[VCMD] = y;
10678 tt_szchng[VCMD] = 2;
10681 VscrnInit(VCMD); /* Height set here */
10684 tt_szchng[VCMD] = 1;
10687 VscrnInit(VCMD); /* Height set here */
10690 return(success = 1);
10697 ppos = VscrnGetCurPos(VCMD);
10701 itoa(ppos->y+1, tmpbuf, 10);
10702 if ((y = cmnum("row (1-based)",tmpbuf,10,&row,xxstring)) < 0)
10705 itoa(ppos->x+1, tmpbuf, 10);
10706 if ((y = cmnum("col (1-based)",tmpbuf,10,&col,xxstring)) < 0)
10708 if ((x = cmcfm()) < 0) return(x);
10710 lgotoxy( VCMD, col, row ) ;
10711 VscrnIsDirty( VCMD );
10714 #endif /* NOLOCAL */
10717 y = cmnum("Command screen width, characters","80",10,&x,xxstring);
10718 return(setnum(&cmd_cols,x,y,1024));
10721 y = cmnum("Command screen height, rows","24",10,&x,xxstring);
10722 return(setnum(&cmd_rows,x,y,1024));
10726 return(seton(&cmdint));
10730 return(seton(&cmdadl));
10731 #endif /* CK_AUTODL */
10733 #ifdef DOUBLEQUOTING
10736 return(seton(&dblquo));
10738 #endif /* DOUBLEQUOTING */
10741 y = cmnum("Error message verbosity level, 0-3","1",10,&x,xxstring);
10742 return(setnum(&cmd_err,x,y,3));
10745 return(setvareval());
10754 case XYDFLT: /* SET DEFAULT = CD */
10755 return(success = docd(XXCWD));
10757 case XYDEBU: /* SET DEBUG { on, off, session } */
10758 if ((y = cmkey(dbgtab,ndbg,"","",xxstring)) < 0)
10762 return(seton(&debtim) < 0 ? x : (success = 1));
10764 /* why this change? */
10765 return(success = seton(&debtim));
10766 #endif /* COMMENT */
10769 if (inserver && isguest) {
10770 printf("?Sorry, command disabled.\r\n");
10771 return(success = 0);
10777 y = cmnum("Max length for debug log strings","",10,&x,xxstring);
10778 if ((z = setnum(&debxlen,x,y,-1)) < 0)
10780 if ((x = cmcfm()) < 0)
10782 return(success = 1);
10785 if ((x = cmcfm()) < 0)
10789 #endif /* NOLOCAL */
10791 if (deblog) doclslog(LOGD);
10793 return(success = 1);
10796 if ((x = cmcfm()) < 0)
10799 deblog = debopn("debug.log", 0);
10800 return(success = deblog ? 1 : 0);
10802 printf("?Sorry, debug log feature not enabled\n");
10803 return(success = 0);
10806 if ((x = cmcfm()) < 0)
10810 #endif /* NOLOCAL */
10811 return(success = 1);
10813 case DEB_MSG: /* Debug messages 2010/03/12 */
10814 if ((y = cmkey(ooetab,nooetab,"","on",xxstring)) < 0) return(y);
10815 if ((x = cmcfm()) < 0) return(x);
10822 case XYDELA: /* SET DELAY */
10823 y = cmnum("Number of seconds before starting to send",
10824 "5",10,&x,xxstring);
10826 return(success = setnum(&ckdelay,x,y,999));
10827 #endif /* NOXFER */
10837 #endif /* CK_TAPI */
10839 case XYDIAL: /* SET MODEM or SET DIAL */
10840 return(setdial(-1));
10842 return(setmodem());
10844 /* not implemented yet */
10845 case XYANSWER: /* SET ANSWER */
10846 return(setanswer());
10847 #endif /* COMMENT */
10848 #endif /* NODIAL */
10851 case XYDUPL: /* SET DUPLEX */
10852 if ((y = cmkey(dpxtab,2,"","full",xxstring)) < 0) return(y);
10853 if ((x = cmcfm()) < 0) return(x);
10855 return(success = 1);
10857 case XYLCLE: /* LOCAL-ECHO (= DUPLEX) */
10858 return(success = seton(&duplex));
10860 case XYESC: /* SET ESCAPE */
10861 return(success = setcc(ckitoa(DFESC),&escape));
10862 #endif /* NOLOCAL */
10864 case XYEXIT: /* SET EXIT */
10865 if ((z = cmkey(xittab,nexit,"","",xxstring)) < 0)
10868 case 0: /* STATUS */
10869 y = cmnum("EXIT status code","",10,&x,xxstring);
10870 return(success = setnum(&xitsta,x,y,-1));
10871 case 1: /* WARNING */
10872 if ((z = cmkey(xitwtab,nexitw,"","",xxstring)) < 0)
10874 if ((y = cmcfm()) < 0) return(y);
10876 return(success = 1);
10878 success = seton(&exitonclose);
10880 if (success) tn_exit = exitonclose;
10881 #endif /* TCPSOCKET */
10884 extern int exithangup;
10885 return((success = seton(&exithangup)));
10889 } /* End of SET EXIT switch() */
10896 case XYFILE: /* SET FILE */
10897 return(setfil(rmsflg));
10899 case XYFLOW: { /* FLOW-CONTROL */
10900 extern int cxflow[];
10906 if (network && istncomport())
10908 #endif /* TN_COMPORT */
10911 m = "Flow control type, one of the following:\n\
10912 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10913 or connection type";
10915 /* All this is because chained FDB's don't give chained help yet */
10919 "Flow control type, one of the following:\n\
10920 keep none rts/cts\n\
10921 or connection type",
10923 "Flow control type, one of the following:\n\
10925 or connection type";
10926 #endif /* CK_RTSCTS */
10931 "Flow control type, one of the following:\n\
10932 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10933 or connection type";
10934 #else /* CK_DTRCTS */
10935 "Flow control type, one of the following:\n\
10936 dtr/cd keep none rts/cts xon/xoff\n\
10937 or connection type";
10938 #endif /* CK_DTRCTS */
10939 #else /* CK_DTRCD */
10941 "Flow control type, one of the following:\n\
10942 dtr/cts keep none rts/cts xon/xoff\n\
10943 or connection type";
10944 #else /* CK_DTRCTS */
10945 "Flow control type, one of the following:\n\
10946 keep none rts/cts xon/xoff\n\
10947 or connection type";
10948 #endif /* CK_DTRCTS */
10949 #endif /* CK_DTRCD */
10951 "Flow control type, one of the following:\n\
10952 keep none xon/xoff\n\
10953 or connection type";
10954 #endif /* CK_RTSCTS */
10957 cmfdbi(&k1,_CMKEY,m,"","",ncxtypesw, 4, xxstring, cxtypesw, &k2);
10964 (tncomport ? ntnflo : nflo),
10967 #endif /* TN_COMPORT */
10971 (tncomport ? tnflotab : flotab),
10974 #endif /* TN_COMPORT */
10978 if (x < 0) { /* Error */
10979 if (x == -2 || x == -9)
10980 printf("?No keywords or switches match: \"%s\"\n",atmbuf);
10983 z = cmresult.nresult; /* Keyword value */
10984 if (cmresult.fdbaddr == &k2) { /* Flow-control type keyword table */
10985 if ((x = cmcfm()) < 0) /* Set it immediately */
10988 debug(F101,"set flow","",flow);
10990 if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
10991 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
10992 #endif /* CK_SPEED */
10993 autoflow = (flow == FLO_AUTO);
10994 return(success = 1); /* Done */
10996 debug(F101,"set flow /blah 1","",z); /* SET FLOW /for-what */
10997 if ((y = cmkey(flotab,nflo,"Flow control type","none",xxstring)) < 0)
10999 if ((x = cmcfm()) < 0)
11001 debug(F101,"set flow /blah 2","",y);
11002 if (y == FLO_AUTO) {
11004 "?Sorry, \"automatic\" can not be assigned to a connection type.\n");
11006 } else if (z >= 0 && z <= CXT_MAX)
11008 debug(F101,"set flow","",flow);
11009 debug(F101,"set flow autoflow","",autoflow);
11010 return(success = 1);
11013 case XYHAND: /* HANDSHAKE */
11014 if ((y = cmkey(hshtab,nhsh,"","none",xxstring)) < 0) return(y);
11016 if ((x = cmnum("ASCII value","",10,&y,xxstring)) < 0)
11018 if ((y < 1) || ((y > 31) && (y != 127))) {
11019 printf("?Character must be in ASCII control range\n");
11023 if ((x = cmcfm()) < 0) return(x);
11024 turn = (y > 0127) ? 0 : 1;
11026 return(success = 1);
11029 case XYMACR: /* SET MACRO */
11030 if ((y = cmkey(smactab,2,"","",xxstring)) < 0) return(y);
11032 case 0: return(success = seton(&mecho));
11033 case 1: return(success = seton(&merror[cmdlvl]));
11034 default: return(-2);
11040 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
11041 if ((y = cmcfm()) < 0) return(y);
11043 printf("Sorry, SET MESSAGES not implemented yet\n");
11044 return(success = 0);
11052 case XYPARI: /* PARITY */
11053 if ((y = cmkey(partbl,npar,"","none",xxstring)) < 0)
11056 /* If parity not none, then we also want 8th-bit prefixing */
11059 if (y == 'H') { /* Hardware */
11060 if ((x = cmkey(hwpartbl,nhwpar,"","even",xxstring)) < 0)
11063 #endif /* HWPARITY */
11065 if ((z = cmcfm()) < 0)
11069 if (y == 'H') { /* 8 data bits plus hardware parity */
11073 #endif /* NOXFER */
11075 } else { /* 7 data bits + software parity */
11077 #endif /* HWPARITY */
11080 ebqflg = (parity) ? 1 : 0;
11081 #endif /* NOXFER */
11084 #endif /* HWPARITY */
11087 if (network && istncomport())
11088 tnsettings(parity, 0);
11089 #endif /* TN_COMPORT */
11091 return(success = 1);
11094 case XYPROM: /* SET PROMPT */
11096 Note: xxstring not invoked here. Instead, it is invoked every time the
11097 prompt is issued. This allows the prompt string to contain variables
11098 that can change, like \v(dir), \v(time), etc.
11100 ckmakmsg(line, /* Default might have trailing space */
11103 inserver ? ikprompt : ckprompt,
11107 if ((x = cmtxt("Program's command prompt",line,&s,NULL)) < 0)
11109 s = brstrip(s); /* Remove enclosing braces, if any */
11110 cmsetp(s); /* Set the prompt */
11111 return(success = 1);
11112 #endif /* NOFRILLS */
11115 case XYRETR: /* RETRY: per-packet retry limit */
11116 y = cmnum("Maximum retries per packet","10",10,&x,xxstring);
11118 if ((x = setnum(&maxtry,x,y,999)) < 0) return(x);
11120 if (maxtry <= wslotr) {
11121 printf("?Retry limit must be greater than window size\n");
11122 return(success = 0);
11124 #endif /* COMMENT */
11126 sstate = setgen('S', "403", ckitoa(maxtry), "");
11127 return((int) sstate);
11128 } else return(success = x);
11129 #endif /* NOXFER */
11132 case XYSERV: /* SET SERVER items */
11133 if ((y = cmkey(srvtab,nsrvt,"","",xxstring)) < 0) return(y);
11136 if ((y = cmnum("Number of seconds, or 0 for no idle timeout",
11137 "0",10,&x,xxstring)) < 0)
11141 if ((y = cmcfm()) < 0)
11147 return(success = 1);
11149 if ((y = cmnum("Interval for server NAKs, 0 = none",
11151 10,&x, xxstring)) < 0)
11155 "\n?Specify a positive number, or 0 for no server NAKs\n");
11158 if ((y = cmcfm()) < 0) return(y);
11160 sstate = setgen('S', "404", ckitoa(x), "");
11161 return((int) sstate);
11166 srvtim = x; /* Set the server timeout variable */
11167 return(success = 1);
11169 case XYSERD: /* SERVER DISPLAY */
11170 return(success = seton(&srvdis)); /* ON or OFF... */
11173 case XYSERP: /* SERVER GET-PATH */
11174 return(parsdir(2));
11177 case XYSERL: /* SERVER LOGIN */
11180 case XYSERC: /* SERVER CD-MESSAGE */
11182 cmkey(onoff,2,"","",xxstring) :
11183 cmkey(cdmsg,3,"","",xxstring);
11186 if (x == 2) { /* CD-MESSAGE FILE */
11187 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
11193 makestr(&cdmsgstr,s);
11194 makelist(cdmsgstr,cdmsgfile,8);
11195 return(success = 1);
11197 if ((y = cmcfm()) < 0) /* CD-MESSAGE ON/OFF */
11200 sstate = setgen('S', "420", x ? "1" : "0", "");
11201 return((int) sstate);
11207 return(success = 1);
11209 case XYSERK: /* SERVER KEEPALIVE */
11210 return(success = seton(&srvping)); /* ON or OFF... */
11215 #endif /* NOSERVER */
11221 case XYSUSP: /* SET SUSPEND */
11222 seton(&xsuspend); /* on or off... */
11223 return(success = 1);
11227 case XYTAKE: /* SET TAKE */
11228 if ((y = cmkey(taktab,4,"","",xxstring)) < 0) return(y);
11230 case 0: return(success = seton(&techo));
11232 case 1: return(success = seton(&takerr[cmdlvl]));
11234 case 1: return(success = seton(&takerr[tlevel]));
11236 case 2: techo = 0; return(success = 1); /* For compatibility with */
11237 case 3: techo = 1; return(success = 1); /* MS-DOS Kermit */
11238 default: return(-2);
11242 case XYSCRI: /* SET SCRIPT */
11243 if ((y = cmkey(scrtab,1,"","echo",xxstring)) < 0) return(y);
11245 case 0: return(success = seton(&secho));
11246 default: return(-2);
11248 #endif /* NOSCRIPT */
11256 case XYTERM: /* SET TERMINAL */
11258 success = (x > 0) ? 1 : 0;
11262 case XYWIN95: /* SET WIN95 workarounds */
11264 success = (x > 0 ? 1 : 0);
11269 case XYDLR: /* SET DIALER workarounds */
11271 success = (x > 0 ? 1 : 0);
11274 case XYTITLE: /* SET TITLE of window */
11276 success = (x > 0 ? 1 : 0);
11281 case XYMOUSE: /* SET MOUSE */
11282 return(success = setmou());
11283 #endif /* OS2MOUSE */
11285 case XYBELL: /* SET BELL */
11286 return(success = setbell());
11290 return(success = setprty() );
11296 #endif /* NOLOCAL */
11300 /* SET SEND/RECEIVE protocol parameters. */
11305 return(setsr(xx,rmsflg));
11306 #endif /* NOXFER */
11309 case XYSESS: /* SESSION-LOG */
11310 if ((x = cmkey(sfttab,nsfttab,"type of file",
11320 if ((y = cmcfm()) < 0)
11322 if (x == 999) { /* TIMESTAMPED-TEXT */
11323 sessft = XYFT_T; /* Implies text */
11324 slogts = 1; /* and timestamps */
11325 } else if (x == 998) { /* NULL-PADDED-LINES */
11326 slognul = 1; /* adds NUL after ^J */
11327 } else { /* A regular type */
11328 sessft = x; /* The type */
11329 slogts = 0; /* No timestampes */
11331 return(success = 1);
11333 case XYSPEE: /* SET SPEED */
11335 if (local && !network) {
11338 "Transmission rate for ",
11340 " (bits per second)",
11345 "Serial-port speed (bits per second)",
11352 if (network && istncomport())
11353 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
11355 #endif /* TN_COMPORT */
11356 x = cmkey(spdtab,nspd,line,"",xxstring);
11358 if (x == -3) printf("?value required\n");
11359 #ifdef USETCSETSPEED
11360 /* In this case, any number can be tried */
11361 /* There's a parse error message but the request still goes thru */
11362 if (rdigits(atmbuf))
11365 #endif /* USETCSETSPEED */
11368 if ((y = cmcfm()) < 0) return(y);
11371 printf("?Sorry, command disabled.\r\n");
11372 return(success = 0);
11376 printf("?SET SPEED has no effect without prior SET LINE\n");
11377 return(success = 0);
11381 #endif /* TN_COMPORT */
11383 printf("\n?Speed cannot be set for network connections\n");
11384 return(success = 0);
11388 Note: This way of handling speeds is not 16-bit safe for speeds greater
11389 than 230400. The argument to ttsspd() should have been a long.
11391 #ifdef USETCSETSPEED
11394 #endif /* USETCSETSPEED */
11395 zz = (long) x * 10L;
11396 if (zz == 130L) zz = 134L;
11397 if (zz == 70L) zz = 75L; /* (see spdtab[] definition) */
11398 if (ttsspd(x) < 0) { /* Call ttsspd with cps, not bps! */
11399 printf("?Unsupported line speed - %ld\n",zz);
11400 return(success = 0);
11403 if (!tttapi || tapipass)
11404 speed = ttgspd(); /* Read it back */
11407 #else /* CK_TAPI */
11408 speed = ttgspd(); /* Read it back */
11409 #endif /* CK_TAPI */
11410 if (speed != zz) { /* Call ttsspd with cps, not bps! */
11411 printf("?SET SPEED fails, speed is %ld\n",speed);
11412 return(success = 0);
11414 if (pflag && !xcmdsrc) {
11416 printf("%s, 75/1200 bps\n",ttname);
11417 else if (speed == 134)
11418 printf("%s, 134.5 bps\n",ttname);
11420 printf("%s, %ld bps\n",ttname,speed);
11422 return(success = 1);
11424 #endif /* NOLOCAL */
11427 case XYXFER: /* SET TRANSFER */
11428 if ((y = cmkey(rmsflg ? rtstab : tstab, /* (or REMOTE SET TRANSFER) */
11429 rmsflg ? nrts : nts,
11430 "","character-set",xxstring)) < 0) return(y);
11433 case XYX_CAN: /* CANCELLATION */
11434 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
11435 if (z == 0) { /* OFF */
11436 if ((y = cmcfm()) < 0) return(y);
11439 if ((y = cmnum("ASCII code for cancellation character",
11443 if (x > 31 && x != 127) {
11444 printf("Cancel character must be 0-31 or 127\n");
11447 if ((y = cmnum("How many required to cause cancellation",
11448 "2",10,&z, xxstring)) < 0)
11451 printf("Number must be 2 or greater\n");
11454 if ((y = cmcfm()) < 0) return(y);
11455 xfrcan = 1; /* CANCELLATION ON */
11456 xfrchr = x; /* Using this character */
11457 xfrnum = z; /* Needing this many of them */
11459 return(success = 1);
11460 #endif /* XFRCAN */
11463 case XYX_CSE: /* CHARACTER-SET */
11464 if ((y = cmkey(tcstab,ntcs,"","transparent",xxstring)) < 0)
11466 if ((x = cmcfm()) < 0) return(x);
11468 sstate = setgen('S', "405", tcsinfo[y].designator, "");
11469 return((int) sstate);
11471 extern int s_cset, fcharset, axcset[], tcs_save;
11472 tslevel = (y == TC_TRANSP) ? 0 : 1; /* transfer syntax level */
11474 tcharset = y; /* transfer character set */
11475 /* SEND CHARACTER-SET AUTO */
11476 if (tslevel > 0 && s_cset == XMODE_A)
11477 if (y > -1 && y <= MAXTCSETS)
11478 if (axcset[y] > -1 && axcset[y] > MAXFCSETS)
11479 fcharset = axcset[y]; /* Auto-pick file charset */
11480 setxlatype(tcharset,fcharset); /* Translation type */
11482 return(success = 1);
11484 #endif /* NOCSETS */
11486 case XYX_LSH: /* LOCKING-SHIFT */
11487 if ((y = cmkey(lstab,nls,"","on",xxstring)) < 0)
11489 if ((x = cmcfm()) < 0) return(x);
11490 lscapr = (y == 1) ? 1 : 0; /* ON: requested = 1 */
11491 lscapu = (y == 2) ? 2 : 0; /* FORCED: used = 1 */
11492 return(success = 1);
11494 /* #ifdef CK_XYZ */
11495 case XYX_PRO: /* Protocol */
11498 printf("?Sorry, only Kermit protocol is available\n");
11502 return(setproto());
11503 /* #endif */ /* CK_XYZ */
11505 case XYX_MOD: /* Mode */
11506 if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
11508 if ((x = cmcfm()) < 0) return(x);
11510 sstate = setgen('S', "410", y == XMODE_A ? "0" : "1", "");
11511 return((int)sstate);
11516 if (ftpisopen()) { /* If an FTP connection is open */
11517 extern int ftp_xfermode; /* change its transfer mode too */
11518 ftp_xfermode = xfermode;
11520 #endif /* NEWFTP */
11521 return(success = 1);
11524 case XYX_DIS: /* Display */
11525 return(doxdis(1)); /* 1 == Kermit */
11526 #endif /* NOLOCAL */
11528 case XYX_SLO: /* Slow-start */
11529 return(seton(&slostart));
11532 case XYX_CRC: /* CRC */
11533 return(seton(&docrc));
11536 case XYX_BEL: /* Bell */
11537 return(seton(&xfrbel));
11540 case XYX_PIP: /* Pipes */
11543 #endif /* NOPUSH */
11544 printf("Sorry, access to pipes is disabled\n");
11548 #endif /* NOPUSH */
11549 return(seton(&usepipes));
11550 #endif /* PIPESEND */
11552 case XYX_INT: /* Interruption */
11553 return(seton(&xfrint));
11556 return(seton(&xfrxla)); /* Translation */
11559 extern char * xfrmsg;
11560 if ((x = cmtxt("Prompt string","",&s,xxstring)) < 0)
11563 makestr(&xfrmsg,s);
11564 return(success = 1);
11568 extern int whereflg;
11569 return(seton(&whereflg));
11574 #endif /* NOXFER */
11580 case XYXMIT: /* SET TRANSMIT */
11582 #endif /* NOXMIT */
11586 case XYUNCS: /* UNKNOWN-CHARACTER-SET */
11587 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
11588 if ((x = cmcfm()) < 0) return(x);
11590 return(success = 1);
11591 #endif /* NOCSETS */
11592 #endif /* NOXFER */
11596 case XYWILD: /* WILDCARD-EXPANSION */
11597 if ((y = cmkey(wildtab,nwild,
11598 "Wildcard expansion option","on",xxstring)) < 0)
11600 if ((z = cmkey(wdottab,
11602 "whether to match filenames that start with \".\"",
11603 "/no-match-dot-files",
11607 if ((x = cmcfm()) < 0) return(x);
11610 printf("Shell expansion is disabled\n");
11611 return(success = 0);
11622 wildxpand = 0; /* These are the previous */
11623 break; /* hardwired values */
11629 return(success = 1);
11631 #endif /* NOPUSH */
11634 case XYWIND: /* WINDOW-SLOTS */
11635 if (protocol == PROTO_K) {
11636 y = cmnum("Window size for Kermit protocol, 1 to 32",
11637 "1", 10, &x, xxstring);
11638 y = setnum(&z,x,y,MAXWS); /* == 32 */
11641 else if (protocol == PROTO_Z) {
11642 y = cmnum("Window size for ZMODEM protocol, 0 to 65535",
11643 "0", 10, &x, xxstring);
11644 y = setnum(&z,x,y,65535);
11646 #endif /* CK_XYZ */
11648 y = cmnum("Window size for current protocol",
11649 "", 10, &x, xxstring);
11650 y = setnum(&z,x,y,65472); /* Doesn't matter - we won't use it */
11652 if (y < 0) return(y);
11653 if (protocol == PROTO_K) {
11658 else if (protocol == PROTO_Z) {
11659 /* Zmodem windowing is closer to Kermit packet length */
11660 /* than Kermit window size. If Window size is zero */
11661 /* an end of frame and CRC is sent only at the end of */
11662 /* the file (default). Otherwise, an End of Frame */
11663 /* and CRC are sent after Window Size number of bytes */
11664 if (z < 0) /* Disable windowing */
11667 printf("?SET WINDOW does not apply to %s protocol\n",
11668 ptab[protocol].p_name
11671 #endif /* CK_XYZ */
11674 /* This is taken care of automatically now in protocol negotiation */
11676 printf("?Window slots must be less than retry limit\n");
11677 return(success = 0);
11679 #endif /* COMMENT */
11680 if (protocol == PROTO_K && rmsflg) { /* Set remote window size */
11681 wslotr = z; /* Set local window size too */
11682 ptab[protocol].winsize = wslotr;
11683 sstate = setgen('S', "406", ckitoa(z), "");
11684 return((int) sstate);
11686 wslotr = z; /* Set requested window size here */
11687 ptab[protocol].winsize = wslotr; /* and in protocol-specific table */
11688 if (protocol == PROTO_K) { /* And for Kermit only... */
11689 swcapr = (wslotr > 1) ? 1 : 0; /* set window bit in capas word */
11690 if (wslotr > 1) { /* Window size > 1? */
11691 /* Maybe adjust packet size */
11692 y = adjpkl(urpsiz,wslotr,bigrbsiz);
11693 if (y != urpsiz) { /* Did it change? */
11697 " Adjusting receive packet-length to %d for %d window slots\n",
11704 return(success = 1);
11705 #endif /* NOXFER */
11711 case XYOUTP: /* OUTPUT command parameters */
11712 if ((y = cmkey(outptab,noutptab,"OUTPUT command parameter","pacing",
11715 switch(y) { /* Which parameter */
11716 case OUT_PAC: /* PACING */
11717 y = cmnum("Milliseconds to pause between each OUTPUT character",
11718 "100", 10,&x,xxstring);
11719 y = setnum(&z,x,y,16383); /* Verify and get confirmation */
11720 if (y < 0) return(y);
11721 if (z < 0) z = 0; /* (save some space) */
11723 return(success = 1);
11724 case OUT_ESC: /* Special-escapes */
11725 return(seton(&outesc));
11726 default: /* (shouldn't happen) */
11735 if ((z = cmkey(ctltab,2, "control-character prefixing option",""
11738 /* Make space for a temporary copy of the prefixing table */
11740 p = (short *)malloc(256 * sizeof(short));
11742 printf("?Internal error - malloc failure\n");
11745 for (i = 0; i < 256; i++) p[i] = ctlp[i]; /* Copy current table */
11748 case 0: /* UNPREFIXED control character */
11749 case 1: /* PREFIXED control character */
11750 while (1) { /* Collect a list of numbers */
11752 x_ifnum = 1; /* Turn off complaints from eval() */
11754 if ((x = cmnum((z == 0) ?
11755 "\n Numeric ASCII value of control character that needs NO prefix,\n\
11756 or the word \"all\", or carriage return to complete the list" :
11757 "\n Numeric ASCII value of control character that MUST BE prefixed,\n\
11758 or the word \"all\", or carriage return to complete the list",
11765 if ((x = cmcfm()) < 0) return(x);
11769 if (p) { free((char *)p); p = NULL; }
11770 debug(F110,"SET CONTROL atmbuf",atmbuf,0);
11771 if (!ckstrcmp(atmbuf,"all",3,0) || /* "ALL" */
11772 !ckstrcmp(atmbuf,"al",2,0) ||
11773 !ckstrcmp(atmbuf,"a",1,0)) {
11774 if ((x = cmcfm()) < 0) /* Get confirmation */
11776 prefixing = z ? PX_ALL : PX_NON;
11777 setprefix(prefixing);
11778 return(success = 1);
11779 } else { /* Not number, not ALL */
11781 "?Please specify a number or the word ALL\n");
11785 if (p) free((char *)p);
11792 #ifdef UNPREFIXZERO
11798 zz = 0; /* Allow 0 (but only for Zmodem) */
11800 #endif /* UNPREFIXZERO */
11802 /* printf("x = %d, y = %d, z = %d, zz = %d\n", x,y,z,zz); */
11804 if ((y > 31 && y < 127) || /* A specific numeric value */
11805 (y > 159 && y < 255) || /* Check that it is a valid */
11806 (y < zz) || /* control code. */
11808 printf("?Values allowed are: %d-31, 127-159, 255\n",zz);
11809 if (p) free((char *)p);
11812 x = y & 127; /* Get 7-bit value */
11813 if (z == 0) { /* If they are saying it is safe... */
11814 /* If flow control is Xon/Xoff */
11815 if (((flow == FLO_XONX) &&
11816 /* XON & XOFF chars not safe. */
11817 (x == XON || x == XOFF))
11821 "Sorry, not while Xon/Xoff is in effect.\n");
11822 if (p) free((char *)p);
11826 else if (network && IS_TELNET()
11828 (unsigned) y == (unsigned) 255)) {
11830 printf("Sorry, not on a TELNET connection.\n");
11831 if (p) free((char *)p);
11834 #endif /* TNCODE */
11836 p[y] = (char) z; /* All OK, set flag */
11837 } /* End of while loop */
11839 Get here only if they have made no mistakes. Copy temporary table back to
11840 permanent one, then free temporary table and return successfully.
11842 for (i = 0; i < 256; i++) ctlp[i] = p[i];
11843 if (p) free((char *)p);
11844 if (z > 0) clearrq = 0; /* 199 (see SET PREFIXING) */
11845 return(success = 1);
11850 #endif /* CK_SPEED */
11857 if ((y = cmkey(rpttab,2,
11858 "repeat-count compression parameter","",xxstring)) < 0)
11862 return(success = seton(&rptena)); /* REPEAT COUNTS = ON, OFF */
11863 case 1: /* REPEAT MININUM number */
11864 printf("(not implemented yet, nothing happens)\n");
11866 case 2: /* REPEAT PREFIX char */
11867 if ((x = cmnum("ASCII value","",10,&z,xxstring)) < 0)
11869 if ((x = cmcfm()) < 0) return(x);
11870 if ((z > 32 && z < 63) || (z > 95 && z < 127)) {
11871 if (y == 1) rptmin = (CHAR) z; else myrptq = (CHAR) z;
11872 return(success = 1);
11874 printf("?Illegal value for prefix character\n");
11878 #endif /* NOXFER */
11887 x_ifnum = 1; /* Turn off internal complaints */
11888 y = cmnum("Seconds from now, or time of day as hh:mm:ss",
11889 "0" ,10, &x, xxstring);
11892 if (y == -2) { /* Invalid number or expression */
11893 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
11895 printf("?Number, expression, or time of day required\n");
11898 char now[32]; /* Current time */
11903 tnow = atol(p+11) * 3600L +
11904 atol(p+14) * 60L + atol(p+17);
11905 if (zz < tnow) /* User's time before now */
11906 zz += 86400L; /* So make it tomorrow */
11907 zz -= tnow; /* Seconds from now. */
11913 printf("?Alarm time is in the past.\n");
11916 if ((y = cmcfm()) < 0) return(y);
11917 if (zz > -1L) { /* Time of day given? */
11919 if (zz != (long) x) {
11921 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
11926 return(setalarm((long)x));
11930 This is to allow long values where int and long are not the same, e.g.
11931 on 16-bit systems. But something is wrong with it.
11933 if ((y = cmtxt("seconds from now", "0", &s, xxstring)) < 0)
11936 return(setalarm(atol(s)));
11938 printf("%s - not a number\n",s);
11941 #endif /* COMMENT */
11946 return(setproto());
11947 #endif /* NOXFER */
11950 C-Kermit unprefixes control characters automatically on network connections
11951 if CLEAR-CHANNEL is ON, which it is by default. But not all network
11952 connections are transparent to all control characters. For example, the
11953 DEC-20, even when you TELNET to it, is sensitive to Ctrl-O and Ctrl-T.
11954 If you tell C-Kermit to SET CONTROL PREFIX 15 and/or 20, it doesn't help
11955 because CLEAR-CHANNEL is still in effect. If the user goes to the trouble
11956 to set up some prefixing, then Kermit should do what the user said. In
11957 C-Kermit 7.1 Alpha.03 we change the code to set clearrq to 0 if the user
11958 gives a SET PREFIXING or SET CONTROL PREFIX command.
11964 extern int clearrq;
11965 #endif /* COMMENT */
11966 if ((z = cmkey(pfxtab, 4, "control-character prefixing option",
11967 "", xxstring)) < 0)
11969 if ((x = cmcfm()) < 0) return(x);
11970 clearrq = 0; /* 199 */
11973 if (hints && (z == PX_ALL || z == PX_CAU) && clearrq) {
11974 printf("Hint: Use SET CLEAR-CHANNEL OFF to disable negotiation of\n");
11975 printf(" SET PREFIXING NONE during file transfers on reliable\n");
11976 printf(" connections.\n");
11978 #endif /* COMMENT */
11979 return(success = 1);
11981 #endif /* CK_SPEED */
11985 if ((z = cmkey(logintab, 3, "value for login script","userid",
11991 if ((y = cmtxt("text","", &s, NULL)) < 0) {
11998 return(success = 0);
12001 if ((int)strlen(s) > 63) {
12002 printf("Sorry, too long\n");
12007 ckstrncpy(uidbuf,s,UIDBUFLEN);
12011 ckstrncpy(pwbuf,s,PWBUFL);
12022 ckstrncpy(prmbuf,s,PWBUFL);
12024 return(success = 1);
12031 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
12032 if ((x = cmcfm()) < 0) return(x);
12033 DeleteStartupFile = (y != 0) ? 0 : 1;
12034 return(success = 1);
12037 x = cmdir("Name of temporary directory","",&s,xxstring);
12042 if ((x = cmcfm()) < 0) return(x);
12043 makestr(&tempdir,s);
12044 return(tempdir ? 1 : 0);
12047 case XYDEST: /* DESTINATION */
12049 #endif /* NOXFER */
12054 /* Editor, Browser, and FTP Client */
12056 case XYEDIT: /* EDITOR */
12059 printf("?Sorry, command disabled.\r\n");
12060 return(success = 0);
12064 /* Don't let this be set remotely */
12065 if (apcactive == APC_LOCAL ||
12066 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12067 return(success = 0);
12068 #endif /* CK_APC */
12072 char *p = getenv("PATH");
12074 e = editor[0] ? (char *) editor : getenv("EDITOR");
12077 x = cmifip("Name of preferred editor",e,&s,&y,0,p,xxstring);
12079 x = cmifi("Full path of preferred editor",e,&s,&y,xxstring);
12080 if (x < 0 && x != -3)
12085 if ((y = cmtxt("DCL command for editing", "edit", &s, NULL)) < 0) {
12090 if ((x = cmifi("Full path of preferred editor","",&s,&y,xxstring))<0) {
12095 #endif /* OS2ORUNIX */
12097 ckstrncpy(editor,s,CKMAXPATH);
12101 printf("?A single file please\n");
12104 ckstrncpy(line,s,LINBUFSIZ);
12105 if ((x = cmtxt("editor command-line options","",&s,NULL)) < 0)
12107 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12108 if ((z = cmcfm()) < 0) return(z);
12110 zfnqfp(line,CKMAXPATH,editor);
12111 ckstrncpy(editopts,tmpbuf,128);
12117 return(success = 1);
12123 return(dosetftp()); /* SET FTP */
12124 #endif /* TCPSOCKET */
12125 #endif /* SYSFTP */
12131 case XYFTP: /* SET FTP-CLIENT */
12132 #endif /* SYSFTP */
12134 case XYBROWSE: /* SET BROWSER */
12136 char *p = getenv("PATH");
12137 char *app = (char *) browser, *opts = (char *) browsopts;
12140 extern char ftpapp[], ftpopts[];
12142 app = (char *)ftpapp;
12143 opts = (char *)ftpopts;
12145 #endif /* SYSFTP */
12149 printf("?Sorry, command disabled.\r\n");
12150 return(success = 0);
12154 /* Don't let this be set remotely */
12155 if (apcactive == APC_LOCAL ||
12156 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12157 return(success = 0);
12158 #endif /* CK_APC */
12161 x = cmifip(xx == XYBROWSE ?
12162 "Name of preferred browser" :
12163 "Name of preferred ftp client",
12165 xx == XYFTP ? "ftp.exe" : ""
12167 xx == XYFTP ? "ftp" : ""
12169 ,&s,&y,0,p,xxstring
12172 x = cmifi(xx == XYBROWSE ?
12173 "Full path of preferred browser" :
12174 "Full path of preferred ftp client",
12177 if (x < 0 && x != -3)
12181 if ((x = cmtxt("DCL command to start your preferred Web browser",
12182 "", &s, NULL)) < 0) {
12187 if ((x = cmifi("Full path of preferred browser","",&s,&y,xxstring)
12193 #endif /* OS2ORUNIX */
12195 ckstrncpy(app,s,CKMAXPATH);
12199 printf("?A single file please\n");
12202 ckstrncpy(line,s,LINBUFSIZ);
12203 if ((x = cmtxt(xx == XYBROWSE ?
12204 "browser command-line options" :
12205 "ftp client command-line options",
12209 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12210 if ((z = cmcfm()) < 0) return(z);
12212 zfnqfp(line,CKMAXPATH,app);
12213 ckstrncpy(opts, tmpbuf, 128);
12219 return(success = 1);
12221 #endif /* BROWSER */
12222 #endif /* NOFRILLS */
12223 #endif /* NOPUSH */
12226 case XYEOF: { /* SET EOF */
12227 extern int eofmethod; extern struct keytab eoftab[];
12228 if ((x = cmkey(eoftab,3,"end-of-file detection method","",
12231 if ((y = cmcfm()) < 0)
12234 return(success = 1);
12236 #endif /* CK_CTRLZ */
12239 case XYLIMIT: { /* Session-Limit (length of session in seconds) */
12240 extern int seslimit;
12242 extern int downloaded;
12244 y = cmnum("Maximum length of session, seconds","0",10,&x,xxstring);
12250 #endif /* IKSDCONF */
12255 if ((z = cmcfm()) < 0)
12257 printf("?Sorry, command disabled.\r\n");
12258 return(success = 0);
12260 return(setnum(&seslimit,x,y,86400));
12262 #endif /* SESLIMIT */
12264 case XYRELY: { /* SET RELIABLE */
12265 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12267 if ((y = cmcfm()) < 0) return(y);
12269 setreliable = (x != SET_AUTO);
12270 debug(F101,"SET RELIABLE reliable","",reliable);
12271 return(success = 1);
12275 case XYSTREAM: { /* SET STREAMING */
12276 extern int streamrq;
12277 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12279 if ((y = cmcfm()) < 0) return(y);
12281 return(success = 1);
12283 #endif /* STREAMING */
12287 if ((x = cmkey(syslogtab,nsyslog,"","",xxstring)) < 0)
12289 if ((y = cmcfm()) < 0) return(y);
12296 #endif /* IKSDCONF */
12298 printf("?Sorry, command disabled.\n");
12299 return(success = 0);
12303 /* Don't let this be set remotely */
12304 if (apcactive == APC_LOCAL ||
12305 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12306 return(success = 0);
12307 #endif /* CK_APC */
12309 return(success = 1);
12311 #endif /* CKSYSLOG */
12314 case XYTLOG: { /* SET TRANSACTION-LOG */
12315 extern int tlogsep;
12316 if ((x = cmkey(vbtab,nvb,"","verbose",xxstring)) < 0)
12319 if ((y = cmtxt("field separator",",",&s,NULL)) < 0) return(y);
12323 printf("?A single character, please.\n");
12325 } else if ((*s >= '0' && *s <= '9') ||
12326 (*s >= 'A' && *s <= 'Z') ||
12327 (*s >= 'a' && *s <= 'z')) {
12328 printf("?A non-alphanumeric character, please.\n");
12334 if ((y = cmcfm()) < 0) return(y);
12337 if (inserver && isguest) {
12338 printf("?Sorry, command disabled.\n");
12339 return(success = 0);
12343 /* Don't let this be set remotely */
12344 if (apcactive == APC_LOCAL ||
12345 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12346 return(success = 0);
12347 #endif /* CK_APC */
12349 return(success = 1);
12353 case XYCLEAR: { /* SET CLEARCHANNEL */
12354 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12356 if ((y = cmcfm()) < 0) return(y);
12358 return(success = 1);
12361 #ifdef CK_AUTHENTICATION
12362 case XYAUTH: { /* SET AUTHENTICATION */
12365 extern struct krb_op_data krb_op;
12366 #endif /* CK_KERBEROS */
12369 cmkey(setauth,nsetauth,"authentication type","",xxstring)) < 0)
12373 case AUTH_KRB4: kv = 4; break; /* Don't assume values are same */
12374 case AUTH_KRB5: kv = 5; break;
12375 #endif /* CK_KERBEROS */
12377 case AUTH_SRP: break;
12378 #endif /* CK_SRP */
12383 #endif /* CK_SSL */
12385 printf("?Authorization type not supported yet - \"%s\"\n",
12395 #endif /* IKSDCONF */
12397 if ((y = cmcfm()) < 0) return(y);
12398 printf("?Sorry, command disabled.\n");
12399 return(success = 0);
12403 /* Don't let this be set remotely */
12404 if (apcactive == APC_LOCAL ||
12405 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) {
12406 if ((y = cmcfm()) < 0) return(y);
12407 return(success = 0);
12409 #endif /* CK_APC */
12415 if ((x = cmkey(kv == 4 ? k4tab : k5tab,
12416 kv == 4 ? nk4tab : nk5tab,
12417 "Kerberos parameter","",xxstring)) < 0) {
12425 if ((y = seton(&k4debug)) < 0)
12428 ck_krb4_debug(k4debug);
12436 if ((y = cmnum("TGT lifetime","600",10,&z,xxstring)) < 0)
12441 if ((y = seton(&krb4_d_preauth)) < 0)
12448 if ((y = cmtxt("Instance name","",&s,xxstring)) < 0)
12453 if ((y = seton(&krb5_d_forwardable)) < 0)
12461 if ((y = seton(&krb5_d_proxiable)) < 0)
12468 if ((y = cmnum("TGT renewable lifetime",
12469 "0",10,&z,xxstring)) < 0)
12474 if ((y = seton(&krb5_checkaddrs)) < 0)
12477 if ((y = seton(&krb4_checkaddrs)) < 0)
12483 if ((y = seton(&krb5_d_no_addresses)) < 0)
12489 char * tmpaddrs[KRB5_NUM_OF_ADDRS];
12490 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++)
12491 tmpaddrs[i] = NULL;
12494 cmfld("List of IP addresses","",&s,xxstring)) < 0)
12496 makelist(s,tmpaddrs,KRB5_NUM_OF_ADDRS);
12497 if ((y = cmcfm()) < 0) {
12498 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12499 if (tmpaddrs[i] != NULL)
12505 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12507 if (inet_addr(tmpaddrs[i]) == 0xffffffff) {
12508 printf("invalid ip address: %s\n",
12510 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12511 if (tmpaddrs[i] != NULL)
12518 i < KRB5_NUM_OF_ADDRS && krb5_d_addrs[i];
12520 if (krb5_d_addrs[i])
12521 free(krb5_d_addrs[i]);
12522 krb5_d_addrs[i] = NULL;
12525 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12527 krb5_d_addrs[i] = tmpaddrs[i];
12528 tmpaddrs[i] = NULL;
12530 krb5_d_addrs[i] = NULL;
12531 return(success = 1);
12537 if ((y = seton(&krb5_autoget)) < 0)
12540 if ((y = seton(&krb4_autoget)) < 0)
12545 if ((z = cmkey(kdestab,nkdestab,
12546 "Auto Destroy Tickets",
12547 "never",xxstring)) < 0)
12551 if ((y = cmtxt("User ID",uidbuf,&s,xxstring)) < 0)
12555 if ((y = cmtxt("Name of realm","",&s,xxstring)) < 0)
12559 y = cmifi("Filename","",&s,&z,xxstring);
12564 printf("?Wildcards not allowed\n");
12570 if ((y = cmofi("Filename","",&s,xxstring)) < 0)
12574 if ((y = cmtxt("Name of service to use in ticket",
12575 (kv == 4 ? "rcmd" : "host"),
12583 if ((y = seton(&krb5_d_getk4)) < 0)
12589 case XYKRBPRM: /* Prompt */
12590 if ((z = cmkey(krbprmtab,2,"","",xxstring)) < 0)
12592 if ((y = cmtxt((z == KRB_PW_PRM) ?
12593 "Text of prompt;\nmay contain \"%s\" to be replaced by principal name" :
12603 ckstrncpy(line,s,LINBUFSIZ);
12605 if ((y = cmcfm()) < 0)
12611 #else /* IKSDCONF */
12613 #endif /* IKSDCONF */
12615 return(success = 0);
12618 switch (x) { /* Copy value to right place */
12619 case XYKRBLIF: /* Lifetime */
12621 krb4_d_lifetime = z;
12623 krb5_d_lifetime = z;
12627 krb5_d_renewable = z;
12629 case XYKRBPR: /* Principal */
12630 s = brstrip(s); /* Strip braces around. */
12632 makestr(&krb4_d_principal,s);
12634 makestr(&krb5_d_principal,s);
12636 case XYKRBINS: /* Instance */
12638 makestr(&krb4_d_instance,s);
12640 makestr(&krb5_d_instance,s);
12642 case XYKRBRL: /* Realm */
12644 makestr(&krb4_d_realm,s);
12646 makestr(&krb5_d_realm,s);
12648 case XYKRBKTB: /* Key Table */
12650 makestr(&k4_keytab,s);
12652 makestr(&k5_keytab,s);
12654 case XYKRBCC: /* Credentials cache */
12655 makestr(&krb5_d_cc,s);
12657 case XYKRBSRV: /* Service Name */
12659 makestr(&krb4_d_srv,s);
12661 makestr(&krb5_d_srv,s);
12669 case XYKRBPRM: /* Prompt */
12672 case KRB_PW_PRM: { /* Password */
12673 /* Check that there are no more than */
12674 /* two % fields and % must followed by 's'. */
12677 for (i = 0, n = 0; i < len; i++) {
12679 if (s[i+1] != '%') {
12680 if (s[i+1] != 's') {
12682 "Only %%s fields are permitted.\n"
12688 "Only two %%s fields are permitted.\n");
12696 makestr(&k5pwprompt,s);
12698 makestr(&k4pwprompt,s);
12701 case KRB_PR_PRM: { /* Principal */
12702 /* Check to make sure there are no % fields */
12705 for (i = 0; i < len; i++) {
12707 if (s[i+1] != '%') {
12709 "%% fields are not used in this command.\n");
12716 makestr(&k5prprompt,s);
12718 makestr(&k4prprompt,s);
12725 #endif /* CK_KERBEROS */
12728 if ((x = cmkey(srptab, nsrptab,
12729 "SRP parameter","",xxstring)) < 0) {
12734 case XYSRPPRM: /* Prompt */
12735 if ((z = cmkey(srpprmtab,1,"","",xxstring)) < 0)
12738 "Text of prompt;\nmay contain one \"%s\" to be replaced by the username",
12747 ckstrncpy(line,s,LINBUFSIZ);
12749 if ((y = cmcfm()) < 0)
12751 switch (x) { /* Copy value to right place */
12752 case XYSRPPRM: /* Prompt */
12755 case SRP_PW_PRM: { /* Password */
12756 /* Check %s fields */
12759 for (i = 0, n = 0; i < len; i++) {
12761 if (s[i+1] != '%') {
12762 if (s[i+1] != 's') {
12764 "Only %%s fields are permitted.\n");
12769 "Only one %%s field is permitted.\n");
12776 makestr(&srppwprompt,s);
12783 #endif /* CK_SRP */
12787 if ((z = cmkey(ssltab, nssltab,
12788 (x == AUTH_SSL ? "SSL parameter" : "TLS parameter"),
12793 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12794 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12795 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12796 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12797 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12798 case XYSSLDKFL: /* SSL/TLS DH Key File */
12799 case XYSSLDPFL: /* SSL/TLS DH Param File */
12800 case XYSSLCRL: /* SSL/TLS CRL File */
12801 case XYSSLVRFF: /* SSL/TLS Verify File */
12802 case XYSSLRND: /* SSL/TLS Random File */
12803 y = cmifi("Filename","",&s,&x,xxstring);
12808 printf("?Wildcards not allowed\n");
12812 ckstrncpy(line,s,LINBUFSIZ);
12815 if ((y = cmcfm()) < 0)
12818 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12819 if (!s[0] && ssl_rsa_cert_file) {
12820 free(ssl_rsa_cert_file);
12821 ssl_rsa_cert_file = NULL;
12823 makestr(&ssl_rsa_cert_file,s);
12824 if (!ssl_rsa_key_file)
12825 makestr(&ssl_rsa_key_file,s);
12828 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12829 if (!s[0] && ssl_rsa_cert_chain_file) {
12830 free(ssl_rsa_cert_chain_file);
12831 ssl_rsa_cert_chain_file = NULL;
12833 makestr(&ssl_rsa_cert_chain_file,s);
12836 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12837 if (!s[0] && ssl_rsa_key_file) {
12838 free(ssl_rsa_key_file);
12839 ssl_rsa_key_file = NULL;
12841 makestr(&ssl_rsa_key_file,s);
12844 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12845 if (!s[0] && ssl_dsa_cert_file) {
12846 free(ssl_dsa_cert_file);
12847 ssl_dsa_cert_file = NULL;
12849 makestr(&ssl_dsa_cert_file,s);
12850 if (!ssl_dh_key_file)
12851 makestr(&ssl_dh_key_file,s);
12854 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12855 if (!s[0] && ssl_dsa_cert_chain_file) {
12856 free(ssl_dsa_cert_chain_file);
12857 ssl_dsa_cert_chain_file = NULL;
12859 makestr(&ssl_dsa_cert_chain_file,s);
12862 case XYSSLDKFL: /* SSL/TLS DH Key File */
12863 if (!s[0] && ssl_dh_key_file) {
12864 free(ssl_dh_key_file);
12865 ssl_dh_key_file = NULL;
12867 makestr(&ssl_dh_key_file,s);
12870 case XYSSLDPFL: /* SSL/TLS DH Param File */
12871 if (!s[0] && ssl_dh_param_file) {
12872 free(ssl_dh_param_file);
12873 ssl_dh_param_file = NULL;
12875 makestr(&ssl_dh_param_file,s);
12878 case XYSSLCRL: /* SSL/TLS CRL File */
12879 if (!s[0] && ssl_crl_file) {
12880 free(ssl_crl_file);
12881 ssl_crl_file = NULL;
12883 makestr(&ssl_crl_file,s);
12886 case XYSSLVRFF: /* SSL/TLS Verify File */
12887 if (!s[0] && ssl_verify_file) {
12888 free(ssl_verify_file);
12889 ssl_verify_file = NULL;
12891 makestr(&ssl_verify_file,s);
12894 case XYSSLRND: /* SSL/TLS Random File */
12895 if (!s[0] && ssl_rnd_file) {
12896 free(ssl_rnd_file);
12897 ssl_rnd_file = NULL;
12899 makestr(&ssl_rnd_file,s);
12908 if (z == XYSSLVRFD)
12909 d= getenv("SSL_CERT_DIR");
12912 if ((y = cmdir("Directory",d,&s,xxstring)) < 0)
12915 ckstrncpy(line,s,LINBUFSIZ);
12918 if ((y = cmcfm()) < 0)
12922 if (!s[0] && ssl_crl_dir) {
12924 ssl_crl_dir = NULL;
12926 makestr(&ssl_crl_dir,s);
12930 if (!s[0] && ssl_verify_dir) {
12931 free(ssl_verify_dir);
12932 ssl_verify_dir = NULL;
12934 makestr(&ssl_verify_dir,s);
12940 case XYSSLCOK: /* SSL/TLS Certs-Ok flag */
12941 if ((y = seton(&ssl_certsok_flag)) < 0)
12944 case XYSSLDBG: /* SSL/TLS Debug flag */
12945 if ((y = seton(&ssl_debug_flag)) < 0)
12948 case XYSSLON: /* SSL/TLS Only flag */
12951 if ((y = seton(&ssl_only_flag)) < 0)
12955 if ((y = seton(&tls_only_flag)) < 0)
12960 case XYSSLVRB: /* SSL/TLS Verbose flag */
12961 if ((y = seton(&ssl_verbose_flag)) < 0)
12964 case XYSSLVRF: /* SSL/TLS Verify flag */
12965 if ((x = cmkey(sslvertab, nsslvertab,
12966 "SSL/TLS verify mode",
12967 "peer-cert",xxstring)) < 0)
12969 if ((y = cmcfm()) < 0)
12971 ssl_verify_flag = x;
12974 if ((y = seton(&ssl_dummy_flag)) < 0)
12977 case XYSSLCL: { /* SSL/TLS Cipher List */
12979 /* This code is used to generate a colon delimited */
12980 /* list of the ciphers currently in use to be used */
12981 /* as the default for cmtxt(). However, a better */
12982 /* default is simply the magic keyword "ALL". */
12983 CHAR def[1024] = "";
12984 if (ssl_con != NULL) {
12985 CHAR * p = NULL, *q = def;
12988 for (i = 0; ; i++) {
12989 p = (CHAR *) SSL_get_cipher_list(ssl_con,i);
12993 if (q+len+1 >= def+1024)
13001 #endif /* COMMENT */
13002 char * p = getenv("SSL_CIPHER");
13006 "Colon-delimited list of ciphers or ALL (case-sensitive)",
13013 makestr(&ssl_cipher_list,s);
13014 if (ssl_con == NULL) {
13015 SSL_library_init();
13016 ssl_ctx = (SSL_CTX *)
13017 SSL_CTX_new((SSL_METHOD *)TLSv1_method());
13018 if (ssl_ctx != NULL)
13019 ssl_con= (SSL *) SSL_new(ssl_ctx);
13022 SSL_set_cipher_list(ssl_con,ssl_cipher_list);
13029 #endif /* CK_SSL */
13033 return(success = 1);
13035 #endif /* CK_AUTHENTICATION */
13039 if ((x = cmkey(functab,nfunctab,"","diagnostics",xxstring)) < 0)
13042 case FUNC_DI: return(seton(&fndiags));
13043 case FUNC_ER: return(seton(&fnerror));
13044 default: return(-2);
13048 case XYSLEEP: /* SET SLEEP / PAUSE */
13049 if ((x = cmkey(sleeptab,1,"","cancellation",xxstring)) < 0)
13051 return(seton(&sleepcan));
13053 case XYCD: /* SET CD */
13054 if ((x = cmkey(cdtab,ncdtab,"","",xxstring)) < 0)
13057 case XYCD_H: { /* SET CD HOME */
13058 extern char * myhome;
13059 if ((y = cmdir("Directory name",zhome(),&s,xxstring)) < 0)
13061 makestr(&myhome,s);
13062 return(success = 1);
13064 case XYCD_M: /* SET CD MESSAGE */
13065 if ((x = cmkey(cdmsg,ncdmsg,"","",xxstring)) < 0)
13067 if (x == 2) { /* CD MESSAGE FILE */
13068 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
13074 #endif /* NOXFER */
13076 makestr(&cdmsgstr,s);
13077 makelist(cdmsgstr,cdmsgfile,8);
13078 return(success = 1);
13081 if ((y = cmcfm()) < 0) return(y); /* CD-MESSAGE ON/OFF */
13087 #endif /* NOXFER */
13088 return(success = 1);
13090 case XYCD_P: { /* SET CD PATH */
13091 extern char * ckcdpath;
13092 if ((x = cmtxt("CD PATH string","",&s,xxstring)) < 0)
13094 makestr(&ckcdpath,s);
13095 return(success = 1);
13101 case XYSTOP: /* STOP-BITS */
13102 if ((x = cmkey(stoptbl,2,"Stop bits for serial device","",
13105 if ((y = cmcfm()) < 0)
13107 if (x > 0 && x < 3) {
13110 if (network && istncomport()) {
13112 return(success = 1);
13114 #endif /* TN_COMPORT */
13116 return(success = 1);
13117 #else /* HWPARITY */
13119 #endif /* HWPARITY */
13122 #endif /* STOPBITS */
13125 extern int clsondisc;
13126 return(seton(&clsondisc));
13132 if ((x = cmkey(sertbl,nsertbl,
13133 "Serial device character size, parity, and stop bits",
13134 "8N1", xxstring)) < 0)
13136 ckstrncpy(line,atmbuf,LINBUFSIZ); /* Associated keyword string */
13138 if ((y = cmcfm()) < 0)
13140 ckstrncpy(line,sernam[x],LINBUFSIZ);
13142 if (s[0] != '8' && s[0] != '7') /* Char size */
13146 if (isupper(s[1])) /* Parity */
13147 s[1] = tolower(s[1]);
13148 if (s[2] != '1' && s[2] != '2') /* Stop bits */
13151 stopbits = s[2] - '0';
13152 if (z == 8) { /* 8 bits + parity (or not) */
13153 parity = 0; /* Set parity */
13154 hwparity = (s[1] == 'n') ? 0 : s[1];
13155 setcmask(8); /* Also set TERM BYTESIZE to 8 */
13156 } else { /* 7 bits plus parity */
13157 parity = (s[1] == 'n') ? 0 : s[1];
13159 setcmask(7); /* Also set TERM BYTESIZE to 7 */
13162 if (network && !istncomport())
13163 tnsettings(parity, stopbits);
13164 #endif /* TN_COMPORT */
13166 return(success = 1); /* from SET SERIAL */
13169 case XYOPTS: { /* SET OPTIONS */
13170 extern int setdiropts();
13171 extern int settypopts();
13173 extern int setpurgopts();
13174 #endif /* CKPURGE */
13175 if ((x = cmkey(optstab,noptstab,"for command","", xxstring)) < 0)
13180 return(setdelopts());
13181 #endif /* NOFRILLS */
13183 return(setdiropts());
13185 return(settypopts());
13188 return(setpurgopts());
13189 #endif /* CKPURGE */
13194 #endif /* NOLOCAL */
13198 return(seton(&q8flag));
13201 extern int asktimer;
13202 y = cmnum("Time limit for ASK command, seconds","0",10,&x,xxstring);
13204 return(setnum(&asktimer,x,y,32767));
13206 return(setnum(&asktimer,x,y,86400));
13210 extern int fackbug;
13211 return(seton(&fackbug));
13213 #endif /* NOXFER */
13216 return(seton(&hints));
13220 extern int oldeval;
13221 if ((x = cmkey(oldnew,2,"","", xxstring)) < 0)
13223 if ((y = cmcfm()) < 0)
13226 return(success = 1);
13232 extern int fackpath;
13233 return(seton(&fackpath));
13235 #endif /* NOXFER */
13238 extern int qnxportlock;
13239 return(seton(&qnxportlock));
13249 #endif /* NOCMDL */
13253 return(dochroot());
13254 #endif /* CKROOT */
13259 if ((x = cmkey(sexptab,3,"","", xxstring)) < 0)
13263 if ((x = cmkey(ooatab,3,"","automatic", xxstring)) < 0)
13265 if ((y = cmcfm()) < 0)
13272 if ((y = cmnum("Maximum recursion depth",
13273 "1000",10,&x,xxstring)) < 0)
13275 z = setnum(&sexpmaxdep,x,y,-1);
13278 if (sxresult) { /* Free old stack if allocated */
13279 for (i = 0; i < xx; i++)
13280 if (sxresult[i]) free(sxresult[i]);
13281 free((char *)sxresult);
13282 if (sxrlen) free((char *)sxrlen);
13289 return(seton(&sexptrunc));
13291 return(success = 1);
13293 #endif /* NOSEXPL */
13298 extern struct keytab gprtab[];
13300 if ((x = cmkey(gprtab,3,"","kermit", xxstring)) < 0)
13302 if ((y = cmcfm()) < 0)
13305 return(success = 1);
13307 #endif /* NEWFTP */
13311 return(dosetssh());
13312 #endif /* ANYSHH */
13314 #ifdef SFTP_BUILTIN
13316 return(dosetsftp());
13317 #endif /* SFTP_BUILTIN */
13321 if ((x = cmkey(locustab,nlocustab,"",
13329 if ((y = cmcfm()) < 0)
13331 if (x == 2 || x == 3) { /* AUTO or ASK */
13332 setautolocus(x - 1); /* Two forms of automatic locusing */
13333 /* setlocus(1,0); */ /* we're not changing the locus here */
13334 } else { /* LOCAL or REMOTE */
13335 setautolocus(0); /* No automatic Locus changing */
13336 setlocus(x,0); /* Set Locus as requested */
13338 return(success = 1);
13348 case XY_REN: /* SET RENAME */
13349 return(setrename());
13350 #endif /* NORENAME */
13351 #endif /* NOFRILLS */
13356 case XYEXTRN: /* SET EXTERNAL-PROTOCOL */
13357 return(setextern());
13358 #endif /* NOXFER */
13359 #endif /* CK_REDIR */
13360 #endif /* NOPUSH */
13363 case XYVAREV: /* SET VARIABLE-EVALUATION */
13364 return(setvareval());
13368 if ((x = cmcfm()) < 0) return(x);
13369 printf("Not implemented - %s\n",cmdbuf);
13370 return(success = 0);
13375 H U P O K -- Is Hangup OK?
13377 Issues a warning and gets OK from user depending on whether a connection
13378 seems to be open and what the SET EXIT WARNING setting is. Returns:
13379 0 if not OK to hang up or exit (i.e. user said No);
13381 Argument x is used to differentiate the EXIT command from SET LINE / HOST.
13384 hupok(x) int x; { /* Returns 1 if OK, 0 if not OK */
13386 extern int exithangup;
13390 if (batch) /* No warnings in batch */
13394 if (backgrd) /* No warnings in background */
13400 debug(F101,"hupok local","",local);
13402 if (!local) /* No warnings in remote mode */
13406 if (x == 0 && exithangup == 0) /* EXIT and EXIT HANGUP is OFF */
13409 debug(F101,"hupok x","",x);
13410 debug(F101,"hupok xitwarn","",xitwarn);
13411 debug(F101,"hupok network","",network);
13412 debug(F101,"hupok haveline","",haveline);
13414 if ((local && xitwarn) || /* Is a connection open? */
13415 (!x && xitwarn == 2)) { /* Or Always give warning on EXIT */
13422 /* A connection seems to be open but it can't possibly be */
13426 if (strcmp(ttname,"*"))
13427 ckmakmsg(warning,256,
13428 " A network connection to ",ttname,
13429 " might still be active.\n",NULL);
13432 " An incoming network connection might still be active.\n",
13435 } else { /* Serial connection */
13436 if (carrier == CAR_OFF) /* SET CARRIER OFF */
13437 needwarn = 0; /* so we don't care about carrier. */
13438 else if ((y = ttgmdm()) >= 0) /* else, get modem signals */
13439 needwarn = (y & BM_DCD); /* Check for carrier */
13440 else /* If we can't get modem signals... */
13441 needwarn = (ttchk() >= 0);
13442 /* A connection seems to be open but it can't possibly be */
13443 if (!haveline || !exithangup)
13446 ckmakmsg(warning,256,
13447 " A serial connection might still be active on ",
13448 ttname,".\n",NULL);
13451 /* If a warning was issued, get user's permission to EXIT. */
13453 if (needwarn || (!x && xitwarn == 2
13459 ckstrncpy(warning, "No active connections", 256);
13462 printf("%s",warning);
13463 z = getyesno(x ? "OK to close? " : "OK to exit? ",0);
13464 debug(F101,"hupok getyesno","",z);
13468 x ? "OK to close? " : "OK to exit? ",
13473 debug(F101,"hupok uq_ok","",z);
13475 #endif /* COMMENT */
13483 shoctl() { /* SHOW CONTROL-PREFIXING */
13490 "\ncontrol quote = %d, applied to (0 = unprefixed, 1 = prefixed):\n\n",
13493 #ifndef UNPREFIXZERO
13495 if (protocol == PROTO_K) /* Zero can't be unprefixed */
13496 ctlp[0] = 1; /* for Kermit */
13497 #endif /* UNPREFIXZERO */
13499 for (i = 0; i < 16; i++) {
13500 printf(" %3d: %d %3d: %d ",i,ctlp[i], i+16, ctlp[i+16]);
13502 printf(" 127: %d",ctlp[127]);
13505 printf(" %3d: %d %3d: %d ",i+128,ctlp[i+128], i+144, ctlp[i+144]);
13506 if (i == 15) printf(" 255: %d",ctlp[255]);
13510 #ifndef UNPREFIXZERO
13514 #endif /* UNPREFIXZERO */
13516 #endif /* CK_SPEED */
13521 shodbl() { /* SHOW DOUBLE/IGNORE */
13524 printf("\nSET SEND DOUBLE characters:\n");
13525 for (i = 0; i < 255; i++) {
13534 printf("\nSET RECEIVE IGNORE characters:\n");
13535 for (i = 0; i < 255; i++) {
13544 #endif /* CKXXCHAR */
13546 #endif /* NOXFER */
13547 #endif /* NOSHOW */
13552 Rexx command. Note, this is not OS/2-specific, because Rexx also runs
13553 on other systems where C-Kermit also runs, like the Amiga.
13555 #define REXBUFL 100 /* Change this if neccessary */
13556 char rexxbuf[REXBUFL] = { '\0' }; /* Rexx's return value (string) */
13563 if ((x = cmtxt("Rexx command","",&rexxcmd,xxstring)) < 0)
13568 printf("?Sorry, command disabled.\r\n");
13569 return(success = 0);
13573 /* Don't let this be set remotely */
13574 if (apcactive == APC_LOCAL ||
13575 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
13576 return(success = 0);
13577 #endif /* CK_APC */
13579 ckstrncpy(line,rexxcmd,LINBUFSIZ);
13582 return(os2rexx(rexxcmd,rexxbuf,REXBUFL));
13584 printf("Sorry, nothing happens.\n");
13585 return(success = 0);
13588 #endif /* CK_REXX */
13589 #endif /* NOPUSH */
13593 /* Dummy write record to connection log */