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, 2004,
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 */
90 extern CKFLOAT floatval; /* (see isfloat()) */
96 char editor[CKMAXPATH + 1] = "edit";
98 char editor[CKMAXPATH + 1] = { NUL, NUL };
100 char editopts[128] = { NUL, NUL };
101 char editfile[CKMAXPATH + 1] = { NUL, NUL };
103 char browser[CKMAXPATH + 1] = { NUL, NUL };
104 char browsopts[128] = { NUL, NUL };
105 char browsurl[4096] = { NUL, NUL };
107 #endif /* NOFRILLS */
113 extern int hints, xcmdsrc;
116 char * k4pwprompt = NULL; /* Kerberos 4 password prompt */
117 char * k4prprompt = NULL; /* Kerberos 4 principal prompt */
118 char * k5pwprompt = NULL; /* Kerberos 5 password prompt */
119 char * k5prprompt = NULL; /* Kerberos 5 principal prompt */
120 #endif /* CK_KERBEROS */
122 char * srppwprompt = NULL;
125 extern char * ckprompt, * ikprompt; /* Default prompt */
126 extern xx_strp xxstring;
128 extern char * cdmsgfile[], * cdmsgstr;
131 local, server, success, dest, sleepcan, inserver, flow, autoflow, binary,
132 parity, escape, what, turn, duplex, backgrd, hwparity, stopbits, turnch,
133 mdmtyp, network, quiet, nettype, carrier, debses, debtim, cdtimo, nlangs,
134 bgset, pflag, msgflg, cmdmsk, xsuspend, techo, pacing, xitwarn, xitsta,
135 outesc, cmd_cols, cmd_rows, ckxech, xaskmore, haveline, didsetlin, isguest,
136 mdmsav, clearrq, saveask;
138 extern int reliable, setreliable, matchdot, matchfifo, dir_dots;
142 #endif /* NOSERVER */
146 #endif /* IKSDCONF */
149 #endif /* TCPSOCKET */
151 char * tn_pr_uid = NULL;
153 extern int exitonclose;
157 extern struct keytab kverbs[];
158 #endif /* NOKVERBS */
160 extern int ttnproto; /* Network protocol */
162 extern char *ccntab[]; /* Names of control chars */
165 extern int apcactive, apcstatus;
169 extern int secho; /* Whether SCRIPT cmd should echo */
170 #endif /* NOSCRIPT */
173 extern char *atmbuf, *atxbuf;
175 extern char atmbuf[], atxbuf[];
180 extern char uidbuf[];
181 extern int sl_uid_saved;
182 int DeleteStartupFile = 0;
184 extern int cmdlvl; /* Overall command level */
187 _PROTOTYP( static int parsdir, (int) );
188 char prmbuf[PWBUFL+1] = { NUL, NUL };
189 int fndiags = 1; /* Function diagnostics on/off */
190 int fnerror = 1; /* Function error treatment */
193 extern int *count, *takerr, *merror, *inpcas;
195 extern int count[], takerr[], merror[], inpcas[];
197 extern int mecho; /* Macro echo */
198 extern long ck_alarm;
199 extern char alrm_date[], alrm_time[];
205 extern int bigsbsiz, bigrbsiz; /* Packet buffers */
207 extern long speed; /* Terminal speed */
209 extern char ttname[]; /* Communication device name */
210 extern char myhost[] ;
211 extern char inidir[]; /* Ini File directory */
214 extern KEY *keymap; /* Character map for SET KEY (1:1) */
215 extern MACRO *macrotab; /* Macro map for SET KEY (1:string) */
216 #endif /* NOSETKEY */
218 int wideresult; /* For wide OS/2 scan codes/cmnum() */
223 extern int tt_scrsize[]; /* Scrollback buffer Sizes */
227 /* Printer settings */
229 extern char * printername; /* NULL if printer not redirected */
230 extern int printpipe;
231 extern int noprinter;
234 char * printterm = NULL;
235 char * printsep = NULL;
238 int printbidi = 0; /* SET BPRINTER (bidirectional) */
239 long pportspeed = 0L; /* Bidirection printer port speed, */
240 int pportparity = 0; /* parity, */
241 int pportflow = FLO_KEEP; /* and flow control */
244 extern int txt2ps; /* Text2PS conversion? */
245 extern int ps_width, ps_length; /* Text2PS dimensions */
247 #endif /* PRINTSWI */
250 extern int tcp_avail; /* Nonzero if TCP/IP is available */
252 extern int dnet_avail; /* Ditto for DECnet */
255 extern int slat_avail;
256 #endif /* SUPERLAT */
259 static struct keytab logintab[] = {
260 { "password", LOGI_PSW, CM_INV },
261 { "prompt", LOGI_PRM, CM_INV },
262 { "userid", LOGI_UID, 0 }
266 /* system-independent character sets, defined in ckcxla.[ch] */
267 extern struct csinfo tcsinfo[];
268 extern struct langinfo langs[];
270 /* Other character-set related variables */
271 extern int tcharset, tslevel, language;
274 /* File-transfer variable declarations */
279 #endif /* CK_AUTODL */
283 extern char * getpath[];
284 #endif /* NOSERVER */
286 extern struct ck_p ptab[];
288 extern CHAR sstate; /* Protocol start state */
289 extern CHAR myctlq; /* Control-character prefix */
290 extern CHAR myrptq; /* Repeat-count prefix */
292 extern int protocol, size, spsiz, spmax, urpsiz, srvtim, srvcdmsg, slostart,
293 srvdis, xfermode, ckdelay, keep, maxtry, unkcs, bctr, ebqflg, swcapr,
294 wslotr, lscapr, lscapu, spsizr, rptena, rptmin, docrc, xfrcan, xfrchr,
295 xfrnum, xfrbel, xfrint, srvping, g_xfermode, xfrxla;
299 #endif /* PIPESEND */
301 #ifdef CKXXCHAR /* DOUBLE / IGNORE char table */
302 extern int dblflag, ignflag, dblchar;
304 #endif /* CKXXCHAR */
307 extern short ctlp[]; /* Control-prefix table */
308 extern int prefixing;
309 static struct keytab pfxtab[] = {
311 "cautious", PX_CAU, 0,
312 "minimal", PX_WIL, 0,
315 #endif /* CK_SPEED */
318 /* Declarations from cmd package */
321 extern char *cmdbuf; /* Command buffer */
325 extern char cmdbuf[]; /* Command buffer */
326 extern char line[]; /* Character buffer for anything */
327 extern char tmpbuf[];
330 /* From main ckuser module... */
332 extern char *tp, *lp; /* Temporary buffer */
334 extern int tlevel; /* Take Command file level */
337 extern int sessft; /* Session-log file type */
338 extern int slogts; /* Session-log timestamps on/off */
341 char * tempdir = NULL;
344 int vms_msgs = 1; /* SET MESSAGES */
348 /* Keyword tables for SET commands */
351 struct keytab ctltab[] = {
352 "prefixed", 1, 0, /* Note, the values are important. */
355 #endif /* CK_SPEED */
357 static struct keytab oldnew[] = {
364 struct keytab matchtab[] = {
365 { "dotfile", MCH_DOTF, 0 },
366 { "fifo", MCH_FIFO, 0 }
368 int nmatchtab = (sizeof(matchtab) / sizeof(struct keytab));
371 static struct keytab functab[] = {
372 "diagnostics", FUNC_DI, 0,
375 static int nfunctab = (sizeof(functab) / sizeof(struct keytab));
377 struct keytab outptab[] = { /* SET OUTPUT parameters */
378 "pacing", 0, 0, /* only one so far... */
379 "special-escapes", 1, 0
381 int noutptab = (sizeof(outptab) / sizeof(struct keytab)); /* How many */
384 struct keytab chktab[] = { /* Block check types */
385 "1", 1, 0, /* 1 = 6-bit checksum */
386 "2", 2, 0, /* 2 = 12-bit checksum */
387 "3", 3, 0, /* 3 = 16-bit CRC */
388 "4", 4, CM_INV, /* Same as B */
389 "blank-free-2", 4, 0 /* B = 12-bit checksum, no blanks */
392 struct keytab rpttab[] = { /* SET REPEAT */
393 "counts", 0, 0, /* On or Off */
395 "minimum", 1, 0, /* Threshhold */
397 "prefix", 2, 0 /* Repeat-prefix character value */
401 /* For SET [ MODEM ] CARRIER, and also for SET DIAL CONNECT */
403 struct keytab crrtab[] = {
404 "automatic", CAR_AUT, 0, /* 2 */
405 "off", CAR_OFF, 0, /* 0 */
406 "on", CAR_ON, 0 /* 1 */
411 struct keytab ooatab[] = { /* On/Off/Auto table */
412 "automatic", SET_AUTO, 0, /* 2 */
413 "off", SET_OFF, 0, /* 0 */
414 "on", SET_ON, 0 /* 1 */
417 struct keytab ooktab[] = { /* On/Off/Ask table */
419 "off", SET_OFF, 0, /* 0 */
420 "on", SET_ON, 0 /* 1 */
423 struct keytab qvtab[] = { /* Quiet/Verbose table */
437 struct keytab dbgtab[] = {
438 "linelength", DEB_LEN, CM_INV,
441 "session", DEB_SES, 0,
442 "timestamps", DEB_TIM, 0
444 int ndbg = (sizeof(dbgtab) / sizeof(struct keytab));
447 /* Transmission speeds */
449 #ifdef TTSPDLIST /* Speed table constructed at runtime . . . */
451 struct keytab * spdtab = NULL;
456 Note, the values are encoded in cps rather than bps because 19200 and higher
457 are too big for some ints. All but 75bps are multiples of ten. Result of
458 lookup in this table must be multiplied by 10 to get actual speed in bps.
459 If this number is 70, it must be changed to 75. If it is 888, this means
462 The values are generic, rather than specific to UNIX. We can't use B75,
463 B1200, B9600, etc, because non-UNIX versions of C-Kermit will not
464 necessarily have these symbols defined. The BPS_xxx symbols are
465 Kermit-specific, and are defined in ckcdeb.h or on the CC command line.
467 Like all other keytabs, this one must be in "alphabetical" order,
468 rather than numeric order.
470 struct keytab spdtab[] = {
475 #endif /* BPS_115K */
497 #endif /* BPS_230K */
505 #endif /* BPS_3600 */
510 "460800", 46080, 0, /* Need 32 bits for this... */
511 #endif /* BPS_460K */
522 #endif /* BPS_7200 */
527 "75/1200",888, 0, /* Code "888" for split speed */
528 #endif /* BPS_7512 */
533 "921600", 92160,0, /* Need 32 bits for this... */
534 #endif /* BPS_921K */
537 int nspd = (sizeof(spdtab) / sizeof(struct keytab)); /* How many speeds */
538 #endif /* TTSPDLIST */
541 struct keytab tnspdtab[] = { /* RFC 2217 TELNET COMPORT Option */
542 "115200", 11520, 0, /* (add any other defined speeds) */
557 int ntnspd = (sizeof(tnspdtab) / sizeof(struct keytab)); /* How many speeds */
558 #endif /* TN_COMPORT */
562 extern struct keytab lngtab[]; /* Languages for SET LANGUAGE */
567 /* Duplex keyword table */
569 struct keytab dpxtab[] = {
577 struct keytab cxtypesw[] = {
579 "/decnet", CXT_DECNET, 0,
581 "/direct-serial", CXT_DIRECT, 0,
587 #endif /* SUPERLAT */
589 "/modem", CXT_MODEM, 0,
591 "/named-pipe", CXT_NPIPE, 0,
594 "/netbios", CXT_NETBIOS, 0,
596 "/remote", CXT_REMOTE, 0,
598 "/tcpip", CXT_TCPIP, 0,
599 #endif /* TCPSOCKET */
605 int ncxtypesw = (sizeof(cxtypesw) / sizeof(struct keytab));
608 struct keytab tnflotab[] = { /* SET FLOW-CONTROL keyword table */
609 "dtr/cd", FLO_DTRC, 0, /* for RFC 2217 Telnet COMPORT */
610 "dtr/cts", FLO_DTRT, 0,
613 "rts/cts", FLO_RTSC, 0,
614 "xon/xoff", FLO_XONX, 0
616 int ntnflo = (sizeof(tnflotab) / sizeof(struct keytab));
617 #endif /* TN_COMPORT */
619 struct keytab flotab[] = { /* SET FLOW-CONTROL keyword table */
620 "automatic", FLO_AUTO, CM_INV, /* Not needed any more */
622 "dtr/cd", FLO_DTRC, 0,
623 #endif /* CK_DTRCD */
625 "dtr/cts", FLO_DTRT, 0,
626 #endif /* CK_DTRCTS */
630 "rts/cts", FLO_RTSC, 0,
631 #endif /* CK_RTSCTS */
633 "xon/xoff", FLO_XONX, 0,
637 int nflo = (sizeof(flotab) / sizeof(struct keytab)) - 1;
639 /* Handshake characters */
641 struct keytab hshtab[] = {
647 "none", 999, 0, /* (can't use negative numbers) */
651 int nhsh = (sizeof(hshtab) / sizeof(struct keytab));
654 static struct keytab sfttab[] = { /* File types for SET SESSION-LOG */
655 "ascii", XYFT_T, CM_INV,
659 "timestamped-text", 999, 0
661 static int nsfttab = (sizeof(sfttab) / sizeof(struct keytab));
666 #ifdef NETCONN /* Networks directory depends */
667 int nnetdir = 0; /* on DIAL code -- fix later... */
668 char *netdir[MAXDDIR+2];
671 _PROTOTYP( static int setdial, (int) );
672 _PROTOTYP( static int setdcd, (void) );
673 _PROTOTYP( static int cklogin, (void) );
677 extern int tbmodel; /* Telebit model ID */
678 #endif /* OLDTBCODE */
679 #endif /* MINIDIAL */
681 extern MDMINF *modemp[]; /* Pointers to modem info structs */
682 extern struct keytab mdmtab[]; /* Modem types (in module ckudia.c) */
683 extern int nmdm; /* Number of them */
685 _PROTOTYP(static int dialstr,(char **, char *));
687 extern int dialhng, dialtmo, dialksp, dialdpy, dialmhu, dialec, dialdc;
688 extern int dialrtr, dialint, dialudt, dialsrt, dialrstr, mdmwaitd;
689 extern int mdmspd, dialfc, dialmth, dialesc, dialfld, dialidt, dialpace;
690 extern int mdmspk, mdmvol, dialtest;
692 int dialcvt = 2; /* DIAL CONVERT-DIRECTORY */
693 int dialcnf = 0; /* DIAL CONFIRMATION */
694 int dialcon = 2; /* DIAL CONNECT */
695 int dialcq = 0; /* DIAL CONNECT AUTO quiet/verbose */
696 extern long dialmax, dialcapas;
699 extern char *dialini, *dialmstr, *dialmprmt, *dialdir[], *dialcmd, *dialnpr,
700 *dialdcon, *dialdcoff, *dialecon, *dialecoff, *dialhcmd, *dialx3,
701 *dialhwfc, *dialswfc, *dialnofc, *dialtone, *dialpulse, *dialname, *diallac;
702 extern char *diallcc, *dialixp, *dialixs, *dialldp, *diallds, *dialtfp,
703 *dialpxi, *dialpxo, *dialsfx, *dialaaon, *dialaaoff;
704 extern char *diallcp, *diallcs, *dialini2, *dialmac;
705 extern char *dialspoff, *dialspon, *dialvol1, *dialvol2, *dialvol3;
707 char *dialtocc[MAXTPCC] = { NULL, NULL };
709 char *dialpucc[MAXTPCC] = { NULL, NULL };
712 char *dialtfc[MAXTOLLFREE] = {
713 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
717 char *dialpxx[MAXPBXEXCH] = {
718 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
722 char *diallcac[MAXLOCALAC] = {
723 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
724 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
725 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
726 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
730 static struct keytab drstrtab[] = {
731 "international", 5, 0,
733 "long-distance", 4, 0,
737 static struct keytab dcnvtab[] = {
743 struct keytab setmdm[] = {
744 "capabilities", XYDCAP, 0,
745 "carrier-watch", XYDMCD, 0,
746 "command", XYDSTR, 0,
747 "compression", XYDDC, CM_INV,
748 "data-compression", XYDDC, 0,
749 "dial-command", XYDDIA, 0,
750 "error-correction", XYDEC, 0,
751 "escape-character", XYDESC, 0,
752 "flow-control", XYDFC, 0,
753 "hangup-method", XYDMHU, 0,
755 "kermit-spoof", XYDKSP, 0,
757 "maximum-speed", XYDMAX, 0,
759 "speaker", XYDSPK, 0,
760 "speed-matching", XYDSPD, 0,
764 int nsetmdm = (sizeof(setmdm) / sizeof(struct keytab));
766 struct keytab voltab[] = {
772 struct keytab mdmcap[] = {
773 "at-commands", CKD_AT, 0,
774 "compression", CKD_DC, 0,
775 "dc", CKD_DC, CM_INV,
776 "ec", CKD_EC, CM_INV,
777 "error-correction", CKD_EC, 0,
778 "hardware-flow", CKD_HW, 0,
779 "hwfc", CKD_HW, CM_INV,
780 "itu", CKD_V25, CM_INV,
781 "kermit-spoof", CKD_KS, 0,
782 "ks", CKD_KS, CM_INV,
783 "sb", CKD_SB, CM_INV,
784 "software-flow", CKD_SW, 0,
785 "speed-buffering", CKD_SB, 0,
786 "swfc", CKD_SW, CM_INV,
787 "tb", CKD_TB, CM_INV,
788 "telebit", CKD_TB, 0,
789 "v25bis-commands", CKD_V25, 0
791 int nmdmcap = (sizeof(mdmcap) / sizeof(struct keytab));
793 #ifdef COMMENT /* SET ANSWER not implemented yet */
794 static struct keytab answertab[] = {
795 { "caller-id", XYA_CID, 0 };
796 { "rings", XYA_RNG, 0 };
799 static int nanswertab = (sizeof(answertab) / sizeof(struct keytab)) - 1;
802 struct keytab dialtab[] = { /* SET DIAL table */
803 "area-code", XYDLAC, 0, /* Also still includes items */
804 "compression", XYDDC, CM_INV, /* that were moved to SET MODEM, */
805 "confirmation", XYDCNF, 0, /* but they are CM_INVisible... */
806 "connect", XYDCON, 0,
807 "convert-directory",XYDCVT, 0,
808 "country-code", XYDLCC, 0,
809 "dial-command", XYDDIA, CM_INV,
810 "directory", XYDDIR, 0,
811 "display", XYDDPY, 0,
812 "escape-character", XYDESC, CM_INV,
813 "error-correction", XYDEC, CM_INV,
814 "flow-control", XYDFC, CM_INV,
815 "force-long-distance", XYDFLD, 0,
817 "ignore-dialtone", XYDIDT, 0,
818 "interval", XYDINT, 0,
819 "in", XYDINI, CM_INV|CM_ABR,
820 "init-string", XYDINI, CM_INV,
821 "intl-prefix", XYDIXP, 0,
822 "intl-suffix", XYDIXS, 0,
824 "kermit-spoof", XYDKSP, CM_INV,
826 "lc-area-codes", XYDLLAC, 0,
827 "lc-prefix", XYDLCP, 0,
828 "lc-suffix", XYDLCS, 0,
829 "ld-prefix", XYDLDP, 0,
830 "ld-suffix", XYDLDS, 0,
831 "local-area-code", XYDLAC, CM_INV,
832 "local-prefix", XYDLCP, CM_INV,
833 "local-suffix", XYDLCS, CM_INV,
834 "m", XYDMTH, CM_INV|CM_ABR,
836 "macro", XYDMAC, 0, /* 195 */
839 "me", XYDMTH, CM_INV|CM_ABR,
842 "mnp-enable", XYDMNP, CM_INV, /* obsolete but still accepted */
844 "modem-hangup", XYDMHU, CM_INV,
847 "pbx-exchange", XYDPXX, 0,
848 "pbx-inside-prefix",XYDPXI, 0,
849 "pbx-outside-prefix",XYDPXO, 0,
851 "pulse-countries", XYDPUCC, 0,
852 "restrict", XYDRSTR, 0,
853 "retries", XYDRTM, 0,
855 "speed-matching", XYDSPD, CM_INV,
856 "string", XYDSTR, CM_INV,
859 "timeout", XYDTMO, 0,
860 "tf-area-code", XYDTFC, CM_INV,
861 "tf-prefix", XYDTFP, CM_INV,
862 "toll-free-area-code",XYDTFC,0,
863 "toll-free-prefix", XYDTFP, 0,
864 "tone-countries", XYDTOCC, 0
866 int ndial = (sizeof(dialtab) / sizeof(struct keytab));
869 struct keytab mdmhang[] = {
871 "modem-command", 1, 0,
872 "rs232-signal", 0, 0,
873 "v24-signal", 0, CM_INV
877 static struct keytab mdmcmd[] = {
878 "autoanswer", XYDS_AN, 0, /* autoanswer */
879 "compression", XYDS_DC, 0, /* data compression */
880 "dial-mode-prompt", XYDS_MP, 0, /* dial mode prompt */
881 "dial-mode-string", XYDS_MS, 0, /* dial mode string */
882 "error-correction", XYDS_EC, 0, /* error correction */
883 "hangup-command", XYDS_HU, 0, /* hangup command */
884 "hardware-flow", XYDS_HW, 0, /* hwfc */
885 "ignore-dialtone", XYDS_ID, 0, /* ignore dialtone */
886 "init-string", XYDS_IN, 0, /* init string */
887 "no-flow-control", XYDS_NF, 0, /* no flow control */
888 "predial-init", XYDS_I2, 0, /* last-minute setup commands */
889 "pulse", XYDS_DP, 0, /* pulse */
890 "software-flow", XYDS_SW, 0, /* swfc */
891 "speaker", XYDS_SP, 0, /* Speaker */
892 "tone", XYDS_DT, 0, /* tone */
893 "volume", XYDS_VO, 0 /* Volume */
895 static int nmdmcmd = (sizeof(mdmcmd) / sizeof(struct keytab));
897 struct keytab dial_fc[] = {
900 "rts/cts", FLO_RTSC, 0,
901 "xon/xoff", FLO_XONX, 0
904 struct keytab dial_m[] = { /* DIAL METHOD */
906 "default", XYDM_D, 0,
910 int ndial_m = (sizeof(dial_m)/sizeof(struct keytab));
914 struct keytab tapitab[] = { /* Top-Level Microsoft TAPI */
915 "configure-line", XYTAPI_CFG, 0,
916 "dialing-properties", XYTAPI_DIAL, 0
918 int ntapitab = (sizeof(tapitab)/sizeof(struct keytab));
920 struct keytab settapitab[] = { /* SET Microsoft TAPI */
921 "inactivity-timeout", XYTAPI_INA, 0,
922 "line", XYTAPI_LIN, 0,
923 "location", XYTAPI_LOC, 0,
924 "manual-dialing", XYTAPI_MAN, 0,
925 "modem-dialing", XYTAPI_PASS, 0,
926 "modem-lights", XYTAPI_LGHT, 0,
927 "phone-number-conversions", XYTAPI_CON, 0,
928 "port", XYTAPI_LIN, CM_INV,
929 "post-dial-terminal", XYTAPI_PST, 0,
930 "pre-dial-terminal", XYTAPI_PRE, 0,
931 "use-windows-configuration", XYTAPI_USE, 0,
932 "wait-for-credit-card-tone", XYTAPI_BNG, 0
934 int nsettapitab = (sizeof(settapitab)/sizeof(struct keytab));
936 struct keytab * tapiloctab = NULL; /* Microsoft TAPI Locations */
938 extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
939 extern int ntapiline;
940 extern int tttapi; /* TAPI in use */
941 extern int tapipass; /* TAPI Passthrough mode */
942 extern int tapiconv; /* TAPI Conversion mode */
943 extern int tapilights;
944 extern int tapipreterm;
945 extern int tapipostterm;
946 extern int tapimanual;
947 extern int tapiinactivity;
949 extern int tapiusecfg;
955 struct keytab wildtab[] = { /* SET WILDCARD-EXPANSION */
959 struct keytab wdottab[] = { /* cont'd */
960 "/match-dot-files", 1, 0,
961 "/no-match-dot-files", 0, 0
963 extern int wildxpand;
968 extern struct keytab netcmd[], netkey[];
969 extern int nnets, nnetkey;
971 extern struct keytab tcpopt[];
973 #endif /* TCPSOCKET */
975 char pipename[PIPENAML+1] = { NUL, NUL };
978 extern unsigned char NetBiosName[];
979 #endif /* CK_NETBIOS */
983 struct keytab x25tab[] = {
984 "call-user-data", XYUDAT, 0,
985 "closed-user-group", XYCLOS, 0,
986 "reverse-charge", XYREVC, 0
988 int nx25 = (sizeof(x25tab) / sizeof(struct keytab));
991 struct keytab padx3tab[] = {
992 "break-action", PAD_BREAK_ACTION, 0,
993 "break-character", PAD_BREAK_CHARACTER, 0,
994 "character-delete", PAD_CHAR_DELETE_CHAR, 0,
995 "cr-padding", PAD_PADDING_AFTER_CR, 0,
996 "discard-output", PAD_SUPPRESSION_OF_DATA, 0,
998 "editing", PAD_EDITING, 0,
999 "escape", PAD_ESCAPE, 0,
1000 "forward", PAD_DATA_FORWARD_CHAR, 0,
1001 "lf-padding", PAD_PADDING_AFTER_LF, 0,
1002 "lf-insert", PAD_LF_AFTER_CR, 0,
1003 "line-delete", PAD_BUFFER_DELETE_CHAR, 0,
1004 "line-display", PAD_BUFFER_DISPLAY_CHAR, 0,
1005 "line-fold", PAD_LINE_FOLDING, 0,
1006 "pad-flow-control", PAD_FLOW_CONTROL_BY_PAD, 0,
1007 "service-signals", PAD_SUPPRESSION_OF_SIGNALS, 0,
1008 "timeout", PAD_DATA_FORWARD_TIMEOUT, 0,
1009 /* Speed is read-only */
1010 "transmission-rate", PAD_LINE_SPEED, 0,
1011 "user-flow-control", PAD_FLOW_CONTROL_BY_USER, 0
1013 int npadx3 = (sizeof(padx3tab) / sizeof(struct keytab));
1018 static struct keytab vbtab[] = {
1022 #endif /* OS2ORUNIX */
1025 int nvb = (sizeof(vbtab) / sizeof(struct keytab));
1029 static struct keytab syslogtab[] = {
1031 "commands", SYSLG_CM, 0,
1032 "connection", SYSLG_AC, 0,
1033 "debug", SYSLG_DB, 0,
1034 "dial", SYSLG_DI, 0,
1035 "file-access", SYSLG_FA, 0,
1036 "file-create", SYSLG_FC, 0,
1037 "login", SYSLG_LI, 0,
1038 "none", SYSLG_NO, 0,
1039 "protocol", SYSLG_PR, 0
1041 int nsyslog = (sizeof(syslogtab) / sizeof(struct keytab));
1042 #endif /* CKSYSLOG */
1044 /* Parity keyword table */
1046 struct keytab partbl[] = {
1050 #endif /* HWPARITY */
1056 int npar = (sizeof(partbl) / sizeof(struct keytab));
1059 struct keytab hwpartbl[] = {
1060 /* Add mark and space if needed and possible */
1071 int nhwpar = (sizeof(hwpartbl) / sizeof(struct keytab)) - 1;
1072 #endif /* HWPARITY */
1076 struct keytab onoff[] = {
1081 #define XYCD_M 0 /* CD MESSAGE */
1082 #define XYCD_P 1 /* CD PATH */
1083 #define XYCD_H 2 /* CD HOME */
1085 struct keytab cdtab[] = {
1087 "message", XYCD_M, 0,
1090 int ncdtab = (sizeof(cdtab) / sizeof(struct keytab));
1092 struct keytab cdmsg[] = {
1097 int ncdmsg = (sizeof(cdmsg) / sizeof(struct keytab));
1100 struct keytab xittab[] = { /* SET EXIT */
1101 "hangup", 3, 0, /* ...HANGUP */
1102 "on-disconnect", 2, 0, /* ...ON-DISCONNECT */
1103 "status", 0, 0, /* ...STATUS */
1104 "warning", 1, 0 /* ...WARNING */
1106 int nexit = (sizeof(xittab) / sizeof(struct keytab));
1108 struct keytab xitwtab[] = { /* SET EXIT WARNING */
1109 "always", 2, 0, /* even when not connected */
1110 "off", 0, 0, /* no warning */
1111 "on", 1, 0 /* when connected */
1113 int nexitw = (sizeof(xitwtab) / sizeof(struct keytab));
1115 struct keytab rltab[] = {
1116 "local", 1, 0, /* ECHO values */
1121 int nrlt = (sizeof(rltab) / sizeof(struct keytab));
1123 /* Incomplete File Disposition table */
1125 struct keytab ifdtab[] = {
1126 "discard", SET_OFF, 0,
1130 struct keytab ifdatab[] = {
1131 "auto", SET_AUTO, 0,
1132 "discard", SET_OFF, 0,
1136 char * ifdnam[] = { "discard", "keep", "auto" };
1138 /* SET TAKE parameters table */
1140 struct keytab taktab[] = {
1143 "off", 2, CM_INV, /* For compatibility */
1144 "on", 3, CM_INV /* with MS-DOS Kermit... */
1151 struct keytab suftab[] = { /* (what to do with) STARTUP-FILE */
1155 #endif /* COMMENT */
1157 /* SET MACRO parameters table */
1159 struct keytab smactab[] = {
1167 struct keytab scrtab[] = {
1170 #endif /* NOSCRIPT */
1172 /* SET COMMAND table */
1174 /* SET COMMAND items... */
1176 #define SCMD_BSZ 0 /* BYTESIZE */
1177 #define SCMD_RCL 1 /* RECALL */
1178 #define SCMD_RTR 2 /* RETRY */
1179 #define SCMD_QUO 3 /* QUOTING */
1180 #define SCMD_COL 4 /* COLOR */
1181 #define SCMD_HIG 5 /* HEIGHT */
1182 #define SCMD_WID 6 /* WIDTH */
1183 #define SCMD_CUR 7 /* CURSOR-POSITION */
1184 #define SCMD_SCR 8 /* SCROLLBACK */
1185 #define SCMD_MOR 9 /* MORE-PROMPTING */
1186 #define SCMD_INT 10 /* INTERRUPTION */
1187 #define SCMD_ADL 11 /* AUTODOWNLOAD */
1188 #define SCMD_STA 12 /* STATUSLINE */
1189 #define SCMD_DBQ 13 /* DOUBLEQUOTING */
1190 #define SCMD_CBR 14 /* CBREAK */
1191 #define SCMD_BFL 15 /* BUFFER-SIZE (not used) */
1193 static struct keytab scmdtab[] = {
1195 "autodownload", SCMD_ADL, 0,
1196 #endif /* CK_AUTODL */
1199 To implement this requires that we change CMDBL and ATMBL
1200 from compile-time symbols to runtime variables. Not a big deal,
1201 but not trivial either.
1203 "buffer-size", SCMD_BFL, 0,
1204 #endif /* COMMENT */
1205 "bytesize", SCMD_BSZ, 0,
1206 "cbreak", SCMD_CBR, CM_INV,
1208 "color", SCMD_COL, 0,
1209 "cursor-position", SCMD_CUR, 0,
1211 #ifdef DOUBLEQUOTING
1212 "doublequoting", SCMD_DBQ, 0,
1213 #endif /* DOUBLEQUOTING */
1214 "height", SCMD_HIG, 0,
1215 "interruption", SCMD_INT, 0,
1216 "more-prompting", SCMD_MOR, 0,
1217 "quoting", SCMD_QUO, 0,
1219 "recall-buffer-size", SCMD_RCL, 0,
1220 #endif /* CK_RECALL */
1222 "retry", SCMD_RTR, 0,
1223 #endif /* CK_RECALL */
1226 "scrollback", SCMD_SCR, 0,
1227 "statusline", SCMD_STA, 0,
1228 #endif /* ONETERMUPD */
1230 "width", SCMD_WID, 0
1232 static int nbytt = (sizeof(scmdtab) / sizeof(struct keytab));
1235 /* Server parameters table */
1236 static struct keytab srvtab[] = {
1237 "cd-message", XYSERC, 0,
1238 "display", XYSERD, 0,
1239 "get-path", XYSERP, 0,
1240 "idle-timeout", XYSERI, 0,
1241 "keepalive", XYSERK, 0,
1243 "timeout", XYSERT, 0
1245 static int nsrvt = (sizeof(srvtab) / sizeof(struct keytab));
1246 #endif /* NOSERVER */
1248 static struct keytab sleeptab[] = { /* SET SLEEP table */
1249 "cancellation", 0, 0
1252 static struct keytab tstab[] = { /* SET TRANSFER/XFER table */
1255 "cancellation", XYX_CAN, 0,
1258 "character-set", XYX_CSE, 0,
1259 #endif /* NOCSETS */
1261 "crc-calculation", XYX_CRC, 0,
1263 "display", XYX_DIS, 0,
1264 "interruption", XYX_INT, 0,
1265 "locking-shift", XYX_LSH, 0,
1266 "message", XYX_MSG, 0,
1268 "msg", XYX_MSG, CM_INV,
1270 "pipes", XYX_PIP, 0,
1271 #endif /* PIPESEND */
1273 "protocol", XYX_PRO, 0,
1275 "report", XYX_RPT, 0,
1276 "slow-start", XYX_SLO, 0,
1278 "translation", XYX_XLA, 0,
1280 "translation", XYX_XLA, CM_INV,
1281 #endif /* NOCSETS */
1282 "xlation", XYX_XLA, CM_INV,
1285 static int nts = (sizeof(tstab) / sizeof(struct keytab)) - 1;
1287 static struct keytab rtstab[] = { /* REMOTE SET TRANSFER/XFER table */
1289 "character-set", XYX_CSE, 0,
1290 #endif /* NOCSETS */
1293 static int nrts = (sizeof(rtstab) / sizeof(struct keytab));
1295 struct keytab xfrmtab[] = { /* TRANSFER MODE table */
1296 "automatic", XMODE_A, 0,
1297 "manual", XMODE_M, 0
1301 extern int locus, autolocus;
1303 static struct keytab locustab[] = {
1305 { "ask", 3, 0 }, /* Presently implemented in GUI only */
1311 static int nlocustab = (sizeof(locustab) / sizeof(struct keytab));
1316 /* SET TRANSFER CHARACTER-SET table */
1318 extern struct keytab tcstab[];
1320 #endif /* NOCSETS */
1322 /* SET TRANSFER LOCKING-SHIFT table */
1323 struct keytab lstab[] = {
1328 int nls = (sizeof(lstab) / sizeof(struct keytab));
1330 /* SET TELNET tables */
1332 extern int tn_nlm, tn_b_nlm, tn_b_meu, tn_b_ume, tn_b_xfer, tn_sb_bug;
1333 extern int tn_no_encrypt_xfer, tn_auth_krb5_des_bug;
1334 extern int tn_wait_flg, tn_duplex, tn_delay_sb, tn_sfu;
1335 extern int sl_tn_saved;
1336 extern int tn_infinite;
1337 extern int tn_rem_echo;
1339 extern int tn_auth_how;
1340 extern int tn_auth_enc;
1342 extern char * tn_fwdx_xauthority;
1343 #endif /* CK_FORWARD_X */
1344 #ifdef CK_AUTHENTICATION
1345 static struct keytab setauth[] = {
1347 "k4", AUTH_KRB4, CM_INV,
1348 "k5", AUTH_KRB5, CM_INV,
1349 "kerberos4", AUTH_KRB4, 0,
1350 "kerberos5", AUTH_KRB5, 0,
1351 "kerberos_iv",AUTH_KRB4, CM_INV,
1352 "kerberos_v", AUTH_KRB5, CM_INV,
1353 "krb4", AUTH_KRB4, CM_INV,
1354 "krb5", AUTH_KRB5, CM_INV,
1355 #endif /* CK_KERBEROS */
1365 static int nsetauth = sizeof(setauth)/sizeof(struct keytab) - 1;
1367 extern char * krb5_d_principal; /* Default principal */
1368 extern char * krb5_d_instance;
1369 extern char * krb5_d_realm; /* Default realm */
1370 extern char * krb5_d_cc; /* Default credentials cache */
1371 extern char * krb5_d_srv; /* Default service name */
1372 extern int krb5_d_lifetime; /* Default lifetime */
1373 extern int krb5_d_forwardable;
1374 extern int krb5_d_proxiable;
1375 extern int krb5_d_renewable;
1376 extern int krb5_autoget;
1377 extern int krb5_autodel;
1378 extern int krb5_d_getk4;
1379 extern int krb5_checkaddrs; /* Check TGT Addrs */
1380 extern int krb5_d_no_addresses;
1381 extern char * krb5_d_addrs[];
1382 extern char * k5_keytab; /* Keytab file */
1384 extern struct krb4_init_data krb4_init;
1385 extern char * krb4_d_principal; /* Default principal */
1386 extern char * krb4_d_realm; /* Default realm */
1387 extern char * krb4_d_srv; /* Default service name */
1388 extern int krb4_d_lifetime; /* Default lifetime */
1389 extern int krb4_d_preauth;
1390 extern char * krb4_d_instance;
1391 extern int krb4_autoget;
1392 extern int krb4_autodel;
1393 extern int krb4_checkaddrs; /* Check TGT Addrs */
1394 extern char * k4_keytab; /* Keytab file */
1398 static struct keytab krbver[] = {
1404 static int nkrbver = sizeof(krbver)/sizeof(struct keytab);
1406 static struct keytab kdestab[] = {
1407 "never", KRB_DEL_NO, 0,
1408 "no", KRB_DEL_NO, CM_INV,
1409 "on-close", KRB_DEL_CL, 0,
1410 "on-exit", KRB_DEL_EX, 0
1412 static int nkdestab = sizeof(kdestab)/sizeof(struct keytab);
1414 static struct keytab k4tab[] = {
1415 "autodel", XYKRBDEL, CM_INV,
1416 "autodestroy", XYKRBDEL, 0,
1417 "autoget", XYKRBGET, 0,
1418 "check-address", XYKRBADR, 0,
1419 "debug", XYKRBDBG, CM_INV,
1420 "instance", XYKRBINS, 0,
1421 "keytab", XYKRBKTB, 0,
1422 "lifetime", XYKRBLIF, 0,
1423 "preauth", XYKRBPRE, 0,
1424 "principal", XYKRBPR, 0,
1425 "prompt", XYKRBPRM, 0,
1426 "realm", XYKRBRL, 0,
1427 "service-name", XYKRBSRV, 0
1429 static int nk4tab = sizeof(k4tab)/sizeof(struct keytab);
1431 static struct keytab k5tab[] = {
1432 "addresses", XYKRBADD, 0,
1433 "autodelete", XYKRBDEL, CM_INV,
1434 "autodestroy", XYKRBDEL, 0,
1435 "autoget", XYKRBGET, 0,
1436 "cc", XYKRBCC, CM_INV,
1437 "check-address", XYKRBADR, 0,
1438 "credentials-cache", XYKRBCC, 0,
1439 "forwardable", XYKRBFWD, 0,
1440 "get-k4-tgt", XYKRBK5K4,0,
1441 "instance", XYKRBINS, 0,
1442 "keytab", XYKRBKTB, 0,
1443 "lifetime", XYKRBLIF, 0,
1444 "no-addresses", XYKRBNAD, 0,
1445 "principal", XYKRBPR, 0,
1446 "prompt", XYKRBPRM, 0,
1447 "proxiable", XYKRBPRX, 0,
1448 "realm", XYKRBRL, 0,
1449 "renewable", XYKRBRNW, 0,
1450 "service-name", XYKRBSRV, 0
1452 static int nk5tab = sizeof(k5tab)/sizeof(struct keytab);
1454 #define KRB_PW_PRM 1
1455 #define KRB_PR_PRM 2
1457 static struct keytab krbprmtab[] = {
1458 "password", KRB_PW_PRM, 0,
1459 "principal", KRB_PR_PRM, 0
1462 #endif /* CK_KERBEROS */
1464 static struct keytab srptab[] = {
1465 "prompt", XYSRPPRM, 0
1467 static int nsrptab = sizeof(srptab)/sizeof(struct keytab);
1468 #define SRP_PW_PRM 1
1470 static struct keytab srpprmtab[] = {
1471 "password", SRP_PW_PRM, 0
1475 static struct keytab ssltab[] = {
1476 "certs-ok", XYSSLCOK, CM_INV,
1477 "cipher-list", XYSSLCL, 0,
1478 "crl-dir", XYSSLCRLD, 0,
1479 "crl-file", XYSSLCRL, 0,
1480 "debug", XYSSLDBG, 0,
1481 "dh-key-file", XYSSLDKFL, CM_INV,
1482 "dh-param-file", XYSSLDPFL, 0,
1483 "dsa-cert-chain-file", XYSSLDCCF, 0,
1484 "dsa-cert-file", XYSSLDCFL, 0,
1485 "dsa-key-file", XYSSLDKFL, 0,
1486 "dummy", XYSSLDUM, CM_INV,
1487 "only", XYSSLON, CM_INV,
1488 "random-file", XYSSLRND, 0,
1489 "rsa-cert-chain-file", XYSSLRCCF, 0,
1490 "rsa-cert-file", XYSSLRCFL, 0,
1491 "rsa-key-file", XYSSLRKFL, 0,
1492 "verbose", XYSSLVRB, 0,
1493 "verify", XYSSLVRF, 0,
1494 "verify-dir", XYSSLVRFD, 0,
1495 "verify-file", XYSSLVRFF, 0
1497 static int nssltab = sizeof(ssltab)/sizeof(struct keytab);
1498 static struct keytab sslvertab[] = {
1499 "fail-if-no-peer-cert", SSL_VERIFY_PEER |
1500 SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0,
1501 "no", SSL_VERIFY_NONE, 0,
1502 "none", SSL_VERIFY_NONE, CM_INV,
1503 "off", SSL_VERIFY_NONE, CM_INV,
1504 "on", SSL_VERIFY_PEER, CM_INV,
1505 "peer-cert", SSL_VERIFY_PEER, 0
1507 static int nsslvertab = sizeof(sslvertab)/sizeof(struct keytab);
1509 #endif /* CK_AUTHENTICATION */
1510 #ifdef CK_ENCRYPTION
1511 int cx_type = CX_AUTO;
1512 extern int sl_cx_type;
1513 #endif /* CK_ENCRYPTION */
1514 extern char *tcp_address;
1516 extern char * tcp_http_proxy;
1517 extern char * tcp_http_proxy_user;
1518 extern char * tcp_http_proxy_pwd;
1519 extern char * tcp_http_proxy_agent;
1523 extern char *tcp_socks_svr;
1524 extern char *tcp_socks_user;
1526 extern char *tcp_socks_ns;
1527 #endif /* CK_SOCKS_NS */
1528 #endif /* CK_SOCKS */
1535 static struct keytab userpass[] = {
1536 { "/agent", UPW_AGENT, CM_ARG },
1537 { "/password", UPW_PASS, CM_ARG },
1538 { "/user", UPW_USER, CM_ARG },
1540 static int nuserpass = sizeof(userpass)/sizeof(struct keytab);
1542 static struct keytab tnnegtab[] = { /* TELNET NEGOTIATION table */
1543 "accepted", TN_NG_AC, 0,
1544 "refused", TN_NG_RF, 0,
1545 "req", TN_NG_RQ, CM_INV|CM_ABR,
1546 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1547 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1548 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1549 "request", TN_NG_RQ, CM_INV|CM_ABR,
1550 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1551 "requested", TN_NG_RQ, 0,
1552 "required", TN_NG_MU, 0
1554 static int ntnnegtab = sizeof(tnnegtab)/sizeof(struct keytab);
1556 #ifdef CK_ENCRYPTION
1557 static struct keytab typkwd[] = {
1561 static struct keytab tnenctab[] = { /* TELNET ENCRYPTION table */
1562 "accepted", TN_NG_AC, CM_INV,
1563 "refused", TN_NG_RF, CM_INV,
1564 "req", TN_NG_RQ, CM_INV|CM_ABR,
1565 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1566 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1567 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1568 "request", TN_NG_RQ, CM_INV|CM_ABR,
1569 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1570 "requested", TN_NG_RQ, CM_INV,
1571 "required", TN_NG_MU, CM_INV,
1572 "start", TN_EN_START, CM_INV,
1573 "stop", TN_EN_STOP, CM_INV,
1574 "type", TN_EN_TYP, 0
1576 static int ntnenc = sizeof(tnenctab)/sizeof(struct keytab) ;
1577 #endif /* CK_ENCRYPTION */
1580 static struct keytab tnfwdxtab[] = { /* TELNET FORWARD-X table */
1581 "no-encryption", 1, CM_INV,
1582 "xauthority-file", 0, 0
1584 static int ntnfwdx = sizeof(tnfwdxtab)/sizeof(struct keytab) ;
1585 #endif /* CK_FORWARD_X */
1587 static struct keytab tnbugtab[] = { /* TELNET BUG table */
1588 "auth-krb5-des", 4, 0,
1589 "binary-me-means-u-too", 0, 0,
1590 "binary-u-means-me-too", 1, 0,
1591 "infinite-loop-check", 2, 0,
1592 "sb-implies-will-do", 3, 0
1595 #ifdef CK_ENVIRONMENT
1596 static struct keytab tnenvtab[] = { /* TELNET ENVIRONMENT table */
1597 "acct", TN_ENV_ACCT, 0,
1598 "display", TN_ENV_DISP, 0,
1599 "job", TN_ENV_JOB, 0,
1600 "location", TN_ENV_LOC, 0,
1601 "off", TN_ENV_OFF, CM_INV,
1602 "on", TN_ENV_ON, CM_INV,
1603 "printer", TN_ENV_PRNT, 0,
1604 "systemtype",TN_ENV_SYS, 0,
1605 "user", TN_ENV_USR, 0,
1606 "uservar", TN_ENV_UVAR, 0,
1609 static int ntnenv = sizeof(tnenvtab)/sizeof(struct keytab) - 1;
1610 #endif /* CK_ENVIRONMENT */
1612 #ifdef CK_AUTHENTICATION
1613 static struct keytab tnauthtab[] = { /* TELNET AUTHENTICATION table */
1614 "accepted", TN_NG_AC, CM_INV,
1615 "encrypt-flag", TN_AU_ENC, 0,
1616 "forwarding", TN_AU_FWD, 0,
1617 "how-flag", TN_AU_HOW, 0,
1618 "refused", TN_NG_RF, CM_INV,
1619 "req", TN_NG_RQ, CM_INV|CM_ABR,
1620 "requ", TN_NG_RQ, CM_INV|CM_ABR,
1621 "reque", TN_NG_RQ, CM_INV|CM_ABR,
1622 "reques", TN_NG_RQ, CM_INV|CM_ABR,
1623 "request", TN_NG_RQ, CM_INV|CM_ABR,
1624 "requeste", TN_NG_RQ, CM_INV|CM_ABR,
1625 "requested", TN_NG_RQ, CM_INV,
1626 "required", TN_NG_MU, CM_INV,
1627 "type", TN_AU_TYP, 0
1629 static int ntnauth = sizeof(tnauthtab)/sizeof(struct keytab) ;
1631 struct keytab autyptab[] = { /* TELNET AUTHENTICATION TYPE table */
1632 "automatic", AUTH_AUTO, 0,
1634 "k4", AUTH_KRB4, CM_INV,
1635 "k5", AUTH_KRB5, CM_INV,
1636 "kerberos4", AUTH_KRB4, 0,
1637 "kerberos5", AUTH_KRB5, 0,
1638 "kerberos_iv",AUTH_KRB4, CM_INV,
1639 "kerberos_v", AUTH_KRB5, CM_INV,
1640 "krb4", AUTH_KRB4, CM_INV,
1641 "krb5", AUTH_KRB5, CM_INV,
1642 #endif /* CK_KERBEROS */
1643 "none", AUTH_NONE, 0,
1645 "ntlm", AUTH_NTLM, 0,
1655 int nautyp = sizeof(autyptab)/sizeof(struct keytab) - 1;
1657 struct keytab auhowtab[] = { /* TELNET AUTHENTICATION HOW table */
1658 "any", TN_AUTH_HOW_ANY, 0,
1659 "mutual", TN_AUTH_HOW_MUTUAL, 0,
1660 "one-way", TN_AUTH_HOW_ONE_WAY, 0,
1663 int nauhow = sizeof(auhowtab)/sizeof(struct keytab) - 1;
1665 struct keytab auenctab[] = { /* TELNET AUTHENTICATION ENCRYPT table */
1666 "any", TN_AUTH_ENC_ANY, 0,
1667 "none", TN_AUTH_ENC_NONE, 0,
1668 "telopt", TN_AUTH_ENC_TELOPT, 0,
1670 "tls", TN_AUTH_ENC_TLS, 0,
1674 int nauenc = sizeof(auenctab)/sizeof(struct keytab) - 1;
1675 #endif /* CK_AUTHENTICATION */
1679 static struct keytab tn_nlmtab[] = { /* TELNET NEWLINE-MODE table */
1680 "binary-mode", TN_NL_BIN, 0, /* Binary mode */
1681 "nvt", TN_NL_NVT, 0, /* NVT mode */
1682 "off", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
1683 "on", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
1684 "raw", TNL_CR, CM_INV /* CR only (out of spec) */
1686 static int ntn_nlm = (sizeof(tn_nlmtab) / sizeof(struct keytab));
1688 static struct keytab tnlmtab[] = { /* TELNET NEWLINE-MODE table */
1689 "cr", TNL_CR, CM_INV, /* CR only (out of spec) */
1690 "cr-lf", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
1691 "cr-nul", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
1692 "lf", TNL_LF, CM_INV, /* LF instead of CR-LF */
1693 "off", TNL_CRNUL, 0, /* CR-NUL (TELNET spec) */
1694 "on", TNL_CRLF, 0, /* CR-LF (TELNET spec) */
1695 "raw", TNL_CR, 0 /* CR only (out of spec) */
1697 static int ntnlm = (sizeof(tnlmtab) / sizeof(struct keytab));
1699 struct keytab tntab[] = {
1700 #ifdef CK_AUTHENTICATION
1701 "authentication", CK_TN_AU, 0,
1702 #endif /* CK_AUTHENTICATION */
1703 "b", CK_TN_BM, CM_INV|CM_ABR,
1704 "bi", CK_TN_BM, CM_INV|CM_ABR,
1705 "bin", CK_TN_BM, CM_INV|CM_ABR,
1706 "bina", CK_TN_BM, CM_INV|CM_ABR,
1707 "binar", CK_TN_BM, CM_INV|CM_ABR,
1708 "binary", CK_TN_BM, CM_INV|CM_ABR,
1709 "binary-", CK_TN_BM, CM_INV|CM_ABR,
1710 "binary-mode", CK_TN_BM, CM_INV,
1711 "binary-transfer-mode", CK_TN_XF, 0,
1712 "binary-xfer-mode", CK_TN_XF, CM_INV,
1713 "bug", CK_TN_BUG, 0,
1714 "debug", CK_TN_DB, 0,
1715 "delay-sb", CK_TN_DL, 0,
1716 "echo", CK_TN_EC, 0,
1717 #ifdef CK_ENCRYPTION
1718 "encryption", CK_TN_ENC, 0,
1719 #endif /* CK_ENCRYPTION */
1720 #ifdef CK_ENVIRONMENT
1721 "environment", CK_TN_ENV, 0,
1722 #endif /* CK_ENVIRONMENT */
1724 "forward-x", CK_TN_FX, 0,
1725 #endif /* CK_FORWARD_X */
1727 "kermit", CK_TN_IKS, CM_INV,
1728 #endif /* IKS_OPTION */
1730 "location", CK_TN_LOC, 0,
1731 #endif /* CK_SNDLOC */
1733 "naws", CK_TN_NAWS, CM_INV,
1734 #endif /* CK_NAWS */
1735 "newline-mode", CK_TN_NL, 0,
1736 "no-encrypt-during-xfer", CK_TN_NE, CM_INV,
1737 "prompt-for-userid",CK_TN_PUID,0,
1738 "remote-echo", CK_TN_RE, 0,
1740 "start-tls", CK_TN_TLS, CM_INV,
1743 "sfu-compatibility", CK_TN_SFU, 0,
1745 "sfu-compatibility", CK_TN_SFU, CM_INV,
1747 "terminal-type", CK_TN_TT, 0,
1748 "wait-for-negotiations", CK_TN_WAIT, 0,
1749 #ifdef CK_ENVIRONMENT
1750 "xdisplay-location",CK_TN_XD, CM_INV,
1751 #endif /* CK_ENVIRONMENT */
1754 int ntn = (sizeof(tntab) / sizeof(struct keytab)) - 1;
1756 struct keytab tnopttab[] = {
1757 #ifdef CK_AUTHENTICATION
1758 "authentication", CK_TN_AU, 0,
1760 "authentication", CK_TN_AU, CM_INV,
1761 #endif /* CK_AUTHENTICATION */
1762 "binary-mode", CK_TN_BM, 0,
1764 "c", CK_TN_CPC, CM_INV|CM_ABR,
1765 "co", CK_TN_CPC, CM_INV|CM_ABR,
1766 "com", CK_TN_CPC, CM_INV|CM_ABR,
1767 "com-port-control",CK_TN_CPC, 0,
1768 "comport-control", CK_TN_CPC, CM_INV,
1769 #else /* TN_COMPORT */
1770 "com-port-control",CK_TN_CPC, CM_INV,
1771 "comport-control", CK_TN_CPC, CM_INV,
1772 #endif /* TN_COMPORT */
1773 "echo", CK_TN_EC, 0,
1774 #ifdef CK_ENCRYPTION
1775 "encryption", CK_TN_ENC, 0,
1777 "encryption", CK_TN_ENC, CM_INV,
1778 #endif /* CK_ENCRYPTION */
1780 "forward-x", CK_TN_FX, 0,
1781 #else /* CK_FORWARD_X */
1782 "forward-x", CK_TN_FX, CM_INV,
1783 #endif /* CK_FORWARD_X */
1784 "ibm-sak", CK_TN_SAK, CM_INV,
1786 "kermit", CK_TN_IKS, 0,
1788 "kermit", CK_TN_IKS, CM_INV,
1789 #endif /* IKS_OPTION */
1790 "lflow", CK_TN_FLW, CM_INV,
1791 "logout", CK_TN_LOG, 0,
1793 "naws", CK_TN_NAWS, 0,
1795 "naws", CK_TN_NAWS, CM_INV,
1796 #endif /* CK_NAWS */
1797 #ifdef CK_ENVIRONMENT
1798 "new-environment", CK_TN_ENV, 0,
1800 "new-environment", CK_TN_ENV, CM_INV,
1801 #endif /* CK_ENVIRONMENT */
1802 "pragma-heartbeat",CK_TN_PHR, CM_INV,
1803 "pragma-logon", CK_TN_PLG, CM_INV,
1804 "pragma-sspi", CK_TN_PSP, CM_INV,
1805 "sak", CK_TN_SAK, CM_INV,
1807 "send-location", CK_TN_LOC, 0,
1809 "send-location", CK_TN_LOC, CM_INV,
1810 #endif /* CK_SNDLOC */
1811 "sga", CK_TN_SGA, CM_INV|CM_ABR,
1813 "start-tls", CK_TN_TLS, 0,
1815 "start-tls", CK_TN_TLS, CM_INV,
1817 "suppress-go-aheads", CK_TN_SGA, 0,
1818 "terminal-type", CK_TN_TT, 0,
1819 "ttype", CK_TN_TT, CM_INV|CM_ABR,
1820 #ifdef CK_ENVIRONMENT
1821 "xdisplay-location", CK_TN_XD, 0,
1823 "xdisplay-location", CK_TN_XD, CM_INV,
1824 #endif /* CK_ENVIRONMENT */
1827 int ntnopt = (sizeof(tnopttab) / sizeof(struct keytab)) - 1;
1829 struct keytab tnoptsw[] = {
1830 "/client", CK_TN_CLIENT, 0,
1831 "/server", CK_TN_SERVER, 0
1833 int ntnoptsw = (sizeof(tnoptsw) / sizeof(struct keytab));
1836 struct keytab ftrtab[] = { /* Feature table */
1837 #ifndef NOCSETS /* 0 = we have it, 1 = we don't */
1838 "character-sets", 0, 0,
1840 "character-sets", 1, 0,
1841 #endif /* NOCSETS */
1846 #endif /* NOCYRIL */
1852 #endif /* NOLOGDIAL */
1858 #endif /* NODEBUG */
1867 "dynamic-memory", 0, 0,
1869 "dynamic-memory", 1, 0,
1870 #endif /* DYNAMIC */
1873 "file-transfer", 0, 0,
1875 "file-transfer", 1, 0,
1891 "fullscreen-display", 0, 0,
1893 "fullscreen-display", 1, 0,
1894 #endif /* CK_CURSES */
1924 "job-control", 0, 0,
1926 "job-control", 1, 0,
1929 "job-control", 1, 0,
1947 #endif /* CK_KERBEROS */
1953 #endif /* NOCSETS */
1961 "learned-scripts", 0, 0,
1963 "learned-scripts", 1, 0,
1964 #endif /* CKLEARN */
1967 "making-connections", 0, 0,
1969 "making-connections", 1, 0,
1970 #endif /* NOLOCAL */
1976 #endif /* NETCONN */
1979 #ifdef CK_AUTHENTICATION
1981 #else /* CK_AUTHENTICATION */
1983 #endif /* CK_AUTHENTICATION */
1994 #endif /* PIPESEND */
1998 #endif /* PIPESEND */
2017 #endif /* CK_REDIR */
2023 #endif /* RTS/CTS */
2026 "script-command", 0, 0,
2028 "script-command", 1, 0,
2029 #endif /* NOSCRIPT */
2031 "server-mode", 0, 0,
2033 "server-mode", 1, 0,
2034 #endif /* NOSERVER */
2037 "sexpression", 0, 0,
2039 "sexpression", 1, 0,
2046 #endif /* SFTP_BUILTIN */
2049 "show-command", 0, 0,
2051 "show-command", 1, 0,
2062 #else /* SSHBUILTIN */
2064 #endif /* SSHBUILTIN */
2082 #endif /* UNICODE */
2092 int nftr = (sizeof(ftrtab) / sizeof(struct keytab)) - 1;
2094 struct keytab desttab[] = { /* SET DESTINATION */
2096 "calibrate", DEST_N, CM_INV,
2097 #endif /* CALIBRATE */
2100 "nowhere", DEST_N, 0,
2101 #endif /* CALIBRATE */
2102 "printer", DEST_P, 0,
2105 int ndests = (sizeof(desttab) / sizeof(struct keytab));
2107 #ifndef NOSPL /* Used only with script programming items... */
2109 #ifndef NOSERVER /* This is just to avoid some */
2110 #define CK_PARSDIR /* "statement not reached" */
2111 #else /* complaints... */
2115 #endif /* NOSERVER */
2118 cx == 0 means dial directory
2119 cx == 1 means network directory
2120 cx == 2 means a directory path list
2123 parsdir(cx) int cx; {
2124 int i, x, y, dd; /* Workers */
2128 char *pp[MAXGETPATH]; /* Temporary name pointers */
2135 char dirpath[1024]; /* For fully qualified filenames */
2139 int max = 0; /* Maximum number of things to parse */
2143 if (cx == 0) { /* Dialing */
2149 if (cx == 1) { /* Network */
2154 #endif /* NETCONN */
2157 if (cx == 2) { /* GET path */
2161 } else /* Called with invalid function code */
2162 #endif /* NOSERVER */
2165 for (i = 0; i < MAXGETPATH; i++) /* Init these. */
2169 dd = 0; /* Temporary name counter */
2171 if (cx != 2) { /* Dialing or Network Directory */
2174 char * appdata0 = NULL, * appdata1 = NULL;
2176 env = getenv("K95PHONES");
2177 makestr(&appdata0,(char *)GetAppData(0));
2178 makestr(&appdata1,(char *)GetAppData(1));
2180 env = getenv("K2PHONES");
2183 env = getenv("K95PHONES");
2188 len = strlen(env) + 2*strlen(startupdir) + 2*strlen(inidir)
2189 + (appdata0?2*strlen(appdata0):0)
2190 + (appdata1?2*strlen(appdata1):0)
2191 + 2*strlen(zhome()) + 2*strlen(exedir) + 8*strlen("PHONES/")
2193 if (len < 4096) /* SAFE */
2195 "%s%s%s;%s%s;%s%s%s%s%s%s%s%s%s;%s%s;%s;%s%s",
2196 /* Semicolon-separated path list */
2198 (env[0] && env[strlen(env)-1] == ';') ? "" : ";",
2200 startupdir, "PHONES/",
2201 appdata1 ? appdata1 : "",
2202 appdata1 ? "Kermit 95;" : "",
2203 appdata1 ? appdata1 : "",
2204 appdata1 ? "Kermit 95/PHONES/;" : "",
2205 appdata0 ? appdata0 : "",
2206 appdata0 ? "Kermit 95;" : "",
2207 appdata0 ? appdata0 : "",
2208 appdata0 ? "Kermit 95/PHONES/;" : "",
2217 makestr(&appdata0,NULL);
2218 makestr(&appdata1,NULL);
2224 zzstring("\\v(home)",&s,&y);
2228 "Names of one or more directory files, separated by spaces",
2234 #endif /* OS2ORUNIX */
2237 } else { /* List of directory names */
2239 y = cmdir("Directory name","",&s,xxstring);
2242 if (y == -3) { /* EOL or user typed <CR> */
2243 if ((y = cmcfm()) < 0) return(y);
2244 for (i = 0; i < max; i++) { /* Clear these */
2245 if (i < nxdir && xdir[i]) {
2248 xdir[i] = (i < dd) ? pp[i] : NULL;
2256 #endif /* NETCONN */
2261 #endif /* NOSERVER */
2262 return(success = 1);
2264 } else { /* Parse error */
2265 for (i = 0; i < dd; i++) { /* Free temp storage */
2266 if (pp[i]) free(pp[i]); /* but don't change */
2267 pp[i] = NULL; /* anything else */
2273 printf("?Wildcards not allowed\n");
2277 if (cx == 2 && !isdir(s)) {
2278 printf("?Not a directory - %s\n", s);
2281 #endif /* CK_TMPDIR */
2285 if (!isabsolute(s)) { /* If not relative get full path */
2286 if ((fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf))) {
2288 if ((int) strlen(fnp->fpath) > 0)
2296 if (x > 0) /* Get last char */
2298 debug(F000,"parsdir s",s,c);
2299 if ((pp[dd] = malloc(strlen(s)+2)) == NULL) {
2300 printf("?Internal error - malloc\n");
2301 for (i = 0; i < dd; i++) { /* Free temp storage */
2302 if (pp[i]) free(pp[i]);
2306 } else { /* Have storage for name */
2307 strcpy(pp[dd],s); /* Copy string into new storage */
2308 debug(F111,"parsdir pp[dd] 1",pp[dd],dd);
2310 if (cx == 2) { /* If we are parsing directories */
2312 extern int myindex; /* Append directory separator if */
2313 extern struct sysdata sysidlist[]; /* it is missing... */
2314 debug(F101,"parsdir myindex","",myindex);
2316 if (sysidlist[myindex].sid_unixlike)
2317 if (c != sysidlist[myindex].sid_dirsep) {
2318 dirsep[0] = sysidlist[myindex].sid_dirsep;
2320 strcat(pp[dd], (char *) dirsep); /* safe */
2324 debug(F111,"parsdir pp[dd] 2",pp[dd],dd);
2326 printf("?Too many directories - %d max\n", max);
2327 for (i = 0; i < dd; i++) { /* Free temp storage */
2328 if (pp[i]) free(pp[i]);
2334 #endif /* CK_PARSDIR */
2343 char username[LOGINLEN+1];
2344 char password[LOGINLEN+1];
2345 char account[LOGINLEN+1];
2346 extern char * x_user, * x_passwd, * x_acct;
2347 extern int x_login, x_logged;
2353 x = cmfld("username", "", &s, xxstring);
2357 if ((int)strlen(s) > LOGINLEN) {
2358 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2361 ckstrncpy(username,s,LOGINLEN+1);
2362 x = cmfld("password", "", &s, xxstring);
2366 if ((int)strlen(s) > LOGINLEN) {
2367 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2370 ckstrncpy(password,s,LOGINLEN+1);
2371 x = cmfld("account", "", &s, xxstring);
2375 if ((int)strlen(s) > LOGINLEN) {
2376 printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
2379 ckstrncpy(account,s,LOGINLEN+1);
2380 if ((x = cmcfm()) < 0)
2385 makestr(&x_user,username);
2386 makestr(&x_passwd,password);
2387 makestr(&x_acct,account);
2388 x_login = (x_user) ? 1 : 0;
2392 #endif /* NOSERVER */
2398 if ((y = cmkey(crrtab,ncrr,"","automatic",xxstring)) < 0) return(y);
2400 x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring);
2401 if (x < 0) return(x);
2403 if ((x = cmcfm()) < 0) return(x);
2404 carrier = ttscarr(y);
2408 #endif /* NOLOCAL */
2410 extern struct keytab yesno[];
2413 /* g e t y e s n o */
2415 static struct keytab q0yesno[] = { /* Yes/No/Quit keyword table */
2420 static int nq0yesno = (sizeof(q0yesno) / sizeof(struct keytab));
2422 static struct keytab q1yesno[] = { /* Yes/No/Quit keyword table */
2428 static int nq1yesno = (sizeof(q1yesno) / sizeof(struct keytab));
2430 static struct keytab q2yesno[] = { /* Yes/No/Quit keyword table */
2436 static int nq2yesno = (sizeof(q2yesno) / sizeof(struct keytab));
2438 static struct keytab q3yesno[] = { /* Yes/No/Quit keyword table */
2445 static int nq3yesno = (sizeof(q3yesno) / sizeof(struct keytab));
2448 /* Ask question, get yes/no answer */
2451 getyesno(msg, flags) char * msg; int flags; {
2453 extern int on_recall; /* around Password prompting */
2454 #endif /* CK_RECALL */
2459 extern int vmode, win95_popup, startflags;
2460 int vmode_sav = vmode;
2462 #endif /* NOLOCAL */
2465 if ( apcactive != APC_INACTIVE && (apcstatus & APC_NOINP) ) {
2466 return(success = 0);
2473 if (win95_popup && !(startflags & 96)
2478 return(popup_readyesno(vmode,NULL,msg,flags));
2479 #endif /* COMMENT */
2480 if (vmode == VTERM) {
2482 VscrnIsDirty(VTERM);
2486 #endif /* NOLOCAL */
2489 In VMS, whenever a TAKE file or macro is active, we restore the
2490 original console modes so Ctrl-C/Ctrl-Y can work. But here we
2491 go interactive again, so we have to temporarily put them back.
2494 concb((char)escape);
2499 #endif /* CK_RECALL */
2500 cmsavp(psave,PROMPTL); /* Save old prompt */
2501 cmsetp(msg); /* Make new prompt */
2502 z = 0; /* Initialize answer to No. */
2503 cmini(ckxech); /* Initialize parser. */
2505 prompt(NULL); /* Issue prompt. */
2507 case 0: y = cmkey(q0yesno,nq0yesno,"","",NULL); break;
2508 case 1: y = cmkey(q1yesno,nq1yesno,"","",NULL); break;
2509 case 2: y = cmkey(q2yesno,nq2yesno,"","",NULL); break;
2510 default: y = cmkey(q3yesno,nq3yesno,"","",NULL);
2513 if (y == -4) { /* EOF */
2516 } else if (y == -3) /* No answer? */
2517 printf(" Please respond; type '?' to see valid answers.\n");
2520 z = y; /* Save answer */
2521 y = cmcfm(); /* Get confirmation */
2523 } while (y < 0); /* Continue till done */
2524 cmsetp(psave); /* Restore real prompt */
2526 if (cmdlvl > 0) /* In VMS and not at top level, */
2527 conres(); /* restore console again. */
2531 if (vmode != vmode_sav) {
2534 VscrnIsDirty(VTERM);
2537 #endif /* NOLOCAL */
2542 extern HWND hwndConsole;
2543 _PROTOTYP(int gui_txt_dialog,(char *,char *,int,char *,int,char *,int));
2544 _PROTOTYP(int gui_mtxt_dialog,(char *,int,struct txtbox []));
2545 _PROTOTYP(int gui_position,(int, int));
2546 _PROTOTYP(int gui_resize_mode,(int));
2547 _PROTOTYP(int gui_win_run_mode,(int));
2548 _PROTOTYP(int gui_saveas_dialog,(char *,char *, int, char *, char *, int));
2549 extern int gui_dialog;
2552 /* u q _ o k -- User Query, get Yes/No or OK Cancel */
2555 preface: Explanatory text to print, or NULL.
2557 mask: Bitmask for legal responses: 1 = OK or Yes; 2 = No or Cancel.
2558 help: Help text (array of strings or NULL) [not used by parser].
2559 dflt: Default response (1 or 2) [not used by parser].
2561 -1: Invalid argument(s).
2562 0: User said No or Cancel.
2563 1 User said Yes or OK.
2565 preface and prompt should not include final line terminator but may
2566 include embedded ones. Help text is in case GUI dialog needs a Help
2567 button; final element of help-string array is "". dflt is used by GUI
2568 to highlight the default response button.
2572 uq_ok(char * preface, char * prompt, int mask,char ** help, int dflt)
2573 #else /* CK_ANSIC */
2574 uq_ok(preface,prompt,mask,help,dflt)
2575 char * preface, * prompt, ** help;
2577 #endif /* CK_ANSIC */
2585 if ((mask & 3) == 1) { /* OK (GUI only) */
2588 /* This one is for popup help, alerts, etc */
2590 len = strlen(preface) + strlen(prompt) + 4;
2591 text = (char *)malloc(len);
2592 ckmakmsg(text,len,preface,"\n",prompt,NULL);
2594 rc = MessageBox(hwndConsole,
2595 text ? text : prompt,
2597 MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
2598 ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
2599 SetForegroundWindow(hwndConsole);
2609 if (preface) /* Just display the text, if any */
2610 printf("%s\n",preface);
2612 printf("%s\n",prompt);
2615 } else if ((mask & 3) == 3) { /* Yes/No or OK/Cancel */
2619 len = strlen(preface) + strlen(prompt) + 4;
2620 text = (char *)malloc(len);
2621 ckmakmsg(text,len,preface,"\n",prompt,NULL);
2623 rc = MessageBox(hwndConsole,
2624 text ? text : prompt,
2626 MB_YESNO | MB_ICONINFORMATION | MB_TASKMODAL |
2627 (dflt == 2 ? MB_DEFBUTTON2 : MB_DEFBUTTON1));
2628 ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
2629 SetForegroundWindow(hwndConsole);
2634 else if (rc == IDNO || rc == IDCANCEL)
2642 printf("%s\n",preface);
2643 return(getyesno(prompt,0));
2646 printf("?Internal error: uq_ok()\n");
2651 /* u q _ t x t -- User Query, get single text response */
2654 preface: Explanatory text to print, or NULL.
2656 echo: 0 = don't echo; 1 = echo; 2 = echo with asterisks.
2657 help: Help text (array of strings or NULL) [not used by parser].
2658 buf: Pointer to result buffer.
2659 buflen: Length of result buffer.
2660 dflt: Default response text or NULL [not used by parser].
2661 timer: Optional Timeout
2663 0: User said No or Cancel.
2664 1 User said Yes or OK.
2666 preface, prompt, and help as for uq_ok().
2670 uq_txt(char * preface, char * prompt, int echo, char ** help, char * buf,
2671 int buflen, char *dflt, int timer)
2672 #else /* CK_ANSIC */
2673 uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer)
2674 char * preface, * prompt, ** help, * buf, * dflt;
2675 int buflen, echo, timer;
2676 #endif /* CK_ANSIC */
2681 extern int startflags;
2682 extern int win95_popup;
2684 #endif /* NOLOCAL */
2687 if (buflen < 1 || !buf)
2691 rc = gui_txt_dialog(preface,prompt,echo,buf,buflen,dflt,timer);
2694 /* Otherwise, the dialog could not be created. Fallback to text mode */
2699 if (win95_popup && !(startflags & 96)
2704 debok = 0; /* Don't log */
2706 popup_readtext(vmode,preface,prompt,buf,buflen,0);
2708 popup_readpass(vmode,preface,prompt,buf,buflen,0);
2713 #endif /* NOLOCAL */
2716 printf("%s\n",preface);
2718 readtext(prompt,buf,buflen);
2720 readpass(prompt,buf,buflen);
2721 return(1); /* (no buttons in parser) */
2724 /* u q _ m t x t -- User Query, get multiple text responses */
2727 preface: Explanatory text to print, or NULL.
2728 help: Help text (array of strings or NULL) [not used by parser].
2729 n: Number of responses wanted.
2730 field: Array of struct txtbox, one element per field, see ckuusr.h.
2732 0: User said No or Cancel.
2733 1 User said Yes or OK.
2735 preface and help as for uq_ok().
2739 uq_mtxt(char * preface,char **help, int n, struct txtbox field[])
2740 #else /* CK_ANSIC */
2741 uq_mtxt(preface,help,n,field)
2742 char * preface; char ** help; int n; struct txtbox field[];
2743 #endif /* CK_ANSIC */
2748 extern int startflags;
2749 extern int win95_popup;
2751 #endif /* NOLOCAL */
2754 if (n < 1 || !field)
2758 rc = gui_mtxt_dialog(preface, n, field);
2761 /* Otherwise, the dialog could not be created. Fallback to text mode */
2766 if (win95_popup && !(startflags & 96)
2771 debok = 0; /* Don't log */
2772 for (i = 0; i < n; i++) {
2773 if (field[i].t_echo == 1)
2774 popup_readtext(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
2776 popup_readpass(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
2782 #endif /* NOLOCAL */
2785 printf("%s\n",preface);
2786 for (i = 0; i < n; i++) {
2787 if (field[i].t_echo == 1)
2788 readtext(field[i].t_lbl,field[i].t_buf,field[i].t_len);
2790 readpass(field[i].t_lbl,field[i].t_buf,field[i].t_len);
2795 /* u q _ f i l e -- User Query, get file or directory name */
2798 preface: Explanatory text to print, or NULL.
2799 prompt: Prompt string.
2801 1 = input (existing) file
2802 2 = existing directory
2803 3 = create new output file
2804 4 = output file allowing append access
2805 help: Help text (array of strings or NULL) [not used by parser].
2806 dflt: Default response.
2807 result: Pointer to result buffer.
2808 rlength: Length of result buffer.
2811 -1: Invalid argument, result too long, or other error.
2813 1: OK, with file/pathname copied to result buffer.
2814 2: Like 1, but for output file that is to be appended to.
2817 1. preface and prompt should not include final line terminator but may
2818 include embedded ones. Help text is in case GUI dialog needs a Help
2819 button; final element of help-string array is "".
2821 2. The default might be a filename, a directory name, a relative
2822 pathname, or an absolute pathname. This routine must convert it into
2823 into a fully qualified (absolute) pathname so the user knows exactly
2824 where the file is to be found or stored. In addition, the Windows
2825 version of this routine must separate the directory part from the
2826 name part, so it can display the given directory in the file dialog,
2827 and put name in the filename box to be edited, replaced, or
2830 3. When called with FC 4, the Windows version should include "New" and
2831 "Append" buttons in the dialog. so the user can say whether the file
2832 should overwrite any file of the same name, or be appended to it.
2837 uq_file(char * preface, char * fprompt, int fc, char ** help,
2838 char * dflt, char * result, int rlength)
2839 #else /* CK_ANSIC */
2840 uq_file(preface,fprompt,fc,help,dflt,result,rlength)
2841 char * preface, * fprompt, ** help, * dflt, * result;
2843 #endif /* CK_ANSIC */
2846 int rc = -1, x, y, z;
2847 char * s, * p, * fullpath;
2848 char filebuf[CKMAXPATH+1];
2851 extern int on_recall;
2852 #endif /* CK_RECALL */
2856 rc = gui_saveas_dialog(preface,fprompt,fc,dflt,result,rlength);
2863 #endif /* CK_RECALL */
2865 if (preface) /* If prefatory text given... */
2866 printf("%s\n",preface); /* display it. */
2868 cmsavp(psave,PROMPTL); /* Save old prompt */
2870 /* We get the full pathname of the proposed output file just so */
2871 /* we can show it to the user but we don't use it ourselves. */
2873 p = NULL; /* Build new prompt */
2874 if (!dflt) dflt = "";
2875 if (*dflt) /* Have default filename */
2876 zfnqfp(dflt,CKMAXPATH+1,filebuf); /* Get full path */
2878 ckmakmsg(filebuf,CKMAXPATH+1,zgtdir(),"newfile",NULL,NULL);
2880 x = strlen(fullpath);
2882 /* If no prompt given, build one that shows the proposed full pathname. */
2884 if (!fprompt) fprompt = "";
2885 if (!*fprompt) fprompt = x ? " Filename" : " Filename: ";
2886 y = strlen(fprompt);
2887 if (x > 0) { /* Have default pathname? */
2888 p = (char *)malloc(x + y + 7); /* Get temp storage */
2889 if (p) { /* Build prompt */
2890 ckmakmsg(p,x+y+7,fprompt," [",fullpath,"]: ");
2894 cmsetp(fprompt); /* Make new prompt */
2895 if (p) free(p); /* Free temp storage */
2896 cmini(ckxech); /* Initialize parser. */
2899 prompt(NULL); /* Issue prompt. */
2900 switch (fc) { /* Parse depends on function code */
2901 case 1: /* Input file */
2902 x = cmifi("Name of existing file",dflt,&s,&y,xxstring);
2905 case 2: /* Directory */
2906 x = cmdir("Directory name",dflt,&s,xxstring);
2909 case 3: /* New output file */
2911 case 4: /* Output file - Append allowed */
2912 x = cmofi("Output file specification",dflt,&s,xxstring);
2913 rc = (fc == 4) ? 1 : 2;
2915 default: /* Bad function code */
2918 if (x < 0) { /* Parse error */
2920 if (x == -4) { /* EOF */
2922 } else if (x == -3) /* No answer? */
2924 " Please enter a directory name.\n" :
2925 " Please enter a filename.\n"
2930 if (z > rlength || ckstrncpy(filebuf,brstrip(s),CKMAXPATH+1) < z) {
2931 printf("?Name too long\n");
2934 x = cmcfm(); /* Get confirmation */
2936 if (fc == 1 && x > -1 && y > 0) {
2937 printf("?Wildcards not allowed\n");
2940 } while (x < 0); /* Continue till done */
2946 cmsetp(psave); /* Restore real prompt */
2949 ckstrncpy(result,filebuf,rlength);
2957 _PROTOTYP( int zsetperm, (char *, int));
2959 /* CHMOD command for UNIX only */
2974 static struct keytab uchmodsw[] = {
2975 "/directories", CHM_DIR, 0,
2976 "/dotfiles", CHM_DOT, 0,
2977 "/files", CHM_FIL, 0,
2978 "/list", CHM_LIS, 0,
2979 "/nolist", CHM_NOL, 0,
2980 "/nopage", CHM_NOP, 0,
2981 "/page", CHM_PAG, 0,
2982 "/quiet", CHM_QUI, CM_INV,
2983 "/recursive", CHM_REC, 0,
2984 "/simulate", CHM_SIM, 0,
2985 "/type", CHM_TYP, CM_ARG,
2986 "/verbose", CHM_VRB, CM_INV,
2988 static int nchmodsw = (sizeof(uchmodsw) / sizeof(struct keytab));
2992 extern int recursive, nscanfile, diractive;
2994 extern int tt_rows, tt_cols;
2996 #endif /* CK_TTGWSIZ */
2997 int i, files = 1, t1 = 1, t2 = 0, x, y, z, verbose = 0, rc = 1, paging;
2998 int xmode = -1, fs = 0, getval = 0, simulate = 0, wild = 0;
3007 #endif /* CK_TTGWSIZ */
3011 cmfdbi(&sw, /* First FDB - command switches */
3013 "Octal file permission code, or switch",
3015 "", /* addtl string data */
3016 nchmodsw, /* addtl numeric data 1: tbl size */
3017 4, /* addtl numeric data 2: 4 = cmswi */
3018 xxstring, /* Processing function */
3019 uchmodsw, /* Keyword table */
3020 &nu /* Pointer to next FDB */
3023 _CMNUM, /* Number */
3024 "", /* Help message */
3029 xxstring, /* Processing function */
3035 if ((x = cmfdb(&sw)) < 0) {
3038 printf("?Filename required\n");
3042 if (cmresult.fcode != _CMKEY)
3045 getval = (c == ':' || c == '=');
3046 if (getval && !(cmgkwflgs() & CM_ARG)) {
3047 printf("?This switch does not take an argument\n");
3050 if (!getval && (cmgkwflgs() & CM_ARG)) {
3051 printf("?This switch requires an argument\n");
3054 switch (cmresult.nresult) {
3088 extern struct keytab txtbin[];
3089 if ((x = cmkey(txtbin,3,"","",xxstring)) < 0)
3091 if (x == 2) { /* ALL */
3093 } else { /* TEXT or BINARY only */
3101 z = cmresult.nresult;
3102 x = cmifi2("File specification","",&s,&wild,t1,NULL,xxstring,t2);
3105 printf("?A file specification is required\n");
3110 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
3112 if ((x = cmcfm()) < 0)
3115 if (wild) files = zxrewind();
3117 if (wild) files = nzxpand(s,0);
3118 #endif /* ZXREWIND */
3124 if (verbose && paging) {
3128 if (ttgwsiz() > 0) {
3129 if (tt_rows > 0 && tt_cols > 0) {
3136 #endif /* CK_TTGWSIZ */
3138 for (i = 0; i < files; i++) {
3139 if (files == 1 && wild == 0) { /* For "chmod 777 ." */
3140 ckstrncpy(line,s,LINBUFSIZ);
3145 printf("?No files match - \"%s\"\n",line);
3153 /* If /TYPE:TEXT or BINARY given, skip directories and links */
3154 /* since they are neither text nor binary. */
3155 extern int zgfs_dir, zgfs_link;
3157 if (zgfs_dir || zgfs_link)
3160 if (zchki(line) < 0)
3162 #endif /* VMSORUNIX */
3163 /* Regular file, scan it */
3164 switch (scanfile(line,&y,nscanfile)) {
3175 #endif /* UNICODE */
3182 extern int zchkod; /* Unidentified Flying */
3183 int xx = zchkod; /* API Extension... */
3186 if (zchko(line) < 0)
3187 printf("%s - Access denied\n",line);
3189 printf("%s - OK\n",line);
3194 if (zsetperm(line,z) < 1) {
3195 if (verbose || files < 2) {
3196 printf("%s: %s\n",line,ck_errstr());
3199 } else if (verbose) {
3200 printf("%s %s\n",ziperm(line),line);
3204 if (verbose && paging) { /* Pause at end of screen */
3205 if (cmd_rows > 0 && cmd_cols > 0) {
3206 if (++n > cmd_rows - 3) {
3214 #endif /* CK_TTGWSIZ */
3217 return(success = rc);
3220 #endif /* CK_PERMS */
3222 #ifndef NOSPL /* S-Expressions */
3225 struct keytab sexptab[] = {
3226 "depth-limit", 1, 0,
3230 static int sexpmaxdep = 1000; /* Maximum depth */
3232 #define xxfloat(s,x) \
3233 ((isdigit(*s)||(*s=='-')||(*s=='+')||(*s=='.')||(*s=='\040'))?isfloat(s,x):0)
3235 #define SX_ADD 1 /* Symbols for built-in operators */
3279 /* Operator flags */
3281 #define SXF_PRE 256 /* Predicate */
3282 #define SXF_ONE 512 /* Requires one arg */
3283 #define SXF_TWO 1024 /* Requires two args or more */
3284 #define SXF_FLO 2048 /* Coerce to floating-point */
3286 /* Built-in constants */
3288 #define SXC_NIL 1 /* NIL */
3289 #define SXC_PI 2 /* PI */
3290 #define SXC_T 3 /* T */
3293 This is an xlookup() table and so need not be in "alhabetical" order.
3294 Therefore entries are arranged to minimize search for most common
3297 static struct keytab sexpops[] = { /* Built-in operators */
3298 "setq", SX_SET, 0, /* Global assignment */
3299 "+", SX_ADD, 0, /* Simple arithmetic */
3302 "/", SX_DIV, SXF_TWO,
3303 "^", SX_POW, SXF_TWO,
3305 "if", SX_IFC, SXF_TWO, /* IF */
3306 "let", SX_LET, 0, /* Local assignment */
3307 "not", SX_NOT, SXF_ONE, /* NOT */
3308 "mod", SX_MOD, SXF_TWO, /* Modulus */
3310 "<", SX_ALT, SXF_PRE|SXF_TWO, /* Comparisons */
3311 ">", SX_AGT, SXF_PRE|SXF_TWO,
3312 "<=", SX_ALE, SXF_PRE|SXF_TWO,
3313 "=", SX_AEQ, SXF_PRE|SXF_TWO,
3314 ">=", SX_AGE, SXF_PRE|SXF_TWO,
3315 "!=", SX_NEQ, SXF_PRE|SXF_TWO,
3317 "++", SX_INC, SXF_ONE|SXF_TWO, /* Increment */
3318 "--", SX_DEC, SXF_ONE|SXF_TWO, /* Decrement */
3320 "**", SX_POW, SXF_TWO, /* Common synonyms */
3321 "==", SX_AEQ, SXF_PRE|SXF_TWO,
3322 "!", SX_NOT, SXF_ONE,
3325 "and", SX_AND, 0, /* Logical operators */
3327 "xor", SX_XOR, SXF_TWO,
3329 "max", SX_MAX, SXF_ONE|SXF_TWO, /* Max and min */
3330 "min", SX_MIN, SXF_ONE|SXF_TWO,
3332 "%", SX_MOD, SXF_TWO, /* More synonyms */
3336 "quote", SX_QUO, SXF_ONE,
3337 "string", SX_STR, SXF_ONE,
3339 "eval", SX_EVA, 0, /* Assorted commands */
3340 "abs", SX_ABS, SXF_ONE,
3341 "truncate",SX_TRU, SXF_ONE|SXF_FLO,
3342 "round", SX_ROU, SXF_ONE|SXF_FLO,
3343 "ceiling", SX_CEI, SXF_ONE|SXF_FLO,
3344 "floor", SX_FLR, SXF_ONE|SXF_FLO,
3345 "float", SX_FLO, SXF_ONE|SXF_FLO,
3348 "sqrt", SX_SQR, SXF_ONE|SXF_FLO, /* Floating point functions */
3349 "exp", SX_EXP, SXF_ONE|SXF_FLO,
3350 "sin", SX_SIN, SXF_ONE|SXF_FLO,
3351 "cos", SX_COS, SXF_ONE|SXF_FLO,
3352 "tan", SX_TAN, SXF_ONE|SXF_FLO,
3353 "log", SX_LGN, SXF_ONE|SXF_FLO,
3354 "log10", SX_LGX, SXF_ONE|SXF_FLO,
3355 #endif /* FNFLOAT */
3357 "#", SX_BWX, SXF_TWO, /* Bitwise operators */
3360 "~", SX_BWN, SXF_ONE,
3361 "", 0, 0 /* (end) */
3363 static int nsexpops = (sizeof(sexpops) / sizeof(struct keytab)) - 1;
3365 static struct keytab sexpconsts[] = { /* Built-in constants */
3366 "nil", SXC_NIL, 0, /* NIL (false) */
3367 "pi", SXC_PI, 0, /* Pi (3.1415926...) */
3368 "t", SXC_T, 0, /* T (true) */
3371 static int nsexpconsts = (sizeof(sexpconsts) / sizeof(struct keytab)) - 1;
3373 int sexprc = 0; /* S-Expression error flag */
3374 int sexppv = -1; /* Predicate value */
3376 #define SXMLEN 64 /* Macro arg list initial length */
3377 #include <math.h> /* Floating-point functions */
3379 _PROTOTYP( char * fpformat, (CKFLOAT, int, int) );
3381 extern char math_pi[]; /* Value of Pi */
3382 extern int sexpecho; /* SET SEXPRESSION ECHO value */
3383 extern char * sexpval; /* Last top-level S-Expression value */
3384 extern char * lastsexp; /* Last S-Expression */
3385 int sexprmax = 0; /* Longest result (for stats) */
3386 int sexpdmax = 0; /* Max depth reached (for stats) */
3387 int sexpdep = 0; /* dosexp() recursion depth */
3388 static int * sxrlen = NULL; /* Result stack string sizes */
3389 static char ** sxresult = NULL; /* Result stack */
3391 /* s h o s e x p -- Show S-Expression info */
3396 printf(" sexpression echo-result: %s\n",showooa(sexpecho));
3397 printf(" sexpression depth-limit: %d\n",sexpmaxdep);
3399 printf(" maximum depth reached: %d\n",sexpdmax);
3400 printf(" longest result returned: %d\n",sexprmax);
3402 printf(" last sexpression: %s\n",lastsexp ? lastsexp : "(none)");
3403 printf(" last value: %s\n",sexpval ? sexpval : "(none)");
3409 sexpdebug(s) char * s; {
3410 /* For debugging -- includes recursion depth in each debug entry */
3411 static char buf[64];
3412 ckmakmsg(buf,64,"dosexp[",ckitoa(sexpdep),"] ",s);
3413 return((char *)buf);
3416 /* d o s e x p -- S-Expression Reader */
3418 /* Returns value as string (empty, numeric, or non-numeric) */
3421 dosexp(s) char *s; { /* s = S-Expression */
3422 extern struct mtab *mactab; /* Macro table */
3423 extern int maclvl, nmac;
3424 extern char *mrval[];
3425 extern int makestrlen; /* (see makestr()) */
3426 struct stringarray * q = NULL; /* cksplit() return type */
3427 char * p[SEXPMAX+1], ** p2; /* List items (must be on stack) */
3428 char * line = NULL; /* For building macro argument list */
3432 int quote = 0; /* LISP quote flag */
3433 char * s2; /* Workers */
3434 int i, j, k, n = 0, x = 0, kw, kwflags, mx = 0;
3435 int result = 0, not = 0, truncate = 0, builtin = 0;
3436 int fpflag = 0, quit = 0, macro = 0;
3437 CKFLOAT fpj, fpresult = 0.0; /* Floating-point results */
3438 int pflag = 0; /* Have predicate */
3439 int presult = 0; /* Predicate result */
3440 int mustfree = 0; /* If we malloc'd we must free */
3442 sexppv = -1; /* Predicate value */
3443 s2 = ""; /* Default return value */
3445 if (++sexpdep > sexpmaxdep) { /* Keep track of depth */
3446 printf("?S-Expression depth limit exceeded: %d\n",sexpmaxdep);
3448 debug(F111,sexpdebug("max depth exceeded"),s,sexprc);
3450 if (sexpdep > sexpdmax) /* For stats */
3453 if (sexprc) /* Error, quit all levels */
3454 goto xdosexp; /* Always goto common exit point */
3456 debug(F111,sexpdebug("entry"),s,sexprc);
3458 if (!s) s = ""; /* Null or empty arg */
3460 while (*s == SP) s++; /* Strip leading spaces */
3461 if (!*s) /* so empty result */
3465 Allocate result stack upon first use, or after it has been resized with
3466 SET SEXP DEPTH-LIMIT.
3469 sxresult = (char **)malloc(sexpmaxdep * sizeof(char *));
3471 printf("?Memory allocation failure - \"%s\"\n", s);
3475 sxrlen = (int *)malloc(sexpmaxdep * sizeof(int));
3477 printf("?Memory allocation failure - \"%s\"\n", s);
3481 for (i = 0; i < sexpmaxdep; i++) {
3482 sxresult[i] = NULL; /* Result pointers */
3483 sxrlen[i] = 0; /* Buffer sizes */
3486 s2 = s; /* s2 is the result pointer */
3487 k = 0; /* Length accumulator */
3488 if (s[0] == '(') { /* Starts with open paren? */
3489 while (*s2++) k++; /* Get length */
3490 if (s[k-1] == ')') { /* Strip outer parens if any */
3494 while (*s == SP) { /* Strip leading spaces from result */
3498 while (k > 0 && s[k-1] == SP) { /* And trailing spaces. */
3503 if (!*s) { /* If nothing remains */
3504 s2 = ""; /* return empty result. */
3508 /* Break result up into "words" (an SEXP counts as a word) */
3510 p[0] = NULL; /* (We don't use element 0) */
3511 if (!*(s+1) || !*(s+2)) { /* No need to call cksplit() */
3512 n = 1; /* if it's one or two chars. */
3513 p[1] = s; /* No need to malloc this either. */
3515 debug(F101,sexpdebug("nosplit"),"",n);
3516 if (s[0] == '(') { /* () empty */
3522 q = cksplit(1,SEXPMAX,s,NULL,"\\%[]&$+-/=*^_@!{}/<>|.#~'`:;?",8,39,0);
3525 n = q->a_size; /* Number of items */
3526 debug(F101,sexpdebug("split"),"",n);
3527 if (n < 0 || n > SEXPMAX) { /* Check for too many */
3528 printf("?Too many operands: max = %d\n",SEXPMAX);
3532 if (n == 0) /* None, result is NULL, done. */
3534 if (n == 1 && s[0] == '(') { /* One but it's another SEXP */
3538 p2 = q->a_head; /* Point to result array. */
3539 for (i = 1; i <= n; i++) { /* We must copy it because */
3540 p[i] = NULL; /* recursive calls to dosexp() */
3541 if (p2[i]) /* write over the same array */
3542 makestr(&(p[i]),p2[i]);
3544 if (s[0] == '(') { /* Operator is an S-Expression */
3545 s2 = dosexp(p[1]); /* Replace it by its value */
3546 makestr(&(p[1]),s2);
3548 mustfree++; /* Remember to free it */
3550 debug(F110,sexpdebug("head"),p[1],0);
3552 if (n == 1 && p[1]) {
3553 if (*(p[1]) == '\047') {
3559 This section sidesteps xlookup() of the most common operators.
3560 It's not necessary but it speeds up SEXP-heavy loops by about 10%.
3563 if (n > 0) { /* Look up the operator */
3564 s2 = p[1]; /* Prelookup optimization... */
3571 if (isdigit(*s2)) { /* Digit */
3574 } else if (isalpha(*s2) && !*(s2+1)) { /* Single letter */
3577 } else if (*s2 == 's' || *s2 == 'S') { /* SETQ */
3579 if (*s2 == 'e' || *s2 == 'E') {
3581 if (*s2 == 't' || *s2 == 'T') {
3583 if (*s2 == 'q' || *s2 == 'Q') {
3594 if (!*(s2+1)) { /* Common single-character ops */
3599 } else if (*s2 == '-') {
3603 } else if (*s2 == '*') {
3607 } else if (*s2 == '/') {
3613 if (!x) { /* None of the above, look it up */
3614 x = xlookup(sexpops,p[1],nsexpops,&kw);
3615 debug(F111,"XXX",p[1],x);
3617 kwflags = sexpops[kw].flgs;
3623 /* If none of the above, check built-in constants */
3626 x = xlookup(sexpconsts,p[1],nsexpconsts,&kw);
3641 if (n == 1) { /* Not an expression */
3642 if (builtin) { /* Built-in operand? */
3643 switch (x) { /* Operators with default values */
3647 case SX_MUL: /* (*) */
3648 s2 = sexpval ? sexpval : "1";
3650 case SX_AND: /* (AND) */
3651 case SX_BWA: /* Bitwise (&) */
3653 case SX_LOR: /* (OR) */
3654 case SX_BWO: /* Bitwise (|) */
3655 case SX_ADD: /* (+) */
3656 case SX_SUB: /* (-) */
3657 s2 = result ? "1" : "0";
3661 } else { /* Not a built-in operand */
3664 while (*p1 == SP) p1++;
3665 if (!isalpha(*p1)) {
3666 if (xxfloat(p1,0) > 0) { /* Is it a number? */
3668 while (*s2 == '+') s2++;
3669 } else if (*p1 == '(') { /* An S-Expression? */
3675 #endif /* COMMENT */
3678 } else if (x < 1) { /* Is it a variable? */
3679 j = mxlook(mactab,p[1],nmac); /* Look it up */
3680 debug(F111,sexpdebug("n==1 mxlook"),p[1],j);
3681 s2 = (j > -1) ? mactab[j].mval : "";
3683 if (xxfloat(s2,0) > 0) /* Macro value is a number */
3685 if (j > -1) { /* It's a macro */
3687 x = j; /* whose definition is not numeric */
3688 if (*s2 == '(') { /* Is it an S-Expression? */
3689 /* We have to allocate memory on the stack */
3690 /* to call ourselves recursively on it */
3691 /* otherwise we'll wipe out the macro definition */
3696 s3 = (char *)malloc(k + 4);
3698 strcpy(s3,s2); /* SAFE */
3699 s2 = dosexp(s3); /* Evaluate it */
3702 printf("?Memory allocation failure - \"%s\"\n",s2);
3707 if (*s2 == '\047') {
3710 /* Dumps core if petty optimization was taken */
3711 makestr(&(p[1]),s2);
3713 if (!nosplit && p[1]) free(p[1]);
3714 p[1] = (char *)malloc((int)strlen(s2) + 1);
3715 #endif /* COMMENT */
3719 if (s2[makestrlen-1] == ')') {
3720 s2[makestrlen-1] = NUL;
3724 debug(F110,sexpdebug("'A"),s2,0);
3727 macro++; /* Not an S-Expression */
3728 } else { /* Not found in macro table */
3729 printf("?Not defined - \"%s\"\n", p[1]);
3735 } else if (x < 1 && !macro) { /* n > 1 and not a built-in operator */
3736 x = mxlook(mactab,p[1],nmac); /* See if it's a macro */
3737 debug(F111,sexpdebug("n!=1 mxlook"),p[1],x);
3739 printf("?Invalid operand - \"%s\"\n",p[1]);
3746 if (builtin) { /* Built-in operator... */
3749 if ((flgs = (kwflags & (SXF_ONE|SXF_TWO)))) {
3751 case (SXF_ONE|SXF_TWO):
3753 printf("?Too few operands - \"%s\"\n",s);
3760 printf("?Too few operands - \"%s\"\n",s);
3767 printf("?Too %s operands - \"%s\"\n",
3768 (n > 2) ? "many" : "few", s);
3774 if (kwflags & SXF_PRE) { /* Predicate? */
3778 if (kwflags & SXF_FLO) /* Operator requires floating point */
3779 fpflag++; /* Force it */
3781 if (x == SX_SET || x == SX_LET || /* Assignment is special */
3782 x == SX_INC || x == SX_DEC) {
3790 for (i = 1; i < n; i += 2) { /* Loop thru operand pairs */
3794 debug(F110,sexpdebug("target p"),s3,0);
3796 /* Make sure target doesn't have multiple words */
3797 while (*s3) { if (*s3 < '!') { rc = 1; break; }; s3++; }
3799 if (rc) { /* If it does it must have been */
3800 char * s4; /* an SEXP so evaluate it */
3804 while (*s4) { if (*s4 < '!') { rc = 1; break; }; s4++; }
3805 if (rc == 0) makestr(&(p[i+1]),s3);
3808 /* And that it's not a number, etc. */
3809 if (rc > 0 || isdigit(c) || c == '(') {
3810 printf("?Invalid assignment - \"%s\"\n",s);
3813 } else if (isalpha(c)) {
3814 rc = xlookup(sexpconsts,s3,nsexpconsts,NULL);
3816 printf("?Assignment to constant - \"%s\"\n",s);
3822 /* If ++ or --, get current value of variable */
3823 if (x == SX_INC || x == SX_DEC) {
3826 if (c == CMDQ) { /* A backslash variable */
3830 if (zzstring(s3,&s,&n) < 0 || !buf[0])
3833 } else { /* A macro */
3834 if ((k = mxlook(mactab,s3,nmac)) < 0)
3837 s2 = mactab[k].mval;
3840 printf("?Not defined - \"%s\"\n",p[i+1]);
3847 printf("?Not numeric - \"%s\"\n",p[i+1]);
3851 while (*s2 == '+') s2++;
3853 fpresult = floatval;
3854 if (k > 1 || fpresult != result)
3857 if (n < i+2) { /* Variable with no value */
3859 if (x == SX_SET || x == SX_LET) {
3860 delmac(p[i+1],1); /* Delete the variable */
3865 } else { /* Variable with value */
3866 k = xxfloat(p[i+2],0); /* Is it a number? */
3869 while (*s2 == '+') s2++;
3871 s2 = dosexp(p[i+2]); /* Have value, evaluate it */
3872 if (sexprc) goto xdosexp;
3874 if (!*s2 && (x == SX_INC || x == SX_DEC))
3878 if (x == SX_INC || x == SX_DEC) {
3881 printf("?Not numeric - \"%s\"\n",s2);
3885 while (*s2 == '+') s2++;
3896 } else if (x == SX_DEC) {
3900 if (result != fpresult) fpflag++;
3901 s2 = fpflag ? fpformat(fpresult,0,0) : ckitoa(result);
3903 if (x == SX_LET && cmdlvl > 0) /* LET makes var local */
3905 if ((rc = addmac(p[i+1],s2)) < 0) { /* Add the value */
3907 case -3: m = "Array not declared"; break;
3908 case -2: m = "Subscript out of range"; break;
3909 case -4: m = "Out of memory"; break;
3910 default: m = "Error creating variable";
3912 printf("?%s - \"%s\"\n",m,s);
3916 if (s2) result = atoi(s2);
3919 } else if (x == SX_IFC) { /* Conditional expression */
3922 printf("?Too many operands: IF - \"%s\"\n",s);
3927 if (sexprc) goto xdosexp;
3930 if (xxfloat(s2,0) == 2) {
3932 fpresult = (CKFLOAT)result;
3937 true = ((fpj != 0.0) ? 1 : 0);
3939 if (!true && n < 4) {
3942 s2 = dosexp(true ? p[3] : p[4]);
3943 if (sexprc) goto xdosexp;
3944 j = s2 ? atoi(s2) : 0;
3945 if (xxfloat(s2,0) == 2) {
3947 fpresult = (CKFLOAT)result;
3950 fpj = s2 ? atof(s2) : 0.0;
3956 } else if (x == SX_QUO) {
3960 p[3] = (char *)malloc(xx+4);
3962 ckmakmsg(p[3],xx+4,"'(",p[2],")",NULL);
3966 #endif /* COMMENT */
3968 } else if (x == SX_STR) {
3971 if (sexprc) goto xdosexp;
3973 p[3] = (char *)malloc(xx+4);
3974 ckmakmsg(p[3],xx+4,"'(",s2,")",NULL);
3980 /* Arithmetic operator or macro - Loop thru operands */
3982 quit = 0; /* Short-circuit flag. */
3983 if (macro && n > 1) { /* If operator is a macro */
3984 if (!line) { /* allocate local buffer for */
3985 line = (char *)malloc(SXMLEN); /* the evaluated argument list. */
3987 printf("?Memory allocation failure - \"%s\"\n",p[1]);
3992 /* debug(F101,"dosexp macro arg buffer","",linelen); */
3995 line[linepos] = NUL;
3997 for (i = 1; ((i < n) && !sexprc && !quit); i++) { /* Loop thru operands */
3999 s2 = p[i+1]; /* Get operand */
4002 if (*s2 == '\047') { /* Is it quoted? */
4003 debug(F110,sexpdebug("'B"),s2,0);
4004 s2++; /* Space past the quote */
4006 if (*s2 == '(') { /* Quoted S-Expression? */
4007 char c4, * s4 = s2+1; /* Strip outer parens */
4008 while ((c4 = *s4++)) {
4009 if (c4 == ')' && !*s4) {
4016 debug(F110,sexpdebug("'C"),s2,0);
4018 } else { /* Not quoted */
4019 s2 = dosexp(p[i+1]); /* evaluate it */
4020 if (sexprc) goto xdosexp;
4022 if (!macro && x == SX_EVA)
4026 if (*s2 != '\047') { /* Is it quoted? */
4027 s2 = dosexp(p[i+1]); /* No, evaluate it */
4028 if (sexprc) goto xdosexp;
4030 if (!macro && x == SX_EVA)
4033 if (*s2 == '\047') { /* Is result quoted? */
4034 debug(F110,sexpdebug("'B"),s2,0);
4035 s2++; /* Space past the quote */
4037 if (*s2 == '(') { /* Quoted S-Expression? */
4038 char c4, * s4 = s2+1; /* Strip outer parens */
4039 while ((c4 = *s4++)) {
4040 if (c4 == ')' && !*s4) {
4047 debug(F110,sexpdebug("'C"),s2,0);
4049 #endif /* COMMENT */
4051 debug(F111,sexpdebug("macro arg"),s2,i);
4054 register char c4, * s4 = s2;
4055 while ((c4 = *s4++)) if (c4 == SP) { quote++; break; }
4057 if (quote) line[linepos++] = '{';
4058 while ((line[linepos++] = *s2++)) {
4059 if (linepos > linelen - 3) {
4061 line[linepos] = NUL;
4063 tmp = (char *) malloc(linelen);
4065 printf("?Memory re-allocation failure - \"%s...\"\n",
4075 linepos--; /* Back up over NUL */
4077 line[linepos++] = '}'; /* End quote group */
4078 line[linepos++] = SP; /* add a space */
4079 line[linepos] = NUL; /* and a NUL */
4082 if (!quote) { /* Built-in operator... */
4084 if (sexprc) goto xdosexp;
4091 /* An empty value is not a legal number */
4092 /* but it is a legal truth value */
4093 if (x != SX_AND && x != SX_LOR && x != SX_NOT) {
4094 printf("?Not Numeric - \"%s\"\n",p[i+1]);
4102 /* Switch to floating-point upon encountering any f.p. arg */
4103 /* OR... if integer is too big */
4104 if (!fpflag) if (xxfloat(s2,0) == 2)
4108 if (i == 1) { /* Initial result is first operand */
4109 result = (n == 2 && x == SX_SUB) ? 0-j : j;
4110 fpresult = (n == 2 && x == SX_SUB) ? -fpj : fpj;
4111 if (!(kwflags & SXF_ONE)) /* Command with single arg */
4114 if (x == SX_MOD || x == SX_DIV) {
4118 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4123 switch (x) { /* Accumulate result */
4125 case SX_EVA: /* EVAL */
4130 case SX_ADD: /* + */
4133 if (result != fpresult)
4137 case SX_SUB: /* - */
4140 if (result != fpresult)
4144 case SX_MUL: /* * */
4147 if (result != fpresult)
4151 case SX_AND: /* AND */
4152 result = result && j;
4153 if (!result) quit++;
4154 fpresult = fpresult && fpj;
4157 case SX_LOR: /* OR */
4158 result = result || j;
4159 if (!result) quit++;
4160 fpresult = fpresult || fpj;
4163 case SX_MOD: /* Modulus */
4164 result = result % j;
4166 fpresult = (CKFLOAT)fmod(fpresult,fpj);
4167 if (result != fpresult)
4171 #endif /* FNFLOAT */
4174 case SX_DIV: /* / */
4177 if (result != fpresult)
4181 case SX_AEQ: /* Test for equality */
4183 if (fpresult != fpj)
4191 case SX_NEQ: /* Test for ineqality */
4193 if (fpresult == fpj)
4201 case SX_ALE: /* Arithmetic less-equal */
4213 case SX_ALT: /* Arithmetic less-than */
4215 if (fpj <= fpresult)
4225 case SX_AGT: /* Arithmetic greater-than */
4227 if (fpj >= fpresult)
4237 case SX_AGE: /* Arithmetic greater-equal */
4249 case SX_POW: /* Raise to power */
4255 } else if ((!fpresult && fpj <= 0.0)) {
4256 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4259 } else if (fpresult < 0.0 && modf(fpj,&dummy)) {
4260 printf("?Domain error - \"%s\"\n",cmdbuf);
4264 fpresult = (CKFLOAT)pow(fpresult,fpj);
4267 #endif /* FNFLOAT */
4274 printf("?Divide by zero - \"%s\"\n",cmdbuf);
4285 result = 1 / result;
4287 if (result != fpresult)
4292 case SX_EXP: /* e to the given power */
4293 fpresult = (CKFLOAT) exp(fpj);
4296 case SX_LGN: /* Natural log */
4297 case SX_LGX: /* Log base 10 */
4298 case SX_SQR: /* Square root */
4300 printf("?Argument out of range - \"%s\"\n",cmdbuf);
4305 fpresult = (CKFLOAT) sqrt(fpj);
4306 else if (x == SX_LGN)
4307 fpresult = (CKFLOAT) log(fpj);
4309 fpresult = (CKFLOAT) log10(fpj);
4312 case SX_SIN: /* sine */
4313 fpresult = (CKFLOAT) sin(fpj);
4316 case SX_COS: /* cosine */
4317 fpresult = (CKFLOAT) cos(fpj);
4320 case SX_TAN: /* tangent */
4321 fpresult = (CKFLOAT) tan(fpj);
4323 #endif /* FNFLOAT */
4325 case SX_CEI: /* Ceiling */
4334 case SX_FLR: /* Floor */
4343 case SX_TRU: /* Truncate */
4349 case SX_ROU: /* Round */
4359 case SX_ABS: /* Absolute value */
4360 result = (j < 0) ? 0 - j : j;
4361 fpresult = (fpj < 0.0) ? 0.0 - fpj : fpj;
4362 if (result != fpresult)
4366 case SX_MAX: /* Max */
4377 case SX_MIN: /* Min */
4388 case SX_FLO: /* Float */
4394 case SX_NOT: /* NOT (reverse truth value) */
4399 case SX_BWA: /* Bitwise AND */
4404 case SX_BWO: /* Bitwise OR */
4409 case SX_BWX: /* Bitwise XOR */
4410 case SX_XOR: /* Logical XOR */
4412 printf("?Too many operands - \"%s\"\n",s);
4420 result = (result && !j) || (!result && j);
4421 if (result) result = 1;
4425 case SX_BWN: /* Bitwise Not */
4431 printf("BAD OP [%s]\n",p[1]);
4435 if (!pflag) /* Not a predicate */
4436 sexppv = -1; /* So unset this */
4440 if (macro) { /* User-defined macro */
4441 extern int fsexpflag; /* (see fneval():ckuus4.c) */
4442 int lookagain = 0; /* Maybe the macro table changed */
4443 if (mactab[mx].kwd) { /* Check and see */
4444 if (ckstrcmp(mactab[mx].kwd,p[1],-1,0))
4448 if (lookagain) { /* The table changed */
4449 mx = mxlook(mactab,p[1],nmac); /* Get the macro's new index */
4450 debug(F111,sexpdebug("macro moved"),p[1],mx);
4451 if (mx < 0) { /* Yikes! */
4452 printf("?Macro disappeared! - \"%s\"\n",p[1]);
4457 debug(F111,sexpdebug("macro mx"),mactab[mx].kwd,mx);
4458 if (fsexpflag) { /* If embedded in a function call */
4459 if (cmpush() > -1) { /* get a new copy of the parsing */
4460 extern int ifc; /* environment, */
4461 int k, ifcsav = ifc; /* save the IF state */
4462 dodo(mx,line,0); /* Set up the macro */
4463 k = parser(1); /* Call the parser to execute it */
4464 cmpop(); /* Pop back to previous level */
4465 ifc = ifcsav; /* restore IF state */
4466 if (k == 0) /* If no error */
4467 s2 = mrval[maclvl+1]; /* get return value, if any */
4469 debug(F110,sexpdebug("macro return"),s2,0);
4471 printf("?Resources exhausted - \"%s\"\n",s);
4474 } else { /* Not embedded in a function call */
4475 dodo(mx,line,0); /* As above but without cmpush/pop() */
4478 s2 = mrval[maclvl+1];
4481 } else if (pflag) { /* Predicate */
4482 if (not) presult = presult ? 0 : 1;
4483 sexppv = presult; /* So set predicate value (0 or 1) */
4484 s2 = presult ? "1" : "0";
4485 } else if (fpflag) { /* Result is floating-point */
4486 if (not) fpresult = fpresult ? 0.0 : 1.0;
4487 s2 = fpformat(fpresult,0,0);
4488 } else if (x != SX_EVA) {
4489 if (not) result = result ? 0 : 1;
4490 s2 = ckitoa(result);
4493 /* Common exit point. Always come here to exit. */
4498 if (!sexprc && s2) { /* Have a result */
4500 char * q2 = s2; int xx = 0;
4502 while (*q2++) xx++; /* Get length */
4503 if (xx > sexprmax) /* (stats) */
4507 if (xx > sxrlen[sexpdep] || !sxresult[sexpdep]) {
4511 if (sxresult[sexpdep])
4512 free(sxresult[sexpdep]);
4513 if ((sxresult[sexpdep] = (char *)malloc(k))) {
4514 sxrlen[sexpdep] = k;
4516 printf("?Memory allocation failure - \"%s\"\n",s2);
4520 sx = sxresult[sexpdep]; /* Point to result buffer */
4521 while ((*sx++ = *s2++)) ; /* copy result. */
4522 if (fpflag && truncate) { /* Floating point + truncate */
4523 sx = sxresult[sexpdep]; /* at decimal point */
4524 for (i = xx - 1; i >= 0; i--) {
4527 if (i == 0) { /* If nothing left */
4528 sx[0] = '0'; /* put a zero. */
4535 if (line) /* If macro arg buffer allocated */
4536 free(line); /* free it. */
4537 if (mustfree) { /* And free local copy of split list */
4538 for (i = 1; i <= n; i++) {
4539 if (p[i]) free(p[i]);
4542 debug(F111,sexpdebug("exit"),sxresult[sexpdep],sexprc);
4543 return(sxresult[sexpdep--]);
4548 int /* CHECK command */
4551 if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0)
4553 ckstrncpy(line,atmbuf,LINBUFSIZ);
4554 if ((y = cmcfm()) < 0)
4557 if (!ckstrcmp(line,"push",(int)strlen(line),0)) {
4558 if (msgflg) /* If at top level... */
4559 printf(" push%s available\n", nopush ? " not" : "");
4560 else if (nopush && !backgrd)
4561 printf(" CHECK: push not available\n");
4562 return(success = 1 - nopush);
4566 if (!ckstrcmp(line,"pipes",(int)strlen(line),0)) {
4567 if (msgflg) /* If at top level... */
4568 printf(" pipes%s available\n",
4569 (nopush || protocol != PROTO_K) ? " not" : "");
4570 else if ((nopush || protocol != PROTO_K) && !backgrd)
4571 printf(" CHECK: pipes not available\n");
4572 return(success = 1 - nopush);
4574 #endif /* PIPESEND */
4575 y = lookup(ftrtab,line,nftr,&x); /* Look it up */
4576 debug(F111,"dochk",ftrtab[x].kwd,y);
4577 if (msgflg) /* If at top level... */
4578 printf(" %s%s available\n", ftrtab[x].kwd, y ? " not" : "");
4579 else if (y && !backgrd)
4580 printf(" CHECK: %s not available\n", ftrtab[x].kwd);
4581 return(success = 1 - y);
4587 /* Connection log and elapsed-time reporting */
4589 extern char cxlogbuf[]; /* Log record buffer */
4590 extern char diafil[]; /* Log file name */
4591 extern int dialog, cx_active; /* Flags */
4592 static long cx_prev = 0L; /* Elapsed time of previous session */
4594 #endif /* CKLOGDIAL */
4595 #endif /* NOLOCAL */
4598 dologend() { /* Write record to connection log */
4600 extern int locus, autolocus;
4605 long d1, d2, t1, t2;
4607 #endif /* CKLOGDIAL */
4608 #endif /* NOLOCAL */
4614 extern int ftpisconnected();
4615 debug(F101,"dologend ftpisconnected","",ftpisconnected());
4616 setlocus(ftpisconnected() ? 0 : 1, 1);
4625 debug(F101,"dologend dialog","",dialog);
4626 debug(F101,"dologend cxlogbuf[0]","",cxlogbuf[0]);
4628 debug(F101,"dologend ckxlogging","",ckxlogging);
4629 #endif /* CKSYSLOG */
4631 if (!cx_active || !cxlogbuf[0]) /* No active record */
4634 cx_active = 0; /* Record is not active */
4635 debug(F111,"dologend cxlogbuf 1",cxlogbuf,cx_active);
4637 d1 = mjd((char *)cxlogbuf); /* Get start date of this session */
4638 ckstrncpy(buf,ckdate(),31); /* Get current date */
4639 d2 = mjd(buf); /* Convert them to mjds */
4640 p = cxlogbuf; /* Get start time */
4642 p[14] = NUL; /* Convert to seconds */
4643 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4646 p = buf; /* Get end time */
4649 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4650 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */
4651 debug(F101,"dologend t2","",t2);
4655 debug(F110,"dologend hhmmss",p,0);
4656 strncat(cxlogbuf,"E=",CXLOGBUFL); /* Append to log record */
4657 strncat(cxlogbuf,p,CXLOGBUFL);
4658 debug(F110,"dologend cxlogbuf 2",cxlogbuf,0);
4661 debug(F101,"dologend cx_prev","",cx_prev);
4662 if (dialog) { /* If logging */
4664 x = diaopn(diafil,1,1); /* Open log in append mode */
4665 debug(F101,"dologend diaopn","",x);
4666 x = zsoutl(ZDIFIL,cxlogbuf); /* Write the record */
4667 debug(F101,"dologend zsoutl","",x);
4668 x = zclose(ZDIFIL); /* Close the log */
4669 debug(F101,"dologend zclose","",x);
4672 debug(F101,"dologend ckxlogging","",ckxlogging);
4675 x = ckindex("T=DIAL",cxlogbuf,0,0,1);
4676 debug(F111,"dologend ckxsyslog",cxlogbuf,ckxsyslog);
4677 debug(F111,"dologend ckindex","T=DIAL",x);
4679 if (ckxsyslog >= SYSLG_DI) {
4680 debug(F110,"dologend syslog",cxlogbuf+18,0);
4681 cksyslog(SYSLG_DI,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4682 } else if (ckxsyslog >= SYSLG_AC) {
4683 debug(F110,"dologend syslog",cxlogbuf+18,0);
4684 cksyslog(SYSLG_AC,1,"CONNECTION",(char *)(cxlogbuf+18),"");
4688 #endif /* CKSYSLOG */
4689 #endif /* CKLOGDIAL */
4690 #endif /* NOLOCAL */
4696 /* D O L O G S H O W -- Show session/connection info */
4698 /* Call with fc == 1 to show, fc == 0 to only calculate. */
4699 /* Returns session elapsed time in seconds. */
4700 /* If no session active, returns elapsed time of previous session, if any, */
4704 dologshow(fc) int fc; { /* SHOW (current) CONNECTION */
4705 long d1, d2, t1, t2 = 0, prev;
4706 char c, buf1[32], buf2[32], * info[32], * p, * s;
4707 char * xlogbuf, xbuf[CXLOGBUFL+1];
4708 int i, x = 0, z, ftp = 0, active = 0;
4711 extern char ftplogbuf[];
4712 extern long ftplogprev;
4713 extern int ftplogactive;
4717 xlogbuf = ftplogbuf;
4719 active = ftplogactive;
4730 debug(F101,"dologshow local","",local);
4731 debug(F101,"dologshow ftp","",ftp);
4732 debug(F111,"dologshow active",xlogbuf,active);
4736 if (didsetlin || ftp)
4737 printf(" %s: No record.\n", ftp ? "FTP" : "Kermit");
4739 printf(" %s: No connection.\n", ftp ? "FTP" : "Kermit");
4746 z = ftpisconnected() ? 1 : -1;
4749 if (local) { /* See if we have an open connection */
4751 debug(F101,"dologshow ttchk","",z);
4752 z = (z > -1) ? 1 : -2;
4754 z = active ? 1 : -2;
4765 /* Note: NOT ckstrncpy! */
4766 strncpy(buf1,xlogbuf,17); /* Copy of just the timestamp */
4767 buf1[17] = NUL; /* Terminate it */
4768 ckstrncpy(xbuf,xlogbuf+18,CXLOGBUFL); /* Copy that can be poked */
4769 debug(F111,"dologshow prev",xbuf,prev);
4771 xwords(xbuf,31,info,1); /* Break up into fields */
4772 d1 = mjd(buf1); /* Convert start time to MJD */
4773 ckstrncpy(buf2,ckdate(),31); /* Current date */
4774 d2 = mjd(buf2); /* Convert to MJD */
4775 p = buf1; /* Point to start time */
4777 p[14] = NUL; /* Convert to seconds */
4778 t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4781 p = buf2; /* Ditto for current time */
4785 t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
4786 t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Elapsed time so far */
4790 if (t2 > -1L) /* Convert seconds to hh:mm:ss */
4798 printf("\n"); /* Show results */
4799 printf(" Status: %s\n",s);
4800 printf(" Opened: %s\n",buf1);
4801 printf(" User: %s\n",info[1] ? info[1] : "");
4802 printf(" PID: %s\n",info[2] ? info[2] : "");
4803 for (i = 3; info[i]; i++) {
4805 s = (info[i]) ? info[i]+2 : "";
4807 case 'T': printf(" Type: %s\n", s); break;
4808 case 'N': printf(" To: %s\n", s); break;
4809 case 'H': printf(" From: %s\n", s); break;
4810 case 'D': printf(" Device: %s\n", s); break;
4811 case 'O': printf(" Origin: %s\n", s); break;
4813 default: printf(" %s\n",info[i] ? info[i] : "");
4817 printf(" Elapsed time: %s\n", hhmmss(t2));
4819 printf(" Elapsed time: %s\n", p ? p : "(unknown)");
4823 if ( IS_SSH() ) x++;
4824 #endif /* SSHBUILTIN */
4825 #ifdef CK_ENCRYPTION
4826 if (ck_tn_encrypting() && ck_tn_decrypting()) x++;
4827 #endif /* CK_ENCRYPTION */
4829 if (tls_active_flag || ssl_active_flag) x++;
4833 #ifdef CK_ENCRYPTION
4834 if (ttnproto == NP_EK4LOGIN || ttnproto == NP_EK5LOGIN) x++;
4835 #endif /* CK_ENCRYPTION */
4836 #endif /* CK_KERBEROS */
4837 #endif /* RLOGCODE */
4838 #endif /* NETCONN */
4840 printf(" Encrypted: %s\n", x ? "Yes" : "No");
4841 printf(" Log: %s\n", dialog ? diafil : "(none)");
4844 return(t2 > -1L ? t2 : 0L);
4852 dologend(); /* Previous session not closed out? */
4853 cx_active = 1; /* Record is active */
4855 p = ckdate(); /* Get timestamp */
4856 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL-1); /* Start record off with it */
4858 debug(F100,"dologline uidbuf empty","",0);
4859 #ifdef UNIX /* Who has whoami()... */
4860 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4863 ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
4865 ckstrncpy(uidbuf,"UNKNOWN",UIDBUFLEN);
4866 #endif /* STRATUS */
4869 m = strlen(uidbuf) + strlen(myhost) + strlen(ttname) + 32;
4870 if (n+m < CXLOGBUFL-1) { /* Add serial device info */
4872 sprintf(p," %s %s T=SERIAL H=%s D=%s ", /* SAFE */
4879 ckstrncpy(cxlogbuf,"LOGLINE BUFFER OVERFLOW",CXLOGBUFL);
4880 debug(F110,"dologline",cxlogbuf,0);
4886 char * p, * s = "NET", * uu = uidbuf;
4889 dologend(); /* Previous session not closed out? */
4891 cx_active = 1; /* Record is active */
4893 n = ckstrncpy(cxlogbuf,p,CXLOGBUFL);
4895 if (nettype == NET_TCPB || nettype == NET_TCPA)
4897 #endif /* TCPSOCKET */
4899 if (nettype == NET_SX25 || nettype == NET_VX25 || nettype == NET_IX25)
4903 if (nettype == NET_DEC)
4907 if (nettype == NET_SLAT)
4909 #endif /* SUPERLAT */
4911 if (nettype == NET_BIOS)
4913 #endif /* CK_NETBIOS */
4916 debug(F100,"dolognet uidbuf empty","",0);
4917 #ifdef OS2ORUNIX /* Who has whoami()... */
4918 uu = (char *)whoami();
4921 uu = (char *)whoami();
4924 #endif /* STRATUS */
4927 m = strlen(uu) + strlen(myhost) + strlen(ttname) + strlen(s) + 32;
4928 if (n+m < CXLOGBUFL-1) { /* SAFE */
4930 sprintf(p," %s %s T=%s N=%s H=%s ",
4938 ckstrncpy(cxlogbuf,"LOGNET BUFFER OVERFLOW",CXLOGBUFL);
4939 debug(F110,"dolognet cxlogbuf",cxlogbuf,0);
4941 #endif /* NETCONN */
4942 #endif /* CKLOGDIAL */
4946 Parse a DIAL-related string, stripping enclosing braces, if any.
4949 dialstr(p,msg) char **p; char *msg; {
4953 if ((x = cmtxt(msg, "", &s, xxstring)) < 0)
4955 s = brstrip(s); /* Strip braces around. */
4956 debug(F110,"dialstr",s,0);
4957 makestr(p,*s?s:NULL);
4958 return(success = 1);
4966 mdmtyp = x; /* Set global modem type */
4967 debug(F101,"initmdm mdmtyp","",mdmtyp);
4968 debug(F101,"initmdm usermdm","",usermdm);
4971 m = usermdm ? usermdm : mdmtyp;
4973 p = modemp[m]; /* Point to modem info struct, and */
4974 debug(F101,"initmdm p","",p);
4976 dialec = p->capas & CKD_EC; /* set DIAL ERROR-CORRECTION, */
4977 dialdc = p->capas & CKD_DC; /* DIAL DATA-COMPRESSION, and */
4978 mdmspd = p->capas & CKD_SB ? 0 : 1; /* DIAL SPEED-MATCHING from it. */
4979 dialfc = FLO_AUTO; /* Modem's local flow control.. */
4980 dialmax = p->max_speed;
4981 dialcapas = p->capas;
4982 dialesc = p->esc_char;
4983 } else if (mdmtyp > 0) {
4984 printf("WARNING: modem info for \"%s\" not filled in yet\n",
4989 /* Reset or set the SET DIAL STRING items ... */
4993 debug(F110,"initmdm dialini",dialini,0);
4994 debug(F110,"initmdm dialmstr ",dialmstr,0);
4995 debug(F110,"initmdm dialmprmt",dialmprmt,0);
4996 debug(F110,"initmdm dialcmd",dialcmd,0);
4997 debug(F110,"initmdm dialdcon",dialdcon,0);
4998 debug(F110,"initmdm dialdcoff",dialdcoff,0);
4999 debug(F110,"initmdm dialecon",dialecon,0);
5000 debug(F110,"initmdm dialecoff",dialecoff,0);
5001 debug(F110,"initmdm dialhcmd",dialhcmd,0);
5002 debug(F110,"initmdm dialhwfc",dialhwfc,0);
5003 debug(F110,"initmdm dialswfc",dialswfc,0);
5004 debug(F110,"initmdm dialnofc",dialnofc,0);
5005 debug(F110,"initmdm dialtone",dialtone,0);
5006 debug(F110,"initmdm dialpulse",dialpulse,0);
5007 debug(F110,"initmdm dialname",dialname,0);
5008 debug(F110,"initmdm dialaaon",dialaaon,0);
5009 debug(F110,"initmdm dialaaoff",dialaaoff,0);
5010 debug(F110,"initmdm dialx3",dialx3,0);
5011 debug(F110,"initmdm dialspon",dialspon,0);
5012 debug(F110,"initmdm dialspoff",dialspoff,0);
5013 debug(F110,"initmdm dialvol1",dialvol1,0);
5014 debug(F110,"initmdm dialvol2",dialvol2,0);
5015 debug(F110,"initmdm dialvol3",dialvol3,0);
5016 debug(F110,"initmdm dialini2",dialini2,0);
5020 if (usermdm && p) { /* USER-DEFINED: copy info from specified template */
5022 makestr(&dialini ,p->wake_str);
5023 makestr(&dialmstr ,p->dmode_str);
5024 makestr(&dialmprmt,p->dmode_prompt);
5025 makestr(&dialcmd ,p->dial_str);
5026 makestr(&dialdcon ,p->dc_on_str);
5027 makestr(&dialdcoff,p->dc_off_str);
5028 makestr(&dialecon ,p->ec_on_str);
5029 makestr(&dialecoff,p->ec_off_str);
5030 makestr(&dialhcmd ,p->hup_str);
5031 makestr(&dialhwfc ,p->hwfc_str);
5032 makestr(&dialswfc ,p->swfc_str);
5033 makestr(&dialnofc ,p->nofc_str);
5034 makestr(&dialtone ,p->tone);
5035 makestr(&dialpulse,p->pulse);
5036 makestr(&dialname ,"This space available (use SET MODEM NAME)");
5037 makestr(&dialaaon ,p->aa_on_str);
5038 makestr(&dialaaoff,p->aa_off_str);
5039 makestr(&dialx3 ,p->ignoredt);
5040 makestr(&dialspon ,p->sp_on_str);
5041 makestr(&dialspoff,p->sp_off_str);
5042 makestr(&dialvol1 ,p->vol1_str);
5043 makestr(&dialvol2 ,p->vol2_str);
5044 makestr(&dialvol3 ,p->vol3_str);
5045 makestr(&dialini2 ,p->ini2);
5047 } else { /* Not user-defined, so wipe out overrides */
5049 if (dialini) makestr(&dialini,NULL); /* Init-string */
5050 if (dialmstr) makestr(&dialmstr,NULL); /* Dial-mode-str */
5051 if (dialmprmt) makestr(&dialmprmt,NULL); /* Dial-mode-pro */
5052 if (dialcmd) makestr(&dialcmd,NULL); /* Dial-command */
5053 if (dialdcon) makestr(&dialdcon,NULL); /* DC ON command */
5054 if (dialdcoff) makestr(&dialdcoff,NULL); /* DC OFF command */
5055 if (dialecon) makestr(&dialecon,NULL); /* EC ON command */
5056 if (dialecoff) makestr(&dialecoff,NULL); /* EC OFF command */
5057 if (dialhcmd) makestr(&dialhcmd,NULL); /* Hangup command */
5058 if (dialhwfc) makestr(&dialhwfc,NULL); /* Flow control... */
5059 if (dialswfc) makestr(&dialswfc,NULL); /* */
5060 if (dialnofc) makestr(&dialnofc,NULL); /* */
5061 if (dialtone) makestr(&dialtone,NULL); /* Dialing method */
5062 if (dialpulse) makestr(&dialpulse,NULL); /* */
5063 if (dialname) makestr(&dialname,NULL); /* Modem name */
5064 if (dialaaon) makestr(&dialaaon,NULL); /* Autoanswer On */
5065 if (dialaaoff) makestr(&dialaaoff,NULL); /* Autoanswer Off */
5066 if (dialx3) makestr(&dialx3,NULL); /* Ignore dialtone */
5067 if (dialspon) makestr(&dialspon,NULL); /* Speaker On */
5068 if (dialspoff) makestr(&dialspoff,NULL); /* Speaker Off */
5069 if (dialvol1) makestr(&dialvol1,NULL); /* Low volume */
5070 if (dialvol2) makestr(&dialvol2,NULL); /* Medium volume */
5071 if (dialvol3) makestr(&dialvol3,NULL); /* High volume */
5072 if (dialini2) makestr(&dialini2,NULL); /* Init string 2 */
5074 if (autoflow) /* Maybe change flow control */
5079 tbmodel = 0; /* If it's a Telebit, we don't know the model yet */
5080 #endif /* OLDTBCODE */
5081 #endif /* MINIDIAL */
5085 /* Not implemented yet */
5089 extern int ans_cid, ans_ring;
5090 if ((x = cmkey(answertab,nanswertab,"","",xxstring)) < 0)
5094 return(seton(&ans_cid));
5096 y = cmnum("How many rings before answering","1",10,&x,xxstring);
5097 y = setnum(&ans_rings,x,y,254);
5101 #endif /* COMMENT */
5104 setmodem() { /* SET MODEM */
5112 "Modem parameter","","",nsetmdm, 0, xxstring, setmdm, &k2);
5113 cmfdbi(&k2,_CMKEY,"","","",nmdm,0,xxstring,mdmtab,NULL);
5115 if (x < 0) { /* Error */
5116 if (x == -2 || x == -9)
5117 printf("?No keywords match: \"%s\"\n",atmbuf);
5120 y = cmresult.nresult; /* Keyword value */
5121 if (cmresult.fdbaddr == &k2) { /* Modem-type keyword table */
5122 if ((x = cmcfm()) < 0)
5125 initmdm(cmresult.nresult); /* Set the modem type. */
5126 return(success = 1); /* Done */
5128 switch (cmresult.nresult) { /* SET MODEM keyword table. */
5130 case XYDMHU: /* DIAL MODEM-HANGUP */
5131 if ((y = cmkey(mdmhang,4,"how to hang up modem",
5132 "modem-command", xxstring)) < 0)
5134 if ((x = cmcfm()) < 0)
5138 /* Nope, I fixed it (2001 11 08) */
5140 if (dialmhu == 0 && !quiet) {
5142 "\n WARNING: RS-232 signal sampling and manipulation do not work\n"
5145 " in the standard SCO OSR5 serial i/o drivers. SET MODEM HANGUP-METHOD\n"
5148 " MODEM-COMMAND is recommended for OSR5.\n\n"
5151 #endif /* CK_SCOV5 */
5152 #endif /* COMMENT */
5153 return(success = 1);
5160 if ((y = cmkey(mdmcap,nmdmcap,
5161 "capability of modem", "", xxstring)) < 0) {
5169 if ((x = cmcfm()) < 0)
5172 debug(F101,"setmodem autoflow","",autoflow);
5173 debug(F101,"setmodem flow 1","",flow);
5174 if (autoflow) /* Maybe change flow control */
5176 debug(F101,"setmodem flow 2","",flow);
5177 mdmspd = zz & CKD_SB ? 0 : 1; /* Set MODEM SPEED-MATCHING from it. */
5178 return(success = 1);
5182 if (network && istncomport())
5183 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
5185 #endif /* TN_COMPORT */
5186 x = cmkey(spdtab,nspd,line,"",xxstring);
5188 if (x == -3) printf("?value required\n");
5191 if ((y = cmcfm()) < 0) return(y);
5192 dialmax = (long) x * 10L;
5193 if (dialmax == 70) dialmax = 75;
5194 return(success = 1);
5196 case XYDSTR: /* These moved from SET DIAL */
5207 if ((y = cmkey(mdmtab,nmdm,"modem type","none", xxstring)) < 0)
5209 if (y == dialudt) { /* User-defined modem type */
5210 if ((x = cmkey(mdmtab,nmdm,"based on existing modem type",
5211 "unknown", xxstring)) < 0)
5214 if ((z = cmcfm()) < 0)
5217 usermdm = (y == dialudt) ? x : 0;
5219 mdmset = (mdmtyp > 0);
5220 return(success = 1);
5223 return(dialstr(&dialname,"Descriptive name for modem"));
5225 case XYDMCD: /* SET MODEM CARRIER-WATCH */
5228 case XYDSPK: /* SET MODEM SPEAKER */
5229 return(seton(&mdmspk));
5231 case XYDVOL: /* SET MODEM VOLUME */
5232 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0)
5234 if ((y = cmcfm()) < 0)
5237 return(success = 1);
5240 printf("Unexpected SET MODEM parameter\n");
5245 static int /* Set DIAL command options */
5251 if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0)
5254 case XYDHUP: /* DIAL HANGUP */
5255 return(seton(&dialhng));
5256 case XYDINI: /* DIAL INIT-STRING */
5257 return(dialstr(&dialini,"Modem initialization string"));
5258 case XYDNPR: /* DIAL PREFIX */
5259 return(dialstr(&dialnpr,"Telephone number prefix"));
5260 case XYDDIA: /* DIAL DIAL-COMMAND */
5261 x = cmtxt("Dialing command for modem,\n\
5262 include \"%s\" to stand for phone number,\n\
5263 for example, \"set dial dial-command ATDT%s\\13\"",
5267 if (x < 0 && x != -3) /* Handle parse errors */
5269 s = brstrip(s); /* Strip braces or quotes */
5270 y = x = strlen(s); /* Get length of text */
5271 if (y > 0) { /* If there is any text (left), */
5272 for (x = 0; x < y; x++) { /* make sure they included "%s" */
5273 if (s[x] != '%') continue;
5274 if (s[x+1] == 's') break;
5278 "?Dial-command must contain \"%cs\" for phone number.\n",'%');
5282 if (dialcmd) { /* Free any previous string. */
5284 dialcmd = (char *) 0;
5287 dialcmd = malloc(y + 1); /* Allocate space for it */
5289 strcpy(dialcmd,s); /* and make a safe copy. */
5291 return(success = 1);
5293 case XYDKSP: /* DIAL KERMIT-SPOOF */
5294 return(seton(&dialksp));
5296 case XYDTMO: /* DIAL TIMEOUT */
5297 y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);
5298 if (y < 0) return(y);
5299 y = cmnum("Kermit/modem timeout differential","10",10,&z,xxstring);
5300 if (y < 0) return(y);
5301 if ((y = cmcfm()) < 0)
5305 case XYDESC: /* DIAL ESCAPE-CHARACTER */
5306 y = cmnum("ASCII value of character to escape back to modem",
5307 "43",10,&x,xxstring);
5308 y = setnum(&dialesc,x,y,128);
5309 if (y > -1 && dialesc < 0) /* No escape character */
5310 dialmhu = 0; /* So no hangup by modem command */
5312 case XYDDPY: /* DIAL DISPLAY */
5313 return(seton(&dialdpy));
5314 case XYDSPD: /* DIAL SPEED-MATCHING */
5315 /* used to be speed-changing */
5316 if ((y = seton(&mdmspd)) < 0) return(y);
5318 mdmspd = 1 - mdmspd; /* so here we reverse the meaning */
5319 #endif /* COMMENT */
5320 return(success = 1);
5321 case XYDMNP: /* DIAL MNP-ENABLE */
5322 case XYDEC: /* DIAL ERROR-CORRECTION */
5325 if (!dialec) dialdc = 0; /* OFF also turns off compression */
5328 case XYDDC: /* DIAL COMPRESSION */
5331 if (dialdc) dialec = 1; /* ON also turns on error correction */
5335 case XYDMHU: /* DIAL MODEM-HANGUP */
5336 return(seton(&dialmhu));
5340 case XYDDIR: /* DIAL DIRECTORY (zero or more) */
5341 return(parsdir(0)); /* 0 means DIAL */
5344 case XYDSTR: /* DIAL STRING */
5345 if ((y = cmkey(mdmcmd,nmdmcmd,"","",xxstring)) < 0) return(y);
5347 case XYDS_AN: /* Autoanswer ON/OFF */
5348 case XYDS_DC: /* Data compression ON/OFF */
5349 case XYDS_EC: /* Error correction ON/OFF */
5350 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
5352 sprintf(tmpbuf,"Modem's command to %sable %s", /* SAFE */
5354 (y == XYDS_DC) ? "compression" :
5355 ((y == XYDS_EC) ? "error-correction" :
5360 return(dialstr(&dialdcon,tmpbuf));
5361 else if (y == XYDS_EC)
5362 return(dialstr(&dialecon,tmpbuf));
5364 return(dialstr(&dialaaon,tmpbuf));
5367 return(dialstr(&dialdcoff,tmpbuf));
5368 else if (y == XYDS_EC)
5369 return(dialstr(&dialecoff,tmpbuf));
5371 return(dialstr(&dialaaoff,tmpbuf));
5373 case XYDS_HU: /* hangup command */
5374 return(dialstr(&dialhcmd,"Modem's hangup command"));
5375 case XYDS_HW: /* hwfc */
5376 return(dialstr(&dialhwfc,
5377 "Modem's command to enable hardware flow control"));
5378 case XYDS_IN: /* init */
5379 return(dialstr(&dialini,"Modem's initialization string"));
5380 case XYDS_NF: /* no flow control */
5381 return(dialstr(&dialnofc,
5382 "Modem's command to disable local flow control"));
5383 case XYDS_PX: /* prefix */
5384 return(dialstr(&dialnpr,"Telephone number prefix for dialing"));
5385 case XYDS_SW: /* swfc */
5386 return(dialstr(&dialswfc,
5387 "Modem's command to enable local software flow control"));
5388 case XYDS_DT: /* tone dialing */
5389 return(dialstr(&dialtone,
5390 "Command to configure modem for tone dialing"));
5391 case XYDS_DP: /* pulse dialing */
5392 return(dialstr(&dialpulse,
5393 "Command to configure modem for pulse dialing"));
5394 case XYDS_MS: /* dial mode string */
5395 return(dialstr(&dialmstr,
5396 "Command to enter dial mode"));
5397 case XYDS_MP: /* dial mode prompt */
5398 return(dialstr(&dialmprmt,
5399 "Modem response upon entering dial mode"));
5400 case XYDS_SP: /* SPEAKER OFF */
5401 if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x);
5403 return(dialstr(&dialspon,"Command to turn modem speaker on"));
5405 return(dialstr(&dialspoff,"Command to turn modem speaker off"));
5407 case XYDS_VO: /* VOLUME LOW */
5408 if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0) return(x);
5412 return(dialstr(&dialvol1,
5413 "Command for low modem speaker volume"));
5415 return(dialstr(&dialvol2,
5416 "Command for medium modem speaker volume"));
5419 return(dialstr(&dialvol3,
5420 "Command for high modem speaker volume"));
5425 case XYDS_ID: /* IGNORE-DIALTONE */
5426 return(dialstr(&dialx3,
5427 "Command to tell modem to ignore dialtone"));
5429 case XYDS_I2: /* PREDIAL-INIT */
5430 return(dialstr(&dialini2,
5431 "Command to send to modem just prior to dialing"));
5434 printf("?Unexpected SET DIAL STRING parameter\n");
5437 case XYDFC: /* DIAL FLOW-CONTROL */
5438 if ((y = cmkey(dial_fc,4,"","auto",xxstring)) < 0) return(y);
5439 if ((x = cmcfm()) < 0) return(x);
5441 return(success = 1);
5443 case XYDMTH: { /* DIAL METHOD */
5444 extern int dialmauto;
5445 if ((y = cmkey(dial_m,ndial_m,"","default",xxstring)) < 0)
5447 if ((x = cmcfm()) < 0)
5449 if (y == XYDM_A) { /* AUTO */
5450 dialmauto = 1; /* local country code, if known. */
5453 dialmauto = 0; /* use the method specified */
5456 return(success = 1);
5459 y = cmnum("Number of times to try dialing a number",
5460 "1",10,&x,xxstring);
5461 z = setnum(&dialrtr,x,y,-1);
5462 if (z > -1 && dialrtr < 0) {
5463 printf("?Sorry, negative dial retries not valid: %d\n",dialrtr);
5469 y = cmnum("Seconds to wait between redial attempts",
5470 "30",10,&x,xxstring);
5471 z = setnum(&dialint,x,y,-1);
5472 if (z > -1 && dialint < 0) {
5473 printf("?Sorry, negative dial interval not valid: %d\n",dialint);
5478 case XYDLAC: /* DIAL AREA-CODE */
5479 if ((x = dialstr(&diallac,"Area code you are calling from")) < 0)
5482 if (!rdigits(diallac)) {
5483 printf("?Sorry, area code must be numeric\n");
5484 if (*diallac == '(')
5485 printf("(please omit the parentheses)\n");
5486 if (*diallac == '/')
5487 printf("(no slashes, please)\n");
5488 if (diallac) free(diallac);
5495 case XYDCNF: /* CONFIRMATION */
5496 return(success = seton(&dialcnf));
5498 case XYDCVT: /* CONVERT-DIRECTORY */
5499 if ((y = cmkey(dcnvtab,3,"","ask",xxstring)) < 0)
5501 if ((x = cmcfm()) < 0)
5504 return(success = 1);
5506 case XYDLCC: /* DIAL COUNTRY-CODE */
5507 x = dialstr(&diallcc,"Country code you are calling from");
5508 if (x < 1) return(x);
5510 if (!rdigits(diallcc)) {
5511 printf("?Sorry, country code must be numeric\n");
5512 if (*diallcc == '+')
5513 printf("(please omit the plus sign)\n");
5514 if (diallcc) free(diallcc);
5518 if (!strcmp(diallcc,"1")) { /* Set defaults for USA and Canada */
5519 if (!dialldp) /* Long-distance prefix */
5520 makestr(&dialldp,"1");
5521 if (!dialixp) /* International dialing prefix */
5522 makestr(&dialixp,"011");
5523 if (ntollfree == 0) { /* Toll-free area codes */
5524 if ((dialtfc[0] = malloc(4))) {
5525 strcpy(dialtfc[0],"800"); /* 1970-something */
5527 if ((dialtfc[1] = malloc(4))) {
5528 strcpy(dialtfc[1],"888"); /* 1996 */
5530 if ((dialtfc[2] = malloc(4))) {
5531 strcpy(dialtfc[2],"877"); /* 5 April 1998 */
5533 if ((dialtfc[3] = malloc(4))) {
5534 strcpy(dialtfc[3],"866"); /* 2000? */
5541 if (!dialtfp) /* Toll-free dialing prefix */
5542 makestr(&dialtfp,"1");
5544 /* The time for this is past */
5545 } else if (!strcmp(diallcc,"358") &&
5546 ((int) strcmp(zzndate(),"19961011") > 0)
5548 if (!dialldp) /* Long-distance prefix */
5549 makestr(&dialldp,"9");
5550 if (!dialixp) /* International dialing prefix */
5551 makestr(&dialixp,"990");
5552 #endif /* COMMENT */
5553 } else { /* Everywhere else ... */
5555 if ((dialldp = malloc(4)))
5556 strcpy(dialldp,"0");
5559 if ((dialixp = malloc(4)))
5560 strcpy(dialixp,"00");
5563 if (!strcmp(diallcc,"33")) /* France */
5564 dialfld = 1; /* Long-distance dialing is forced */
5566 return(success = 1);
5568 case XYDIXP: /* DIAL INTL-PREFIX */
5569 return(dialstr(&dialixp,"International dialing prefix"));
5571 case XYDIXS: /* DIAL INTL-SUFFIX */
5572 return(dialstr(&dialixs,"International dialing suffix"));
5574 case XYDLDP: /* DIAL LD-PREFIX */
5575 return(dialstr(&dialldp,"Long-distance dialing prefix"));
5577 case XYDLDS: /* DIAL LD-SUFFIX */
5578 return(dialstr(&diallds,"Long-distance dialing suffix"));
5580 case XYDLCP: /* DIAL LC-PREFIX */
5581 return(dialstr(&diallcp,"Local dialing prefix"));
5583 case XYDLCS: /* DIAL LC-SUFFIX */
5584 return(dialstr(&diallcs,"Local dialing suffix"));
5587 case XYDPXX: /* DIAL PBX-EXCHANGE */
5588 return(dialstr(&dialpxx,"Exchange of PBX you are calling from"));
5589 #endif /* COMMENT */
5591 case XYDPXI: { /* DIAL PBX-INTERNAL-PREFIX */
5593 return(dialstr(&dialpxi,
5594 "Internal-call prefix of PBX you are calling from"));
5597 if ((x = cmtxt("Internal-call prefix of PBX you are calling from",
5598 "",&s,NULL)) < 0) /* Don't evaluate */
5602 char c, * p = tmpbuf;
5605 if (isupper(c)) c = tolower(c);
5607 ckstrcmp(s,"\\v(d$px)",8,0) &&
5608 ckstrcmp(s,"\\v(d$pxx)",9,0) &&
5609 ckstrcmp(s,"\\v(d$p)",7,0)) {
5617 makestr(&dialpxi,s);
5620 #endif /* COMMENT */
5622 case XYDPXO: /* DIAL PBX-OUTSIDE-PREFIX */
5623 return(dialstr(&dialpxo,
5624 "Outside-line prefix of PBX you are calling from"));
5626 case XYDSFX: /* DIAL INTL-SUFFIX */
5627 return(dialstr(&dialsfx," Telephone number suffix for dialing"));
5629 case XYDSRT: /* DIAL SORT */
5630 return(success = seton(&dialsrt));
5632 case XYDPXX: /* DIAL PBX-EXCHANGE */
5633 case XYDTFC: { /* DIAL TOLL-FREE-AREA-CODE */
5634 int n, i; /* (zero or more of them...) */
5635 char * p[MAXTOLLFREE]; /* Temporary pointers */
5637 for (n = 0; n < MAXTOLLFREE; n++) {
5640 "Toll-free area code(s) in the country you are calling from"
5641 : "Exchange(s) of PBX you are calling from";
5644 "Another toll-free area code"
5645 : "Another PBX exchange";
5647 if ((x = cmfld(m,"",&s,xxstring)) < 0)
5651 k = (int) strlen(s);
5653 if ((p[n] = malloc(k + 1)))
5654 strcpy(p[n], s); /* safe */
5658 if (x == -3) { /* Command was successful */
5660 m = (y == XYDTFC) ? ntollfree : ndialpxx;
5661 if ((x = cmcfm()) < 0)
5664 for (i = 0; i < m; i++) { /* Remove old list, if any */
5666 makestr(&(dialtfc[i]),NULL);
5668 makestr(&(dialpxx[i]),NULL);
5671 ntollfree = n; /* New count */
5674 for (i = 0; i < n; i++) { /* New list */
5676 makestr(&(dialtfc[i]),p[i]);
5678 makestr(&(dialpxx[i]),p[i]);
5682 for (i = 0; i < n; i++)
5683 if (p[i]) free(p[i]);
5687 case XYDTFP: /* TOLL-FREE-PREFIX */
5688 return(dialstr(&dialtfp,
5689 " Long-distance prefix for toll-free dialing"));
5691 case XYDCON: /* CONNECT */
5693 if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);
5694 if (y != CAR_OFF) /* AUTO or ON? */
5695 if ((z = cmkey(qvtab,nqvt,"","verbose",xxstring)) < 0) return(z);
5696 if ((x = cmcfm()) < 0) return(x);
5700 return(success = 1);
5702 case XYDRSTR: /* RESTRICT */
5703 if ((y = cmkey(drstrtab,4,"","none",xxstring)) < 0) return(y);
5704 if ((x = cmcfm()) < 0) return(x);
5706 return(success = 1);
5708 case XYDLLAC: { /* Local area-code list */
5709 int n, i; /* (zero or more of them...) */
5710 char * p[MAXLOCALAC]; /* Temporary pointers */
5711 for (n = 0; n < MAXLOCALAC; n++) {
5713 "Area code to which calls from your area are local",
5714 "",&s,xxstring)) < 0)
5718 k = (int) strlen(s);
5720 if ((p[n] = malloc(k + 1)))
5721 strcpy(p[n], s); /* safe */
5725 if (x == -3) { /* Command was successful */
5726 if ((x = cmcfm()) < 0)
5728 for (i = 0; i < nlocalac; i++) /* Remove old list, if any */
5733 nlocalac = n; /* New count */
5734 for (i = 0; i < nlocalac; i++) /* New list */
5736 return(success = 1);
5737 } else { /* Parse error, undo everything */
5738 for (i = 0; i < n; i++)
5739 if (p[i]) free(p[i]);
5745 return(success = seton(&dialfld));
5747 case XYDIDT: /* DIAL IGNORE-DIALTONE */
5748 return(seton(&dialidt));
5752 "Milliseconds to pause between each character sent to dialer",
5754 return(setnum(&dialpace,x,y,9999));
5758 if ((x = cmfld("Name of macro to execute just prior to dialing",
5759 "",&s,xxstring)) < 0) {
5769 ckstrncpy(line,s,LINBUFSIZ);
5773 if ((x = cmcfm()) < 0)
5775 makestr(&dialmac,s);
5776 return(success = 1);
5779 case XYDPUCC: /* Pulse country codes */
5780 case XYDTOCC: { /* Tone country codes */
5784 for (n = 0; n < MAXTPCC; n++) {
5786 m = (y == XYDPUCC) ?
5787 "Country code where Pulse dialing is required"
5788 : "Country code where Tone dialing is available";
5790 m = "Another country code";
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 == XYDPUCC) ? ndialpucc : ndialtocc;
5805 if ((x = cmcfm()) < 0)
5808 for (i = 0; i < m; i++) { /* Remove old list, if any */
5810 makestr(&(dialpucc[i]),NULL);
5812 makestr(&(dialtocc[i]),NULL);
5815 ndialpucc = n; /* New count */
5819 for (i = 0; i < n; i++) { /* New list */
5821 makestr(&(dialpucc[i]),p[i]);
5823 makestr(&(dialtocc[i]),p[i]);
5828 for (i = 0; i < n; i++)
5829 if (p[i]) free(p[i]);
5833 return(seton(&dialtest));
5836 printf("?Unexpected SET DIAL parameter\n");
5842 int /* SHOW MODEM */
5851 printf("Sorry, command disabled\r\n");
5852 return(success = 0);
5859 mdm = (mdmtyp > 0) ? mdmtyp : mdmsav;
5860 p = (mdm > 0) ? modemp[mdm] : NULL;
5863 printf(" %s\n\n", dialname ? dialname : p->name);
5865 printf(" Modem capabilities: ");
5866 zz = dialcapas ? dialcapas : p->capas;
5870 if (zz & CKD_AT) printf(" AT");
5871 if (zz & CKD_V25) printf(" ITU");
5872 if (zz & CKD_SB) printf(" SB");
5873 if (zz & CKD_EC) printf(" EC");
5874 if (zz & CKD_DC) printf(" DC");
5875 if (zz & CKD_HW) printf(" HWFC");
5876 if (zz & CKD_SW) printf(" SWFC");
5877 if (zz & CKD_KS) printf(" KS");
5878 if (zz & CKD_TB) printf(" TB");
5880 printf("\n Modem carrier-watch: ");
5881 if (carrier == CAR_OFF) printf("off\n");
5882 else if (carrier == CAR_ON) printf("on\n");
5883 else if (carrier == CAR_AUT) printf("auto\n");
5884 else printf("unknown\n");
5886 printf(" Modem maximum-speed: ");
5887 zz = (dialmax > 0L) ? dialmax : p->max_speed;
5889 printf("%ld bps\n", zz);
5891 printf("(unknown)\n");
5892 printf(" Modem error-correction: %s\n", dialec ? "on" : "off");
5893 printf(" Modem compression: %s\n", dialdc ? "on" : "off");
5894 printf(" Modem speed-matching: %s", mdmspd ? "on" : "off");
5895 printf(" (interface speed %s)\n", mdmspd ? "changes" : "is locked");
5896 printf(" Modem flow-control: ");
5897 if (dialfc == FLO_NONE) printf("none\n");
5898 else if (dialfc == FLO_XONX) printf("xon/xoff\n");
5899 else if (dialfc == FLO_RTSC) printf("rts/cts\n");
5900 else if (dialfc == FLO_AUTO) printf("auto\n");
5901 printf(" Modem hangup-method: %s\n",
5906 printf(" Modem speaker: %s\n", showoff(mdmspk));
5907 printf(" Modem volume: %s\n",
5908 (mdmvol == 2) ? "medium" : ((mdmvol <= 1) ? "low" : "high"));
5909 printf(" Modem kermit-spoof: %s\n", dialksp ? "on" : "off");
5910 c = (char) (x = (dialesc ? dialesc : p->esc_char));
5911 printf(" Modem escape-character: %d", x);
5913 printf(" (= \"%c\")",c);
5915 "\n\nMODEM COMMANDs (* = set automatically by SET MODEM TYPE):\n\n");
5916 debug(F110,"show dialini",dialini,0);
5917 printf(" %c Init-string: ", dialini ? ' ' : '*' );
5918 shods(dialini ? dialini : p->wake_str);
5919 printf(" %c Dial-mode-string: ", dialmstr ? ' ' : '*' );
5920 shods(dialmstr ? dialmstr : p->dmode_str);
5921 n = local ? 19 : 20;
5922 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5923 printf(" %c Dial-mode-prompt: ", dialmprmt ? ' ' : '*' );
5924 shods(dialmprmt ? dialmprmt : p->dmode_prompt);
5925 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5926 printf(" %c Dial-command: ", dialcmd ? ' ' : '*' );
5927 shods(dialcmd ? dialcmd : p->dial_str);
5928 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5929 printf(" %c Compression on: ", dialdcon ? ' ' : '*' );
5931 debug(F110,"dialdcon","(null)",0);
5933 debug(F110,"dialdcon",dialdcon,0);
5934 shods(dialdcon ? dialdcon : p->dc_on_str);
5935 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5936 printf(" %c Compression off: ", dialdcoff ? ' ' : '*' );
5937 shods(dialdcoff ? dialdcoff : p->dc_off_str);
5938 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5939 printf(" %c Error-correction on: ", dialecon ? ' ' : '*' );
5940 shods(dialecon ? dialecon : p->ec_on_str);
5941 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5942 printf(" %c Error-correction off: ", dialecoff ? ' ' : '*' );
5943 shods(dialecoff ? dialecoff : p->ec_off_str);
5944 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5945 printf(" %c Autoanswer on: ", dialaaon ? ' ' : '*' );
5946 shods(dialaaon ? dialaaon : p->aa_on_str);
5947 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5948 printf(" %c Autoanswer off: ", dialaaoff ? ' ' : '*' );
5949 shods(dialaaoff ? dialaaoff : p->aa_off_str);
5950 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5952 printf(" %c Speaker on: ", dialspon ? ' ' : '*' );
5953 shods(dialspon ? dialspon : p->sp_on_str);
5954 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5955 printf(" %c Speaker off: ", dialspoff ? ' ' : '*' );
5956 shods(dialspoff ? dialspoff : p->sp_off_str);
5957 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5958 printf(" %c Volume low: ", dialvol1 ? ' ' : '*' );
5959 shods(dialvol1 ? dialvol1 : p->vol1_str);
5960 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5961 printf(" %c Volume medium: ", dialvol2 ? ' ' : '*' );
5962 shods(dialvol2 ? dialvol2 : p->vol2_str);
5963 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5964 printf(" %c Volume high: ", dialvol3 ? ' ' : '*' );
5965 shods(dialvol3 ? dialvol3 : p->vol3_str);
5966 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5968 printf(" %c Hangup-command: ", dialhcmd ? ' ' : '*' );
5969 shods(dialhcmd ? dialhcmd : p->hup_str);
5970 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5971 printf(" %c Hardware-flow: ", dialhwfc ? ' ' : '*' );
5972 shods(dialhwfc ? dialhwfc : p->hwfc_str);
5973 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5974 printf(" %c Software-flow: ", dialswfc ? ' ' : '*' );
5975 shods(dialswfc ? dialswfc : p->swfc_str);
5976 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5977 printf(" %c No-flow-control: ", dialnofc ? ' ' : '*' );
5978 shods(dialnofc ? dialnofc : p->nofc_str);
5979 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5980 printf(" %c Pulse: ", dialpulse ? ' ' : '*');
5981 shods(dialpulse ? dialpulse : p->pulse);
5982 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5983 printf(" %c Tone: ", dialtone ? ' ' : '*');
5984 shods(dialtone ? dialtone : p->tone);
5986 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5987 printf(" %c Ignore-dialtone: ", dialx3 ? ' ' : '*');
5988 shods(dialx3 ? dialx3 : p->ignoredt);
5990 if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
5991 printf(" %c Predial-init: ", dialini2 ? ' ' : '*');
5992 shods(dialini2 ? dialini2 : p->ini2);
5994 if (++n > cmd_rows - 4) if (!askmore()) return(0); else n = 0;
5995 printf("\n For more info: SHOW DIAL and SHOW COMMUNICATIONS\n");
5997 } else if (mdm > 0) {
5998 printf("Modem info for \"%s\" not filled in yet\n", gmdmtyp());
6000 " No modem selected, so DIAL and most SET MODEM commands have no effect.\n\
6001 Use SET MODEM TYPE to select a modem.\n");
6002 return(success = 1);
6008 int /* TAPI action commands */
6014 printf("\nTAPI is unavailable on this system.\n");
6017 if ((y = cmkey(tapitab,ntapitab,"MS TAPI command","",xxstring)) < 0)
6020 case XYTAPI_CFG: { /* TAPI CONFIGURE-LINE */
6021 extern struct keytab * tapilinetab;
6022 extern struct keytab * _tapilinetab;
6023 extern int ntapiline;
6024 extern int LineDeviceId;
6025 int lineID=LineDeviceId;
6027 cktapiBuildLineTable(&tapilinetab, &_tapilinetab, &ntapiline);
6028 if (tapilinetab && _tapilinetab && ntapiline > 0) {
6029 int i=0, j = 9999, k = -1;
6031 if ( LineDeviceId == -1 ) {
6032 /* Find out what the lowest numbered TAPI device is */
6033 /* and use it as the default. */
6034 for (i = 0; i < ntapiline; i++ ) {
6035 if (tapilinetab[i].kwval < j) {
6040 /* Find the LineDeviceId in the table and use that entry */
6041 for (i = 0; i < ntapiline; i++ ) {
6042 if (tapilinetab[i].kwval == LineDeviceId) {
6049 s = _tapilinetab[k].kwd;
6053 if ((y = cmkey(_tapilinetab,ntapiline,
6054 "TAPI device name",s,xxstring)) < 0)
6058 if ((x = cmcfm()) < 0) return(x);
6061 printf("Sorry, command disabled\r\n");
6062 return(success = 0);
6065 cktapiConfigureLine(lineID);
6068 case XYTAPI_DIAL: /* TAPI DIALING-PROPERTIES */
6069 if ((x = cmcfm()) < 0)
6073 printf("Sorry, command disabled\r\n");
6074 return(success = 0);
6077 cktapiDialingProp();
6080 return(success = 1);
6083 static int /* SET TAPI command options */
6089 printf("\nTAPI is unavailable on this system.\n");
6092 if ((y = cmkey(settapitab,nsettapitab,"MS TAPI option","",xxstring)) < 0)
6096 return (success = seton(&tapiusecfg));
6098 return (success = seton(&tapilights));
6100 return (success = seton(&tapipreterm));
6102 return (success = seton(&tapipostterm));
6104 y = cmnum("seconds of inactivity before auto-disconnect",
6105 "0",10,&x,xxstring);
6106 return(setnum(&tapiinactivity,x,y,65535));
6108 y = cmnum("seconds to wait for credit card tone",
6109 "8",10,&x,xxstring);
6110 return(setnum(&tapibong,x,y,90));
6112 return (success = seton(&tapimanual));
6113 case XYTAPI_CON: /* TAPI CONVERSIONS */
6114 return (success = setonaut(&tapiconv));
6115 case XYTAPI_LIN: /* TAPI LINE */
6116 x = setlin(XYTAPI_LIN,1,0);
6117 if (x > -1) didsetlin++;
6119 case XYTAPI_PASS: { /* TAPI PASSTHROUGH */
6121 printf("\n?Modem-dialing not supported\n");
6124 /* Passthrough became Modem-dialing which is an antonym */
6125 success = seton(&tapipass);
6126 tapipass = !tapipass;
6130 case XYTAPI_LOC: { /* TAPI LOCATION */
6131 extern char tapiloc[];
6132 extern int tapilocid;
6133 int i = 0, j = 9999, k = -1;
6135 cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
6136 if (!tapiloctab || !ntapiloc) {
6137 printf("\nNo TAPI Locations are configured for this system\n");
6140 if (tapilocid == -1)
6141 tapilocid = cktapiGetCurrentLocationID();
6143 /* Find the current tapiloc entry */
6144 /* and use it as the default. */
6145 for (k = 0; k < ntapiloc; k++) {
6146 if (tapiloctab[k].kwval == tapilocid)
6149 if (k >= 0 && k < ntapiloc)
6150 s = tapiloctab[k].kwd;
6154 if ((y = cmkey(tapiloctab,ntapiloc, "TAPI location",s,xxstring)) < 0)
6157 if ((x = cmcfm()) < 0)
6161 printf("Sorry, command disabled\r\n");
6162 return(success = 0);
6165 cktapiFetchLocationInfoByID( y );
6167 CopyTapiLocationInfoToKermitDialCmd();
6174 #endif /* CK_TAPI */
6175 #endif /* NOLOCAL */
6178 #ifdef CK_ANSIC /* SET ALARM */
6183 setalarm(xx) long xx;
6184 #endif /* CK_ANSIC */
6187 int yyyy, mm, dd, x;
6191 #endif /* COMMENT */
6195 debug(F101,"setalarm xx","",xx);
6196 ck_alarm = 0L; /* 0 = no alarm (in case of error) */
6198 printf("%ld - illegal value, must be 0 or positive\n", xx);
6201 if (xx == 0L) { /* CLEAR ALARM */
6207 x = 8; /* Get current date */
6209 if (zzstring("\\v(ndate)",&s,&x) < 0) {
6210 printf("Internal date error, sorry.\n");
6214 x = 5; /* Get current time */
6216 if (zzstring("\\v(ntime)",&s,&x) < 0) {
6217 printf("Internal time error, sorry.\n");
6221 sprintf(buf,"%05ld",atol(alrm_time)); /* SAFE (20) */
6222 ckstrncpy(alrm_time,buf,8);
6223 debug(F110,"SET ALARM date (1)",alrm_date,0);
6224 debug(F110,"SET ALARM time (1)",alrm_time,0);
6226 if ((zz = atol(alrm_time) + xx) < 0L) {
6227 printf("Internal time conversion error, sorry.\n");
6230 if (zz >= 86400L) { /* Alarm crosses midnight */
6231 char d[10]; /* Local date buffer */
6232 int lastday; /* Last day of this month */
6234 ckstrncpy(d,alrm_date,8); /* We'll have to change the date */
6236 x = (zz / 86400L); /* How many days after today */
6238 dd = atoi((char *)(d+6)); /* Parse yyyymmdd */
6239 d[6] = NUL; /* into yyyy, mm, dd ... */
6240 mm = atoi((char *)(d+4));
6242 yyyy = atoi((char *)d);
6244 /* How many days in this month */
6246 lastday = mdays[mm];
6247 if (mm == 2 && yyyy % 4 == 0) /* Works thru 2099 AD... */
6250 if (dd + x > lastday) { /* Dumb loop */
6253 x -= (mdays[mm] - dd); /* Deduct rest of this month's days */
6255 /* There's a more elegant way to do this... */
6258 mm++; /* Next month */
6259 if (mm > 12) { /* Wrap around */
6260 mm = 1; /* Jan, next year */
6263 y = mdays[mm]; /* Days in new month */
6264 if (mm == 2 && yyyy % 4 == 0) /* Feb in leap year */
6265 y++; /* Works until 2100 AD */
6270 dd = x; /* Day of alarm month */
6273 sprintf(alrm_date,"%04d%02d%02d",yyyy,mm,dd); /* SAFE (24) */
6276 sprintf(alrm_time,"%ld",zz); /* SAFE (24) */
6277 debug(F110,"SET ALARM date (2)",alrm_date,0);
6278 debug(F110,"SET ALARM time (2)",alrm_time,0);
6282 ckstrncpy(xbuf,ckcvtdate("",1),20); /* Get current date and time */
6284 ckstrncpy(alrm_date,xbuf,10);
6286 sec = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
6287 debug(F110,"SET ALARM date (1)",alrm_date,0);
6288 debug(F101,"SET ALARM time (1)","",sec);
6289 if ((sec += xx) < 0L) {
6290 printf("Internal time conversion error, sorry.\n");
6293 if (sec >= 86400L) { /* Alarm crosses midnight */
6295 days = sec / 86400L;
6296 jd = mjd(p) + days; /* Get modified Julian date */
6297 ckstrncpy(alrm_date,mjd2date(jd),10);
6300 sprintf(alrm_time,"%05ld",sec); /* SAFE (24) */
6301 debug(F110,"SET ALARM date (2)",alrm_date,0);
6302 debug(F110,"SET ALARM time (2)",alrm_time,0);
6303 ck_alarm = 1; /* Alarm is set */
6305 #endif /* COMMENT */
6306 return(success = 1);
6312 dosetkey() { /* SET KEY */
6315 int kc; /* Key code */
6316 char *s; /* Key binding */
6318 char *p; /* Worker */
6319 #endif /* NOKVERBS */
6327 y = cmnum("numeric key code, or the word CLEAR,","",10,&kc,xxstring);
6330 debug(F111,"SET KEY",atmbuf,y);
6331 if (y == -2) { /* Not a valid number */
6332 if ((y = strlen(atmbuf)) < 0) /* Check for SET KEY CLEAR */
6334 if (ckstrcmp(atmbuf,"clear",y,0))
6336 if ((x = cmcfm()) < 0)
6338 for (y = 0; y < KMSIZE; y++) {
6339 keymap[y] = (KEY) y;
6343 keymapinit(); /* Special OS/2 initializations */
6344 initvik = 1; /* Update the VIK table */
6347 } else if (y == -3) { /* SET KEY <Return> */
6348 printf(" Press key to be defined: "); /* Prompt for a keystroke */
6352 #endif /* NOSETBUF */
6354 conbin((char)escape); /* Put terminal in binary mode */
6356 os2gks = 0; /* Turn off Kverb preprocessing */
6358 kc = congks(0); /* Get character or scan code */
6360 os2gks = 1; /* Turn on Kverb preprocessing */
6362 concb((char)escape); /* Restore terminal to cbreak mode */
6363 if (kc < 0) { /* Check for error */
6364 printf("?Error reading key\n");
6368 shokeycode(kc,-1); /* Show current definition */
6370 shokeycode(kc); /* Show current definition */
6372 flag = 1; /* Remember it's a multiline command */
6377 /* Normal SET KEY <scancode> <value> command... */
6384 if (kc < 0 || kc >= KMSIZE) {
6385 printf("?key code must be between 0 and %d\n", KMSIZE - 1);
6389 printf("Sorry, %d is the CONNECT-mode escape character\n",kc);
6396 cmsavp(psave,PROMPTL);
6397 cmsetp(" Enter new definition: ");
6405 if ((y = cmtxt("key definition,\n\
6406 or Ctrl-C to cancel this command,\n\
6407 or Enter to restore default definition",
6409 if (flag) /* Handle parse errors */
6416 p = s; /* Save this place */
6417 #endif /* NOKVERBS */
6419 If the definition included any \Kverbs, quote the backslash so the \Kverb
6420 will still be in the definition when the key is pressed. We don't do this
6421 in zzstring(), because \Kverbs are valid only in this context and nowhere
6424 We use this code active for all versions that support SET KEY, even if they
6425 don't support \Kverbs, because otherwise \K would behave differently for
6428 for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
6430 (s[x] == 'K' || s[x] == 'k')
6433 if ((x == 1 && s[x-1] == CMDQ) ||
6434 (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
6435 line[y++] = CMDQ; /* Make it \\K */
6437 if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
6438 line[y-1] = CMDQ; /* Have \{K */
6439 line[y++] = '{'; /* Make it \\{K */
6444 line[y++] = NUL; /* Terminate */
6445 s = line + y + 1; /* Point to after it */
6446 x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
6447 if ((x < (LINBUFSIZ / 2)) ||
6448 (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
6449 printf("?Key definition too long\n");
6450 if (flag) cmsetp(psave);
6453 s = line + y + 1; /* Point to result. */
6457 Special case: see if the definition starts with a \Kverb.
6458 If it does, point to it with p, otherwise set p to NULL.
6463 p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
6465 #endif /* NOKVERBS */
6467 if (macrotab[kc]) { /* Possibly free old macro from key. */
6468 free((char *)macrotab[kc]);
6469 macrotab[kc] = NULL;
6471 switch (strlen(s)) { /* Action depends on length */
6472 case 0: /* Reset to default binding */
6473 keymap[kc] = (KEY) kc;
6475 case 1: /* Single character */
6476 keymap[kc] = (CHAR) *s;
6478 default: /* Character string */
6481 y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
6482 debug(F101,"set key kverb lookup",0,y); /* exact match required */
6484 keymap[kc] = F_KVERB | y;
6488 #endif /* NOKVERBS */
6489 keymap[kc] = (KEY) kc;
6490 macrotab[kc] = (MACRO) malloc(strlen(s)+1);
6492 strcpy((char *) macrotab[kc], s); /* safe */
6495 if (flag) cmsetp(psave);
6497 initvik = 1; /* Update VIK table */
6501 #endif /* NOSETKEY */
6504 struct keytab stoptbl[] = {
6508 #endif /* STOPBITS */
6510 static struct keytab sertbl[] = {
6522 #endif /* HWPARITY */
6528 #endif /* HWPARITY */
6531 static int nsertbl = (sizeof(sertbl) / sizeof(struct keytab)) - 1;
6533 static char * sernam[] = { /* Keep this in sync with sertbl[] */
6534 "7E1", "7E2", "7M1", "7M2", "7O1", "7O2", "7S1", "7S2",
6535 "8N1", "8E1", "8E2", "8N2", "8O1", "8O2"
6538 static struct keytab optstab[] = { /* SET OPTIONS table */
6540 { "delete", XXDEL, 0}, /* DELETE */
6541 #endif /* NOFRILLS */
6542 { "directory", XXDIR, 0}, /* DIRECTORY */
6544 { "purge", XXPURGE, 0}, /* PURGE */
6545 #endif /* CKPURGE */
6546 { "type", XXTYP, 0}, /* TYPE */
6549 static int noptstab = (sizeof(optstab) / sizeof(struct keytab)) - 1;
6553 PROTOCOL SELECTION. Kermit is always available. If CK_XYZ is defined at
6554 compile time, then the others become selections also. In OS/2 and
6555 Windows, they are integrated and the various SET commands (e.g. "set file
6556 type") affect them as they would Kermit. In other OS's (UNIX, VMS, etc),
6557 they are external protocols which are run via Kermit's REDIRECT mechanism.
6558 All we do is collect and verify the filenames and pass them along to the
6561 struct keytab protos[] = {
6563 "g", PROTO_G, CM_INV,
6565 "kermit", PROTO_K, 0,
6567 "other", PROTO_O, 0,
6568 "x", PROTO_X, CM_INV|CM_ABR,
6569 "xmodem", PROTO_X, 0,
6570 "xmodem-crc", PROTO_XC, 0,
6571 "y", PROTO_Y, CM_INV|CM_ABR,
6572 "ymodem", PROTO_Y, 0,
6573 "ymodem-g", PROTO_G, 0,
6574 "zmodem", PROTO_Z, 0
6577 int nprotos = (sizeof(protos) / sizeof(struct keytab));
6581 _PROTOTYP(static int protofield, (char *, char *, char *));
6582 _PROTOTYP(static int setproto, (void));
6585 protofield(current, help, px) char * current, * help, * px; {
6587 char *s, tmpbuf[XPCMDLEN+1];
6590 if (current) /* Put braces around default */
6591 ckmakmsg(tmpbuf,TMPBUFSIZ,"{",current,"}",NULL);
6595 if ((x = cmfld(help, (char *)tmpbuf, &s, xxstring)) < 0)
6597 if ((int)strlen(s) > XPCMDLEN) {
6598 printf("?Sorry - maximum length is %d\n", XPCMDLEN);
6601 strcpy(px,s); /* safe */
6609 setproto() { /* Select a file transfer protocol */
6610 /* char * s = NULL; */
6612 char s1[XPCMDLEN+1], s2[XPCMDLEN+1], s3[XPCMDLEN+1];
6613 char s4[XPCMDLEN+1], s5[XPCMDLEN+1], s6[XPCMDLEN+1], s7[XPCMDLEN+1];
6614 char * p1 = s1, * p2 = s2, *p3 = s3;
6615 char * p4 = s4, * p5 = s5, *p6 = s6, *p7 = s7;
6622 #endif /* CK_REDIR */
6623 #endif /* XYZ_INTERNAL */
6631 if ((y = cmkey(protos,nprotos,"","kermit",xxstring)) < 0)
6634 if (x && y != PROTO_K) {
6636 "?Sorry, REDIRECT capability required for external protocols.\n");
6639 if ((x = protofield(ptab[y].h_b_init,
6640 "Optional command to send to host prior to uploading in binary mode",
6643 protocol = y; /* Set protocol but don't change */
6644 return(1); /* anything else */
6648 if ((x = protofield(ptab[y].h_t_init,
6649 "Optional command to send to host prior to uploading in text mode",
6658 if ((x = protofield(ptab[y].h_x_init,
6659 "Optional command to send to host to start Kermit server",
6669 #ifndef XYZ_INTERNAL /* If XYZMODEM are external... */
6672 if ((x = protofield(ptab[y].p_b_scmd,
6673 "External command to SEND in BINARY mode with this protocol",
6680 if ((x = protofield(ptab[y].p_t_scmd,
6681 "External command to SEND in TEXT mode with this protocol",
6688 if ((x = protofield(ptab[y].p_b_rcmd,
6689 "External command to RECEIVE in BINARY mode with this protocol",
6696 if ((x = protofield(ptab[y].p_t_rcmd,
6697 "External command to RECEIVE in TEXT mode with this protocol",
6705 #endif /* XYZ_INTERNAL */
6707 if ((x = cmcfm()) < 0) /* Confirm the command */
6710 protoexit: /* Common exit from this routine */
6715 printf("\n?X,Y, and Zmodem are unavailable\n");
6716 return(success = 0);
6718 #endif /* XYZ_INTERNAL */
6727 initproto(y,p1,p2,p3,p4,p5,p6,p7);
6728 return(success = 1);
6734 if ((y = cmkey(desttab,ndests,"","disk",xxstring)) < 0) return(y);
6735 if ((x = cmcfm()) < 0) return(x);
6742 struct keytab dnettab[] = {
6744 "cterm", NP_CTERM, 0,
6745 #endif /* OS2ONLY */
6748 int ndnet = (sizeof(dnettab) / sizeof(struct keytab));
6751 /* S E T P R I N T E R -- SET PRINTER command */
6754 static struct keytab prntab[] = { /* SET PRINTER switches */
6755 "/bidirectional", PRN_BID, 0,
6757 "/character-set", PRN_CS, CM_ARG,
6759 "/command", PRN_PIP, CM_ARG,
6760 "/dos-device", PRN_DOS, CM_ARG,
6761 "/end-of-job-string",PRN_TRM, CM_ARG,
6762 "/file", PRN_FIL, CM_ARG,
6764 "/flow-control", PRN_FLO, CM_ARG,
6766 "/job-header-file", PRN_SEP, CM_ARG,
6768 "/length", PRN_LEN, CM_ARG,
6770 "/none", PRN_NON, 0,
6772 "/nopostscript", PRN_RAW, 0,
6773 "/nops", PRN_RAW, CM_INV,
6775 "/output-only", PRN_OUT, 0,
6777 "/parity", PRN_PAR, CM_ARG,
6779 "/pipe", PRN_PIP, CM_ARG|CM_INV,
6781 "/postscript", PRN_PS, 0,
6782 "/ps", PRN_PS, CM_INV,
6784 "/separator", PRN_SEP, CM_ARG|CM_INV,
6786 "/speed", PRN_SPD, CM_ARG,
6788 "/timeout", PRN_TMO, CM_ARG,
6789 "/terminator", PRN_TRM, CM_ARG|CM_INV,
6792 "/w", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
6793 "/wi", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
6795 "/width", PRN_WID, CM_ARG,
6798 "/windows-queue", PRN_WIN, CM_ARG,
6802 int nprnswi = (sizeof(prntab) / sizeof(struct keytab)) - 1;
6803 #endif /* PRINTSWI */
6806 setprinter(xx) int xx; {
6809 char * defname = NULL;
6816 long portspeed = 0L;
6822 int c, i, n, wild, confirmed = 0; /* Workers */
6823 int getval = 0; /* Whether to get switch value */
6824 struct stringint { /* Temporary array for switch values */
6828 struct FDB sw, of, cm; /* FDBs for each parse function */
6831 #endif /* PRINTSWI */
6834 struct keytab * printtab = NULL, * _printtab = NULL;
6835 int nprint = 0, printdef=0;
6839 defname = "PRN"; /* default */
6852 haveque = Win32EnumPrt(&printtab,&_printtab,&nprint,&printdef);
6853 haveque = haveque && nprint;
6856 for (i = 0; i <= PRN_MAX; i++) { /* Initialize switch values */
6857 pv[i].sval = NULL; /* to null pointers */
6858 pv[i].ival = -1; /* and -1 int values */
6860 if (xx == XYBDCP) { /* SET BPRINTER == /BIDIRECTIONAL */
6861 pv[PRN_BID].ival = 1;
6862 pv[PRN_OUT].ival = 0;
6865 /* Initialize defaults based upon current printer settings */
6867 defname = printername;
6868 switch (printertype) {
6869 case PRT_WIN: pv[PRN_WIN].ival = 1; break;
6870 case PRT_DOS: pv[PRN_DOS].ival = 1; break;
6871 case PRT_PIP: pv[PRN_PIP].ival = 1; break;
6872 case PRT_FIL: pv[PRN_FIL].ival = 1; break;
6873 case PRT_NON: pv[PRN_NON].ival = 1; break;
6877 /* only set the BIDI flag if we are bidi */
6879 pv[PRN_BID].ival = 1;
6881 /* serial port parameters may be set for non-bidi devices */
6882 pv[PRN_SPD].ival = pportspeed / 10L;
6883 pv[PRN_PAR].ival = pportparity;
6884 pv[PRN_FLO].ival = pportflow;
6887 pv[PRN_TMO].ival = printtimo;
6889 pv[PRN_TRM].ival = 1;
6890 makestr(&pv[PRN_TRM].sval,printterm);
6893 pv[PRN_SEP].ival = 1;
6894 makestr(&pv[PRN_SEP].sval,printsep);
6897 pv[PRN_PS].ival = 1;
6898 pv[PRN_WID].ival = ps_width;
6899 pv[PRN_LEN].ival = ps_length;
6901 pv[PRN_RAW].ival = 1;
6904 /* Set up chained parse functions... */
6906 cmfdbi(&sw, /* First FDB - command switches */
6908 "Switch", /* hlpmsg */
6910 "", /* addtl string data */
6911 nprnswi, /* addtl numeric data 1: tbl size */
6912 4, /* addtl numeric data 2: 4 = cmswi */
6913 xxstring, /* Processing function */
6914 prntab, /* Keyword table */
6915 &cm /* Pointer to next FDB */
6917 cmfdbi(&cm, /* Second fdb for confirmation */
6921 "", /* addtl string data */
6922 0, /* addtl numeric data 1 */
6923 0, /* addtl numeric data 2 */
6928 cmfdbi(&of, /* Third FDB for printer name */
6930 "Printer or file name", /* hlpmsg */
6931 defname, /* default */
6932 "", /* addtl string data */
6933 0, /* addtl numeric data 1: tbl size */
6934 0, /* addtl numeric data 2: 4 = cmswi */
6935 xxstring, /* Processing function */
6940 while (1) { /* Parse 0 or more switches */
6941 x = cmfdb(&sw); /* Parse switch or other thing */
6942 debug(F101,"setprinter cmfdb","",x);
6943 if (x < 0) /* Error */
6944 goto xsetprn; /* or reparse needed */
6945 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
6947 if (cmresult.fdbaddr != &sw) /* Advanced usage :-) */
6949 c = cmgbrk(); /* Get break character */
6950 getval = (c == ':' || c == '='); /* to see how they ended the switch */
6951 n = cmresult.nresult; /* Numeric result = switch value */
6952 debug(F101,"setprinter switch","",n);
6954 switch (n) { /* Process the switch */
6955 case PRN_PS: /* Text to Postscript */
6956 pv[PRN_PS].ival = 1;
6957 pv[PRN_BID].ival = 0;
6958 pv[PRN_OUT].ival = 1;
6959 pv[PRN_RAW].ival = 0;
6962 case PRN_RAW: /* Non-Postscript */
6963 pv[PRN_PS].ival = 0;
6964 pv[PRN_RAW].ival = 1;
6967 case PRN_BID: /* Bidirectional */
6968 pv[PRN_BID].ival = 1;
6969 pv[PRN_OUT].ival = 0;
6970 pv[PRN_PS].ival = 0;
6971 pv[PRN_RAW].ival = 1;
6974 case PRN_OUT: /* Output-only */
6975 pv[PRN_OUT].ival = 1;
6976 pv[PRN_BID].ival = 0;
6977 pv[PRN_PS].ival = 0;
6978 pv[PRN_RAW].ival = 1;
6981 case PRN_NON: /* NONE */
6984 pv[PRN_SPD].ival = 0;
6985 pv[PRN_PAR].ival = 0;
6986 pv[PRN_FLO].ival = FLO_KEEP;
6992 case PRN_DOS: /* DOS printer name */
6993 case PRN_FIL: /* Or filename */
6996 if (pv[n].sval) free(pv[n].sval);
6998 pv[PRN_NON].ival = 0; /* Zero any previous selections */
6999 pv[PRN_WIN].ival = 0;
7000 pv[PRN_DOS].ival = 0;
7001 pv[PRN_FIL].ival = 0;
7002 pv[PRN_PIP].ival = 0;
7003 pv[n].ival = 1; /* Flag this one */
7004 if (!getval) break; /* No value wanted */
7006 if (n == PRN_FIL) { /* File, check accessibility */
7008 if ((x = cmiofi("Filename","kermit.prn",&s,&wild,xxstring))< 0)
7011 printf("Can't create \"%s\"\n",s);
7014 } else goto xsetprn;
7016 printf("?A single file please\n");
7019 pv[PRN_SPD].ival = 0;
7020 pv[PRN_PAR].ival = 0;
7021 pv[PRN_FLO].ival = FLO_KEEP;
7022 } else if ((x = cmfld(n == PRN_DOS ? /* Value wanted - parse it */
7023 "DOS printer device name" : /* Help message */
7028 "PRN" : /* Default */
7034 s = brstrip(s); /* Strip enclosing braces */
7035 while (*s == SP) /* Strip leading blanks */
7037 if (n == PRN_PIP) { /* If /PIPE: */
7038 if (*s == '|') { /* strip any extraneous pipe sign */
7043 pv[PRN_SPD].ival = 0;
7044 pv[PRN_PAR].ival = 0;
7045 pv[PRN_FLO].ival = FLO_KEEP;
7047 if ((y = strlen(s)) > 0) /* Anything left? */
7048 if (pv[n].sval = (char *) malloc(y+1)) /* Yes, keep it */
7049 strcpy(pv[n].sval,s); /* safe */
7052 case PRN_WIN: /* Windows queue name */
7054 if (pv[n].sval) free(pv[n].sval);
7056 pv[PRN_NON].ival = 0;
7057 pv[PRN_DOS].ival = 0;
7058 pv[PRN_FIL].ival = 0;
7060 pv[PRN_SPD].ival = 0;
7061 pv[PRN_PAR].ival = 0;
7062 pv[PRN_FLO].ival = FLO_KEEP;
7064 if (!getval || !haveque)
7066 if ((x = cmkey(_printtab,nprint,"Print queue name",
7067 _printtab[printdef].kwd,xxstring)) < 0) {
7071 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7073 if ((y = strlen(s)) > 0)
7074 if (pv[n].sval = (char *)malloc(y+1))
7075 strcpy(pv[n].sval,s); /* safe */
7077 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7078 for (i = 0; i < nprint; i++) {
7079 if (x == printtab[i].kwval) {
7080 s = printtab[i].kwd;
7084 if ((y = strlen(s)) > 0)
7085 if (pv[n].sval = (char *)malloc(y+1))
7086 strcpy(pv[n].sval,s); /* safe */
7091 case PRN_SEP: /* /JOB-HEADER (separator) */
7092 if (pv[n].sval) free(pv[n].sval);
7096 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0)
7099 printf("?Wildcards not allowed\n");
7103 if ((y = strlen(s)) > 0)
7104 if (pv[n].sval = (char *) malloc(y+1))
7105 strcpy(pv[n].sval,s); /* safe */
7108 case PRN_TMO: /* /TIMEOUT:number */
7111 if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
7114 printf("?Sorry - 999 is the maximum\n");
7121 case PRN_TRM: /* /END-OF-JOB:string */
7122 if (pv[n].sval) free(pv[n].sval);
7126 if ((x = cmfld("String (enclose in braces if it contains spaces)",
7127 "",&s,xxstring)) < 0)
7130 if ((y = strlen(s)) > 0)
7131 if (pv[n].sval = (char *) malloc(y+1))
7132 strcpy(pv[n].sval,s); /* safe */
7138 if ((x = cmkey(flotab,nflo,
7139 "Serial printer-port flow control",
7140 "rts/cts",xxstring)) < 0)
7149 /* TN_COMPORT here too? */
7151 if ((x = cmkey(spdtab, /* Speed (no default) */
7153 "Serial printer-port interface speed",
7160 #endif /* NOLOCAL */
7165 if ((x = cmkey(partbl,npar,"Serial printer-port parity",
7166 "none",xxstring)) < 0)
7175 if ((x = cmnum("PS page length", "66",10,&y,xxstring)) < 0)
7182 if ((x = cmnum("PS page width", "80",10,&y,xxstring)) < 0)
7196 "auto-print/printscreen character-set",
7197 "cp437",xxstring)) < 0)
7204 printf("?Unexpected switch value - %d\n",cmresult.nresult);
7209 line[0] = NUL; /* Initialize printer name value */
7210 switch (cmresult.fcode) { /* How did we get here? */
7211 case _CMOFI: /* They typed a filename */
7212 ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
7213 wild = cmresult.nresult; /* Wild flag */
7214 if (!typeset) { /* A printer name without a type */
7215 pv[PRN_NON].ival = 0; /* is supposed to be treated as */
7216 pv[PRN_WIN].ival = 0; /* a DOS or Pipe printer. We */
7217 pv[PRN_FIL].ival = 0; /* clear all the flags and let */
7218 pv[PRN_PIP].ival = 0; /* the code below dope out the */
7219 pv[PRN_DOS].ival = 0; /* type. */
7222 else if (pv[PRN_WIN].ival && lookup(_printtab,line,nprint,&y)) {
7223 /* invalid Window Queue name */
7224 printf("?invalid Windows Printer Queue name: \"%s\"\r\n",line);
7229 if ((x = cmcfm()) < 0) /* Confirm the command */
7232 case _CMCFM: /* They entered the command */
7233 if (pv[PRN_DOS].ival > 0)
7234 ckstrncpy(line,pv[PRN_DOS].sval ? pv[PRN_DOS].sval : "",LINBUFSIZ);
7235 else if (pv[PRN_WIN].ival > 0)
7236 ckstrncpy(line,pv[PRN_WIN].sval ? pv[PRN_WIN].sval : "",LINBUFSIZ);
7237 else if (pv[PRN_FIL].ival > 0)
7238 ckstrncpy(line,pv[PRN_FIL].sval ? pv[PRN_FIL].sval : "",LINBUFSIZ);
7239 else if (pv[PRN_PIP].ival > 0)
7240 ckstrncpy(line,pv[PRN_PIP].sval ? pv[PRN_PIP].sval : "",LINBUFSIZ);
7242 default: /* By mistake */
7243 printf("?Unexpected function code: %d\n",cmresult.fcode);
7248 #else /* No PRINTSWI */
7250 if ((x = cmofi("Printer or file name",defname,&s,xxstring)) < 0)
7253 printf("?Directory names not allowed\n");
7256 while (*s == SP || *s == HT) s++; /* Trim leading whitespace */
7257 ckstrncpy(line,s,LINBUFSIZ); /* Make a temporary safe copy */
7258 if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
7259 #endif /* PRINTSWI */
7262 if (inserver && (isguest
7265 #endif /* NOSERVER */
7267 printf("Sorry, printing disabled\r\n");
7268 return(success = 0);
7274 if (printbidi) { /* If bidi printing active */
7276 bprtstop(); /* Stop it before proceeding */
7280 if (pv[PRN_SPD].ival > 0) {
7281 portspeed = (long) pv[PRN_SPD].ival * 10L;
7282 if (portspeed == 70L) portspeed = 75L;
7284 if (pv[PRN_PAR].ival > 0)
7285 portparity = pv[PRN_PAR].ival;
7286 if (pv[PRN_FLO].ival > 0)
7287 portflow = pv[PRN_FLO].ival;
7289 #endif /* PRINTSWI */
7291 s = line; /* Printer name, if given */
7295 if (pv[PRN_PIP].ival > 0) { /* /PIPE was given? */
7298 if (*s == '|') { /* It might still have a pipe sign */
7299 s++; /* if name give later */
7300 while (*s == SP) /* so remove it and spaces */
7304 #endif /* PRINTSWI */
7305 if (*s == '|') { /* Or pipe implied by name? */
7306 s++; /* Point past pipe sign */
7307 while (*s == SP) /* Gobble whitespace */
7319 if (printpipe && pv[PRN_BID].ival > 0) {
7320 printf("?Sorry, pipes not allowed for bidirectional printer\n");
7324 #endif /* PRINTSWI */
7325 #endif /* OS2ORUNIX */
7328 if ( pv[PRN_CS].ival > 0 )
7329 prncs = pv[PRN_CS].ival;
7331 if ( pv[PRN_PS].ival > 0 ) {
7333 ps_width = pv[PRN_WID].ival <= 0 ? 80 : pv[PRN_WID].ival;
7334 ps_length = pv[PRN_LEN].ival <= 0 ? 66 : pv[PRN_LEN].ival;
7338 y = strlen(s); /* Length of name of new print file */
7341 && ((y != 3) || (ckstrcmp(s,"PRN",3,0) != 0))
7344 if (printername) { /* Had a print file before? */
7345 free(printername); /* Remove its name */
7348 printername = (char *) malloc(y + 1); /* Allocate space for it */
7350 printf("?Memory allocation failure\n");
7353 strcpy(printername,s); /* (safe) Copy new name to new space */
7354 debug(F110,"printername",printername,0);
7358 /* Set printer type from switches that were given explicitly */
7360 if (pv[PRN_NON].ival > 0) { /* No printer */
7361 printertype = PRT_NON;
7364 } else if (pv[PRN_FIL].ival > 0) { /* File */
7365 printertype = PRT_FIL;
7368 } else if (pv[PRN_PIP].ival > 0) { /* Pipe */
7369 printertype = PRT_PIP;
7372 } else if (pv[PRN_WIN].ival > 0) { /* Windows print queue */
7373 printertype = PRT_WIN;
7376 } else if (pv[PRN_DOS].ival > 0) { /* DOS device */
7377 printertype = PRT_DOS;
7380 } else if (line[0]) { /* Name given without switches */
7382 printertype = printpipe ? PRT_PIP : PRT_DOS;
7384 /* was the command SET PRINTER windows-queue ? */
7385 y = lookup(_printtab,line,nprint,&x);
7387 printertype = PRT_WIN;
7388 if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
7389 if (printername) { /* Had a print file before? */
7390 free(printername); /* Remove its name */
7393 pv[PRN_WIN].sval = NULL;
7394 pv[PRN_WIN].ival = 1;
7395 s = printtab[x].kwd; /* Get full new name */
7396 if ((y = strlen(s)) > 0) {
7397 makestr(&pv[PRN_WIN].sval,s);
7398 makestr(&printername,s);
7400 printf("?Memory allocation failure\n");
7403 debug(F110,"printername",printername,0);
7405 } else if ( y == -2 ) {
7406 /* Ambiguous Print Queue Name */
7407 printf("?Ambiguous printer name provided.\n");
7414 /* Port parameters may be set for non-bidi mode */
7416 pportspeed = portspeed; /* Set parameters */
7417 pportparity = portparity;
7418 pportflow = portflow;
7420 if (pv[PRN_BID].ival > 0) { /* Bidirectional */
7422 printbidi = 1; /* (just to test parsing...) */
7424 printbidi = bprtstart(); /* Start bidirectional printer */
7426 return(success = printbidi);
7428 printbidi = 0; /* Not BPRINTER, unset flag */
7431 if (pv[PRN_TMO].ival > -1) { /* Take care of timeout */
7432 printtimo = pv[PRN_TMO].ival;
7434 if (pv[PRN_TRM].ival > 0) { /* Termination string */
7439 if (pv[PRN_TRM].sval)
7440 makestr(&printterm,pv[PRN_TRM].sval);
7442 if (pv[PRN_SEP].ival > 0) { /* and separator file */
7447 if (pv[PRN_SEP].sval)
7448 makestr(&printsep,pv[PRN_SEP].sval);
7450 #endif /* PRINTSWI */
7456 #endif /* PRINTSWI */
7457 ) { /* File - check access */
7459 printf("?Access denied - %s\n",s);
7464 #endif /* UNIXOROSK */
7466 x = 1; /* Return code */
7468 xsetprn: /* Common exit */
7470 for (i = 0; i <= PRN_MAX; i++) { /* Free malloc'd memory */
7474 #endif /* PRINTSWI */
7475 success = (x > 0) ? 1 : 0;
7480 /* The SET SSH command */
7482 #define SSH_CMD 1 /* SET SSH COMMAND */
7484 #ifdef SSHBUILTIN /* Built-in SET SSH options */
7485 #define SSH_ADD 2 /* Add */
7486 #define SSH_AFW 3 /* Agent-forwarding */
7487 #define SSH_CHI 4 /* Check Host IP */
7488 #define SSH_XFW 5 /* X11-forwarding */
7489 #define SSH_DYF 6 /* Dynamic forwarding */
7490 #define SSH_GWP 7 /* Gatewa portgs */
7491 #define SSH_GSS 8 /* GSSAPI */
7492 #define SSH_KBD 9 /* KBD Interactive Devices */
7493 #define SSH_K4 10 /* Kerberos 4 */
7494 #define SSH_K5 11 /* Kerberos 5 */
7495 #define SSH_SHK 12 /* Strict Host Key Check */
7496 #define SSH_V1 13 /* SSH V1 */
7497 #define SSH_V2 14 /* SSH V2 */
7498 #define SSH_PRP 15 /* Privd port */
7499 #define SSH_CMP 16 /* Compression */
7500 #define SSH_XAL 17 /* X Auth Location */
7501 #define SSH_SHH 18 /* Quiet */
7502 #define SSH_VER 19 /* Version */
7503 #define SSH_VRB 20 /* Verbosity level */
7504 #define SSH_IDF 21 /* Identity File */
7505 #define SSH_CFG 22 /* Use OpenSSH Config */
7506 #define SSH_HBT 23 /* Heartbeat Interval */
7507 #endif /* SSHBUILTIN */
7509 static struct keytab sshtab[] = { /* SET SSH command table */
7511 { "agent-forwarding", SSH_AFW, 0 },
7512 { "check-host-ip", SSH_CHI, 0 },
7513 { "compression", SSH_CMP, 0 },
7514 { "dynamic-forwarding", SSH_DYF, 0 },
7515 { "gateway-ports", SSH_GWP, 0 },
7516 { "gssapi", SSH_GSS, 0 },
7517 { "heartbeat-interval", SSH_HBT, 0 },
7518 { "identity-file", SSH_IDF, 0 },
7520 { "kbd-interactive-devices", SSH_KBD, 0 },
7521 #endif /* COMMENT */
7522 { "k4", SSH_K4, CM_INV },
7523 { "k5", SSH_K5, CM_INV },
7524 { "kerberos4", SSH_K4, 0 },
7525 { "kerberos5", SSH_K5, 0 },
7526 { "krb4", SSH_K4, CM_INV },
7527 { "krb5", SSH_K5, CM_INV },
7528 { "privileged-port", SSH_PRP, 0 },
7529 { "quiet", SSH_SHH, 0 },
7530 { "strict-host-key-check", SSH_SHK, 0 },
7531 { "use-openssh-config", SSH_CFG, 0 },
7532 { "v1", SSH_V1, 0 },
7533 { "v2", SSH_V2, 0 },
7534 { "verbose", SSH_VRB, 0 },
7535 { "version", SSH_VER, 0 },
7536 { "x11-forwarding", SSH_XFW, 0 },
7537 { "xauth-location", SSH_XAL, 0 },
7540 { "command", SSH_CMD, 0 },
7542 #endif /* SSHBUILTIN */
7545 static int nsshtab = (sizeof(sshtab) / sizeof(struct keytab)) - 1;
7548 static struct keytab sshver[] = { /* SET SSH VERSION command table */
7551 { "automatic", 0, 0 }
7568 static struct keytab ssh2aut[] = { /* SET SSH V2 AUTH command table */
7569 { "external-keyx", SSHA_EXT, 0 },
7570 { "gssapi", SSHA_GSS, 0 },
7571 { "hostbased", SSHA_HOS, 0 },
7572 { "keyboard-interactive", SSHA_KBD, 0 },
7573 { "password", SSHA_PSW, 0 },
7574 { "publickey", SSHA_PK, 0 },
7575 { "srp-gex-sha1", SSHA_SRP, 0 },
7578 static int nssh2aut = (sizeof(ssh2aut) / sizeof(struct keytab)) - 1;
7583 static struct keytab addfwd[] = { /* SET SSH ADD command table */
7584 { "local-port-forward", SSHF_LCL, 0 },
7585 { "remote-port-forward", SSHF_RMT, 0 },
7588 static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
7603 static struct keytab sshv1tab[] = { /* SET SSH V1 command table */
7604 { "cipher", SSH1_CIF, 0 },
7605 { "global-known-hosts-file", SSH1_GNH, 0 },
7606 { "k5-reuse-k4-messages", SSH1_K54, CM_INV },
7607 { "user-known-hosts-file", SSH1_UNH, 0 },
7610 static int nsshv1tab = (sizeof(sshv1tab) / sizeof(struct keytab)) - 1;
7612 static struct keytab sshv2tab[] = { /* SET SSH V2 command table */
7613 { "authentication", SSH2_AUT, 0 },
7614 { "auto-rekey", SSH2_ARK, 0 },
7615 { "ciphers", SSH2_CIF, 0 },
7616 { "global-known-hosts-file", SSH2_GNH, 0 },
7617 { "hostkey-algorithms", SSH2_HKA, 0 },
7618 { "macs", SSH2_MAC, 0 },
7619 { "user-known-hosts-file", SSH2_UNH, 0 },
7622 static int nsshv2tab = (sizeof(sshv2tab) / sizeof(struct keytab)) - 1;
7624 #define SSHC_3DES 1 /* 3DES */
7625 #define SSHC_3CBC 2 /* 3DES-CBC */
7626 #define SSHC_A128 3 /* AES128-CBC */
7627 #define SSHC_A192 4 /* AES192-CBC */
7628 #define SSHC_A256 5 /* AES256-CBC */
7629 #define SSHC_ARC4 6 /* ARCFOUR */
7630 #define SSHC_FISH 7 /* BLOWFISH */
7631 #define SSHC_BCBC 9 /* BLOWFISH-CBC */
7632 #define SSHC_C128 8 /* CAST128-CBC */
7633 #define SSHC_1DES 10 /* DES */
7635 static struct keytab ssh1ciphers[] = {
7636 { "3des", SSHC_3DES, 0 },
7637 { "blowfish", SSHC_FISH, 0 },
7638 { "des", SSHC_1DES, 0 },
7641 static int nssh1ciphers = (sizeof(ssh1ciphers) / sizeof(struct keytab)) - 1;
7643 static struct keytab ssh2ciphers[] = { /* SET SSH V2 CIPHERS command table */
7644 { "3des-cbc", SSHC_3DES, 0 },
7645 { "aes128-cbc", SSHC_A128, 0 },
7646 { "aes192-cbc", SSHC_A192, 0 },
7647 { "aes256-cbc", SSHC_A256, 0 },
7648 { "arcfour", SSHC_ARC4, 0 },
7649 { "blowfish-cbc", SSHC_FISH, 0 },
7650 { "cast128-cbc", SSHC_C128, 0 },
7651 { "rijndael128-cbc", SSHC_A128, 0 },
7652 { "rijndael192-cbc", SSHC_A192, 0 },
7653 { "rijndael256-cbc", SSHC_A256, 0 },
7656 static int nssh2ciphers = (sizeof(ssh2ciphers) / sizeof(struct keytab)) - 1;
7658 #define SSHM_SHA 1 /* HMAC-SHA1 */
7659 #define SSHM_SHA_96 2 /* HMAC-SHA1-96 */
7660 #define SSHM_MD5 3 /* HMAC-MD5 */
7661 #define SSHM_MD5_96 4 /* HMAC-MD5-96 */
7662 #define SSHM_RIPE 5 /* HMAC-RIPEMD160 */
7664 static struct keytab ssh2macs[] = { /* SET SSH V2 MACS command table */
7665 { "hmac-md5", SSHM_MD5, 0 },
7666 { "hmac-md5-96", SSHM_MD5_96, 0 },
7667 { "hmac-ripemd160", SSHM_RIPE, 0 },
7668 { "hmac-sha1", SSHM_SHA, 0 },
7669 { "hmac-sha1-96", SSHM_SHA_96, 0 },
7672 static int nssh2macs = (sizeof(ssh2macs) / sizeof(struct keytab)) - 1;
7674 static struct keytab tgtpass[] = {
7675 { "tgt-passing", 1, 0, },
7678 static int ntgtpass = (sizeof(tgtpass) / sizeof(struct keytab)) - 1;
7680 static struct keytab gssapitab[] = {
7681 { "delegate-credentials", 1, 0, },
7682 { "key-exchange", 2, CM_INV, },
7685 static int ngssapitab = (sizeof(gssapitab) / sizeof(struct keytab)) - 1;
7690 static struct keytab hkatab[] = {
7691 { "ssh-dss", HKA_DSS, 0, },
7692 { "ssh-rsa", HKA_RSA, 0, },
7695 static int nhkatab = (sizeof(hkatab) / sizeof(struct keytab)) - 1;
7697 int /* SET SSH variables */
7698 ssh_afw = 0, /* agent forwarding */
7699 ssh_xfw = 0, /* x11 forwarding */
7700 ssh_prp = SET_OFF, /* privileged ports */
7701 ssh_cmp = 1, /* compression */
7702 ssh_shh = 0, /* quiet */
7703 ssh_ver = 0, /* protocol version (auto,1,2) */
7704 ssh_vrb = 2, /* Report errors */
7705 ssh_chkip = 0, /* SSH Check Host IP flag */
7706 ssh_gwp = 0, /* gateway ports */
7707 ssh_dyf = 0, /* dynamic forwarding */
7708 ssh_gsd = 0, /* gssapi delegate credentials */
7709 ssh_k4tgt = 0, /* k4 tgt passing */
7710 ssh_k5tgt = 0, /* k5 tgt passing */
7711 ssh_shk = 2, /* Strict host key (no, yes, ask) */
7712 ssh2_ark = 1, /* Auto re-key */
7713 ssh_cas = 0, /* command as subsys */
7714 ssh_cfg = 0, /* use OpenSSH config? */
7715 ssh_gkx = 1, /* gssapi key exchange */
7716 ssh_k5_is_k4 = 1, /* some SSH v1 use same codes */
7717 ssh_hbt = 0, /* heartbeat (seconds) */
7718 ssh_dummy = 0; /* bottom of list */
7720 char /* The following are to be malloc'd */
7721 * ssh1_cif = NULL, /* v1 cipher */
7722 * ssh2_cif = NULL, /* v2 cipher list */
7723 * ssh2_mac = NULL, /* v2 mac list */
7724 * ssh2_auth = NULL, /* v2 authentication list */
7725 * ssh_hst = NULL, /* hostname */
7726 * ssh_prt = NULL, /* port/service */
7727 * ssh_cmd = NULL, /* command to execute */
7728 * ssh_xal = NULL, /* xauth-location */
7729 * ssh1_gnh = NULL, /* v1 global known hosts file */
7730 * ssh1_unh = NULL, /* v1 user known hosts file */
7731 * ssh2_gnh = NULL, /* v2 global known hosts file */
7732 * ssh2_unh = NULL, /* v2 user known hosts file */
7733 * ssh2_hka = NULL, /* Host Key Algorithms */
7736 char * ssh_idf[32] = { /* Identity file list */
7737 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7738 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7739 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7740 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7742 char * ssh_tmp[32] = { /* Temp identity file list */
7743 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7744 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7745 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
7746 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
7750 extern int ssh_pf_lcl_n,
7752 extern struct ssh_pf ssh_pf_lcl[32]; /* Port forwarding structs */
7753 extern struct ssh_pf ssh_pf_rmt[32]; /* (declared in ckuusr.c) */
7754 #endif /* SSHBUILTIN */
7757 static struct keytab sftptab[] = {
7758 { "end-of-line", XY_SFTP_EOL, 0, },
7759 { "remote-character-set", XY_SFTP_RCS, 0, },
7762 static int nsftptab = (sizeof(sftptab) / sizeof(struct keytab)) - 1;
7763 #endif /* SFTP_BUILTIN */
7768 int i, n = 0; /* ADD askmore()! */
7770 printf("\nSSH is built in:\n\n");
7772 printf(" ssh host: %s\n",showstring(ssh_hst));
7773 printf(" ssh port: %s\n",showstring(ssh_prt));
7774 printf(" ssh command: %s\n",showstring(ssh_cmd));
7775 printf(" ssh agent-forwarding: %s\n",showoff(ssh_afw));
7776 printf(" ssh check-host-ip: %s\n",showoff(ssh_chkip));
7777 printf(" ssh compression: %s\n",showoff(ssh_cmp));
7778 printf(" ssh dynamic-forwarding: %s\n",showoff(ssh_dyf));
7779 if (ssh_pf_lcl[0].p1 && ssh_pf_lcl[0].host && ssh_pf_lcl[0].p2) {
7780 printf(" ssh forward-local-port: %d %s %d\n",
7781 ssh_pf_lcl[0].p1, ssh_pf_lcl[0].host, ssh_pf_lcl[0].p2);
7782 for ( n=1;n<ssh_pf_lcl_n;n++ )
7783 printf(" : %d %s %d\n",
7784 ssh_pf_lcl[n].p1, ssh_pf_lcl[n].host, ssh_pf_lcl[n].p2);
7786 printf(" ssh forward-local-port: (none)\n");
7787 if (ssh_pf_rmt[0].p1 && ssh_pf_rmt[0].host && ssh_pf_rmt[0].p2) {
7788 printf(" ssh forward-remote-port: %d %s %d\n",
7789 ssh_pf_rmt[0].p1, ssh_pf_rmt[0].host, ssh_pf_rmt[0].p2);
7790 for ( n=1;n<ssh_pf_rmt_n;n++ )
7791 printf(" : %d %s %d\n",
7792 ssh_pf_rmt[n].p1, ssh_pf_rmt[n].host, ssh_pf_rmt[n].p2);
7794 printf(" ssh forward-remote-port: (none)\n");
7795 printf(" ssh gateway-ports: %s\n",showoff(ssh_gwp));
7796 printf(" ssh gssapi delegate-credentials: %s\n",showoff(ssh_gsd));
7797 printf(" ssh gssapi key-exchange : %s\n",showoff(ssh_gkx));
7798 printf(" ssh identity-file: %d\n",ssh_idf_n);
7799 for (i = 0; i < ssh_idf_n; i++)
7800 printf(" %2d. %s\n",i+1,showstring(ssh_idf[i]));
7801 printf(" ssh heartbeat interval: %d\n", ssh_hbt);
7802 printf(" ssh k4 tgt-passing: %s\n",showoff(ssh_k4tgt));
7803 printf(" ssh k5 tgt-passing: %s\n",showoff(ssh_k5tgt));
7805 printf(" ssh privileged-port: %s\n",showooa(ssh_prp));
7806 printf(" ssh quiet: %s\n",showoff(ssh_shh));
7807 printf(" ssh strict-host-key-check: %d\n",ssh_shk);
7808 printf(" ssh use-openssh-config: %s\n",showoff(ssh_cfg));
7809 printf(" ssh verbose: %d\n",ssh_vrb);
7810 printf(" ssh version: %s\n",
7811 ssh_ver ? ckitoa(ssh_ver) : "automatic"
7813 printf(" ssh x11-forwarding: %s\n",showooa(ssh_xfw));
7814 printf(" ssh xauth-location: %s\n",showstring(ssh_xal));
7816 printf(" ssh v1 cipher: %s\n",showstring(ssh1_cif));
7817 printf(" ssh v1 global-known-hosts-file: %s\n",showstring(ssh1_gnh));
7818 printf(" ssh v1 user-known-hosts-file: %s\n",showstring(ssh1_unh));
7820 printf(" ssh v2 authentication: %s\n",showstring(ssh2_auth));
7821 printf(" ssh v2 auto-rekey: %s\n",showoff(ssh2_ark));
7822 printf(" ssh v2 ciphers: %s\n",showstring(ssh2_cif));
7823 printf(" ssh v2 command-as-subsystem: %s\n",showoff(ssh_cas));
7824 printf(" ssh v2 global-known-hosts-file: %s\n",showstring(ssh2_gnh));
7825 printf(" ssh v2 hostkey-algorithms: %s\n",showstring(ssh2_hka));
7826 printf(" ssh v2 mac: %s\n",showstring(ssh2_mac));
7827 printf(" ssh v2 user-known-hosts-file: %s\n",showstring(ssh2_unh));
7830 extern char * sshcmd, * defsshcmd;
7832 s = sshcmd ? sshcmd : defsshcmd;
7833 printf("\n SSH is external.\n\n");
7834 printf(" ssh command: %s\n",showstring(s));
7836 #endif /* SSHBUILTIN */
7843 extern char * sshcmd;
7847 extern int sl_ssh_xfw_saved, sl_ssh_ver_saved;
7848 #endif /* SSHTEST */
7849 #endif /* SSHBUILTIN */
7853 if ((cx = cmkey(sshtab,nsshtab,"","command", xxstring)) < 0)
7857 case SSH_CMD: /* Command */
7858 if ((x = cmtxt("Command to start ssh","ssh -e none",
7862 return(success = 1);
7866 case SSH_AFW: /* Agent-forwarding */
7867 return(success = seton(&ssh_afw));
7869 case SSH_CHI: /* Check Host IP */
7870 return(success = seton(&ssh_chkip));
7873 case SSH_CMP: /* Compression */
7874 return(success = seton(&ssh_cmp));
7876 case SSH_DYF: /* Dynamic Forwarding */
7877 return(success = seton(&ssh_dyf));
7879 case SSH_GWP: /* Gateway ports */
7880 return(success = seton(&ssh_gwp));
7882 case SSH_GSS: /* GSSAPI */
7883 if ((y = cmkey(gssapitab,ngssapitab,"","", xxstring)) < 0)
7886 case 1: /* Delegate credentials */
7887 return(success = seton(&ssh_gsd));
7888 case 2: /* key-exchange */
7889 return(success = seton(&ssh_gkx));
7891 if ((x = cmcfm()) < 0)
7893 return(success = 0);
7896 case SSH_KBD: /* Kbd Interactive Devices */
7897 if ((x = cmcfm()) < 0)
7899 /* TO BE FILLED IN */
7901 #endif /* COMMENT */
7903 case SSH_K4: /* Kerberos IV */
7904 case SSH_K5: /* Kerberos V */
7905 if ((y = cmkey(tgtpass,1,"","tgt-passing", xxstring)) < 0)
7909 return(success = (cx == SSH_K4) ?
7910 seton(&ssh_k4tgt) : seton(&ssh_k5tgt));
7912 if ((x = cmcfm()) < 0)
7914 return(success = 0);
7916 case SSH_PRP: /* Privd port */
7917 return(success = seton(&ssh_prp));
7919 case SSH_SHH: /* Quiet */
7920 return(success = seton(&ssh_shh));
7922 case SSH_SHK: /* Strict Host Key Check */
7923 if ((y = cmkey(ooktab,3,"","", xxstring)) < 0)
7925 if ((x = cmcfm()) < 0)
7928 return(success = 1);
7931 x = cmnum("Heartbeat interval, seconds","0",10,&z,xxstring);
7932 if (x < 0) return(x);
7933 if ((x = cmcfm()) < 0) return(x);
7935 return(success = 1);
7937 case SSH_V1: /* SSH V1 */
7938 if ((y = cmkey(sshv1tab,nsshv1tab,"","", xxstring)) < 0)
7942 return(success = seton(&ssh_k5_is_k4));
7943 case SSH1_CIF: /* Not a list */
7944 if ((y = cmkey(ssh1ciphers,nssh1ciphers,"","", xxstring)) < 0)
7947 if ((x = cmcfm()) < 0) return(x);
7949 makestr(&ssh1_cif,NULL);
7951 for (x = 0; x < nssh1ciphers; x++)
7952 if (ssh1ciphers[x].kwval == y)
7954 makestr(&ssh1_cif,ssh1ciphers[x].kwd);
7959 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
7963 ckstrncpy(line,s,LINBUFSIZ);
7964 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
7965 ckstrncpy(line,tmpbuf,LINBUFSIZ);
7967 s = (x == -3) ? NULL : line;
7968 if ((x = cmcfm()) < 0)
7971 case SSH1_GNH: makestr(&ssh1_gnh,s); break;
7972 case SSH1_UNH: makestr(&ssh1_unh,s); break;
7977 case SSH_V2: /* SSH V2 */
7978 if ((y = cmkey(sshv2tab,nsshv2tab,"","", xxstring)) < 0)
7982 return(success = seton(&ssh2_ark));
7983 case SSH2_AUT: { /* Authentication */
7985 int i, j, tmp[TMPCNT];
7986 for (i = 0; i < TMPCNT; i++)
7988 for (i = 0; i < TMPCNT; i++) {
7989 if ((y = cmkey(ssh2aut,nssh2aut,
7990 "Authentication method","",xxstring)) < 0) {
7995 for (j = 0; j < i; j++) {
7997 printf("\r\n?Choice has already been used.\r\n");
8003 if ((z = cmcfm()) < 0)
8012 for (j = 0; j < i; j++) {
8013 for (x = 0; x < nssh2aut; x++)
8014 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8016 len += strlen(ssh2aut[x].kwd) + 1;
8018 ssh2_auth = malloc(len);
8019 ssh2_auth[0] = '\0';
8020 for (j = 0; j < i; j++) {
8021 for (x = 0; x < nssh2aut; x++)
8022 if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
8024 ckstrncat(ssh2_auth,ssh2aut[x].kwd,len);
8026 ckstrncat(ssh2_auth,",",len);
8029 return(success = 1);
8034 int i, j, tmp[TMPCNT];
8035 for (i = 0; i < TMPCNT; i++)
8038 for (i = 0; i < TMPCNT; i++) {
8039 if ((y = cmkey(ssh2ciphers,nssh2ciphers,
8040 "","", xxstring)) < 0) {
8045 for (j = 0; j < i; j++) {
8047 printf("\r\n?Choice has already been used.\r\n");
8053 if ((z = cmcfm()) < 0)
8062 for (j=0; j < i; j++) {
8063 for (x = 0; x < nssh2ciphers; x++)
8064 if (ssh2ciphers[x].kwval == tmp[j] &&
8065 !ssh2ciphers[x].flgs)
8067 len += strlen(ssh2ciphers[x].kwd) + 1;
8069 ssh2_cif = malloc(len);
8071 for (j = 0; j < i; j++) {
8072 for (x = 0; x < nssh2ciphers; x++)
8073 if (ssh2ciphers[x].kwval == tmp[j] && !ssh2ciphers[x].flgs)
8075 ckstrncat(ssh2_cif,ssh2ciphers[x].kwd,len);
8077 ckstrncat(ssh2_cif,",",len);
8080 return(success = 1);
8085 int i, j, tmp[TMPCNT];
8086 for (i = 0; i < TMPCNT; i++)
8089 for (i = 0; i < TMPCNT; i++) {
8090 if ((y = cmkey(ssh2macs,nssh2macs,"","", xxstring)) < 0) {
8095 for (j = 0; j < i; j++) {
8097 printf("\r\n?Choice has already been used.\r\n");
8103 if ((z = cmcfm()) < 0)
8112 for (j = 0; j < i; j++) {
8113 for (x = 0; x < nssh2macs; x++)
8114 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8116 len += strlen(ssh2macs[x].kwd) + 1;
8118 ssh2_mac = malloc(len);
8120 for (j=0; j < i; j++) {
8121 for (x = 0; x < nssh2macs; x++)
8122 if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
8124 ckstrncat(ssh2_mac,ssh2macs[x].kwd,len);
8126 ckstrncat(ssh2_mac,",",len);
8129 return(success = 1);
8134 int i, j, tmp[TMPCNT];
8135 for (i = 0; i < TMPCNT; i++)
8138 for (i = 0; i < TMPCNT; i++) {
8139 if ((y = cmkey(hkatab,nhkatab,
8140 "","", xxstring)) < 0) {
8145 for (j = 0; j < i; j++) {
8147 printf("\r\n?Choice has already been used.\r\n");
8153 if ((z = cmcfm()) < 0)
8162 for (j=0; j < i; j++) {
8163 for (x = 0; x < nhkatab; x++)
8164 if (hkatab[x].kwval == tmp[j] &&
8167 len += strlen(hkatab[x].kwd) + 1;
8169 ssh2_hka = malloc(len);
8171 for (j = 0; j < i; j++) {
8172 for (x = 0; x < nhkatab; x++)
8173 if (hkatab[x].kwval == tmp[j] && !hkatab[x].flgs)
8175 ckstrncat(ssh2_hka,hkatab[x].kwd,len);
8177 ckstrncat(ssh2_hka,",",len);
8180 return(success = 1);
8185 if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
8189 ckstrncpy(line,s,LINBUFSIZ);
8190 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8191 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8193 s = (x == -3) ? NULL : line;
8194 if ((x = cmcfm()) < 0)
8197 case SSH2_GNH: makestr(&ssh2_gnh,s); break;
8198 case SSH2_UNH: makestr(&ssh2_unh,s); break;
8199 default: return(success = 0);
8201 return(success = 1);
8204 case SSH_VRB: /* Verbosity level */
8205 y = cmnum("SSH verbosity level, 0-7","2",10,&x,xxstring);
8206 return(setnum(&ssh_vrb,x,y,7));
8208 case SSH_VER: /* Version */
8209 if ((y = cmkey(sshver,3,"","auto", xxstring)) < 0)
8211 if ((x = cmcfm()) < 0)
8213 ssh_ver = y; /* 0 == AUTO */
8215 sl_ssh_ver_saved = 0;
8216 #endif /* SSHTEST */
8217 return(success = 1);
8219 case SSH_IDF: { /* Identity file */
8221 for (i = 0; i < 32; i++) {
8222 if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
8227 if (!zfnqfp(s,LINBUFSIZ,line))
8228 ckstrncpy(line,s,LINBUFSIZ);
8229 makestr(&ssh_tmp[i],line);
8232 if ((x = cmcfm()) < 0) {
8233 for (i = 0; i < n; i++)
8234 makestr(&(ssh_tmp[i]),NULL);
8237 for (i = 0; i < 32; i++) {
8238 makestr(&(ssh_idf[i]),NULL);
8240 ssh_idf[i] = ssh_tmp[i];
8243 makestr(&(ssh_tmp[i]),NULL);
8247 return(success = 1);
8249 case SSH_XFW: /* X11-forwarding */
8250 success = seton(&ssh_xfw);
8253 sl_ssh_xfw_saved = 0;
8254 #endif /* SSHTEST */
8257 case SSH_XAL: /* SSH Xauth Location */
8258 if ((x = cmifi("Path to executable", "",&s,&y,xxstring)) < 0) {
8262 ckstrncpy(line,s,LINBUFSIZ);
8263 if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
8264 ckstrncpy(line,tmpbuf,LINBUFSIZ);
8266 s = (x == -3) ? NULL : line;
8267 if ((x = cmcfm()) < 0) return(x);
8268 makestr(&ssh_xal,s);
8269 return(success = 1);
8271 case SSH_CFG: /* Use OpenSSH Config */
8272 return(success = seton(&ssh_cfg));
8273 #endif /* SSHBUILTIN */
8287 if ((cx = cmkey(sftptab,nsftptab,"","", xxstring)) < 0)
8296 #endif /* SFTP_BUILTIN */
8300 extern ULONG RGBTable[16];
8319 static struct keytab guitab[] = {
8320 { "dialogs", GUI_DIA, 0 },
8321 { "font", GUI_FON, 0 },
8322 { "menubar", GUI_MNB, 0 },
8323 { "rgbcolor", GUI_RGB, 0 },
8324 { "toolbar", GUI_TLB, 0 },
8325 { "window", GUI_WIN, 0 },
8328 static int nguitab = (sizeof(guitab) / sizeof(struct keytab));
8330 static struct keytab guiwtab[] = {
8331 { "position", GUIW_POS, 0 },
8332 { "resize-mode", GUIW_RES, 0 },
8333 { "run-mode", GUIW_RUN, 0 },
8336 static int nguiwtab = (sizeof(guiwtab) / sizeof(struct keytab));
8338 static struct keytab guiwrtab[] = {
8339 { "change-dimensions", GUIWR_DIM, 0 },
8340 { "none", GUIWR_NON, 0 },
8341 { "scale-font", GUIWR_FON, 0 },
8344 static int nguiwrtab = (sizeof(guiwrtab) / sizeof(struct keytab));
8346 static struct keytab guiwntab[] = {
8347 { "maximize", GUIWN_MAX, 0 },
8348 { "minimize", GUIWN_MIN, 0 },
8349 { "restore", GUIWN_RES, 0 },
8352 static int nguiwntab = (sizeof(guiwntab) / sizeof(struct keytab));
8354 static struct keytab rgbtab[] = {
8359 { "darkgray", 8, 0 },
8360 { "dgray", 8, CM_INV },
8362 { "lblue", 9, CM_INV },
8363 { "lcyan", 11, CM_INV },
8364 { "lgreen", 10, CM_INV },
8365 { "lgray", 7, CM_INV },
8366 { "lightblue", 9, 0 },
8367 { "lightcyan", 11, 0 },
8368 { "lightgreen", 10, 0 },
8369 { "lightgray", 7, 0 },
8370 { "lightmagenta", 13, 0 },
8371 { "lightred", 12, 0 },
8372 { "lmagenta", 13, CM_INV },
8373 { "lred", 12, CM_INV },
8374 { "magenta", 5, 0 },
8377 { "yellow", 14, 0 },
8380 int nrgb = (sizeof(rgbtab) / sizeof(struct keytab));
8385 extern HWND getHwndKUI();
8386 unsigned char cmdsav = colorcmd;
8387 int i, red, green, blue, lines=0;
8391 printf("GUI paramters:\n");
8392 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8393 printf(" Dialogs: %s\n",showoff(gui_dialog));
8394 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8395 printf(" Position: %d,%d\n",get_gui_window_pos_x(),
8396 get_gui_window_pos_y());
8397 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8398 printf(" Resolution: %d x %d\n",GetSystemMetrics(SM_CXSCREEN),
8399 GetSystemMetrics(SM_CYSCREEN));
8400 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8401 printf(" Run-mode: %s\n",IsIconic(getHwndKUI()) ? "minimized" :
8402 IsZoomed(getHwndKUI()) ? "maximized" : "restored");
8403 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8404 switch ( get_gui_resize_mode() ) {
8412 s= "changes dimensions";
8415 printf(" Resize-mode: %s\n",s);
8416 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8418 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8420 printf("RGB Color Table:\n");
8421 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8422 printf(" Color Red Green Blue\n");
8423 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8424 printf(" ------------------------------------------\n");
8425 if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
8426 for (i = 0; i < nrgb; i++) {
8427 if (!rgbtab[i].flgs) {
8428 blue = (RGBTable[rgbtab[i].kwval] & 0x00FF0000)>>16;
8429 green = (RGBTable[rgbtab[i].kwval] & 0x0000FF00)>>8;
8430 red = (RGBTable[rgbtab[i].kwval] & 0x000000FF);
8431 printf(" %-18s %3d %3d %3d ",rgbtab[i].kwd,red,green,blue);
8432 colorcmd = rgbtab[i].kwval << 4;
8436 if (++lines > cmd_rows - 3) {
8449 int cx, red = 0, blue = 0, green = 0, z, x;
8451 if ((cx = cmkey(rgbtab,nrgb,"","",xxstring)) < 0)
8453 if ((z = cmnum("Red value, 0-255","",10,&red,xxstring)) < 0)
8455 if ((z = cmnum("Green value, 0-255","",10,&green,xxstring)) < 0)
8457 if ((z = cmnum("Blue value, 0-255","",10,&blue,xxstring)) < 0)
8459 if ((x = cmcfm()) < 0) return(x);
8460 if (cx > 15 || red > 255 || blue > 255 || green > 255)
8462 RGBTable[cx] = (unsigned)(((unsigned)blue << 16) |
8463 (unsigned)((unsigned)green << 8) |
8465 return(success = 1);
8469 Set GUI window position: XY coordinates of upper left corner,
8470 expressed as pixel numbers in the current screen resolution.
8471 (0,0) means put ourselves in the upper left corner.
8472 Can we check for out of bounds?
8478 if ((cx = cmkey(guiwtab,nguiwtab,"","",xxstring)) < 0)
8482 if ((z = cmnum("X coordinate (pixel number)","",10,&x,xxstring)) < 0)
8484 if ((z = cmnum("Y coordinate (pixel number)","",10,&y,xxstring)) < 0)
8486 if ((z = cmcfm()) < 0)
8488 if (x < 0 || y < 0) {
8489 printf("?Coordinates must be 0 or greater\n");
8493 return(success = 1);
8495 if ((x = cmkey(guiwrtab,nguiwrtab,"","",xxstring)) < 0)
8497 if ((z = cmcfm()) < 0)
8500 return(success = 1);
8502 if ((x = cmkey(guiwntab,nguiwntab,"","",xxstring)) < 0)
8504 if ((z = cmcfm()) < 0)
8506 gui_win_run_mode(x);
8507 return(success = 1);
8514 setguifont() { /* Assumes that CKFLOAT is defined! */
8516 extern struct keytab * term_font;
8517 extern struct keytab * _term_font;
8518 extern int tt_font, tt_font_size, ntermfont;
8523 BuildFontTable(&term_font, &_term_font, &ntermfont);
8524 if (!(term_font && _term_font && ntermfont > 0)) {
8525 printf("?Internal error: Failure to enumerate fonts\n");
8528 if ((x = cmkey(_term_font,ntermfont,"","",xxstring)) < 0)
8530 if ((z = cmfld("Height of font in points","12",&s,xxstring)) < 0)
8532 if (isfloat(s,0) < 1) { /* (sets floatval) */
8533 printf("?Integer or floating-point number required\n");
8536 if (floatval < 0.5) {
8537 printf("?Positive number required\n");
8540 if ((z = cmcfm()) < 0)
8542 tt_font = x; /* Font index */
8543 tt_font_size = (int)(floatval * 2); /* Font size in half points */
8544 KuiSetProperty(KUI_TERM_FONT, (long)tt_font, (long)tt_font_size);
8545 return(success = 1);
8549 setguidialog(x) int x;
8551 extern int gui_dialog;
8553 KuiSetProperty(KUI_GUI_DIALOGS, (long)x, 0L);
8557 setguimenubar(x) int x;
8559 KuiSetProperty(KUI_GUI_MENUBAR, (long)x, 0L);
8563 setguitoolbar(x) int x;
8565 KuiSetProperty(KUI_GUI_TOOLBAR, (long)x, 0L);
8571 if ((cx = cmkey(guitab,nguitab,"","",xxstring)) < 0)
8580 return(setguifont());
8584 return(setguiwin());
8602 setexitwarn(x) int x;
8606 KuiSetProperty(KUI_EXIT_WARNING, (long)x, 0L);
8612 setdebses(x) int x; {
8614 if ((debses != 0) && (x == 0)) /* It was on and we turned it off? */
8615 os2debugoff(); /* Fix OS/2 coloration */
8619 KuiSetProperty(KUI_TERM_DEBUG,x,0);
8622 #endif /* NOLOCAL */
8624 /* D O P R M -- Set a parameter. */
8632 doprm(xx,rmsflg) int xx, rmsflg; {
8633 int i = 0, x = 0, y = 0, z = 0;
8635 char *s = NULL, *p = NULL;
8638 long portspeed = 0L;
8648 #endif /* NOSETKEY */
8650 if (xx == XYFLAG) { /* SET FLAG */
8652 return(success = seton(&ooflag));
8654 if (xx == XYPRTR /* SET PRINTER (or BPRINTER) */
8659 return(setprinter(xx));
8663 #ifdef ANYX25 /* SET X25 ... */
8668 case XYPAD: /* SET PAD ... */
8674 case XYEOL: /* These have all been moved to set send/receive... */
8675 case XYLEN: /* Let the user know what to do. */
8680 printf("...Use SET SEND or SET RECEIVE instead.\n");
8681 printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n");
8682 return(success = 0);
8684 case XYATTR: /* File Attribute packets */
8685 return(setat(rmsflg));
8687 case XYIFD: /* Incomplete file disposition */
8688 if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
8689 if ((x = cmcfm()) < 0) return(x);
8691 sstate = setgen('S',
8693 y == 0 ? "0" : (y == 1 ? "1" : "2"),
8696 return((int) sstate);
8699 return(success = 1);
8703 case XYMATCH: /* [ REMOTE ] SET MATCH... */
8705 if ((z = cmkey(matchtab,nmatchtab,"","",xxstring)) < 0)
8708 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
8709 if ((x = cmcfm()) < 0) return(x);
8712 return(sstate = setgen('S',"330", y == 0 ? "0" : "1", ""));
8714 return(sstate = setgen('S',"331", y == 0 ? "0" : "1", ""));
8722 return(success = seton(&matchfifo));
8724 x = seton(&matchdot);
8725 if (x < 0) return(x);
8727 return(success = x);
8733 case XYINPU: /* SET INPUT */
8738 case XYNET: { /* SET NETWORK */
8742 cmfdbi(&k1,_CMKEY,"","","",nnetkey, 0, xxstring, netkey, &k2);
8743 cmfdbi(&k2,_CMKEY,"","","",nnets, 0, xxstring, netcmd, NULL);
8745 #ifdef OS2 /* Hide network-type keywords for networks not installed */
8746 for (z = 0; z < nnets; z++) {
8747 if (netcmd[z].kwval == NET_TCPB && tcp_avail == 0)
8748 netcmd[z].flgs = CM_INV;
8750 if (netcmd[z].kwval == NET_SSH &&
8751 !ck_ssleay_is_installed())
8752 netcmd[z].flgs = CM_INV;
8753 #endif /* SSHBUILTIN */
8755 else if (netcmd[z].kwval == NET_DEC && dnet_avail == 0)
8756 netcmd[z].flgs = CM_INV;
8759 else if (netcmd[z].kwval == NET_BIOS && netbiosAvail == 0)
8760 netcmd[z].flgs = CM_INV;
8761 #endif /* CK_NETBIOS */
8763 else if (netcmd[z].kwval == NET_SLAT && slat_avail == 0)
8764 netcmd[z].flgs = CM_INV;
8765 #endif /* SUPERLAT */
8767 if (tcp_avail) /* Default network type */
8768 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
8770 else if ( ck_ssleay_is_installed() )
8771 ckstrncpy(tmpbuf,"ssh",TMPBUFSIZ);
8772 #endif /* SSHBUILTIN */
8774 else if (dnet_avail)
8775 ckstrncpy(tmpbuf,"decnet",TMPBUFSIZ);
8778 else if (slat_avail)
8779 ckstrncpy(tmpbuf,"superlat",TMPBUFSIZ);
8780 #endif /* SUPERLAT */
8782 else if (netbiosAvail)
8783 ckstrncpy(tmpbuf,"netbios",TMPBUFSIZ);
8784 #endif /* CK_NETBIOS */
8785 else ckstrncpy(tmpbuf,"named-pipe",TMPBUFSIZ);
8788 ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
8791 ckstrncpy(tmpbuf,"x.25",TMPBUFSIZ);
8793 ckstrncpy(tmpbuf,"",TMPBUFSIZ);
8795 #endif /* TCPSOCKET */
8799 if (x < 0) { /* Error */
8800 if (x == -2 || x == -9)
8801 printf("?No keywords match: \"%s\"\n",atmbuf);
8804 z = cmresult.nresult; /* Keyword value */
8805 if (cmresult.fdbaddr == &k1) { /* Which table? */
8812 if ((z = cmkey(netcmd,nnets,"",tmpbuf,xxstring)) < 0)
8817 if (z == NET_CMD && nopush) {
8818 printf("\n?Sorry, access to external commands is disabled\n");
8825 if (z == NET_PTY && nopush) {
8826 printf("\n?Sorry, access to external commands is disabled\n");
8833 if (z == NET_TCPB && tcp_avail == 0) {
8835 "\n?Sorry, either TCP/IP is not available on this system or\n\
8836 necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
8839 } else if (z == NET_SSH && !ck_ssleay_is_installed()) {
8840 printf("\n?Sorry, SSH is not available on this system.\n") ;
8842 #endif /* SSHBUILTIN */
8844 } else if (z == NET_BIOS && netbiosAvail == 0) {
8845 printf("\n?Sorry, NETBIOS is not available on this system.\n") ;
8847 #endif /* CK_NETBIOS */
8849 } else if (z == NET_DEC && dnet_avail == 0) {
8850 printf("\n?Sorry, DECnet is not available on this system.\n") ;
8854 } else if (z == NET_SLAT && slat_avail == 0) {
8855 printf("\n?Sorry, SuperLAT is not available on this system.\n") ;
8857 #endif /* SUPERLAT */
8862 if (z == NET_PIPE || /* Named pipe -- also get pipename */
8863 z == NET_BIOS) { /* NETBIOS -- also get local name */
8866 char tmpnbnam[NETBIOS_NAME_LEN+1];
8867 #endif /* CK_NETBIOS */
8868 /* Construct default name */
8869 if (z == NET_PIPE) { /* Named pipe */
8870 defnam = "kermit"; /* Default name is always "kermit" */
8871 } else { /* NetBIOS */
8872 if (NetBiosName[0] != SP) { /* If there is already a name, */
8874 int n; /* use it as the default. */
8875 ckstrncpy(tmpnbnam,NetBiosName,NETBIOS_NAME_LEN+1);
8876 /* convert trailing spaces to NULs */
8877 p = &tmpnbnam[NETBIOS_NAME_LEN-1];
8883 } else if (*myhost) /* Otherwise use this PC's host name */
8884 defnam = (char *) myhost;
8885 else /* Otherwise use "kermit" */
8888 if ((y = cmtxt((z == NET_PIPE) ? "pipe name" :
8889 "local NETBIOS name",
8890 defnam, &s, xxstring)) < 0)
8895 if ((y = (int) strlen(s)) < 1) {
8896 printf("?You must also specify a %s name\n",
8897 (z == NET_PIPE) ? "pipe" : "local NETBIOS" );
8901 if (z == NET_BIOS) {
8902 if (!netbiosAvail) {
8903 printf("?NETBIOS is not available on this system.\n") ;
8906 if (y - NETBIOS_NAME_LEN > 0) {
8907 printf("?NETBIOS name too long, %ld maximum\n",
8910 } else if ( !strcmp(s,tmpnbnam) ) {
8911 nettype = z; /* Returning to old connection... */
8912 return(success = 1); /* Done */
8913 } else if (strcmp(" ",NetBiosName)) {
8914 printf("?NETBIOS name already assigned to \"%s\"\n",
8920 ckstrncpy(NetBiosName,s,16);
8921 for (x = y; x < NETBIOS_NAME_LEN; x++)
8922 NetBiosName[x] = SP;
8923 NetBiosName[NETBIOS_NAME_LEN] = NUL;
8924 printf("Checking \"%s\" as a unique NetBIOS name...\n",
8926 rc = NCBAddName( NetbeuiAPI,
8927 &ncb, NetBiosAdapter, NetBiosName );
8930 "?Sorry, \"%s\" is already in use by another NetBIOS node.\n",
8932 for (x = 0; x < NETBIOS_NAME_LEN; x++)
8933 NetBiosName[x] = SP;
8938 #endif /* CK_NETBIOS */
8941 ckstrncpy(pipename,s,PIPENAML);
8944 #endif /* NPIPEORBIOS */
8947 /* Determine if we are using LAT or CTERM */
8948 if ((y = cmkey(dnettab,
8949 ndnet,"DECNET protocol","lat",xxstring)) < 0)
8951 if ((x = cmcfm()) < 0) return(x);
8957 /* Find out which DLL they are using */
8958 char dllname[256]="";
8960 if ((x = cmifi("Dynamic load library",
8961 "",&p,&y,xxstring)) < 0) {
8963 printf("?Name of DLL required\n");
8968 ckstrncpy(dllname,p,256);
8969 if ((x = cmcfm()) < 0) return(x);
8971 if (netdll_load(dllname) < 0) /* Try to load the dll */
8972 return(success = 0);
8975 return(success = 1);
8979 if ((x = cmcfm()) < 0) return(x);
8983 (nettype != NET_DEC) &&
8986 (nettype != NET_PIPE) &&
8989 (nettype != NET_BIOS) &&
8990 #endif /* CK_NETBIOS */
8992 (nettype != NET_FILE) &&
8993 #endif /* NETFILE */
8995 (nettype != NET_CMD) &&
8998 (nettype != NET_PTY) &&
9001 (nettype != NET_DLL) &&
9004 (nettype != NET_SLAT) &&
9005 #endif /* SUPERLAT */
9006 (nettype != NET_SX25) &&
9007 (nettype != NET_VX25) &&
9009 (nettype != NET_IX25) &&
9012 (nettype != NET_SSH) &&
9013 #endif /* SSHBUILTIN */
9014 (nettype != NET_TCPB)) {
9015 printf("?Network type not supported\n");
9016 return(success = 0);
9018 return(success = 1);
9027 if ((z = cmkey(tcpopt,ntcpopt,"TCP option","nodelay",xxstring)) < 0)
9032 case XYTCP_HTTP_PROXY: {
9035 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1], abuf[256];
9036 ubuf[0] = pbuf[0] = abuf[0] = 0;
9038 cmfdbi(&sw, /* First FDB - switches */
9040 "HTTP proxy server host[:port] or switch",
9042 "", /* addtl string data */
9043 nuserpass, /* addtl numeric data 1: tbl size */
9044 4, /* addtl numeric data 2: 4 = cmswi */
9045 xxstring, /* Processing function */
9046 userpass, /* Keyword table */
9047 &tx /* Pointer to next FDB */
9051 "HTTP proxy server host[:port]",
9053 "", /* addtl string data */
9054 0, /* addtl numeric data 1 */
9055 0, /* addtl numeric data 2 */
9061 if ((x = cmfdb(&sw)) < 0) {
9064 printf("?Hostname required\n");
9068 if (cmresult.fcode != _CMKEY)
9070 n = cmresult.nresult;
9075 if ((x = cmfld((n == UPW_USER) ?
9077 ((n == UPW_PASS) ? "Password" : "Agent"),
9078 "", &s, xxstring)) < 0) {
9082 ckstrncpy((n == UPW_USER) ? ubuf :
9083 ((n == UPW_PASS) ? pbuf : abuf), s,
9084 (n == UPW_AGENT) ? 256 : (LOGINLEN+1));
9087 if (cmresult.fcode != _CMTXT)
9089 s = cmresult.sresult;
9090 if (s) if (!*s) s = NULL;
9094 return(success = 0);
9095 #endif /* IKSDCONF */
9096 makestr(&tcp_http_proxy_user,ubuf[0]?ubuf:NULL);
9097 makestr(&tcp_http_proxy_pwd,pbuf[0]?pbuf:NULL);
9098 makestr(&tcp_http_proxy_agent,abuf[0]?abuf:NULL);
9099 makestr(&tcp_http_proxy,s);
9100 memset(pbuf,0,sizeof(pbuf));
9101 return(success = 1);
9105 It would have been easy to combine XYTCP_SOCKS_SVR with the previous
9106 one except for the #ifdefs...
9110 case XYTCP_SOCKS_SVR: {
9111 char ubuf[LOGINLEN+1], pbuf[LOGINLEN+1];
9112 char * p = getenv("SOCKS_SERVER");
9118 cmfdbi(&sw, /* First FDB - switches */
9120 "SOCKS server host[:port] or switch",
9122 "", /* addtl string data */
9123 nuserpass, /* addtl numeric data 1: tbl size */
9124 4, /* addtl numeric data 2: 4 = cmswi */
9125 xxstring, /* Processing function */
9126 userpass, /* Keyword table */
9127 &tx /* Pointer to next FDB */
9131 "SOCKS server host[:port]",
9133 "", /* addtl string data */
9134 0, /* addtl numeric data 1 */
9135 0, /* addtl numeric data 2 */
9141 if ((x = cmfdb(&sw)) < 0) {
9144 printf("?Hostname required\n");
9148 if (cmresult.fcode != _CMKEY)
9150 n = cmresult.nresult;
9154 if ((x = cmfld((n == UPW_USER) ? "Username" : "Password",
9155 "", &s, xxstring)) < 0) {
9159 ckstrncpy((n == UPW_USER) ? ubuf : pbuf, s, LOGINLEN+1);
9162 if (cmresult.fcode != _CMTXT)
9164 s = cmresult.sresult;
9165 if (s) if (!*s) s = NULL;
9169 return(success = 0);
9170 #endif /* IKSDCONF */
9171 makestr(&tcp_socks_user,ubuf);
9172 memset(pbuf,0,sizeof(pbuf));
9173 makestr(&tcp_socks_svr,s);
9174 return(success = 1);
9178 case XYTCP_SOCKS_NS: {
9179 char * p = getenv("SOCKS_NS");
9181 if ((y = cmtxt("hostname or IP of SOCKS Name Server",p,
9185 if (iksdcf) return(success = 0);
9186 #endif /* IKSDCONF */
9188 free(tcp_socks_ns); /* Free any previous storage */
9189 tcp_socks_ns = NULL;
9191 if (s == NULL || *s == NUL) { /* If none given */
9192 tcp_socks_ns = NULL; /* remove the override string */
9193 return(success = 1);
9194 } else if ((tcp_socks_ns = malloc(strlen(s)+1))) {
9195 strcpy(tcp_socks_ns,s);
9196 return(success = 1);
9198 return(success = 0);
9200 #endif /* CK_SOCKS_NS */
9201 #endif /* CK_SOCKS */
9204 if ((y = cmtxt("preferred IP Address for TCP connections","",
9208 if (iksdcf) return(success = 0);
9209 #endif /* IKSDCONF */
9211 free(tcp_address); /* Free any previous storage */
9214 if (s == NULL || *s == NUL) { /* If none given */
9215 tcp_address = NULL; /* remove the override string */
9216 return(success = 1);
9217 } else if ((tcp_address = malloc(strlen(s)+1))) {
9218 strcpy(tcp_address,s);
9219 return(success = 1);
9221 return(success = 0);
9223 case XYTCP_KEEPALIVE:
9224 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9225 if ((y = cmcfm()) < 0) return(y);
9227 if (iksdcf) return(success = 0);
9228 #endif /* IKSDCONF */
9230 if (network && nettype == NET_SSH && ssh_sock != -1)
9231 success = keepalive(ssh_sock,z);
9233 #endif /* SSHBUILTIN */
9234 success = keepalive(ttyfd,z);
9236 #endif /* SO_KEEPALIVE */
9238 case XYTCP_DONTROUTE:
9239 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9240 if ((y = cmcfm()) < 0) return(y);
9242 if (iksdcf) return(success = 0);
9243 #endif /* IKSDCONF */
9245 if (network && nettype == NET_SSH && ssh_sock != -1)
9246 success = dontroute(ssh_sock,z);
9248 #endif /* SSHBUILTIN */
9249 success = dontroute(ttyfd,z);
9251 #endif /* SO_DONTROUTE */
9254 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
9255 if ((y = cmcfm()) < 0) return(y);
9257 if (iksdcf) return(success = 0);
9258 #endif /* IKSDCONF */
9260 if (network && nettype == NET_SSH && ssh_sock != -1)
9261 success = no_delay(ssh_sock,z);
9263 #endif /* SSHBUILTIN */
9264 success = no_delay(ttyfd,z);
9266 case XYTCP_NAGLE: /* The inverse of NODELAY */
9267 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9268 if ((y = cmcfm()) < 0) return(y);
9270 if (iksdcf) return(success = 0);
9271 #endif /* IKSDCONF */
9273 if (network && nettype == NET_SSH && ssh_sock != -1)
9274 success = no_delay(ssh_sock,z);
9276 #endif /* SSHBUILTIN */
9277 success = no_delay(ttyfd,!z);
9279 #endif /* TCP_NODELAY */
9282 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0)
9284 if (z) { /* if on, we need a timeout value */
9285 if ((x = cmnum("Linger timeout in 10th of a millisecond",
9286 "0",10,&y,xxstring)) < 0)
9290 if ((x = cmcfm()) < 0)
9293 if (iksdcf) return(success = 0);
9294 #endif /* IKSDCONF */
9296 if (network && nettype == NET_SSH && ssh_sock != -1)
9297 success = ck_linger(ssh_sock,z,y);
9299 #endif /* SSHBUILTIN */
9300 success = ck_linger(ttyfd,z,y);
9302 #endif /* SO_LINGER */
9305 x = cmnum("Send buffer size, bytes","8192",10,&z,xxstring);
9306 if (x < 0) return(x);
9307 if ((x = cmcfm()) < 0) return(x);
9309 if (iksdcf) return(success = 0);
9310 #endif /* IKSDCONF */
9312 if (network && nettype == NET_SSH && ssh_sock != -1)
9313 success = sendbuf(ssh_sock,z);
9315 #endif /* SSHBUILTIN */
9316 success = sendbuf(ttyfd,z);
9318 #endif /* SO_SNDBUF */
9321 x = cmnum("Receive buffer size, bytes","8192",10,&z,xxstring);
9322 if (x < 0) return(x);
9323 if ((x = cmcfm()) < 0) return(x);
9325 if (iksdcf) return(success = 0);
9326 #endif /* IKSDCONF */
9328 /* Note: The following is not 16-bit safe */
9332 printf("?Warning: receive buffers larger than 52248 bytes\n");
9333 printf(" may not be understood by all hosts. Performance\n");
9334 printf(" may suffer.\n");
9339 if (network && nettype == NET_SSH && ssh_sock != -1)
9340 success = recvbuf(ssh_sock,z);
9342 #endif /* SSHBUILTIN */
9343 success = recvbuf(ttyfd,z);
9345 #endif /* SO_RCVBUF */
9349 case XYTCP_UCX: { /* UCX 2.0 port swabbing bug */
9350 extern int ucx_port_bug;
9351 return(success = seton(&ucx_port_bug));
9353 #endif /* DEC_TCPIP */
9357 extern int tcp_rdns;
9358 return(success = setonaut(&tcp_rdns));
9362 case XYTCP_DNS_SRV: {
9363 extern int tcp_dns_srv;
9364 return(success = seton(&tcp_dns_srv));
9366 #endif /* CK_DNS_SRV */
9372 #endif /* TCPSOCKET */
9373 #endif /* NOTCPOPTS */
9374 #endif /* NETCONN */
9381 case XYHOST: { /* SET HOST */
9382 z = ttnproto; /* Save protocol in case of failure */
9384 if (nettype != NET_DEC)
9387 if ((y = setlin(XYHOST,1,0)) <= 0) { /* Sets success to 1 */
9388 debug(F101,"SET HOST fail mdmtyp","",mdmtyp);
9389 ttnproto = z; /* Failed, restore protocol */
9393 debug(F101,"SET HOST OK mdmtyp","",mdmtyp);
9394 debug(F101,"SET HOST reliable","",reliable);
9397 #endif /* NETCONN */
9399 case XYLINE: /* SET LINE (= SET PORT) */
9400 debug(F101,"setlin flow 1","",flow);
9402 if (x > -1) didsetlin++;
9403 debug(F101,"SET LINE setlin","",x);
9404 debug(F101,"SET LINE flow","",flow);
9405 debug(F101,"SET LINE local","",local);
9406 debug(F101,"SET LINE reliable","",reliable);
9408 #endif /* NOLOCAL */
9411 case XYKEY: /* SET KEY */
9413 #endif /* NOSETKEY */
9416 case XYLANG: /* Language */
9417 if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0)
9419 if ((x = cmcfm()) < 0) return(x);
9421 /* Look up language and get associated character sets */
9422 for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ;
9424 printf("?internal error, sorry\n");
9425 return(success = 0);
9427 language = i; /* All good, set the language, */
9428 return(success = 1);
9429 #endif /* NOCSETS */
9432 case XYBACK: /* BACKGROUND */
9433 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
9434 if ((y = cmcfm()) < 0) return(y);
9436 bgset = z; /* 0 = off (foreground) */
9437 #ifdef VMS /* 1 = on (background) */
9438 if (batch && bgset == 0) /* To enable echoing of commands */
9439 ckxech = 1; /* in VMS batch logs */
9442 if (z) { /* 1 = Background */
9448 } else { /* 0 = Foreground */
9455 #endif /* COMMENT */
9461 case XYQUIE: { /* QUIET */
9463 extern int * xquiet;
9465 extern int xquiet[];
9466 #endif /* DCMDBUF */
9468 if (x < 0) return(x);
9469 xquiet[cmdlvl] = quiet;
9470 return(success = x);
9474 case XYBUF: { /* BUFFERS */
9477 if ((y = cmnum("Send buffer size","",10,&sb,xxstring)) < 0) {
9478 if (y == -3) printf("?Buffer size required\n");
9483 printf("?Negative numbers can't be used here\n");
9484 else printf("?Integer overflow, use a smaller number please\n");
9486 } else if (sb < 80) {
9487 printf("?Too small\n");
9490 if ((y=cmnum("Receive buffer size",ckitoa(sb),10,&rb,xxstring)) < 0)
9494 printf("?Negative numbers can't be used here\n");
9495 else printf("?Integer overflow, use a smaller number please\n");
9497 } else if (rb < 80) {
9498 printf("?Too small\n");
9501 if ((y = cmcfm()) < 0) return(y);
9502 if ((y = inibufs(sb,rb)) < 0) return(y);
9503 y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */
9504 if (y != urpsiz) urpsiz = y;
9505 y = adjpkl(spsiz,wslotr,bigsbsiz);
9506 if (y != spsiz) spsiz = spmax = spsizr = y;
9507 return(success = 1);
9509 printf("?Sorry, not available\n");
9510 return(success = 0);
9511 #endif /* DYNAMIC */
9514 case XYCHKT: /* BLOCK-CHECK */
9515 if ((x = cmkey(chktab,4,"","3",xxstring)) < 0) return(x);
9516 if ((y = cmcfm()) < 0) return(y);
9517 bctr = x; /* Set local too even if REMOTE SET */
9523 ckstrncpy(tmpbuf,ckitoa(x),TMPBUFSIZ);
9524 sstate = setgen('S', "400", tmpbuf, "");
9525 return((int) sstate);
9527 return(success = 1);
9532 #ifndef MAC /* The Mac has no RS-232 */
9533 case XYCARR: /* CARRIER-WATCH */
9536 #endif /* NOLOCAL */
9540 switch (xx) { /* Avoid long switch statements... */
9542 int c, n; /* Workers */
9543 int getval = 0; /* Whether to get switch value */
9544 int tnserver = 0; /* Client by default */
9545 int opt = -1; /* Telnet Option */
9546 struct FDB sw, op; /* FDBs for each parse function */
9547 #ifdef CK_AUTHENTICATION
9548 extern int sl_topt_a_s_saved;
9549 extern int sl_topt_a_c_saved;
9550 extern int sl_topt_e_s_saved;
9551 extern int sl_topt_e_c_saved;
9552 #endif /* CK_AUTHENTICATION */
9554 if (inserver) /* Server by default when IKSD */
9558 /* Set up chained parse functions... */
9560 cmfdbi(&op, /* First fdb - telopts*/
9562 "/client, /server or", /* hlpmsg */
9564 "", /* addtl string data */
9565 ntnopt, /* addtl numeric data 1 */
9566 0, /* addtl numeric data 2 */
9571 cmfdbi(&sw, /* Second FDB - command switches */
9575 "", /* addtl string data */
9576 ntnoptsw, /* addtl numeric data 1: tbl size */
9577 4, /* addtl numeric data 2: 4 = cmswi */
9578 xxstring, /* Processing function */
9579 tnoptsw, /* Keyword table */
9580 NULL /* Pointer to next FDB */
9583 while (opt < 0) { /* Parse 0 or more switches */
9584 x = cmfdb(&op); /* Parse switch or other thing */
9585 debug(F101,"XYTELOP cmfdb","",x);
9586 if (x < 0) /* Error */
9587 return(x); /* or reparse needed */
9588 if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
9590 c = cmgbrk(); /* Get break character */
9591 getval = (c == ':' || c == '='); /* see how switch ended */
9592 if (getval && !(cmresult.kflags & CM_ARG)) {
9593 printf("?This switch does not take arguments\n");
9596 z = cmresult.nresult; /* Numeric result = switch value */
9597 debug(F101,"XYTELOP switch","",z);
9599 switch (z) { /* Process the switch */
9613 opt = TELOPT_BINARY;
9616 opt = TELOPT_NEWENVIRON;
9619 opt = TELOPT_SNDLOC;
9622 opt = TELOPT_AUTHENTICATION;
9625 opt = TELOPT_FORWARD_X;
9628 opt = TELOPT_ENCRYPTION;
9631 opt = TELOPT_KERMIT;
9634 opt = TELOPT_START_TLS;
9637 opt = TELOPT_XDISPLOC;
9646 opt = TELOPT_PRAGMA_HEARTBEAT;
9649 opt = TELOPT_SSPI_LOGON;
9652 opt = TELOPT_PRAGMA_LOGON;
9655 opt = TELOPT_IBM_SAK;
9658 opt = TELOPT_COMPORT;
9661 opt = TELOPT_LOGOUT;
9667 printf("?Unexpected value - %d\n",z);
9671 if (cmresult.fdbaddr == &op)
9673 #endif /* COMMENT */
9676 case TELOPT_ECHO: /* Options only the Server WILL */
9677 case TELOPT_FORWARD_X:
9678 case TELOPT_SEND_URL:
9679 case TELOPT_IBM_SAK:
9681 if ((x = cmkey(tnnegtab,
9683 "desired server state",
9684 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
9688 if ((z = cmcfm()) < 0)
9691 TELOPT_DEF_S_ME_MODE(opt) = x;
9692 TELOPT_ME_MODE(opt) = x;
9694 TELOPT_DEF_C_U_MODE(opt) = x;
9695 TELOPT_U_MODE(opt) = x;
9699 case TELOPT_TTYPE: /* Options only the Client WILL */
9700 case TELOPT_NEWENVIRON:
9702 case TELOPT_AUTHENTICATION:
9703 case TELOPT_START_TLS:
9704 case TELOPT_XDISPLOC:
9707 case TELOPT_COMPORT:
9708 if ((x = cmkey(tnnegtab,
9710 "desired client state",
9711 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
9715 if ((z = cmcfm()) < 0)
9718 TELOPT_DEF_S_U_MODE(opt) = x;
9719 TELOPT_U_MODE(opt) = x;
9720 #ifdef CK_AUTHENTICATION
9721 if (opt == TELOPT_AUTHENTICATION)
9722 sl_topt_a_s_saved = 0;
9723 #endif /* CK_AUTHENTICATION */
9725 TELOPT_DEF_C_ME_MODE(opt) = x;
9726 TELOPT_ME_MODE(opt) = x;
9727 #ifdef CK_AUTHENTICATION
9728 if (opt == TELOPT_AUTHENTICATION)
9729 sl_topt_a_c_saved = 0;
9730 #endif /* CK_AUTHENTICATION */
9735 if ((x = cmkey(tnnegtab,
9738 "desired server state" :
9739 "desired client state",
9740 TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
9745 if ((y = cmkey(tnnegtab,
9747 !tnserver ? "desired server state" :
9748 "desired client state",
9749 TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
9754 if ((z = cmcfm()) < 0)
9757 TELOPT_DEF_S_ME_MODE(opt) = x;
9758 TELOPT_ME_MODE(opt) = x;
9759 TELOPT_DEF_S_U_MODE(opt) = y;
9760 TELOPT_U_MODE(opt) = y;
9761 #ifdef CK_ENCRYPTION
9762 if (opt == TELOPT_ENCRYPTION)
9763 sl_topt_e_s_saved = 0;
9764 #endif /* CK_ENCRYPTION */
9766 TELOPT_DEF_C_ME_MODE(opt) = x;
9767 TELOPT_ME_MODE(opt) = x;
9768 TELOPT_DEF_C_U_MODE(opt) = y;
9769 TELOPT_U_MODE(opt) = y;
9770 #ifdef CK_ENCRYPTION
9771 if (opt == TELOPT_ENCRYPTION)
9772 sl_topt_e_c_saved = 0;
9773 #endif /* CK_ENCRYPTION */
9776 return(success = 1);
9779 case XYTEL: /* TELNET */
9780 if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "",
9784 case CK_TN_EC: /* ECHO */
9785 if ((x = cmkey(rltab,nrlt,
9786 "initial TELNET echoing state",
9787 "local",xxstring)) < 0)
9789 if ((y = cmcfm()) < 0) return(y);
9791 return(success = 1);
9793 case CK_TN_RE: /* REMOTE-ECHO */
9794 return(success = seton(&tn_rem_echo));
9796 case CK_TN_DB: /* DEBUG */
9797 return(success = seton(&tn_deb));
9799 case CK_TN_TT: /* TERMINAL TYPE */
9800 if ((y = cmtxt("terminal type for TELNET connections","",
9804 free(tn_term); /* Free any previous storage */
9807 if (s == NULL || *s == NUL) { /* If none given */
9808 tn_term = NULL; /* remove the override string */
9809 return(success = 1);
9810 } else if ((tn_term = malloc(strlen(s)+1))) {
9812 return(success = 1);
9813 } else return(success = 0);
9816 case CK_TN_FX: /* FORWARD-X */
9817 if ((x=cmkey(tnfwdxtab,ntnfwdx,"","xauthority-file",xxstring)) < 0)
9820 case 0: { /* Xauthority-File */
9821 x = cmifi("Full path of .Xauthority file","",&s,&y,xxstring);
9822 if (x < 0 && x != -3)
9824 makestr(&tn_fwdx_xauthority,s);
9825 return(success = 1);
9827 case 1: { /* No-Encryption */
9828 extern int fwdx_no_encrypt;
9829 return(success = seton(&fwdx_no_encrypt));
9832 return(success = 0);
9833 #endif /* CK_FORWARD_X */
9835 case CK_TN_NL: /* TELNET NEWLINE-MODE */
9836 if ((x = cmkey(tn_nlmtab,ntn_nlm,"","nvt",xxstring)) < 0)
9838 if (x == TN_NL_BIN) {
9839 if ((x = cmkey(tnlmtab,ntnlm,"","raw",xxstring)) < 0)
9841 if ((y = cmcfm()) < 0)
9844 return(success = 1);
9845 } else if (x == TN_NL_NVT) {
9846 if ((x = cmkey(tnlmtab,ntnlm,"","on",xxstring)) < 0)
9848 if ((y = cmcfm()) < 0)
9851 return(success = 1);
9853 if ((y = cmcfm()) < 0)
9856 return(success = 1);
9859 case CK_TN_XF: /* BINARY-TRANSFER-MODE */
9860 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9861 if ((y = cmcfm()) < 0) return(y);
9863 return(success = 1);
9865 case CK_TN_NE: /* NO-ENCRYPT-DURING-XFER */
9866 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
9867 if ((y = cmcfm()) < 0) return(y);
9869 /* Don't let this be set remotely */
9870 if (apcactive == APC_LOCAL ||
9871 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
9872 return(success = 0);
9874 tn_no_encrypt_xfer = z;
9875 return(success = 1);
9877 case CK_TN_BM: /* BINARY-MODE */
9878 if ((x = cmkey(tnnegtab,ntnnegtab,"","refused",xxstring)) < 0)
9880 if ((y = cmcfm()) < 0)
9882 TELOPT_DEF_S_ME_MODE(TELOPT_BINARY) = x;
9883 TELOPT_DEF_S_U_MODE(TELOPT_BINARY) = x;
9884 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = x;
9885 TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = x;
9886 return(success = 1);
9889 case CK_TN_IKS: /* KERMIT */
9890 if ((x = cmkey(tnnegtab,ntnnegtab,"DO","accept",xxstring)) < 0)
9892 if ((y = cmkey(tnnegtab,ntnnegtab,"WILL","accept",xxstring)) < 0)
9894 if ((z = cmcfm()) < 0)
9896 TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = y;
9897 TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = x;
9898 TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = y;
9899 TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = x;
9900 return(success = 1);
9901 #endif /* IKS_OPTION */
9904 case CK_TN_TLS: /* START_TLS */
9905 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
9907 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
9909 if ((z = cmcfm()) < 0)
9911 TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = x;
9912 TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = y;
9913 TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = x;
9914 TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = y;
9915 return(success = 1);
9919 case CK_TN_NAWS: /* NAWS */
9920 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
9922 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
9924 if ((z = cmcfm()) < 0)
9926 TELOPT_DEF_S_ME_MODE(TELOPT_NAWS) = x;
9927 TELOPT_DEF_S_U_MODE(TELOPT_NAWS) = y;
9928 TELOPT_DEF_C_ME_MODE(TELOPT_NAWS) = x;
9929 TELOPT_DEF_C_U_MODE(TELOPT_NAWS) = y;
9930 return(success = 1);
9931 #endif /* CK_NAWS */
9933 #ifdef CK_AUTHENTICATION
9934 case CK_TN_AU: /* AUTHENTICATION */
9935 if ((x = cmkey(tnauthtab,ntnauth,"","",xxstring)) < 0)
9937 if (x == TN_AU_FWD) {
9938 extern int forward_flag;
9939 return(success = seton(&forward_flag));
9940 } else if (x == TN_AU_TYP) {
9941 extern int auth_type_user[];
9942 extern int sl_auth_type_user[];
9943 extern int sl_auth_saved;
9944 int i, j, atypes[AUTHTYPLSTSZ];
9946 for (i = 0; i < AUTHTYPLSTSZ; i++) {
9947 if ((y = cmkey(autyptab,nautyp,"",
9948 i == 0 ? "automatic" : "" ,
9954 if (i > 0 && (y == AUTHTYPE_AUTO || y == AUTHTYPE_NULL)) {
9956 "\r\n?Choice may only be used in first position.\r\n");
9959 for (j = 0; j < i; j++) {
9960 if (atypes[j] == y) {
9961 printf("\r\n?Choice has already been used.\r\n");
9966 if (y == AUTHTYPE_NULL || y == AUTHTYPE_AUTO) {
9971 if (i < AUTHTYPLSTSZ)
9972 atypes[i] = AUTHTYPE_NULL;
9973 if ((z = cmcfm()) < 0)
9976 for (i = 0; i < AUTHTYPLSTSZ; i++) {
9977 auth_type_user[i] = atypes[i];
9978 sl_auth_type_user[i] = 0;
9980 } else if (x == TN_AU_HOW) {
9981 if ((y = cmkey(auhowtab,nauhow,"","any",xxstring)) < 0)
9983 if ((z = cmcfm()) < 0)
9986 } else if (x == TN_AU_ENC) {
9987 if ((y = cmkey(auenctab,nauenc,"","encrypt",xxstring)) < 0)
9989 if ((z = cmcfm()) < 0)
9993 if ((y = cmcfm()) < 0)
9995 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = x;
9996 TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = x;
9998 return(success = 1);
9999 #endif /* CK_AUTHENTICATION */
10001 #ifdef CK_ENCRYPTION
10002 case CK_TN_ENC: { /* ENCRYPTION */
10005 static struct keytab * tnetbl = NULL;
10006 static int ntnetbl = 0;
10008 if ((y = cmkey(tnenctab,ntnenc,"","",xxstring)) < 0)
10012 x = ck_get_crypt_table(&tnetbl,&ntnetbl);
10013 debug(F101,"ck_get_crypt_table x","",x);
10014 debug(F101,"ck_get_crypt_table n","",ntnetbl);
10015 if (x < 1 || !tnetbl || ntnetbl < 1) /* Didn't get it */
10018 printf("?Oops, types not loaded\n");
10021 if ((x = cmkey(tnetbl,ntnetbl,"type of encryption",
10022 "automatic",xxstring)) < 0)
10024 if ((z = cmcfm()) < 0)
10030 if ((z = cmcfm()) < 0)
10033 /* Don't let this be set remotely */
10034 if (apcactive == APC_LOCAL ||
10035 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10036 return(success = 0);
10037 #endif /* CK_APC */
10041 if ((z = cmcfm()) < 0)
10044 /* Don't let this be set remotely */
10045 if (apcactive == APC_LOCAL ||
10046 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
10047 return(success = 0);
10048 #endif /* CK_APC */
10052 if ((z = cmcfm()) < 0)
10054 TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = y;
10055 TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = y;
10056 TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = y;
10057 TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = y;
10059 return(success = 1);
10061 #endif /* CK_ENCRYPTION */
10063 case CK_TN_BUG: /* BUG */
10064 if ((x = cmkey(tnbugtab,4,"",
10065 "binary-me-means-u-too",xxstring)) < 0)
10067 if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
10068 if ((y = cmcfm()) < 0) return(y);
10083 tn_auth_krb5_des_bug = z;
10086 return(success = 1);
10088 #ifdef CK_ENVIRONMENT
10089 case CK_TN_XD: /* XDISPLOC */
10090 if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
10092 if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
10094 if ((z = cmcfm()) < 0)
10096 TELOPT_DEF_S_ME_MODE(TELOPT_XDISPLOC) = x;
10097 TELOPT_DEF_S_U_MODE(TELOPT_XDISPLOC) = y;
10098 TELOPT_DEF_C_ME_MODE(TELOPT_XDISPLOC) = x;
10099 TELOPT_DEF_C_U_MODE(TELOPT_XDISPLOC) = y;
10100 return(success = 1);
10103 char * msg = "value of telnet environment variable";
10104 extern int tn_env_flg;
10105 extern char tn_env_acct[], tn_env_disp[], tn_env_job[],
10106 tn_env_prnt[], tn_env_sys[];
10107 extern char * tn_loc;
10108 if ((x = cmkey(tnenvtab,ntnenv,"","",xxstring)) < 0)
10110 if (x == TN_ENV_UVAR) { /* User variables */
10114 extern char * tn_env_uservar[8][2];
10116 /* Get the user variable name */
10117 if ((x = cmfld("Name of Environment Variable","",&s,
10122 env = getenv(uvar);
10123 if (!env) env = "";
10125 if ((x = cmtxt("Value of Environment Variable",env,
10131 /* Now that we have the variable and perhaps a value */
10132 /* there are three possibilities: (1) new variable */
10133 /* and associated value; (2) variable already exists */
10134 /* but we have a new value; (3) variable already */
10135 /* exists but no new value therefore the user wants */
10136 /* to clear variable. */
10138 /* Try to find an existing variable */
10139 for (x = 0; x < 8; x++) {
10140 if (!ckstrcmp(tn_env_uservar[x][0],uvar,-1,0)) {
10142 free(tn_env_uservar[x][1]);
10143 tn_env_uservar[x][1] = uval;
10145 return(success = 1);
10147 free(tn_env_uservar[x][0]);
10148 tn_env_uservar[x][0] = NULL;
10149 free(tn_env_uservar[x][1]);
10150 tn_env_uservar[x][1] = NULL;
10152 return(success = 1);
10157 /* Couldn't find one; look for empty location to insert */
10158 for (x = 0; x < 8; x++) {
10159 if (!tn_env_uservar[x][0]) {
10160 tn_env_uservar[x][0] = uvar;
10161 tn_env_uservar[x][1] = uval;
10162 return(success = 1);
10165 printf("?Sorry, no space for variable.\n");
10166 return(success = 0);
10168 if (x == TN_ENV_OFF || x == TN_ENV_ON) {
10169 if ((y = cmcfm()) < 0) return(y);
10172 printf("?Sorry, command disabled.\r\n");
10173 return(success = 0);
10176 tn_env_flg = x == TN_ENV_OFF ? 0 : 1;
10177 return(success = 1);
10180 /* Not ON/OFF - Get the value */
10183 if ((y = cmtxt(msg, "", &s, xxstring)) < 0) {
10190 return(success = 0);
10192 if ((int)strlen(s) > 63) {
10193 printf("Sorry, too long\n");
10198 ckstrncpy(uidbuf,s,UIDBUFLEN);
10202 ckstrncpy(tn_env_acct,s,64);
10205 ckstrncpy(tn_env_disp,s,64);
10208 ckstrncpy(tn_env_job,s,64);
10211 ckstrncpy(tn_env_prnt,s,64);
10214 ckstrncpy(tn_env_sys,s,64);
10218 makestr(&tn_loc,s);
10221 printf("\n?Not yet implemented\n");
10224 return(success = 1);
10226 #endif /* CK_ENVIRONMENT */
10229 case CK_TN_LOC: { /* LOCATION */
10230 extern char * tn_loc;
10231 if ((y = cmtxt("Location string","",&s,xxstring)) < 0)
10234 makestr(&tn_loc,s);
10235 return(success = 1);
10237 #endif /* CK_SNDLOC */
10238 case CK_TN_SFU: /* Microsoft SFU compatibility */
10239 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10240 if ((y = cmcfm()) < 0) return(y);
10242 return(success = 1);
10245 case CK_TN_WAIT: /* WAIT-FOR-NEGOTIATIONS */
10246 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10247 if ((y = cmcfm()) < 0) return(y);
10254 #endif /* IKSDCONF */
10256 printf("?Sorry, command disabled.\r\n");
10257 return(success = 0);
10262 return(success = 1);
10264 case CK_TN_DL: /* DELAY SUBNEGOTIATIONS */
10265 if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
10266 if ((y = cmcfm()) < 0) return(y);
10273 #endif /* IKSDCONF */
10275 printf("?Sorry, command disabled.\r\n");
10276 return(success = 0);
10280 return(success = 1);
10282 case CK_TN_PUID: { /* PROMPT-FOR-USERID */
10284 if ((y = cmtxt("Prompt string","",&s,xxstring)) < 0)
10286 if (s == "") s = NULL;
10289 if (s == "") s = NULL;
10291 /* we must check to make sure there are no % fields */
10293 for (i = 0; i < len; i++) {
10295 if (s[i+1] != '%') {
10296 printf("%% fields are not used in this command.\n");
10302 makestr(&tn_pr_uid,s);
10303 return(success = 1);
10309 #endif /* TNCODE */
10313 case XYCOUN: /* SET COUNT */
10314 x = cmnum("Positive number","0",10,&z,xxstring);
10315 if (x < 0) return(x);
10316 if ((x = cmcfm()) < 0) return(x);
10318 printf("?A positive number, please\n");
10321 debug(F101,"XYCOUN: z","",z);
10322 return(success = setnum(&count[cmdlvl],z,0,10000));
10327 return(success = seton(&inpcas[cmdlvl]));
10330 case XYCMD: /* COMMAND ... */
10331 if ((y = cmkey(scmdtab,nbytt,"","",xxstring)) < 0)
10335 if ((y = cmcfm()) < 0)
10337 concb((char)escape);
10338 return(success = 1);
10341 if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x,
10344 if (x != 7 && x != 8) {
10345 printf("\n?The choices are 7 and 8\n");
10346 return(success = 0);
10348 if ((y = cmcfm()) < 0) return(y);
10349 if (x == 7) cmdmsk = 0177;
10350 else if (x == 8) cmdmsk = 0377;
10351 return(success = 1);
10354 if ((y = cmnum("maximum number of commands in recall buffer","10",
10355 10,&x,xxstring)) < 0)
10357 if ((y = cmcfm()) < 0) return(y);
10358 return(success = cmrini(x));
10359 #endif /* CK_RECALL */
10362 return(success = seton(&cm_retry));
10363 #endif /* CK_RECALL */
10364 case SCMD_MOR: /* More-prompting */
10365 success = seton(&xaskmore);
10367 saveask = xaskmore;
10370 if ((x = seton(&y)) < 0) return(x);
10371 cmdsquo(y); /* Do it the right way */
10372 cmd_quoting = y; /* Also keep a global copy */
10373 /* Set string-processing function */
10375 xxstring = y ? zzstring : (xx_strp) NULL;
10378 xxstring = y ? zzstring : (xx_strp) NULL;
10380 xxstring = y ? zzstring : (xx_strp) NULL;
10381 #endif /* CK_ANSIC */
10382 #endif /* datageneral */
10383 return(success = 1);
10387 case SCMD_COL: { /* Command-screen colors */
10389 fg = cmkey(ttyclrtab, nclrs,
10390 "foreground color and then background color",
10395 if ((bg = cmkey(ttyclrtab,nclrs,
10396 "background color","black",xxstring)) < 0)
10398 if ((y = cmcfm()) < 0)
10400 colorcmd = fg | bg << 4;
10401 return(success = 1);
10403 case SCMD_SCR: /* Command Scrollback size */
10404 if ((y = cmnum("COMMAND scrollback buffer size, lines","512",10,&x,
10407 /* The max number of lines is the RAM */
10408 /* we can actually dedicate to a */
10409 /* scrollback buffer given the maximum */
10410 /* process memory space of 512MB */
10411 if (x < 256 || x > 2000000L) {
10412 printf("\n?The size must be between 256 and 2,000,000.\n");
10413 return(success = 0);
10415 if ((y = cmcfm()) < 0) return(y);
10416 tt_scrsize[VCMD] = x;
10418 return(success = 1);
10421 if ((y = cmnum("Number of columns in display window",
10422 "80",10,&x,xxstring)) < 0)
10424 if ((y = cmcfm()) < 0) return(y);
10426 os2_setcmdwidth(x);
10427 return(success = 1);
10430 if ((y = cmnum("Number of rows in display window",
10431 "24",10,&x,xxstring)) < 0)
10433 if ((y = cmcfm()) < 0) return(y);
10434 os2_setcmdheight(x);
10435 return(success = 1);
10438 extern int marginbot;
10439 if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
10440 if ((x = cmcfm()) < 0) return(x);
10441 if (y != tt_status[VCMD]) {
10442 /* Might need to fixup the margins */
10443 tt_status[VCMD] = y;
10445 tt_szchng[VCMD] = 2;
10448 VscrnInit(VCMD); /* Height set here */
10451 tt_szchng[VCMD] = 1;
10454 VscrnInit(VCMD); /* Height set here */
10457 return(success = 1);
10464 ppos = VscrnGetCurPos(VCMD);
10468 itoa(ppos->y+1, tmpbuf, 10);
10469 if ((y = cmnum("row (1-based)",tmpbuf,10,&row,xxstring)) < 0)
10472 itoa(ppos->x+1, tmpbuf, 10);
10473 if ((y = cmnum("col (1-based)",tmpbuf,10,&col,xxstring)) < 0)
10475 if ((x = cmcfm()) < 0) return(x);
10477 lgotoxy( VCMD, col, row ) ;
10478 VscrnIsDirty( VCMD );
10481 #endif /* NOLOCAL */
10484 y = cmnum("Command screen width, characters","80",10,&x,xxstring);
10485 return(setnum(&cmd_cols,x,y,1024));
10488 y = cmnum("Command screen height, rows","24",10,&x,xxstring);
10489 return(setnum(&cmd_rows,x,y,1024));
10493 return(seton(&cmdint));
10497 return(seton(&cmdadl));
10498 #endif /* CK_AUTODL */
10500 #ifdef DOUBLEQUOTING
10503 return(seton(&dblquo));
10505 #endif /* DOUBLEQUOTING */
10514 case XYDFLT: /* SET DEFAULT = CD */
10515 return(success = docd(XXCWD));
10517 case XYDEBU: /* SET DEBUG { on, off, session } */
10518 if ((y = cmkey(dbgtab,ndbg,"","",xxstring)) < 0)
10522 return(seton(&debtim) < 0 ? x : (success = 1));
10524 /* why this change? */
10525 return(success = seton(&debtim));
10526 #endif /* COMMENT */
10529 if (inserver && isguest) {
10530 printf("?Sorry, command disabled.\r\n");
10531 return(success = 0);
10537 y = cmnum("Max length for debug log strings","",10,&x,xxstring);
10538 if ((z = setnum(&debxlen,x,y,-1)) < 0)
10540 if ((x = cmcfm()) < 0)
10542 return(success = 1);
10545 if ((x = cmcfm()) < 0)
10549 #endif /* NOLOCAL */
10551 if (deblog) doclslog(LOGD);
10553 return(success = 1);
10556 if ((x = cmcfm()) < 0)
10559 deblog = debopn("debug.log", 0);
10560 return(success = deblog ? 1 : 0);
10562 printf("?Sorry, debug log feature not enabled\n");
10563 return(success = 0);
10566 if ((x = cmcfm()) < 0)
10570 #endif /* NOLOCAL */
10571 return(success = 1);
10576 case XYDELA: /* SET DELAY */
10577 y = cmnum("Number of seconds before starting to send",
10578 "5",10,&x,xxstring);
10580 return(success = setnum(&ckdelay,x,y,999));
10581 #endif /* NOXFER */
10591 #endif /* CK_TAPI */
10593 case XYDIAL: /* SET MODEM or SET DIAL */
10594 return(setdial(-1));
10596 return(setmodem());
10598 /* not implemented yet */
10599 case XYANSWER: /* SET ANSWER */
10600 return(setanswer());
10601 #endif /* COMMENT */
10602 #endif /* NODIAL */
10605 case XYDUPL: /* SET DUPLEX */
10606 if ((y = cmkey(dpxtab,2,"","full",xxstring)) < 0) return(y);
10607 if ((x = cmcfm()) < 0) return(x);
10609 return(success = 1);
10611 case XYLCLE: /* LOCAL-ECHO (= DUPLEX) */
10612 return(success = seton(&duplex));
10614 case XYESC: /* SET ESCAPE */
10615 return(success = setcc(ckitoa(DFESC),&escape));
10616 #endif /* NOLOCAL */
10618 case XYEXIT: /* SET EXIT */
10619 if ((z = cmkey(xittab,nexit,"","",xxstring)) < 0)
10622 case 0: /* STATUS */
10623 y = cmnum("EXIT status code","",10,&x,xxstring);
10624 return(success = setnum(&xitsta,x,y,-1));
10625 case 1: /* WARNING */
10626 if ((z = cmkey(xitwtab,nexitw,"","",xxstring)) < 0)
10628 if ((y = cmcfm()) < 0) return(y);
10630 return(success = 1);
10632 success = seton(&exitonclose);
10634 if (success) tn_exit = exitonclose;
10635 #endif /* TCPSOCKET */
10638 extern int exithangup;
10639 return((success = seton(&exithangup)));
10643 } /* End of SET EXIT switch() */
10650 case XYFILE: /* SET FILE */
10651 return(setfil(rmsflg));
10653 case XYFLOW: { /* FLOW-CONTROL */
10654 extern int cxflow[];
10660 if (network && istncomport())
10662 #endif /* TN_COMPORT */
10665 m = "Flow control type, one of the following:\n\
10666 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10667 or connection type";
10669 /* All this is because chained FDB's don't give chained help yet */
10673 "Flow control type, one of the following:\n\
10674 keep none rts/cts\n\
10675 or connection type",
10677 "Flow control type, one of the following:\n\
10679 or connection type";
10680 #endif /* CK_RTSCTS */
10685 "Flow control type, one of the following:\n\
10686 dtr/cd dtr/cts keep none rts/cts xon/xoff\n\
10687 or connection type";
10688 #else /* CK_DTRCTS */
10689 "Flow control type, one of the following:\n\
10690 dtr/cd keep none rts/cts xon/xoff\n\
10691 or connection type";
10692 #endif /* CK_DTRCTS */
10693 #else /* CK_DTRCD */
10695 "Flow control type, one of the following:\n\
10696 dtr/cts keep none rts/cts xon/xoff\n\
10697 or connection type";
10698 #else /* CK_DTRCTS */
10699 "Flow control type, one of the following:\n\
10700 keep none rts/cts xon/xoff\n\
10701 or connection type";
10702 #endif /* CK_DTRCTS */
10703 #endif /* CK_DTRCD */
10705 "Flow control type, one of the following:\n\
10706 keep none xon/xoff\n\
10707 or connection type";
10708 #endif /* CK_RTSCTS */
10711 cmfdbi(&k1,_CMKEY,m,"","",ncxtypesw, 4, xxstring, cxtypesw, &k2);
10718 (tncomport ? ntnflo : nflo),
10721 #endif /* TN_COMPORT */
10725 (tncomport ? tnflotab : flotab),
10728 #endif /* TN_COMPORT */
10732 if (x < 0) { /* Error */
10733 if (x == -2 || x == -9)
10734 printf("?No keywords or switches match: \"%s\"\n",atmbuf);
10737 z = cmresult.nresult; /* Keyword value */
10738 if (cmresult.fdbaddr == &k2) { /* Flow-control type keyword table */
10739 if ((x = cmcfm()) < 0) /* Set it immediately */
10742 debug(F101,"set flow","",flow);
10744 if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
10745 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
10746 #endif /* CK_SPEED */
10747 autoflow = (flow == FLO_AUTO);
10748 return(success = 1); /* Done */
10750 debug(F101,"set flow /blah 1","",z); /* SET FLOW /for-what */
10751 if ((y = cmkey(flotab,nflo,"Flow control type","none",xxstring)) < 0)
10753 if ((x = cmcfm()) < 0)
10755 debug(F101,"set flow /blah 2","",y);
10756 if (y == FLO_AUTO) {
10758 "?Sorry, \"automatic\" can not be assigned to a connection type.\n");
10760 } else if (z >= 0 && z <= CXT_MAX)
10762 debug(F101,"set flow","",flow);
10763 debug(F101,"set flow autoflow","",autoflow);
10764 return(success = 1);
10767 case XYHAND: /* HANDSHAKE */
10768 if ((y = cmkey(hshtab,nhsh,"","none",xxstring)) < 0) return(y);
10770 if ((x = cmnum("ASCII value","",10,&y,xxstring)) < 0)
10772 if ((y < 1) || ((y > 31) && (y != 127))) {
10773 printf("?Character must be in ASCII control range\n");
10777 if ((x = cmcfm()) < 0) return(x);
10778 turn = (y > 0127) ? 0 : 1;
10780 return(success = 1);
10783 case XYMACR: /* SET MACRO */
10784 if ((y = cmkey(smactab,2,"","",xxstring)) < 0) return(y);
10786 case 0: return(success = seton(&mecho));
10787 case 1: return(success = seton(&merror[cmdlvl]));
10788 default: return(-2);
10794 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
10795 if ((y = cmcfm()) < 0) return(y);
10797 printf("Sorry, SET MESSAGES not implemented yet\n");
10798 return(success = 0);
10806 case XYPARI: /* PARITY */
10807 if ((y = cmkey(partbl,npar,"","none",xxstring)) < 0)
10810 /* If parity not none, then we also want 8th-bit prefixing */
10813 if (y == 'H') { /* Hardware */
10814 if ((x = cmkey(hwpartbl,nhwpar,"","even",xxstring)) < 0)
10817 #endif /* HWPARITY */
10819 if ((z = cmcfm()) < 0)
10823 if (y == 'H') { /* 8 data bits plus hardware parity */
10827 #endif /* NOXFER */
10829 } else { /* 7 data bits + software parity */
10831 #endif /* HWPARITY */
10834 ebqflg = (parity) ? 1 : 0;
10835 #endif /* NOXFER */
10838 #endif /* HWPARITY */
10841 if (network && istncomport())
10842 tnsettings(parity, 0);
10843 #endif /* TN_COMPORT */
10845 return(success = 1);
10848 case XYPROM: /* SET PROMPT */
10850 Note: xxstring not invoked here. Instead, it is invoked every time the
10851 prompt is issued. This allows the prompt string to contain variables
10852 that can change, like \v(dir), \v(time), etc.
10854 ckmakmsg(line, /* Default might have trailing space */
10857 inserver ? ikprompt : ckprompt,
10861 if ((x = cmtxt("Program's command prompt",line,&s,NULL)) < 0)
10863 s = brstrip(s); /* Remove enclosing braces, if any */
10864 cmsetp(s); /* Set the prompt */
10865 return(success = 1);
10866 #endif /* NOFRILLS */
10869 case XYRETR: /* RETRY: per-packet retry limit */
10870 y = cmnum("Maximum retries per packet","10",10,&x,xxstring);
10872 if ((x = setnum(&maxtry,x,y,999)) < 0) return(x);
10874 if (maxtry <= wslotr) {
10875 printf("?Retry limit must be greater than window size\n");
10876 return(success = 0);
10878 #endif /* COMMENT */
10880 sstate = setgen('S', "403", ckitoa(maxtry), "");
10881 return((int) sstate);
10882 } else return(success = x);
10883 #endif /* NOXFER */
10886 case XYSERV: /* SET SERVER items */
10887 if ((y = cmkey(srvtab,nsrvt,"","",xxstring)) < 0) return(y);
10890 if ((y = cmnum("Number of seconds, or 0 for no idle timeout",
10891 "0",10,&x,xxstring)) < 0)
10895 if ((y = cmcfm()) < 0)
10901 return(success = 1);
10903 if ((y = cmnum("Interval for server NAKs, 0 = none",
10905 10,&x, xxstring)) < 0)
10909 "\n?Specify a positive number, or 0 for no server NAKs\n");
10912 if ((y = cmcfm()) < 0) return(y);
10914 sstate = setgen('S', "404", ckitoa(x), "");
10915 return((int) sstate);
10920 srvtim = x; /* Set the server timeout variable */
10921 return(success = 1);
10923 case XYSERD: /* SERVER DISPLAY */
10924 return(success = seton(&srvdis)); /* ON or OFF... */
10927 case XYSERP: /* SERVER GET-PATH */
10928 return(parsdir(2));
10931 case XYSERL: /* SERVER LOGIN */
10934 case XYSERC: /* SERVER CD-MESSAGE */
10936 cmkey(onoff,2,"","",xxstring) :
10937 cmkey(cdmsg,3,"","",xxstring);
10940 if (x == 2) { /* CD-MESSAGE FILE */
10941 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
10947 makestr(&cdmsgstr,s);
10948 makelist(cdmsgstr,cdmsgfile,8);
10949 return(success = 1);
10951 if ((y = cmcfm()) < 0) /* CD-MESSAGE ON/OFF */
10954 sstate = setgen('S', "420", x ? "1" : "0", "");
10955 return((int) sstate);
10961 return(success = 1);
10963 case XYSERK: /* SERVER KEEPALIVE */
10964 return(success = seton(&srvping)); /* ON or OFF... */
10969 #endif /* NOSERVER */
10975 case XYSUSP: /* SET SUSPEND */
10976 seton(&xsuspend); /* on or off... */
10977 return(success = 1);
10981 case XYTAKE: /* SET TAKE */
10982 if ((y = cmkey(taktab,4,"","",xxstring)) < 0) return(y);
10984 case 0: return(success = seton(&techo));
10986 case 1: return(success = seton(&takerr[cmdlvl]));
10988 case 1: return(success = seton(&takerr[tlevel]));
10990 case 2: techo = 0; return(success = 1); /* For compatibility with */
10991 case 3: techo = 1; return(success = 1); /* MS-DOS Kermit */
10992 default: return(-2);
10996 case XYSCRI: /* SET SCRIPT */
10997 if ((y = cmkey(scrtab,1,"","echo",xxstring)) < 0) return(y);
10999 case 0: return(success = seton(&secho));
11000 default: return(-2);
11002 #endif /* NOSCRIPT */
11010 case XYTERM: /* SET TERMINAL */
11012 success = (x > 0) ? 1 : 0;
11016 case XYWIN95: /* SET WIN95 workarounds */
11018 success = (x > 0 ? 1 : 0);
11023 case XYDLR: /* SET DIALER workarounds */
11025 success = (x > 0 ? 1 : 0);
11028 case XYTITLE: /* SET TITLE of window */
11030 success = (x > 0 ? 1 : 0);
11035 case XYMOUSE: /* SET MOUSE */
11036 return(success = setmou());
11037 #endif /* OS2MOUSE */
11039 case XYBELL: /* SET BELL */
11040 return(success = setbell());
11044 return(success = setprty() );
11050 #endif /* NOLOCAL */
11054 /* SET SEND/RECEIVE protocol parameters. */
11059 return(setsr(xx,rmsflg));
11060 #endif /* NOXFER */
11063 case XYSESS: /* SESSION-LOG */
11064 if ((x = cmkey(sfttab,nsfttab,"type of file",
11074 if ((y = cmcfm()) < 0)
11076 if (x == 999) { /* TIMESTAMPED-TEXT */
11077 sessft = XYFT_T; /* Implies text */
11078 slogts = 1; /* and timestamps */
11079 } else { /* A regular type */
11080 sessft = x; /* The type */
11081 slogts = 0; /* No timestampes */
11083 return(success = 1);
11085 case XYSPEE: /* SET SPEED */
11087 if (local && !network) {
11090 "Transmission rate for ",
11092 " (bits per second)",
11097 "Serial-port speed (bits per second)",
11104 if (network && istncomport())
11105 x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
11107 #endif /* TN_COMPORT */
11108 x = cmkey(spdtab,nspd,line,"",xxstring);
11110 if (x == -3) printf("?value required\n");
11111 #ifdef USETCSETSPEED
11112 /* In this case, any number can be tried */
11113 /* There's a parse error message but the request still goes thru */
11114 if (rdigits(atmbuf))
11117 #endif /* USETCSETSPEED */
11120 if ((y = cmcfm()) < 0) return(y);
11123 printf("?Sorry, command disabled.\r\n");
11124 return(success = 0);
11128 printf("?SET SPEED has no effect without prior SET LINE\n");
11129 return(success = 0);
11133 #endif /* TN_COMPORT */
11135 printf("\n?Speed cannot be set for network connections\n");
11136 return(success = 0);
11140 Note: This way of handling speeds is not 16-bit safe for speeds greater
11141 than 230400. The argument to ttsspd() should have been a long.
11143 #ifdef USETCSETSPEED
11146 #endif /* USETCSETSPEED */
11147 zz = (long) x * 10L;
11148 if (zz == 130L) zz = 134L;
11149 if (zz == 70L) zz = 75L; /* (see spdtab[] definition) */
11150 if (ttsspd(x) < 0) { /* Call ttsspd with cps, not bps! */
11151 printf("?Unsupported line speed - %ld\n",zz);
11152 return(success = 0);
11155 if (!tttapi || tapipass)
11156 speed = ttgspd(); /* Read it back */
11159 #else /* CK_TAPI */
11160 speed = ttgspd(); /* Read it back */
11161 #endif /* CK_TAPI */
11162 if (speed != zz) { /* Call ttsspd with cps, not bps! */
11163 printf("?SET SPEED fails, speed is %ld\n",speed);
11164 return(success = 0);
11166 if (pflag && !xcmdsrc) {
11168 printf("%s, 75/1200 bps\n",ttname);
11169 else if (speed == 134)
11170 printf("%s, 134.5 bps\n",ttname);
11172 printf("%s, %ld bps\n",ttname,speed);
11174 return(success = 1);
11176 #endif /* NOLOCAL */
11179 case XYXFER: /* SET TRANSFER */
11180 if ((y = cmkey(rmsflg ? rtstab : tstab, /* (or REMOTE SET TRANSFER) */
11181 rmsflg ? nrts : nts,
11182 "","character-set",xxstring)) < 0) return(y);
11185 case XYX_CAN: /* CANCELLATION */
11186 if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
11187 if (z == 0) { /* OFF */
11188 if ((y = cmcfm()) < 0) return(y);
11191 if ((y = cmnum("ASCII code for cancellation character",
11195 if (x > 31 && x != 127) {
11196 printf("Cancel character must be 0-31 or 127\n");
11199 if ((y = cmnum("How many required to cause cancellation",
11200 "2",10,&z, xxstring)) < 0)
11203 printf("Number must be 2 or greater\n");
11206 if ((y = cmcfm()) < 0) return(y);
11207 xfrcan = 1; /* CANCELLATION ON */
11208 xfrchr = x; /* Using this character */
11209 xfrnum = z; /* Needing this many of them */
11211 return(success = 1);
11212 #endif /* XFRCAN */
11215 case XYX_CSE: /* CHARACTER-SET */
11216 if ((y = cmkey(tcstab,ntcs,"","transparent",xxstring)) < 0)
11218 if ((x = cmcfm()) < 0) return(x);
11220 sstate = setgen('S', "405", tcsinfo[y].designator, "");
11221 return((int) sstate);
11223 extern int s_cset, fcharset, axcset[], tcs_save;
11224 tslevel = (y == TC_TRANSP) ? 0 : 1; /* transfer syntax level */
11226 tcharset = y; /* transfer character set */
11227 /* SEND CHARACTER-SET AUTO */
11228 if (tslevel > 0 && s_cset == XMODE_A)
11229 if (y > -1 && y <= MAXTCSETS)
11230 if (axcset[y] > -1 && axcset[y] > MAXFCSETS)
11231 fcharset = axcset[y]; /* Auto-pick file charset */
11232 setxlatype(tcharset,fcharset); /* Translation type */
11234 return(success = 1);
11236 #endif /* NOCSETS */
11238 case XYX_LSH: /* LOCKING-SHIFT */
11239 if ((y = cmkey(lstab,nls,"","on",xxstring)) < 0)
11241 if ((x = cmcfm()) < 0) return(x);
11242 lscapr = (y == 1) ? 1 : 0; /* ON: requested = 1 */
11243 lscapu = (y == 2) ? 2 : 0; /* FORCED: used = 1 */
11244 return(success = 1);
11247 case XYX_PRO: /* Protocol */
11250 printf("?Sorry, only Kermit protocol is available\n");
11254 return(setproto());
11255 #endif /* CK_XYZ */
11257 case XYX_MOD: /* Mode */
11258 if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
11260 if ((x = cmcfm()) < 0) return(x);
11262 sstate = setgen('S', "410", y == XMODE_A ? "0" : "1", "");
11263 return((int)sstate);
11267 return(success = 1);
11270 case XYX_DIS: /* Display */
11271 return(doxdis(1)); /* 1 == Kermit */
11272 #endif /* NOLOCAL */
11274 case XYX_SLO: /* Slow-start */
11275 return(seton(&slostart));
11278 case XYX_CRC: /* CRC */
11279 return(seton(&docrc));
11282 case XYX_BEL: /* Bell */
11283 return(seton(&xfrbel));
11286 case XYX_PIP: /* Pipes */
11289 #endif /* NOPUSH */
11290 printf("Sorry, access to pipes is disabled\n");
11294 #endif /* NOPUSH */
11295 return(seton(&usepipes));
11296 #endif /* PIPESEND */
11298 case XYX_INT: /* Interruption */
11299 return(seton(&xfrint));
11302 return(seton(&xfrxla)); /* Translation */
11305 extern char * xfrmsg;
11306 if ((x = cmtxt("Prompt string","",&s,xxstring)) < 0)
11309 makestr(&xfrmsg,s);
11310 return(success = 1);
11314 extern int whereflg;
11315 return(seton(&whereflg));
11320 #endif /* NOXFER */
11326 case XYXMIT: /* SET TRANSMIT */
11328 #endif /* NOXMIT */
11332 case XYUNCS: /* UNKNOWN-CHARACTER-SET */
11333 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
11334 if ((x = cmcfm()) < 0) return(x);
11336 return(success = 1);
11337 #endif /* NOCSETS */
11338 #endif /* NOXFER */
11342 case XYWILD: /* WILDCARD-EXPANSION */
11343 if ((y = cmkey(wildtab,2,
11344 "Who expands wildcards","kermit",xxstring)) < 0)
11346 if ((z = cmkey(wdottab,
11348 "whether to match filenames that start with \".\"",
11349 "/no-match-dot-files",
11353 if ((x = cmcfm()) < 0) return(x);
11356 printf("Shell expansion is disabled\n");
11357 return(success = 0);
11362 return(success = 1);
11364 #endif /* NOPUSH */
11367 case XYWIND: /* WINDOW-SLOTS */
11368 if (protocol == PROTO_K) {
11369 y = cmnum("Window size for Kermit protocol, 1 to 32",
11370 "1", 10, &x, xxstring);
11371 y = setnum(&z,x,y,MAXWS); /* == 32 */
11374 else if (protocol == PROTO_Z) {
11375 y = cmnum("Window size for ZMODEM protocol, 0 to 65535",
11376 "0", 10, &x, xxstring);
11377 y = setnum(&z,x,y,65535);
11379 #endif /* CK_XYZ */
11381 y = cmnum("Window size for current protocol",
11382 "", 10, &x, xxstring);
11383 y = setnum(&z,x,y,65472); /* Doesn't matter - we won't use it */
11385 if (y < 0) return(y);
11386 if (protocol == PROTO_K) {
11391 else if (protocol == PROTO_Z) {
11392 /* Zmodem windowing is closer to Kermit packet length */
11393 /* than Kermit window size. If Window size is zero */
11394 /* an end of frame and CRC is sent only at the end of */
11395 /* the file (default). Otherwise, an End of Frame */
11396 /* and CRC are sent after Window Size number of bytes */
11397 if (z < 0) /* Disable windowing */
11400 printf("?SET WINDOW does not apply to %s protocol\n",
11401 ptab[protocol].p_name
11404 #endif /* CK_XYZ */
11407 /* This is taken care of automatically now in protocol negotiation */
11409 printf("?Window slots must be less than retry limit\n");
11410 return(success = 0);
11412 #endif /* COMMENT */
11413 if (protocol == PROTO_K && rmsflg) { /* Set remote window size */
11414 wslotr = z; /* Set local window size too */
11415 ptab[protocol].winsize = wslotr;
11416 sstate = setgen('S', "406", ckitoa(z), "");
11417 return((int) sstate);
11419 wslotr = z; /* Set requested window size here */
11420 ptab[protocol].winsize = wslotr; /* and in protocol-specific table */
11421 if (protocol == PROTO_K) { /* And for Kermit only... */
11422 swcapr = (wslotr > 1) ? 1 : 0; /* set window bit in capas word */
11423 if (wslotr > 1) { /* Window size > 1? */
11424 /* Maybe adjust packet size */
11425 y = adjpkl(urpsiz,wslotr,bigrbsiz);
11426 if (y != urpsiz) { /* Did it change? */
11430 " Adjusting receive packet-length to %d for %d window slots\n",
11437 return(success = 1);
11438 #endif /* NOXFER */
11444 case XYOUTP: /* OUTPUT command parameters */
11445 if ((y = cmkey(outptab,noutptab,"OUTPUT command parameter","pacing",
11448 switch(y) { /* Which parameter */
11449 case OUT_PAC: /* PACING */
11450 y = cmnum("Milliseconds to pause between each OUTPUT character",
11451 "100", 10,&x,xxstring);
11452 y = setnum(&z,x,y,16383); /* Verify and get confirmation */
11453 if (y < 0) return(y);
11454 if (z < 0) z = 0; /* (save some space) */
11456 return(success = 1);
11457 case OUT_ESC: /* Special-escapes */
11458 return(seton(&outesc));
11459 default: /* (shouldn't happen) */
11468 if ((z = cmkey(ctltab,2, "control-character prefixing option",""
11471 /* Make space for a temporary copy of the prefixing table */
11473 p = (short *)malloc(256 * sizeof(short));
11475 printf("?Internal error - malloc failure\n");
11478 for (i = 0; i < 256; i++) p[i] = ctlp[i]; /* Copy current table */
11481 case 0: /* UNPREFIXED control character */
11482 case 1: /* PREFIXED control character */
11483 while (1) { /* Collect a list of numbers */
11485 x_ifnum = 1; /* Turn off complaints from eval() */
11487 if ((x = cmnum((z == 0) ?
11488 "\n Numeric ASCII value of control character that needs NO prefix,\n\
11489 or the word \"all\", or carriage return to complete the list" :
11490 "\n Numeric ASCII value of control character that MUST BE prefixed,\n\
11491 or the word \"all\", or carriage return to complete the list",
11498 if ((x = cmcfm()) < 0) return(x);
11502 if (p) { free((char *)p); p = NULL; }
11503 debug(F110,"SET CONTROL atmbuf",atmbuf,0);
11504 if (!ckstrcmp(atmbuf,"all",3,0) || /* "ALL" */
11505 !ckstrcmp(atmbuf,"al",2,0) ||
11506 !ckstrcmp(atmbuf,"a",1,0)) {
11507 if ((x = cmcfm()) < 0) /* Get confirmation */
11509 prefixing = z ? PX_ALL : PX_NON;
11510 setprefix(prefixing);
11511 return(success = 1);
11512 } else { /* Not number, not ALL */
11514 "?Please specify a number or the word ALL\n");
11518 if (p) free((char *)p);
11525 #ifdef UNPREFIXZERO
11531 zz = 0; /* Allow 0 (but only for Zmodem) */
11533 #endif /* UNPREFIXZERO */
11535 /* printf("x = %d, y = %d, z = %d, zz = %d\n", x,y,z,zz); */
11537 if ((y > 31 && y < 127) || /* A specific numeric value */
11538 (y > 159 && y < 255) || /* Check that it is a valid */
11539 (y < zz) || /* control code. */
11541 printf("?Values allowed are: %d-31, 127-159, 255\n",zz);
11542 if (p) free((char *)p);
11545 x = y & 127; /* Get 7-bit value */
11546 if (z == 0) { /* If they are saying it is safe... */
11547 /* If flow control is Xon/Xoff */
11548 if (((flow == FLO_XONX) &&
11549 /* XON & XOFF chars not safe. */
11550 (x == XON || x == XOFF))
11554 "Sorry, not while Xon/Xoff is in effect.\n");
11555 if (p) free((char *)p);
11559 else if (network && IS_TELNET()
11561 (unsigned) y == (unsigned) 255)) {
11563 printf("Sorry, not on a TELNET connection.\n");
11564 if (p) free((char *)p);
11567 #endif /* TNCODE */
11569 p[y] = (char) z; /* All OK, set flag */
11570 } /* End of while loop */
11572 Get here only if they have made no mistakes. Copy temporary table back to
11573 permanent one, then free temporary table and return successfully.
11575 for (i = 0; i < 256; i++) ctlp[i] = p[i];
11576 if (p) free((char *)p);
11577 if (z > 0) clearrq = 0; /* 199 (see SET PREFIXING) */
11578 return(success = 1);
11583 #endif /* CK_SPEED */
11590 if ((y = cmkey(rpttab,2,
11591 "repeat-count compression parameter","",xxstring)) < 0)
11595 return(success = seton(&rptena)); /* REPEAT COUNTS = ON, OFF */
11596 case 1: /* REPEAT MININUM number */
11597 printf("(not implemented yet, nothing happens)\n");
11599 case 2: /* REPEAT PREFIX char */
11600 if ((x = cmnum("ASCII value","",10,&z,xxstring)) < 0)
11602 if ((x = cmcfm()) < 0) return(x);
11603 if ((z > 32 && z < 63) || (z > 95 && z < 127)) {
11604 if (y == 1) rptmin = (CHAR) z; else myrptq = (CHAR) z;
11605 return(success = 1);
11607 printf("?Illegal value for prefix character\n");
11611 #endif /* NOXFER */
11620 x_ifnum = 1; /* Turn off internal complaints */
11621 y = cmnum("Seconds from now, or time of day as hh:mm:ss",
11622 "0" ,10, &x, xxstring);
11625 if (y == -2) { /* Invalid number or expression */
11626 zz = tod2sec(atmbuf); /* Convert to secs since midnight */
11628 printf("?Number, expression, or time of day required\n");
11631 char now[32]; /* Current time */
11636 tnow = atol(p+11) * 3600L +
11637 atol(p+14) * 60L + atol(p+17);
11638 if (zz < tnow) /* User's time before now */
11639 zz += 86400L; /* So make it tomorrow */
11640 zz -= tnow; /* Seconds from now. */
11646 printf("?Alarm time is in the past.\n");
11649 if ((y = cmcfm()) < 0) return(y);
11650 if (zz > -1L) { /* Time of day given? */
11652 if (zz != (long) x) {
11654 "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
11659 return(setalarm((long)x));
11663 This is to allow long values where int and long are not the same, e.g.
11664 on 16-bit systems. But something is wrong with it.
11666 if ((y = cmtxt("seconds from now", "0", &s, xxstring)) < 0)
11669 return(setalarm(atol(s)));
11671 printf("%s - not a number\n",s);
11674 #endif /* COMMENT */
11679 return(setproto());
11680 #endif /* NOXFER */
11683 C-Kermit unprefixes control characters automatically on network connections
11684 if CLEAR-CHANNEL is ON, which it is by default. But not all network
11685 connections are transparent to all control characters. For example, the
11686 DEC-20, even when you TELNET to it, is sensitive to Ctrl-O and Ctrl-T.
11687 If you tell C-Kermit to SET CONTROL PREFIX 15 and/or 20, it doesn't help
11688 because CLEAR-CHANNEL is still in effect. If the user goes to the trouble
11689 to set up some prefixing, then Kermit should do what the user said. In
11690 C-Kermit 7.1 Alpha.03 we change the code to set clearrq to 0 if the user
11691 gives a SET PREFIXING or SET CONTROL PREFIX command.
11697 extern int clearrq;
11698 #endif /* COMMENT */
11699 if ((z = cmkey(pfxtab, 4, "control-character prefixing option",
11700 "", xxstring)) < 0)
11702 if ((x = cmcfm()) < 0) return(x);
11703 clearrq = 0; /* 199 */
11706 if (hints && (z == PX_ALL || z == PX_CAU) && clearrq) {
11707 printf("Hint: Use SET CLEAR-CHANNEL OFF to disable negotiation of\n");
11708 printf(" SET PREFIXING NONE during file transfers on reliable\n");
11709 printf(" connections.\n");
11711 #endif /* COMMENT */
11712 return(success = 1);
11714 #endif /* CK_SPEED */
11718 if ((z = cmkey(logintab, 3, "value for login script","userid",
11724 if ((y = cmtxt("text","", &s, NULL)) < 0) {
11731 return(success = 0);
11734 if ((int)strlen(s) > 63) {
11735 printf("Sorry, too long\n");
11740 ckstrncpy(uidbuf,s,UIDBUFLEN);
11744 ckstrncpy(pwbuf,s,PWBUFL);
11755 ckstrncpy(prmbuf,s,PWBUFL);
11757 return(success = 1);
11764 if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
11765 if ((x = cmcfm()) < 0) return(x);
11766 DeleteStartupFile = (y != 0) ? 0 : 1;
11767 return(success = 1);
11770 x = cmdir("Name of temporary directory","",&s,xxstring);
11775 if ((x = cmcfm()) < 0) return(x);
11776 makestr(&tempdir,s);
11777 return(tempdir ? 1 : 0);
11780 case XYDEST: /* DESTINATION */
11782 #endif /* NOXFER */
11787 /* Editor, Browser, and FTP Client */
11789 case XYEDIT: /* EDITOR */
11792 printf("?Sorry, command disabled.\r\n");
11793 return(success = 0);
11797 /* Don't let this be set remotely */
11798 if (apcactive == APC_LOCAL ||
11799 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
11800 return(success = 0);
11801 #endif /* CK_APC */
11805 char *p = getenv("PATH");
11807 e = editor[0] ? (char *) editor : getenv("EDITOR");
11810 x = cmifip("Name of preferred editor",e,&s,&y,0,p,xxstring);
11812 x = cmifi("Full path of preferred editor",e,&s,&y,xxstring);
11813 if (x < 0 && x != -3)
11818 if ((y = cmtxt("DCL command for editing", "edit", &s, NULL)) < 0) {
11823 if ((x = cmifi("Full path of preferred editor","",&s,&y,xxstring))<0) {
11828 #endif /* OS2ORUNIX */
11830 ckstrncpy(editor,s,CKMAXPATH);
11834 printf("?A single file please\n");
11837 ckstrncpy(line,s,LINBUFSIZ);
11838 if ((x = cmtxt("editor command-line options","",&s,NULL)) < 0)
11840 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
11841 if ((z = cmcfm()) < 0) return(z);
11843 zfnqfp(line,CKMAXPATH,editor);
11844 ckstrncpy(editopts,tmpbuf,128);
11850 return(success = 1);
11856 return(dosetftp()); /* SET FTP */
11857 #endif /* TCPSOCKET */
11858 #endif /* SYSFTP */
11864 case XYFTP: /* SET FTP-CLIENT */
11865 #endif /* SYSFTP */
11867 case XYBROWSE: /* SET BROWSER */
11869 char *p = getenv("PATH");
11870 char *app = (char *) browser, *opts = (char *) browsopts;
11873 extern char ftpapp[], ftpopts[];
11875 app = (char *)ftpapp;
11876 opts = (char *)ftpopts;
11878 #endif /* SYSFTP */
11882 printf("?Sorry, command disabled.\r\n");
11883 return(success = 0);
11887 /* Don't let this be set remotely */
11888 if (apcactive == APC_LOCAL ||
11889 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
11890 return(success = 0);
11891 #endif /* CK_APC */
11894 x = cmifip(xx == XYBROWSE ?
11895 "Name of preferred browser" :
11896 "Name of preferred ftp client",
11898 xx == XYFTP ? "ftp.exe" : ""
11900 xx == XYFTP ? "ftp" : ""
11902 ,&s,&y,0,p,xxstring
11905 x = cmifi(xx == XYBROWSE ?
11906 "Full path of preferred browser" :
11907 "Full path of preferred ftp client",
11910 if (x < 0 && x != -3)
11914 if ((x = cmtxt("DCL command to start your preferred Web browser",
11915 "", &s, NULL)) < 0) {
11920 if ((x = cmifi("Full path of preferred browser","",&s,&y,xxstring)
11926 #endif /* OS2ORUNIX */
11928 ckstrncpy(app,s,CKMAXPATH);
11932 printf("?A single file please\n");
11935 ckstrncpy(line,s,LINBUFSIZ);
11936 if ((x = cmtxt(xx == XYBROWSE ?
11937 "browser command-line options" :
11938 "ftp client command-line options",
11942 ckstrncpy(tmpbuf,s,TMPBUFSIZ);
11943 if ((z = cmcfm()) < 0) return(z);
11945 zfnqfp(line,CKMAXPATH,app);
11946 ckstrncpy(opts, tmpbuf, 128);
11952 return(success = 1);
11954 #endif /* BROWSER */
11955 #endif /* NOFRILLS */
11956 #endif /* NOPUSH */
11959 case XYEOF: { /* SET EOF */
11960 extern int eofmethod; extern struct keytab eoftab[];
11961 if ((x = cmkey(eoftab,3,"end-of-file detection method","",
11964 if ((y = cmcfm()) < 0)
11967 return(success = 1);
11969 #endif /* CK_CTRLZ */
11972 case XYLIMIT: { /* Session-Limit (length of session in seconds) */
11973 extern int seslimit;
11975 extern int downloaded;
11977 y = cmnum("Maximum length of session, seconds","0",10,&x,xxstring);
11983 #endif /* IKSDCONF */
11988 if ((z = cmcfm()) < 0)
11990 printf("?Sorry, command disabled.\r\n");
11991 return(success = 0);
11993 return(setnum(&seslimit,x,y,86400));
11995 #endif /* SESLIMIT */
11997 case XYRELY: { /* SET RELIABLE */
11998 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12000 if ((y = cmcfm()) < 0) return(y);
12002 setreliable = (x != SET_AUTO);
12003 debug(F101,"SET RELIABLE reliable","",reliable);
12004 return(success = 1);
12008 case XYSTREAM: { /* SET STREAMING */
12009 extern int streamrq;
12010 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12012 if ((y = cmcfm()) < 0) return(y);
12014 return(success = 1);
12016 #endif /* STREAMING */
12020 if ((x = cmkey(syslogtab,nsyslog,"","",xxstring)) < 0)
12022 if ((y = cmcfm()) < 0) return(y);
12029 #endif /* IKSDCONF */
12031 printf("?Sorry, command disabled.\n");
12032 return(success = 0);
12036 /* Don't let this be set remotely */
12037 if (apcactive == APC_LOCAL ||
12038 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12039 return(success = 0);
12040 #endif /* CK_APC */
12042 return(success = 1);
12044 #endif /* CKSYSLOG */
12047 case XYTLOG: { /* SET TRANSACTION-LOG */
12048 extern int tlogsep;
12049 if ((x = cmkey(vbtab,nvb,"","verbose",xxstring)) < 0)
12052 if ((y = cmtxt("field separator",",",&s,NULL)) < 0) return(y);
12056 printf("?A single character, please.\n");
12058 } else if ((*s >= '0' && *s <= '9') ||
12059 (*s >= 'A' && *s <= 'Z') ||
12060 (*s >= 'a' && *s <= 'z')) {
12061 printf("?A non-alphanumeric character, please.\n");
12067 if ((y = cmcfm()) < 0) return(y);
12070 if (inserver && isguest) {
12071 printf("?Sorry, command disabled.\n");
12072 return(success = 0);
12076 /* Don't let this be set remotely */
12077 if (apcactive == APC_LOCAL ||
12078 (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
12079 return(success = 0);
12080 #endif /* CK_APC */
12082 return(success = 1);
12086 case XYCLEAR: { /* SET CLEARCHANNEL */
12087 if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
12089 if ((y = cmcfm()) < 0) return(y);
12091 return(success = 1);
12094 #ifdef CK_AUTHENTICATION
12095 case XYAUTH: { /* SET AUTHENTICATION */
12098 extern struct krb_op_data krb_op;
12099 #endif /* CK_KERBEROS */
12102 cmkey(setauth,nsetauth,"authentication type","",xxstring)) < 0)
12106 case AUTH_KRB4: kv = 4; break; /* Don't assume values are same */
12107 case AUTH_KRB5: kv = 5; break;
12108 #endif /* CK_KERBEROS */
12110 case AUTH_SRP: break;
12111 #endif /* CK_SRP */
12116 #endif /* CK_SSL */
12118 printf("?Authorization type not supported yet - \"%s\"\n",
12128 #endif /* IKSDCONF */
12130 if ((y = cmcfm()) < 0) return(y);
12131 printf("?Sorry, command disabled.\n");
12132 return(success = 0);
12136 /* Don't let this be set remotely */
12137 if (apcactive == APC_LOCAL ||
12138 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)) {
12139 if ((y = cmcfm()) < 0) return(y);
12140 return(success = 0);
12142 #endif /* CK_APC */
12148 if ((x = cmkey(kv == 4 ? k4tab : k5tab,
12149 kv == 4 ? nk4tab : nk5tab,
12150 "Kerberos parameter","",xxstring)) < 0) {
12158 if ((y = seton(&k4debug)) < 0)
12161 ck_krb4_debug(k4debug);
12169 if ((y = cmnum("TGT lifetime","600",10,&z,xxstring)) < 0)
12174 if ((y = seton(&krb4_d_preauth)) < 0)
12181 if ((y = cmtxt("Instance name","",&s,xxstring)) < 0)
12186 if ((y = seton(&krb5_d_forwardable)) < 0)
12194 if ((y = seton(&krb5_d_proxiable)) < 0)
12201 if ((y = cmnum("TGT renewable lifetime",
12202 "0",10,&z,xxstring)) < 0)
12207 if ((y = seton(&krb5_checkaddrs)) < 0)
12210 if ((y = seton(&krb4_checkaddrs)) < 0)
12216 if ((y = seton(&krb5_d_no_addresses)) < 0)
12222 char * tmpaddrs[KRB5_NUM_OF_ADDRS];
12223 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++)
12224 tmpaddrs[i] = NULL;
12227 cmfld("List of IP addresses","",&s,xxstring)) < 0)
12229 makelist(s,tmpaddrs,KRB5_NUM_OF_ADDRS);
12230 if ((y = cmcfm()) < 0) {
12231 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12232 if (tmpaddrs[i] != NULL)
12238 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12240 if (inet_addr(tmpaddrs[i]) == 0xffffffff) {
12241 printf("invalid ip address: %s\n",
12243 for (i = 0; i < KRB5_NUM_OF_ADDRS; i++) {
12244 if (tmpaddrs[i] != NULL)
12251 i < KRB5_NUM_OF_ADDRS && krb5_d_addrs[i];
12253 if (krb5_d_addrs[i])
12254 free(krb5_d_addrs[i]);
12255 krb5_d_addrs[i] = NULL;
12258 i < KRB5_NUM_OF_ADDRS && tmpaddrs[i];
12260 krb5_d_addrs[i] = tmpaddrs[i];
12261 tmpaddrs[i] = NULL;
12263 krb5_d_addrs[i] = NULL;
12264 return(success = 1);
12270 if ((y = seton(&krb5_autoget)) < 0)
12273 if ((y = seton(&krb4_autoget)) < 0)
12278 if ((z = cmkey(kdestab,nkdestab,
12279 "Auto Destroy Tickets",
12280 "never",xxstring)) < 0)
12284 if ((y = cmtxt("User ID",uidbuf,&s,xxstring)) < 0)
12288 if ((y = cmtxt("Name of realm","",&s,xxstring)) < 0)
12292 y = cmifi("Filename","",&s,&z,xxstring);
12297 printf("?Wildcards not allowed\n");
12303 if ((y = cmofi("Filename","",&s,xxstring)) < 0)
12307 if ((y = cmtxt("Name of service to use in ticket",
12308 (kv == 4 ? "rcmd" : "host"),
12316 if ((y = seton(&krb5_d_getk4)) < 0)
12322 case XYKRBPRM: /* Prompt */
12323 if ((z = cmkey(krbprmtab,2,"","",xxstring)) < 0)
12325 if ((y = cmtxt((z == KRB_PW_PRM) ?
12326 "Text of prompt;\nmay contain \"%s\" to be replaced by principal name" :
12336 ckstrncpy(line,s,LINBUFSIZ);
12338 if ((y = cmcfm()) < 0)
12344 #else /* IKSDCONF */
12346 #endif /* IKSDCONF */
12348 return(success = 0);
12351 switch (x) { /* Copy value to right place */
12352 case XYKRBLIF: /* Lifetime */
12354 krb4_d_lifetime = z;
12356 krb5_d_lifetime = z;
12360 krb5_d_renewable = z;
12362 case XYKRBPR: /* Principal */
12363 s = brstrip(s); /* Strip braces around. */
12365 makestr(&krb4_d_principal,s);
12367 makestr(&krb5_d_principal,s);
12369 case XYKRBINS: /* Instance */
12371 makestr(&krb4_d_instance,s);
12373 makestr(&krb5_d_instance,s);
12375 case XYKRBRL: /* Realm */
12377 makestr(&krb4_d_realm,s);
12379 makestr(&krb5_d_realm,s);
12381 case XYKRBKTB: /* Key Table */
12383 makestr(&k4_keytab,s);
12385 makestr(&k5_keytab,s);
12387 case XYKRBCC: /* Credentials cache */
12388 makestr(&krb5_d_cc,s);
12390 case XYKRBSRV: /* Service Name */
12392 makestr(&krb4_d_srv,s);
12394 makestr(&krb5_d_srv,s);
12402 case XYKRBPRM: /* Prompt */
12403 if (s == "") s = NULL;
12406 if (s == "") s = NULL;
12409 case KRB_PW_PRM: { /* Password */
12410 /* Check that there are no more than */
12411 /* two % fields and % must followed by 's'. */
12414 for (i = 0, n = 0; i < len; i++) {
12416 if (s[i+1] != '%') {
12417 if (s[i+1] != 's') {
12419 "Only %%s fields are permitted.\n"
12425 "Only two %%s fields are permitted.\n");
12433 makestr(&k5pwprompt,s);
12435 makestr(&k4pwprompt,s);
12438 case KRB_PR_PRM: { /* Principal */
12439 /* Check to make sure there are no % fields */
12442 for (i = 0; i < len; i++) {
12444 if (s[i+1] != '%') {
12446 "%% fields are not used in this command.\n");
12453 makestr(&k5prprompt,s);
12455 makestr(&k4prprompt,s);
12462 #endif /* CK_KERBEROS */
12465 if ((x = cmkey(srptab, nsrptab,
12466 "SRP parameter","",xxstring)) < 0) {
12471 case XYSRPPRM: /* Prompt */
12472 if ((z = cmkey(srpprmtab,1,"","",xxstring)) < 0)
12475 "Text of prompt;\nmay contain one \"%s\" to be replaced by the username",
12484 ckstrncpy(line,s,LINBUFSIZ);
12486 if ((y = cmcfm()) < 0)
12488 switch (x) { /* Copy value to right place */
12489 case XYSRPPRM: /* Prompt */
12490 if (s == "") s = NULL;
12493 if (s == "") s = NULL;
12496 case SRP_PW_PRM: { /* Password */
12497 /* Check %s fields */
12500 for (i = 0, n = 0; i < len; i++) {
12502 if (s[i+1] != '%') {
12503 if (s[i+1] != 's') {
12505 "Only %%s fields are permitted.\n");
12510 "Only one %%s field is permitted.\n");
12517 makestr(&srppwprompt,s);
12524 #endif /* CK_SRP */
12528 if ((z = cmkey(ssltab, nssltab,
12529 (x == AUTH_SSL ? "SSL parameter" : "TLS parameter"),
12534 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12535 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12536 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12537 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12538 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12539 case XYSSLDKFL: /* SSL/TLS DH Key File */
12540 case XYSSLDPFL: /* SSL/TLS DH Param File */
12541 case XYSSLCRL: /* SSL/TLS CRL File */
12542 case XYSSLVRFF: /* SSL/TLS Verify File */
12543 case XYSSLRND: /* SSL/TLS Random File */
12544 y = cmifi("Filename","",&s,&x,xxstring);
12549 printf("?Wildcards not allowed\n");
12553 ckstrncpy(line,s,LINBUFSIZ);
12556 if ((y = cmcfm()) < 0)
12559 case XYSSLRCFL: /* SSL/TLS RSA Certs file */
12560 if (!s[0] && ssl_rsa_cert_file) {
12561 free(ssl_rsa_cert_file);
12562 ssl_rsa_cert_file = NULL;
12564 makestr(&ssl_rsa_cert_file,s);
12565 if (!ssl_rsa_key_file)
12566 makestr(&ssl_rsa_key_file,s);
12569 case XYSSLRCCF: /* SSL/TLS RSA Certs Chain file */
12570 if (!s[0] && ssl_rsa_cert_chain_file) {
12571 free(ssl_rsa_cert_chain_file);
12572 ssl_rsa_cert_chain_file = NULL;
12574 makestr(&ssl_rsa_cert_chain_file,s);
12577 case XYSSLRKFL: /* SSL/TLS RSA Key File */
12578 if (!s[0] && ssl_rsa_key_file) {
12579 free(ssl_rsa_key_file);
12580 ssl_rsa_key_file = NULL;
12582 makestr(&ssl_rsa_key_file,s);
12585 case XYSSLDCFL: /* SSL/TLS DSA Certs file */
12586 if (!s[0] && ssl_dsa_cert_file) {
12587 free(ssl_dsa_cert_file);
12588 ssl_dsa_cert_file = NULL;
12590 makestr(&ssl_dsa_cert_file,s);
12591 if (!ssl_dh_key_file)
12592 makestr(&ssl_dh_key_file,s);
12595 case XYSSLDCCF: /* SSL/TLS DSA Certs Chain file */
12596 if (!s[0] && ssl_dsa_cert_chain_file) {
12597 free(ssl_dsa_cert_chain_file);
12598 ssl_dsa_cert_chain_file = NULL;
12600 makestr(&ssl_dsa_cert_chain_file,s);
12603 case XYSSLDKFL: /* SSL/TLS DH Key File */
12604 if (!s[0] && ssl_dh_key_file) {
12605 free(ssl_dh_key_file);
12606 ssl_dh_key_file = NULL;
12608 makestr(&ssl_dh_key_file,s);
12611 case XYSSLDPFL: /* SSL/TLS DH Param File */
12612 if (!s[0] && ssl_dh_param_file) {
12613 free(ssl_dh_param_file);
12614 ssl_dh_param_file = NULL;
12616 makestr(&ssl_dh_param_file,s);
12619 case XYSSLCRL: /* SSL/TLS CRL File */
12620 if (!s[0] && ssl_crl_file) {
12621 free(ssl_crl_file);
12622 ssl_crl_file = NULL;
12624 makestr(&ssl_crl_file,s);
12627 case XYSSLVRFF: /* SSL/TLS Verify File */
12628 if (!s[0] && ssl_verify_file) {
12629 free(ssl_verify_file);
12630 ssl_verify_file = NULL;
12632 makestr(&ssl_verify_file,s);
12635 case XYSSLRND: /* SSL/TLS Random File */
12636 if (!s[0] && ssl_rnd_file) {
12637 free(ssl_rnd_file);
12638 ssl_rnd_file = NULL;
12640 makestr(&ssl_rnd_file,s);
12649 if (z == XYSSLVRFD)
12650 d= getenv("SSL_CERT_DIR");
12653 if ((y = cmdir("Directory",d,&s,xxstring)) < 0)
12656 ckstrncpy(line,s,LINBUFSIZ);
12659 if ((y = cmcfm()) < 0)
12663 if (!s[0] && ssl_crl_dir) {
12665 ssl_crl_dir = NULL;
12667 makestr(&ssl_crl_dir,s);
12671 if (!s[0] && ssl_verify_dir) {
12672 free(ssl_verify_dir);
12673 ssl_verify_dir = NULL;
12675 makestr(&ssl_verify_dir,s);
12681 case XYSSLCOK: /* SSL/TLS Certs-Ok flag */
12682 if ((y = seton(&ssl_certsok_flag)) < 0)
12685 case XYSSLDBG: /* SSL/TLS Debug flag */
12686 if ((y = seton(&ssl_debug_flag)) < 0)
12689 case XYSSLON: /* SSL/TLS Only flag */
12692 if ((y = seton(&ssl_only_flag)) < 0)
12696 if ((y = seton(&tls_only_flag)) < 0)
12701 case XYSSLVRB: /* SSL/TLS Verbose flag */
12702 if ((y = seton(&ssl_verbose_flag)) < 0)
12705 case XYSSLVRF: /* SSL/TLS Verify flag */
12706 if ((x = cmkey(sslvertab, nsslvertab,
12707 "SSL/TLS verify mode",
12708 "peer-cert",xxstring)) < 0)
12710 if ((y = cmcfm()) < 0)
12712 ssl_verify_flag = x;
12715 if ((y = seton(&ssl_dummy_flag)) < 0)
12718 case XYSSLCL: { /* SSL/TLS Cipher List */
12720 /* This code is used to generate a colon delimited */
12721 /* list of the ciphers currently in use to be used */
12722 /* as the default for cmtxt(). However, a better */
12723 /* default is simply the magic keyword "ALL". */
12724 CHAR def[1024] = "";
12725 if (ssl_con != NULL) {
12726 CHAR * p = NULL, *q = def;
12729 for (i = 0; ; i++) {
12730 p = (CHAR *) SSL_get_cipher_list(ssl_con,i);
12734 if (q+len+1 >= def+1024)
12742 #endif /* COMMENT */
12743 char * p = getenv("SSL_CIPHER");
12747 "Colon-delimited list of ciphers or ALL (case-sensitive)",
12754 makestr(&ssl_cipher_list,s);
12755 if (ssl_con == NULL) {
12756 SSL_library_init();
12757 ssl_ctx = (SSL_CTX *)
12758 SSL_CTX_new((SSL_METHOD *)TLSv1_method());
12759 if (ssl_ctx != NULL)
12760 ssl_con= (SSL *) SSL_new(ssl_ctx);
12763 SSL_set_cipher_list(ssl_con,ssl_cipher_list);
12770 #endif /* CK_SSL */
12774 return(success = 1);
12776 #endif /* CK_AUTHENTICATION */
12780 if ((x = cmkey(functab,nfunctab,"","diagnostics",xxstring)) < 0)
12783 case FUNC_DI: return(seton(&fndiags));
12784 case FUNC_ER: return(seton(&fnerror));
12785 default: return(-2);
12789 case XYSLEEP: /* SET SLEEP / PAUSE */
12790 if ((x = cmkey(sleeptab,1,"","cancellation",xxstring)) < 0)
12792 return(seton(&sleepcan));
12794 case XYCD: /* SET CD */
12795 if ((x = cmkey(cdtab,ncdtab,"","",xxstring)) < 0)
12798 case XYCD_H: { /* SET CD HOME */
12799 extern char * myhome;
12800 if ((y = cmdir("Directory name",zhome(),&s,xxstring)) < 0)
12802 makestr(&myhome,s);
12803 return(success = 1);
12805 case XYCD_M: /* SET CD MESSAGE */
12806 if ((x = cmkey(cdmsg,ncdmsg,"","",xxstring)) < 0)
12808 if (x == 2) { /* CD MESSAGE FILE */
12809 if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
12815 #endif /* NOXFER */
12817 makestr(&cdmsgstr,s);
12818 makelist(cdmsgstr,cdmsgfile,8);
12819 return(success = 1);
12822 if ((y = cmcfm()) < 0) return(y); /* CD-MESSAGE ON/OFF */
12828 #endif /* NOXFER */
12829 return(success = 1);
12831 case XYCD_P: { /* SET CD PATH */
12832 extern char * ckcdpath;
12833 if ((x = cmtxt("CD PATH string","",&s,xxstring)) < 0)
12835 makestr(&ckcdpath,s);
12836 return(success = 1);
12842 case XYSTOP: /* STOP-BITS */
12843 if ((x = cmkey(stoptbl,2,"Stop bits for serial device","",
12846 if ((y = cmcfm()) < 0)
12848 if (x > 0 && x < 3) {
12851 if (network && istncomport()) {
12853 return(success = 1);
12855 #endif /* TN_COMPORT */
12857 return(success = 1);
12858 #else /* HWPARITY */
12860 #endif /* HWPARITY */
12863 #endif /* STOPBITS */
12866 extern int clsondisc;
12867 return(seton(&clsondisc));
12873 if ((x = cmkey(sertbl,nsertbl,
12874 "Serial device character size, parity, and stop bits",
12875 "8N1", xxstring)) < 0)
12877 ckstrncpy(line,atmbuf,LINBUFSIZ); /* Associated keyword string */
12879 if ((y = cmcfm()) < 0)
12881 ckstrncpy(line,sernam[x],LINBUFSIZ);
12883 if (s[0] != '8' && s[0] != '7') /* Char size */
12887 if (isupper(s[1])) /* Parity */
12888 s[1] = tolower(s[1]);
12889 if (s[2] != '1' && s[2] != '2') /* Stop bits */
12892 stopbits = s[2] - '0';
12893 if (z == 8) { /* 8 bits + parity (or not) */
12894 parity = 0; /* Set parity */
12895 hwparity = (s[1] == 'n') ? 0 : s[1];
12896 setcmask(8); /* Also set TERM BYTESIZE to 8 */
12897 } else { /* 7 bits plus parity */
12898 parity = (s[1] == 'n') ? 0 : s[1];
12900 setcmask(7); /* Also set TERM BYTESIZE to 7 */
12903 if (network && !istncomport())
12904 tnsettings(parity, stopbits);
12905 #endif /* TN_COMPORT */
12907 return(success = 1); /* from SET SERIAL */
12910 case XYOPTS: { /* SET OPTIONS */
12911 extern int setdiropts();
12912 extern int settypopts();
12914 extern int setpurgopts();
12915 #endif /* CKPURGE */
12916 if ((x = cmkey(optstab,noptstab,"for command","", xxstring)) < 0)
12921 return(setdelopts());
12922 #endif /* NOFRILLS */
12924 return(setdiropts());
12926 return(settypopts());
12929 return(setpurgopts());
12930 #endif /* CKPURGE */
12935 #endif /* NOLOCAL */
12939 return(seton(&q8flag));
12942 extern int asktimer;
12943 y = cmnum("Time limit for ASK command, seconds","0",10,&x,xxstring);
12945 return(setnum(&asktimer,x,y,32767));
12947 return(setnum(&asktimer,x,y,86400));
12951 extern int fackbug;
12952 return(seton(&fackbug));
12954 #endif /* NOXFER */
12957 return(seton(&hints));
12961 extern int oldeval;
12962 if ((x = cmkey(oldnew,2,"","", xxstring)) < 0)
12964 if ((y = cmcfm()) < 0)
12967 return(success = 1);
12973 extern int fackpath;
12974 return(seton(&fackpath));
12976 #endif /* NOXFER */
12979 extern int qnxportlock;
12980 return(seton(&qnxportlock));
12990 #endif /* NOCMDL */
12994 return(dochroot());
12995 #endif /* CKROOT */
13000 if ((x = cmkey(sexptab,2,"","", xxstring)) < 0)
13004 if ((x = cmkey(ooatab,3,"","automatic", xxstring)) < 0)
13006 if ((y = cmcfm()) < 0)
13013 if ((y = cmnum("Maximum recursion depth",
13014 "1000",10,&x,xxstring)) < 0)
13016 z = setnum(&sexpmaxdep,x,y,-1);
13019 if (sxresult) { /* Free old stack if allocated */
13020 for (i = 0; i < xx; i++)
13021 if (sxresult[i]) free(sxresult[i]);
13022 free((char *)sxresult);
13023 if (sxrlen) free((char *)sxrlen);
13030 return(success = 1);
13032 #endif /* NOSEXPL */
13037 extern struct keytab gprtab[];
13039 if ((x = cmkey(gprtab,3,"","kermit", xxstring)) < 0)
13041 if ((y = cmcfm()) < 0)
13044 return(success = 1);
13046 #endif /* NEWFTP */
13050 return(dosetssh());
13051 #endif /* ANYSHH */
13053 #ifdef SFTP_BUILTIN
13055 return(dosetsftp());
13056 #endif /* SFTP_BUILTIN */
13060 if ((x = cmkey(locustab,nlocustab,"",
13068 if ((y = cmcfm()) < 0)
13070 if (x == 2 || x == 3) { /* AUTO or ASK */
13071 setautolocus(x - 1); /* Two forms of automatic locusing */
13072 /* setlocus(1,0); */ /* we're not changing the locus here */
13073 } else { /* LOCAL or REMOTE */
13074 setautolocus(0); /* No automatic Locus changing */
13075 setlocus(x,0); /* Set Locus as requested */
13077 return(success = 1);
13086 if ((x = cmcfm()) < 0) return(x);
13087 printf("Not implemented - %s\n",cmdbuf);
13088 return(success = 0);
13093 H U P O K -- Is Hangup OK?
13095 Issues a warning and gets OK from user depending on whether a connection
13096 seems to be open and what the SET EXIT WARNING setting is. Returns:
13097 0 if not OK to hang up or exit (i.e. user said No);
13099 Argument x is used to differentiate the EXIT command from SET LINE / HOST.
13102 hupok(x) int x; { /* Returns 1 if OK, 0 if not OK */
13104 extern int exithangup;
13108 if (batch) /* No warnings in batch */
13112 if (backgrd) /* No warnings in background */
13118 debug(F101,"hupok local","",local);
13120 if (!local) /* No warnings in remote mode */
13124 if (x == 0 && exithangup == 0) /* EXIT and EXIT HANGUP is OFF */
13127 debug(F101,"hupok x","",x);
13128 debug(F101,"hupok xitwarn","",xitwarn);
13129 debug(F101,"hupok network","",network);
13130 debug(F101,"hupok haveline","",haveline);
13132 if ((local && xitwarn) || /* Is a connection open? */
13133 (!x && xitwarn == 2)) { /* Or Always give warning on EXIT */
13140 /* A connection seems to be open but it can't possibly be */
13144 if (strcmp(ttname,"*"))
13145 ckmakmsg(warning,256,
13146 " A network connection to ",ttname,
13147 " might still be active.\n",NULL);
13150 " An incoming network connection might still be active.\n",
13153 } else { /* Serial connection */
13154 if (carrier == CAR_OFF) /* SET CARRIER OFF */
13155 needwarn = 0; /* so we don't care about carrier. */
13156 else if ((y = ttgmdm()) >= 0) /* else, get modem signals */
13157 needwarn = (y & BM_DCD); /* Check for carrier */
13158 else /* If we can't get modem signals... */
13159 needwarn = (ttchk() >= 0);
13160 /* A connection seems to be open but it can't possibly be */
13161 if (!haveline || !exithangup)
13164 ckmakmsg(warning,256,
13165 " A serial connection might still be active on ",
13166 ttname,".\n",NULL);
13169 /* If a warning was issued, get user's permission to EXIT. */
13171 if (needwarn || (!x && xitwarn == 2
13177 printf("%s",warning);
13178 z = getyesno(x ? "OK to close? " : "OK to exit? ",0);
13179 debug(F101,"hupok getyesno","",z);
13183 x ? "OK to close? " : "OK to exit? ",
13188 debug(F101,"hupok uq_ok","",z);
13190 #endif /* COMMENT */
13198 shoctl() { /* SHOW CONTROL-PREFIXING */
13205 "\ncontrol quote = %d, applied to (0 = unprefixed, 1 = prefixed):\n\n",
13208 #ifndef UNPREFIXZERO
13210 if (protocol == PROTO_K) /* Zero can't be unprefixed */
13211 ctlp[0] = 1; /* for Kermit */
13212 #endif /* UNPREFIXZERO */
13214 for (i = 0; i < 16; i++) {
13215 printf(" %3d: %d %3d: %d ",i,ctlp[i], i+16, ctlp[i+16]);
13217 printf(" 127: %d",ctlp[127]);
13220 printf(" %3d: %d %3d: %d ",i+128,ctlp[i+128], i+144, ctlp[i+144]);
13221 if (i == 15) printf(" 255: %d",ctlp[255]);
13225 #ifndef UNPREFIXZERO
13229 #endif /* UNPREFIXZERO */
13231 #endif /* CK_SPEED */
13236 shodbl() { /* SHOW DOUBLE/IGNORE */
13239 printf("\nSET SEND DOUBLE characters:\n");
13240 for (i = 0; i < 255; i++) {
13249 printf("\nSET RECEIVE IGNORE characters:\n");
13250 for (i = 0; i < 255; i++) {
13259 #endif /* CKXXCHAR */
13261 #endif /* NOXFER */
13262 #endif /* NOSHOW */
13267 Rexx command. Note, this is not OS/2-specific, because Rexx also runs
13268 on other systems where C-Kermit also runs, like the Amiga.
13270 #define REXBUFL 100 /* Change this if neccessary */
13271 char rexxbuf[REXBUFL] = { '\0' }; /* Rexx's return value (string) */
13278 if ((x = cmtxt("Rexx command","",&rexxcmd,xxstring)) < 0)
13283 printf("?Sorry, command disabled.\r\n");
13284 return(success = 0);
13288 /* Don't let this be set remotely */
13289 if (apcactive == APC_LOCAL ||
13290 apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
13291 return(success = 0);
13292 #endif /* CK_APC */
13294 ckstrncpy(line,rexxcmd,LINBUFSIZ);
13297 return(os2rexx(rexxcmd,rexxbuf,REXBUFL));
13299 printf("Sorry, nothing happens.\n");
13300 return(success = 0);
13303 #endif /* CK_REXX */
13304 #endif /* NOPUSH */
13308 /* Dummy write record to connection log */