4 /* C K U U S Y -- "User Interface" for C-Kermit Kermit, part Y */
6 /* Command-Line Argument Parser */
10 Frank da Cruz <fdc@columbia.edu>,
11 The Kermit Project, Columbia University, New York City
12 Jeffrey E Altman <jaltman@secure-endpoints.com>
13 Secure Endpoints Inc., New York City
15 Copyright (C) 1985, 2009,
16 Trustees of Columbia University in the City of New York.
17 All rights reserved. See the C-Kermit COPYING.TXT file or the
18 copyright text in the ckcmai.c module for disclaimer and permissions.
22 char * bannerfile = NULL;
23 char * helpfile = NULL;
24 extern int xferlog, filepeek, nolinks;
25 extern char * xferfile;
43 extern struct _kui_init kui_init;
47 extern int inserver, fncnv, f_save, xfermode;
59 extern int revcall, closgr, cudata;
72 extern struct keytab netcmd[];
76 extern int nnets, nnetdir; /* Network services directory */
77 extern char *netdir[];
78 extern char *nh_p[]; /* Network directory entry pointers */
79 extern char *nh_p2[]; /* Network directory entry nettype */
80 extern char *nh_px[4][MAXDNUMS + 1];
83 extern char * n_name; /* Network name pointer */
89 extern struct mtab *mactab;
97 extern char * myname, * dftty;
100 extern char *ckxsys, *ckzsys, **xargv, *xarg0, **cmlist, *clcmds;
102 extern int action, cflg, xargc, cnflg, local, quiet, escape, network, mdmtyp,
103 bgset, backgrd, xargs, binary, parity, turn, turnch, duplex, flow, clfils,
104 noinit, stayflg, nettype, cfilef, noherald, cmask, cmdmsk, exitonclose,
105 haveline, justone, cxtype, xfinish, ttnproto;
108 extern char ttname[];
109 extern char * pipedata, * cmdfil;
112 extern char *cmarg, *cmarg2;
114 extern int nfils, stdouf, stdinf, displa, maxrps, rpsiz, ckwarn, urpsiz,
115 wslotr, swcapr, ckdelay, recursive, reliable, xreliable, fnspath, fncact,
116 clearrq, setreliable;
119 extern int usepipes, pipesend;
120 #endif /* PIPESEND */
129 extern struct keytab os2devtab[];
132 extern int tt_scroll, tt_escape;
139 extern unsigned char NetBiosAdapter;
140 #endif /* CK_NETBIOS */
147 _PROTOTYP(static int dotnarg, (char x) );
150 _PROTOTYP(static int dorlgarg, (char x) );
151 #endif /* RLOGCODE */
153 _PROTOTYP(static int dossharg, (char x) );
154 #endif /* SSHBUILTIN */
156 int haveftpuid = 0; /* Have FTP user ID */
157 static int have_cx = 0; /* Have connection */
159 static char * failmsg = NULL; /* Failure message */
162 extern char * ftp_host;
169 extern int nmdm, telephony;
170 extern struct keytab mdmtab[];
171 extern int usermdm, dialudt;
173 _PROTOTYP(static int pmsg, (char *) );
174 _PROTOTYP(static int fmsg, (char *) );
175 static int pmsg(s) char *s; { printf("%s\n", s); return(0); }
176 static int fmsg(s) char *s; { fatal(s); return(0); }
177 #define XFATAL(s) return(what==W_COMMAND?pmsg(s):fmsg(s))
189 /* URLs we recognize */
198 struct keytab urltab[] = {
204 "https", URL_HTTPS, 0,
207 "kermit", URL_IKSD, 0,
208 "telnet", URL_TELNET, 0,
211 int nurltab = sizeof(urltab)/sizeof(struct keytab) - 1;
214 #define URLBUFLEN 1024
215 #endif /* URLBUFLEN */
216 static char urlbuf[URLBUFLEN];
217 struct urldata g_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
219 /* u r l p a r s e -- Parse a possible URL */
222 Returns 0 if the candidate does not seem to be a URL.
223 Returns 1 if it might be a URL, with the above pointers set to its pieces:
224 service : [ // ] [ user [ : password ] @ ] host [ : service ] [ / path ] -
225 [ ? name [ = value ]]
227 Example: ftp://ds.internic.net:21/rfc/rfc1234.txt
231 url.hos = [ds.internic.net]
233 url.pth = [rfc/rfc1234.txt]
235 It might be a URL if it contains a possible service name followed by a
236 a colon (:). Thus "telnet:xyzcorp.com" is a minimal URL, whereas a
237 full-blown example would be:
239 ftp://olga:secret@ftp.xyzcorp.com/public/oofa.txt
241 The caller must verify the results, i.e. that the service string is a real
242 TCP service, etc. This routine just parses the fields.
244 struct urldata defined in ckcker.h
248 urlparse(s,url) char *s; struct urldata * url; {
249 char * p = NULL, * urlbuf = NULL;
260 if (url->sav) { /* In case we were called before... */
290 for (i = 0; i < url->nopts && i < MAX_URL_OPTS; i++ ) {
291 if (url->opt[i].nam) {
292 free(url->opt[i].nam);
293 url->opt[i].nam = NULL;
295 if (url->opt[i].val) {
296 free(url->opt[i].val);
297 url->opt[i].val = NULL;
302 p = urlbuf; /* Was a service requested? */
303 while (*p && *p != ':') /* Look for colon */
305 if (*p == ':') { /* Have a colon */
306 *p++ = NUL; /* Get service name or number */
307 if (*p == ':') /* a second colon */
308 *p++ = NUL; /* get rid of that one too */
309 while (*p == '/') *p++ = NUL; /* and slashes */
311 /* Trailing slash is part of path - leave it - jaltman */
312 x = strlen(p); /* Length of remainder */
313 if (p[x-1] == '/') /* If there is a trailing slash */
314 p[x-1] = NUL; /* remove it. */
316 if (urlbuf[0]) { /* Anything left? */
317 char *q = p, *r = p, *w = p;
318 makestr(&url->svc,urlbuf);
320 while (*p != NUL && *p != '@') /* look for @ */
322 if (*p == '@') { /* Signifies user ID, maybe password */
325 while (*w != NUL && *w != ':')
329 url->usr = r; /* Username */
331 url->psw = w; /* Password */
333 } else { /* No username or password */
338 debug(F111,"urlparse url->usr",url->usr,url->usr);
339 debug(F111,"urlparse url->psw",url->usr,url->psw);
340 debug(F111,"urlparse url->hos",url->usr,url->hos);
343 while (*p != NUL && *p != ':' && *p != '/') /* Port? */
345 if (*p == ':') { /* TCP port */
349 while (*p != NUL && *p != '/')
351 /* '/' is part of path, leave it until we can copy */
353 makestr(&url->pth,p); /* Path */
356 } else { /* No port */
357 /* '/' is part of path, leave it */
359 makestr(&url->pth,p); /* Path */
364 /* Copy non-NULL result strings */
365 if (url->svc) if (*url->svc) {
368 makestr(&url->svc,p);
370 if (url->hos) if (*url->hos) {
373 makestr(&url->hos,p);
375 if (url->por) if (*url->por) {
378 makestr(&url->por,p);
381 WARNING (Wed Oct 9 16:09:03 2002): We now allow the username and
382 password to be empty strings. These are treated differently from null
383 pointers: an empty string means the URL included username and/or password
384 fields that were empty, e.g. ftp://:@ftp.xyzcorp.com/somepath/somefile,
385 which causes the client to prompt for the username and/or password.
387 if (url->usr) /* if (*url->usr) */ {
390 makestr(&url->usr,p);
392 if (url->psw) /* if (*url->psw) */ {
395 makestr(&url->psw,p);
397 /* Save a copy of the full url if one was found. */
399 makestr(&url->sav,s);
401 return(url->svc ? 1 : 0);
411 " [filename] [-x arg [-x arg]...[-yyy]..] [ = text ] ]\n",
413 "[-x arg [-x arg]...[-yyy]..]\n",
416 " -x is an option requiring an argument, -y an option with no argument.\n",
417 " If the first command-line argument is the name of a file, interactive-\n",
418 " mode commands are executed from the file. The '=' argument tells Kermit\n",
419 " not to parse the remainder of the command line, but to make the words\n",
420 " following '=' available as \\%1, \\%2, ... \\%9. The command file \
422 " is executed before the command-line options.\n",
425 "If no action command is included, or -S is, then after the command line is\n",
426 "executed, Kermit issues its prompt and waits for you to type commands.\n",
428 "Operation by command-line options only.\n",
435 " [option-list] host[:port] [port]\n",
436 " The option-list consists of zero, one, or more of:\n",
437 " -8 Negotiate Telnet Binary in both directions\n",
438 " -a Require use of Telnet authentication\n",
439 " -d Turn on debug mode\n",
440 " -E No escape character\n",
441 " -K Refuse use of authentication; do not send username\n",
442 " -l user Set username and request Telnet authentication\n",
443 " -L Negotiate Telnet Binary Output only\n",
444 " -x Require Encryption\n",
445 " -D Disable forward-X\n",
446 " -T cert=file Use certificate in file\n",
447 " -T key=file Use private key in file\n",
448 " -T crlfile=file Use CRL in file\n",
449 " -T crldir=dir Use CRLs in directory\n",
450 " -T cipher=string Use only ciphers in string\n",
451 " -f Forward credentials to host\n",
452 " -k realm Set default Kerberos realm\n",
457 char *hlp3[] = { /* rlogin */
458 " [option-list] host[:port] [port]\n",
459 " The option-list consists of zero, one, or more of:\n",
460 " -d Turn on debug mode\n",
461 " -l user Set username\n",
466 char *hlp4[] = { /* ssh */
467 " [option-list] host[:port] [port]\n",
468 " The option-list consists of zero, one, or more of:\n",
470 " -# flags Kermit 95 Startup Flags\n",
471 " 1 turn off Win95 special fixes\n",
472 " 2 do not load optional network dlls\n",
473 " 4 do not load optional tapi dlls\n",
474 " 8 do not load optional kerberos dlls\n",
475 " 16 do not load optional zmodem dlls\n",
476 " 32 use stdin for input instead of the console\n",
477 " 64 use stdout for output instead of the console\n",
478 " 128 do not terminate process in response to Session Logoff\n",
480 " -d Turn on debug mode\n",
481 " -Y Disable init file processing\n",
482 " -l user Set username\n",
486 /* Command-line option help lines. Update this when adding new options! */
488 char * opthlp[128]; /* Option help */
489 char * arghlp[128]; /* Argument for option */
490 int optact[128]; /* Action-option flag */
493 fatal2(msg1,msg2) char *msg1, *msg2; {
495 if (!msg1) msg1 = "";
496 if (!msg2) msg2 = "";
497 ckmakmsg(buf,256,"\"",msg1,"\" - ",msg2);
499 if (what == W_COMMAND)
510 cl_int(dummy) int dummy;
512 { /* Command-line interrupt handler */
518 extern int ftp_action, ftp_cmdlin;
521 xx_ftp(host, port) char * host, * port; {
525 extern char * ftp_logname;
529 if (port) if (!*port) port = NULL;
535 debug(F111,"ftp xx_ftp host",ftp_host,haveftpuid);
536 debug(F111,"ftp xx_ftp uidbuf 1",uidbuf,haveftpuid);
537 ftp_cmdlin = 1; /* 1 = FTP started from command line */
539 ftp_cmdlin++; /* 2 = same plus file transfer */
542 /* debug(F111,"ftp xx_ftp g_url.usr",g_url.usr,g_url.usr); */
543 if (haveurl && g_url.usr) { /* Wed Oct 9 15:15:22 2002 */
544 if (!*(g_url.usr)) { /* Force username prompt if */
545 haveftpuid = 0; /* "ftp://:@host" given. */
547 makestr(&ftp_logname,NULL);
549 debug(F111,"ftp xx_ftp uidbuf 2",uidbuf,haveftpuid);
552 debug(F111,"ftp xx_ftp uidbuf 3",uidbuf,haveftpuid);
554 makestr(&ftp_logname,uidbuf);
555 debug(F111,"ftp_logname",ftp_logname,haveftpuid);
558 if ((p = ckstrchr(ftp_host,':')))
577 if (haveurl && g_url.svc)
578 use_tls = !ckstrcmp("ftps",g_url.svc,-1,0);
581 if (ftpopen(ftp_host,port,use_tls) < 1)
583 debug(F111,"ftp xx_ftp action",ckctoa((char)ftp_action),nfils);
585 switch (ftp_action) {
587 return(cmdlinget(stayflg));
590 return(cmdlinput(stayflg));
600 char * http_hlp[] = {
601 " -h This message.\n",
602 " -d Debug to debug.log.\n",
603 " -S Stay (issue command prompt when done).\n",
604 " -Y Do not execute Kermit initialization file.\n",
605 " -q Quiet (suppress most messages).\n",
606 " -u name Username.\n",
607 " -P password Password.\n",
608 " -g pathname Get remote pathname.\n",
609 " -p pathname Put remote pathname.\n",
610 " -H pathname Head remote pathname.\n",
611 " -l pathname Local path for -g, -p, and -H.\n",
613 " -z opt[=value] Security options...\n",
614 " cert=file Client certificate file\n",
615 " certsok Accept all certificates\n",
616 " key=file Client private key file\n",
618 " verify=n 0 = none, 1 = peer , 2 = certificate required\n",
629 static struct keytab httpztab[] = {
630 { "cert", HT_CERTFI, CM_ARG },
631 { "certsok", HT_OKCERT, 0 },
632 { "key", HT_KEY, CM_ARG },
633 { "secure", HT_SECURE, 0 },
634 { "verify", HT_VERIFY, CM_ARG },
637 static int nhttpztab = sizeof(httpztab) / sizeof(struct keytab) - 1;
647 conol(" [-x arg [-x arg]...[-yyy]..] ]\n");
651 if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
652 howcalled == I_AM_SSHSUB)
654 else if (howcalled == I_AM_TELNET)
656 else if (howcalled == I_AM_RLOGIN)
658 else if (howcalled == I_AM_SSH)
660 if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
661 howcalled == I_AM_SSHSUB) {
664 conoll("Complete listing of command-line options:");
666 for (c = 31; c < 128; c++) {
670 printf(" -%c <arg>%s\n",
672 (optact[c] ? " (action option)" : "")
674 printf(" %s\n",opthlp[c]);
675 printf(" Argument: %s\n\n",arghlp[c]);
676 } else { /* Option without arg */
677 printf(" -%c %s%s\n",
679 (optact[c]?" (action option)":"")
681 printf(" Argument: (none)\n\n");
685 printf("To prevent this message from scrolling, use '%s -h | more'.\n",
687 #endif /* OS2ORUNIX */
688 printf("For a list of extended options use '%s --help'.\n",
695 /* C M D L I N -- Get arguments from command line */
699 char x; /* Local general-purpose char */
707 cmarg = ""; /* Initialize globals */
713 signal(SIGINT,cl_int);
715 /* Here we handle different "Command Line Personalities" */
719 if (howcalled == I_AM_HTTP) { /* If I was called as HTTP... */
722 char * agent = "Kermit 95";
724 char * agent = "C-Kermit";
727 debug(F100,"http personality","",0);
733 type = lookup(urltab,g_url.svc,nurltab,NULL);
734 if (!(type == URL_HTTP || type == URL_HTTPS)) {
735 printf("?Internal Error: HTTP command line processing\n");
736 debug(F100,"Error: HTTP command line processing","",0);
741 x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc,
742 type == URL_HTTPS, rdns,128,NULL) == 0);
745 char asname[CKMAXPATH+1];
749 printf("Connected to %s [%s]\r\n",g_url.hos,rdns);
751 printf("Connected to %s\r\n",g_url.hos);
754 zstrip(g_url.pth,&lfile);
759 lfile = "index.html";
762 if (uq_file(NULL, /* K95 GUI: Put up file box. */
763 NULL, /* (not tested...) */
782 x = (http_close() == 0);
785 printf("?HTTP Connection failed.\r\n");
787 doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
792 char * host = NULL, * svc = NULL, * lpath = NULL;
793 char * user = NULL, * pswd = NULL, * path = NULL;
796 while (--xargc > 0) { /* Go through command line words */
798 debug(F111,"cmdlin http xargv",*xargv,xargc);
800 if (**xargv == '-') { /* Got an option */
802 x = *(*xargv+1); /* Get the option letter */
804 case 'd': /* Debug */
809 deblog = debopn("debug.log",0);
814 case 'Y': /* No initialization file */
815 break; /* (already done in prescan) */
816 case 'q': /* Quiet */
819 case 'u': /* Options that require arguments */
826 XFATAL("Invalid argument bundling");
829 if ((xargc < 1) || (**xargv == '-')) {
830 XFATAL("Missing argument");
840 if (http_action != HTTP_PUT)
844 http_action = HTTP_GET;
846 debug(F111,"cmdlin http GET",path,http_action);
849 http_action = HTTP_PUT;
853 http_action = HTTP_HED;
860 /* *xargv contains a value of the form tag=value */
861 /* we need to lookup the tag and save the value */
865 y = ckindex("=",p,0,0,1);
868 x = lookup(httpztab,p,nhttpztab,&z);
870 printf("?Invalid security option: \"%s\"\n",p);
872 printf("Security option: \"%s",p);
873 if (httpztab[z].flgs & CM_ARG) {
876 fatal("?Missing required value");
878 /* -z options w/args */
879 switch (httpztab[z].kwval) {
881 makestr(&ssl_rsa_cert_file,q);
884 ssl_certsok_flag = 1;
887 makestr(&ssl_rsa_key_file,q);
894 printf("?Bad number: %s\n",q);
895 ssl_verify_flag = atoi(q);
906 printf("Usage: %s host [ options... ]\n",xarg0);
908 doexit(GOOD_EXIT,-1);
910 } else { /* No dash - must be hostname */
914 if (svc) if (*svc == '-' || !*svc)
924 if (!*svc) svc = "http";
925 if (!host) XFATAL("No http host given");
927 /* Check action args before opening the connection */
929 if (http_action == HTTP_PUT) {
931 XFATAL("No local path for http PUT");
934 XFATAL("No remote path for http action");
936 /* Now it's OK to open the connection */
939 svc,!ckstrcmp("https",svc,-1,0),rdns,128,NULL
943 printf("?HTTP Connection failed.\r\n");
948 printf("Connected to %s [%s]\r\n",host,rdns);
950 printf("Connected to %s\r\n",host);
954 if (http_action != HTTP_PUT) { /* Supply default */
955 if (!lpath) { /* local path... */
960 lpath = "index.html";
964 char * p = (char *) malloc(strlen(path)+2);
965 if (!p) fatal("?Memory allocation error\n");
967 strcpy(&p[1],path); /* safe */
971 switch (http_action) {
973 x = http_get(agent,NULL,user,pswd,0,lpath,path,0);
977 x = http_put(agent,NULL,"text/HTML",
978 user,pswd,0,lpath,path,NULL,0);
982 x = http_head(agent,NULL,user,pswd,0,lpath,path,0);
985 debug(F101,"cmdline http result","",x);
986 x = (http_close() == 0);
987 if (pcpy) free(path);
988 doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
995 if (howcalled == I_AM_FTP) { /* If I was called as FTP... */
996 debug(F100,"ftp personality","",0);
1003 while (--xargc > 0) { /* Go through command line words */
1005 debug(F111,"cmdlin ftp xargv",*xargv,xargc);
1006 if (**xargv == '-') { /* Got an option */
1008 x = *(*xargv+1); /* Get the option letter */
1011 if (what == W_COMMAND)
1016 } else { /* No dash - must be hostname */
1017 makestr(&ftp_host,*xargv);
1020 if (port) if (*port == '-' || !*port)
1027 debug(F110,"cmdlin ftp host",ftp_host,0);
1028 debug(F110,"cmdlin ftp port",port,0);
1031 } /* if (haveurl) */
1036 xx = xx_ftp(ftp_host,port);
1037 if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
1040 xx = xx_ftp(ftp_host,port);
1041 if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
1043 if (*ftp_host == '=') { /* Skip directory lookup */
1044 xx = xx_ftp(&ftp_host[1],port);
1045 if (xx < 0 && (haveurl || ftp_cmdlin > 1))
1046 doexit(BAD_EXIT,-1);
1047 } else { /* Want lookup */
1049 nhcount = 0; /* Check network directory */
1050 debug(F101,"cmdlin nnetdir","",nnetdir);
1051 if (nnetdir > 0) /* If there is a directory... */
1052 lunet(ftp_host); /* Look up the name */
1053 else /* If no directory */
1054 nhcount = 0; /* we didn't find anything there */
1057 debug(F101,"cmdlin lunet nhcount","",nhcount);
1059 debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
1060 debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
1061 debug(F110,"cmdlin lunet nh_px[0][0]",
1067 xx = xx_ftp(ftp_host,port);
1068 if (xx < 0 && (haveurl || ftp_cmdlin > 1))
1069 doexit(BAD_EXIT,-1);
1071 for (i = 0; i < nhcount; i++) {
1072 if (ckstrcmp(nh_p2[i],"tcp/ip",6,0))
1074 makestr(&ftp_host,nh_p[i]);
1075 debug(F110,"cmdlin calling xx_ftp",ftp_host,0);
1077 printf("Trying %s...\n",ftp_host);
1078 if (xx_ftp(ftp_host,port) > -1)
1085 if (!ftpisconnected())
1086 doexit(BAD_EXIT,-1);
1093 if (howcalled == I_AM_TELNET) { /* If I was called as Telnet... */
1095 while (--xargc > 0) { /* Go through command line words */
1097 debug(F111,"cmdlin telnet xargv",*xargv,xargc);
1100 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1103 else if (**xargv == '/')
1106 else if (**xargv == '-') { /* Got an option (begins with dash) */
1108 x = *(*xargv+1); /* Get the option letter */
1109 debug(F111,"cmdlin telnet args 1",*xargv,xargc);
1111 debug(F101,"cmdlin telnet doarg","",xx);
1112 debug(F111,"cmdlin telnet args 2",*xargv,xargc);
1115 if (what == W_COMMAND)
1121 sleep(1); /* Give it a chance... */
1123 doexit(BAD_EXIT,1); /* Go handle option */
1126 } else { /* No dash must be hostname */
1127 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1128 debug(F110,"cmdlin telnet host",ttname,0);
1132 nhcount = 0; /* Check network directory */
1133 debug(F101,"cmdlin telnet nnetdir","",nnetdir);
1134 if (nnetdir > 0) /* If there is a directory... */
1135 lunet(*xargv); /* Look up the name */
1136 else /* If no directory */
1137 nhcount = 0; /* we didn't find anything there */
1140 debug(F101,"cmdlin telnet lunet nhcount","",nhcount);
1142 debug(F110,"cmdlin telnet lunet nh_p[0]",nh_p[0],0);
1143 debug(F110,"cmdlin telnet lunet nh_p2[0]",nh_p2[0],0);
1144 debug(F110,"cmdlin telnet lunet nh_px[0][0]",
1149 if (nhcount > 0 && nh_p2[0]) /* If network type specified */
1150 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
1152 if (nhcount == 1) { /* Still OK, so make substitution */
1153 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1154 debug(F110,"cmdlin telnet lunet substitution",ttname,0);
1159 if (--xargc > 0 && !haveurl) { /* Service from command line? */
1161 ckstrncat(ttname,":",TTNAMLEN+1);
1162 ckstrncat(ttname,*xargv,TTNAMLEN+1);
1163 debug(F110,"cmdlin telnet host2",ttname,0);
1167 else if (nhcount) { /* No - how about in net directory? */
1169 ckstrncat(ttname,":",TTNAMLEN+1);
1170 ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
1175 local = 1; /* Try to open the connection */
1178 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1179 XFATAL("can't open host connection");
1181 network = 1; /* It's open */
1184 #endif /* CKLOGDIAL */
1186 reliable = 1; /* It's reliable */
1187 xreliable = 1; /* ... */
1190 cflg = 1; /* Connect */
1191 stayflg = 1; /* Stay */
1192 tn_exit = 1; /* Telnet-like exit condition */
1194 exitonclose = 1; /* Exit when connection closes */
1197 if (nmac) { /* Any macros defined? */
1199 k = mlook(mactab,"on_open",nmac); /* Look this up */
1200 if (k >= 0) { /* If found, */
1201 if (dodo(k,ttname,0) > -1) /* set it up, */
1202 parser(1); /* and execute it */
1214 else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */
1215 while (--xargc > 0) { /* Go through command line words */
1217 debug(F111,"cmdlin rlogin xargv",*xargv,xargc);
1220 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1223 else if (**xargv == '/')
1226 else if (**xargv == '-') { /* Got an option (begins with dash) */
1228 x = *(*xargv+1); /* Get the option letter */
1229 debug(F111,"cmdlin rlogin args 1",*xargv,xargc);
1231 debug(F101,"cmdlin rlogin doarg","",xx);
1232 debug(F111,"cmdlin rlogin args 2",*xargv,xargc);
1235 if (what == W_COMMAND)
1241 sleep(1); /* Give it a chance... */
1243 doexit(BAD_EXIT,1); /* Go handle option */
1246 } else { /* No dash must be hostname */
1247 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1248 debug(F110,"cmdlin rlogin host",ttname,0);
1252 nhcount = 0; /* Check network directory */
1253 debug(F101,"cmdlin rlogin nnetdir","",nnetdir);
1254 if (nnetdir > 0) /* If there is a directory... */
1255 lunet(*xargv); /* Look up the name */
1256 else /* If no directory */
1257 nhcount = 0; /* we didn't find anything there */
1260 debug(F101,"cmdlin rlogin lunet nhcount","",nhcount);
1262 debug(F110,"cmdlin rlogin lunet nh_p[0]",nh_p[0],0);
1263 debug(F110,"cmdlin rlogin lunet nh_p2[0]",nh_p2[0],0);
1264 debug(F110,"cmdlin rlogin lunet nh_px[0][0]",
1269 if (nhcount > 0 && nh_p2[0]) /* If network type specified */
1270 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
1272 if (nhcount == 1) { /* Still OK, so make substitution */
1273 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1274 debug(F110,"cmdlin rlogin lunet substitution",ttname,0);
1279 if (!haveurl) { /* Service from command line? */
1280 ckstrncat(ttname,":login",TTNAMLEN+1);
1281 debug(F110,"cmdlin rlogin host2",ttname,0);
1283 local = 1; /* Try to open the connection */
1286 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1287 XFATAL("can't open host connection");
1289 network = 1; /* It's open */
1292 #endif /* CKLOGDIAL */
1294 reliable = 1; /* It's reliable */
1295 xreliable = 1; /* ... */
1298 cflg = 1; /* Connect */
1299 stayflg = 1; /* Stay */
1300 tn_exit = 1; /* Telnet-like exit condition */
1302 exitonclose = 1; /* Exit when connection closes */
1305 if (nmac) { /* Any macros defined? */
1307 k = mlook(mactab,"on_open",nmac); /* Look this up */
1308 if (k >= 0) { /* If found, */
1309 if (dodo(k,ttname,0) > -1) /* set it up, */
1310 parser(1); /* and execute it */
1320 #endif /* RLOGCODE */
1321 #endif /* TCPSOCKET */
1324 if (howcalled == I_AM_SSH) { /* If I was called as SSH... */
1325 extern char * ssh_hst, * ssh_cmd, * ssh_prt;
1326 debug(F100,"ssh personality","",0);
1329 makestr(&ssh_hst,g_url.hos);
1330 makestr(&ssh_prt,g_url.svc);
1331 ckstrncpy(ttname,ssh_hst,TTNAMLEN+1);
1332 ckstrncat(ttname,":",TTNAMLEN+1);
1333 ckstrncat(ttname,ssh_prt,TTNAMLEN+1);
1338 while (--xargc > 0) { /* Go through command line words */
1340 debug(F111,"cmdlin ssh xargv",*xargv,xargc);
1343 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1346 else if (**xargv == '/')
1349 /* Got an option (begins with dash) */
1350 else if (**xargv == '-') {
1352 x = *(*xargv+1); /* Get the option letter */
1353 debug(F111,"cmdlin args 1",*xargv,xargc);
1355 debug(F101,"cmdlin doarg","",xx);
1356 debug(F111,"cmdlin args 2",*xargv,xargc);
1359 if (what == W_COMMAND)
1365 sleep(1); /* Give it a chance... */
1367 doexit(BAD_EXIT,1); /* Go handle option */
1370 } else { /* No dash must be hostname */
1371 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1372 makestr(&ssh_hst,ttname);
1373 debug(F110,"cmdlin ssh host",ttname,0);
1376 nhcount = 0; /* Check network directory */
1377 debug(F101,"cmdlin nnetdir","",nnetdir);
1378 if (nnetdir > 0) /* If there is a directory... */
1379 lunet(*xargv); /* Look up the name */
1380 else /* If no directory */
1381 nhcount = 0; /* we didn't find anything there */
1384 debug(F101,"cmdlin lunet nhcount","",nhcount);
1386 debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
1387 debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
1389 "cmdlin lunet nh_px[0][0]",nh_px[0][0],0);
1393 /* If network type specified */
1394 /* it must be TCP/IP */
1395 if (nhcount > 0 && nh_p2[0])
1396 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0))
1398 if (nhcount == 1) { /* Still OK, so make substitution */
1399 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1400 makestr(&ssh_hst,ttname);
1401 debug(F110,"cmdlin lunet substitution",ttname,0);
1405 /* Service from command line? */
1406 if (--xargc > 0 && !haveurl) {
1408 ckstrncat(ttname,":",TTNAMLEN+1);
1409 ckstrncat(ttname,*xargv,TTNAMLEN+1);
1410 makestr(&ssh_prt,*xargv);
1411 debug(F110,"cmdlin telnet host2",ttname,0);
1414 /* Do not substitute net dir service for ssh port */
1417 /* No - how about in net directory? */
1420 ckstrncat(ttname,":",TTNAMLEN+1);
1421 ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
1422 makestr(&ssh_prt,nh_px[0][0]);
1428 #endif /* COMMENT */
1433 local = 1; /* Try to open the connection */
1436 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1437 XFATAL("can't open host connection");
1439 network = 1; /* It's open */
1442 #endif /* CKLOGDIAL */
1444 reliable = 1; /* It's reliable */
1445 xreliable = 1; /* ... */
1448 cflg = 1; /* Connect */
1449 stayflg = 1; /* Stay */
1450 tn_exit = 1; /* Telnet-like exit condition */
1452 exitonclose = 1; /* Exit when connection closes */
1455 if (nmac) { /* Any macros defined? */
1457 k = mlook(mactab,"on_open",nmac); /* Look this up */
1458 if (k >= 0) { /* If found, */
1459 if (dodo(k,ttname,0) > -1) /* set it up, */
1460 parser(1); /* and execute it */
1467 #endif /* SSHBUILTIN */
1469 if (howcalled == I_AM_SSHSUB)
1473 From here down: We were called as "kermit" or "iksd".
1475 If we were started directly from a Kermit script file,
1476 the filename of the script is in argv[1], so skip past it.
1480 if (*xargv[1] != '-') {
1483 /* If we were started with a Kerbang script, the script */
1484 /* arguments were already picked up in prescan / cmdini() */
1485 /* and there is nothing here for us anyway. */
1486 if (!strcmp(xargv[1],"+"))
1488 #endif /* KERBANG */
1490 if (cfilef) { /* Command file found in prescan() */
1491 xargc -= n; /* Skip past it */
1494 debug(F101,"cmdlin cfilef set to 0","",cfilef);
1499 Regular Unix-style command line parser, mostly conforming with 'A Proposed
1500 Command Syntax Standard for Unix Systems', Hemenway & Armitage, Unix/World,
1503 while (--xargc > 0) { /* Go through command line words */
1505 debug(F111,"cmdlin xargv",*xargv,xargc);
1508 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1511 else if (**xargv == '/')
1514 else if (**xargv == '-') { /* Got an option (begins with dash) */
1516 x = *(*xargv+1); /* Get the option letter */
1517 debug(F111,"cmdlin args 1",*xargv,xargc);
1519 debug(F101,"cmdlin doarg","",xx);
1520 debug(F111,"cmdlin args 2",*xargv,xargc);
1523 if (what == W_COMMAND)
1529 sleep(1); /* Give it a chance... */
1531 doexit(BAD_EXIT,1); /* Go handle option */
1534 } else if (!haveurl) { /* No dash where expected */
1538 k = ckstrncpy(xbuf,*xargv,40);
1547 "invalid command-line option, type \"",
1558 debug(F101,"cmdlin what","",what);
1560 debug(F101,"cmdlin action","",action);
1562 debug(F101,"cmdlin stdouf","",stdouf);
1568 if (!action && !cflg && !cnflg) {
1569 debug(F100,"cmdlin NOICP fatal no action","",0);
1570 XFATAL("?No actions specified on command line");
1573 if (inserver && what == 0) { /* Internet Kermit server checks */
1574 if (local || (action != 0 && action != 'x')) {
1576 printf("local\r\n");
1578 printf("action=%c\r\n",action);
1579 debug(F100,"cmdlin fatal 1","",0);
1580 XFATAL("No actions or connections allowed with -A");
1587 if ((action == 'c') || (cflg != 0)) {
1588 debug(F100,"cmdlin fatal 2","",0);
1589 XFATAL("-l or -j or -X required");
1592 #endif /* NOLOCAL */
1595 if ((action != 's') && (action != 'r') && (action != 'v')) {
1596 debug(F100,"cmdlin fatal 3","",0);
1597 XFATAL("-a without -s, -r, or -g");
1599 if (action == 'r' || action == 'v') {
1601 if (isdir(cmarg2)) { /* -a is a directory */
1602 if (!zchdir(cmarg2)) { /* try to change to it */
1603 debug(F100,"cmdlin fatal 4","",0);
1604 XFATAL("can't change to '-a' directory");
1607 #endif /* CK_TMPDIR */
1608 if (zchko(cmarg2) < 0) {
1609 debug(F100,"cmdlin fatal 5","",0);
1610 XFATAL("write access to -a file denied");
1614 if ((action == 'v') && (stdouf) && (!local)) {
1616 debug(F100,"cmdlin fatal 6","",0);
1617 XFATAL("unredirected -k can only be used in local mode");
1620 if ((action == 's') || (action == 'v') ||
1621 (action == 'r') || (action == 'x')) {
1629 if (quiet) displa = 0; /* No display if quiet requested */
1633 debug(F000,"cmdlin returns action","",action);
1635 debug(F101,"cmdlin returns action","",action);
1638 return(action); /* Then do any requested protocol */
1641 /* Extended argument parsing: --keyword[:value] (or =value) */
1644 XA_xxxx symbols are defined in ckuusr.h.
1645 If you add a new one, also remember to update doshow(),
1646 SHXOPT section, in ckuus5.c.
1648 struct keytab xargtab[] = {
1650 { "anonymous", XA_ANON, CM_ARG|CM_PRE },
1651 #endif /* CK_LOGIN */
1652 { "bannerfile", XA_BAFI, CM_ARG },
1653 { "cdfile", XA_CDFI, CM_ARG },
1654 { "cdmessage", XA_CDMS, CM_ARG },
1655 { "cdmsg", XA_CDMS, CM_ARG|CM_INV },
1657 { "changedim", XA_CHGD, CM_PRE },
1660 { "charset", XA_CSET, CM_ARG|CM_PRE },
1661 #endif /* NOCSETS */
1663 { "database", XA_DBAS, CM_ARG|CM_PRE },
1664 { "dbfile", XA_DBFI, CM_ARG|CM_PRE },
1667 { "facename", XA_FNAM, CM_ARG|CM_PRE|CM_INV },
1668 { "fontname", XA_FNAM, CM_ARG|CM_PRE },
1669 { "fontsize", XA_FSIZ, CM_ARG|CM_PRE },
1673 { "ftp", XA_FTP, CM_ARG },
1675 #endif /* COMMENT */
1678 { "height", XA_ROWS, CM_ARG|CM_PRE },
1680 #endif /* NOLOCAL */
1681 { "help", XA_HELP, 0 },
1683 { "helpfile", XA_HEFI, CM_ARG },
1686 { "initfile", XA_ANFI, CM_ARG|CM_PRE },
1687 #endif /* CK_LOGIN */
1689 { "lockdown", XA_LOCK, CM_PRE },
1691 { "maximize", XA_WMAX, CM_PRE },
1692 { "minimize", XA_WMIN, CM_PRE },
1693 { "nobars", XA_NOBAR, CM_PRE },
1694 { "noclose" , XA_NOCLOSE, CM_PRE },
1696 { "noescape", XA_NOESCAPE, CM_PRE },
1698 { "nointerrupts",XA_NOIN, CM_PRE },
1700 { "nomenubar", XA_NOMN, CM_PRE },
1702 { "noperms", XA_NPRM, 0 },
1704 { "nopush", XA_NOPUSH, CM_PRE },
1707 { "noscroll", XA_NOSCROLL, CM_PRE },
1710 { "nostatusbar", XA_NOSB, CM_PRE },
1711 { "notoolbar", XA_NOTB, CM_PRE },
1714 { "password", XA_PASS, CM_ARG|CM_INV },
1715 #endif /* COMMENT */
1719 { "permissions", XA_PERM, CM_ARG|CM_PRE },
1720 { "perms", XA_PERM, CM_ARG|CM_PRE|CM_INV },
1721 #endif /* CK_PERM */
1724 { "privid", XA_PRIV, CM_ARG|CM_PRE },
1728 { "rcharset", XA_CSET, CM_ARG|CM_PRE|CM_INV },
1729 #endif /* NOCSETS */
1730 #endif /* NOLOCAL */
1732 { "root", XA_ROOT, CM_ARG|CM_PRE },
1735 { "root", XA_ROOT, CM_ARG|CM_PRE },
1739 { "scalefont", XA_SCALE, CM_PRE },
1743 { "ssh", XA_SSH, CM_ARG },
1744 #endif /* SSHBUILTIN */
1745 #endif /* COMMENT */
1747 { "syslog", XA_SYSL, CM_ARG|CM_PRE },
1748 #endif /* CKSYSLOG */
1752 { "telnet", XA_TEL, CM_ARG },
1754 #endif /* COMMENT */
1755 { "termtype", XA_TERM, CM_ARG|CM_PRE },
1756 #endif /* NOLOCAL */
1757 { "timeout", XA_TIMO, CM_ARG|CM_PRE },
1760 { "title", XA_TITL, CM_ARG },
1763 { "unbuffered", XA_UNBUF, 0 },
1766 { "user", XA_USER, CM_ARG },
1768 #endif /* NOLOCAL */
1769 { "userfile", XA_USFI, CM_ARG|CM_PRE },
1770 { "version", XA_VERS, 0 },
1773 { "width", XA_COLS, CM_ARG|CM_PRE },
1775 #endif /* NOLOCAL */
1777 { "wtmpfile", XA_WTFI, CM_ARG|CM_PRE },
1778 { "wtmplog", XA_WTMP, CM_ARG|CM_PRE },
1780 #endif /* CK_LOGIN */
1781 { "xferfile", XA_IKFI, CM_ARG|CM_PRE },
1782 { "xferlog", XA_IKLG, CM_ARG|CM_PRE },
1785 { "xpos", XA_XPOS, CM_ARG|CM_PRE },
1786 { "ypos", XA_YPOS, CM_ARG|CM_PRE },
1788 #endif /* NOLOCAL */
1791 int nxargs = sizeof(xargtab)/sizeof(struct keytab) - 1;
1793 static struct keytab oktab[] = {
1812 static int noktab = sizeof(oktab)/sizeof(struct keytab);
1816 char * xopthlp[XA_MAX+1]; /* Extended option help */
1817 char * xarghlp[XA_MAX+1]; /* Extended argument for option */
1822 for (i = 0; i <= XA_MAX; i++) { /* Initialize all to null */
1826 for (i = 0; i < nxargs; i++) { /* Then for each defined keyword */
1827 j = xargtab[i].kwval; /* index by associated value */
1828 if (j < 0 || j > XA_MAX)
1832 case XA_ANON: /* "--anonymous" */
1833 xopthlp[j] = "--anonymous:{on,off} [IKSD only]";
1834 xarghlp[j] = "Whether to allow anonymous IKSD logins";
1838 xopthlp[j] = "--privid:{on,off} [IKSD only]";
1839 xarghlp[j] = "Whether to allow privileged IDs to login to IKSD";
1842 #endif /* CK_LOGIN */
1843 case XA_BAFI: /* "--bannerfile" */
1844 xopthlp[j] = "--bannerfile:<filename>";
1845 xarghlp[j] = "File to display upon startup or IKSD login";
1847 case XA_CDFI: /* "--cdfile" */
1848 xopthlp[j] = "--cdfile:<filename>";
1849 xarghlp[j] = "File to display when server changes directory";
1851 case XA_CDMS: /* "--cdmessage" */
1852 xopthlp[j] = "--cdmessage:{on,off}";
1853 xarghlp[j] = "Whether to display CD message file";
1855 case XA_HELP: /* "--help" */
1856 xopthlp[j] = "--help";
1857 xarghlp[j] = "Print this help text about extended options";
1859 case XA_HEFI: /* "--help" */
1860 xopthlp[j] = "--helpfile:<filename>";
1861 xarghlp[j] = "File containing custom info for HELP command";
1863 case XA_IKFI: /* "--xferfile" */
1864 xopthlp[j] = "--xferfile:<filename> [IKSD only]";
1865 xarghlp[j] = "Name of ftpd-like logfile.";
1867 case XA_IKLG: /* "--xferlog" */
1868 xopthlp[j] = "--xferlog:{on,off} [IKSD only]";
1869 xarghlp[j] = "Whether to keep an ftpd-like logfile.";
1872 case XA_ANFI: /* "--initfile" */
1873 xopthlp[j] = "--initfile:<filename> [IKSD only]";
1874 xarghlp[j] = "Initialization file for anonymous users.";
1877 case XA_PERM: /* "--permissions" */
1878 xopthlp[j] = "--permissions:<octalnum> [IKSD only]";
1879 xarghlp[j] = "Permissions for files uploaded by anonymous users.";
1881 #endif /* CK_PERM */
1883 case XA_ROOT: /* "--root" */
1884 xopthlp[j] = "--root:<directory> [IKSD only]";
1885 xarghlp[j] = "File-system root for anonymous users.";
1889 case XA_ROOT: /* "--root" */
1890 xopthlp[j] = "--root:<directory> [IKSD only]";
1891 xarghlp[j] = "File-system root for anonymous users.";
1895 #endif /* CK_LOGIN */
1897 case XA_SYSL: /* "--syslog" */
1898 xopthlp[j] = "--syslog:<digit> [IKSD only]";
1899 xarghlp[j] = "Syslog recording level, 0-6.";
1901 #endif /* CKSYSLOG */
1902 case XA_USFI: /* "--userfile" */
1903 xopthlp[j] = "--userfile:<filename> [IKSD only]";
1904 xarghlp[j] = "Forbidden user file.";
1907 case XA_WTFI: /* "--wtmpfile" */
1908 xopthlp[j] = "--wtmpfile:<filename> [IKSD only]";
1909 xarghlp[j] = "Name of wtmp logfile.";
1911 case XA_WTMP: /* "--wtmplog" */
1912 xopthlp[j] = "--wtmplog:{on,off} [IKSD only]";
1913 xarghlp[j] = "Whether to keep a wtmp logfile.";
1917 case XA_TIMO: /* "--timeout" */
1918 xopthlp[j] = "--timeout:<seconds> [IKSD only]";
1920 "How long to wait for login before closing the connection.";
1922 #endif /* CK_LOGIN */
1924 xopthlp[j] = "--nointerrupts";
1925 xarghlp[j] = "Disable keyboard interrupts.";
1929 xopthlp[j] = "--unbuffered";
1930 xarghlp[j] = "Force unbuffered console i/o.";
1935 xopthlp[j] = "--database:{on,off}";
1936 xarghlp[j] = "Enable/Disable IKSD database (IKSD only)";
1939 xopthlp[j] = "--dbfile:<filename>";
1940 xarghlp[j] = "Specify IKSD database file (IKSD only)";
1945 xopthlp[j] = "--noperms";
1946 xarghlp[j] = "Disable file-transfer Permissions attribute.";
1948 #endif /* CK_PERMS */
1951 xopthlp[j] = "--changedim";
1952 xarghlp[j] = "Change Dimension on Window Resize";
1954 xopthlp[j] = "--scalefont";
1955 xarghlp[j] = "Scale Font on Window Resize";
1957 xopthlp[j] = "--maximize";
1958 xarghlp[j] = "start K95G window maximized.";
1961 xopthlp[j] = "--minimize";
1962 xarghlp[j] = "start K95G window minimized.";
1965 xopthlp[j] = "--xpos:n";
1966 xarghlp[j] = "X-coordinate of window position (number).";
1969 xopthlp[j] = "--ypos:n";
1970 xarghlp[j] = "Y-coordinate of window position (number).";
1973 xopthlp[j] = "--fontname:s (or --facename:s)";
1974 xarghlp[j] = "Font/typeface name: string with _ replacing blank.";
1977 xopthlp[j] = "--fontsize:n";
1978 xarghlp[j] = "Font point size (number).";
1981 xopthlp[j] = "--nomenubar";
1982 xarghlp[j] = "No Menu Bar";
1985 xopthlp[j] = "--notoolbar";
1986 xarghlp[j] = "No Tool Bar";
1989 xopthlp[j] = "--nostatusbar";
1990 xarghlp[j] = "No Status Bar";
1993 xopthlp[j] = "--nobars";
1994 xarghlp[j] = "No Menu, Status, or Tool Bars";
1999 xopthlp[j] = "--nopush";
2000 xarghlp[j] = "Disable external command execution.";
2005 xopthlp[j] = "--lockdown";
2006 xarghlp[j] = "Enable all lockdown options.";
2009 xopthlp[j] = "--noclose";
2010 xarghlp[j] = "Disable Close Window and Menu Exit.";
2013 xopthlp[j] = "--noscroll";
2014 xarghlp[j] = "Disable scrollback operations.";
2017 xopthlp[j] = "--noescape";
2018 xarghlp[j] = "Disable escape from connect mode.";
2021 xopthlp[j] = "--height:n";
2022 xarghlp[j] = "Screen height (number of rows).";
2025 xopthlp[j] = "--width:n";
2026 xarghlp[j] = "Screen width (number of columns).";
2029 xopthlp[j] = "--title:string";
2030 xarghlp[j] = "Window Title.";
2034 xopthlp[j] = "--rcharset:name";
2035 xarghlp[j] = "Name of remote terminal character set.";
2038 xopthlp[j] = "--termtype:name";
2040 xarghlp[j] = "Choose terminal emulation.";
2042 xarghlp[j] = "Choose terminal type.";
2046 xopthlp[j] = "--user:name";
2048 xarghlp[j] = "Username (for network login)";
2050 xarghlp[j] = "Username.";
2051 #endif /* NETCONN */
2060 for (i = 0; i < 128; i++) {
2064 case '#': /* K95 Startup Flags */
2065 opthlp[i] = "Kermit 95 Startup Flags";
2067 " 1 - turn off Win95 special fixes\n"\
2068 " 2 - do not load optional network dlls\n"\
2069 " 4 - do not load optional tapi dlls\n"\
2070 " 8 - do not load optional kerberos dlls\n"\
2071 " 16 - do not load optional zmodem dlls\n"\
2072 " 32 - use stdin for input instead of the console\n"\
2073 " 64 - use stdout for output instead of the console\n"\
2074 " 128 - do not terminate process in response to Session Logoff";
2077 case '0': /* In the middle */
2079 "100% transparent CONNECT mode for \"in-the-middle\" operation";
2084 opthlp[i] = "Connection is 8-bit clean";
2090 opthlp[i] = "Make a connection to an FTP server";
2091 arghlp[i] = "IP-address-or-hostname[:optional-TCP-port]";
2097 opthlp[i] = "Kermit is to be started as an Internet service";
2099 arghlp[i] = " socket handle of incoming connection";
2105 case 'B': opthlp[i] =
2106 "Kermit is running in Batch or Background (no controlling terminal)";
2110 opthlp[i] = "Interactive-mode Commands to be executed";
2111 arghlp[i] = "Commands separated by commas, list in doublequotes";
2115 opthlp[i] = "Delay before starting to send";
2116 arghlp[i] = "Number of seconds";
2119 opthlp[i] = "Exit automatically when connection closes";
2124 opthlp[i] = "Use an existing TCP connection";
2125 arghlp[i] = "Numeric file descriptor of open TCP connection";
2127 #endif /* TCPSOCKET */
2129 opthlp[i] = "GET from server, send to standard output";
2130 arghlp[i] = "Remote file specification";
2134 opthlp[i] = "Suppress program startup Herald and greeting";
2138 opthlp[i] = "Connection is reliable, streaming is allowed";
2143 opthlp[i] = "'Be like Telnet'";
2144 arghlp[i] = "IP hostname/address optionally followed by service";
2146 #endif /* TCPSOCKET */
2148 opthlp[i] = "Recursive directory descent for files in -s option";
2152 opthlp[i] = "My user name (for use with Telnet, Rlogin, etc)";
2153 arghlp[i] = "Username string";
2157 opthlp[i] = "NETBIOS adapter number";
2158 arghlp[i] = "Number";
2160 #endif /* NETBIOS */
2161 case 'O': /* Be a server for One command only */
2162 opthlp[i] = "Be a server for One command only";
2167 opthlp[i] = "Don't convert file (Path) names";
2171 opthlp[i] = "Quick (FAST) Kermit protocol settings";
2174 case 'R': /* Remote-Only */
2175 opthlp[i] = "Remote-only (makes IF REMOTE true)";
2178 case 'S': /* "Stay" - enter interactive */
2179 opthlp[i] = "Stay (enter command parser after action options)";
2182 case 'T': /* Text file transfer mode */
2183 opthlp[i] = "Transfer files in Text mode";
2187 case 'U': /* X.25 call user data */
2188 opthlp[i] = "X.25 call User data";
2189 arghlp[i] = "Call-user-data string";
2192 case 'V': /* No automatic filetype switching */
2193 opthlp[i] = "Disable automatic per-file text/binary switching";
2198 case 'W': /* Win32 Window Handle */
2203 #endif /* COMMENT */
2205 case 'X': /* SET HOST to X.25 address */
2206 opthlp[i] = "Make an X.25 connection";
2207 arghlp[i] = "X.25 or X.121 address";
2210 case 'Y': /* No initialization file */
2211 opthlp[i] = "Skip initialization file";
2215 case 'Z': /* SET HOST to X.25 file descriptor */
2216 opthlp[i] = "Make an X.25 connection";
2217 arghlp[i] = "Numeric file descriptor of open X.25 connection";
2220 case 'a': /* as-name */
2221 opthlp[i] = "As-name for file(s) in -s, -r, or -g";
2222 arghlp[i] = "As-name string (alternative filename)";
2224 case 'b': /* Set bits-per-second for serial */
2225 opthlp[i] = "Speed for serial device";
2226 arghlp[i] = "Numeric Bits per second";
2228 case 'c': /* Connect before */
2230 opthlp[i] = "CONNECT before transferring files";
2233 case 'd': /* DEBUG */
2234 opthlp[i] = "Create debug.log file (a second -d adds timestamps)";
2237 case 'e': /* Extended packet length */
2238 opthlp[i] = "Maximum length for incoming file-transfer packets";
2239 arghlp[i] = "Length in bytes";
2241 case 'f': /* finish */
2243 opthlp[i] = "Send Finish command to a Kermit server";
2248 opthlp[i] = "GET file(s) from a Kermit server";
2249 arghlp[i] = "Remote file specification";
2251 case 'h': /* help */
2255 "Print this message (pipe thru 'more' to prevent scrolling)";
2257 "Print this message";
2258 #endif /* OS2ORUNIX */
2261 case 'i': /* Treat files as binary */
2262 opthlp[i] ="Transfer files in binary mode";
2266 case 'j': /* SET HOST (TCP/IP socket) */
2267 opthlp[i] = "Make a TCP connection";
2269 "TCP host name/address and optional service name or number";
2271 #endif /* TCPSOCKET */
2272 case 'k': /* receive to stdout */
2274 opthlp[i] = "RECEIVE file(s) to standard output";
2277 case 'l': /* SET LINE */
2278 opthlp[i] = "Make connection on serial communications device";
2279 arghlp[i] = "Serial device name";
2281 case 'm': /* Modem type */
2282 opthlp[i] = "Modem type for use with -l device";
2283 arghlp[i] = "Modem name as in SET MODEM TYPE command";
2285 case 'n': /* connect after */
2287 opthlp[i] = "CONNECT after transferring files";
2291 case 'o': /* X.25 closed user group */
2292 opthlp[i] = "X.25 closed user group";
2293 arghlp[i] = "User group string";
2296 case 'p': /* SET PARITY */
2297 opthlp[i] = "Parity";
2298 arghlp[i] = "One of the following: even, odd, mark, none, space";
2300 case 'q': /* Quiet */
2301 opthlp[i] = "Quiet (suppress most messages)";
2304 case 'r': /* receive */
2306 opthlp[i] = "RECEIVE file(s)";
2309 case 's': /* send */
2311 opthlp[i] = "SEND file(s)";
2312 arghlp[i] = "One or more file specifications";
2314 case 't': /* Line turnaround handshake */
2315 opthlp[i] = "XON Turnaround character for half-duplex connections";
2319 case 'u': /* X.25 reverse charge call */
2320 opthlp[i] = "X.25 reverse charge call";
2324 case 'v': /* Vindow size */
2325 opthlp[i] = "Window size";
2326 arghlp[i] = "Number, 1 to 32";
2328 case 'w': /* Writeover */
2329 opthlp[i] = "Incoming files Write over existing files";
2332 case 'x': /* Server */
2334 opthlp[i] = "Be a Kermit SERVER";
2337 case 'y': /* Alternate init-file name */
2338 opthlp[i] = "Alternative initialization file";
2339 arghlp[i] = "File specification";
2341 case 'z': /* Not background */
2342 opthlp[i] = "Force foreground behavior";
2354 doxarg(s,pre) char ** s; int pre; {
2357 extern int ckxsyslog, ckxwtmp, ckxanon;
2362 extern int ckxperms;
2363 #endif /* CK_PERMS */
2364 extern char * anonfile, * userfile, * anonroot;
2365 #endif /* CK_LOGIN */
2367 extern char * wtmpfile;
2370 extern int srvcdmsg;
2371 extern char * cdmsgfile[], * cdmsgstr;
2372 char tmpbuf[CKMAXPATH+1];
2374 int i, x, y, z, havearg = 0;
2375 char buf[XARGBUFL], c, * p;
2380 c = *(*s + 1); /* Hyphen or Plus sign */
2383 for (i = 0; *p && i < XARGBUFL; i++) {
2385 if (buf[i] == '=' || buf[i] == ':') {
2389 } else if (buf[i] < ' ') {
2394 if (i > XARGBUFL - 1)
2398 x = lookup(xargtab,buf,nxargs,&z); /* Lookup the option keyword */
2400 if (x < 0) /* On any kind of error */
2401 return(-1); /* fail. */
2403 /* Handle prescan versus post-initialization file */
2405 if (((xargtab[z].flgs & CM_PRE) || (c == '+')) && !pre)
2407 else if (pre && !(xargtab[z].flgs & CM_PRE) && (c != '+'))
2410 /* Ensure that argument is given if and only if required */
2412 p = havearg ? *s + i + 3 : NULL;
2414 if ((xargtab[z].flgs & CM_ARG) && !havearg)
2416 else if ((!(xargtab[z].flgs & CM_ARG)) && havearg)
2419 switch (x) { /* OK to process this option... */
2421 case XA_SYSL: /* IKS: Syslog level */
2425 if (*p < '0' || *p > '9')
2427 y = y * 10 + (*p++ - '0');
2430 y = lookup(oktab,p,noktab,&z);
2431 if (y > 0) y = SYSLG_DF; /* Yes = default logging level */
2434 /* If specified on cc command line, user can't change it. */
2435 if (!inserver) /* Don't allow voluminous syslogging */
2436 if (y > SYSLG_FA) /* by ordinary users. */
2438 #endif /* SYSLOGLEVEL */
2439 if (y < 0) return(-1);
2443 deblog = debopn("debug.log",0);
2446 /* If specified on cc command line, user can't change it. */
2448 #endif /* SYSLOGLEVEL */
2450 /* printf("ckxsyslog=%d\n",ckxsyslog); */
2452 #endif /* CKSYSLOG */
2456 case XA_WTMP: /* IKS: wtmp log */
2457 y = lookup(oktab,p,noktab,&z);
2458 if (y < 0) return(-1);
2460 /* printf("ckxwtmp=%d\n",ckxwtmp); */
2463 case XA_WTFI: /* IKS: wtmp logfile */
2464 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2466 makestr(&wtmpfile,p);
2467 /* printf("wtmpfile=%s\n",wtmpfile); */
2471 case XA_ANON: /* IKS: Anonymous login allowed */
2472 y = lookup(oktab,p,noktab,&z);
2473 if (y < 0) return(-1);
2475 /* printf("ckxanon=%d\n",ckxanon); */
2479 case XA_PRIV: /* IKS: Priv'd login allowed */
2480 y = lookup(oktab,p,noktab,&z);
2481 if (y < 0) return(-1);
2483 /* printf("ckxpriv=%d\n",ckxpriv); */
2488 case XA_PERM: /* IKS: Anonymous Upload Permissions */
2491 if (*p < '0' || *p > '7')
2493 y = y * 8 + (*p++ - '0');
2496 /* printf("ckxperms=%04o\n",ckxperms); */
2498 #endif /* CK_PERMS */
2500 case XA_ANFI: /* Anonymous init file */
2502 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2504 makestr(&anonfile,p);
2505 /* printf("anonfile=%s\n",anonfile); */
2508 case XA_USFI: /* IKS: Forbidden user file */
2510 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2512 makestr(&userfile,p);
2513 /* printf("userfile=%s\n",userfile); */
2516 case XA_ROOT: /* IKS: Anonymous root */
2518 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2520 makestr(&anonroot,p);
2521 /* printf("anonroot=%s\n",anonroot); */
2523 #endif /* CK_LOGIN */
2525 case XA_CDFI: /* CD filename */
2527 /* Do NOT expand this one! */
2528 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2530 #endif /* COMMENT */
2531 makelist(p,cdmsgfile,16);
2532 makestr(&cdmsgstr,p);
2533 /* printf("cdmsgstr=%s\n",cdmsgstr); */
2536 case XA_CDMS: /* CD messages */
2537 y = lookup(oktab,p,noktab,&z);
2538 if (y < 0) return(-1);
2540 /* printf("srvcdmsg=%d\n",srvcdmsg); */
2544 case XA_IKLG: /* Transfer log on/off */
2545 y = lookup(oktab,p,noktab,&z);
2546 if (y < 0) return(-1);
2548 /* printf("xferlog=%d\n",xferlog); */
2551 case XA_IKFI: /* Transfer log file */
2553 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2555 makestr(&xferfile,p);
2557 /* printf("xferfile=%s\n",xferfile); */
2560 case XA_BAFI: /* IKS: banner (greeting) file */
2562 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2564 makestr(&bannerfile,p);
2565 /* printf("bannerfile=%s\n",bannerfile); */
2570 case XA_HELP: /* Help */
2571 /* printf("help\n"); */
2572 for (i = 0; i <= XA_MAX; i++)
2574 printf("%s\n %s\n\n",xopthlp[i],xarghlp[i]);
2575 if (stayflg || what == W_COMMAND)
2578 doexit(GOOD_EXIT,-1);
2582 case XA_HEFI: /* IKS: custom help file */
2584 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2586 makestr(&helpfile,p);
2587 /* printf("helpfile=%s\n",helpfile); */
2595 logintimo = atoi(p);
2596 /* printf("logintimo=%d\n",p); */
2598 #endif /* CK_LOGIN */
2600 case XA_NOIN: /* No interrupts */
2608 case XA_UNBUF: /* Unbuffered console i/o*/
2609 break; /* This one is handled in ckcmai.c */
2614 extern char * dbdir, * dbfile;
2615 extern int dbenabled;
2617 if ((zz = zfnqfp(p,CKMAXPATH,tmpbuf))) {
2618 char *s, *s2 = NULL;
2619 makestr(&dbdir,zz->fpath);
2620 makestr(&dbfile,zz->fpath);
2621 for (s = dbdir; *s; s++) {
2626 debug(F110,"XA_DBFI dbdir",dbdir,0);
2627 debug(F110,"XA_DBFI dbfile",dbfile,0);
2633 extern int dbenabled;
2634 y = lookup(oktab,p,noktab,&z);
2635 if (y < 0) return(-1);
2642 extern char * ck_s_ver, * ck_s_xver;
2643 printf("%s",ck_s_ver);
2645 printf(" [%s]\n",ck_s_xver);
2647 if (stayflg || what == W_COMMAND)
2650 doexit(GOOD_EXIT,-1);
2655 extern int atlpri, atlpro, atgpri, atgpro;
2662 #endif /* CK_PERMS */
2667 kui_init.resizeMode = 1;
2670 kui_init.resizeMode = 2;
2673 kui_init.nCmdShow = SW_MAXIMIZE;
2676 kui_init.nCmdShow = SW_MINIMIZE;
2682 kui_init.pos_init++;
2683 kui_init.pos_x = atoi(p);
2689 kui_init.pos_init++;
2690 kui_init.pos_y = atoi(p);
2694 extern struct _kui_init kui_init;
2695 extern struct keytab * term_font;
2696 extern struct keytab * _term_font;
2697 extern int tt_font, ntermfont;
2700 BuildFontTable(&term_font, &_term_font, &ntermfont);
2701 if (!(term_font && _term_font && ntermfont > 0)) {
2702 printf("?Unable to construct Font Facename Table\n");
2705 x = lookup(term_font,p,ntermfont,&z);
2707 x = lookup(_term_font,p,ntermfont,&z);
2709 printf("?Invalid Font Facename: %s\n",p);
2714 kui_init.face_init++;
2715 makestr(&kui_init.facename,term_font[z].kwd);
2719 extern struct _kui_init kui_init;
2720 extern int tt_font_size;
2724 kui_init.font_init++;
2725 for ( q=p ; *q ; q++ ) {
2730 if (!*q || atoi(q) == 0)
2731 break; /* no halfpoint */
2734 printf("? Font sizes are treated in half-point increments\n");
2740 tt_font_size = kui_init.font_size = 2 * atoi(p) + halfpoint;
2744 kui_init.nomenubar = 1;
2747 kui_init.notoolbar = 1;
2750 kui_init.nostatusbar = 1;
2753 kui_init.nomenubar = 1;
2754 kui_init.notoolbar = 1;
2755 kui_init.nostatusbar = 1;
2772 kui_init.nomenubar = 1;
2773 kui_init.notoolbar = 1;
2774 kui_init.nostatusbar = 1;
2779 kui_init.noclose = 1;
2791 case XA_TERM: { /* Terminal type */
2792 extern struct keytab ttyptab[];
2795 extern char * tn_term;
2799 extern int tt_type, tt_type_mode;
2800 x = lookup(ttyptab,p,nttyp,&z);
2803 tt_type_mode = tt_type = x;
2806 makestr(&tn_term,p);
2810 case XA_CSET: { /* Remote Character Set */
2813 extern struct keytab txrtab[];
2815 x = lookup(txrtab,p,ntxrtab,&z);
2817 extern struct keytab ttcstab[];
2819 x = lookup(ttcstab,p,ntermc,&z);
2823 setremcharset(z,4 /* TT_GR_ALL (in ckuus7.c) */);
2826 #endif /* NOCSETS */
2829 case XA_ROWS: { /* Screen rows (height) */
2831 extern int row_init;
2838 if (!os2_settermheight(atoi(p)))
2841 #else /* Not OS/2 */
2846 case XA_COLS: { /* Screen columns (width) */
2848 extern int col_init;
2855 if (!os2_settermwidth(atoi(p)))
2858 #else /* Not OS/2 */
2865 extern char usertitle[];
2866 ckstrncpy(usertitle,p,64);
2872 #ifdef COMMENT /* TO BE FILLED IN ... */
2873 case XA_TEL: /* Make a Telnet connection */
2874 case XA_FTP: /* Make an FTP connection */
2875 case XA_SSH: /* Make an SSH connection */
2876 #endif /* COMMENT */
2879 case XA_USER: /* Username for login */
2884 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
2889 #endif /* NOLOCAL */
2921 #define IKS_NTDOM 22
2925 static struct keytab iksantab[] = {
2927 { "account", IKS_ACCT, 0 },
2929 { "initfile", IKS_ANFI, 0 },
2930 { "login", IKS_ANLG, 0 },
2932 { "root", IKS_ROOT, 0 },
2935 { "root", IKS_ROOT, 0 },
2940 static int niksantab = sizeof(iksantab) / sizeof(struct keytab) - 1;
2941 #endif /* CK_LOGIN */
2943 static struct keytab ikstab[] = {
2945 { "anonymous", IKS_ANON, 0 },
2946 #endif /* CK_LOGIN */
2947 { "bannerfile", IKS_BAFI, 0 },
2948 { "cdfile", IKS_CDFI, 0 },
2949 { "cdmessage", IKS_CDMS, 0 },
2950 { "cdmsg", IKS_CDMS, CM_INV },
2952 { "database", IKS_DBAS, 0 },
2953 { "dbfile", IKS_DBFI, 0 },
2957 { "default-domain", IKS_NTDOM, 0 },
2959 #endif /* CK_LOGIN */
2961 { "helpfile", IKS_HEFI, 0 },
2963 { "initfile", IKS_INIT, 0 },
2964 { "no-initfile", IKS_NOIN, 0 },
2967 { "permissions", IKS_PERM, 0 },
2968 { "perms", IKS_PERM, CM_INV },
2969 #endif /* CK_PERM */
2971 { "privid", IKS_PRIV, 0 },
2973 { "server-only", IKS_SRVR, 0 },
2975 { "syslog", IKS_SYSL, 0 },
2976 #endif /* CKSYSLOG */
2977 { "timeout", IKS_TIMO, 0 },
2978 { "userfile", IKS_USFI, 0 },
2980 { "wtmpfile", IKS_WTFI, 0 },
2981 { "wtmplog", IKS_WTMP, 0 },
2983 #endif /* CK_LOGIN */
2984 { "xferfile", IKS_IKFI, 0 },
2985 { "xferlog", IKS_IKLG, 0 }
2987 static int nikstab = sizeof(ikstab) / sizeof(struct keytab);
2988 #endif /* IKSDCONF */
2992 setiks() { /* SET IKS */
2995 extern int ckxsyslog, ckxwtmp, ckxanon;
3000 extern int ckxperms;
3001 #endif /* CK_PERMS */
3002 extern char * anonfile, * userfile, * anonroot;
3004 extern char * anonacct;
3007 extern char * iks_domain;
3009 #endif /* CK_LOGIN */
3011 extern char * wtmpfile;
3013 extern int srvcdmsg, success, iksdcf, rcflag, noinit, arg_x;
3014 extern char * cdmsgfile[], * cdmsgstr, *kermrc;
3015 extern xx_strp xxstring;
3018 char tmpbuf[CKMAXPATH+1];
3020 if ((y = cmkey(ikstab,nikstab,"","",xxstring)) < 0)
3024 if (y == IKS_ANON) {
3025 if ((y = cmkey(iksantab,niksantab,"","",xxstring)) < 0)
3028 #endif /* CK_LOGIN */
3032 case IKS_SYSL: /* IKS: Syslog level */
3033 if ((z = cmkey(oktab,noktab,"","",xxstring)) < 0)
3035 if ((x = cmcfm()) < 0) return(x);
3036 if (iksdcf) return(success = 0);
3038 /* If specified on cc command line, user can't change it. */
3039 if (!inserver) /* Don't allow voluminous syslogging */
3040 if (y > SYSLG_FA) /* by ordinary users. */
3042 #endif /* SYSLOGLEVEL */
3043 if (y < 0) return(-1);
3047 deblog = debopn("debug.log",0);
3050 /* If specified on cc command line, user can't change it. */
3052 #endif /* SYSLOGLEVEL */
3054 /* printf("ckxsyslog=%d\n",ckxsyslog); */
3056 #endif /* CKSYSLOG */
3062 "DOMAIN to be used for user authentication when none is specified",
3063 "", &s,xxstring)) < 0)
3065 if (iksdcf) return(success = 0);
3067 makestr(&iks_domain,s);
3072 if ((z = cmtxt("Name of local account to use for anonymous logins",
3073 "GUEST", &s,xxstring)) < 0)
3075 if (iksdcf) return(success = 0);
3077 makestr(&anonacct,s);
3078 } else if ( anonacct ) {
3085 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3087 if ((x = cmcfm()) < 0) return(x);
3088 if (iksdcf) return(success = 0);
3091 if (ckxanon && !anonacct)
3092 makestr(&anonacct,"GUEST");
3095 #endif /* CK_LOGIN */
3097 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3100 printf("?Wildcards not allowed\n");
3103 debug(F110,"bannerfile before zfnqfp()",s,0);
3104 if (zfnqfp(s,CKMAXPATH,tmpbuf)) {
3105 debug(F110,"bannerfile after zfnqfp()",tmpbuf,0);
3108 if ((x = cmcfm()) < 0) return(x);
3109 if (iksdcf) return(success = 0);
3111 makestr(&bannerfile,s);
3114 if ((z = cmtxt("list of cd message file names","READ.ME",
3117 if (iksdcf) return(success = 0);
3119 makelist(s,cdmsgfile,16);
3120 makestr(&cdmsgstr,s);
3124 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3126 if ((x = cmcfm()) < 0) return(x);
3127 if (iksdcf) return(success = 0);
3131 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3134 printf("?Wildcards not allowed\n");
3137 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3139 if ((x = cmcfm()) < 0) return(x);
3140 if (iksdcf) return(success = 0);
3142 makestr(&helpfile,s);
3145 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3148 printf("?Wildcards not allowed\n");
3151 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3153 if ((x = cmcfm()) < 0) return(x);
3154 if (iksdcf) return(success = 0);
3156 makestr(&anonfile,s);
3159 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3162 printf("?Wildcards not allowed\n");
3165 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3167 if ((x = cmcfm()) < 0) return(x);
3168 if (iksdcf) return(success = 0);
3170 makestr(&userfile,s);
3173 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3176 printf("?Wildcards not allowed\n");
3179 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3181 if ((x = cmcfm()) < 0) return(x);
3182 if (iksdcf) return(success = 0);
3184 makestr(&xferfile,s);
3189 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3191 if ((x = cmcfm()) < 0) return(x);
3192 if (iksdcf) return(success = 0);
3199 if ((z = cmtxt("Octal file permssion code","000",
3202 if (z < 0) return(z);
3203 if (iksdcf) return(success = 0);
3206 if (*s < '0' || *s > '7')
3208 y = y * 8 + (*s++ - '0');
3212 #endif /* CK_PERM */
3214 case IKS_PRIV: /* IKS: Priv'd login allowed */
3215 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3217 if ((x = cmcfm()) < 0) return(x);
3218 if (iksdcf) return(success = 0);
3223 case IKS_ROOT: /* IKS: Anonymous root */
3224 if ((z = cmdir("Name of disk and/or directory","",&s,
3230 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3234 if ((x = cmcfm()) < 0) return(x);
3235 if (iksdcf) return(success = 0);
3237 makestr(&anonroot,s);
3238 /* printf("anonroot=%s\n",anonroot); */
3242 z = cmnum("login timeout, seconds","0",10,&x,xxstring);
3243 if (z < 0) return(z);
3244 if (x < 0 || x > 7200) {
3245 printf("?Value must be between 0 and 7200\r\n");
3248 if ((z = cmcfm()) < 0) return(z);
3249 if (iksdcf) return(success = 0);
3254 case IKS_WTMP: /* IKS: wtmp log */
3255 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3257 if ((x = cmcfm()) < 0) return(x);
3258 if (iksdcf) return(success = 0);
3262 case IKS_WTFI: /* IKS: wtmp logfile */
3263 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3266 printf("?Wildcards not allowed\n");
3269 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3271 if ((x = cmcfm()) < 0) return(x);
3272 if (iksdcf) return(success = 0);
3274 makestr(&wtmpfile,s);
3277 #endif /* CK_LOGIN */
3280 extern char * dbdir, * dbfile;
3281 extern int dbenabled;
3283 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3286 printf("?Wildcards not allowed\n");
3289 zz = zfnqfp(s,CKMAXPATH,tmpbuf);
3290 if ((x = cmcfm()) < 0) return(x);
3291 if (iksdcf) return(success = 0);
3293 makestr(&dbdir,zz->fpath);
3294 makestr(&dbfile,(char *)tmpbuf);
3297 return(success = 0);
3301 extern int dbenabled;
3302 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3304 if ((x = cmcfm()) < 0) return(x);
3305 if (iksdcf) return(success = 0);
3312 if ((z = cmtxt("Alternate init file specification","",
3315 if (z < 0) return(z);
3316 if (iksdcf) return(success = 0);
3317 ckstrncpy(kermrc,s,KERMRCL);
3318 rcflag = 1; /* Flag that this has been done */
3322 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3324 if ((x = cmcfm()) < 0) return(x);
3325 if (iksdcf) return(success = 0);
3330 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3332 if ((x = cmcfm()) < 0) return(x);
3333 if (iksdcf) return(success = 0);
3340 return(success = (inserver ? 1 : 0));
3341 #else /* IKSDCONF */
3342 if ((x = cmcfm()) < 0)
3344 return(success = 0);
3345 #endif /* IKSDCONF */
3350 /* D O A R G -- Do a command-line argument. */
3357 #endif /* CK_ANSIC */
3359 int i, n, y, z, xx; long zz; char *xp;
3362 extern char *line, *tmpbuf; /* Character buffers for anything */
3363 #endif /* NETCONN */
3366 /* Internet Kermit Server set some way besides -A... */
3371 xp = *xargv+1; /* Pointer for bundled args */
3372 debug(F111,"doarg entry",xp,xargc);
3374 debug(F000,"doarg arg","",x);
3375 switch (x) { /* Big switch on arg */
3378 case '-': /* Extended commands... */
3379 if (doxarg(xargv,0) < 0) {
3380 XFATAL("Extended option error");
3381 } /* Full thru... */
3382 case '+': /* Extended command for prescan() */
3387 XFATAL("Extended options not configured");
3391 case 'C': { /* Commands for parser */
3394 if ((xargc < 1) || (**xargv == '-')) {
3395 XFATAL("No commands given for -C");
3397 s = *xargv; /* Get the argument (must be quoted) */
3398 if (!*s) /* If empty quotes */
3399 s = NULL; /* ignore this option */
3401 makestr(&clcmds,s); /* Make pokeable copy */
3402 s = clcmds; /* Change tabs to spaces */
3404 if (*s == '\t') *s = ' ';
3413 case 'D': /* Delay */
3415 XFATAL("invalid argument bundling");
3418 if ((xargc < 1) || (**xargv == '-')) {
3419 XFATAL("missing delay value");
3421 z = atoi(*xargv); /* Convert to number */
3422 if (z > -1) /* If in range */
3423 ckdelay = z; /* set it */
3425 XFATAL("bad delay value");
3430 case 'E': /* Exit on close */
3433 #endif /* NETCONN */
3438 case 'S': /* "Stay" - enter interactive */
3439 stayflg = 1; /* command parser after executing */
3440 xfinish = 0; /* command-line actions. */
3444 case 'T': /* File transfer mode = text */
3446 xfermode = XMODE_M; /* Transfer mode manual */
3450 #endif /* PATTERNS */
3457 case 'A': { /* Internet server */
3458 /* Already done in prescan() */
3459 /* but implies 'x' && 'Q' */
3463 XFATAL("invalid argument bundling");
3466 /* Support for Pragma Systems Telnet/Terminal Servers */
3467 p = getenv("PRAGMASYS_INETD_SOCK");
3468 if (!(p && atoi(p) != 0)) {
3470 if (xargc < 1 || **xargv == '-') {
3471 XFATAL("missing socket handle");
3476 if (xargc < 1 || **xargv == '-') {
3477 XFATAL("missing socket handle");
3481 #ifdef NOICP /* If no Interactive Command Parser */
3482 action = 'x'; /* -A implies -x. */
3492 case 'Q': /* Quick (i.e. FAST) */
3497 case 'R': /* Remote-Only */
3498 break; /* This is handled in prescan(). */
3501 case 'x': /* server */
3502 case 'O': /* (for One command only) */
3504 XFATAL("conflicting actions");
3506 if (x == 'O') justone = 1;
3510 #endif /* NOSERVER */
3513 case 'f': /* finish */
3515 XFATAL("conflicting actions");
3517 action = setgen('F',"","","");
3521 case 'r': { /* receive */
3523 XFATAL("conflicting actions");
3530 case 'k': /* receive to stdout */
3532 XFATAL("conflicting actions");
3538 case 's': { /* send */
3541 nolinks = 0; /* Follow links by default */
3544 XFATAL("conflicting actions");
3547 XFATAL("invalid argument bundling after -s");
3549 nfils = 0; /* Initialize file counter */
3550 fil2snd = 0; /* Assume nothing to send */
3551 z = 0; /* Flag for stdin */
3552 cmlist = xargv + 1; /* Remember this pointer */
3553 while (++xargv, --xargc > 0) { /* Traverse the list */
3555 if (usepipes && protocol == PROTO_K && **xargv == '!') {
3558 debug(F110,"doarg pipesend",cmarg,0);
3563 #endif /* PIPESEND */
3564 if (**xargv == '-') { /* Check for sending stdin */
3565 if (strcmp(*xargv,"-") != 0) /* next option? */
3567 z++; /* "-" alone means send from stdin. */
3569 } else if (!strcmp(*xargv,".")) {
3574 #endif /* RECURSIVE */
3575 } else /* Check if file exists */
3576 if ((rc = zchki(*xargv)) > -1 || (rc == -2)) {
3579 nfils++; /* Bump file counter */
3580 } else if (iswild(*xargv) && nzxpand(*xargv,0) > 0) {
3581 /* or contains wildcard characters matching real files */
3586 failmsg = (char *)malloc(2000);
3588 ckmakmsg(failmsg,2000,
3590 "%CKERMIT-E-SEARCHFAIL "
3602 xargc++, xargv--; /* Adjust argv/argc */
3603 if (!fil2snd && z == 0) {
3606 failmsg = "%CKERMIT-E-SEARCHFAIL, no files for -s";
3608 failmsg = "No files for -s";
3614 XFATAL("kermit -s: too many -'s");
3616 if (z == 1 && fil2snd) {
3617 XFATAL("invalid mixture of filenames and '-' in -s");
3619 debug(F101,"doarg s nfils","",nfils);
3620 debug(F101,"doarg s z","",z);
3621 if (nfils == 0) { /* no file parameters were specified */
3622 if (is_a_tty(0)) { /* (used to be is_a_tty(1) - why?) */
3623 XFATAL("sending from terminal not allowed");
3626 debug(F101,"doarg s stdinf","",stdinf);
3627 debug(F111,"doarg",*xargv,nfils);
3633 case 'G': /* get to stdout */
3635 XFATAL("conflicting actions");
3638 XFATAL("invalid argument bundling after -g");
3641 if ((xargc == 0) || (**xargv == '-')) {
3642 XFATAL("missing filename for -g");
3644 if (x == 'G') stdouf = 1;
3651 case 'c': /* connect before */
3655 case 'n': /* connect after */
3658 #endif /* NOLOCAL */
3660 case 'h': /* help */
3663 if (stayflg || what == W_COMMAND)
3667 doexit(GOOD_EXIT,-1);
3670 case 'a': /* "as" */
3672 XFATAL("invalid argument bundling after -a");
3675 if ((xargc < 1) || (**xargv == '-')) {
3676 XFATAL("missing name in -a");
3679 debug(F111,"doarg a",cmarg2,xargc);
3684 case 'Y': /* No initialization file */
3688 case 'y': /* Alternate init-file name */
3691 XFATAL("invalid argument bundling after -y");
3695 XFATAL("missing filename in -y");
3697 /* strcpy(kermrc,*xargv); ... already done in prescan()... */
3702 case 'I': /* Assume we have an "Internet" */
3703 reliable = 1; /* or other reliable connection */
3707 /* I'm not so sure about this -- what about VMS? (next comment) */
3708 clearrq = 1; /* therefore the channel is clear */
3712 Since this can trigger full control-character unprefixing, we need to
3713 ensure that our terminal or pty driver is not doing Xon/Xoff; otherwise
3714 we can become deadlocked the first time we receive a file that contains
3723 case 'l': /* SET LINE */
3726 case 'X': /* SET HOST to X.25 address */
3728 case 'Z': /* SET HOST to X.25 file descriptor */
3733 case 'j': /* SET HOST (TCP/IP socket) */
3734 #endif /* TCPSOCKET */
3735 #endif /* NETCONN */
3737 if (x == 'j' || x == 'J' || x == 'X' || x == 'Z') {
3738 reliable = 1; /* or other reliable connection */
3745 XFATAL("invalid argument bundling after -l or -j");
3748 if ((xargc < 1) || (**xargv == '-')) {
3749 XFATAL("communication line device name missing");
3754 cflg = 1; /* Connect */
3755 stayflg = 1; /* Stay */
3756 tn_exit = 1; /* Telnet-like exit condition */
3759 #endif /* NETCONN */
3760 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
3761 local = (strcmp(ttname,CTTNAM) != 0);
3762 if (local && strcmp(ttname,"0") == 0)
3765 NOTE: We really do not need to call ttopen here, since it should be called
3766 again later, automatically, when we first try to condition the device via
3767 ttpkt or ttvt. Calling ttopen here has the bad side effect of making the
3768 order of the -b and -l options significant when the order of command-line
3769 options should not matter. However, the network cases immediately below
3770 complicate matters a bit, so we'll settle this in a future edit.
3773 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
3774 XFATAL("can't open device");
3778 #endif /* CKLOGDIAL */
3779 debug(F101,"doarg speed","",speed);
3780 cxtype = (mdmtyp > 0) ? CXT_MODEM : CXT_DIRECT;
3781 speed = ttgspd(); /* Get the speed. */
3782 setflow(); /* Do something about flow control. */
3785 if (nmac) { /* Any macros defined? */
3787 k = mlook(mactab,"on_open",nmac); /* Look this up */
3788 if (k >= 0) { /* If found, */
3789 if (dodo(k,ttname,0) > -1) /* set it up, */
3790 parser(1); /* and execute it */
3798 if (x == 'j' || x == 'J') { /* IP network host name */
3800 char * service = tmpbuf;
3801 if (xargc > 0) { /* Check if it's followed by */
3802 /* A service name or number */
3803 if (*(xargv+1) && *(*(xargv+1)) != '-') {
3805 ckstrncat(ttname,":",TTNAMLEN+1);
3806 ckstrncat(ttname,*xargv,TTNAMLEN+1);
3810 mdmtyp = -nettype; /* Perhaps already set in init file */
3811 telnetfd = 1; /* Or maybe an open file descriptor */
3812 ckstrncpy(line, ttname, LINBUFSIZ); /* Working copy */
3813 for (s = line; *s != NUL && *s != ':'; s++);
3816 ckstrncpy(service, s, TMPBUFSIZ);
3817 } else *service = NUL;
3821 /* Look up in network directory */
3823 if (*s == '=') { /* If number starts with = sign */
3825 while (*s == SP) /* and also any leading spaces */
3827 ckstrncpy(line,s,LINBUFSIZ); /* Do this again. */
3829 } else if (!isdigit(line[0])) {
3831 nnetdir will be greater than 0 if the init file has been processed and it
3832 contained a SET NETWORK DIRECTORY command.
3834 xx = 0; /* Initialize this */
3835 if (nnetdir > 0) /* If there is a directory... */
3836 xx = lunet(line); /* Look up the name */
3837 else /* If no directory */
3838 nhcount = 0; /* we didn't find anything there */
3839 if (xx < 0) { /* Lookup error: */
3842 "?Fatal network directory lookup error - ",
3852 /* Add service to line specification for ttopen() */
3853 if (*service) { /* There is a service specified */
3854 ckstrncat(line, ":",LINBUFSIZ);
3855 ckstrncat(line, service,LINBUFSIZ);
3856 ttnproto = NP_DEFAULT;
3858 ckstrncat(line, ":telnet",LINBUFSIZ);
3859 ttnproto = NP_TELNET;
3864 if ((nhcount > 1) && !quiet && !backgrd) {
3865 printf("%d entr%s found for \"%s\"%s\n",
3867 (nhcount == 1) ? "y" : "ies",
3869 (nhcount > 0) ? ":" : "."
3871 for (i = 0; i < nhcount; i++)
3872 printf("%3d. %s %-12s => %s\n",
3873 i+1, n_name, nh_p2[i], nh_p[i]
3884 for (i = 0; i < n; i++) {
3887 /* Copy the current entry to line */
3888 ckstrncpy(line,nh_p[i],LINBUFSIZ);
3889 /* Check to see if the network entry contains a service */
3890 for (s = line ; (*s != NUL) && (*s != ':'); s++)
3892 /* If directory does not have a service ... */
3893 /* and the user specified one */
3894 if (!*s && *service) {
3895 ckstrncat(line, ":",LINBUFSIZ);
3896 ckstrncat(line, service,LINBUFSIZ);
3898 if (lookup(netcmd,nh_p2[i],nnets,&z) > -1) {
3899 mdmtyp = 0 - netcmd[z].kwval;
3902 "Error - network type \"%s\" not supported\n",
3911 ckstrncpy(ttname, line,TTNAMLEN+1);
3912 cxtype = CXT_TCPIP; /* Set connection type */
3913 setflow(); /* Set appropriate flow control. */
3915 } else if (x == 'X') { /* X.25 address */
3918 } else if (x == 'Z') { /* Open X.25 file descriptor */
3924 } else if (x == 'X') { /* X.25 address */
3927 #endif /* STRATUSX25 */
3929 } else if (x == 'X') { /* X.25 address */
3934 } else if (x == 'X') { /* X.25 address */
3939 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
3940 XFATAL("can't open host connection");
3945 #endif /* CKLOGDIAL */
3946 cxtype = CXT_X25; /* Set connection type */
3947 setflow(); /* Set appropriate flow control. */
3950 if (nmac) { /* Any macros defined? */
3952 k = mlook(mactab,"on_open",nmac); /* Look this up */
3953 if (k >= 0) { /* If found, */
3954 if (dodo(k,ttname,0) > -1) /* set it up, */
3955 parser(1); /* and execute it */
3960 #endif /* NETCONN */
3962 /* add more here -- decnet, etc... */
3967 case 'U': /* X.25 call user data */
3969 XFATAL("invalid argument bundling");
3972 if ((xargc < 1) || (**xargv == '-')) {
3973 XFATAL("missing call user data string");
3975 ckstrncpy(udata,*xargv,MAXCUDATA);
3976 if ((int)strlen(udata) <= MAXCUDATA) {
3979 XFATAL("Invalid call user data");
3983 case 'o': /* X.25 closed user group */
3985 XFATAL("invalid argument bundling");
3988 if ((xargc < 1) || (**xargv == '-')) {
3989 XFATAL("missing closed user group index");
3991 z = atoi(*xargv); /* Convert to number */
3992 if (z >= 0 && z <= 99) {
3995 XFATAL("Invalid closed user group index");
3999 case 'u': /* X.25 reverse charge call */
4003 #endif /* NOLOCAL */
4005 case 'b': /* Bits-per-second for serial device */
4007 XFATAL("invalid argument bundling");
4010 if ((xargc < 1) || (**xargv == '-')) {
4011 XFATAL("missing bps");
4013 zz = atol(*xargv); /* Convert to long int */
4016 if (ttsspd(i) > -1) /* Check and set it */
4017 #endif /* NOLOCAL */
4018 speed = ttgspd(); /* and read it back. */
4021 XFATAL("unsupported transmission rate");
4023 #endif /* NOLOCAL */
4028 case 'm': /* Modem type */
4030 XFATAL("invalid argument bundling after -m");
4033 if ((xargc < 1) || (**xargv == '-')) {
4034 XFATAL("modem type missing");
4036 y = lookup(mdmtab,*xargv,nmdm,&z);
4038 XFATAL("unknown modem type");
4041 usermdm = (y == dialudt) ? x : 0;
4048 case 'e': /* Extended packet length */
4050 XFATAL("invalid argument bundling after -e");
4053 if ((xargc < 1) || (**xargv == '-')) {
4054 XFATAL("missing length");
4056 z = atoi(*xargv); /* Convert to number */
4057 if (z > 10 && z <= maxrps) {
4059 if (z > 94) rpsiz = 94; /* Fallback if other Kermit can't */
4061 XFATAL("Unsupported packet length");
4065 case 'v': /* Vindow size */
4067 XFATAL("invalid argument bundling");
4070 if ((xargc < 1) || (**xargv == '-')) {
4071 XFATAL("missing or bad window size");
4073 z = atoi(*xargv); /* Convert to number */
4074 if (z < 32) { /* If in range */
4075 wslotr = z; /* set it */
4076 if (z > 1) swcapr = 1; /* Set capas bit if windowing */
4078 XFATAL("Unsupported packet length");
4083 case 'i': /* Treat files as binary */
4085 xfermode = XMODE_M; /* Transfer mode manual */
4089 #endif /* PATTERNS */
4093 case 'w': /* Writeover */
4099 case 'q': /* Quiet */
4104 case 'd': /* DEBUG */
4105 break; /* Handled in prescan() */
4108 case '0': { /* In the middle */
4109 extern int tt_escape, lscapr;
4110 tt_escape = 0; /* No escape character */
4111 flow = 0; /* No Xon/Xoff (what about hwfc?) */
4113 lscapr = 0; /* No locking shifts */
4117 extern int apcstatus; /* No APCs */
4118 apcstatus = APC_OFF;
4123 setautodl(0,0); /* No autodownload */
4124 #endif /* CK_AUTODL */
4125 #endif /* NOLOCAL */
4128 extern int tcsr, tcsl; /* No character-set translation */
4130 tcsl = tcsr; /* Make these equal */
4132 #endif /* NOCSETS */
4134 TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
4135 TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
4136 TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
4137 TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
4142 case '8': /* 8-bit clean */
4149 extern int xfermode;
4151 extern int patterns;
4152 patterns = 0; /* No patterns */
4153 #endif /* PATTERNS */
4154 xfermode = XMODE_M; /* Manual transfer mode */
4159 case 'p': /* SET PARITY */
4161 XFATAL("invalid argument bundling");
4164 if ((xargc < 1) || (**xargv == '-')) {
4165 XFATAL("missing parity");
4167 switch(x = **xargv) {
4171 case 's': parity = x; break;
4172 case 'n': parity = 0; break;
4173 default: { XFATAL("invalid parity"); }
4177 case 't': /* Line turnaround handshake */
4179 turnch = XON; /* XON is turnaround character */
4180 duplex = 1; /* Half duplex */
4181 flow = 0; /* No flow control */
4185 bgset = 1; /* Force background (batch) */
4189 case 'z': /* Force foreground */
4201 #endif /* RECURSIVE */
4205 case 'M': /* My User Name */
4207 XFATAL("invalid argument bundling");
4210 if ((xargc < 1) || (**xargv == '-')) {
4211 XFATAL("missing username");
4213 if ((int)strlen(*xargv) > 63) {
4214 XFATAL("username too long");
4220 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4227 case 'N': /* NetBios Adapter Number follows */
4229 XFATAL("invalid argument bundling after -N");
4232 if ((xargc < 1) || (**xargv == '-')) {
4233 XFATAL("missing NetBios Adapter number");
4235 if ((strlen(*xargv) != 1) ||
4236 (*xargv)[0] != 'X' &&
4237 (atoi(*xargv) < 0) &&
4238 (atoi(*xargv) > 9)) {
4239 XFATAL("Invalid NetBios Adapter - Adapters 0 to 9 are valid");
4242 #endif /* CK_NETBIOS */
4248 XFATAL("invalid argument bundling after -F");
4251 if ((xargc < 1) || (**xargv == '-')) {
4252 XFATAL("network file descriptor missing");
4254 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
4260 #endif /* NETCONN */
4264 case 'P': /* OS/2 Presentation Manager */
4266 XFATAL("invalid argument bundling after -P");
4269 if ((xargc < 1) || (**xargv == '-')) {
4270 XFATAL("pipe data missing");
4276 case 'P': /* Filenames literal */
4280 #endif /* COMMENT */
4291 XFATAL("invalid argument bundling after -W");
4294 if ((xargc < 1)) { /* could be negative */
4295 XFATAL("Window handle missing");
4298 if ((xargc < 1) || (**xargv == '-')) {
4299 XFATAL("Kermit Instance missing");
4301 /* Action done in prescan */
4304 case '#': /* K95 stdio threads */
4305 xargv++, xargc--; /* Skip past argument */
4306 break; /* Action done in prescan */
4312 XFATAL("invalid argument bundling after -9");
4315 if ((xargc < 1) || (**xargv == '-')) {
4316 XFATAL("FTP server address missing");
4318 makestr(&ftp_host,*xargv);
4325 "invalid command-line option, type \"k95 -h\" for help"
4328 "invalid command-line option, type \"k2 -h\" for help"
4330 "invalid command-line option, type \"kermit -h\" for help"
4336 x = *++xp; /* See if options are bundled */
4342 /* D O T N A R G -- Do a telnet command-line argument. */
4349 #endif /* CK_ANSIC */
4353 xp = *xargv+1; /* Pointer for bundled args */
4354 debug(F111,"dotnarg entry",xp,xargc);
4356 debug(F000,"dotnarg arg","",x);
4357 switch (x) { /* Big switch on arg */
4360 case '-': /* Extended commands... */
4361 if (doxarg(xargv,0) < 0) {
4362 XFATAL("Extended option error");
4363 } /* Full thru... */
4364 case '+': /* Extended command for prescan() */
4369 XFATAL("Extended options not configured");
4370 #endif /* COMMENT */
4373 * -# Kermit 95 Startup Flags
4374 * -8 Negotiate Telnet Binary in both directions
4375 * -a Require use of Telnet authentication
4376 * -c Do not read the .telnetrc file
4377 * -d Turn on debug mode
4378 * -E No escape character
4379 * -f Forward credentials to host
4380 * -K Refuse use of authentication; do not send username
4381 * -k realm Set default realm
4382 * -l user Set username and request Telnet authentication
4383 * -L Negotiate Telnet Binary Output only
4384 * -q Quiet mode (suppress messages)
4385 * -S tos Use the IP type-of-service tos
4386 * -x Require Encryption
4387 * -D Disable forward-X
4388 * -T cert=file Use certificate in file
4389 * -T key=file Use private key in file
4390 * -T crlfile=file Use CRL in file
4391 * -T crldir=dir Use CRLs in directory
4392 * -T cipher=string Use only ciphers in string
4393 * -X atype Disable use of atype authentication
4394 * -Y Disable init file processing
4397 case 'h': /* help */
4399 doexit(GOOD_EXIT,-1);
4402 case '8': /* Telnet Binary in both directions */
4403 TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = TN_NG_MU;
4404 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
4410 case 'a': /* Require Telnet Auth */
4411 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
4415 xargv++, xargc--; /* Skip past argument */
4416 break; /* Action done in prescan */
4419 case '#': /* K95 stdio threads */
4420 xargv++, xargc--; /* Skip past argument */
4421 break; /* Action done in prescan */
4424 case 'q': /* Quiet */
4433 deblog = debopn("debug.log",0);
4438 case 'E': { /* No Escape character */
4439 extern int tt_escape;
4445 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_RF;
4449 case 'l': /* Set username and request telnet authentication */
4451 XFATAL("invalid argument bundling");
4454 if ((xargc < 1) || (**xargv == '-')) {
4455 XFATAL("missing username");
4457 if ((int)strlen(*xargv) > 63) {
4458 XFATAL("username too long");
4460 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4461 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
4464 case 'L': /* Require BINARY mode outbound only */
4465 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
4468 case 'x': /* Require Encryption */
4469 TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
4470 TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
4473 case 'D': /* Disable use of Forward X */
4474 TELOPT_DEF_C_U_MODE(TELOPT_FORWARD_X) = TN_NG_RF;
4477 case 'f': /* Forward credentials to host */
4479 #ifdef CK_AUTHENTICATION
4480 extern int forward_flag;
4488 extern char * krb5_d_realm, * krb4_d_realm;
4489 #endif /* CK_KERBEROS */
4491 XFATAL("invalid argument bundling");
4494 if ((xargc < 1) || (**xargv == '-')) {
4495 XFATAL("missing realm");
4498 if ((int)strlen(*xargv) > 63) {
4499 XFATAL("realm too long");
4501 makestr(&krb5_d_realm,*xargv);
4502 makestr(&krb4_d_realm,*xargv);
4503 #endif /* CK_KERBEROS */
4509 XFATAL("invalid argument bundling");
4512 if ((xargc < 1) || (**xargv == '-')) {
4513 XFATAL("missing cert=, key=, crlfile=, crldir=, or cipher=");
4516 if (!strncmp(*xargv,"cert=",5)) {
4517 extern char * ssl_rsa_cert_file;
4518 makestr(&ssl_rsa_cert_file,&(*xargv[5]));
4519 } else if ( !strncmp(*xargv,"key=",4) ) {
4520 extern char * ssl_rsa_key_file;
4521 makestr(&ssl_rsa_key_file,&(*xargv[4]));
4522 } else if ( !strncmp(*xargv,"crlfile=",8) ) {
4523 extern char * ssl_crl_file;
4524 makestr(&ssl_crl_file,&(*xargv[8]));
4525 } else if ( !strncmp(*xargv,"crldir=",7) ) {
4526 extern char * ssl_crl_dir;
4527 makestr(&ssl_crl_dir,&(*xargv[7]));
4528 } else if ( !strncmp(*xargv,"cipher=",7) ) {
4529 extern char * ssl_cipher_list;
4530 makestr(&ssl_cipher_list,&(*xargv[7]));
4532 XFATAL("invalid parameter");
4540 "invalid command-line option, type \"telnet -h\" for help"
4545 x = *++xp; /* See if options are bundled */
4553 /* D O R L G A R G -- Do a rlogin command-line argument. */
4560 #endif /* CK_ANSIC */
4564 xp = *xargv+1; /* Pointer for bundled args */
4565 debug(F111,"dorlgarg entry",xp,xargc);
4567 debug(F000,"dorlgarg arg","",x);
4568 switch (x) { /* Big switch on arg */
4571 case '-': /* Extended commands... */
4572 if (doxarg(xargv,0) < 0) {
4573 XFATAL("Extended option error");
4574 } /* Full thru... */
4575 case '+': /* Extended command for prescan() */
4580 XFATAL("Extended options not configured");
4581 #endif /* COMMENT */
4585 * -l user Set username
4588 case 'h': /* help */
4590 doexit(GOOD_EXIT,-1);
4594 xargv++, xargc--; /* Skip past argument */
4595 break; /* Action done in prescan */
4597 case '#': /* K95 stdio threads */
4598 xargv++, xargc--; /* Skip past argument */
4599 break; /* Action done in prescan */
4601 case 'q': /* Quiet */
4610 deblog = debopn("debug.log",0);
4615 case 'l': /* Set username and request telnet authentication */
4617 XFATAL("invalid argument bundling");
4620 if ((xargc < 1) || (**xargv == '-')) {
4621 XFATAL("missing username");
4623 if ((int)strlen(*xargv) > 63) {
4624 XFATAL("username too long");
4626 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4631 "invalid command-line option, type \"rlogin -h\" for help"
4636 x = *++xp; /* See if options are bundled */
4640 #endif /* RLOGCODE */
4644 /* D O S S H A R G -- Do a ssh command-line argument. */
4651 #endif /* CK_ANSIC */
4655 xp = *xargv+1; /* Pointer for bundled args */
4656 debug(F111,"dossharg entry",xp,xargc);
4658 debug(F000,"dossharg arg","",x);
4659 switch (x) { /* Big switch on arg */
4662 case '-': /* Extended commands... */
4663 if (doxarg(xargv,0) < 0) {
4664 XFATAL("Extended option error");
4665 } /* Full thru... */
4666 case '+': /* Extended command for prescan() */
4668 #else /* COMMENTP */
4671 XFATAL("Extended options not configured");
4672 #endif /* COMMENT */
4678 * -l user Set username
4681 case 'h': /* help */
4683 doexit(GOOD_EXIT,-1);
4687 xargv++, xargc--; /* Skip past argument */
4688 break; /* Action done in prescan */
4690 case '#': /* K95 stdio threads */
4691 xargv++, xargc--; /* Skip past argument */
4692 break; /* Action done in prescan */
4694 case 'q': /* Quiet */
4703 deblog = debopn("debug.log",0);
4708 case 'l': /* Set username and request telnet authentication */
4710 XFATAL("invalid argument bundling");
4713 if ((xargc < 1) || (**xargv == '-')) {
4714 XFATAL("missing username");
4716 if ((int)strlen(*xargv) > 63) {
4717 XFATAL("username too long");
4719 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4724 "invalid command-line option, type \"ssh -h\" for help"
4729 x = *++xp; /* See if options are bundled */
4733 #endif /* SSHBUILTIN */
4735 #else /* No command-line interface... */
4741 XFATAL("Sorry, command-line options disabled.");