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, 2011,
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_TWO|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) );
3431 _PROTOTYP( CKFLOAT ckround, (CKFLOAT, int, char *, int) );
3433 extern char math_pi[]; /* Value of Pi */
3434 extern int sexpecho; /* SET SEXPRESSION ECHO value */
3435 extern char * sexpval; /* Last top-level S-Expression value */
3436 extern char * lastsexp; /* Last S-Expression */
3437 int sexprmax = 0; /* Longest result (for stats) */
3438 int sexpdmax = 0; /* Max depth reached (for stats) */
3439 int sexpdep = 0; /* dosexp() recursion depth */
3440 static int * sxrlen = NULL; /* Result stack string sizes */
3441 static char ** sxresult = NULL; /* Result stack */
3443 /* s h o s e x p -- Show S-Expression info */
3448 printf(" sexpression echo-result: %s\n",showooa(sexpecho));
3449 printf(" sexpression depth-limit: %d\n",sexpmaxdep);
3451 printf(" maximum depth reached: %d\n",sexpdmax);
3452 printf(" longest result returned: %d\n",sexprmax);
3454 printf(" truncate all results: %s\n",showoff(sexptrunc));
3456 printf(" last sexpression: %s\n",lastsexp ? lastsexp : "(none)");
3457 printf(" last value: %s\n",sexpval ? sexpval : "(none)");
3463 sexpdebug(s) char * s; {
3464 /* For debugging -- includes recursion depth in each debug entry */
3465 static char buf[64];
3466 ckmakmsg(buf,64,"dosexp[",ckitoa(sexpdep),"] ",s);
3467 return((char *)buf);
3470 /* d o s e x p -- S-Expression Reader */
3472 /* Returns value as string (empty, numeric, or non-numeric) */
3474 static char sxroundbuf[32]; /* For ROUND result */
3477 dosexp(s) char *s; { /* s = S-Expression */
3478 extern struct mtab *mactab; /* Macro table */
3479 extern int maclvl, nmac;
3480 extern char *mrval[];
3481 extern int makestrlen; /* (see makestr()) */
3482 struct stringarray * q = NULL; /* cksplit() return type */
3483 char * p[SEXPMAX+1], ** p2; /* List items (must be on stack) */
3484 char * line = NULL; /* For building macro argument list */
3488 int quote = 0; /* LISP quote flag */
3489 char * s2; /* Workers */
3490 int kw, kwflags, mx = 0, x = 0;
3491 int not = 0, truncate = 0, builtin = 0;
3492 int fpflag = 0, quit = 0, macro = 0;
3493 CK_OFF_T result = 0, i, j, k, n = 0;
3494 CKFLOAT fpj, fpresult = 0.0; /* Floating-point results */
3495 int pflag = 0; /* Have predicate */
3496 int presult = 0; /* Predicate result */
3497 int mustfree = 0; /* If we malloc'd we must free */
3499 sexppv = -1; /* Predicate value */
3500 s2 = ""; /* Default return value */
3502 debug(F111,sexpdebug("entry 1"),s,sexprc);
3504 if (++sexpdep > sexpmaxdep) { /* Keep track of depth */
3505 printf("?S-Expression depth limit exceeded: %d\n",sexpmaxdep);
3507 debug(F111,sexpdebug("max depth exceeded"),s,sexprc);
3509 if (sexpdep > sexpdmax) /* For stats */
3512 if (sexprc) /* Error, quit all levels */
3513 goto xdosexp; /* Always goto common exit point */
3515 debug(F111,sexpdebug("entry 2"),s,sexprc);
3517 if (!s) s = ""; /* Null or empty arg */
3519 while (*s == SP) s++; /* Strip leading spaces */
3520 if (!*s) /* so empty result */
3523 Allocate result stack upon first use, or after it has been resized with
3524 SET SEXP DEPTH-LIMIT.
3527 sxresult = (char **)malloc(sexpmaxdep * sizeof(char *));
3529 printf("?Memory allocation failure - \"%s\"\n", s);
3533 sxrlen = (int *)malloc(sexpmaxdep * sizeof(int));
3535 printf("?Memory allocation failure - \"%s\"\n", s);
3539 for (i = 0; i < sexpmaxdep; i++) {
3540 sxresult[i] = NULL; /* Result pointers */
3541 sxrlen[i] = 0; /* Buffer sizes */
3544 s2 = s; /* s2 is the result pointer */
3545 k = 0; /* Length accumulator */
3546 if (s[0] == '(') { /* Starts with open paren? */
3547 while (*s2++) k++; /* Get length */
3548 if (s[k-1] == ')') { /* Strip outer parens if any */
3552 while (*s == SP) { /* Strip leading spaces from result */
3556 while (k > 0 && s[k-1] == SP) { /* And trailing spaces. */
3561 if (!*s) { /* If nothing remains */
3562 s2 = ""; /* return empty result. */
3566 /* Break result up into "words" (an SEXP counts as a word) */
3568 for (i = 0; i < SEXPMAX+1; i++ ) { /* Clear the operands */
3571 if (!*(s+1) || !*(s+2)) { /* No need to call cksplit() */
3572 n = 1; /* if it's one or two chars. */
3573 p[1] = s; /* No need to malloc this either. */
3575 debug(F101,sexpdebug("nosplit"),"",n);
3576 if (s[0] == '(') { /* () empty */
3582 q = cksplit(1,SEXPMAX,s,NULL,"\\%[]&$+-/=*^_@!{}/<>|.#~'`:;?",8,39,0);
3585 n = q->a_size; /* Number of items */
3586 debug(F101,sexpdebug("split"),"",n);
3587 if (n < 0 || n > SEXPMAX) { /* Check for too many */
3588 printf("?Too many operands: max = %d\n",SEXPMAX);
3592 if (n == 0) /* None, result is NULL, done. */
3594 if (n == 1 && s[0] == '(') { /* One but it's another SEXP */
3598 p2 = q->a_head; /* Point to result array. */
3599 for (i = 1; i <= n; i++) { /* We must copy it because */
3600 p[i] = NULL; /* recursive calls to dosexp() */
3601 if (p2[i]) /* write over the same array */
3602 makestr(&(p[i]),p2[i]);
3604 if (s[0] == '(') { /* Operator is an S-Expression */
3605 s2 = dosexp(p[1]); /* Replace it by its value */
3606 makestr(&(p[1]),s2);
3608 mustfree++; /* Remember to free it */
3610 debug(F110,sexpdebug("head"),p[1],0);
3612 if (n == 1 && p[1]) {
3613 if (*(p[1]) == '\047') { /* Apostrophe = LISP quote character */
3619 This section sidesteps xlookup() of the most common operators.
3620 It's not necessary but it speeds up SEXP-heavy loops by about 10%.
3623 if (n > 0) { /* Look up the operator */
3624 s2 = p[1]; /* Prelookup optimization... */
3631 if (isdigit(*s2)) { /* Digit */
3634 } else if (isalpha(*s2) && !*(s2+1)) { /* Single letter */
3637 } else if (*s2 == 's' || *s2 == 'S') { /* SETQ */
3639 if (*s2 == 'e' || *s2 == 'E') {
3641 if (*s2 == 't' || *s2 == 'T') {
3643 if (*s2 == 'q' || *s2 == 'Q') {
3654 if (!*(s2+1)) { /* Common single-character ops */
3659 } else if (*s2 == '-') {
3663 } else if (*s2 == '*') {
3667 } else if (*s2 == '/') {
3673 if (!x) { /* None of the above, look it up */
3674 x = xlookup(sexpops,p[1],nsexpops,&kw);
3676 kwflags = sexpops[kw].flgs;
3682 /* If none of the above, check built-in constants */
3685 x = xlookup(sexpconsts,p[1],nsexpconsts,&kw);
3700 if (n == 1) { /* Not an expression */
3701 if (builtin) { /* Built-in operand? */
3702 switch (x) { /* Operators with default values */
3706 case SX_MUL: /* (*) */
3707 s2 = sexpval ? sexpval : "1";
3709 case SX_AND: /* (AND) */
3710 case SX_BWA: /* Bitwise (&) */
3712 case SX_LOR: /* (OR) */
3713 case SX_BWO: /* Bitwise (|) */
3714 case SX_ADD: /* (+) */
3715 case SX_SUB: /* (-) */
3716 s2 = result ? "1" : "0";
3720 } else { /* Not a built-in operand */
3723 while (*p1 == SP) p1++;
3724 if (!isalpha(*p1)) {
3725 if (xxfloat(p1,0) > 0) { /* Is it a number? */
3727 while (*s2 == '+') s2++;
3728 } else if (*p1 == '(') { /* An S-Expression? */
3734 #endif /* COMMENT */
3737 } else if (x < 1) { /* Is it a variable? */
3738 j = mxlook(mactab,p[1],nmac); /* Look it up */
3739 debug(F111,sexpdebug("n==1 mxlook"),p[1],j);
3740 s2 = (j > -1) ? mactab[j].mval : "";
3742 if (xxfloat(s2,0) > 0) /* Macro value is a number */
3744 if (j > -1) { /* It's a macro */
3746 x = j; /* whose definition is not numeric */
3747 if (*s2 == '(') { /* Is it an S-Expression? */
3748 /* We have to allocate memory on the stack */
3749 /* to call ourselves recursively on it */
3750 /* otherwise we'll wipe out the macro definition */
3755 s3 = (char *)malloc(k + 4);
3757 strcpy(s3,s2); /* SAFE */
3758 s2 = dosexp(s3); /* Evaluate it */
3761 printf("?Memory allocation failure - \"%s\"\n",s2);
3766 if (*s2 == '\047') {
3769 /* Dumps core if petty optimization was taken */
3770 makestr(&(p[1]),s2);
3772 if (!nosplit && p[1]) free(p[1]);
3773 p[1] = (char *)malloc((int)strlen(s2) + 1);
3774 #endif /* COMMENT */
3778 if (s2[makestrlen-1] == ')') {
3779 s2[makestrlen-1] = NUL;
3783 debug(F110,sexpdebug("'A"),s2,0);
3786 macro++; /* Not an S-Expression */
3787 } else { /* Not found in macro table */
3788 printf("?Not defined - \"%s\"\n", p[1]);
3794 } else if (x < 1 && !macro) { /* n > 1 and not a built-in operator */
3795 x = mxlook(mactab,p[1],nmac); /* See if it's a macro */
3796 debug(F111,sexpdebug("n!=1 mxlook"),p[1],x);
3798 printf("?Invalid operand - \"%s\"\n",p[1]);
3805 if (builtin) { /* Built-in operator... */
3808 if ((flgs = (kwflags & (SXF_ONE|SXF_TWO)))) {
3810 case (SXF_ONE|SXF_TWO):
3812 printf("?Too few operands - \"%s\"\n",s);
3819 printf("?Too few operands - \"%s\"\n",s);
3826 printf("?Too %s operands - \"%s\"\n",
3827 (n > 2) ? "many" : "few", s);
3833 if (kwflags & SXF_PRE) { /* Predicate? */
3835 printf("?Too few operands - \"%s\"\n",s);
3842 if (kwflags & SXF_FLO) /* Operator requires floating point */
3843 fpflag++; /* Force it */
3845 if (x == SX_ROU) { /* ROUND can have 1 or 2 arguments */
3846 if (n < 2 || n > 3) {
3847 printf("?Too %s operands - \"%s\"\n",
3848 (n > 3) ? "many" : "few", s);
3854 /* But they are not "cumulative" like other SEXP args */
3855 /* So this case is handled specially */
3856 char buf1[32], buf2[32];
3865 ckstrncpy(buf1,q0,32);
3874 ckstrncpy(buf2,q1,32);
3877 r = ckround(atof(q0),(int)(atof(q1)),sxroundbuf,31);
3883 if (x == SX_SET || x == SX_LET || /* Assignment is special */
3884 x == SX_INC || x == SX_DEC) {
3892 for (i = 1; i < n; i += 2) { /* Loop thru operand pairs */
3896 debug(F110,sexpdebug("target p"),s3,0);
3898 /* Make sure target doesn't have multiple words */
3899 while (*s3) { if (*s3 < '!') { rc = 1; break; }; s3++; }
3901 if (rc) { /* If it does it must have been */
3902 char * s4; /* an SEXP so evaluate it */
3906 while (*s4) { if (*s4 < '!') { rc = 1; break; }; s4++; }
3907 if (rc == 0) makestr(&(p[i+1]),s3);
3910 /* And that it's not a number, etc. */
3911 if (rc > 0 || isdigit(c) || c == '(') {
3912 printf("?Invalid assignment - \"%s\"\n",s);
3915 } else if (isalpha(c)) {
3916 rc = xlookup(sexpconsts,s3,nsexpconsts,NULL);
3918 printf("?Assignment to constant - \"%s\"\n",s);
3924 /* If ++ or --, get current value of variable */
3925 if (x == SX_INC || x == SX_DEC) {
3928 if (c == CMDQ) { /* A backslash variable */
3932 if (zzstring(s3,&s,&n) < 0 || !buf[0])
3935 } else { /* A macro */
3936 if ((k = mxlook(mactab,s3,nmac)) < 0)
3939 s2 = mactab[k].mval;
3942 printf("?Not defined - \"%s\"\n",p[i+1]);
3949 printf("?Not numeric - \"%s\"\n",p[i+1]);
3953 while (*s2 == '+') s2++;
3954 result = ckatofs(s2);
3955 fpresult = floatval;
3956 if (k > 1 || fpresult != result)
3959 if (n < i+2) { /* Variable with no value */
3961 if (x == SX_SET || x == SX_LET) {
3962 delmac(p[i+1],1); /* Delete the variable */
3967 } else { /* Variable with value */
3968 k = xxfloat(p[i+2],0); /* Is it a number? */
3971 while (*s2 == '+') s2++;
3973 s2 = dosexp(p[i+2]); /* Have value, evaluate it */
3974 if (sexprc) goto xdosexp;
3976 if (!*s2 && (x == SX_INC || x == SX_DEC))
3980 if (x == SX_INC || x == SX_DEC) {
3983 printf("?Not numeric - \"%s\"\n",s2);
3987 while (*s2 == '+') s2++;
3998 } else if (x == SX_DEC) {
4003 if (result != fpresult) fpflag++;
4004 #endif /* FNFLOAT */
4005 s2 = (fpflag && !sexptrunc) ?
4006 fpformat(fpresult,0,0) : ckfstoa(result);
4008 if (x == SX_LET && cmdlvl > 0) /* LET makes var local */
4010 if ((rc = addmac(p[i+1],s2)) < 0) { /* Add the value */
4012 case -3: m = "Array not declared"; break;
4013 case -2: m = "Subscript out of range"; break;
4014 case -4: m = "Out of memory"; break;
4015 default: m = "Error creating variable";
4017 printf("?%s - \"%s\"\n",m,s);
4021 if (s2) result = ckatofs(s2);
4024 } else if (x == SX_IFC) { /* Conditional expression */
4027 printf("?Too many operands: IF - \"%s\"\n",s);
4032 if (sexprc) goto xdosexp;
4035 if (xxfloat(s2,0) == 2) {
4037 fpresult = (CKFLOAT)result;
4042 true = ((fpj != 0.0) ? 1 : 0);
4044 if (!true && n < 4) {
4047 s2 = dosexp(true ? p[3] : p[4]);
4048 if (sexprc) goto xdosexp;
4049 j = s2 ? ckatofs(s2) : 0;
4050 if (xxfloat(s2,0) == 2) {
4052 fpresult = (CKFLOAT)result;
4055 fpj = s2 ? atof(s2) : 0.0;
4061 } else if (x == SX_QUO) {
4065 p[3] = (char *)malloc(xx+4);
4067 ckmakmsg(p[3],xx+4,"'(",p[2],")",NULL);
4071 #endif /* COMMENT */
4073 } else if (x == SX_STR) {
4076 if (sexprc) goto xdosexp;
4078 p[3] = (char *)malloc(xx+4);
4079 ckmakmsg(p[3],xx+4,"'(",s2,")",NULL);
4085 /* Arithmetic operator or macro - Loop thru operands */
4087 quit = 0; /* Short-circuit flag. */
4088 if (macro && n > 1) { /* If operator is a macro */
4089 if (!line) { /* allocate local buffer for */
4090 line = (char *)malloc(SXMLEN); /* the evaluated argument list. */
4092 printf("?Memory allocation failure - \"%s\"\n",p[1]);
4097 /* debug(F101,"dosexp macro arg buffer","",linelen); */
4100 line[linepos] = NUL;
4102 for (i = 1; ((i < n) && !sexprc && !quit); i++) { /* Loop thru operands */
4104 s2 = p[i+1]; /* Get operand */
4108 if (*s2 == '\047') { /* Is it quoted? */
4109 debug(F110,sexpdebug("'B"),s2,0);
4110 s2++; /* Space past the quote */
4112 if (*s2 == '(') { /* Quoted S-Expression? */
4113 char c4, * s4 = s2+1; /* Strip outer parens */
4114 while ((c4 = *s4++)) {
4115 if (c4 == ')' && !*s4) {
4122 debug(F110,sexpdebug("'C"),s2,0);
4124 } else { /* Not quoted */
4125 s2 = dosexp(p[i+1]); /* evaluate it */
4126 if (sexprc) goto xdosexp;
4128 if (!macro && x == SX_EVA)
4132 if (*s2 != '\047') { /* Is it quoted? */
4133 s2 = dosexp(p[i+1]); /* No, evaluate it */
4134 if (sexprc) goto xdosexp;
4136 if (!macro && x == SX_EVA)
4139 if (*s2 == '\047') { /* Is result quoted? */
4140 debug(F110,sexpdebug("'B"),s2,0);
4141 s2++; /* Space past the quote */
4143 if (*s2 == '(') { /* Quoted S-Expression? */
4144 char c4, * s4 = s2+1; /* Strip outer parens */
4145 while ((c4 = *s4++)) {
4146 if (c4 == ')' && !*s4) {
4153 debug(F110,sexpdebug("'C"),s2,0);
4155 #endif /* COMMENT */
4157 debug(F111,sexpdebug("macro arg"),s2,i);
4160 register char c4, * s4 = s2;
4161 while ((c4 = *s4++)) if (c4 == SP) { quote++; break; }
4163 if (quote) line[linepos++] = '{';
4164 while ((line[linepos++] = *s2++)) {
4165 if (linepos > linelen - 3) {
4167 line[linepos] = NUL;
4169 tmp = (char *) malloc(linelen);
4171 printf("?Memory re-allocation failure - \"%s...\"\n",
4181 linepos--; /* Back up over NUL */
4183 line[linepos++] = '}'; /* End quote group */
4184 line[linepos++] = SP; /* add a space */
4185 line[linepos] = NUL; /* and a NUL */
4188 if (!quote) { /* Built-in operator... */
4190 if (sexprc) goto xdosexp;
4197 /* An empty value is not a legal number */
4198 /* but it is a legal truth value */
4199 if (x != SX_AND && x != SX_LOR && x != SX_NOT) {
4200 printf("?Not Numeric - \"%s\"\n",p[i+1]);
4208 /* Switch to floating-point upon encountering any f.p. arg */
4209 /* OR... if integer is too big */
4210 if (!fpflag) if (xxfloat(s2,0) == 2)
4214 if (i == 1) { /* Initial result is first operand */
4215 result = (n == 2 && x == SX_SUB) ? 0-j : j;
4216 fpresult = (n == 2 && x == SX_SUB) ? -fpj : fpj;
4217 if ((x == SX_AND && result == 0) || /* Short circuit */
4218 (x == SX_LOR && result != 0))
4220 if (!(kwflags & SXF_ONE)) /* Command w/single arg */
4223 if (x == SX_MOD || x == SX_DIV) {
4227 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4232 switch (x) { /* Accumulate result */
4234 case SX_EVA: /* EVAL */
4239 case SX_ADD: /* + */
4243 if (result != fpresult)
4245 #endif /* FNFLOAT */
4248 case SX_SUB: /* - */
4252 if (result != fpresult)
4254 #endif /* FNFLOAT */
4257 case SX_MUL: /* * */
4261 if (result != fpresult)
4263 #endif /* FNFLOAT */
4266 case SX_AND: /* AND */
4267 result = result && j;
4268 if (!result) quit++;
4269 fpresult = fpresult && fpj;
4272 case SX_LOR: /* OR */
4273 result = result || j;
4274 if (!result) quit++;
4275 fpresult = fpresult || fpj;
4278 case SX_MOD: /* Modulus */
4279 result = result % j;
4281 fpresult = (CKFLOAT)fmod(fpresult,fpj);
4282 if (result != fpresult)
4286 #endif /* FNFLOAT */
4289 case SX_DIV: /* / */
4294 if (result != fpresult)
4296 #endif /* FNFLOAT */
4302 #endif /* FNFLOAT */
4306 case SX_AEQ: /* Test for equality */
4308 if (fpresult != fpj)
4316 case SX_NEQ: /* Test for ineqality */
4318 if (fpresult == fpj)
4326 case SX_ALE: /* Arithmetic less-equal */
4338 case SX_ALT: /* Arithmetic less-than */
4340 if (fpj <= fpresult)
4350 case SX_AGT: /* Arithmetic greater-than */
4352 if (fpj >= fpresult)
4362 case SX_AGE: /* Arithmetic greater-equal */
4374 case SX_POW: /* Raise to power */
4380 } else if ((!fpresult && fpj <= 0.0)) {
4381 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4384 } else if (fpresult < 0.0 && modf(fpj,&dummy)) {
4385 printf("?Domain error - \"%s\"\n",cmdbuf);
4389 fpresult = (CKFLOAT)pow(fpresult,fpj);
4392 #endif /* FNFLOAT */
4396 CK_OFF_T z, sign = 0;
4399 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4410 result = 1 / result;
4413 if (result != fpresult)
4415 #endif /* FNFLOAT */
4419 case SX_EXP: /* e to the given power */
4420 fpresult = (CKFLOAT) exp(fpj);
4423 case SX_LGN: /* Natural log */
4424 case SX_LGX: /* Log base 10 */
4425 case SX_SQR: /* Square root */
4427 printf("?Argument out of range - \"%s\"\n",cmdbuf);
4432 fpresult = (CKFLOAT) sqrt(fpj);
4433 else if (x == SX_LGN)
4434 fpresult = (CKFLOAT) log(fpj);
4436 fpresult = (CKFLOAT) log10(fpj);
4439 case SX_SIN: /* sine */
4440 fpresult = (CKFLOAT) sin(fpj);
4443 case SX_COS: /* cosine */
4444 fpresult = (CKFLOAT) cos(fpj);
4447 case SX_TAN: /* tangent */
4448 fpresult = (CKFLOAT) tan(fpj);
4450 #endif /* FNFLOAT */
4452 case SX_CEI: /* Ceiling */
4461 case SX_FLR: /* Floor */
4470 case SX_TRU: /* Truncate */
4476 case SX_ABS: /* Absolute value */
4477 result = (j < 0) ? 0 - j : j;
4479 fpresult = (fpj < 0.0) ? 0.0 - fpj : fpj;
4480 if (result != fpresult)
4482 #endif /* FNFLOAT */
4485 case SX_MAX: /* Max */
4496 case SX_MIN: /* Min */
4507 case SX_FLO: /* Float */
4513 case SX_NOT: /* NOT (reverse truth value) */
4518 case SX_BWA: /* Bitwise AND */
4523 case SX_BWO: /* Bitwise OR */
4528 case SX_BWX: /* Bitwise XOR */
4529 case SX_XOR: /* Logical XOR */
4531 printf("?Too many operands - \"%s\"\n",s);
4539 result = (result && !j) || (!result && j);
4540 if (result) result = 1;
4544 case SX_BWN: /* Bitwise Not */
4550 printf("BAD OP [%s]\n",p[1]);
4554 if (!pflag) /* Not a predicate */
4555 sexppv = -1; /* So unset this */
4559 if (macro) { /* User-defined macro */
4560 extern int fsexpflag; /* (see fneval():ckuus4.c) */
4561 int lookagain = 0; /* Maybe the macro table changed */
4562 if (mactab[mx].kwd) { /* Check and see */
4563 if (ckstrcmp(mactab[mx].kwd,p[1],-1,0))
4567 if (lookagain) { /* The table changed */
4568 mx = mxlook(mactab,p[1],nmac); /* Get the macro's new index */
4569 debug(F111,sexpdebug("macro moved"),p[1],mx);
4570 if (mx < 0) { /* Yikes! */
4571 printf("?Macro disappeared! - \"%s\"\n",p[1]);
4576 debug(F111,sexpdebug("macro mx"),mactab[mx].kwd,mx);
4577 if (fsexpflag) { /* If embedded in a function call */
4578 if (cmpush() > -1) { /* get a new copy of the parsing */
4579 extern int ifc; /* environment, */
4580 int k, ifcsav = ifc; /* save the IF state */
4581 dodo(mx,line,0); /* Set up the macro */
4582 k = parser(1); /* Call the parser to execute it */
4583 cmpop(); /* Pop back to previous level */
4584 ifc = ifcsav; /* restore IF state */
4585 if (k == 0) /* If no error */
4586 s2 = mrval[maclvl+1]; /* get return value, if any */
4588 debug(F110,sexpdebug("macro return"),s2,0);
4590 printf("?Resources exhausted - \"%s\"\n",s);
4593 } else { /* Not embedded in a function call */
4594 dodo(mx,line,0); /* As above but without cmpush/pop() */
4597 s2 = mrval[maclvl+1];
4600 } else if (pflag) { /* Predicate */
4601 if (not) presult = presult ? 0 : 1;
4602 sexppv = presult; /* So set predicate value (0 or 1) */
4603 s2 = presult ? "1" : "0";
4604 } else if (fpflag && !sexptrunc) { /* Result is floating-point */
4605 if (not) fpresult = fpresult ? 0.0 : 1.0;
4606 s2 = fpformat(fpresult,0,0);
4607 } else if (x != SX_EVA) {
4608 if (not) result = result ? 0 : 1;
4609 s2 = ckfstoa(result);
4612 /* Common exit point. Always come here to exit. */
4617 if (!sexprc && s2) { /* Have a result */
4619 char * q2 = s2; int xx = 0;
4621 while (*q2++) xx++; /* Get length */
4622 if (xx > sexprmax) /* (stats) */
4626 if (xx > sxrlen[sexpdep] || !sxresult[sexpdep]) {
4630 if (sxresult[sexpdep])
4631 free(sxresult[sexpdep]);
4632 if ((sxresult[sexpdep] = (char *)malloc(k))) {
4633 sxrlen[sexpdep] = k;
4635 printf("?Memory allocation failure - \"%s\"\n",s2);
4639 sx = sxresult[sexpdep]; /* Point to result buffer */
4640 while ((*sx++ = *s2++)) ; /* copy result. */
4641 if (fpflag && truncate) { /* Floating point + truncate */
4642 sx = sxresult[sexpdep]; /* at decimal point */
4643 for (i = xx - 1; i >= 0; i--) {
4646 if (i == 0) { /* If nothing left */
4647 sx[0] = '0'; /* put a zero. */
4654 if (line) /* If macro arg buffer allocated */
4655 free(line); /* free it. */
4656 if (mustfree) { /* And free local copy of split list */
4657 for (i = 1; i <= n; i++) {
4658 if (p[i]) free(p[i]);
4661 debug(F111,sexpdebug("exit"),sxresult[sexpdep],sexprc);
4662 return(sxresult[sexpdep--]);
4667 int /* CHECK command */
4670 if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0)
4672 ckstrncpy(line,atmbuf,LINBUFSIZ);
4673 if ((y = cmcfm()) < 0)
4676 if (!ckstrcmp(line,"push",(int)strlen(line),0)) {
4677 if (msgflg) /* If at top level... */
4678 printf(" push%s available\n", nopush ? " not" : "");
4679 else if (nopush && !backgrd)
4680 printf(" CHECK: push not available\n");
4681 return(success = 1 - nopush);
4685 if (!ckstrcmp(line,"pipes",(int)strlen(line),0)) {
4686 if (msgflg) /* If at top level... */
4687 printf(" pipes%s available\n",
4688 (nopush || protocol != PROTO_K) ? " not" : "");
4689 else if ((nopush || protocol != PROTO_K) && !backgrd)
4690 printf(" CHECK: pipes not available\n");
4691 return(success = 1 - nopush);
4693 #endif /* PIPESEND */
4694 y = lookup(ftrtab,line,nftr,&x); /* Look it up */
4695 debug(F111,"dochk",ftrtab[x].kwd,y);
4696 if (msgflg) /* If at top level... */
4697 printf(" %s%s available\n", ftrtab[x].kwd, y ? " not" : "");
4698 else if (y && !backgrd)
4699 printf(" CHECK: %s not available\n", ftrtab[x].kwd);
4700 return(success = 1 - y);
4706 /* Connection log and elapsed-time reporting */
4708 extern char cxlogbuf[]; /* Log record buffer */
4709 extern char diafil[]; /* Log file name */
4710 extern int dialog, cx_active; /* Flags */
4711 static long cx_prev = 0L; /* Elapsed time of previous session */
4713 #endif /* CKLOGDIAL */
4714 #endif /* NOLOCAL */
4717 dologend() { /* Write record to connection log */
4719 extern int locus, autolocus;
4724 long d1, d2, t1, t2;
4726 #endif /* CKLOGDIAL */
4727 #endif /* NOLOCAL */
4733 debug(F101,"dologend ftpisconnected","",ftpisconnected());
4734 setlocus(ftpisconnected() ? 0 : 1, 1);
4743 debug(F101,"dologend dialog","",dialog);
4744 debug(F101,"dologend cxlogbuf[0]","",cxlogbuf[0]);
4746 debug(F101,"dologend ckxlogging","",ckxlogging);
4747 #endif /* CKSYSLOG */
4749 if (!cx_active || !cxlogbuf[0]) /* No active record */
4752 cx_active = 0; /* Record is not active */
4753 debug(F111,"dologend cxlogbuf 1",cxlogbuf,cx_active);
4755 d1 = mjd((char *)cxlogbuf); /* Get start date of this session */
4756 ckstrncpy(buf,ckdate(),31); /* Get current date */
4757 d2 = mjd(buf); /* Convert them to mjds */
4758 p = cxlogbuf; /* Get start time */
4760 p[14] = NUL; /* Convert to seconds */
4761 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4764 p = buf; /* Get end time */
4767 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4768 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */
4769 debug(F101,"dologend t2","",t2);
4773 debug(F110,"dologend hhmmss",p,0);
4774 ckstrncat(cxlogbuf,"E=",CXLOGBUFL); /* Append to log record */
4775 ckstrncat(cxlogbuf,p,CXLOGBUFL);
4776 debug(F110,"dologend cxlogbuf 2",cxlogbuf,0);
4779 debug(F101,"dologend cx_prev","",cx_prev);
4780 if (dialog) { /* If logging */
4782 x = diaopn(diafil,1,1); /* Open log in append mode */
4783 debug(F101,"dologend diaopn","",x);
4784 x = zsoutl(ZDIFIL,cxlogbuf); /* Write the record */
4785 debug(F101,"dologend zsoutl","",x);
4786 x = zclose(ZDIFIL); /* Close the log */
4787 debug(F101,"dologend zclose","",x);
4790 debug(F101,"dologend ckxlogging","",ckxlogging);
4793 x = ckindex("T=DIAL",cxlogbuf,0,0,1);
4794 debug(F111,"dologend ckxsyslog",cxlogbuf,ckxsyslog);
4795 debug(F111,"dologend ckindex","T=DIAL",x);
4797 if (ckxsyslog >= SYSLG_DI) {
4798 debug(F110,"dologend syslog",cxlogbuf+18,0);
4799 cksyslog(SYSLG_DI,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4800 } else if (ckxsyslog >= SYSLG_AC) {
4801 debug(F110,"dologend syslog",cxlogbuf+18,0);
4802 cksyslog(SYSLG_AC,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4806 #endif /* CKSYSLOG */
4807 #endif /* CKLOGDIAL */
4808 #endif /* NOLOCAL */
4814 /* D O L O G S H O W -- Show session/connection info */
4816 /* Call with fc == 1 to show, fc == 0 to only calculate. */
4817 /* Returns session elapsed time in seconds. */
4818 /* If no session active, returns elapsed time of previous session, if any, */
4822 dologshow(fc) int fc; { /* SHOW (current) CONNECTION */
4823 long d1, d2, t1, t2 = 0, prev;
4824 char c, buf1[32], buf2[32], * info[32], * p, * s;
4825 char * xlogbuf, xbuf[CXLOGBUFL+1];
4826 int i, x = 0, z, ftp = 0, active = 0;
4829 extern char ftplogbuf[];
4830 extern long ftplogprev;
4831 extern int ftplogactive;
4835 xlogbuf = ftplogbuf;
4837 active = ftplogactive;
4848 debug(F101,"dologshow local","",local);
4849 debug(F101,"dologshow ftp","",ftp);
4850 debug(F111,"dologshow active",xlogbuf,active);
4854 if (didsetlin || ftp)
4855 printf(" %s: No record.\n", ftp ? "FTP" : "Kermit");
4857 printf(" %s: No connection.\n", ftp ? "FTP" : "Kermit");
4864 z = ftpisconnected() ? 1 : -1;
4867 if (local) { /* See if we have an open connection */
4869 debug(F101,"dologshow ttchk","",z);
4870 z = (z > -1) ? 1 : -2;
4872 z = active ? 1 : -2;
4883 /* Note: NOT ckstrncpy! */
4884 strncpy(buf1,xlogbuf,17); /* Copy of just the timestamp */
4885 buf1[17] = NUL; /* Terminate it */
4886 ckstrncpy(xbuf,xlogbuf+18,CXLOGBUFL); /* Copy that can be poked */
4887 debug(F111,"dologshow prev",xbuf,prev);
4889 xwords(xbuf,31,info,1); /* Break up into fields */
4890 d1 = mjd(buf1); /* Convert start time to MJD */
4891 ckstrncpy(buf2,ckdate(),31); /* Current date */
4892 d2 = mjd(buf2); /* Convert to MJD */
4893 p = buf1; /* Point to start time */
4895 p[14] = NUL; /* Convert to seconds */
4896 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4899 p = buf2; /* Ditto for current time */
4903 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4904 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Elapsed time so far */
4908 if (t2 > -1L) /* Convert seconds to hh:mm:ss */
4916 printf("\n"); /* Show results */
4917 printf(" Status: %s\n",s);
4918 printf(" Opened: %s\n",buf1);
4919 printf(" User: %s\n",info[1] ? info[1] : "");
4920 printf(" PID: %s\n",info[2] ? info[2] : "");
4921 for (i = 3; info[i]; i++) {
4923 s = (info[i]) ? info[i]+2 : "";
4925 case 'T': printf(" Type: %s\n", s); break;
4926 case 'N': printf(" To: %s\n", s); break;
4927 case 'P': printf(" Port: %s\n", s); break;
4928 case 'H': printf(" From: %s\n", s); break;
4929 case 'D': printf(" Device: %s\n", s); break;
4930 case 'O': printf(" Origin: %s\n", s); break;
4932 default: printf(" %s\n",info[i] ? info[i] : "");
4936 printf(" Elapsed time: %s\n", hhmmss(t2));
4938 printf(" Elapsed time: %s\n", p ? p : "(unknown)");
4942 if ( IS_SSH() ) x++;
4943 #endif /* SSHBUILTIN */
4944 #ifdef CK_ENCRYPTION
4945 if (ck_tn_encrypting() && ck_tn_decrypting()) x++;
4946 #endif /* CK_ENCRYPTION */
4948 if (tls_active_flag || ssl_active_flag) x++;
4952 #ifdef CK_ENCRYPTION
4953 if (ttnproto == NP_EK4LOGIN || ttnproto == NP_EK5LOGIN) x++;
4954 #endif /* CK_ENCRYPTION */
4955 #endif /* CK_KERBEROS */
4956 #endif /* RLOGCODE */
4957 #endif /* NETCONN */
4959 printf(" Encrypted: %s\n", x ? "Yes" : "No");
4960 printf(" Log: %s\n", dialog ? diafil : "(none)");
4963 return(t2 > -1L ? t2 : 0L);
4971 dologend(); /* Previous session not closed out? */
4972 cx_active = 1; /* Record is active */
4974 p = ckdate(); /* Get timestamp */
4975 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL-1); /* Start record off with it */
4977 debug(F100,"dologline uidbuf empty","",0);
4978 #ifdef UNIX /* Who has whoami()... */
4979 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4982 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4984 ckstrncpy(uidbuf,"UNKNOWN",UIDBUFLEN);
4985 #endif /* STRATUS */
4988 m = strlen(uidbuf) + strlen(myhost) + strlen(ttname) + 32;
4989 if (n+m < CXLOGBUFL-1) { /* Add serial device info */
4991 sprintf(p," %s %s T=SERIAL H=%s D=%s ", /* SAFE */
4998 ckstrncpy(cxlogbuf,"LOGLINE BUFFER OVERFLOW",CXLOGBUFL);
4999 debug(F110,"dologline",cxlogbuf,0);
5005 char * p, * s = "NET", * uu = uidbuf;
5010 dologend(); /* Previous session not closed out? */
5012 cx_active = 1; /* Record is active */
5014 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL);
5016 if (nettype == NET_TCPB || nettype == NET_TCPA) {
5019 } else if (nettype == NET_SSH) {
5023 #endif /* TCPSOCKET */
5025 if (nettype == NET_SX25 || nettype == NET_VX25 || nettype == NET_IX25)
5029 if (nettype == NET_DEC)
5033 if (nettype == NET_SLAT)
5035 #endif /* SUPERLAT */
5037 if (nettype == NET_BIOS)
5039 #endif /* CK_NETBIOS */
5042 debug(F100,"dolognet uidbuf empty","",0);
5043 #ifdef OS2ORUNIX /* Who has whoami()... */
5044 uu = (char *)whoami();
5047 uu = (char *)whoami();
5050 #endif /* STRATUS */
5057 if ((k = ckindex(":",h,0,0,0)) > 0) {
5061 int svcnum = gettcpport();
5063 port = ckitoa(svcnum);
5068 #endif /* TCPSOCKET */
5069 m = strlen(uu) + strlen(myhost) + strlen(ttname) + strlen(s) + 32;
5070 if (n+m < CXLOGBUFL-1) { /* SAFE */
5072 sprintf(p," %s %s T=%s N=%s H=%s P=%s ",
5081 ckstrncpy(cxlogbuf,"LOGNET BUFFER OVERFLOW",CXLOGBUFL);
5082 debug(F110,"dolognet cxlogbuf",cxlogbuf,0);
5083 if (h) makestr(&h,NULL);
5085 #endif /* NETCONN */
5086 #endif /* CKLOGDIAL */
5090 Parse a DIAL-related string, stripping enclosing braces, if any.
5093 dialstr(p,msg) char **p; char *msg; {
5097 if ((x = cmtxt(msg, "", &s, xxstring)) < 0)
5099 s = brstrip(s); /* Strip braces around. */
5100 debug(F110,"dialstr",s,0);
5101 makestr(p,*s?s:NULL);
5102 return(success = 1);
5110 mdmtyp = x; /* Set global modem type */
5111 debug(F101,"initmdm mdmtyp","",mdmtyp);
5112 debug(F101,"initmdm usermdm","",usermdm);
5115 m = usermdm ? usermdm : mdmtyp;
5117 p = modemp[m]; /* Point to modem info struct, and */
5118 /* debug(F101,"initmdm p","",p); */
5120 dialec = p->capas & CKD_EC; /* set DIAL ERROR-CORRECTION, */
5121 dialdc = p->capas & CKD_DC; /* DIAL DATA-COMPRESSION, and */
5122 mdmspd = p->capas & CKD_SB ? 0 : 1; /* DIAL SPEED-MATCHING from it. */
5123 dialfc = FLO_AUTO; /* Modem's local flow control.. */
5124 dialmax = p->max_speed;
5125 dialcapas = p->capas;
5126 dialesc = p->esc_char;
5127 } else if (mdmtyp > 0) {
5128 printf("WARNING: modem info for \"%s\" not filled in yet\n",
5133 /* Reset or set the SET DIAL STRING items ... */
5137 debug(F110,"initmdm dialini",dialini,0);
5138 debug(F110,"initmdm dialmstr ",dialmstr,0);
5139 debug(F110,"initmdm dialmprmt",dialmprmt,0);
5140 debug(F110,"initmdm dialcmd",dialcmd,0);
5141 debug(F110,"initmdm dialdcon",dialdcon,0);
5142 debug(F110,"initmdm dialdcoff",dialdcoff,0);
5143 debug(F110,"initmdm dialecon",dialecon,0);
5144 debug(F110,"initmdm dialecoff",dialecoff,0);
5145 debug(F110,"initmdm dialhcmd",dialhcmd,0);
5146 debug(F110,"initmdm dialhwfc",dialhwfc,0);
5147 debug(F110,"initmdm dialswfc",dialswfc,0);
5148 debug(F110,"initmdm dialnofc",dialnofc,0);
5149 debug(F110,"initmdm dialtone",dialtone,0);
5150 debug(F110,"initmdm dialpulse",dialpulse,0);
5151 debug(F110,"initmdm dialname",dialname,0);
5152 debug(F110,"initmdm dialaaon",dialaaon,0);
5153 debug(F110,"initmdm dialaaoff",dialaaoff,0);
5154 debug(F110,"initmdm dialx3",dialx3,0);
5155 debug(F110,"initmdm dialspon",dialspon,0);
5156 debug(F110,"initmdm dialspoff",dialspoff,0);
5157 debug(F110,"initmdm dialvol1",dialvol1,0);
5158 debug(F110,"initmdm dialvol2",dialvol2,0);
5159 debug(F110,"initmdm dialvol3",dialvol3,0);
5160 debug(F110,"initmdm dialini2",dialini2,0);
5164 if (usermdm && p) { /* USER-DEFINED: copy info from specified template */
5166 makestr(&dialini ,p->wake_str);
5167 makestr(&dialmstr ,p->dmode_str);
5168 makestr(&dialmprmt,p->dmode_prompt);
5169 makestr(&dialcmd ,p->dial_str);
5170 makestr(&dialdcon ,p->dc_on_str);
5171 makestr(&dialdcoff,p->dc_off_str);
5172 makestr(&dialecon ,p->ec_on_str);
5173 makestr(&dialecoff,p->ec_off_str);
5174 makestr(&dialhcmd ,p->hup_str);
5175 makestr(&dialhwfc ,p->hwfc_str);
5176 makestr(&dialswfc ,p->swfc_str);
5177 makestr(&dialnofc ,p->nofc_str);
5178 makestr(&dialtone ,p->tone);
5179 makestr(&dialpulse,p->pulse);
5180 makestr(&dialname ,"This space available (use SET MODEM NAME)");
5181 makestr(&dialaaon ,p->aa_on_str);
5182 makestr(&dialaaoff,p->aa_off_str);
5183 makestr(&dialx3 ,p->ignoredt);
5184 makestr(&dialspon ,p->sp_on_str);
5185 makestr(&dialspoff,p->sp_off_str);
5186 makestr(&dialvol1 ,p->vol1_str);
5187 makestr(&dialvol2 ,p->vol2_str);
5188 makestr(&dialvol3 ,p->vol3_str);
5189 makestr(&dialini2 ,p->ini2);
5191 } else { /* Not user-defined, so wipe out overrides */
5193 if (dialini) makestr(&dialini,NULL); /* Init-string */
5194 if (dialmstr) makestr(&dialmstr,NULL); /* Dial-mode-str */
5195 if (dialmprmt) makestr(&dialmprmt,NULL); /* Dial-mode-pro */
5196 if (dialcmd) makestr(&dialcmd,NULL); /* Dial-command */
5197 if (dialdcon) makestr(&dialdcon,NULL); /* DC ON command */
5198 if (dialdcoff) makestr(&dialdcoff,NULL); /* DC OFF command */
5199 if (dialecon) makestr(&dialecon,NULL); /* EC ON command */
5200 if (dialecoff) makestr(&dialecoff,NULL); /* EC OFF command */
5201 if (dialhcmd) makestr(&dialhcmd,NULL); /* Hangup command */
5202 if (dialhwfc) makestr(&dialhwfc,NULL); /* Flow control... */
5203 if (dialswfc) makestr(&dialswfc,NULL); /* */
5204 if (dialnofc) makestr(&dialnofc,NULL); /* */
5205 if (dialtone) makestr(&dialtone,NULL); /* Dialing method */
5206 if (dialpulse) makestr(&dialpulse,NULL); /* */
5207 if (dialname) makestr(&dialname,NULL); /* Modem name */
5208 if (dialaaon) makestr(&dialaaon,NULL); /* Autoanswer On */
5209 if (dialaaoff) makestr(&dialaaoff,NULL); /* Autoanswer Off */
5210 if (dialx3) makestr(&dialx3,NULL); /* Ignore dialtone */
5211 if (dialspon) makestr(&dialspon,NULL); /* Speaker On */
5212 if (dialspoff) makestr(&dialspoff,NULL); /* Speaker Off */
5213 if (dialvol1) makestr(&dialvol1,NULL); /* Low volume */
5214 if (dialvol2) makestr(&dialvol2,NULL); /* Medium volume */
5215 if (dialvol3) makestr(&dialvol3,NULL); /* High volume */
5216 if (dialini2) makestr(&dialini2,NULL); /* Init string 2 */
5218 if (autoflow) /* Maybe change flow control */
5223 tbmodel = 0; /* If it's a Telebit, we don't know the model yet */
5224 #endif /* OLDTBCODE */
5225 #endif /* MINIDIAL */
5229 /* Not implemented yet */
5233 extern int ans_cid, ans_ring;
5234 if ((x = cmkey(answertab,nanswertab,"","",xxstring)) < 0)
5238 return(seton(&ans_cid));
5240 y = cmnum("How many rings before answering","1",10,&x,xxstring);
5241 y = setnum(&ans_rings,x,y,254);
5245 #endif /* COMMENT */
5248 setmodem() { /* SET MODEM */
5256 "Modem parameter","","",nsetmdm, 0, xxstring, setmdm, &k2);
5257 cmfdbi(&k2,_CMKEY,"","","",nmdm,0,xxstring,mdmtab,NULL);
5259 if (x < 0) { /* Error */
5260 if (x == -2 || x == -9)
5261 printf("?No keywords match: \"%s\"\n",atmbuf);
5264 y = cmresult.nresult; /* Keyword value */
5265 if (cmresult.fdbaddr == &k2) { /* Modem-type keyword table */
5266 if ((x = cmcfm()) < 0)
5269 initmdm(cmresult.nresult); /* Set the modem type. */
5270 return(success = 1); /* Done */
5272 switch (cmresult.nresult) { /* SET MODEM keyword table. */
5274 case XYDMHU: /* DIAL MODEM-HANGUP */
5275 if ((y = cmkey(mdmhang,4,"how to hang up modem",
5276 "modem-command", xxstring)) < 0)
5278 if ((x = cmcfm()) < 0)
5282 /* Nope, I fixed it (2001 11 08) */
5284 if (dialmhu == 0 && !quiet) {
5286 "\n WARNING: RS-232 signal sampling and manipulation do not work\n"
5289 " in the standard SCO OSR5 serial i/o drivers. SET MODEM HANGUP-METHOD\n"
5292 " MODEM-COMMAND is recommended for OSR5.\n\n"
5295 #endif /* CK_SCOV5 */
5296 #endif /* COMMENT */
5297 return(success = 1);
5304 if ((y = cmkey(mdmcap,nmdmcap,
5305 "capability of modem", "", xxstring)) < 0) {
5313 if ((x = cmcfm()) < 0)
5316 debug(F101,"setmodem autoflow","",autoflow);
5317 debug(F101,"setmodem flow 1","",flow);
5318 if (autoflow) /* Maybe change flow control */
5320 debug(F101,"setmodem flow 2","",flow);
5321 mdmspd = zz & CKD_SB ? 0 : 1; /* Set MODEM SPEED-MATCHING from it. */
5322 return(success = 1);
5326 if (network && istncomport())
5327 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
5329 #endif /* TN_COMPORT */
5330 x = cmkey(spdtab,nspd,line,"",xxstring);
5332 if (x == -3) printf("?value required\n");
5335 if ((y = cmcfm()) < 0) return(y);
5336 dialmax = (long) x * 10L;
5337 if (dialmax == 70) dialmax = 75;
5338 return(success = 1);
5340 case XYDSTR: /* These moved from SET DIAL */
5351 if ((y = cmkey(mdmtab,nmdm,"modem type","none", xxstring)) < 0)
5353 if (y == dialudt) { /* User-defined modem type */
5354 if ((x = cmkey(mdmtab,nmdm,"based on existing modem type",
5355 "unknown", xxstring)) < 0)
5358 if ((z = cmcfm()) < 0)
5361 usermdm = (y == dialudt) ? x : 0;
5363 mdmset = (mdmtyp > 0);
5364 return(success = 1);
5367 return(dialstr(&dialname,"Descriptive name for modem"));
5369 case XYDMCD: /* SET MODEM CARRIER-WATCH */
5372 case XYDSPK: /* SET MODEM SPEAKER */
5373 return(seton(&mdmspk));
5375 case XYDVOL: /* SET MODEM VOLUME */
5376 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0)
5378 if ((y = cmcfm()) < 0)
5381 return(success = 1);
5384 printf("Unexpected SET MODEM parameter\n");
5389 static int /* Set DIAL command options */
5395 if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0)
5398 case XYDHUP: /* DIAL HANGUP */
5399 return(seton(&dialhng));
5400 case XYDINI: /* DIAL INIT-STRING */
5401 return(dialstr(&dialini,"Modem initialization string"));
5402 case XYDNPR: /* DIAL PREFIX */
5403 return(dialstr(&dialnpr,"Telephone number prefix"));
5404 case XYDDIA: /* DIAL DIAL-COMMAND */
5405 x = cmtxt("Dialing command for modem,\n\
5406 include \"%s\" to stand for phone number,\n\
5407 for example, \"set dial dial-command ATDT%s\\13\"",
5411 if (x < 0 && x != -3) /* Handle parse errors */
5413 s = brstrip(s); /* Strip braces or quotes */
5414 y = x = strlen(s); /* Get length of text */
5415 if (y > 0) { /* If there is any text (left), */
5416 for (x = 0; x < y; x++) { /* make sure they included "%s" */
5417 if (s[x] != '%') continue;
5418 if (s[x+1] == 's') break;
5422 "?Dial-command must contain \"%cs\" for phone number.\n",'%');
5426 if (dialcmd) { /* Free any previous string. */
5428 dialcmd = (char *) 0;
5431 dialcmd = malloc(y + 1); /* Allocate space for it */
5433 strcpy(dialcmd,s); /* and make a safe copy. */
5435 return(success = 1);
5437 case XYDKSP: /* DIAL KERMIT-SPOOF */
5438 return(seton(&dialksp));
5440 case XYDTMO: /* DIAL TIMEOUT */
5441 y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);
5442 if (y < 0) return(y);
5443 y = cmnum("Kermit/modem timeout differential","10",10,&z,xxstring);
5444 if (y < 0) return(y);
5445 if ((y = cmcfm()) < 0)
5449 case XYDESC: /* DIAL ESCAPE-CHARACTER */
5450 y = cmnum("ASCII value of character to escape back to modem",
5451 "43",10,&x,xxstring);
5452 y = setnum(&dialesc,x,y,128);
5453 if (y > -1 && dialesc < 0) /* No escape character */
5454 dialmhu = 0; /* So no hangup by modem command */
5456 case XYDDPY: /* DIAL DISPLAY */
5457 return(seton(&dialdpy));
5458 case XYDSPD: /* DIAL SPEED-MATCHING */
5459 /* used to be speed-changing */
5460 if ((y = seton(&mdmspd)) < 0) return(y);
5462 mdmspd = 1 - mdmspd; /* so here we reverse the meaning */
5463 #endif /* COMMENT */
5464 return(success = 1);
5465 case XYDMNP: /* DIAL MNP-ENABLE */
5466 case XYDEC: /* DIAL ERROR-CORRECTION */
5469 if (!dialec) dialdc = 0; /* OFF also turns off compression */
5472 case XYDDC: /* DIAL COMPRESSION */
5475 if (dialdc) dialec = 1; /* ON also turns on error correction */
5479 case XYDMHU: /* DIAL MODEM-HANGUP */
5480 return(seton(&dialmhu));
5484 case XYDDIR: /* DIAL DIRECTORY (zero or more) */
5485 return(parsdir(0)); /* 0 means DIAL */
5488 case XYDSTR: /* DIAL STRING */
5489 if ((y = cmkey(mdmcmd,nmdmcmd,"","",xxstring)) < 0) return(y);
5491 case XYDS_AN: /* Autoanswer ON/OFF */
5492 case XYDS_DC: /* Data compression ON/OFF */
5493 case XYDS_EC: /* Error correction ON/OFF */
5494 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
5496 sprintf(tmpbuf,"Modem's command to %sable %s", /* SAFE */
5498 (y == XYDS_DC) ? "compression" :
5499 ((y == XYDS_EC) ? "error-correction" :
5504 return(dialstr(&dialdcon,tmpbuf));
5505 else if (y == XYDS_EC)
5506 return(dialstr(&dialecon,tmpbuf));
5508 return(dialstr(&dialaaon,tmpbuf));
5511 return(dialstr(&dialdcoff,tmpbuf));
5512 else if (y == XYDS_EC)
5513 return(dialstr(&dialecoff,tmpbuf));
5515 return(dialstr(&dialaaoff,tmpbuf));
5517 case XYDS_HU: /* hangup command */
5518 return(dialstr(&dialhcmd,"Modem's hangup command"));
5519 case XYDS_HW: /* hwfc */
5520 return(dialstr(&dialhwfc,
5521 "Modem's command to enable hardware flow control"));
5522 case XYDS_IN: /* init */
5523 return(dialstr(&dialini,"Modem's initialization string"));
5524 case XYDS_NF: /* no flow control */
5525 return(dialstr(&dialnofc,
5526 "Modem's command to disable local flow control"));
5527 case XYDS_PX: /* prefix */
5528 return(dialstr(&dialnpr,"Telephone number prefix for dialing"));
5529 case XYDS_SW: /* swfc */
5530 return(dialstr(&dialswfc,
5531 "Modem's command to enable local software flow control"));
5532 case XYDS_DT: /* tone dialing */
5533 return(dialstr(&dialtone,
5534 "Command to configure modem for tone dialing"));
5535 case XYDS_DP: /* pulse dialing */
5536 return(dialstr(&dialpulse,
5537 "Command to configure modem for pulse dialing"));
5538 case XYDS_MS: /* dial mode string */
5539 return(dialstr(&dialmstr,
5540 "Command to enter dial mode"));
5541 case XYDS_MP: /* dial mode prompt */
5542 return(dialstr(&dialmprmt,
5543 "Modem response upon entering dial mode"));
5544 case XYDS_SP: /* SPEAKER OFF */
5545 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x);
5547 return(dialstr(&dialspon,"Command to turn modem speaker on"));
5549 return(dialstr(&dialspoff,"Command to turn modem speaker off"));
5551 case XYDS_VO: /* VOLUME LOW */
5552 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0) return(x);
5556 return(dialstr(&dialvol1,
5557 "Command for low modem speaker volume"));
5559 return(dialstr(&dialvol2,
5560 "Command for medium modem speaker volume"));
5563 return(dialstr(&dialvol3,
5564 "Command for high modem speaker volume"));
5569 case XYDS_ID: /* IGNORE-DIALTONE */
5570 return(dialstr(&dialx3,
5571 "Command to tell modem to ignore dialtone"));
5573 case XYDS_I2: /* PREDIAL-INIT */
5574 return(dialstr(&dialini2,
5575 "Command to send to modem just prior to dialing"));
5578 printf("?Unexpected SET DIAL STRING parameter\n");
5581 case XYDFC: /* DIAL FLOW-CONTROL */
5582 if ((y = cmkey(dial_fc,4,"","auto",xxstring)) < 0) return(y);
5583 if ((x = cmcfm()) < 0) return(x);
5585 return(success = 1);
5587 case XYDMTH: { /* DIAL METHOD */
5588 extern int dialmauto;
5589 if ((y = cmkey(dial_m,ndial_m,"","default",xxstring)) < 0)
5591 if ((x = cmcfm()) < 0)
5593 if (y == XYDM_A) { /* AUTO */
5594 dialmauto = 1; /* local country code, if known. */
5597 dialmauto = 0; /* use the method specified */
5600 return(success = 1);
5603 y = cmnum("Number of times to try dialing a number",
5604 "1",10,&x,xxstring);
5605 z = setnum(&dialrtr,x,y,-1);
5606 if (z > -1 && dialrtr < 0) {
5607 printf("?Sorry, negative dial retries not valid: %d\n",dialrtr);
5613 y = cmnum("Seconds to wait between redial attempts",
5614 "30",10,&x,xxstring);
5615 z = setnum(&dialint,x,y,-1);
5616 if (z > -1 && dialint < 0) {
5617 printf("?Sorry, negative dial interval not valid: %d\n",dialint);
5622 case XYDLAC: /* DIAL AREA-CODE */
5623 if ((x = dialstr(&diallac,"Area code you are calling from")) < 0)
5626 if (!rdigits(diallac)) {
5627 printf("?Sorry, area code must be numeric\n");
5628 if (*diallac == '(')
5629 printf("(please omit the parentheses)\n");
5630 if (*diallac == '/')
5631 printf("(no slashes, please)\n");
5632 if (diallac) free(diallac);
5639 case XYDCNF: /* CONFIRMATION */
5640 return(success = seton(&dialcnf));
5642 case XYDCVT: /* CONVERT-DIRECTORY */
5643 if ((y = cmkey(dcnvtab,3,"","ask",xxstring)) < 0)
5645 if ((x = cmcfm()) < 0)
5648 return(success = 1);
5650 case XYDLCC: /* DIAL COUNTRY-CODE */
5651 x = dialstr(&diallcc,"Country code you are calling from");
5652 if (x < 1) return(x);
5654 if (!rdigits(diallcc)) {
5655 printf("?Sorry, country code must be numeric\n");
5656 if (*diallcc == '+')
5657 printf("(please omit the plus sign)\n");
5658 if (diallcc) free(diallcc);
5662 if (!strcmp(diallcc,"1")) { /* Set defaults for USA and Canada */
5663 if (!dialldp) /* Long-distance prefix */
5664 makestr(&dialldp,"1");
5665 if (!dialixp) /* International dialing prefix */
5666 makestr(&dialixp,"011");
5667 if (ntollfree == 0) { /* Toll-free area codes */
5668 if ((dialtfc[0] = malloc(4))) {
5669 strcpy(dialtfc[0],"800"); /* 1970-something */
5671 if ((dialtfc[1] = malloc(4))) {
5672 strcpy(dialtfc[1],"888"); /* 1996 */
5674 if ((dialtfc[2] = malloc(4))) {
5675 strcpy(dialtfc[2],"877"); /* 5 April 1998 */
5677 if ((dialtfc[3] = malloc(4))) {
5678 strcpy(dialtfc[3],"866"); /* 2000? */
5685 if (!dialtfp) /* Toll-free dialing prefix */
5686 makestr(&dialtfp,"1");
5688 /* The time for this is past */
5689 } else if (!strcmp(diallcc,"358") &&
5690 ((int) strcmp(zzndate(),"19961011") > 0)
5692 if (!dialldp) /* Long-distance prefix */
5693 makestr(&dialldp,"9");
5694 if (!dialixp) /* International dialing prefix */
5695 makestr(&dialixp,"990");
5696 #endif /* COMMENT */
5697 } else { /* Everywhere else ... */
5699 if ((dialldp = malloc(4)))
5700 strcpy(dialldp,"0");
5703 if ((dialixp = malloc(4)))
5704 strcpy(dialixp,"00");
5707 if (!strcmp(diallcc,"33")) /* France */
5708 dialfld = 1; /* Long-distance dialing is forced */
5710 return(success = 1);
5712 case XYDIXP: /* DIAL INTL-PREFIX */
5713 return(dialstr(&dialixp,"International dialing prefix"));
5715 case XYDIXS: /* DIAL INTL-SUFFIX */
5716 return(dialstr(&dialixs,"International dialing suffix"));
5718 case XYDLDP: /* DIAL LD-PREFIX */
5719 return(dialstr(&dialldp,"Long-distance dialing prefix"));
5721 case XYDLDS: /* DIAL LD-SUFFIX */
5722 return(dialstr(&diallds,"Long-distance dialing suffix"));
5724 case XYDLCP: /* DIAL LC-PREFIX */
5725 return(dialstr(&diallcp,"Local dialing prefix"));
5727 case XYDLCS: /* DIAL LC-SUFFIX */
5728 return(dialstr(&diallcs,"Local dialing suffix"));
5731 case XYDPXX: /* DIAL PBX-EXCHANGE */
5732 return(dialstr(&dialpxx,"Exchange of PBX you are calling from"));
5733 #endif /* COMMENT */
5735 case XYDPXI: { /* DIAL PBX-INTERNAL-PREFIX */
5737 return(dialstr(&dialpxi,
5738 "Internal-call prefix of PBX you are calling from"));
5741 if ((x = cmtxt("Internal-call prefix of PBX you are calling from",
5742 "",&s,NULL)) < 0) /* Don't evaluate */
5746 char c, * p = tmpbuf;
5749 if (isupper(c)) c = tolower(c);
5751 ckstrcmp(s,"\\v(d$px)",8,0) &&
5752 ckstrcmp(s,"\\v(d$pxx)",9,0) &&
5753 ckstrcmp(s,"\\v(d$p)",7,0)) {
5761 makestr(&dialpxi,s);
5764 #endif /* COMMENT */
5766 case XYDPXO: /* DIAL PBX-OUTSIDE-PREFIX */
5767 return(dialstr(&dialpxo,
5768 "Outside-line prefix of PBX you are calling from"));
5770 case XYDSFX: /* DIAL INTL-SUFFIX */
5771 return(dialstr(&dialsfx," Telephone number suffix for dialing"));
5773 case XYDSRT: /* DIAL SORT */
5774 return(success = seton(&dialsrt));
5776 case XYDPXX: /* DIAL PBX-EXCHANGE */
5777 case XYDTFC: { /* DIAL TOLL-FREE-AREA-CODE */
5778 int n, i; /* (zero or more of them...) */
5779 char * p[MAXTOLLFREE]; /* Temporary pointers */
5781 for (n = 0; n < MAXTOLLFREE; n++) {
5784 "Toll-free area code(s) in the country you are calling from"
5785 : "Exchange(s) of PBX you are calling from";
5788 "Another toll-free area code"
5789 : "Another PBX exchange";
5791 if ((x = cmfld(m,"",&s,xxstring)) < 0)
5795 k = (int) strlen(s);
5797 if ((p[n] = malloc(k + 1)))
5798 strcpy(p[n], s); /* safe */
5802 if (x == -3) { /* Command was successful */
5804 m = (y == XYDTFC) ? ntollfree : ndialpxx;
5805 if ((x = cmcfm()) < 0)
5808 for (i = 0; i < m; i++) { /* Remove old list, if any */
5810 makestr(&(dialtfc[i]),NULL);
5812 makestr(&(dialpxx[i]),NULL);
5815 ntollfree = n; /* New count */
5818 for (i = 0; i < n; i++) { /* New list */
5820 makestr(&(dialtfc[i]),p[i]);
5822 makestr(&(dialpxx[i]),p[i]);
5826 for (i = 0; i < n; i++)
5827 if (p[i]) free(p[i]);
5831 case XYDTFP: /* TOLL-FREE-PREFIX */
5832 return(dialstr(&dialtfp,
5833 " Long-distance prefix for toll-free dialing"));
5835 case XYDCON: /* CONNECT */
5837 if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);
5838 if (y != CAR_OFF) /* AUTO or ON? */
5839 if ((z = cmkey(qvtab,nqvt,"","verbose",xxstring)) < 0) return(z);
5840 if ((x = cmcfm()) < 0) return(x);
5844 return(success = 1);
5846 case XYDRSTR: /* RESTRICT */
5847 if ((y = cmkey(drstrtab,4,"","none",xxstring)) < 0) return(y);
5848 if ((x = cmcfm()) < 0) return(x);
5850 return(success = 1);
5852 case XYDLLAC: { /* Local area-code list */
5853 int n, i; /* (zero or more of them...) */
5854 char * p[MAXLOCALAC]; /* Temporary pointers */
5855 for (n = 0; n < MAXLOCALAC; n++) {
5857 "Area code to which calls from your area are local",
5858 "",&s,xxstring)) < 0)
5862 k = (int) strlen(s);
5864 if ((p[n] = malloc(k + 1)))
5865 strcpy(p[n], s); /* safe */
5869 if (x == -3) { /* Command was successful */
5870 if ((x = cmcfm()) < 0)
5872 for (i = 0; i < nlocalac; i++) /* Remove old list, if any */
5877 nlocalac = n; /* New count */
5878 for (i = 0; i < nlocalac; i++) /* New list */
5880 return(success = 1);
5881 } else { /* Parse error, undo everything */
5882 for (i = 0; i < n; i++)
5883 if (p[i]) free(p[i]);
5889 return(success = seton(&dialfld));
5891 case XYDIDT: /* DIAL IGNORE-DIALTONE */
5892 return(seton(&dialidt));
5896 "Milliseconds to pause between each character sent to dialer",
5898 return(setnum(&dialpace,x,y,9999));
5902 if ((x = cmfld("Name of macro to execute just prior to dialing",
5903 "",&s,xxstring)) < 0) {
5913 ckstrncpy(line,s,LINBUFSIZ);
5917 if ((x = cmcfm()) < 0)
5919 makestr(&dialmac,s);
5920 return(success = 1);
5923 case XYDPUCC: /* Pulse country codes */
5924 case XYDTOCC: { /* Tone country codes */
5928 for (n = 0; n < MAXTPCC; n++) {
5930 m = (y == XYDPUCC) ?
5931 "Country code where Pulse dialing is required"
5932 : "Country code where Tone dialing is available";
5934 m = "Another country code";
5935 if ((x = cmfld(m,"",&s,xxstring)) < 0)
5939 k = (int) strlen(s);
5941 if ((p[n] = malloc(k + 1)))
5942 strcpy(p[n], s); /* safe */
5946 if (x == -3) { /* Command was successful */
5948 m = (y == XYDPUCC) ? ndialpucc : ndialtocc;
5949 if ((x = cmcfm()) < 0)
5952 for (i = 0; i < m; i++) { /* Remove old list, if any */
5954 makestr(&(dialpucc[i]),NULL);
5956 makestr(&(dialtocc[i]),NULL);
5959 ndialpucc = n; /* New count */
5963 for (i = 0; i < n; i++) { /* New list */
5965 makestr(&(dialpucc[i]),p[i]);
5967 makestr(&(dialtocc[i]),p[i]);
5972 for (i = 0; i < n; i++)
5973 if (p[i]) free(p[i]);
5977 return(seton(&dialtest));
5980 printf("?Unexpected SET DIAL parameter\n");
5986 int /* SHOW MODEM */
5995 printf("Sorry, command disabled\r\n");
5996 return(success = 0);
6003 mdm = (mdmtyp > 0) ? mdmtyp : mdmsav;
6004 p = (mdm > 0) ? modemp[mdm] : NULL;
6007 printf(" %s\n\n", dialname ? dialname : p->name);
6009 printf(" Modem capabilities: ");
6010 zz = dialcapas ? dialcapas : p->capas;
6014 if (zz & CKD_AT) printf(" AT");
6015 if (zz & CKD_V25) printf(" ITU");
6016 if (zz & CKD_SB) printf(" SB");
6017 if (zz & CKD_EC) printf(" EC");
6018 if (zz & CKD_DC) printf(" DC");
6019 if (zz & CKD_HW) printf(" HWFC");
6020 if (zz & CKD_SW) printf(" SWFC");
6021 if (zz & CKD_KS) printf(" KS");
6022 if (zz & CKD_TB) printf(" TB");
6024 printf("\n Modem carrier-watch: ");
6025 if (carrier == CAR_OFF) printf("off\n");
6026 else if (carrier == CAR_ON) printf("on\n");
6027 else if (carrier == CAR_AUT) printf("auto\n");
6028 else printf("unknown\n");
6030 printf(" Modem maximum-speed: ");
6031 zz = (dialmax > 0L) ? dialmax : p->max_speed;
6033 printf("%ld bps\n", zz);
6035 printf("(unknown)\n");
6036 printf(" Modem error-correction: %s\n", dialec ? "on" : "off");
6037 printf(" Modem compression: %s\n", dialdc ? "on" : "off");
6038 printf(" Modem speed-matching: %s", mdmspd ? "on" : "off");
6039 printf(" (interface speed %s)\n", mdmspd ? "changes" : "is locked");
6040 printf(" Modem flow-control: ");
6041 if (dialfc == FLO_NONE) printf("none\n");
6042 else if (dialfc == FLO_XONX) printf("xon/xoff\n");
6043 else if (dialfc == FLO_RTSC) printf("rts/cts\n");
6044 else if (dialfc == FLO_AUTO) printf("auto\n");
6045 printf(" Modem hangup-method: %s\n",
6050 printf(" Modem speaker: %s\n", showoff(mdmspk));
6051 printf(" Modem volume: %s\n",
6052 (mdmvol == 2) ? "medium" : ((mdmvol <= 1) ? "low" : "high"));
6053 printf(" Modem kermit-spoof: %s\n", dialksp ? "on" : "off");
6054 c = (char) (x = (dialesc ? dialesc : p->esc_char));
6055 printf(" Modem escape-character: %d", x);
6057 printf(" (= \"%c\")",c);
6059 "\n\nMODEM COMMANDs (* = set automatically by SET MODEM TYPE):\n\n");
6060 debug(F110,"show dialini",dialini,0);
6061 printf(" %c Init-string: ", dialini ? ' ' : '*' );
6062 shods(dialini ? dialini : p->wake_str);
6063 printf(" %c Dial-mode-string: ", dialmstr ? ' ' : '*' );
6064 shods(dialmstr ? dialmstr : p->dmode_str);
6065 n = local ? 19 : 20;
6066 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6067 printf(" %c Dial-mode-prompt: ", dialmprmt ? ' ' : '*' );
6068 shods(dialmprmt ? dialmprmt : p->dmode_prompt);
6069 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6070 printf(" %c Dial-command: ", dialcmd ? ' ' : '*' );
6071 shods(dialcmd ? dialcmd : p->dial_str);
6072 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6073 printf(" %c Compression on: ", dialdcon ? ' ' : '*' );
6075 debug(F110,"dialdcon","(null)",0);
6077 debug(F110,"dialdcon",dialdcon,0);
6078 shods(dialdcon ? dialdcon : p->dc_on_str);
6079 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6080 printf(" %c Compression off: ", dialdcoff ? ' ' : '*' );
6081 shods(dialdcoff ? dialdcoff : p->dc_off_str);
6082 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6083 printf(" %c Error-correction on: ", dialecon ? ' ' : '*' );
6084 shods(dialecon ? dialecon : p->ec_on_str);
6085 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6086 printf(" %c Error-correction off: ", dialecoff ? ' ' : '*' );
6087 shods(dialecoff ? dialecoff : p->ec_off_str);
6088 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6089 printf(" %c Autoanswer on: ", dialaaon ? ' ' : '*' );
6090 shods(dialaaon ? dialaaon : p->aa_on_str);
6091 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6092 printf(" %c Autoanswer off: ", dialaaoff ? ' ' : '*' );
6093 shods(dialaaoff ? dialaaoff : p->aa_off_str);
6094 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6096 printf(" %c Speaker on: ", dialspon ? ' ' : '*' );
6097 shods(dialspon ? dialspon : p->sp_on_str);
6098 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6099 printf(" %c Speaker off: ", dialspoff ? ' ' : '*' );
6100 shods(dialspoff ? dialspoff : p->sp_off_str);
6101 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6102 printf(" %c Volume low: ", dialvol1 ? ' ' : '*' );
6103 shods(dialvol1 ? dialvol1 : p->vol1_str);
6104 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6105 printf(" %c Volume medium: ", dialvol2 ? ' ' : '*' );
6106 shods(dialvol2 ? dialvol2 : p->vol2_str);
6107 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6108 printf(" %c Volume high: ", dialvol3 ? ' ' : '*' );
6109 shods(dialvol3 ? dialvol3 : p->vol3_str);
6110 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6112 printf(" %c Hangup-command: ", dialhcmd ? ' ' : '*' );
6113 shods(dialhcmd ? dialhcmd : p->hup_str);
6114 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6115 printf(" %c Hardware-flow: ", dialhwfc ? ' ' : '*' );
6116 shods(dialhwfc ? dialhwfc : p->hwfc_str);
6117 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6118 printf(" %c Software-flow: ", dialswfc ? ' ' : '*' );
6119 shods(dialswfc ? dialswfc : p->swfc_str);
6120 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6121 printf(" %c No-flow-control: ", dialnofc ? ' ' : '*' );
6122 shods(dialnofc ? dialnofc : p->nofc_str);
6123 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6124 printf(" %c Pulse: ", dialpulse ? ' ' : '*');
6125 shods(dialpulse ? dialpulse : p->pulse);
6126 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6127 printf(" %c Tone: ", dialtone ? ' ' : '*');
6128 shods(dialtone ? dialtone : p->tone);
6130 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6131 printf(" %c Ignore-dialtone: ", dialx3 ? ' ' : '*');
6132 shods(dialx3 ? dialx3 : p->ignoredt);
6134 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
6135 printf(" %c Predial-init: ", dialini2 ? ' ' : '*');
6136 shods(dialini2 ? dialini2 : p->ini2);
6138 if (++n > cmd_rows - 4) if (!askmore()) return(0); else n = 0;
6139 printf("\n For more info: SHOW DIAL and SHOW COMMUNICATIONS\n");
6141 } else if (mdm > 0) {
6142 printf("Modem info for \"%s\" not filled in yet\n", gmdmtyp());
6144 " No modem selected, so DIAL and most SET MODEM commands have no effect.\n\
6145 Use SET MODEM TYPE to select a modem.\n");
6146 return(success = 1);
6152 int /* TAPI action commands */
6158 printf("\nTAPI is unavailable on this system.\n");
6161 if ((y = cmkey(tapitab,ntapitab,"MS TAPI command","",xxstring)) < 0)
6164 case XYTAPI_CFG: { /* TAPI CONFIGURE-LINE */
6165 extern struct keytab * tapilinetab;
6166 extern struct keytab * _tapilinetab;
6167 extern int ntapiline;
6168 extern int LineDeviceId;
6169 int lineID=LineDeviceId;
6171 cktapiBuildLineTable(&tapilinetab, &_tapilinetab, &ntapiline);
6172 if (tapilinetab && _tapilinetab && ntapiline > 0) {
6173 int i=0, j = 9999, k = -1;
6175 if ( LineDeviceId == -1 ) {
6176 /* Find out what the lowest numbered TAPI device is */
6177 /* and use it as the default. */
6178 for (i = 0; i < ntapiline; i++ ) {
6179 if (tapilinetab[i].kwval < j) {
6184 /* Find the LineDeviceId in the table and use that entry */
6185 for (i = 0; i < ntapiline; i++ ) {
6186 if (tapilinetab[i].kwval == LineDeviceId) {
6193 s = _tapilinetab[k].kwd;
6197 if ((y = cmkey(_tapilinetab,ntapiline,
6198 "TAPI device name",s,xxstring)) < 0)
6202 if ((x = cmcfm()) < 0) return(x);
6205 printf("Sorry, command disabled\r\n");
6206 return(success = 0);
6209 cktapiConfigureLine(lineID);
6212 case XYTAPI_DIAL: /* TAPI DIALING-PROPERTIES */
6213 if ((x = cmcfm()) < 0)
6217 printf("Sorry, command disabled\r\n");
6218 return(success = 0);
6221 cktapiDialingProp();
6224 return(success = 1);
6227 static int /* SET TAPI command options */
6233 printf("\nTAPI is unavailable on this system.\n");
6236 if ((y = cmkey(settapitab,nsettapitab,"MS TAPI option","",xxstring)) < 0)
6240 return (success = seton(&tapiusecfg));
6242 return (success = seton(&tapilights));
6244 return (success = seton(&tapipreterm));
6246 return (success = seton(&tapipostterm));
6248 y = cmnum("seconds of inactivity before auto-disconnect",
6249 "0",10,&x,xxstring);
6250 return(setnum(&tapiinactivity,x,y,65535));
6252 y = cmnum("seconds to wait for credit card tone",
6253 "8",10,&x,xxstring);
6254 return(setnum(&tapibong,x,y,90));
6256 return (success = seton(&tapimanual));
6257 case XYTAPI_CON: /* TAPI CONVERSIONS */
6258 return (success = setonaut(&tapiconv));
6259 case XYTAPI_LIN: /* TAPI LINE */
6260 x = setlin(XYTAPI_LIN,1,0);
6261 if (x > -1) didsetlin++;
6263 case XYTAPI_PASS: { /* TAPI PASSTHROUGH */
6265 printf("\n?Modem-dialing not supported\n");
6268 /* Passthrough became Modem-dialing which is an antonym */
6269 success = seton(&tapipass);
6270 tapipass = !tapipass;
6274 case XYTAPI_LOC: { /* TAPI LOCATION */
6275 extern char tapiloc[];
6276 extern int tapilocid;
6277 int i = 0, j = 9999, k = -1;
6279 cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
6280 if (!tapiloctab || !ntapiloc) {
6281 printf("\nNo TAPI Locations are configured for this system\n");
6284 if (tapilocid == -1)
6285 tapilocid = cktapiGetCurrentLocationID();
6287 /* Find the current tapiloc entry */
6288 /* and use it as the default. */
6289 for (k = 0; k < ntapiloc; k++) {
6290 if (tapiloctab[k].kwval == tapilocid)
6293 if (k >= 0 && k < ntapiloc)
6294 s = tapiloctab[k].kwd;
6298 if ((y = cmkey(tapiloctab,ntapiloc, "TAPI location",s,xxstring)) < 0)
6301 if ((x = cmcfm()) < 0)
6305 printf("Sorry, command disabled\r\n");
6306 return(success = 0);
6309 cktapiFetchLocationInfoByID( y );
6311 CopyTapiLocationInfoToKermitDialCmd();
6318 #endif /* CK_TAPI */
6319 #endif /* NOLOCAL */
6322 /* Method for evaluating \%x and \&x[] variables */
6324 static struct keytab varevaltab[] = {
6325 { "recursive", 1, 0 },
6328 static int nvarevaltab = (sizeof(varevaltab) / sizeof(struct keytab));
6335 extern int * xvarev;
6337 extern int xvarev[];
6338 #endif /* DCMDBUF */
6340 if ((x = cmkey(varevaltab,
6342 "Method for evaluating \\%x and \\&x[] variables",
6346 if ((y = cmcfm()) < 0)
6350 return(success = 1);
6353 #ifdef CK_ANSIC /* SET ALARM */
6358 setalarm(xx) long xx;
6359 #endif /* CK_ANSIC */
6362 int yyyy, mm, dd, x;
6366 #endif /* COMMENT */
6370 debug(F101,"setalarm xx","",xx);
6371 ck_alarm = 0L; /* 0 = no alarm (in case of error) */
6373 printf("%ld - illegal value, must be 0 or positive\n", xx);
6376 if (xx == 0L) { /* CLEAR ALARM */
6382 x = 8; /* Get current date */
6384 if (zzstring("\\v(ndate)",&s,&x) < 0) {
6385 printf("Internal date error, sorry.\n");
6389 x = 5; /* Get current time */
6391 if (zzstring("\\v(ntime)",&s,&x) < 0) {
6392 printf("Internal time error, sorry.\n");
6396 sprintf(buf,"%05ld",atol(alrm_time)); /* SAFE (20) */
6397 ckstrncpy(alrm_time,buf,8);
6398 debug(F110,"SET ALARM date (1)",alrm_date,0);
6399 debug(F110,"SET ALARM time (1)",alrm_time,0);
6401 if ((zz = atol(alrm_time) + xx) < 0L) {
6402 printf("Internal time conversion error, sorry.\n");
6405 if (zz >= 86400L) { /* Alarm crosses midnight */
6406 char d[10]; /* Local date buffer */
6407 int lastday; /* Last day of this month */
6409 ckstrncpy(d,alrm_date,8); /* We'll have to change the date */
6411 x = (zz / 86400L); /* How many days after today */
6413 dd = atoi((char *)(d+6)); /* Parse yyyymmdd */
6414 d[6] = NUL; /* into yyyy, mm, dd ... */
6415 mm = atoi((char *)(d+4));
6417 yyyy = atoi((char *)d);
6419 /* How many days in this month */
6421 lastday = mdays[mm];
6422 if (mm == 2 && yyyy % 4 == 0) /* Works thru 2099 AD... */
6425 if (dd + x > lastday) { /* Dumb loop */
6428 x -= (mdays[mm] - dd); /* Deduct rest of this month's days */
6430 /* There's a more elegant way to do this... */
6433 mm++; /* Next month */
6434 if (mm > 12) { /* Wrap around */
6435 mm = 1; /* Jan, next year */
6438 y = mdays[mm]; /* Days in new month */
6439 if (mm == 2 && yyyy % 4 == 0) /* Feb in leap year */
6440 y++; /* Works until 2100 AD */
6445 dd = x; /* Day of alarm month */
6448 sprintf(alrm_date,"%04d%02d%02d",yyyy,mm,dd); /* SAFE (24) */
6451 sprintf(alrm_time,"%ld",zz); /* SAFE (24) */
6452 debug(F110,"SET ALARM date (2)",alrm_date,0);
6453 debug(F110,"SET ALARM time (2)",alrm_time,0);
6457 ckstrncpy(xbuf,ckcvtdate("",1),20); /* Get current date and time */
6459 ckstrncpy(alrm_date,xbuf,10);
6461 sec = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
6462 debug(F110,"SET ALARM date (1)",alrm_date,0);
6463 debug(F101,"SET ALARM time (1)","",sec);
6464 if ((sec += xx) < 0L) {
6465 printf("Internal time conversion error, sorry.\n");
6468 if (sec >= 86400L) { /* Alarm crosses midnight */
6470 days = sec / 86400L;
6471 jd = mjd(p) + days; /* Get modified Julian date */
6472 ckstrncpy(alrm_date,mjd2date(jd),10);
6475 sprintf(alrm_time,"%05ld",sec); /* SAFE (24) */
6476 debug(F110,"SET ALARM date (2)",alrm_date,0);
6477 debug(F110,"SET ALARM time (2)",alrm_time,0);
6478 ck_alarm = 1; /* Alarm is set */
6480 #endif /* COMMENT */
6481 return(success = 1);
6487 dosetkey() { /* SET KEY */
6490 int kc; /* Key code */
6491 char *s; /* Key binding */
6493 char *p; /* Worker */
6494 #endif /* NOKVERBS */
6502 y = cmnum("numeric key code, or the word CLEAR,","",10,&kc,xxstring);
6505 debug(F111,"SET KEY",atmbuf,y);
6506 if (y == -2) { /* Not a valid number */
6507 if ((y = strlen(atmbuf)) < 0) /* Check for SET KEY CLEAR */
6509 if (ckstrcmp(atmbuf,"clear",y,0))
6511 if ((x = cmcfm()) < 0)
6513 for (y = 0; y < KMSIZE; y++) {
6514 keymap[y] = (KEY) y;
6518 keymapinit(); /* Special OS/2 initializations */
6519 initvik = 1; /* Update the VIK table */
6522 } else if (y == -3) { /* SET KEY <Return> */
6523 printf(" Press key to be defined: "); /* Prompt for a keystroke */
6527 #endif /* NOSETBUF */
6529 conbin((char)escape); /* Put terminal in binary mode */
6531 os2gks = 0; /* Turn off Kverb preprocessing */
6533 kc = congks(0); /* Get character or scan code */
6535 os2gks = 1; /* Turn on Kverb preprocessing */
6537 concb((char)escape); /* Restore terminal to cbreak mode */
6538 if (kc < 0) { /* Check for error */
6539 printf("?Error reading key\n");
6543 shokeycode(kc,-1); /* Show current definition */
6545 shokeycode(kc); /* Show current definition */
6547 flag = 1; /* Remember it's a multiline command */
6552 /* Normal SET KEY <scancode> <value> command... */
6559 if (kc < 0 || kc >= KMSIZE) {
6560 printf("?key code must be between 0 and %d\n", KMSIZE - 1);
6564 printf("Sorry, %d is the CONNECT-mode escape character\n",kc);
6571 cmsavp(psave,PROMPTL);
6572 cmsetp(" Enter new definition: ");
6580 if ((y = cmtxt("key definition,\n\
6581 or Ctrl-C to cancel this command,\n\
6582 or Enter to restore default definition",
6584 if (flag) /* Handle parse errors */
6591 p = s; /* Save this place */
6592 #endif /* NOKVERBS */
6594 If the definition included any \Kverbs, quote the backslash so the \Kverb
6595 will still be in the definition when the key is pressed. We don't do this
6596 in zzstring(), because \Kverbs are valid only in this context and nowhere
6599 We use this code active for all versions that support SET KEY, even if they
6600 don't support \Kverbs, because otherwise \K would behave differently for
6603 for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
6605 (s[x] == 'K' || s[x] == 'k')
6608 if ((x == 1 && s[x-1] == CMDQ) ||
6609 (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
6610 line[y++] = CMDQ; /* Make it \\K */
6612 if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
6613 line[y-1] = CMDQ; /* Have \{K */
6614 line[y++] = '{'; /* Make it \\{K */
6619 line[y++] = NUL; /* Terminate */
6620 s = line + y + 1; /* Point to after it */
6621 x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
6622 if ((x < (LINBUFSIZ / 2)) ||
6623 (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
6624 printf("?Key definition too long\n");
6625 if (flag) cmsetp(psave);
6628 s = line + y + 1; /* Point to result. */
6632 Special case: see if the definition starts with a \Kverb.
6633 If it does, point to it with p, otherwise set p to NULL.
6638 p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
6640 #endif /* NOKVERBS */
6642 if (macrotab[kc]) { /* Possibly free old macro from key. */
6643 free((char *)macrotab[kc]);
6644 macrotab[kc] = NULL;
6646 switch (strlen(s)) { /* Action depends on length */
6647 case 0: /* Reset to default binding */
6648 keymap[kc] = (KEY) kc;
6650 case 1: /* Single character */
6651 keymap[kc] = (CHAR) *s;
6653 default: /* Character string */
6656 y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
6657 debug(F101,"set key kverb lookup",0,y); /* exact match required */
6659 keymap[kc] = F_KVERB | y;
6663 #endif /* NOKVERBS */
6664 keymap[kc] = (KEY) kc;
6665 macrotab[kc] = (MACRO) malloc(strlen(s)+1);
6667 strcpy((char *) macrotab[kc], s); /* safe */
6670 if (flag) cmsetp(psave);
6672 initvik = 1; /* Update VIK table */
6676 #endif /* NOSETKEY */
6679 struct keytab stoptbl[] = {
6683 #endif /* STOPBITS */
6685 static struct keytab sertbl[] = {
6697 #endif /* HWPARITY */
6703 #endif /* HWPARITY */
6706 static int nsertbl = (sizeof(sertbl) / sizeof(struct keytab)) - 1;
6708 static char * sernam[] = { /* Keep this in sync with sertbl[] */
6709 "7E1", "7E2", "7M1", "7M2", "7O1", "7O2", "7S1", "7S2",
6710 "8N1", "8E1", "8E2", "8N2", "8O1", "8O2"
6713 static struct keytab optstab[] = { /* SET OPTIONS table */
6715 { "delete", XXDEL, 0}, /* DELETE */
6716 #endif /* NOFRILLS */
6717 { "directory", XXDIR, 0}, /* DIRECTORY */
6719 { "purge", XXPURGE, 0}, /* PURGE */
6720 #endif /* CKPURGE */
6721 { "type", XXTYP, 0}, /* TYPE */
6724 static int noptstab = (sizeof(optstab) / sizeof(struct keytab)) - 1;
6728 PROTOCOL SELECTION. Kermit is always available. If CK_XYZ is defined at
6729 compile time, then the others become selections also. In OS/2 and
6730 Windows, they are integrated and the various SET commands (e.g. "set file
6731 type") affect them as they would Kermit. In other OS's (UNIX, VMS, etc),
6732 they are external protocols which are run via Kermit's REDIRECT mechanism.
6733 All we do is collect and verify the filenames and pass them along to the
6736 struct keytab protos[] = {
6738 "g", PROTO_G, CM_INV,
6740 "kermit", PROTO_K, 0,
6742 "other", PROTO_O, 0,
6743 "x", PROTO_X, CM_INV|CM_ABR,
6744 "xmodem", PROTO_X, 0,
6745 "xmodem-crc", PROTO_XC, 0,
6746 "y", PROTO_Y, CM_INV|CM_ABR,
6747 "ymodem", PROTO_Y, 0,
6748 "ymodem-g", PROTO_G, 0,
6749 "zmodem", PROTO_Z, 0
6752 int nprotos = (sizeof(protos) / sizeof(struct keytab));
6754 #ifndef XYZ_INTERNAL
6756 #define EXP_HANDLER 1
6757 #define EXP_STDERR 2
6760 static struct keytab extprotab[] = {
6761 { "handler", EXP_HANDLER, 0 },
6762 { "redirect-stderr", EXP_STDERR, 0 },
6763 { "timeout", EXP_TIMO, 0 }
6765 static int nxtprotab = (sizeof(extprotab) / sizeof(struct keytab));
6767 #endif /* XYZ_INTERNAL */
6771 _PROTOTYP(static int protofield, (char *, char *, char *));
6772 _PROTOTYP(static int setproto, (void));
6775 protofield(current, help, px) char * current, * help, * px; {
6777 char *s, tmpbuf[XPCMDLEN+1];
6780 if (current) /* Put braces around default */
6781 ckmakmsg(tmpbuf,TMPBUFSIZ,"{",current,"}",NULL);
6785 if ((x = cmfld(help, (char *)tmpbuf, &s, xxstring)) < 0)
6787 if ((int)strlen(s) > XPCMDLEN) {
6788 printf("?Sorry - maximum length is %d\n", XPCMDLEN);
6791 strcpy(px,s); /* safe */
6799 setproto() { /* Select a file transfer protocol */
6800 /* char * s = NULL; */
6802 char s1[XPCMDLEN+1], s2[XPCMDLEN+1], s3[XPCMDLEN+1];
6803 char s4[XPCMDLEN+1], s5[XPCMDLEN+1], s6[XPCMDLEN+1], s7[XPCMDLEN+1];
6804 char * p1 = s1, * p2 = s2, *p3 = s3;
6805 char * p4 = s4, * p5 = s5, *p6 = s6, *p7 = s7;
6812 #endif /* CK_REDIR */
6813 #endif /* XYZ_INTERNAL */
6821 if ((y = cmkey(protos,nprotos,"","kermit",xxstring)) < 0)
6824 if (x && y != PROTO_K) {
6826 "?Sorry, REDIRECT capability required for external protocols.\n");
6829 if ((x = protofield(ptab[y].h_b_init,
6830 "Optional command to send to host prior to uploading in binary mode",
6833 protocol = y; /* Set protocol but don't change */
6834 return(1); /* anything else */
6838 if ((x = protofield(ptab[y].h_t_init,
6839 "Optional command to send to host prior to uploading in text mode",
6848 if ((x = protofield(ptab[y].h_x_init,
6849 "Optional command to send to host to start Kermit server",
6859 #ifndef XYZ_INTERNAL /* If XYZMODEM are external... */
6862 if ((x = protofield(ptab[y].p_b_scmd,
6863 "External command to SEND in BINARY mode with this protocol",
6870 if ((x = protofield(ptab[y].p_t_scmd,
6871 "External command to SEND in TEXT mode with this protocol",
6878 if ((x = protofield(ptab[y].p_b_rcmd,
6879 "External command to RECEIVE in BINARY mode with this protocol",
6886 if ((x = protofield(ptab[y].p_t_rcmd,
6887 "External command to RECEIVE in TEXT mode with this protocol",
6895 #endif /* XYZ_INTERNAL */
6897 if ((x = cmcfm()) < 0) /* Confirm the command */
6900 protoexit: /* Common exit from this routine */
6905 printf("\n?X,Y, and Zmodem are unavailable\n");
6906 return(success = 0);
6908 #endif /* XYZ_INTERNAL */
6917 initproto(y,p1,p2,p3,p4,p5,p6,p7);
6918 return(success = 1);
6922 #ifndef XYZ_INTERNAL
6924 #define DEF_EXP_TIMO 12 /* Default timeout for external protocol (seconds) */
6926 int exp_handler = 0; /* These are exported */
6927 int exp_timo = DEF_EXP_TIMO;
6928 int exp_stderr = SET_AUTO;
6931 shoextern() { /* Invoked by SHOW PROTOCOL */
6932 printf("\n External-protocol handler: %s\n",
6933 exp_handler ? (exp_handler == 1 ? "pty" : "system") : "automatic");
6935 printf(" External-protocol redirect-stderr: %s\n", showooa(exp_stderr));
6936 #endif /* COMMENT */
6937 printf(" External-protocol timeout: %d (sec)\n", exp_timo);
6940 static struct keytab setexternhandler[] = {
6941 { "automatic", 0, 0 },
6947 setextern() { /* SET EXTERNAL-PROTOCOL */
6949 if ((x = cmkey(extprotab,nxtprotab,"","",xxstring)) < 0)
6953 if ((x = cmkey(setexternhandler,3,"","automatic",xxstring)) < 0)
6955 if ((y = cmcfm()) < 0)
6962 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
6964 if ((y = cmcfm()) < 0)
6968 #endif /* COMMENT */
6971 y = cmnum("Inactivity timeout, seconds,",ckitoa(DEF_EXP_TIMO),
6973 return(setnum(&exp_timo,x,y,-1));
6975 return(success = 1);
6977 #endif /* XYZ_INTERNAL */
6983 if ((y = cmkey(desttab,ndests,"","disk",xxstring)) < 0) return(y);
6984 if ((x = cmcfm()) < 0) return(x);
6991 struct keytab dnettab[] = {
6993 "cterm", NP_CTERM, 0,
6994 #endif /* OS2ONLY */
6997 int ndnet = (sizeof(dnettab) / sizeof(struct keytab));
7000 /* S E T P R I N T E R -- SET PRINTER command */
7003 static struct keytab prntab[] = { /* SET PRINTER switches */
7004 "/bidirectional", PRN_BID, 0,
7006 "/character-set", PRN_CS, CM_ARG,
7008 "/command", PRN_PIP, CM_ARG,
7009 "/dos-device", PRN_DOS, CM_ARG,
7010 "/end-of-job-string",PRN_TRM, CM_ARG,
7011 "/file", PRN_FIL, CM_ARG,
7013 "/flow-control", PRN_FLO, CM_ARG,
7015 "/job-header-file", PRN_SEP, CM_ARG,
7017 "/length", PRN_LEN, CM_ARG,
7019 "/none", PRN_NON, 0,
7021 "/nopostscript", PRN_RAW, 0,
7022 "/nops", PRN_RAW, CM_INV,
7024 "/output-only", PRN_OUT, 0,
7026 "/parity", PRN_PAR, CM_ARG,
7028 "/pipe", PRN_PIP, CM_ARG|CM_INV,
7030 "/postscript", PRN_PS, 0,
7031 "/ps", PRN_PS, CM_INV,
7033 "/separator", PRN_SEP, CM_ARG|CM_INV,
7035 "/speed", PRN_SPD, CM_ARG,
7037 "/timeout", PRN_TMO, CM_ARG,
7038 "/terminator", PRN_TRM, CM_ARG|CM_INV,
7041 "/w", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
7042 "/wi", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
7044 "/width", PRN_WID, CM_ARG,
7047 "/windows-queue", PRN_WIN, CM_ARG,
7051 int nprnswi = (sizeof(prntab) / sizeof(struct keytab)) - 1;
7052 #endif /* PRINTSWI */
7055 setprinter(xx) int xx; {
7058 char * defname = NULL;
7065 long portspeed = 0L;
7071 int c, i, n, wild, confirmed = 0; /* Workers */
7072 int getval = 0; /* Whether to get switch value */
7073 struct stringint pv[PRN_MAX+1]; /* Temporary array for switch values */
7074 struct FDB sw, of, cm; /* FDBs for each parse function */
7077 #endif /* PRINTSWI */
7080 struct keytab * printtab = NULL, * _printtab = NULL;
7081 int nprint = 0, printdef=0;
7085 defname = "PRN"; /* default */
7098 haveque = Win32EnumPrt(&printtab,&_printtab,&nprint,&printdef);
7099 haveque = haveque && nprint;
7102 for (i = 0; i <= PRN_MAX; i++) { /* Initialize switch values */
7103 pv[i].sval = NULL; /* to null pointers */
7104 pv[i].ival = -1; /* and -1 int values */
7105 pv[i].wval = (CK_OFF_T)-1; /* and -1 wide values */
7107 if (xx == XYBDCP) { /* SET BPRINTER == /BIDIRECTIONAL */
7108 pv[PRN_BID].ival = 1;
7109 pv[PRN_OUT].ival = 0;
7112 /* Initialize defaults based upon current printer settings */
7114 defname = printername;
7115 switch (printertype) {
7116 case PRT_WIN: pv[PRN_WIN].ival = 1; break;
7117 case PRT_DOS: pv[PRN_DOS].ival = 1; break;
7118 case PRT_PIP: pv[PRN_PIP].ival = 1; break;
7119 case PRT_FIL: pv[PRN_FIL].ival = 1; break;
7120 case PRT_NON: pv[PRN_NON].ival = 1; break;
7124 /* only set the BIDI flag if we are bidi */
7126 pv[PRN_BID].ival = 1;
7128 /* serial port parameters may be set for non-bidi devices */
7129 pv[PRN_SPD].ival = pportspeed / 10L;
7130 pv[PRN_PAR].ival = pportparity;
7131 pv[PRN_FLO].ival = pportflow;
7134 pv[PRN_TMO].ival = printtimo;
7136 pv[PRN_TRM].ival = 1;
7137 makestr(&pv[PRN_TRM].sval,printterm);
7140 pv[PRN_SEP].ival = 1;
7141 makestr(&pv[PRN_SEP].sval,printsep);
7144 pv[PRN_PS].ival = 1;
7145 pv[PRN_WID].ival = ps_width;
7146 pv[PRN_LEN].ival = ps_length;
7148 pv[PRN_RAW].ival = 1;
7151 /* Set up chained parse functions... */
7153 cmfdbi(&sw, /* First FDB - command switches */
7155 "Switch", /* hlpmsg */
7157 "", /* addtl string data */
7158 nprnswi, /* addtl numeric data 1: tbl size */
7159 4, /* addtl numeric data 2: 4 = cmswi */
7160 xxstring, /* Processing function */
7161 prntab, /* Keyword table */
7162 &cm /* Pointer to next FDB */
7164 cmfdbi(&cm, /* Second fdb for confirmation */
7168 "", /* addtl string data */
7169 0, /* addtl numeric data 1 */
7170 0, /* addtl numeric data 2 */
7175 cmfdbi(&of, /* Third FDB for printer name */
7177 "Printer or file name", /* hlpmsg */
7178 defname, /* default */
7179 "", /* addtl string data */
7180 0, /* addtl numeric data 1: tbl size */
7181 0, /* addtl numeric data 2: 4 = cmswi */
7182 xxstring, /* Processing function */
7187 while (1) { /* Parse 0 or more switches */
7188 x = cmfdb(&sw); /* Parse switch or other thing */
7189 debug(F101,"setprinter cmfdb","",x);
7190 if (x < 0) /* Error */
7191 goto xsetprn; /* or reparse needed */
7192 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
7194 if (cmresult.fdbaddr != &sw) /* Advanced usage :-) */
7196 c = cmgbrk(); /* Get break character */
7197 getval = (c == ':' || c == '='); /* to see how they ended the switch */
7198 n = cmresult.nresult; /* Numeric result = switch value */
7199 debug(F101,"setprinter switch","",n);
7201 switch (n) { /* Process the switch */
7202 case PRN_PS: /* Text to Postscript */
7203 pv[PRN_PS].ival = 1;
7204 pv[PRN_BID].ival = 0;
7205 pv[PRN_OUT].ival = 1;
7206 pv[PRN_RAW].ival = 0;
7209 case PRN_RAW: /* Non-Postscript */
7210 pv[PRN_PS].ival = 0;
7211 pv[PRN_RAW].ival = 1;
7214 case PRN_BID: /* Bidirectional */
7215 pv[PRN_BID].ival = 1;
7216 pv[PRN_OUT].ival = 0;
7217 pv[PRN_PS].ival = 0;
7218 pv[PRN_RAW].ival = 1;
7221 case PRN_OUT: /* Output-only */
7222 pv[PRN_OUT].ival = 1;
7223 pv[PRN_BID].ival = 0;
7224 pv[PRN_PS].ival = 0;
7225 pv[PRN_RAW].ival = 1;
7228 case PRN_NON: /* NONE */
7231 pv[PRN_SPD].ival = 0;
7232 pv[PRN_PAR].ival = 0;
7233 pv[PRN_FLO].ival = FLO_KEEP;
7239 case PRN_DOS: /* DOS printer name */
7240 case PRN_FIL: /* Or filename */
7243 if (pv[n].sval) free(pv[n].sval);
7245 pv[PRN_NON].ival = 0; /* Zero any previous selections */
7246 pv[PRN_WIN].ival = 0;
7247 pv[PRN_DOS].ival = 0;
7248 pv[PRN_FIL].ival = 0;
7249 pv[PRN_PIP].ival = 0;
7250 pv[n].ival = 1; /* Flag this one */
7251 if (!getval) break; /* No value wanted */
7253 if (n == PRN_FIL) { /* File, check accessibility */
7255 if ((x = cmiofi("Filename","kermit.prn",&s,&wild,xxstring))< 0)
7258 printf("Can't create \"%s\"\n",s);
7261 } else goto xsetprn;
7263 printf("?A single file please\n");
7266 pv[PRN_SPD].ival = 0;
7267 pv[PRN_PAR].ival = 0;
7268 pv[PRN_FLO].ival = FLO_KEEP;
7269 } else if ((x = cmfld(n == PRN_DOS ? /* Value wanted - parse it */
7270 "DOS printer device name" : /* Help message */
7275 "PRN" : /* Default */
7281 s = brstrip(s); /* Strip enclosing braces */
7282 while (*s == SP) /* Strip leading blanks */
7284 if (n == PRN_PIP) { /* If /PIPE: */
7285 if (*s == '|') { /* strip any extraneous pipe sign */
7290 pv[PRN_SPD].ival = 0;
7291 pv[PRN_PAR].ival = 0;
7292 pv[PRN_FLO].ival = FLO_KEEP;
7294 if ((y = strlen(s)) > 0) /* Anything left? */
7295 if (pv[n].sval = (char *) malloc(y+1)) /* Yes, keep it */
7296 strcpy(pv[n].sval,s); /* safe */
7299 case PRN_WIN: /* Windows queue name */
7301 if (pv[n].sval) free(pv[n].sval);
7303 pv[PRN_NON].ival = 0;
7304 pv[PRN_DOS].ival = 0;
7305 pv[PRN_FIL].ival = 0;
7307 pv[PRN_SPD].ival = 0;
7308 pv[PRN_PAR].ival = 0;
7309 pv[PRN_FLO].ival = FLO_KEEP;
7311 if (!getval || !haveque)
7313 if ((x = cmkey(_printtab,nprint,"Print queue name",
7314 _printtab[printdef].kwd,xxstring)) < 0) {
7318 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7320 if ((y = strlen(s)) > 0)
7321 if (pv[n].sval = (char *)malloc(y+1))
7322 strcpy(pv[n].sval,s); /* safe */
7324 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7325 for (i = 0; i < nprint; i++) {
7326 if (x == printtab[i].kwval) {
7327 s = printtab[i].kwd;
7331 if ((y = strlen(s)) > 0)
7332 if (pv[n].sval = (char *)malloc(y+1))
7333 strcpy(pv[n].sval,s); /* safe */
7338 case PRN_SEP: /* /JOB-HEADER (separator) */
7339 if (pv[n].sval) free(pv[n].sval);
7343 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0)
7346 printf("?Wildcards not allowed\n");
7350 if ((y = strlen(s)) > 0)
7351 if (pv[n].sval = (char *) malloc(y+1))
7352 strcpy(pv[n].sval,s); /* safe */
7355 case PRN_TMO: /* /TIMEOUT:number */
7358 if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
7361 printf("?Sorry - 999 is the maximum\n");
7368 case PRN_TRM: /* /END-OF-JOB:string */
7369 if (pv[n].sval) free(pv[n].sval);
7373 if ((x = cmfld("String (enclose in braces if it contains spaces)",
7374 "",&s,xxstring)) < 0)
7377 if ((y = strlen(s)) > 0)
7378 if (pv[n].sval = (char *) malloc(y+1))
7379 strcpy(pv[n].sval,s); /* safe */
7385 if ((x = cmkey(flotab,nflo,
7386 "Serial printer-port flow control",
7387 "rts/cts",xxstring)) < 0)
7396 /* TN_COMPORT here too? */
7398 if ((x = cmkey(spdtab, /* Speed (no default) */
7400 "Serial printer-port interface speed",
7407 #endif /* NOLOCAL */
7412 if ((x = cmkey(partbl,npar,"Serial printer-port parity",
7413 "none",xxstring)) < 0)
7422 if ((x = cmnum("PS page length", "66",10,&y,xxstring)) < 0)
7429 if ((x = cmnum("PS page width", "80",10,&y,xxstring)) < 0)
7443 "auto-print/printscreen character-set",
7444 "cp437",xxstring)) < 0)
7451 printf("?Unexpected switch value - %d\n",cmresult.nresult);
7456 line[0] = NUL; /* Initialize printer name value */
7457 switch (cmresult.fcode) { /* How did we get here? */
7458 case _CMOFI: /* They typed a filename */
7459 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
7460 wild = cmresult.nresult; /* Wild flag */
7461 if (!typeset) { /* A printer name without a type */
7462 pv[PRN_NON].ival = 0; /* is supposed to be treated as */
7463 pv[PRN_WIN].ival = 0; /* a DOS or Pipe printer. We */
7464 pv[PRN_FIL].ival = 0; /* clear all the flags and let */
7465 pv[PRN_PIP].ival = 0; /* the code below dope out the */
7466 pv[PRN_DOS].ival = 0; /* type. */
7469 else if (pv[PRN_WIN].ival && lookup(_printtab,line,nprint,&y)) {
7470 /* invalid Window Queue name */
7471 printf("?invalid Windows Printer Queue name: \"%s\"\r\n",line);
7476 if ((x = cmcfm()) < 0) /* Confirm the command */
7479 case _CMCFM: /* They entered the command */
7480 if (pv[PRN_DOS].ival > 0)
7481 ckstrncpy(line,pv[PRN_DOS].sval ? pv[PRN_DOS].sval : "",LINBUFSIZ);
7482 else if (pv[PRN_WIN].ival > 0)
7483 ckstrncpy(line,pv[PRN_WIN].sval ? pv[PRN_WIN].sval : "",LINBUFSIZ);
7484 else if (pv[PRN_FIL].ival > 0)
7485 ckstrncpy(line,pv[PRN_FIL].sval ? pv[PRN_FIL].sval : "",LINBUFSIZ);
7486 else if (pv[PRN_PIP].ival > 0)
7487 ckstrncpy(line,pv[PRN_PIP].sval ? pv[PRN_PIP].sval : "",LINBUFSIZ);
7489 default: /* By mistake */
7490 printf("?Unexpected function code: %d\n",cmresult.fcode);
7495 #else /* No PRINTSWI */
7497 if ((x = cmofi("Printer or file name",defname,&s,xxstring)) < 0)
7500 printf("?Directory names not allowed\n");
7503 while (*s == SP || *s == HT) s++; /* Trim leading whitespace */
7504 ckstrncpy(line,s,LINBUFSIZ); /* Make a temporary safe copy */
7505 if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
7506 #endif /* PRINTSWI */
7509 if (inserver && (isguest
7512 #endif /* NOSERVER */
7514 printf("Sorry, printing disabled\r\n");
7515 return(success = 0);
7521 if (printbidi) { /* If bidi printing active */
7523 bprtstop(); /* Stop it before proceeding */
7527 if (pv[PRN_SPD].ival > 0) {
7528 portspeed = (long) pv[PRN_SPD].ival * 10L;
7529 if (portspeed == 70L) portspeed = 75L;
7531 if (pv[PRN_PAR].ival > 0)
7532 portparity = pv[PRN_PAR].ival;
7533 if (pv[PRN_FLO].ival > 0)
7534 portflow = pv[PRN_FLO].ival;
7536 #endif /* PRINTSWI */
7538 s = line; /* Printer name, if given */
7542 if (pv[PRN_PIP].ival > 0) { /* /PIPE was given? */
7545 if (*s == '|') { /* It might still have a pipe sign */
7546 s++; /* if name give later */
7547 while (*s == SP) /* so remove it and spaces */
7551 #endif /* PRINTSWI */
7552 if (*s == '|') { /* Or pipe implied by name? */
7553 s++; /* Point past pipe sign */
7554 while (*s == SP) /* Gobble whitespace */
7566 if (printpipe && pv[PRN_BID].ival > 0) {
7567 printf("?Sorry, pipes not allowed for bidirectional printer\n");
7571 #endif /* PRINTSWI */
7572 #endif /* OS2ORUNIX */
7575 if ( pv[PRN_CS].ival > 0 )
7576 prncs = pv[PRN_CS].ival;
7578 if ( pv[PRN_PS].ival > 0 ) {
7580 ps_width = pv[PRN_WID].ival <= 0 ? 80 : pv[PRN_WID].ival;
7581 ps_length = pv[PRN_LEN].ival <= 0 ? 66 : pv[PRN_LEN].ival;
7585 y = strlen(s); /* Length of name of new print file */
7588 && ((y != 3) || (ckstrcmp(s,"PRN",3,0) != 0))
7591 if (printername) { /* Had a print file before? */
7592 free(printername); /* Remove its name */
7595 printername = (char *) malloc(y + 1); /* Allocate space for it */
7597 printf("?Memory allocation failure\n");
7600 strcpy(printername,s); /* (safe) Copy new name to new space */
7601 debug(F110,"printername",printername,0);
7605 /* Set printer type from switches that were given explicitly */
7607 if (pv[PRN_NON].ival > 0) { /* No printer */
7608 printertype = PRT_NON;
7611 } else if (pv[PRN_FIL].ival > 0) { /* File */
7612 printertype = PRT_FIL;
7615 } else if (pv[PRN_PIP].ival > 0) { /* Pipe */
7616 printertype = PRT_PIP;
7619 } else if (pv[PRN_WIN].ival > 0) { /* Windows print queue */
7620 printertype = PRT_WIN;
7623 } else if (pv[PRN_DOS].ival > 0) { /* DOS device */
7624 printertype = PRT_DOS;
7627 } else if (line[0]) { /* Name given without switches */
7629 printertype = printpipe ? PRT_PIP : PRT_DOS;
7631 /* was the command SET PRINTER windows-queue ? */
7632 y = lookup(_printtab,line,nprint,&x);
7634 printertype = PRT_WIN;
7635 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7636 if (printername) { /* Had a print file before? */
7637 free(printername); /* Remove its name */
7640 pv[PRN_WIN].sval = NULL;
7641 pv[PRN_WIN].ival = 1;
7642 s = printtab[x].kwd; /* Get full new name */
7643 if ((y = strlen(s)) > 0) {
7644 makestr(&pv[PRN_WIN].sval,s);
7645 makestr(&printername,s);
7647 printf("?Memory allocation failure\n");
7650 debug(F110,"printername",printername,0);
7652 } else if ( y == -2 ) {
7653 /* Ambiguous Print Queue Name */
7654 printf("?Ambiguous printer name provided.\n");
7661 /* Port parameters may be set for non-bidi mode */
7663 pportspeed = portspeed; /* Set parameters */
7664 pportparity = portparity;
7665 pportflow = portflow;
7667 if (pv[PRN_BID].ival > 0) { /* Bidirectional */
7669 printbidi = 1; /* (just to test parsing...) */
7671 printbidi = bprtstart(); /* Start bidirectional printer */
7673 return(success = printbidi);
7675 printbidi = 0; /* Not BPRINTER, unset flag */
7678 if (pv[PRN_TMO].ival > -1) { /* Take care of timeout */
7679 printtimo = pv[PRN_TMO].ival;
7681 if (pv[PRN_TRM].ival > 0) { /* Termination string */
7686 if (pv[PRN_TRM].sval)
7687 makestr(&printterm,pv[PRN_TRM].sval);
7689 if (pv[PRN_SEP].ival > 0) { /* and separator file */
7694 if (pv[PRN_SEP].sval)
7695 makestr(&printsep,pv[PRN_SEP].sval);
7697 #endif /* PRINTSWI */
7703 #endif /* PRINTSWI */
7704 ) { /* File - check access */
7706 printf("?Access denied - %s\n",s);
7711 #endif /* UNIXOROSK */
7713 x = 1; /* Return code */
7715 xsetprn: /* Common exit */
7717 for (i = 0; i <= PRN_MAX; i++) { /* Free malloc'd memory */
7721 #endif /* PRINTSWI */
7722 success = (x > 0) ? 1 : 0;
7727 /* The SET SSH command */
7729 #define SSH_CMD 1 /* SET SSH COMMAND */
7731 #ifdef SSHBUILTIN /* Built-in SET SSH options */
7732 #define SSH_ADD 2 /* Add */
7733 #define SSH_AFW 3 /* Agent-forwarding */
7734 #define SSH_CHI 4 /* Check Host IP */
7735 #define SSH_XFW 5 /* X11-forwarding */
7736 #define SSH_DYF 6 /* Dynamic forwarding */
7737 #define SSH_GWP 7 /* Gatewa portgs */
7738 #define SSH_GSS 8 /* GSSAPI */
7739 #define SSH_KBD 9 /* KBD Interactive Devices */
7740 #define SSH_K4 10 /* Kerberos 4 */
7741 #define SSH_K5 11 /* Kerberos 5 */
7742 #define SSH_SHK 12 /* Strict Host Key Check */
7743 #define SSH_V1 13 /* SSH V1 */
7744 #define SSH_V2 14 /* SSH V2 */
7745 #define SSH_PRP 15 /* Privd port */
7746 #define SSH_CMP 16 /* Compression */
7747 #define SSH_XAL 17 /* X Auth Location */
7748 #define SSH_SHH 18 /* Quiet */
7749 #define SSH_VER 19 /* Version */
7750 #define SSH_VRB 20 /* Verbosity level */
7751 #define SSH_IDF 21 /* Identity File */
7752 #define SSH_CFG 22 /* Use OpenSSH Config */
7753 #define SSH_HBT 23 /* Heartbeat Interval */
7754 #endif /* SSHBUILTIN */
7756 static struct keytab sshtab[] = { /* SET SSH command table */
7758 { "agent-forwarding", SSH_AFW, 0 },
7759 { "check-host-ip", SSH_CHI, 0 },
7760 { "compression", SSH_CMP, 0 },
7761 { "dynamic-forwarding", SSH_DYF, 0 },
7762 { "gateway-ports", SSH_GWP, 0 },
7763 { "gssapi", SSH_GSS, 0 },
7764 { "heartbeat-interval", SSH_HBT, 0 },
7765 { "identity-file", SSH_IDF, 0 },
7767 { "kbd-interactive-devices", SSH_KBD, 0 },
7768 #endif /* COMMENT */
7769 { "k4", SSH_K4, CM_INV },
7770 { "k5", SSH_K5, CM_INV },
7771 { "kerberos4", SSH_K4, 0 },
7772 { "kerberos5", SSH_K5, 0 },
7773 { "krb4", SSH_K4, CM_INV },
7774 { "krb5", SSH_K5, CM_INV },
7775 { "privileged-port", SSH_PRP, 0 },
7776 { "quiet", SSH_SHH, 0 },
7777 { "strict-host-key-check", SSH_SHK, 0 },
7778 { "use-openssh-config", SSH_CFG, 0 },
7779 { "v1", SSH_V1, 0 },
7780 { "v2", SSH_V2, 0 },
7781 { "verbose", SSH_VRB, 0 },
7782 { "version", SSH_VER, 0 },
7783 { "x11-forwarding", SSH_XFW, 0 },
7784 { "xauth-location", SSH_XAL, 0 },
7787 { "command", SSH_CMD, 0 },
7789 #endif /* SSHBUILTIN */
7792 static int nsshtab = (sizeof(sshtab) / sizeof(struct keytab)) - 1;
7795 static struct keytab sshver[] = { /* SET SSH VERSION command table */
7798 { "automatic", 0, 0 }
7815 static struct keytab ssh2aut[] = { /* SET SSH V2 AUTH command table */
7816 { "external-keyx", SSHA_EXT, 0 },
7817 { "gssapi", SSHA_GSS, 0 },
7818 { "hostbased", SSHA_HOS, 0 },
7819 { "keyboard-interactive", SSHA_KBD, 0 },
7820 { "password", SSHA_PSW, 0 },
7821 { "publickey", SSHA_PK, 0 },
7822 { "srp-gex-sha1", SSHA_SRP, 0 },
7825 static int nssh2aut = (sizeof(ssh2aut) / sizeof(struct keytab)) - 1;
7830 static struct keytab addfwd[] = { /* SET SSH ADD command table */
7831 { "local-port-forward", SSHF_LCL, 0 },
7832 { "remote-port-forward", SSHF_RMT, 0 },
7835 static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
7850 static struct keytab sshv1tab[] = { /* SET SSH V1 command table */
7851 { "cipher", SSH1_CIF, 0 },
7852 { "global-known-hosts-file", SSH1_GNH, 0 },
7853 { "k5-reuse-k4-messages", SSH1_K54, CM_INV },
7854 { "user-known-hosts-file", SSH1_UNH, 0 },
7857 static int nsshv1tab = (sizeof(sshv1tab) / sizeof(struct keytab)) - 1;
7859 static struct keytab sshv2tab[] = { /* SET SSH V2 command table */
7860 { "authentication", SSH2_AUT, 0 },
7861 { "auto-rekey", SSH2_ARK, 0 },
7862 { "ciphers", SSH2_CIF, 0 },
7863 { "global-known-hosts-file", SSH2_GNH, 0 },
7864 { "hostkey-algorithms", SSH2_HKA, 0 },
7865 { "macs", SSH2_MAC, 0 },
7866 { "user-known-hosts-file", SSH2_UNH, 0 },
7869 static int nsshv2tab = (sizeof(sshv2tab) / sizeof(struct keytab)) - 1;
7871 #define SSHC_3DES 1 /* 3DES */
7872 #define SSHC_3CBC 2 /* 3DES-CBC */
7873 #define SSHC_A128 3 /* AES128-CBC */
7874 #define SSHC_A192 4 /* AES192-CBC */
7875 #define SSHC_A256 5 /* AES256-CBC */
7876 #define SSHC_ARC4 6 /* ARCFOUR */
7877 #define SSHC_FISH 7 /* BLOWFISH */
7878 #define SSHC_BCBC 9 /* BLOWFISH-CBC */
7879 #define SSHC_C128 8 /* CAST128-CBC */
7880 #define SSHC_1DES 10 /* DES */
7882 static struct keytab ssh1ciphers[] = {
7883 { "3des", SSHC_3DES, 0 },
7884 { "blowfish", SSHC_FISH, 0 },
7885 { "des", SSHC_1DES, 0 },
7888 static int nssh1ciphers = (sizeof(ssh1ciphers) / sizeof(struct keytab)) - 1;
7890 static struct keytab ssh2ciphers[] = { /* SET SSH V2 CIPHERS command table */
7891 { "3des-cbc", SSHC_3DES, 0 },
7892 { "aes128-cbc", SSHC_A128, 0 },
7893 { "aes192-cbc", SSHC_A192, 0 },
7894 { "aes256-cbc", SSHC_A256, 0 },
7895 { "arcfour", SSHC_ARC4, 0 },
7896 { "blowfish-cbc", SSHC_FISH, 0 },
7897 { "cast128-cbc", SSHC_C128, 0 },
7898 { "rijndael128-cbc", SSHC_A128, 0 },
7899 { "rijndael192-cbc", SSHC_A192, 0 },
7900 { "rijndael256-cbc", SSHC_A256, 0 },
7903 static int nssh2ciphers = (sizeof(ssh2ciphers) / sizeof(struct keytab)) - 1;
7905 #define SSHM_SHA 1 /* HMAC-SHA1 */
7906 #define SSHM_SHA_96 2 /* HMAC-SHA1-96 */
7907 #define SSHM_MD5 3 /* HMAC-MD5 */
7908 #define SSHM_MD5_96 4 /* HMAC-MD5-96 */
7909 #define SSHM_RIPE 5 /* HMAC-RIPEMD160 */
7911 static struct keytab ssh2macs[] = { /* SET SSH V2 MACS command table */
7912 { "hmac-md5", SSHM_MD5, 0 },
7913 { "hmac-md5-96", SSHM_MD5_96, 0 },
7914 { "hmac-ripemd160", SSHM_RIPE, 0 },
7915 { "hmac-sha1", SSHM_SHA, 0 },
7916 { "hmac-sha1-96", SSHM_SHA_96, 0 },
7919 static int nssh2macs = (sizeof(ssh2macs) / sizeof(struct keytab)) - 1;
7921 static struct keytab tgtpass[] = {
7922 { "tgt-passing", 1, 0, },
7925 static int ntgtpass = (sizeof(tgtpass) / sizeof(struct keytab)) - 1;
7927 static struct keytab gssapitab[] = {
7928 { "delegate-credentials", 1, 0, },
7929 { "key-exchange", 2, CM_INV, },
7932 static int ngssapitab = (sizeof(gssapitab) / sizeof(struct keytab)) - 1;
7937 static struct keytab hkatab[] = {
7938 { "ssh-dss", HKA_DSS, 0, },
7939 { "ssh-rsa", HKA_RSA, 0, },
7942 static int nhkatab = (sizeof(hkatab) / sizeof(struct keytab)) - 1;
7944 int /* SET SSH variables */
7945 ssh_afw = 0, /* agent forwarding */
7946 ssh_xfw = 0, /* x11 forwarding */
7947 ssh_prp = SET_OFF, /* privileged ports */
7948 ssh_cmp = 1, /* compression */
7949 ssh_shh = 0, /* quiet */
7950 ssh_ver = 0, /* protocol version (auto,1,2) */
7951 ssh_vrb = 2, /* Report errors */
7952 ssh_chkip = 0, /* SSH Check Host IP flag */
7953 ssh_gwp = 0, /* gateway ports */
7954 ssh_dyf = 0, /* dynamic forwarding */
7955 ssh_gsd = 0, /* gssapi delegate credentials */
7956 ssh_k4tgt = 0, /* k4 tgt passing */
7957 ssh_k5tgt = 0, /* k5 tgt passing */
7958 ssh_shk = 2, /* Strict host key (no, yes, ask) */
7959 ssh2_ark = 1, /* Auto re-key */
7960 ssh_cas = 0, /* command as subsys */
7961 ssh_cfg = 0, /* use OpenSSH config? */
7962 ssh_gkx = 1, /* gssapi key exchange */
7963 ssh_k5_is_k4 = 1, /* some SSH v1 use same codes */
7964 ssh_hbt = 0, /* heartbeat (seconds) */
7965 ssh_dummy = 0; /* bottom of list */
7967 char /* The following are to be malloc'd */
7968 * ssh1_cif = NULL, /* v1 cipher */
7969 * ssh2_cif = NULL, /* v2 cipher list */
7970 * ssh2_mac = NULL, /* v2 mac list */
7971 * ssh2_auth = NULL, /* v2 authentication list */
7972 * ssh_hst = NULL, /* hostname */
7973 * ssh_prt = NULL, /* port/service */
7974 * ssh_cmd = NULL, /* command to execute */
7975 * ssh_xal = NULL, /* xauth-location */
7976 * ssh1_gnh = NULL, /* v1 global known hosts file */
7977 * ssh1_unh = NULL, /* v1 user known hosts file */
7978 * ssh2_gnh = NULL, /* v2 global known hosts file */
7979 * ssh2_unh = NULL, /* v2 user known hosts file */
7980 * ssh2_hka = NULL, /* Host Key Algorithms */
7983 char * ssh_idf[32] = { /* Identity file list */
7984 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7985 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7986 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7987 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7989 char * ssh_tmp[32] = { /* Temp identity file list */
7990 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7991 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7992 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7993 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7997 extern int ssh_pf_lcl_n,
7999 extern struct ssh_pf ssh_pf_lcl[32]; /* Port forwarding structs */
8000 extern struct ssh_pf ssh_pf_rmt[32]; /* (declared in ckuusr.c) */
8001 #endif /* SSHBUILTIN */
8004 static struct keytab sftptab[] = {
8005 { "end-of-line", XY_SFTP_EOL, 0, },
8006 { "remote-character-set", XY_SFTP_RCS, 0, },
8009 static int nsftptab = (sizeof(sftptab) / sizeof(struct keytab)) - 1;
8010 #endif /* SFTP_BUILTIN */
8015 int i, n = 0; /* ADD askmore()! */
8017 printf("\nSSH is built in:\n\n");
8019 printf(" ssh host: %s\n",showstring(ssh_hst));
8020 printf(" ssh port: %s\n",showstring(ssh_prt));
8021 printf(" ssh command: %s\n",showstring(ssh_cmd));
8022 printf(" ssh agent-forwarding: %s\n",showoff(ssh_afw));
8023 printf(" ssh check-host-ip: %s\n",showoff(ssh_chkip));
8024 printf(" ssh compression: %s\n",showoff(ssh_cmp));
8025 printf(" ssh dynamic-forwarding: %s\n",showoff(ssh_dyf));
8026 if (ssh_pf_lcl[0].p1 && ssh_pf_lcl[0].host && ssh_pf_lcl[0].p2) {
8027 printf(" ssh forward-local-port: %d %s %d\n",
8028 ssh_pf_lcl[0].p1, ssh_pf_lcl[0].host, ssh_pf_lcl[0].p2);
8029 for ( n=1;n<ssh_pf_lcl_n;n++ )
8030 printf(" : %d %s %d\n",
8031 ssh_pf_lcl[n].p1, ssh_pf_lcl[n].host, ssh_pf_lcl[n].p2);
8033 printf(" ssh forward-local-port: (none)\n");
8034 if (ssh_pf_rmt[0].p1 && ssh_pf_rmt[0].host && ssh_pf_rmt[0].p2) {
8035 printf(" ssh forward-remote-port: %d %s %d\n",
8036 ssh_pf_rmt[0].p1, ssh_pf_rmt[0].host, ssh_pf_rmt[0].p2);
8037 for ( n=1;n<ssh_pf_rmt_n;n++ )
8038 printf(" : %d %s %d\n",
8039 ssh_pf_rmt[n].p1, ssh_pf_rmt[n].host, ssh_pf_rmt[n].p2);
8041 printf(" ssh forward-remote-port: (none)\n");
8042 printf(" ssh gateway-ports: %s\n",showoff(ssh_gwp));
8043 printf(" ssh gssapi delegate-credentials: %s\n",showoff(ssh_gsd));
8044 printf(" ssh gssapi key-exchange : %s\n",showoff(ssh_gkx));
8045 printf(" ssh identity-file: %d\n",ssh_idf_n);
8046 for (i = 0; i < ssh_idf_n; i++)
8047 printf(" %2d. %s\n",i+1,showstring(ssh_idf[i]));
8048 printf(" ssh heartbeat interval: %d\n", ssh_hbt);
8049 printf(" ssh k4 tgt-passing: %s\n",showoff(ssh_k4tgt));
8050 printf(" ssh k5 tgt-passing: %s\n",showoff(ssh_k5tgt));
8052 printf(" ssh privileged-port: %s\n",showooa(ssh_prp));
8053 printf(" ssh quiet: %s\n",showoff(ssh_shh));
8054 printf(" ssh strict-host-key-check: %d\n",ssh_shk);
8055 printf(" ssh use-openssh-config: %s\n",showoff(ssh_cfg));
8056 printf(" ssh verbose: %d\n",ssh_vrb);
8057 printf(" ssh version: %s\n",
8058 ssh_ver ? ckitoa(ssh_ver) : "automatic"
8060 printf(" ssh x11-forwarding: %s\n",showooa(ssh_xfw));
8061 printf(" ssh xauth-location: %s\n",showstring(ssh_xal));
8063 printf(" ssh v1 cipher: %s\n",showstring(ssh1_cif));
8064 printf(" ssh v1 global-known-hosts-file: %s\n",showstring(ssh1_gnh));
8065 printf(" ssh v1 user-known-hosts-file: %s\n",showstring(ssh1_unh));
8067 printf(" ssh v2 authentication: %s\n",showstring(ssh2_auth));
8068 printf(" ssh v2 auto-rekey: %s\n",showoff(ssh2_ark));
8069 printf(" ssh v2 ciphers: %s\n",showstring(ssh2_cif));
8070 printf(" ssh v2 command-as-subsystem: %s\n",showoff(ssh_cas));
8071 printf(" ssh v2 global-known-hosts-file: %s\n",showstring(ssh2_gnh));
8072 printf(" ssh v2 hostkey-algorithms: %s\n",showstring(ssh2_hka));
8073 printf(" ssh v2 mac: %s\n",showstring(ssh2_mac));
8074 printf(" ssh v2 user-known-hosts-file: %s\n",showstring(ssh2_unh));
8077 extern char * sshcmd, * defsshcmd;
8079 s = sshcmd ? sshcmd : defsshcmd;
8080 printf("\n SSH is external.\n\n");
8081 printf(" ssh command: %s\n",showstring(s));
8083 #endif /* SSHBUILTIN */
8090 extern char * sshcmd;
8094 extern int sl_ssh_xfw_saved, sl_ssh_ver_saved;
8095 #endif /* SSHTEST */
8096 #endif /* SSHBUILTIN */
8100 if ((cx = cmkey(sshtab,nsshtab,"","command", xxstring)) < 0)
8104 case SSH_CMD: /* Command */
8105 if ((x = cmtxt("Command to start ssh","ssh -e none",
8109 return(success = 1);
8113 case SSH_AFW: /* Agent-forwarding */
8114 return(success = seton(&ssh_afw));
8116 case SSH_CHI: /* Check Host IP */
8117 return(success = seton(&ssh_chkip));
8120 case SSH_CMP: /* Compression */
8121 return(success = seton(&ssh_cmp));
8123 case SSH_DYF: /* Dynamic Forwarding */
8124 return(success = seton(&ssh_dyf));
8126 case SSH_GWP: /* Gateway ports */
8127 return(success = seton(&ssh_gwp));
8129 case SSH_GSS: /* GSSAPI */
8130 if ((y = cmkey(gssapitab,ngssapitab,"","", xxstring)) < 0)
8133 case 1: /* Delegate credentials */
8134 return(success = seton(&ssh_gsd));
8135 case 2: /* key-exchange */
8136 return(success = seton(&ssh_gkx));
8138 if ((x = cmcfm()) < 0)
8140 return(success = 0);
8143 case SSH_KBD: /* Kbd Interactive Devices */
8144 if ((x = cmcfm()) < 0)
8146 /* TO BE FILLED IN */
8148 #endif /* COMMENT */
8150 case SSH_K4: /* Kerberos IV */
8151 case SSH_K5: /* Kerberos V */
8152 if ((y = cmkey(tgtpass,1,"","tgt-passing", xxstring)) < 0)
8156 return(success = (cx == SSH_K4) ?
8157 seton(&ssh_k4tgt) : seton(&ssh_k5tgt));
8159 if ((x = cmcfm()) < 0)
8161 return(success = 0);
8163 case SSH_PRP: /* Privd port */
8164 return(success = seton(&ssh_prp));
8166 case SSH_SHH: /* Quiet */
8167 return(success = seton(&ssh_shh));
8169 case SSH_SHK: /* Strict Host Key Check */
8170 if ((y = cmkey(ooktab,3,"","", xxstring)) < 0)
8172 if ((x = cmcfm()) < 0)
8175 return(success = 1);
8178 x = cmnum("Heartbeat interval, seconds","0",10,&z,xxstring);
8179 if (x < 0) return(x);
8180 if ((x = cmcfm()) < 0) return(x);
8182 return(success = 1);
8184 case SSH_V1: /* SSH V1 */
8185 if ((y = cmkey(sshv1tab,nsshv1tab,"","", xxstring)) < 0)
8189 return(success = seton(&ssh_k5_is_k4));
8190 case SSH1_CIF: /* Not a list */
8191 if ((y = cmkey(ssh1ciphers,nssh1ciphers,"","", xxstring)) < 0)
8194 if ((x = cmcfm()) < 0) return(x);
8196 makestr(&ssh1_cif,NULL);
8198 for (x = 0; x < nssh1ciphers; x++)
8199 if (ssh1ciphers[x].kwval == y)
8201 makestr(&ssh1_cif,ssh1ciphers[x].kwd);
8206 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
8210 ckstrncpy(line,s,LINBUFSIZ);
8211 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8212 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8214 s = (x == -3) ? NULL : line;
8215 if ((x = cmcfm()) < 0)
8218 case SSH1_GNH: makestr(&ssh1_gnh,s); break;
8219 case SSH1_UNH: makestr(&ssh1_unh,s); break;
8224 case SSH_V2: /* SSH V2 */
8225 if ((y = cmkey(sshv2tab,nsshv2tab,"","", xxstring)) < 0)
8229 return(success = seton(&ssh2_ark));
8230 case SSH2_AUT: { /* Authentication */
8232 int i, j, tmp[TMPCNT];
8233 for (i = 0; i < TMPCNT; i++)
8235 for (i = 0; i < TMPCNT; i++) {
8236 if ((y = cmkey(ssh2aut,nssh2aut,
8237 "Authentication method","",xxstring)) < 0) {
8242 for (j = 0; j < i; j++) {
8244 printf("\r\n?Choice has already been used.\r\n");
8250 if ((z = cmcfm()) < 0)
8259 for (j = 0; j < i; j++) {
8260 for (x = 0; x < nssh2aut; x++)
8261 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8263 len += strlen(ssh2aut[x].kwd) + 1;
8265 ssh2_auth = malloc(len);
8266 ssh2_auth[0] = '\0';
8267 for (j = 0; j < i; j++) {
8268 for (x = 0; x < nssh2aut; x++)
8269 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8271 ckstrncat(ssh2_auth,ssh2aut[x].kwd,len);
8273 ckstrncat(ssh2_auth,",",len);
8276 return(success = 1);
8281 int i, j, tmp[TMPCNT];
8282 for (i = 0; i < TMPCNT; i++)
8285 for (i = 0; i < TMPCNT; i++) {
8286 if ((y = cmkey(ssh2ciphers,nssh2ciphers,
8287 "","", xxstring)) < 0) {
8292 for (j = 0; j < i; j++) {
8294 printf("\r\n?Choice has already been used.\r\n");
8300 if ((z = cmcfm()) < 0)
8309 for (j=0; j < i; j++) {
8310 for (x = 0; x < nssh2ciphers; x++)
8311 if (ssh2ciphers[x].kwval == tmp[j] &&
8312 !ssh2ciphers[x].flgs)
8314 len += strlen(ssh2ciphers[x].kwd) + 1;
8316 ssh2_cif = malloc(len);
8318 for (j = 0; j < i; j++) {
8319 for (x = 0; x < nssh2ciphers; x++)
8320 if (ssh2ciphers[x].kwval == tmp[j] && !ssh2ciphers[x].flgs)
8322 ckstrncat(ssh2_cif,ssh2ciphers[x].kwd,len);
8324 ckstrncat(ssh2_cif,",",len);
8327 return(success = 1);
8332 int i, j, tmp[TMPCNT];
8333 for (i = 0; i < TMPCNT; i++)
8336 for (i = 0; i < TMPCNT; i++) {
8337 if ((y = cmkey(ssh2macs,nssh2macs,"","", xxstring)) < 0) {
8342 for (j = 0; j < i; j++) {
8344 printf("\r\n?Choice has already been used.\r\n");
8350 if ((z = cmcfm()) < 0)
8359 for (j = 0; j < i; j++) {
8360 for (x = 0; x < nssh2macs; x++)
8361 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8363 len += strlen(ssh2macs[x].kwd) + 1;
8365 ssh2_mac = malloc(len);
8367 for (j=0; j < i; j++) {
8368 for (x = 0; x < nssh2macs; x++)
8369 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8371 ckstrncat(ssh2_mac,ssh2macs[x].kwd,len);
8373 ckstrncat(ssh2_mac,",",len);
8376 return(success = 1);
8381 int i, j, tmp[TMPCNT];
8382 for (i = 0; i < TMPCNT; i++)
8385 for (i = 0; i < TMPCNT; i++) {
8386 if ((y = cmkey(hkatab,nhkatab,
8387 "","", xxstring)) < 0) {
8392 for (j = 0; j < i; j++) {
8394 printf("\r\n?Choice has already been used.\r\n");
8400 if ((z = cmcfm()) < 0)
8409 for (j=0; j < i; j++) {
8410 for (x = 0; x < nhkatab; x++)
8411 if (hkatab[x].kwval == tmp[j] &&
8414 len += strlen(hkatab[x].kwd) + 1;
8416 ssh2_hka = malloc(len);
8418 for (j = 0; j < i; j++) {
8419 for (x = 0; x < nhkatab; x++)
8420 if (hkatab[x].kwval == tmp[j] && !hkatab[x].flgs)
8422 ckstrncat(ssh2_hka,hkatab[x].kwd,len);
8424 ckstrncat(ssh2_hka,",",len);
8427 return(success = 1);
8432 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
8436 ckstrncpy(line,s,LINBUFSIZ);
8437 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8438 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8440 s = (x == -3) ? NULL : line;
8441 if ((x = cmcfm()) < 0)
8444 case SSH2_GNH: makestr(&ssh2_gnh,s); break;
8445 case SSH2_UNH: makestr(&ssh2_unh,s); break;
8446 default: return(success = 0);
8448 return(success = 1);
8451 case SSH_VRB: /* Verbosity level */
8452 y = cmnum("SSH verbosity level, 0-7","2",10,&x,xxstring);
8453 return(setnum(&ssh_vrb,x,y,7));
8455 case SSH_VER: /* Version */
8456 if ((y = cmkey(sshver,3,"","auto", xxstring)) < 0)
8458 if ((x = cmcfm()) < 0)
8460 ssh_ver = y; /* 0 == AUTO */
8462 sl_ssh_ver_saved = 0;
8463 #endif /* SSHTEST */
8464 return(success = 1);
8466 case SSH_IDF: { /* Identity file */
8468 for (i = 0; i < 32; i++) {
8469 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
8474 if (!zfnqfp(s,LINBUFSIZ,line))
8475 ckstrncpy(line,s,LINBUFSIZ);
8476 makestr(&ssh_tmp[i],line);
8479 if ((x = cmcfm()) < 0) {
8480 for (i = 0; i < n; i++)
8481 makestr(&(ssh_tmp[i]),NULL);
8484 for (i = 0; i < 32; i++) {
8485 makestr(&(ssh_idf[i]),NULL);
8487 ssh_idf[i] = ssh_tmp[i];
8490 makestr(&(ssh_tmp[i]),NULL);
8494 return(success = 1);
8496 case SSH_XFW: /* X11-forwarding */
8497 success = seton(&ssh_xfw);
8500 sl_ssh_xfw_saved = 0;
8501 #endif /* SSHTEST */
8504 case SSH_XAL: /* SSH Xauth Location */
8505 if ((x = cmifi("Path to executable", "",&s,&y,xxstring)) < 0) {
8509 ckstrncpy(line,s,LINBUFSIZ);
8510 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8511 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8513 s = (x == -3) ? NULL : line;
8514 if ((x = cmcfm()) < 0) return(x);
8515 makestr(&ssh_xal,s);
8516 return(success = 1);
8518 case SSH_CFG: /* Use OpenSSH Config */
8519 return(success = seton(&ssh_cfg));
8520 #endif /* SSHBUILTIN */
8534 if ((cx = cmkey(sftptab,nsftptab,"","", xxstring)) < 0)
8543 #endif /* SFTP_BUILTIN */
8547 extern ULONG RGBTable[16];
8567 static struct keytab guitab[] = {
8568 { "close", GUI_CLS, 0 },
8569 { "dialogs", GUI_DIA, 0 },
8570 { "font", GUI_FON, 0 },
8571 { "menubar", GUI_MNB, 0 },
8572 { "rgbcolor", GUI_RGB, 0 },
8573 { "toolbar", GUI_TLB, 0 },
8574 { "window", GUI_WIN, 0 },
8577 static int nguitab = (sizeof(guitab) / sizeof(struct keytab));
8579 static struct keytab guiwtab[] = {
8580 { "position", GUIW_POS, 0 },
8581 { "resize-mode", GUIW_RES, 0 },
8582 { "run-mode", GUIW_RUN, 0 },
8585 static int nguiwtab = (sizeof(guiwtab) / sizeof(struct keytab));
8587 static struct keytab guiwrtab[] = {
8588 { "change-dimensions", GUIWR_DIM, 0 },
8589 { "none", GUIWR_NON, 0 },
8590 { "scale-font", GUIWR_FON, 0 },
8593 static int nguiwrtab = (sizeof(guiwrtab) / sizeof(struct keytab));
8595 static struct keytab guiwntab[] = {
8596 { "maximize", GUIWN_MAX, 0 },
8597 { "minimize", GUIWN_MIN, 0 },
8598 { "restore", GUIWN_RES, 0 },
8601 static int nguiwntab = (sizeof(guiwntab) / sizeof(struct keytab));
8603 static struct keytab rgbtab[] = {
8608 { "darkgray", 8, 0 },
8609 { "dgray", 8, CM_INV },
8611 { "lblue", 9, CM_INV },
8612 { "lcyan", 11, CM_INV },
8613 { "lgreen", 10, CM_INV },
8614 { "lgray", 7, CM_INV },
8615 { "lightblue", 9, 0 },
8616 { "lightcyan", 11, 0 },
8617 { "lightgreen", 10, 0 },
8618 { "lightgray", 7, 0 },
8619 { "lightmagenta", 13, 0 },
8620 { "lightred", 12, 0 },
8621 { "lmagenta", 13, CM_INV },
8622 { "lred", 12, CM_INV },
8623 { "magenta", 5, 0 },
8626 { "yellow", 14, 0 },
8629 int nrgb = (sizeof(rgbtab) / sizeof(struct keytab));
8634 extern HWND getHwndKUI();
8635 unsigned char cmdsav = colorcmd;
8636 int i, red, green, blue, lines=0;
8640 printf("GUI paramters:\n");
8641 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8642 printf(" Dialogs: %s\n",showoff(gui_dialog));
8643 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8644 printf(" Position: %d,%d\n",get_gui_window_pos_x(),
8645 get_gui_window_pos_y());
8646 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8647 printf(" Resolution: %d x %d\n",GetSystemMetrics(SM_CXSCREEN),
8648 GetSystemMetrics(SM_CYSCREEN));
8649 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8650 printf(" Run-mode: %s\n",IsIconic(getHwndKUI()) ? "minimized" :
8651 IsZoomed(getHwndKUI()) ? "maximized" : "restored");
8652 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8653 switch ( get_gui_resize_mode() ) {
8661 s= "changes dimensions";
8664 printf(" Resize-mode: %s\n",s);
8665 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8667 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8669 printf("RGB Color Table:\n");
8670 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8671 printf(" Color Red Green Blue\n");
8672 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8673 printf(" ------------------------------------------\n");
8674 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8675 for (i = 0; i < nrgb; i++) {
8676 if (!rgbtab[i].flgs) {
8677 blue = (RGBTable[rgbtab[i].kwval] & 0x00FF0000)>>16;
8678 green = (RGBTable[rgbtab[i].kwval] & 0x0000FF00)>>8;
8679 red = (RGBTable[rgbtab[i].kwval] & 0x000000FF);
8680 printf(" %-18s %3d %3d %3d ",rgbtab[i].kwd,red,green,blue);
8681 colorcmd = rgbtab[i].kwval << 4;
8685 if (++lines > cmd_rows - 3) {
8698 int cx, red = 0, blue = 0, green = 0, z, x;
8700 if ((cx = cmkey(rgbtab,nrgb,"","",xxstring)) < 0)
8702 if ((z = cmnum("Red value, 0-255","",10,&red,xxstring)) < 0)
8704 if ((z = cmnum("Green value, 0-255","",10,&green,xxstring)) < 0)
8706 if ((z = cmnum("Blue value, 0-255","",10,&blue,xxstring)) < 0)
8708 if ((x = cmcfm()) < 0) return(x);
8709 if (cx > 15 || red > 255 || blue > 255 || green > 255)
8711 RGBTable[cx] = (unsigned)(((unsigned)blue << 16) |
8712 (unsigned)((unsigned)green << 8) |
8714 return(success = 1);
8718 Set GUI window position: XY coordinates of upper left corner,
8719 expressed as pixel numbers in the current screen resolution.
8720 (0,0) means put ourselves in the upper left corner.
8721 Can we check for out of bounds?
8727 if ((cx = cmkey(guiwtab,nguiwtab,"","",xxstring)) < 0)
8731 if ((z = cmnum("X coordinate (pixel number)","",10,&x,xxstring)) < 0)
8733 if ((z = cmnum("Y coordinate (pixel number)","",10,&y,xxstring)) < 0)
8735 if ((z = cmcfm()) < 0)
8737 if (x < 0 || y < 0) {
8738 printf("?Coordinates must be 0 or greater\n");
8742 return(success = 1);
8744 if ((x = cmkey(guiwrtab,nguiwrtab,"","",xxstring)) < 0)
8746 if ((z = cmcfm()) < 0)
8749 return(success = 1);
8751 if ((x = cmkey(guiwntab,nguiwntab,"","",xxstring)) < 0)
8753 if ((z = cmcfm()) < 0)
8755 gui_win_run_mode(x);
8756 return(success = 1);
8763 setguifont() { /* Assumes that CKFLOAT is defined! */
8765 extern struct keytab * term_font;
8766 extern struct keytab * _term_font;
8767 extern int tt_font, tt_font_size, ntermfont;
8772 BuildFontTable(&term_font, &_term_font, &ntermfont);
8773 if (!(term_font && _term_font && ntermfont > 0)) {
8774 printf("?Internal error: Failure to enumerate fonts\n");
8777 if ((x = cmkey(_term_font,ntermfont,"","",xxstring)) < 0)
8779 if ((z = cmfld("Height of font in points","12",&s,xxstring)) < 0)
8781 if (isfloat(s,0) < 1) { /* (sets floatval) */
8782 printf("?Integer or floating-point number required\n");
8785 if (floatval < 0.5) {
8786 printf("?Positive number required\n");
8789 if ((z = cmcfm()) < 0)
8791 tt_font = x; /* Font index */
8792 tt_font_size = (int)(floatval * 2); /* Font size in half points */
8793 KuiSetProperty(KUI_TERM_FONT, (long)tt_font, (long)tt_font_size);
8794 return(success = 1);
8798 setguidialog(x) int x;
8800 extern int gui_dialog;
8802 KuiSetProperty(KUI_GUI_DIALOGS, (long)x, 0L);
8806 setguimenubar(x) int x;
8808 KuiSetProperty(KUI_GUI_MENUBAR, (long)x, 0L);
8812 setguitoolbar(x) int x;
8814 KuiSetProperty(KUI_GUI_TOOLBAR, (long)x, 0L);
8818 setguiclose(x) int x;
8820 KuiSetProperty(KUI_GUI_CLOSE, (long)x, 0L);
8826 if ((cx = cmkey(guitab,nguitab,"","",xxstring)) < 0)
8835 return(setguifont());
8839 return(setguiwin());
8862 setexitwarn(x) int x;
8866 KuiSetProperty(KUI_EXIT_WARNING, (long)x, 0L);
8872 setdebses(x) int x; {
8874 if ((debses != 0) && (x == 0)) /* It was on and we turned it off? */
8875 os2debugoff(); /* Fix OS/2 coloration */
8879 KuiSetProperty(KUI_TERM_DEBUG,x,0);
8882 #endif /* NOLOCAL */
8884 /* D O P R M -- Set a parameter. */
8892 doprm(xx,rmsflg) int xx, rmsflg; {
8893 int i = 0, x = 0, y = 0, z = 0;
8895 char *s = NULL, *p = NULL;
8898 long portspeed = 0L;
8908 #endif /* NOSETKEY */
8910 if (xx == XYFLAG) { /* SET FLAG */
8912 return(success = seton(&ooflag));
8914 if (xx == XYPRTR /* SET PRINTER (or BPRINTER) */
8919 return(setprinter(xx));
8923 #ifdef ANYX25 /* SET X25 ... */
8928 case XYPAD: /* SET PAD ... */
8934 case XYEOL: /* These have all been moved to set send/receive... */
8935 case XYLEN: /* Let the user know what to do. */
8940 printf("...Use SET SEND or SET RECEIVE instead.\n");
8941 printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n");
8942 return(success = 0);
8944 case XYATTR: /* File Attribute packets */
8945 return(setat(rmsflg));
8947 case XYIFD: /* Incomplete file disposition */
8948 if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
8949 if ((x = cmcfm()) < 0) return(x);
8951 sstate = setgen('S',
8953 y == 0 ? "0" : (y == 1 ? "1" : "2"),
8956 return((int) sstate);
8959 return(success = 1);
8963 case XYMATCH: /* [ REMOTE ] SET MATCH... */
8965 if ((z = cmkey(matchtab,nmatchtab,"","",xxstring)) < 0)
8968 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
8969 if ((x = cmcfm()) < 0) return(x);
8972 return(sstate = setgen('S',"330", y == 0 ? "0" : "1", ""));
8974 return(sstate = setgen('S',"331", y == 0 ? "0" : "1", ""));
8982 return(success = seton(&matchfifo));
8984 x = seton(&matchdot);
8985 if (x < 0) return(x);
8987 return(success = x);
8993 case XYINPU: /* SET INPUT */
8998 case XYNET: { /* SET NETWORK */
9002 cmfdbi(&k1,_CMKEY,"","","",nnetkey, 0, xxstring, netkey, &k2);
9003 cmfdbi(&k2,_CMKEY,"","","",nnets, 0, xxstring, netcmd, NULL);
9005 #ifdef OS2 /* Hide network-type keywords for networks not installed */
9006 for (z = 0; z < nnets; z++) {
9007 if (netcmd[z].kwval == NET_TCPB && tcp_avail == 0)
9008 netcmd[z].flgs = CM_INV;
9010 if (netcmd[z].kwval == NET_SSH &&
9011 !ck_ssleay_is_installed())
9012 netcmd[z].flgs = CM_INV;
9013 #endif /* SSHBUILTIN */
9015 else if (netcmd[z].kwval == NET_DEC && dnet_avail == 0)
9016 netcmd[z].flgs = CM_INV;
9019 else if (netcmd[z].kwval == NET_BIOS && netbiosAvail == 0)
9020 netcmd[z].flgs = CM_INV;
9021 #endif /* CK_NETBIOS */
9023 else if (netcmd[z].kwval == NET_SLAT && slat_avail == 0)
9024 netcmd[z].flgs = CM_INV;
9025 #endif /* SUPERLAT */
9027 if (tcp_avail) /* Default network type */
9028 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
9030 else if ( ck_ssleay_is_installed() )
9031 ckstrncpy(tmpbuf,"ssh",TMPBUFSIZ);
9032 #endif /* SSHBUILTIN */
9034 else if (dnet_avail)
9035 ckstrncpy(tmpbuf,"decnet",TMPBUFSIZ);
9038 else if (slat_avail)
9039 ckstrncpy(tmpbuf,"superlat",TMPBUFSIZ);
9040 #endif /* SUPERLAT */
9042 else if (netbiosAvail)
9043 ckstrncpy(tmpbuf,"netbios",TMPBUFSIZ);
9044 #endif /* CK_NETBIOS */
9045 else ckstrncpy(tmpbuf,"named-pipe",TMPBUFSIZ);
9048 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
9051 ckstrncpy(tmpbuf,"x.25",TMPBUFSIZ);
9053 ckstrncpy(tmpbuf,"",TMPBUFSIZ);
9055 #endif /* TCPSOCKET */
9059 if (x < 0) { /* Error */
9060 if (x == -2 || x == -9)
9061 printf("?No keywords match: \"%s\"\n",atmbuf);
9064 z = cmresult.nresult; /* Keyword value */
9065 if (cmresult.fdbaddr == &k1) { /* Which table? */
9072 if ((z = cmkey(netcmd,nnets,"",tmpbuf,xxstring)) < 0)
9077 if (z == NET_CMD && nopush) {
9078 printf("\n?Sorry, access to external commands is disabled\n");
9085 if (z == NET_PTY && nopush) {
9086 printf("\n?Sorry, access to external commands is disabled\n");
9093 if (z == NET_TCPB && tcp_avail == 0) {
9095 "\n?Sorry, either TCP/IP is not available on this system or\n\
9096 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
9099 } else if (z == NET_SSH && !ck_ssleay_is_installed()) {
9100 printf("\n?Sorry, SSH is not available on this system.\n") ;
9102 #endif /* SSHBUILTIN */
9104 } else if (z == NET_BIOS && netbiosAvail == 0) {
9105 printf("\n?Sorry, NETBIOS is not available on this system.\n") ;
9107 #endif /* CK_NETBIOS */
9109 } else if (z == NET_DEC && dnet_avail == 0) {
9110 printf("\n?Sorry, DECnet is not available on this system.\n") ;
9114 } else if (z == NET_SLAT && slat_avail == 0) {
9115 printf("\n?Sorry, SuperLAT is not available on this system.\n") ;
9117 #endif /* SUPERLAT */
9122 if (z == NET_PIPE || /* Named pipe -- also get pipename */
9123 z == NET_BIOS) { /* NETBIOS -- also get local name */
9126 char tmpnbnam[NETBIOS_NAME_LEN+1];
9127 #endif /* CK_NETBIOS */
9128 /* Construct default name */
9129 if (z == NET_PIPE) { /* Named pipe */
9130 defnam = "kermit"; /* Default name is always "kermit" */
9133 else { /* NetBIOS */
9134 if (NetBiosName[0] != SP) { /* If there is already a name, */
9136 int n; /* use it as the default. */
9137 ckstrncpy(tmpnbnam,NetBiosName,NETBIOS_NAME_LEN+1);
9138 /* convert trailing spaces to NULs */
9139 p = &tmpnbnam[NETBIOS_NAME_LEN-1];
9145 } else if (*myhost) /* Otherwise use this PC's host name */
9146 defnam = (char *) myhost;
9147 else /* Otherwise use "kermit" */
9150 #endif /* CK_NETBIOS */
9151 if ((y = cmtxt((z == NET_PIPE) ? "name of named-pipe" :
9152 "local NETBIOS name",
9153 defnam, &s, xxstring)) < 0)
9158 if ((y = (int) strlen(s)) < 1) {
9159 printf("?You must also specify a %s name\n",
9160 (z == NET_PIPE) ? "pipe" : "local NETBIOS" );
9164 if (z == NET_BIOS) {
9165 if (!netbiosAvail) {
9166 printf("?NETBIOS is not available on this system.\n") ;
9169 if (y - NETBIOS_NAME_LEN > 0) {
9170 printf("?NETBIOS name too long, %ld maximum\n",
9173 } else if ( !strcmp(s,tmpnbnam) ) {
9174 nettype = z; /* Returning to old connection... */
9175 return(success = 1); /* Done */
9176 } else if (strcmp(" ",NetBiosName)) {
9177 printf("?NETBIOS name already assigned to \"%s\"\n",
9183 ckstrncpy(NetBiosName,s,16);
9184 for (x = y; x < NETBIOS_NAME_LEN; x++)
9185 NetBiosName[x] = SP;
9186 NetBiosName[NETBIOS_NAME_LEN] = NUL;
9187 printf("Checking \"%s\" as a unique NetBIOS name...\n",
9189 rc = NCBAddName( NetbeuiAPI,
9190 &ncb, NetBiosAdapter, NetBiosName );
9193 "?Sorry, \"%s\" is already in use by another NetBIOS node.\n",
9195 for (x = 0; x < NETBIOS_NAME_LEN; x++)
9196 NetBiosName[x] = SP;
9201 #endif /* CK_NETBIOS */
9204 ckstrncpy(pipename,s,PIPENAML);
9207 #endif /* NPIPEORBIOS */
9210 /* Determine if we are using LAT or CTERM */
9211 if ((y = cmkey(dnettab,
9212 ndnet,"DECNET protocol","lat",xxstring)) < 0)
9214 if ((x = cmcfm()) < 0) return(x);
9220 /* Find out which DLL they are using */
9221 char dllname[256]="";
9223 if ((x = cmifi("Dynamic load library",
9224 "",&p,&y,xxstring)) < 0) {
9226 printf("?Name of DLL required\n");
9231 ckstrncpy(dllname,p,256);
9232 if ((x = cmcfm()) < 0) return(x);
9234 if (netdll_load(dllname) < 0) /* Try to load the dll */
9235 return(success = 0);
9238 return(success = 1);
9242 if ((x = cmcfm()) < 0) return(x);
9246 (nettype != NET_DEC) &&
9249 (nettype != NET_PIPE) &&
9252 (nettype != NET_BIOS) &&
9253 #endif /* CK_NETBIOS */
9255 (nettype != NET_FILE) &&
9256 #endif /* NETFILE */
9258 (nettype != NET_CMD) &&
9261 (nettype != NET_PTY) &&
9264 (nettype != NET_DLL) &&
9267 (nettype != NET_SLAT) &&
9268 #endif /* SUPERLAT */
9269 (nettype != NET_SX25) &&
9270 (nettype != NET_VX25) &&
9272 (nettype != NET_IX25) &&
9275 (nettype != NET_SSH) &&
9276 #endif /* SSHBUILTIN */
9277 (nettype != NET_TCPB)) {
9278 printf("?Network type not supported\n");
9279 return(success = 0);
9281 return(success = 1);
9290 if ((z = cmkey(tcpopt,ntcpopt,"TCP option","nodelay",xxstring)) < 0)
9295 case XYTCP_HTTP_PROXY: {
9298 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1], abuf[256];
9299 ubuf[0] = pbuf[0] = abuf[0] = 0;
9301 cmfdbi(&sw, /* First FDB - switches */
9303 "HTTP proxy server host[:port] or switch",
9305 "", /* addtl string data */
9306 nuserpass, /* addtl numeric data 1: tbl size */
9307 4, /* addtl numeric data 2: 4 = cmswi */
9308 xxstring, /* Processing function */
9309 userpass, /* Keyword table */
9310 &tx /* Pointer to next FDB */
9314 "HTTP proxy server host[:port]",
9316 "", /* addtl string data */
9317 0, /* addtl numeric data 1 */
9318 0, /* addtl numeric data 2 */
9324 if ((x = cmfdb(&sw)) < 0) {
9327 printf("?Hostname required\n");
9331 if (cmresult.fcode != _CMKEY)
9333 n = cmresult.nresult;
9338 if ((x = cmfld((n == UPW_USER) ?
9340 ((n == UPW_PASS) ? "Password" : "Agent"),
9341 "", &s, xxstring)) < 0) {
9345 ckstrncpy((n == UPW_USER) ? ubuf :
9346 ((n == UPW_PASS) ? pbuf : abuf), s,
9347 (n == UPW_AGENT) ? 256 : (LOGINLEN+1));
9350 if (cmresult.fcode != _CMTXT)
9352 s = cmresult.sresult;
9353 if (s) if (!*s) s = NULL;
9357 return(success = 0);
9358 #endif /* IKSDCONF */
9359 makestr(&tcp_http_proxy_user,ubuf[0]?ubuf:NULL);
9360 makestr(&tcp_http_proxy_pwd,pbuf[0]?pbuf:NULL);
9361 makestr(&tcp_http_proxy_agent,abuf[0]?abuf:NULL);
9362 makestr(&tcp_http_proxy,s);
9363 memset(pbuf,0,sizeof(pbuf));
9364 return(success = 1);
9368 It would have been easy to combine XYTCP_SOCKS_SVR with the previous
9369 one except for the #ifdefs...
9373 case XYTCP_SOCKS_SVR: {
9374 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1];
9375 char * p = getenv("SOCKS_SERVER");
9381 cmfdbi(&sw, /* First FDB - switches */
9383 "SOCKS server host[:port] or switch",
9385 "", /* addtl string data */
9386 nuserpass, /* addtl numeric data 1: tbl size */
9387 4, /* addtl numeric data 2: 4 = cmswi */
9388 xxstring, /* Processing function */
9389 userpass, /* Keyword table */
9390 &tx /* Pointer to next FDB */
9394 "SOCKS server host[:port]",
9396 "", /* addtl string data */
9397 0, /* addtl numeric data 1 */
9398 0, /* addtl numeric data 2 */
9404 if ((x = cmfdb(&sw)) < 0) {
9407 printf("?Hostname required\n");
9411 if (cmresult.fcode != _CMKEY)
9413 n = cmresult.nresult;
9417 if ((x = cmfld((n == UPW_USER) ? "Username" : "Password",
9418 "", &s, xxstring)) < 0) {
9422 ckstrncpy((n == UPW_USER) ? ubuf : pbuf, s, LOGINLEN+1);
9425 if (cmresult.fcode != _CMTXT)
9427 s = cmresult.sresult;
9428 if (s) if (!*s) s = NULL;
9432 return(success = 0);
9433 #endif /* IKSDCONF */
9434 makestr(&tcp_socks_user,ubuf);
9435 memset(pbuf,0,sizeof(pbuf));
9436 makestr(&tcp_socks_svr,s);
9437 return(success = 1);
9441 case XYTCP_SOCKS_NS: {
9442 char * p = getenv("SOCKS_NS");
9444 if ((y = cmtxt("hostname or IP of SOCKS Name Server",p,
9448 if (iksdcf) return(success = 0);
9449 #endif /* IKSDCONF */
9451 free(tcp_socks_ns); /* Free any previous storage */
9452 tcp_socks_ns = NULL;
9454 if (s == NULL || *s == NUL) { /* If none given */
9455 tcp_socks_ns = NULL; /* remove the override string */
9456 return(success = 1);
9457 } else if ((tcp_socks_ns = malloc(strlen(s)+1))) {
9458 strcpy(tcp_socks_ns,s);
9459 return(success = 1);
9461 return(success = 0);
9463 #endif /* CK_SOCKS_NS */
9464 #endif /* CK_SOCKS */
9467 if ((y = cmtxt("preferred IP Address for TCP connections","",
9471 if (iksdcf) return(success = 0);
9472 #endif /* IKSDCONF */
9474 free(tcp_address); /* Free any previous storage */
9477 if (s == NULL || *s == NUL) { /* If none given */
9478 tcp_address = NULL; /* remove the override string */
9479 return(success = 1);
9480 } else if ((tcp_address = malloc(strlen(s)+1))) {
9481 strcpy(tcp_address,s);
9482 return(success = 1);
9484 return(success = 0);
9486 case XYTCP_KEEPALIVE:
9487 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9488 if ((y = cmcfm()) < 0) return(y);
9490 if (iksdcf) return(success = 0);
9491 #endif /* IKSDCONF */
9493 if (network && nettype == NET_SSH && ssh_sock != -1)
9494 success = keepalive(ssh_sock,z);
9496 #endif /* SSHBUILTIN */
9497 success = keepalive(ttyfd,z);
9499 #endif /* SO_KEEPALIVE */
9501 case XYTCP_DONTROUTE:
9502 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9503 if ((y = cmcfm()) < 0) return(y);
9505 if (iksdcf) return(success = 0);
9506 #endif /* IKSDCONF */
9508 if (network && nettype == NET_SSH && ssh_sock != -1)
9509 success = dontroute(ssh_sock,z);
9511 #endif /* SSHBUILTIN */
9512 success = dontroute(ttyfd,z);
9514 #endif /* SO_DONTROUTE */
9517 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9518 if ((y = cmcfm()) < 0) return(y);
9520 if (iksdcf) return(success = 0);
9521 #endif /* IKSDCONF */
9523 if (network && nettype == NET_SSH && ssh_sock != -1)
9524 success = no_delay(ssh_sock,z);
9526 #endif /* SSHBUILTIN */
9527 success = no_delay(ttyfd,z);
9529 case XYTCP_NAGLE: /* The inverse of NODELAY */
9530 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9531 if ((y = cmcfm()) < 0) return(y);
9533 if (iksdcf) return(success = 0);
9534 #endif /* IKSDCONF */
9536 if (network && nettype == NET_SSH && ssh_sock != -1)
9537 success = no_delay(ssh_sock,z);
9539 #endif /* SSHBUILTIN */
9540 success = no_delay(ttyfd,!z);
9542 #endif /* TCP_NODELAY */
9545 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0)
9547 if (z) { /* if on, we need a timeout value */
9548 if ((x = cmnum("Linger timeout in 10th of a millisecond",
9549 "0",10,&y,xxstring)) < 0)
9553 if ((x = cmcfm()) < 0)
9556 if (iksdcf) return(success = 0);
9557 #endif /* IKSDCONF */
9559 if (network && nettype == NET_SSH && ssh_sock != -1)
9560 success = ck_linger(ssh_sock,z,y);
9562 #endif /* SSHBUILTIN */
9563 success = ck_linger(ttyfd,z,y);
9565 #endif /* SO_LINGER */
9568 x = cmnum("Send buffer size, bytes","8192",10,&z,xxstring);
9569 if (x < 0) return(x);
9570 if ((x = cmcfm()) < 0) return(x);
9572 if (iksdcf) return(success = 0);
9573 #endif /* IKSDCONF */
9575 if (network && nettype == NET_SSH && ssh_sock != -1)
9576 success = sendbuf(ssh_sock,z);
9578 #endif /* SSHBUILTIN */
9579 success = sendbuf(ttyfd,z);
9581 #endif /* SO_SNDBUF */
9584 x = cmnum("Receive buffer size, bytes","8192",10,&z,xxstring);
9585 if (x < 0) return(x);
9586 if ((x = cmcfm()) < 0) return(x);
9588 if (iksdcf) return(success = 0);
9589 #endif /* IKSDCONF */
9591 /* Note: The following is not 16-bit safe */
9595 printf("?Warning: receive buffers larger than 52248 bytes\n");
9596 printf(" may not be understood by all hosts. Performance\n");
9597 printf(" may suffer.\n");
9602 if (network && nettype == NET_SSH && ssh_sock != -1)
9603 success = recvbuf(ssh_sock,z);
9605 #endif /* SSHBUILTIN */
9606 success = recvbuf(ttyfd,z);
9608 #endif /* SO_RCVBUF */
9612 case XYTCP_UCX: { /* UCX 2.0 port swabbing bug */
9613 extern int ucx_port_bug;
9614 return(success = seton(&ucx_port_bug));
9616 #endif /* DEC_TCPIP */
9620 extern int tcp_rdns;
9621 return(success = setonaut(&tcp_rdns));
9625 case XYTCP_DNS_SRV: {
9626 extern int tcp_dns_srv;
9627 return(success = seton(&tcp_dns_srv));
9629 #endif /* CK_DNS_SRV */
9635 #endif /* TCPSOCKET */
9636 #endif /* NOTCPOPTS */
9637 #endif /* NETCONN */
9644 case XYHOST: { /* SET HOST */
9645 z = ttnproto; /* Save protocol in case of failure */
9647 if (nettype != NET_DEC)
9650 if ((y = setlin(XYHOST,1,0)) <= 0) { /* Sets success to 1 */
9651 debug(F101,"SET HOST fail mdmtyp","",mdmtyp);
9652 ttnproto = z; /* Failed, restore protocol */
9656 debug(F101,"SET HOST OK mdmtyp","",mdmtyp);
9657 debug(F101,"SET HOST reliable","",reliable);
9660 #endif /* NETCONN */
9662 case XYLINE: /* SET LINE (= SET PORT) */
9663 debug(F101,"setlin flow 1","",flow);
9665 if (x > -1) didsetlin++;
9666 debug(F101,"SET LINE setlin","",x);
9667 debug(F101,"SET LINE flow","",flow);
9668 debug(F101,"SET LINE local","",local);
9669 debug(F101,"SET LINE reliable","",reliable);
9671 #endif /* NOLOCAL */
9674 case XYKEY: /* SET KEY */
9676 #endif /* NOSETKEY */
9679 case XYLANG: /* Language */
9680 if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0)
9682 if ((x = cmcfm()) < 0) return(x);
9684 /* Look up language and get associated character sets */
9685 for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ;
9687 printf("?internal error, sorry\n");
9688 return(success = 0);
9690 language = i; /* All good, set the language, */
9691 return(success = 1);
9692 #endif /* NOCSETS */
9695 case XYBACK: /* BACKGROUND */
9696 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
9697 if ((y = cmcfm()) < 0) return(y);
9699 bgset = z; /* 0 = off (foreground) */
9700 #ifdef VMS /* 1 = on (background) */
9701 if (batch && bgset == 0) /* To enable echoing of commands */
9702 ckxech = 1; /* in VMS batch logs */
9705 if (z) { /* 1 = Background */
9711 } else { /* 0 = Foreground */
9718 #endif /* COMMENT */
9724 case XYQUIE: { /* QUIET */
9726 extern int * xquiet;
9728 extern int xquiet[];
9729 #endif /* DCMDBUF */
9731 if (x < 0) return(x);
9732 xquiet[cmdlvl] = quiet;
9733 return(success = x);
9737 case XYBUF: { /* BUFFERS */
9740 if ((y = cmnum("Send buffer size","",10,&sb,xxstring)) < 0) {
9741 if (y == -3) printf("?Buffer size required\n");
9746 printf("?Negative numbers can't be used here\n");
9747 else printf("?Integer overflow, use a smaller number please\n");
9749 } else if (sb < 80) {
9750 printf("?Too small\n");
9753 if ((y=cmnum("Receive buffer size",ckitoa(sb),10,&rb,xxstring)) < 0)
9757 printf("?Negative numbers can't be used here\n");
9758 else printf("?Integer overflow, use a smaller number please\n");
9760 } else if (rb < 80) {
9761 printf("?Too small\n");
9764 if ((y = cmcfm()) < 0) return(y);
9765 if ((y = inibufs(sb,rb)) < 0) return(y);
9766 y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */
9767 if (y != urpsiz) urpsiz = y;
9768 y = adjpkl(spsiz,wslotr,bigsbsiz);
9769 if (y != spsiz) spsiz = spmax = spsizr = y;
9770 return(success = 1);
9772 printf("?Sorry, not available\n");
9773 return(success = 0);
9774 #endif /* DYNAMIC */
9777 case XYCHKT: /* BLOCK-CHECK */
9778 if ((x = cmkey(chktab,nchkt,"","3",xxstring)) < 0) return(x);
9779 if ((y = cmcfm()) < 0) return(y);
9783 printf("?5 - Not implemented yet\n");
9784 return(success = 0);
9785 #endif /* COMMENT */
9787 bctr = x; /* Set local too even if REMOTE SET */
9794 ckstrncpy(tmpbuf,ckitoa(x),TMPBUFSIZ);
9795 sstate = setgen('S', "400", tmpbuf, "");
9796 return((int) sstate);
9798 return(success = 1);
9803 #ifndef MAC /* The Mac has no RS-232 */
9804 case XYCARR: /* CARRIER-WATCH */
9807 #endif /* NOLOCAL */
9811 switch (xx) { /* Avoid long switch statements... */
9813 int c, n; /* Workers */
9814 int getval = 0; /* Whether to get switch value */
9815 int tnserver = 0; /* Client by default */
9816 int opt = -1; /* Telnet Option */
9817 struct FDB sw, op; /* FDBs for each parse function */
9818 #ifdef CK_AUTHENTICATION
9819 extern int sl_topt_a_s_saved;
9820 extern int sl_topt_a_c_saved;
9821 extern int sl_topt_e_s_saved;
9822 extern int sl_topt_e_c_saved;
9823 #endif /* CK_AUTHENTICATION */
9825 if (inserver) /* Server by default when IKSD */
9829 /* Set up chained parse functions... */
9831 cmfdbi(&op, /* First fdb - telopts*/
9833 "/client, /server or", /* hlpmsg */
9835 "", /* addtl string data */
9836 ntnopt, /* addtl numeric data 1 */
9837 0, /* addtl numeric data 2 */
9842 cmfdbi(&sw, /* Second FDB - command switches */
9846 "", /* addtl string data */
9847 ntnoptsw, /* addtl numeric data 1: tbl size */
9848 4, /* addtl numeric data 2: 4 = cmswi */
9849 xxstring, /* Processing function */
9850 tnoptsw, /* Keyword table */
9851 NULL /* Pointer to next FDB */
9854 while (opt < 0) { /* Parse 0 or more switches */
9855 x = cmfdb(&op); /* Parse switch or other thing */
9856 debug(F101,"XYTELOP cmfdb","",x);
9857 if (x < 0) /* Error */
9858 return(x); /* or reparse needed */
9859 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
9861 c = cmgbrk(); /* Get break character */
9862 getval = (c == ':' || c == '='); /* see how switch ended */
9863 if (getval && !(cmresult.kflags & CM_ARG)) {
9864 printf("?This switch does not take arguments\n");
9867 z = cmresult.nresult; /* Numeric result = switch value */
9868 debug(F101,"XYTELOP switch","",z);
9870 switch (z) { /* Process the switch */
9884 opt = TELOPT_BINARY;
9887 opt = TELOPT_NEWENVIRON;
9890 opt = TELOPT_SNDLOC;
9893 opt = TELOPT_AUTHENTICATION;
9896 opt = TELOPT_FORWARD_X;
9899 opt = TELOPT_ENCRYPTION;
9902 opt = TELOPT_KERMIT;
9905 opt = TELOPT_START_TLS;
9908 opt = TELOPT_XDISPLOC;
9917 opt = TELOPT_PRAGMA_HEARTBEAT;
9920 opt = TELOPT_SSPI_LOGON;
9923 opt = TELOPT_PRAGMA_LOGON;
9926 opt = TELOPT_IBM_SAK;
9929 opt = TELOPT_COMPORT;
9932 opt = TELOPT_LOGOUT;
9938 printf("?Unexpected value - %d\n",z);
9942 if (cmresult.fdbaddr == &op)
9944 #endif /* COMMENT */
9947 case TELOPT_ECHO: /* Options only the Server WILL */
9948 case TELOPT_FORWARD_X:
9949 case TELOPT_SEND_URL:
9950 case TELOPT_IBM_SAK:
9952 if ((x = cmkey(tnnegtab,
9954 "desired server state",
9955 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
9959 if ((z = cmcfm()) < 0)
9962 TELOPT_DEF_S_ME_MODE(opt) = x;
9963 TELOPT_ME_MODE(opt) = x;
9965 TELOPT_DEF_C_U_MODE(opt) = x;
9966 TELOPT_U_MODE(opt) = x;
9970 case TELOPT_TTYPE: /* Options only the Client WILL */
9971 case TELOPT_NEWENVIRON:
9973 case TELOPT_AUTHENTICATION:
9974 case TELOPT_START_TLS:
9975 case TELOPT_XDISPLOC:
9978 case TELOPT_COMPORT:
9979 if ((x = cmkey(tnnegtab,
9981 "desired client state",
9982 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
9986 if ((z = cmcfm()) < 0)
9989 TELOPT_DEF_S_U_MODE(opt) = x;
9990 TELOPT_U_MODE(opt) = x;
9991 #ifdef CK_AUTHENTICATION
9992 if (opt == TELOPT_AUTHENTICATION)
9993 sl_topt_a_s_saved = 0;
9994 #endif /* CK_AUTHENTICATION */
9996 TELOPT_DEF_C_ME_MODE(opt) = x;
9997 TELOPT_ME_MODE(opt) = x;
9998 #ifdef CK_AUTHENTICATION
9999 if (opt == TELOPT_AUTHENTICATION)
10000 sl_topt_a_c_saved = 0;
10001 #endif /* CK_AUTHENTICATION */
10006 if ((x = cmkey(tnnegtab,
10009 "desired server state" :
10010 "desired client state",
10011 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
10016 if ((y = cmkey(tnnegtab,
10018 !tnserver ? "desired server state" :
10019 "desired client state",
10020 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
10025 if ((z = cmcfm()) < 0)
10028 TELOPT_DEF_S_ME_MODE(opt) = x;
10029 TELOPT_ME_MODE(opt) = x;
10030 TELOPT_DEF_S_U_MODE(opt) = y;
10031 TELOPT_U_MODE(opt) = y;
10032 #ifdef CK_ENCRYPTION
10033 if (opt == TELOPT_ENCRYPTION)
10034 sl_topt_e_s_saved = 0;
10035 #endif /* CK_ENCRYPTION */
10037 TELOPT_DEF_C_ME_MODE(opt) = x;
10038 TELOPT_ME_MODE(opt) = x;
10039 TELOPT_DEF_C_U_MODE(opt) = y;
10040 TELOPT_U_MODE(opt) = y;
10041 #ifdef CK_ENCRYPTION
10042 if (opt == TELOPT_ENCRYPTION)
10043 sl_topt_e_c_saved = 0;
10044 #endif /* CK_ENCRYPTION */
10047 return(success = 1);
10050 case XYTEL: /* TELNET */
10051 if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "",
10055 case CK_TN_EC: /* ECHO */
10056 if ((x = cmkey(rltab,nrlt,
10057 "initial TELNET echoing state",
10058 "local",xxstring)) < 0)
10060 if ((y = cmcfm()) < 0) return(y);
10062 return(success = 1);
10064 case CK_TN_RE: /* REMOTE-ECHO */
10065 return(success = seton(&tn_rem_echo));
10067 case CK_TN_DB: /* DEBUG */
10068 return(success = seton(&tn_deb));
10070 case CK_TN_TT: /* TERMINAL TYPE */
10071 if ((y = cmtxt("terminal type for TELNET connections","",
10075 free(tn_term); /* Free any previous storage */
10078 if (s == NULL || *s == NUL) { /* If none given */
10079 tn_term = NULL; /* remove the override string */
10080 return(success = 1);
10081 } else if ((tn_term = malloc(strlen(s)+1))) {
10083 return(success = 1);
10084 } else return(success = 0);
10086 #ifdef CK_FORWARD_X
10087 case CK_TN_FX: /* FORWARD-X */
10088 if ((x=cmkey(tnfwdxtab,ntnfwdx,"","xauthority-file",xxstring)) < 0)
10091 case 0: { /* Xauthority-File */
10092 x = cmifi("Full path of .Xauthority file","",&s,&y,xxstring);
10093 if (x < 0 && x != -3)
10095 makestr(&tn_fwdx_xauthority,s);
10096 return(success = 1);
10098 case 1: { /* No-Encryption */
10099 extern int fwdx_no_encrypt;
10100 return(success = seton(&fwdx_no_encrypt));
10103 return(success = 0);
10104 #endif /* CK_FORWARD_X */
10106 case CK_TN_NL: /* TELNET NEWLINE-MODE */
10107 if ((x = cmkey(tn_nlmtab,ntn_nlm,"","nvt",xxstring)) < 0)
10109 if (x == TN_NL_BIN) {
10110 if ((x = cmkey(tnlmtab,ntnlm,"","raw",xxstring)) < 0)
10112 if ((y = cmcfm()) < 0)
10115 return(success = 1);
10116 } else if (x == TN_NL_NVT) {
10117 if ((x = cmkey(tnlmtab,ntnlm,"","on",xxstring)) < 0)
10119 if ((y = cmcfm()) < 0)
10122 return(success = 1);
10124 if ((y = cmcfm()) < 0)
10127 return(success = 1);
10130 case CK_TN_XF: /* BINARY-TRANSFER-MODE */
10131 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10132 if ((y = cmcfm()) < 0) return(y);
10134 return(success = 1);
10136 case CK_TN_NE: /* NO-ENCRYPT-DURING-XFER */
10137 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10138 if ((y = cmcfm()) < 0) return(y);
10140 /* Don't let this be set remotely */
10141 if (apcactive == APC_LOCAL ||
10142 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
10143 return(success = 0);
10144 #endif /* CK_APC */
10145 tn_no_encrypt_xfer = z;
10146 return(success = 1);
10148 case CK_TN_BM: /* BINARY-MODE */
10149 if ((x = cmkey(tnnegtab,ntnnegtab,"","refused",xxstring)) < 0)
10151 if ((y = cmcfm()) < 0)
10153 TELOPT_DEF_S_ME_MODE(TELOPT_BINARY) = x;
10154 TELOPT_DEF_S_U_MODE(TELOPT_BINARY) = x;
10155 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = x;
10156 TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = x;
10157 return(success = 1);
10160 case CK_TN_IKS: /* KERMIT */
10161 if ((x = cmkey(tnnegtab,ntnnegtab,"DO","accept",xxstring)) < 0)
10163 if ((y = cmkey(tnnegtab,ntnnegtab,"WILL","accept",xxstring)) < 0)
10165 if ((z = cmcfm()) < 0)
10167 TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = y;
10168 TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = x;
10169 TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = y;
10170 TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = x;
10171 return(success = 1);
10172 #endif /* IKS_OPTION */
10175 case CK_TN_TLS: /* START_TLS */
10176 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10178 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10180 if ((z = cmcfm()) < 0)
10182 TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = x;
10183 TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = y;
10184 TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = x;
10185 TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = y;
10186 return(success = 1);
10187 #endif /* CK_SSL */
10190 case CK_TN_NAWS: /* NAWS */
10191 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10193 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10195 if ((z = cmcfm()) < 0)
10197 TELOPT_DEF_S_ME_MODE(TELOPT_NAWS) = x;
10198 TELOPT_DEF_S_U_MODE(TELOPT_NAWS) = y;
10199 TELOPT_DEF_C_ME_MODE(TELOPT_NAWS) = x;
10200 TELOPT_DEF_C_U_MODE(TELOPT_NAWS) = y;
10201 return(success = 1);
10202 #endif /* CK_NAWS */
10204 #ifdef CK_AUTHENTICATION
10205 case CK_TN_AU: /* AUTHENTICATION */
10206 if ((x = cmkey(tnauthtab,ntnauth,"","",xxstring)) < 0)
10208 if (x == TN_AU_FWD) {
10209 extern int forward_flag;
10210 return(success = seton(&forward_flag));
10211 } else if (x == TN_AU_TYP) {
10212 extern int auth_type_user[];
10213 extern int sl_auth_type_user[];
10214 extern int sl_auth_saved;
10215 int i, j, atypes[AUTHTYPLSTSZ];
10217 for (i = 0; i < AUTHTYPLSTSZ; i++) {
10218 if ((y = cmkey(autyptab,nautyp,"",
10219 i == 0 ? "automatic" : "" ,
10225 if (i > 0 && (y == AUTHTYPE_AUTO || y == AUTHTYPE_NULL)) {
10227 "\r\n?Choice may only be used in first position.\r\n");
10230 for (j = 0; j < i; j++) {
10231 if (atypes[j] == y) {
10232 printf("\r\n?Choice has already been used.\r\n");
10237 if (y == AUTHTYPE_NULL || y == AUTHTYPE_AUTO) {
10242 if (i < AUTHTYPLSTSZ)
10243 atypes[i] = AUTHTYPE_NULL;
10244 if ((z = cmcfm()) < 0)
10247 for (i = 0; i < AUTHTYPLSTSZ; i++) {
10248 auth_type_user[i] = atypes[i];
10249 sl_auth_type_user[i] = 0;
10251 } else if (x == TN_AU_HOW) {
10252 if ((y = cmkey(auhowtab,nauhow,"","any",xxstring)) < 0)
10254 if ((z = cmcfm()) < 0)
10257 } else if (x == TN_AU_ENC) {
10258 if ((y = cmkey(auenctab,nauenc,"","encrypt",xxstring)) < 0)
10260 if ((z = cmcfm()) < 0)
10264 if ((y = cmcfm()) < 0)
10266 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = x;
10267 TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = x;
10269 return(success = 1);
10270 #endif /* CK_AUTHENTICATION */
10272 #ifdef CK_ENCRYPTION
10273 case CK_TN_ENC: { /* ENCRYPTION */
10276 static struct keytab * tnetbl = NULL;
10277 static int ntnetbl = 0;
10279 if ((y = cmkey(tnenctab,ntnenc,"","",xxstring)) < 0)
10283 x = ck_get_crypt_table(&tnetbl,&ntnetbl);
10284 debug(F101,"ck_get_crypt_table x","",x);
10285 debug(F101,"ck_get_crypt_table n","",ntnetbl);
10286 if (x < 1 || !tnetbl || ntnetbl < 1) /* Didn't get it */
10289 printf("?Oops, types not loaded\n");
10292 if ((x = cmkey(tnetbl,ntnetbl,"type of encryption",
10293 "automatic",xxstring)) < 0)
10295 if ((z = cmcfm()) < 0)
10301 if ((z = cmcfm()) < 0)
10304 /* Don't let this be set remotely */
10305 if (apcactive == APC_LOCAL ||
10306 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10307 return(success = 0);
10308 #endif /* CK_APC */
10312 if ((z = cmcfm()) < 0)
10315 /* Don't let this be set remotely */
10316 if (apcactive == APC_LOCAL ||
10317 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10318 return(success = 0);
10319 #endif /* CK_APC */
10323 if ((z = cmcfm()) < 0)
10325 TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = y;
10326 TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = y;
10327 TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = y;
10328 TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = y;
10330 return(success = 1);
10332 #endif /* CK_ENCRYPTION */
10334 case CK_TN_BUG: /* BUG */
10335 if ((x = cmkey(tnbugtab,4,"",
10336 "binary-me-means-u-too",xxstring)) < 0)
10338 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
10339 if ((y = cmcfm()) < 0) return(y);
10354 tn_auth_krb5_des_bug = z;
10357 return(success = 1);
10359 #ifdef CK_ENVIRONMENT
10360 case CK_TN_XD: /* XDISPLOC */
10361 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10363 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10365 if ((z = cmcfm()) < 0)
10367 TELOPT_DEF_S_ME_MODE(TELOPT_XDISPLOC) = x;
10368 TELOPT_DEF_S_U_MODE(TELOPT_XDISPLOC) = y;
10369 TELOPT_DEF_C_ME_MODE(TELOPT_XDISPLOC) = x;
10370 TELOPT_DEF_C_U_MODE(TELOPT_XDISPLOC) = y;
10371 return(success = 1);
10374 char * msg = "value of telnet environment variable";
10375 extern int tn_env_flg;
10376 extern char tn_env_acct[], tn_env_disp[], tn_env_job[],
10377 tn_env_prnt[], tn_env_sys[];
10378 extern char * tn_loc;
10379 if ((x = cmkey(tnenvtab,ntnenv,"","",xxstring)) < 0)
10381 if (x == TN_ENV_UVAR) { /* User variables */
10385 extern char * tn_env_uservar[8][2];
10387 /* Get the user variable name */
10388 if ((x = cmfld("Name of Environment Variable","",&s,
10393 env = getenv(uvar);
10394 if (!env) env = "";
10396 if ((x = cmtxt("Value of Environment Variable",env,
10402 /* Now that we have the variable and perhaps a value */
10403 /* there are three possibilities: (1) new variable */
10404 /* and associated value; (2) variable already exists */
10405 /* but we have a new value; (3) variable already */
10406 /* exists but no new value therefore the user wants */
10407 /* to clear variable. */
10409 /* Try to find an existing variable */
10410 for (x = 0; x < 8; x++) {
10411 if (!ckstrcmp(tn_env_uservar[x][0],uvar,-1,0)) {
10413 free(tn_env_uservar[x][1]);
10414 tn_env_uservar[x][1] = uval;
10416 return(success = 1);
10418 free(tn_env_uservar[x][0]);
10419 tn_env_uservar[x][0] = NULL;
10420 free(tn_env_uservar[x][1]);
10421 tn_env_uservar[x][1] = NULL;
10423 return(success = 1);
10428 /* Couldn't find one; look for empty location to insert */
10429 for (x = 0; x < 8; x++) {
10430 if (!tn_env_uservar[x][0]) {
10431 tn_env_uservar[x][0] = uvar;
10432 tn_env_uservar[x][1] = uval;
10433 return(success = 1);
10436 printf("?Sorry, no space for variable.\n");
10437 return(success = 0);
10439 if (x == TN_ENV_OFF || x == TN_ENV_ON) {
10440 if ((y = cmcfm()) < 0) return(y);
10443 printf("?Sorry, command disabled.\r\n");
10444 return(success = 0);
10447 tn_env_flg = x == TN_ENV_OFF ? 0 : 1;
10448 return(success = 1);
10451 /* Not ON/OFF - Get the value */
10454 if ((y = cmtxt(msg, "", &s, xxstring)) < 0) {
10461 return(success = 0);
10463 if ((int)strlen(s) > 63) {
10464 printf("Sorry, too long\n");
10469 ckstrncpy(uidbuf,s,UIDBUFLEN);
10473 ckstrncpy(tn_env_acct,s,64);
10476 ckstrncpy(tn_env_disp,s,64);
10479 ckstrncpy(tn_env_job,s,64);
10482 ckstrncpy(tn_env_prnt,s,64);
10485 ckstrncpy(tn_env_sys,s,64);
10489 makestr(&tn_loc,s);
10492 printf("\n?Not yet implemented\n");
10495 return(success = 1);
10497 #endif /* CK_ENVIRONMENT */
10500 case CK_TN_LOC: { /* LOCATION */
10501 extern char * tn_loc;
10502 if ((y = cmtxt("Location string","",&s,xxstring)) < 0)
10505 makestr(&tn_loc,s);
10506 return(success = 1);
10508 #endif /* CK_SNDLOC */
10509 case CK_TN_SFU: /* Microsoft SFU compatibility */
10510 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10511 if ((y = cmcfm()) < 0) return(y);
10513 return(success = 1);
10516 case CK_TN_WAIT: /* WAIT-FOR-NEGOTIATIONS */
10517 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10518 if ((y = cmcfm()) < 0) return(y);
10525 #endif /* IKSDCONF */
10527 printf("?Sorry, command disabled.\r\n");
10528 return(success = 0);
10533 return(success = 1);
10535 case CK_TN_DL: /* DELAY SUBNEGOTIATIONS */
10536 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10537 if ((y = cmcfm()) < 0) return(y);
10544 #endif /* IKSDCONF */
10546 printf("?Sorry, command disabled.\r\n");
10547 return(success = 0);
10551 return(success = 1);
10553 case CK_TN_PUID: { /* PROMPT-FOR-USERID */
10555 if ((y = cmtxt("Prompt string","",&s,xxstring)) < 0)
10558 /* we must check to make sure there are no % fields */
10560 for (i = 0; i < len; i++) {
10562 if (s[i+1] != '%') {
10563 printf("%% fields are not used in this command.\n");
10569 makestr(&tn_pr_uid,s);
10570 return(success = 1);
10576 #endif /* TNCODE */
10580 case XYCOUN: /* SET COUNT */
10581 x = cmnum("Positive number","0",10,&z,xxstring);
10582 if (x < 0) return(x);
10583 if ((x = cmcfm()) < 0) return(x);
10585 printf("?A positive number, please\n");
10588 debug(F101,"XYCOUN: z","",z);
10589 return(success = setnum(&count[cmdlvl],z,0,10000));
10594 return(success = seton(&inpcas[cmdlvl]));
10597 case XYCMD: /* COMMAND ... */
10598 if ((y = cmkey(scmdtab,nbytt,"","",xxstring)) < 0)
10602 if ((y = cmcfm()) < 0)
10604 concb((char)escape);
10605 return(success = 1);
10608 if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x,
10611 if (x != 7 && x != 8) {
10612 printf("\n?The choices are 7 and 8\n");
10613 return(success = 0);
10615 if ((y = cmcfm()) < 0) return(y);
10616 if (x == 7) cmdmsk = 0177;
10617 else if (x == 8) cmdmsk = 0377;
10618 return(success = 1);
10621 if ((y = cmnum("maximum number of commands in recall buffer","10",
10622 10,&x,xxstring)) < 0)
10624 if ((y = cmcfm()) < 0) return(y);
10625 return(success = cmrini(x));
10626 #endif /* CK_RECALL */
10629 return(success = seton(&cm_retry));
10630 #endif /* CK_RECALL */
10631 case SCMD_MOR: /* More-prompting */
10632 success = seton(&xaskmore);
10634 saveask = xaskmore;
10637 if ((x = seton(&y)) < 0) return(x);
10638 cmdsquo(y); /* Do it the right way */
10639 cmd_quoting = y; /* Also keep a global copy */
10640 /* Set string-processing function */
10642 xxstring = y ? zzstring : (xx_strp) NULL;
10645 xxstring = y ? zzstring : (xx_strp) NULL;
10647 xxstring = y ? zzstring : (xx_strp) NULL;
10648 #endif /* CK_ANSIC */
10649 #endif /* datageneral */
10650 return(success = 1);
10654 case SCMD_COL: { /* Command-screen colors */
10656 fg = cmkey(ttyclrtab, nclrs,
10657 "foreground color and then background color",
10662 if ((bg = cmkey(ttyclrtab,nclrs,
10663 "background color","black",xxstring)) < 0)
10665 if ((y = cmcfm()) < 0)
10667 colorcmd = fg | bg << 4;
10668 return(success = 1);
10670 case SCMD_SCR: /* Command Scrollback size */
10671 if ((y = cmnum("COMMAND scrollback buffer size, lines","512",10,&x,
10674 /* The max number of lines is the RAM */
10675 /* we can actually dedicate to a */
10676 /* scrollback buffer given the maximum */
10677 /* process memory space of 512MB */
10678 if (x < 256 || x > 2000000L) {
10679 printf("\n?The size must be between 256 and 2,000,000.\n");
10680 return(success = 0);
10682 if ((y = cmcfm()) < 0) return(y);
10683 tt_scrsize[VCMD] = x;
10685 return(success = 1);
10688 if ((y = cmnum("Number of columns in display window",
10689 "80",10,&x,xxstring)) < 0)
10691 if ((y = cmcfm()) < 0) return(y);
10693 os2_setcmdwidth(x);
10694 return(success = 1);
10697 if ((y = cmnum("Number of rows in display window",
10698 "24",10,&x,xxstring)) < 0)
10700 if ((y = cmcfm()) < 0) return(y);
10701 os2_setcmdheight(x);
10702 return(success = 1);
10705 extern int marginbot;
10706 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
10707 if ((x = cmcfm()) < 0) return(x);
10708 if (y != tt_status[VCMD]) {
10709 /* Might need to fixup the margins */
10710 tt_status[VCMD] = y;
10712 tt_szchng[VCMD] = 2;
10715 VscrnInit(VCMD); /* Height set here */
10718 tt_szchng[VCMD] = 1;
10721 VscrnInit(VCMD); /* Height set here */
10724 return(success = 1);
10731 ppos = VscrnGetCurPos(VCMD);
10735 itoa(ppos->y+1, tmpbuf, 10);
10736 if ((y = cmnum("row (1-based)",tmpbuf,10,&row,xxstring)) < 0)
10739 itoa(ppos->x+1, tmpbuf, 10);
10740 if ((y = cmnum("col (1-based)",tmpbuf,10,&col,xxstring)) < 0)
10742 if ((x = cmcfm()) < 0) return(x);
10744 lgotoxy( VCMD, col, row ) ;
10745 VscrnIsDirty( VCMD );
10748 #endif /* NOLOCAL */
10751 y = cmnum("Command screen width, characters","80",10,&x,xxstring);
10752 return(setnum(&cmd_cols,x,y,1024));
10755 y = cmnum("Command screen height, rows","24",10,&x,xxstring);
10756 return(setnum(&cmd_rows,x,y,1024));
10760 return(seton(&cmdint));
10764 return(seton(&cmdadl));
10765 #endif /* CK_AUTODL */
10767 #ifdef DOUBLEQUOTING
10770 return(seton(&dblquo));
10772 #endif /* DOUBLEQUOTING */
10775 y = cmnum("Error message verbosity level, 0-3","1",10,&x,xxstring);
10776 return(setnum(&cmd_err,x,y,3));
10779 return(setvareval());
10788 case XYDFLT: /* SET DEFAULT = CD */
10789 return(success = docd(XXCWD));
10791 case XYDEBU: /* SET DEBUG { on, off, session } */
10792 if ((y = cmkey(dbgtab,ndbg,"","",xxstring)) < 0)
10796 return(seton(&debtim) < 0 ? x : (success = 1));
10798 /* why this change? */
10799 return(success = seton(&debtim));
10800 #endif /* COMMENT */
10803 if (inserver && isguest) {
10804 printf("?Sorry, command disabled.\r\n");
10805 return(success = 0);
10811 y = cmnum("Max length for debug log strings","",10,&x,xxstring);
10812 if ((z = setnum(&debxlen,x,y,-1)) < 0)
10814 if ((x = cmcfm()) < 0)
10816 return(success = 1);
10819 if ((x = cmcfm()) < 0)
10823 #endif /* NOLOCAL */
10825 if (deblog) doclslog(LOGD);
10827 return(success = 1);
10830 if ((x = cmcfm()) < 0)
10833 deblog = debopn("debug.log", 0);
10834 return(success = deblog ? 1 : 0);
10836 printf("?Sorry, debug log feature not enabled\n");
10837 return(success = 0);
10840 if ((x = cmcfm()) < 0)
10844 #endif /* NOLOCAL */
10845 return(success = 1);
10847 case DEB_MSG: /* Debug messages 2010/03/12 */
10848 if ((y = cmkey(ooetab,nooetab,"","on",xxstring)) < 0) return(y);
10849 if ((x = cmcfm()) < 0) return(x);
10856 case XYDELA: /* SET DELAY */
10857 y = cmnum("Number of seconds before starting to send",
10858 "5",10,&x,xxstring);
10860 return(success = setnum(&ckdelay,x,y,999));
10861 #endif /* NOXFER */
10871 #endif /* CK_TAPI */
10873 case XYDIAL: /* SET MODEM or SET DIAL */
10874 return(setdial(-1));
10876 return(setmodem());
10878 /* not implemented yet */
10879 case XYANSWER: /* SET ANSWER */
10880 return(setanswer());
10881 #endif /* COMMENT */
10882 #endif /* NODIAL */
10885 case XYDUPL: /* SET DUPLEX */
10886 if ((y = cmkey(dpxtab,2,"","full",xxstring)) < 0) return(y);
10887 if ((x = cmcfm()) < 0) return(x);
10889 return(success = 1);
10891 case XYLCLE: /* LOCAL-ECHO (= DUPLEX) */
10892 return(success = seton(&duplex));
10894 case XYESC: /* SET ESCAPE */
10895 return(success = setcc(ckitoa(DFESC),&escape));
10896 #endif /* NOLOCAL */
10898 case XYEXIT: /* SET EXIT */
10899 if ((z = cmkey(xittab,nexit,"","",xxstring)) < 0)
10902 case 0: /* STATUS */
10903 y = cmnum("EXIT status code","",10,&x,xxstring);
10904 return(success = setnum(&xitsta,x,y,-1));
10905 case 1: /* WARNING */
10906 if ((z = cmkey(xitwtab,nexitw,"","",xxstring)) < 0)
10908 if ((y = cmcfm()) < 0) return(y);
10910 return(success = 1);
10912 success = seton(&exitonclose);
10914 if (success) tn_exit = exitonclose;
10915 #endif /* TCPSOCKET */
10918 extern int exithangup;
10919 return((success = seton(&exithangup)));
10923 } /* End of SET EXIT switch() */
10930 case XYFILE: /* SET FILE */
10931 return(setfil(rmsflg));
10933 case XYFLOW: { /* FLOW-CONTROL */
10934 extern int cxflow[];
10940 if (network && istncomport())
10942 #endif /* TN_COMPORT */
10945 m = "Flow control type, one of the following:\n\
10946 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10947 or connection type";
10949 /* All this is because chained FDB's don't give chained help yet */
10953 "Flow control type, one of the following:\n\
10954 keep none rts/cts\n\
10955 or connection type",
10957 "Flow control type, one of the following:\n\
10959 or connection type";
10960 #endif /* CK_RTSCTS */
10965 "Flow control type, one of the following:\n\
10966 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10967 or connection type";
10968 #else /* CK_DTRCTS */
10969 "Flow control type, one of the following:\n\
10970 dtr/cd keep none rts/cts xon/xoff\n\
10971 or connection type";
10972 #endif /* CK_DTRCTS */
10973 #else /* CK_DTRCD */
10975 "Flow control type, one of the following:\n\
10976 dtr/cts keep none rts/cts xon/xoff\n\
10977 or connection type";
10978 #else /* CK_DTRCTS */
10979 "Flow control type, one of the following:\n\
10980 keep none rts/cts xon/xoff\n\
10981 or connection type";
10982 #endif /* CK_DTRCTS */
10983 #endif /* CK_DTRCD */
10985 "Flow control type, one of the following:\n\
10986 keep none xon/xoff\n\
10987 or connection type";
10988 #endif /* CK_RTSCTS */
10991 cmfdbi(&k1,_CMKEY,m,"","",ncxtypesw, 4, xxstring, cxtypesw, &k2);
10998 (tncomport ? ntnflo : nflo),
11001 #endif /* TN_COMPORT */
11005 (tncomport ? tnflotab : flotab),
11008 #endif /* TN_COMPORT */
11012 if (x < 0) { /* Error */
11013 if (x == -2 || x == -9)
11014 printf("?No keywords or switches match: \"%s\"\n",atmbuf);
11017 z = cmresult.nresult; /* Keyword value */
11018 if (cmresult.fdbaddr == &k2) { /* Flow-control type keyword table */
11019 if ((x = cmcfm()) < 0) /* Set it immediately */
11022 debug(F101,"set flow","",flow);
11024 if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
11025 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
11026 #endif /* CK_SPEED */
11027 autoflow = (flow == FLO_AUTO);
11028 return(success = 1); /* Done */
11030 debug(F101,"set flow /blah 1","",z); /* SET FLOW /for-what */
11031 if ((y = cmkey(flotab,nflo,"Flow control type","none",xxstring)) < 0)
11033 if ((x = cmcfm()) < 0)
11035 debug(F101,"set flow /blah 2","",y);
11036 if (y == FLO_AUTO) {
11038 "?Sorry, \"automatic\" can not be assigned to a connection type.\n");
11040 } else if (z >= 0 && z <= CXT_MAX)
11042 debug(F101,"set flow","",flow);
11043 debug(F101,"set flow autoflow","",autoflow);
11044 return(success = 1);
11047 case XYHAND: /* HANDSHAKE */
11048 if ((y = cmkey(hshtab,nhsh,"","none",xxstring)) < 0) return(y);
11050 if ((x = cmnum("ASCII value","",10,&y,xxstring)) < 0)
11052 if ((y < 1) || ((y > 31) && (y != 127))) {
11053 printf("?Character must be in ASCII control range\n");
11057 if ((x = cmcfm()) < 0) return(x);
11058 turn = (y > 0127) ? 0 : 1;
11060 return(success = 1);
11063 case XYMACR: /* SET MACRO */
11064 if ((y = cmkey(smactab,2,"","",xxstring)) < 0) return(y);
11066 case 0: return(success = seton(&mecho));
11067 case 1: return(success = seton(&merror[cmdlvl]));
11068 default: return(-2);
11074 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
11075 if ((y = cmcfm()) < 0) return(y);
11077 printf("Sorry, SET MESSAGES not implemented yet\n");
11078 return(success = 0);
11086 case XYPARI: /* PARITY */
11087 if ((y = cmkey(partbl,npar,"","none",xxstring)) < 0)
11090 /* If parity not none, then we also want 8th-bit prefixing */
11093 if (y == 'H') { /* Hardware */
11094 if ((x = cmkey(hwpartbl,nhwpar,"","even",xxstring)) < 0)
11097 #endif /* HWPARITY */
11099 if ((z = cmcfm()) < 0)
11103 if (y == 'H') { /* 8 data bits plus hardware parity */
11107 #endif /* NOXFER */
11109 } else { /* 7 data bits + software parity */
11111 #endif /* HWPARITY */
11114 ebqflg = (parity) ? 1 : 0;
11115 #endif /* NOXFER */
11118 #endif /* HWPARITY */
11121 if (network && istncomport())
11122 tnsettings(parity, 0);
11123 #endif /* TN_COMPORT */
11125 return(success = 1);
11128 case XYPROM: /* SET PROMPT */
11130 Note: xxstring not invoked here. Instead, it is invoked every time the
11131 prompt is issued. This allows the prompt string to contain variables
11132 that can change, like \v(dir), \v(time), etc.
11134 ckmakmsg(line, /* Default might have trailing space */
11137 inserver ? ikprompt : ckprompt,
11141 if ((x = cmtxt("Program's command prompt",line,&s,NULL)) < 0)
11143 s = brstrip(s); /* Remove enclosing braces, if any */
11144 cmsetp(s); /* Set the prompt */
11145 return(success = 1);
11146 #endif /* NOFRILLS */
11149 case XYRETR: /* RETRY: per-packet retry limit */
11150 y = cmnum("Maximum retries per packet","10",10,&x,xxstring);
11152 if ((x = setnum(&maxtry,x,y,999)) < 0) return(x);
11154 if (maxtry <= wslotr) {
11155 printf("?Retry limit must be greater than window size\n");
11156 return(success = 0);
11158 #endif /* COMMENT */
11160 sstate = setgen('S', "403", ckitoa(maxtry), "");
11161 return((int) sstate);
11162 } else return(success = x);
11163 #endif /* NOXFER */
11166 case XYSERV: /* SET SERVER items */
11167 if ((y = cmkey(srvtab,nsrvt,"","",xxstring)) < 0) return(y);
11170 if ((y = cmnum("Number of seconds, or 0 for no idle timeout",
11171 "0",10,&x,xxstring)) < 0)
11175 if ((y = cmcfm()) < 0)
11181 return(success = 1);
11183 if ((y = cmnum("Interval for server NAKs, 0 = none",
11185 10,&x, xxstring)) < 0)
11189 "\n?Specify a positive number, or 0 for no server NAKs\n");
11192 if ((y = cmcfm()) < 0) return(y);
11194 sstate = setgen('S', "404", ckitoa(x), "");
11195 return((int) sstate);
11200 srvtim = x; /* Set the server timeout variable */
11201 return(success = 1);
11203 case XYSERD: /* SERVER DISPLAY */
11204 return(success = seton(&srvdis)); /* ON or OFF... */
11207 case XYSERP: /* SERVER GET-PATH */
11208 return(parsdir(2));
11211 case XYSERL: /* SERVER LOGIN */
11214 case XYSERC: /* SERVER CD-MESSAGE */
11216 cmkey(onoff,2,"","",xxstring) :
11217 cmkey(cdmsg,3,"","",xxstring);
11220 if (x == 2) { /* CD-MESSAGE FILE */
11221 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
11227 makestr(&cdmsgstr,s);
11228 makelist(cdmsgstr,cdmsgfile,8);
11229 return(success = 1);
11231 if ((y = cmcfm()) < 0) /* CD-MESSAGE ON/OFF */
11234 sstate = setgen('S', "420", x ? "1" : "0", "");
11235 return((int) sstate);
11241 return(success = 1);
11243 case XYSERK: /* SERVER KEEPALIVE */
11244 return(success = seton(&srvping)); /* ON or OFF... */
11249 #endif /* NOSERVER */
11255 case XYSUSP: /* SET SUSPEND */
11256 seton(&xsuspend); /* on or off... */
11257 return(success = 1);
11261 case XYTAKE: /* SET TAKE */
11262 if ((y = cmkey(taktab,4,"","",xxstring)) < 0) return(y);
11264 case 0: return(success = seton(&techo));
11266 case 1: return(success = seton(&takerr[cmdlvl]));
11268 case 1: return(success = seton(&takerr[tlevel]));
11270 case 2: techo = 0; return(success = 1); /* For compatibility with */
11271 case 3: techo = 1; return(success = 1); /* MS-DOS Kermit */
11272 default: return(-2);
11276 case XYSCRI: /* SET SCRIPT */
11277 if ((y = cmkey(scrtab,1,"","echo",xxstring)) < 0) return(y);
11279 case 0: return(success = seton(&secho));
11280 default: return(-2);
11282 #endif /* NOSCRIPT */
11290 case XYTERM: /* SET TERMINAL */
11292 success = (x > 0) ? 1 : 0;
11296 case XYWIN95: /* SET WIN95 workarounds */
11298 success = (x > 0 ? 1 : 0);
11303 case XYDLR: /* SET DIALER workarounds */
11305 success = (x > 0 ? 1 : 0);
11308 case XYTITLE: /* SET TITLE of window */
11310 success = (x > 0 ? 1 : 0);
11315 case XYMOUSE: /* SET MOUSE */
11316 return(success = setmou());
11317 #endif /* OS2MOUSE */
11319 case XYBELL: /* SET BELL */
11320 return(success = setbell());
11324 return(success = setprty() );
11330 #endif /* NOLOCAL */
11334 /* SET SEND/RECEIVE protocol parameters. */
11339 return(setsr(xx,rmsflg));
11340 #endif /* NOXFER */
11343 case XYSESS: /* SESSION-LOG */
11344 if ((x = cmkey(sfttab,nsfttab,"type of file",
11354 if ((y = cmcfm()) < 0)
11356 if (x == 999) { /* TIMESTAMPED-TEXT */
11357 sessft = XYFT_T; /* Implies text */
11358 slogts = 1; /* and timestamps */
11359 } else if (x == 998) { /* NULL-PADDED-LINES */
11360 slognul = 1; /* adds NUL after ^J */
11361 } else { /* A regular type */
11362 sessft = x; /* The type */
11363 slogts = 0; /* No timestampes */
11365 return(success = 1);
11367 case XYSPEE: /* SET SPEED */
11369 if (local && !network) {
11372 "Transmission rate for ",
11374 " (bits per second)",
11379 "Serial-port speed (bits per second)",
11386 if (network && istncomport())
11387 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
11389 #endif /* TN_COMPORT */
11390 x = cmkey(spdtab,nspd,line,"",xxstring);
11392 if (x == -3) printf("?value required\n");
11393 #ifdef USETCSETSPEED
11394 /* In this case, any number can be tried */
11395 /* There's a parse error message but the request still goes thru */
11396 if (rdigits(atmbuf))
11399 #endif /* USETCSETSPEED */
11402 if ((y = cmcfm()) < 0) return(y);
11405 printf("?Sorry, command disabled.\r\n");
11406 return(success = 0);
11410 printf("?SET SPEED has no effect without prior SET LINE\n");
11411 return(success = 0);
11415 #endif /* TN_COMPORT */
11417 printf("\n?Speed cannot be set for network connections\n");
11418 return(success = 0);
11422 Note: This way of handling speeds is not 16-bit safe for speeds greater
11423 than 230400. The argument to ttsspd() should have been a long.
11425 #ifdef USETCSETSPEED
11428 #endif /* USETCSETSPEED */
11429 zz = (long) x * 10L;
11430 if (zz == 130L) zz = 134L;
11431 if (zz == 70L) zz = 75L; /* (see spdtab[] definition) */
11432 if (ttsspd(x) < 0) { /* Call ttsspd with cps, not bps! */
11433 printf("?Unsupported line speed - %ld\n",zz);
11434 return(success = 0);
11437 if (!tttapi || tapipass)
11438 speed = ttgspd(); /* Read it back */
11441 #else /* CK_TAPI */
11442 speed = ttgspd(); /* Read it back */
11443 #endif /* CK_TAPI */
11444 if (speed != zz) { /* Call ttsspd with cps, not bps! */
11445 printf("?SET SPEED fails, speed is %ld\n",speed);
11446 return(success = 0);
11448 if (pflag && !xcmdsrc) {
11450 printf("%s, 75/1200 bps\n",ttname);
11451 else if (speed == 134)
11452 printf("%s, 134.5 bps\n",ttname);
11454 printf("%s, %ld bps\n",ttname,speed);
11456 return(success = 1);
11458 #endif /* NOLOCAL */
11461 case XYXFER: /* SET TRANSFER */
11462 if ((y = cmkey(rmsflg ? rtstab : tstab, /* (or REMOTE SET TRANSFER) */
11463 rmsflg ? nrts : nts,
11464 "","character-set",xxstring)) < 0) return(y);
11467 case XYX_CAN: /* CANCELLATION */
11468 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
11469 if (z == 0) { /* OFF */
11470 if ((y = cmcfm()) < 0) return(y);
11473 if ((y = cmnum("ASCII code for cancellation character",
11477 if (x > 31 && x != 127) {
11478 printf("Cancel character must be 0-31 or 127\n");
11481 if ((y = cmnum("How many required to cause cancellation",
11482 "2",10,&z, xxstring)) < 0)
11485 printf("Number must be 2 or greater\n");
11488 if ((y = cmcfm()) < 0) return(y);
11489 xfrcan = 1; /* CANCELLATION ON */
11490 xfrchr = x; /* Using this character */
11491 xfrnum = z; /* Needing this many of them */
11493 return(success = 1);
11494 #endif /* XFRCAN */
11497 case XYX_CSE: /* CHARACTER-SET */
11498 if ((y = cmkey(tcstab,ntcs,"","transparent",xxstring)) < 0)
11500 if ((x = cmcfm()) < 0) return(x);
11502 sstate = setgen('S', "405", tcsinfo[y].designator, "");
11503 return((int) sstate);
11505 extern int s_cset, fcharset, axcset[], tcs_save;
11506 tslevel = (y == TC_TRANSP) ? 0 : 1; /* transfer syntax level */
11508 tcharset = y; /* transfer character set */
11509 /* SEND CHARACTER-SET AUTO */
11510 if (tslevel > 0 && s_cset == XMODE_A)
11511 if (y > -1 && y <= MAXTCSETS)
11512 if (axcset[y] > -1 && axcset[y] > MAXFCSETS)
11513 fcharset = axcset[y]; /* Auto-pick file charset */
11514 setxlatype(tcharset,fcharset); /* Translation type */
11516 return(success = 1);
11518 #endif /* NOCSETS */
11520 case XYX_LSH: /* LOCKING-SHIFT */
11521 if ((y = cmkey(lstab,nls,"","on",xxstring)) < 0)
11523 if ((x = cmcfm()) < 0) return(x);
11524 lscapr = (y == 1) ? 1 : 0; /* ON: requested = 1 */
11525 lscapu = (y == 2) ? 2 : 0; /* FORCED: used = 1 */
11526 return(success = 1);
11528 /* #ifdef CK_XYZ */
11529 case XYX_PRO: /* Protocol */
11532 printf("?Sorry, only Kermit protocol is available\n");
11536 return(setproto());
11537 /* #endif */ /* CK_XYZ */
11539 case XYX_MOD: /* Mode */
11540 if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
11542 if ((x = cmcfm()) < 0) return(x);
11544 sstate = setgen('S', "410", y == XMODE_A ? "0" : "1", "");
11545 return((int)sstate);
11550 if (ftpisopen()) { /* If an FTP connection is open */
11551 extern int ftp_xfermode; /* change its transfer mode too */
11552 ftp_xfermode = xfermode;
11554 #endif /* NEWFTP */
11555 return(success = 1);
11558 case XYX_DIS: /* Display */
11559 return(doxdis(1)); /* 1 == Kermit */
11560 #endif /* NOLOCAL */
11562 case XYX_SLO: /* Slow-start */
11563 return(seton(&slostart));
11566 case XYX_CRC: /* CRC */
11567 return(seton(&docrc));
11570 case XYX_BEL: /* Bell */
11571 return(seton(&xfrbel));
11574 case XYX_PIP: /* Pipes */
11577 #endif /* NOPUSH */
11578 printf("Sorry, access to pipes is disabled\n");
11582 #endif /* NOPUSH */
11583 return(seton(&usepipes));
11584 #endif /* PIPESEND */
11586 case XYX_INT: /* Interruption */
11587 return(seton(&xfrint));
11590 return(seton(&xfrxla)); /* Translation */
11593 extern char * xfrmsg;
11594 if ((x = cmtxt("Prompt string","",&s,xxstring)) < 0)
11597 makestr(&xfrmsg,s);
11598 return(success = 1);
11602 extern int whereflg;
11603 return(seton(&whereflg));
11608 #endif /* NOXFER */
11614 case XYXMIT: /* SET TRANSMIT */
11616 #endif /* NOXMIT */
11620 case XYUNCS: /* UNKNOWN-CHARACTER-SET */
11621 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
11622 if ((x = cmcfm()) < 0) return(x);
11624 return(success = 1);
11625 #endif /* NOCSETS */
11626 #endif /* NOXFER */
11630 case XYWILD: /* WILDCARD-EXPANSION */
11631 if ((y = cmkey(wildtab,nwild,
11632 "Wildcard expansion option","on",xxstring)) < 0)
11634 if ((z = cmkey(wdottab,
11636 "whether to match filenames that start with \".\"",
11637 "/no-match-dot-files",
11641 if ((x = cmcfm()) < 0) return(x);
11644 printf("Shell expansion is disabled\n");
11645 return(success = 0);
11656 wildxpand = 0; /* These are the previous */
11657 break; /* hardwired values */
11663 return(success = 1);
11665 #endif /* NOPUSH */
11668 case XYWIND: /* WINDOW-SLOTS */
11669 if (protocol == PROTO_K) {
11670 y = cmnum("Window size for Kermit protocol, 1 to 32",
11671 "1", 10, &x, xxstring);
11672 y = setnum(&z,x,y,MAXWS); /* == 32 */
11675 else if (protocol == PROTO_Z) {
11676 y = cmnum("Window size for ZMODEM protocol, 0 to 65535",
11677 "0", 10, &x, xxstring);
11678 y = setnum(&z,x,y,65535);
11680 #endif /* CK_XYZ */
11682 y = cmnum("Window size for current protocol",
11683 "", 10, &x, xxstring);
11684 y = setnum(&z,x,y,65472); /* Doesn't matter - we won't use it */
11686 if (y < 0) return(y);
11687 if (protocol == PROTO_K) {
11692 else if (protocol == PROTO_Z) {
11693 /* Zmodem windowing is closer to Kermit packet length */
11694 /* than Kermit window size. If Window size is zero */
11695 /* an end of frame and CRC is sent only at the end of */
11696 /* the file (default). Otherwise, an End of Frame */
11697 /* and CRC are sent after Window Size number of bytes */
11698 if (z < 0) /* Disable windowing */
11701 printf("?SET WINDOW does not apply to %s protocol\n",
11702 ptab[protocol].p_name
11705 #endif /* CK_XYZ */
11708 /* This is taken care of automatically now in protocol negotiation */
11710 printf("?Window slots must be less than retry limit\n");
11711 return(success = 0);
11713 #endif /* COMMENT */
11714 if (protocol == PROTO_K && rmsflg) { /* Set remote window size */
11715 wslotr = z; /* Set local window size too */
11716 ptab[protocol].winsize = wslotr;
11717 sstate = setgen('S', "406", ckitoa(z), "");
11718 return((int) sstate);
11720 wslotr = z; /* Set requested window size here */
11721 ptab[protocol].winsize = wslotr; /* and in protocol-specific table */
11722 if (protocol == PROTO_K) { /* And for Kermit only... */
11723 swcapr = (wslotr > 1) ? 1 : 0; /* set window bit in capas word */
11724 if (wslotr > 1) { /* Window size > 1? */
11725 /* Maybe adjust packet size */
11726 y = adjpkl(urpsiz,wslotr,bigrbsiz);
11727 if (y != urpsiz) { /* Did it change? */
11731 " Adjusting receive packet-length to %d for %d window slots\n",
11738 return(success = 1);
11739 #endif /* NOXFER */
11745 case XYOUTP: /* OUTPUT command parameters */
11746 if ((y = cmkey(outptab,noutptab,"OUTPUT command parameter","pacing",
11749 switch(y) { /* Which parameter */
11750 case OUT_PAC: /* PACING */
11751 y = cmnum("Milliseconds to pause between each OUTPUT character",
11752 "100", 10,&x,xxstring);
11753 y = setnum(&z,x,y,16383); /* Verify and get confirmation */
11754 if (y < 0) return(y);
11755 if (z < 0) z = 0; /* (save some space) */
11757 return(success = 1);
11758 case OUT_ESC: /* Special-escapes */
11759 return(seton(&outesc));
11760 default: /* (shouldn't happen) */
11769 if ((z = cmkey(ctltab,2, "control-character prefixing option",""
11772 /* Make space for a temporary copy of the prefixing table */
11774 p = (short *)malloc(256 * sizeof(short));
11776 printf("?Internal error - malloc failure\n");
11779 for (i = 0; i < 256; i++) p[i] = ctlp[i]; /* Copy current table */
11782 case 0: /* UNPREFIXED control character */
11783 case 1: /* PREFIXED control character */
11784 while (1) { /* Collect a list of numbers */
11786 x_ifnum = 1; /* Turn off complaints from eval() */
11788 if ((x = cmnum((z == 0) ?
11789 "\n Numeric ASCII value of control character that needs NO prefix,\n\
11790 or the word \"all\", or carriage return to complete the list" :
11791 "\n Numeric ASCII value of control character that MUST BE prefixed,\n\
11792 or the word \"all\", or carriage return to complete the list",
11799 if ((x = cmcfm()) < 0) return(x);
11803 if (p) { free((char *)p); p = NULL; }
11804 debug(F110,"SET CONTROL atmbuf",atmbuf,0);
11805 if (!ckstrcmp(atmbuf,"all",3,0) || /* "ALL" */
11806 !ckstrcmp(atmbuf,"al",2,0) ||
11807 !ckstrcmp(atmbuf,"a",1,0)) {
11808 if ((x = cmcfm()) < 0) /* Get confirmation */
11810 prefixing = z ? PX_ALL : PX_NON;
11811 setprefix(prefixing);
11812 return(success = 1);
11813 } else { /* Not number, not ALL */
11815 "?Please specify a number or the word ALL\n");
11819 if (p) free((char *)p);
11826 #ifdef UNPREFIXZERO
11832 zz = 0; /* Allow 0 (but only for Zmodem) */
11834 #endif /* UNPREFIXZERO */
11836 /* printf("x = %d, y = %d, z = %d, zz = %d\n", x,y,z,zz); */
11838 if ((y > 31 && y < 127) || /* A specific numeric value */
11839 (y > 159 && y < 255) || /* Check that it is a valid */
11840 (y < zz) || /* control code. */
11842 printf("?Values allowed are: %d-31, 127-159, 255\n",zz);
11843 if (p) free((char *)p);
11846 x = y & 127; /* Get 7-bit value */
11847 if (z == 0) { /* If they are saying it is safe... */
11848 /* If flow control is Xon/Xoff */
11849 if (((flow == FLO_XONX) &&
11850 /* XON & XOFF chars not safe. */
11851 (x == XON || x == XOFF))
11855 "Sorry, not while Xon/Xoff is in effect.\n");
11856 if (p) free((char *)p);
11860 else if (network && IS_TELNET()
11862 (unsigned) y == (unsigned) 255)) {
11864 printf("Sorry, not on a TELNET connection.\n");
11865 if (p) free((char *)p);
11868 #endif /* TNCODE */
11870 p[y] = (char) z; /* All OK, set flag */
11871 } /* End of while loop */
11873 Get here only if they have made no mistakes. Copy temporary table back to
11874 permanent one, then free temporary table and return successfully.
11876 for (i = 0; i < 256; i++) ctlp[i] = p[i];
11877 if (p) free((char *)p);
11878 if (z > 0) clearrq = 0; /* 199 (see SET PREFIXING) */
11879 return(success = 1);
11884 #endif /* CK_SPEED */
11891 if ((y = cmkey(rpttab,2,
11892 "repeat-count compression parameter","",xxstring)) < 0)
11896 return(success = seton(&rptena)); /* REPEAT COUNTS = ON, OFF */
11897 case 1: /* REPEAT MININUM number */
11898 printf("(not implemented yet, nothing happens)\n");
11900 case 2: /* REPEAT PREFIX char */
11901 if ((x = cmnum("ASCII value","",10,&z,xxstring)) < 0)
11903 if ((x = cmcfm()) < 0) return(x);
11904 if ((z > 32 && z < 63) || (z > 95 && z < 127)) {
11905 if (y == 1) rptmin = (CHAR) z; else myrptq = (CHAR) z;
11906 return(success = 1);
11908 printf("?Illegal value for prefix character\n");
11912 #endif /* NOXFER */
11921 x_ifnum = 1; /* Turn off internal complaints */
11922 y = cmnum("Seconds from now, or time of day as hh:mm:ss",
11923 "0" ,10, &x, xxstring);
11926 if (y == -2) { /* Invalid number or expression */
11927 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
11929 printf("?Number, expression, or time of day required\n");
11932 char now[32]; /* Current time */
11937 tnow = atol(p+11) * 3600L +
11938 atol(p+14) * 60L + atol(p+17);
11939 if (zz < tnow) /* User's time before now */
11940 zz += 86400L; /* So make it tomorrow */
11941 zz -= tnow; /* Seconds from now. */
11947 printf("?Alarm time is in the past.\n");
11950 if ((y = cmcfm()) < 0) return(y);
11951 if (zz > -1L) { /* Time of day given? */
11953 if (zz != (long) x) {
11955 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
11960 return(setalarm((long)x));
11964 This is to allow long values where int and long are not the same, e.g.
11965 on 16-bit systems. But something is wrong with it.
11967 if ((y = cmtxt("seconds from now", "0", &s, xxstring)) < 0)
11970 return(setalarm(atol(s)));
11972 printf("%s - not a number\n",s);
11975 #endif /* COMMENT */
11980 return(setproto());
11981 #endif /* NOXFER */
11984 C-Kermit unprefixes control characters automatically on network connections
11985 if CLEAR-CHANNEL is ON, which it is by default. But not all network
11986 connections are transparent to all control characters. For example, the
11987 DEC-20, even when you TELNET to it, is sensitive to Ctrl-O and Ctrl-T.
11988 If you tell C-Kermit to SET CONTROL PREFIX 15 and/or 20, it doesn't help
11989 because CLEAR-CHANNEL is still in effect. If the user goes to the trouble
11990 to set up some prefixing, then Kermit should do what the user said. In
11991 C-Kermit 7.1 Alpha.03 we change the code to set clearrq to 0 if the user
11992 gives a SET PREFIXING or SET CONTROL PREFIX command.
11998 extern int clearrq;
11999 #endif /* COMMENT */
12000 if ((z = cmkey(pfxtab, 4, "control-character prefixing option",
12001 "", xxstring)) < 0)
12003 if ((x = cmcfm()) < 0) return(x);
12004 clearrq = 0; /* 199 */
12007 if (hints && (z == PX_ALL || z == PX_CAU) && clearrq) {
12008 printf("Hint: Use SET CLEAR-CHANNEL OFF to disable negotiation of\n");
12009 printf(" SET PREFIXING NONE during file transfers on reliable\n");
12010 printf(" connections.\n");
12012 #endif /* COMMENT */
12013 return(success = 1);
12015 #endif /* CK_SPEED */
12019 if ((z = cmkey(logintab, 3, "value for login script","userid",
12025 if ((y = cmtxt("text","", &s, NULL)) < 0) {
12032 return(success = 0);
12035 if ((int)strlen(s) > 63) {
12036 printf("Sorry, too long\n");
12041 ckstrncpy(uidbuf,s,UIDBUFLEN);
12045 ckstrncpy(pwbuf,s,PWBUFL);
12056 ckstrncpy(prmbuf,s,PWBUFL);
12058 return(success = 1);
12065 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
12066 if ((x = cmcfm()) < 0) return(x);
12067 DeleteStartupFile = (y != 0) ? 0 : 1;
12068 return(success = 1);
12071 x = cmdir("Name of temporary directory","",&s,xxstring);
12076 if ((x = cmcfm()) < 0) return(x);
12077 makestr(&tempdir,s);
12078 return(tempdir ? 1 : 0);
12081 case XYDEST: /* DESTINATION */
12083 #endif /* NOXFER */
12088 /* Editor, Browser, and FTP Client */
12090 case XYEDIT: /* EDITOR */
12093 printf("?Sorry, command disabled.\r\n");
12094 return(success = 0);
12098 /* Don't let this be set remotely */
12099 if (apcactive == APC_LOCAL ||
12100 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12101 return(success = 0);
12102 #endif /* CK_APC */
12106 char *p = getenv("PATH");
12108 e = editor[0] ? (char *) editor : getenv("EDITOR");
12111 x = cmifip("Name of preferred editor",e,&s,&y,0,p,xxstring);
12113 x = cmifi("Full path of preferred editor",e,&s,&y,xxstring);
12114 if (x < 0 && x != -3)
12119 if ((y = cmtxt("DCL command for editing", "edit", &s, NULL)) < 0) {
12124 if ((x = cmifi("Full path of preferred editor","",&s,&y,xxstring))<0) {
12129 #endif /* OS2ORUNIX */
12131 ckstrncpy(editor,s,CKMAXPATH);
12135 printf("?A single file please\n");
12138 ckstrncpy(line,s,LINBUFSIZ);
12139 if ((x = cmtxt("editor command-line options","",&s,NULL)) < 0)
12141 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12142 if ((z = cmcfm()) < 0) return(z);
12144 zfnqfp(line,CKMAXPATH,editor);
12145 ckstrncpy(editopts,tmpbuf,128);
12151 return(success = 1);
12157 return(dosetftp()); /* SET FTP */
12158 #endif /* TCPSOCKET */
12159 #endif /* SYSFTP */
12165 case XYFTP: /* SET FTP-CLIENT */
12166 #endif /* SYSFTP */
12168 case XYBROWSE: /* SET BROWSER */
12170 char *p = getenv("PATH");
12171 char *app = (char *) browser, *opts = (char *) browsopts;
12174 extern char ftpapp[], ftpopts[];
12176 app = (char *)ftpapp;
12177 opts = (char *)ftpopts;
12179 #endif /* SYSFTP */
12183 printf("?Sorry, command disabled.\r\n");
12184 return(success = 0);
12188 /* Don't let this be set remotely */
12189 if (apcactive == APC_LOCAL ||
12190 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12191 return(success = 0);
12192 #endif /* CK_APC */
12195 x = cmifip(xx == XYBROWSE ?
12196 "Name of preferred browser" :
12197 "Name of preferred ftp client",
12199 xx == XYFTP ? "ftp.exe" : ""
12201 xx == XYFTP ? "ftp" : ""
12203 ,&s,&y,0,p,xxstring
12206 x = cmifi(xx == XYBROWSE ?
12207 "Full path of preferred browser" :
12208 "Full path of preferred ftp client",
12211 if (x < 0 && x != -3)
12215 if ((x = cmtxt("DCL command to start your preferred Web browser",
12216 "", &s, NULL)) < 0) {
12221 if ((x = cmifi("Full path of preferred browser","",&s,&y,xxstring)
12227 #endif /* OS2ORUNIX */
12229 ckstrncpy(app,s,CKMAXPATH);
12233 printf("?A single file please\n");
12236 ckstrncpy(line,s,LINBUFSIZ);
12237 if ((x = cmtxt(xx == XYBROWSE ?
12238 "browser command-line options" :
12239 "ftp client command-line options",
12243 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
12244 if ((z = cmcfm()) < 0) return(z);
12246 zfnqfp(line,CKMAXPATH,app);
12247 ckstrncpy(opts, tmpbuf, 128);
12253 return(success = 1);
12255 #endif /* BROWSER */
12256 #endif /* NOFRILLS */
12257 #endif /* NOPUSH */
12260 case XYEOF: { /* SET EOF */
12261 extern int eofmethod; extern struct keytab eoftab[];
12262 if ((x = cmkey(eoftab,3,"end-of-file detection method","",
12265 if ((y = cmcfm()) < 0)
12268 return(success = 1);
12270 #endif /* CK_CTRLZ */
12273 case XYLIMIT: { /* Session-Limit (length of session in seconds) */
12274 extern int seslimit;
12276 extern int downloaded;
12278 y = cmnum("Maximum length of session, seconds","0",10,&x,xxstring);
12284 #endif /* IKSDCONF */
12289 if ((z = cmcfm()) < 0)
12291 printf("?Sorry, command disabled.\r\n");
12292 return(success = 0);
12294 return(setnum(&seslimit,x,y,86400));
12296 #endif /* SESLIMIT */
12298 case XYRELY: { /* SET RELIABLE */
12299 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12301 if ((y = cmcfm()) < 0) return(y);
12303 setreliable = (x != SET_AUTO);
12304 debug(F101,"SET RELIABLE reliable","",reliable);
12305 return(success = 1);
12309 case XYSTREAM: { /* SET STREAMING */
12310 extern int streamrq;
12311 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12313 if ((y = cmcfm()) < 0) return(y);
12315 return(success = 1);
12317 #endif /* STREAMING */
12321 if ((x = cmkey(syslogtab,nsyslog,"","",xxstring)) < 0)
12323 if ((y = cmcfm()) < 0) return(y);
12330 #endif /* IKSDCONF */
12332 printf("?Sorry, command disabled.\n");
12333 return(success = 0);
12337 /* Don't let this be set remotely */
12338 if (apcactive == APC_LOCAL ||
12339 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12340 return(success = 0);
12341 #endif /* CK_APC */
12343 return(success = 1);
12345 #endif /* CKSYSLOG */
12348 case XYTLOG: { /* SET TRANSACTION-LOG */
12349 extern int tlogsep;
12350 if ((x = cmkey(vbtab,nvb,"","verbose",xxstring)) < 0)
12353 if ((y = cmtxt("field separator",",",&s,NULL)) < 0) return(y);
12357 printf("?A single character, please.\n");
12359 } else if ((*s >= '0' && *s <= '9') ||
12360 (*s >= 'A' && *s <= 'Z') ||
12361 (*s >= 'a' && *s <= 'z')) {
12362 printf("?A non-alphanumeric character, please.\n");
12368 if ((y = cmcfm()) < 0) return(y);
12371 if (inserver && isguest) {
12372 printf("?Sorry, command disabled.\n");
12373 return(success = 0);
12377 /* Don't let this be set remotely */
12378 if (apcactive == APC_LOCAL ||
12379 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12380 return(success = 0);
12381 #endif /* CK_APC */
12383 return(success = 1);
12387 case XYCLEAR: { /* SET CLEARCHANNEL */
12388 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12390 if ((y = cmcfm()) < 0) return(y);
12392 return(success = 1);
12395 #ifdef CK_AUTHENTICATION
12396 case XYAUTH: { /* SET AUTHENTICATION */
12399 extern struct krb_op_data krb_op;
12400 #endif /* CK_KERBEROS */
12403 cmkey(setauth,nsetauth,"authentication type","",xxstring)) < 0)
12407 case AUTH_KRB4: kv = 4; break; /* Don't assume values are same */
12408 case AUTH_KRB5: kv = 5; break;
12409 #endif /* CK_KERBEROS */
12411 case AUTH_SRP: break;
12412 #endif /* CK_SRP */
12417 #endif /* CK_SSL */
12419 printf("?Authorization type not supported yet - \"%s\"\n",
12429 #endif /* IKSDCONF */
12431 if ((y = cmcfm()) < 0) return(y);
12432 printf("?Sorry, command disabled.\n");
12433 return(success = 0);
12437 /* Don't let this be set remotely */
12438 if (apcactive == APC_LOCAL ||
12439 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) {
12440 if ((y = cmcfm()) < 0) return(y);
12441 return(success = 0);
12443 #endif /* CK_APC */
12449 if ((x = cmkey(kv == 4 ? k4tab : k5tab,
12450 kv == 4 ? nk4tab : nk5tab,
12451 "Kerberos parameter","",xxstring)) < 0) {
12459 if ((y = seton(&k4debug)) < 0)
12462 ck_krb4_debug(k4debug);
12470 if ((y = cmnum("TGT lifetime","600",10,&z,xxstring)) < 0)
12475 if ((y = seton(&krb4_d_preauth)) < 0)
12482 if ((y = cmtxt("Instance name","",&s,xxstring)) < 0)
12487 if ((y = seton(&krb5_d_forwardable)) < 0)
12495 if ((y = seton(&krb5_d_proxiable)) < 0)
12502 if ((y = cmnum("TGT renewable lifetime",
12503 "0",10,&z,xxstring)) < 0)
12508 if ((y = seton(&krb5_checkaddrs)) < 0)
12511 if ((y = seton(&krb4_checkaddrs)) < 0)
12517 if ((y = seton(&krb5_d_no_addresses)) < 0)
12523 char * tmpaddrs[KRB5_NUM_OF_ADDRS];
12524 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++)
12525 tmpaddrs[i] = NULL;
12528 cmfld("List of IP addresses","",&s,xxstring)) < 0)
12530 makelist(s,tmpaddrs,KRB5_NUM_OF_ADDRS);
12531 if ((y = cmcfm()) < 0) {
12532 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12533 if (tmpaddrs[i] != NULL)
12539 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12541 if (inet_addr(tmpaddrs[i]) == 0xffffffff) {
12542 printf("invalid ip address: %s\n",
12544 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12545 if (tmpaddrs[i] != NULL)
12552 i < KRB5_NUM_OF_ADDRS && krb5_d_addrs[i];
12554 if (krb5_d_addrs[i])
12555 free(krb5_d_addrs[i]);
12556 krb5_d_addrs[i] = NULL;
12559 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12561 krb5_d_addrs[i] = tmpaddrs[i];
12562 tmpaddrs[i] = NULL;
12564 krb5_d_addrs[i] = NULL;
12565 return(success = 1);
12571 if ((y = seton(&krb5_autoget)) < 0)
12574 if ((y = seton(&krb4_autoget)) < 0)
12579 if ((z = cmkey(kdestab,nkdestab,
12580 "Auto Destroy Tickets",
12581 "never",xxstring)) < 0)
12585 if ((y = cmtxt("User ID",uidbuf,&s,xxstring)) < 0)
12589 if ((y = cmtxt("Name of realm","",&s,xxstring)) < 0)
12593 y = cmifi("Filename","",&s,&z,xxstring);
12598 printf("?Wildcards not allowed\n");
12604 if ((y = cmofi("Filename","",&s,xxstring)) < 0)
12608 if ((y = cmtxt("Name of service to use in ticket",
12609 (kv == 4 ? "rcmd" : "host"),
12617 if ((y = seton(&krb5_d_getk4)) < 0)
12623 case XYKRBPRM: /* Prompt */
12624 if ((z = cmkey(krbprmtab,2,"","",xxstring)) < 0)
12626 if ((y = cmtxt((z == KRB_PW_PRM) ?
12627 "Text of prompt;\nmay contain \"%s\" to be replaced by principal name" :
12637 ckstrncpy(line,s,LINBUFSIZ);
12639 if ((y = cmcfm()) < 0)
12645 #else /* IKSDCONF */
12647 #endif /* IKSDCONF */
12649 return(success = 0);
12652 switch (x) { /* Copy value to right place */
12653 case XYKRBLIF: /* Lifetime */
12655 krb4_d_lifetime = z;
12657 krb5_d_lifetime = z;
12661 krb5_d_renewable = z;
12663 case XYKRBPR: /* Principal */
12664 s = brstrip(s); /* Strip braces around. */
12666 makestr(&krb4_d_principal,s);
12668 makestr(&krb5_d_principal,s);
12670 case XYKRBINS: /* Instance */
12672 makestr(&krb4_d_instance,s);
12674 makestr(&krb5_d_instance,s);
12676 case XYKRBRL: /* Realm */
12678 makestr(&krb4_d_realm,s);
12680 makestr(&krb5_d_realm,s);
12682 case XYKRBKTB: /* Key Table */
12684 makestr(&k4_keytab,s);
12686 makestr(&k5_keytab,s);
12688 case XYKRBCC: /* Credentials cache */
12689 makestr(&krb5_d_cc,s);
12691 case XYKRBSRV: /* Service Name */
12693 makestr(&krb4_d_srv,s);
12695 makestr(&krb5_d_srv,s);
12703 case XYKRBPRM: /* Prompt */
12706 case KRB_PW_PRM: { /* Password */
12707 /* Check that there are no more than */
12708 /* two % fields and % must followed by 's'. */
12711 for (i = 0, n = 0; i < len; i++) {
12713 if (s[i+1] != '%') {
12714 if (s[i+1] != 's') {
12716 "Only %%s fields are permitted.\n"
12722 "Only two %%s fields are permitted.\n");
12730 makestr(&k5pwprompt,s);
12732 makestr(&k4pwprompt,s);
12735 case KRB_PR_PRM: { /* Principal */
12736 /* Check to make sure there are no % fields */
12739 for (i = 0; i < len; i++) {
12741 if (s[i+1] != '%') {
12743 "%% fields are not used in this command.\n");
12750 makestr(&k5prprompt,s);
12752 makestr(&k4prprompt,s);
12759 #endif /* CK_KERBEROS */
12762 if ((x = cmkey(srptab, nsrptab,
12763 "SRP parameter","",xxstring)) < 0) {
12768 case XYSRPPRM: /* Prompt */
12769 if ((z = cmkey(srpprmtab,1,"","",xxstring)) < 0)
12772 "Text of prompt;\nmay contain one \"%s\" to be replaced by the username",
12781 ckstrncpy(line,s,LINBUFSIZ);
12783 if ((y = cmcfm()) < 0)
12785 switch (x) { /* Copy value to right place */
12786 case XYSRPPRM: /* Prompt */
12789 case SRP_PW_PRM: { /* Password */
12790 /* Check %s fields */
12793 for (i = 0, n = 0; i < len; i++) {
12795 if (s[i+1] != '%') {
12796 if (s[i+1] != 's') {
12798 "Only %%s fields are permitted.\n");
12803 "Only one %%s field is permitted.\n");
12810 makestr(&srppwprompt,s);
12817 #endif /* CK_SRP */
12821 if ((z = cmkey(ssltab, nssltab,
12822 (x == AUTH_SSL ? "SSL parameter" : "TLS parameter"),
12827 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12828 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12829 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12830 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12831 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12832 case XYSSLDKFL: /* SSL/TLS DH Key File */
12833 case XYSSLDPFL: /* SSL/TLS DH Param File */
12834 case XYSSLCRL: /* SSL/TLS CRL File */
12835 case XYSSLVRFF: /* SSL/TLS Verify File */
12836 case XYSSLRND: /* SSL/TLS Random File */
12837 y = cmifi("Filename","",&s,&x,xxstring);
12842 printf("?Wildcards not allowed\n");
12846 ckstrncpy(line,s,LINBUFSIZ);
12849 if ((y = cmcfm()) < 0)
12852 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12853 if (!s[0] && ssl_rsa_cert_file) {
12854 free(ssl_rsa_cert_file);
12855 ssl_rsa_cert_file = NULL;
12857 makestr(&ssl_rsa_cert_file,s);
12858 if (!ssl_rsa_key_file)
12859 makestr(&ssl_rsa_key_file,s);
12862 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12863 if (!s[0] && ssl_rsa_cert_chain_file) {
12864 free(ssl_rsa_cert_chain_file);
12865 ssl_rsa_cert_chain_file = NULL;
12867 makestr(&ssl_rsa_cert_chain_file,s);
12870 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12871 if (!s[0] && ssl_rsa_key_file) {
12872 free(ssl_rsa_key_file);
12873 ssl_rsa_key_file = NULL;
12875 makestr(&ssl_rsa_key_file,s);
12878 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12879 if (!s[0] && ssl_dsa_cert_file) {
12880 free(ssl_dsa_cert_file);
12881 ssl_dsa_cert_file = NULL;
12883 makestr(&ssl_dsa_cert_file,s);
12884 if (!ssl_dh_key_file)
12885 makestr(&ssl_dh_key_file,s);
12888 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12889 if (!s[0] && ssl_dsa_cert_chain_file) {
12890 free(ssl_dsa_cert_chain_file);
12891 ssl_dsa_cert_chain_file = NULL;
12893 makestr(&ssl_dsa_cert_chain_file,s);
12896 case XYSSLDKFL: /* SSL/TLS DH Key File */
12897 if (!s[0] && ssl_dh_key_file) {
12898 free(ssl_dh_key_file);
12899 ssl_dh_key_file = NULL;
12901 makestr(&ssl_dh_key_file,s);
12904 case XYSSLDPFL: /* SSL/TLS DH Param File */
12905 if (!s[0] && ssl_dh_param_file) {
12906 free(ssl_dh_param_file);
12907 ssl_dh_param_file = NULL;
12909 makestr(&ssl_dh_param_file,s);
12912 case XYSSLCRL: /* SSL/TLS CRL File */
12913 if (!s[0] && ssl_crl_file) {
12914 free(ssl_crl_file);
12915 ssl_crl_file = NULL;
12917 makestr(&ssl_crl_file,s);
12920 case XYSSLVRFF: /* SSL/TLS Verify File */
12921 if (!s[0] && ssl_verify_file) {
12922 free(ssl_verify_file);
12923 ssl_verify_file = NULL;
12925 makestr(&ssl_verify_file,s);
12928 case XYSSLRND: /* SSL/TLS Random File */
12929 if (!s[0] && ssl_rnd_file) {
12930 free(ssl_rnd_file);
12931 ssl_rnd_file = NULL;
12933 makestr(&ssl_rnd_file,s);
12942 if (z == XYSSLVRFD)
12943 d= getenv("SSL_CERT_DIR");
12946 if ((y = cmdir("Directory",d,&s,xxstring)) < 0)
12949 ckstrncpy(line,s,LINBUFSIZ);
12952 if ((y = cmcfm()) < 0)
12956 if (!s[0] && ssl_crl_dir) {
12958 ssl_crl_dir = NULL;
12960 makestr(&ssl_crl_dir,s);
12964 if (!s[0] && ssl_verify_dir) {
12965 free(ssl_verify_dir);
12966 ssl_verify_dir = NULL;
12968 makestr(&ssl_verify_dir,s);
12974 case XYSSLCOK: /* SSL/TLS Certs-Ok flag */
12975 if ((y = seton(&ssl_certsok_flag)) < 0)
12978 case XYSSLDBG: /* SSL/TLS Debug flag */
12979 if ((y = seton(&ssl_debug_flag)) < 0)
12982 case XYSSLON: /* SSL/TLS Only flag */
12985 if ((y = seton(&ssl_only_flag)) < 0)
12989 if ((y = seton(&tls_only_flag)) < 0)
12994 case XYSSLVRB: /* SSL/TLS Verbose flag */
12995 if ((y = seton(&ssl_verbose_flag)) < 0)
12998 case XYSSLVRF: /* SSL/TLS Verify flag */
12999 if ((x = cmkey(sslvertab, nsslvertab,
13000 "SSL/TLS verify mode",
13001 "peer-cert",xxstring)) < 0)
13003 if ((y = cmcfm()) < 0)
13005 ssl_verify_flag = x;
13008 if ((y = seton(&ssl_dummy_flag)) < 0)
13011 case XYSSLCL: { /* SSL/TLS Cipher List */
13013 /* This code is used to generate a colon delimited */
13014 /* list of the ciphers currently in use to be used */
13015 /* as the default for cmtxt(). However, a better */
13016 /* default is simply the magic keyword "ALL". */
13017 CHAR def[1024] = "";
13018 if (ssl_con != NULL) {
13019 CHAR * p = NULL, *q = def;
13022 for (i = 0; ; i++) {
13023 p = (CHAR *) SSL_get_cipher_list(ssl_con,i);
13027 if (q+len+1 >= def+1024)
13035 #endif /* COMMENT */
13036 char * p = getenv("SSL_CIPHER");
13040 "Colon-delimited list of ciphers or ALL (case-sensitive)",
13047 makestr(&ssl_cipher_list,s);
13048 if (ssl_con == NULL) {
13049 SSL_library_init();
13050 ssl_ctx = (SSL_CTX *)
13051 SSL_CTX_new((SSL_METHOD *)TLSv1_method());
13052 if (ssl_ctx != NULL)
13053 ssl_con= (SSL *) SSL_new(ssl_ctx);
13056 SSL_set_cipher_list(ssl_con,ssl_cipher_list);
13063 #endif /* CK_SSL */
13067 return(success = 1);
13069 #endif /* CK_AUTHENTICATION */
13073 if ((x = cmkey(functab,nfunctab,"","diagnostics",xxstring)) < 0)
13076 case FUNC_DI: return(seton(&fndiags));
13077 case FUNC_ER: return(seton(&fnerror));
13078 default: return(-2);
13082 case XYSLEEP: /* SET SLEEP / PAUSE */
13083 if ((x = cmkey(sleeptab,1,"","cancellation",xxstring)) < 0)
13085 return(seton(&sleepcan));
13087 case XYCD: /* SET CD */
13088 if ((x = cmkey(cdtab,ncdtab,"","",xxstring)) < 0)
13091 case XYCD_H: { /* SET CD HOME */
13092 extern char * myhome;
13093 if ((y = cmdir("Directory name",zhome(),&s,xxstring)) < 0)
13095 makestr(&myhome,s);
13096 return(success = 1);
13098 case XYCD_M: /* SET CD MESSAGE */
13099 if ((x = cmkey(cdmsg,ncdmsg,"","",xxstring)) < 0)
13101 if (x == 2) { /* CD MESSAGE FILE */
13102 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
13108 #endif /* NOXFER */
13110 makestr(&cdmsgstr,s);
13111 makelist(cdmsgstr,cdmsgfile,8);
13112 return(success = 1);
13115 if ((y = cmcfm()) < 0) return(y); /* CD-MESSAGE ON/OFF */
13121 #endif /* NOXFER */
13122 return(success = 1);
13124 case XYCD_P: { /* SET CD PATH */
13125 extern char * ckcdpath;
13126 if ((x = cmtxt("CD PATH string","",&s,xxstring)) < 0)
13128 makestr(&ckcdpath,s);
13129 return(success = 1);
13135 case XYSTOP: /* STOP-BITS */
13136 if ((x = cmkey(stoptbl,2,"Stop bits for serial device","",
13139 if ((y = cmcfm()) < 0)
13141 if (x > 0 && x < 3) {
13144 if (network && istncomport()) {
13146 return(success = 1);
13148 #endif /* TN_COMPORT */
13150 return(success = 1);
13151 #else /* HWPARITY */
13153 #endif /* HWPARITY */
13156 #endif /* STOPBITS */
13159 extern int clsondisc;
13160 return(seton(&clsondisc));
13166 if ((x = cmkey(sertbl,nsertbl,
13167 "Serial device character size, parity, and stop bits",
13168 "8N1", xxstring)) < 0)
13170 ckstrncpy(line,atmbuf,LINBUFSIZ); /* Associated keyword string */
13172 if ((y = cmcfm()) < 0)
13174 ckstrncpy(line,sernam[x],LINBUFSIZ);
13176 if (s[0] != '8' && s[0] != '7') /* Char size */
13180 if (isupper(s[1])) /* Parity */
13181 s[1] = tolower(s[1]);
13182 if (s[2] != '1' && s[2] != '2') /* Stop bits */
13185 stopbits = s[2] - '0';
13186 if (z == 8) { /* 8 bits + parity (or not) */
13187 parity = 0; /* Set parity */
13188 hwparity = (s[1] == 'n') ? 0 : s[1];
13189 setcmask(8); /* Also set TERM BYTESIZE to 8 */
13190 } else { /* 7 bits plus parity */
13191 parity = (s[1] == 'n') ? 0 : s[1];
13193 setcmask(7); /* Also set TERM BYTESIZE to 7 */
13196 if (network && !istncomport())
13197 tnsettings(parity, stopbits);
13198 #endif /* TN_COMPORT */
13200 return(success = 1); /* from SET SERIAL */
13203 case XYOPTS: { /* SET OPTIONS */
13204 extern int setdiropts();
13205 extern int settypopts();
13207 extern int setpurgopts();
13208 #endif /* CKPURGE */
13209 if ((x = cmkey(optstab,noptstab,"for command","", xxstring)) < 0)
13214 return(setdelopts());
13215 #endif /* NOFRILLS */
13217 return(setdiropts());
13219 return(settypopts());
13222 return(setpurgopts());
13223 #endif /* CKPURGE */
13228 #endif /* NOLOCAL */
13232 return(seton(&q8flag));
13235 extern int asktimer;
13236 y = cmnum("Time limit for ASK command, seconds","0",10,&x,xxstring);
13238 return(setnum(&asktimer,x,y,32767));
13240 return(setnum(&asktimer,x,y,86400));
13244 extern int fackbug;
13245 return(seton(&fackbug));
13247 #endif /* NOXFER */
13250 return(seton(&hints));
13254 extern int oldeval;
13255 if ((x = cmkey(oldnew,2,"","", xxstring)) < 0)
13257 if ((y = cmcfm()) < 0)
13260 return(success = 1);
13266 extern int fackpath;
13267 return(seton(&fackpath));
13269 #endif /* NOXFER */
13272 extern int qnxportlock;
13273 return(seton(&qnxportlock));
13283 #endif /* NOCMDL */
13287 return(dochroot());
13288 #endif /* CKROOT */
13293 if ((x = cmkey(sexptab,3,"","", xxstring)) < 0)
13297 if ((x = cmkey(ooatab,3,"","automatic", xxstring)) < 0)
13299 if ((y = cmcfm()) < 0)
13306 if ((y = cmnum("Maximum recursion depth",
13307 "1000",10,&x,xxstring)) < 0)
13309 z = setnum(&sexpmaxdep,x,y,-1);
13312 if (sxresult) { /* Free old stack if allocated */
13313 for (i = 0; i < xx; i++)
13314 if (sxresult[i]) free(sxresult[i]);
13315 free((char *)sxresult);
13316 if (sxrlen) free((char *)sxrlen);
13323 return(seton(&sexptrunc));
13325 return(success = 1);
13327 #endif /* NOSEXPL */
13332 extern struct keytab gprtab[];
13334 if ((x = cmkey(gprtab,3,"","kermit", xxstring)) < 0)
13336 if ((y = cmcfm()) < 0)
13339 return(success = 1);
13341 #endif /* NEWFTP */
13345 return(dosetssh());
13346 #endif /* ANYSHH */
13348 #ifdef SFTP_BUILTIN
13350 return(dosetsftp());
13351 #endif /* SFTP_BUILTIN */
13355 if ((x = cmkey(locustab,nlocustab,"",
13363 if ((y = cmcfm()) < 0)
13365 if (x == 2 || x == 3) { /* AUTO or ASK */
13366 setautolocus(x - 1); /* Two forms of automatic locusing */
13367 /* setlocus(1,0); */ /* we're not changing the locus here */
13368 } else { /* LOCAL or REMOTE */
13369 setautolocus(0); /* No automatic Locus changing */
13370 setlocus(x,0); /* Set Locus as requested */
13372 return(success = 1);
13382 case XY_REN: /* SET RENAME */
13383 return(setrename());
13384 #endif /* NORENAME */
13385 #endif /* NOFRILLS */
13390 case XYEXTRN: /* SET EXTERNAL-PROTOCOL */
13391 return(setextern());
13392 #endif /* NOXFER */
13393 #endif /* CK_REDIR */
13394 #endif /* NOPUSH */
13397 case XYVAREV: /* SET VARIABLE-EVALUATION */
13398 return(setvareval());
13402 if ((x = cmcfm()) < 0) return(x);
13403 printf("Not implemented - %s\n",cmdbuf);
13404 return(success = 0);
13409 H U P O K -- Is Hangup OK?
13411 Issues a warning and gets OK from user depending on whether a connection
13412 seems to be open and what the SET EXIT WARNING setting is. Returns:
13413 0 if not OK to hang up or exit (i.e. user said No);
13415 Argument x is used to differentiate the EXIT command from SET LINE / HOST.
13418 hupok(x) int x; { /* Returns 1 if OK, 0 if not OK */
13420 extern int exithangup;
13424 if (batch) /* No warnings in batch */
13428 if (backgrd) /* No warnings in background */
13434 debug(F101,"hupok local","",local);
13436 if (!local) /* No warnings in remote mode */
13440 if (x == 0 && exithangup == 0) /* EXIT and EXIT HANGUP is OFF */
13443 debug(F101,"hupok x","",x);
13444 debug(F101,"hupok xitwarn","",xitwarn);
13445 debug(F101,"hupok network","",network);
13446 debug(F101,"hupok haveline","",haveline);
13448 if ((local && xitwarn) || /* Is a connection open? */
13449 (!x && xitwarn == 2)) { /* Or Always give warning on EXIT */
13456 /* A connection seems to be open but it can't possibly be */
13460 if (strcmp(ttname,"*"))
13461 ckmakmsg(warning,256,
13462 " A network connection to ",ttname,
13463 " might still be active.\n",NULL);
13466 " An incoming network connection might still be active.\n",
13469 } else { /* Serial connection */
13470 if (carrier == CAR_OFF) /* SET CARRIER OFF */
13471 needwarn = 0; /* so we don't care about carrier. */
13472 else if ((y = ttgmdm()) >= 0) /* else, get modem signals */
13473 needwarn = (y & BM_DCD); /* Check for carrier */
13474 else /* If we can't get modem signals... */
13475 needwarn = (ttchk() >= 0);
13476 /* A connection seems to be open but it can't possibly be */
13477 if (!haveline || !exithangup)
13480 ckmakmsg(warning,256,
13481 " A serial connection might still be active on ",
13482 ttname,".\n",NULL);
13485 /* If a warning was issued, get user's permission to EXIT. */
13487 if (needwarn || (!x && xitwarn == 2
13493 ckstrncpy(warning, "No active connections", 256);
13496 printf("%s",warning);
13497 z = getyesno(x ? "OK to close? " : "OK to exit? ",0);
13498 debug(F101,"hupok getyesno","",z);
13502 x ? "OK to close? " : "OK to exit? ",
13507 debug(F101,"hupok uq_ok","",z);
13509 #endif /* COMMENT */
13517 shoctl() { /* SHOW CONTROL-PREFIXING */
13524 "\ncontrol quote = %d, applied to (0 = unprefixed, 1 = prefixed):\n\n",
13527 #ifndef UNPREFIXZERO
13529 if (protocol == PROTO_K) /* Zero can't be unprefixed */
13530 ctlp[0] = 1; /* for Kermit */
13531 #endif /* UNPREFIXZERO */
13533 for (i = 0; i < 16; i++) {
13534 printf(" %3d: %d %3d: %d ",i,ctlp[i], i+16, ctlp[i+16]);
13536 printf(" 127: %d",ctlp[127]);
13539 printf(" %3d: %d %3d: %d ",i+128,ctlp[i+128], i+144, ctlp[i+144]);
13540 if (i == 15) printf(" 255: %d",ctlp[255]);
13544 #ifndef UNPREFIXZERO
13548 #endif /* UNPREFIXZERO */
13550 #endif /* CK_SPEED */
13555 shodbl() { /* SHOW DOUBLE/IGNORE */
13558 printf("\nSET SEND DOUBLE characters:\n");
13559 for (i = 0; i < 255; i++) {
13568 printf("\nSET RECEIVE IGNORE characters:\n");
13569 for (i = 0; i < 255; i++) {
13578 #endif /* CKXXCHAR */
13580 #endif /* NOXFER */
13581 #endif /* NOSHOW */
13586 Rexx command. Note, this is not OS/2-specific, because Rexx also runs
13587 on other systems where C-Kermit also runs, like the Amiga.
13589 #define REXBUFL 100 /* Change this if neccessary */
13590 char rexxbuf[REXBUFL] = { '\0' }; /* Rexx's return value (string) */
13597 if ((x = cmtxt("Rexx command","",&rexxcmd,xxstring)) < 0)
13602 printf("?Sorry, command disabled.\r\n");
13603 return(success = 0);
13607 /* Don't let this be set remotely */
13608 if (apcactive == APC_LOCAL ||
13609 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
13610 return(success = 0);
13611 #endif /* CK_APC */
13613 ckstrncpy(line,rexxcmd,LINBUFSIZ);
13616 return(os2rexx(rexxcmd,rexxbuf,REXBUFL));
13618 printf("Sorry, nothing happens.\n");
13619 return(success = 0);
13622 #endif /* CK_REXX */
13623 #endif /* NOPUSH */
13627 /* Dummy write record to connection log */