4 /* C K U U S Y -- "User Interface" for Unix 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, 2004,
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 */
160 extern char * ftp_host;
167 extern int nmdm, telephony;
168 extern struct keytab mdmtab[];
169 extern int usermdm, dialudt;
171 _PROTOTYP(static int pmsg, (char *) );
172 _PROTOTYP(static int fmsg, (char *) );
173 static int pmsg(s) char *s; { printf("%s\n", s); return(0); }
174 static int fmsg(s) char *s; { fatal(s); return(0); }
175 #define XFATAL(s) return(what==W_COMMAND?pmsg(s):fmsg(s))
187 /* URLs we recognize */
196 struct keytab urltab[] = {
202 "https", URL_HTTPS, 0,
205 "kermit", URL_IKSD, 0,
206 "telnet", URL_TELNET, 0,
209 int nurltab = sizeof(urltab)/sizeof(struct keytab) - 1;
212 #define URLBUFLEN 1024
213 #endif /* URLBUFLEN */
214 static char urlbuf[URLBUFLEN];
215 struct urldata g_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
217 /* u r l p a r s e -- Parse a possible URL */
220 Returns 0 if the candidate does not seem to be a URL.
221 Returns 1 if it might be a URL, with the above pointers set to its pieces:
222 service : [ // ] [ user [ : password ] @ ] host [ : service ] [ / path ]
224 Example: ftp://ds.internic.net:21/rfc/rfc1234.txt
228 url.hos = [ds.internic.net]
230 url.pth = [rfc/rfc1234.txt]
232 It might be a URL if it contains a possible service name followed by a
233 a colon (:). Thus "telnet:xyzcorp.com" is a minimal URL, whereas a
234 full-blown example would be:
236 ftp://olga:secret@ftp.xyzcorp.com/public/oofa.txt
238 The caller must verify the results, i.e. that the service string is a real
239 TCP service, etc. This routine just parses the fields.
241 struct urldata defined in ckcker.h
245 urlparse(s,url) char *s; struct urldata * url; {
246 char * p = NULL, * urlbuf = NULL;
257 if (url->sav) { /* In case we were called before... */
285 p = urlbuf; /* Was a service requested? */
286 while (*p && *p != ':') /* Look for colon */
288 if (*p == ':') { /* Have a colon */
289 *p++ = NUL; /* Get service name or number */
290 if (*p == ':') /* a second colon */
291 *p++ = NUL; /* get rid of that one too */
292 while (*p == '/') *p++ = NUL; /* and slashes */
294 /* Trailing slash is part of path - leave it - jaltman */
295 x = strlen(p); /* Length of remainder */
296 if (p[x-1] == '/') /* If there is a trailing slash */
297 p[x-1] = NUL; /* remove it. */
299 if (urlbuf[0]) { /* Anything left? */
300 char *q = p, *r = p, *w = p;
301 makestr(&url->svc,urlbuf);
303 while (*p != NUL && *p != '@') /* look for @ */
305 if (*p == '@') { /* Signifies user ID, maybe password */
308 while (*w != NUL && *w != ':')
312 url->usr = r; /* Username */
314 url->psw = w; /* Password */
316 } else { /* No username or password */
320 debug(F111,"urlparse url->usr",url->usr,url->usr);
321 debug(F111,"urlparse url->psw",url->usr,url->psw);
322 debug(F111,"urlparse url->hos",url->usr,url->hos);
324 while (*p != NUL && *p != ':' && *p != '/') /* Port? */
326 if (*p == ':') { /* TCP port */
330 while (*p != NUL && *p != '/')
332 /* '/' is part of path, leave it until we can copy */
334 makestr(&url->pth,p); /* Path */
337 } else { /* No port */
338 /* '/' is part of path, leave it */
340 makestr(&url->pth,p); /* Path */
345 /* Copy non-NULL result strings */
346 if (url->svc) if (*url->svc) {
349 makestr(&url->svc,p);
351 if (url->hos) if (*url->hos) {
354 makestr(&url->hos,p);
356 if (url->por) if (*url->por) {
359 makestr(&url->por,p);
362 WARNING (Wed Oct 9 16:09:03 2002): We now allow the username and
363 password to be empty strings. These are treated differently from null
364 pointers: an empty string means the URL included username and/or password
365 fields that were empty, e.g. ftp://:@ftp.xyzcorp.com/somepath/somefile,
366 which causes the client to prompt for the username and/or password.
368 if (url->usr) /* if (*url->usr) */ {
371 makestr(&url->usr,p);
373 if (url->psw) /* if (*url->psw) */ {
376 makestr(&url->psw,p);
378 /* Save a copy of the full url if one was found. */
380 makestr(&url->sav,s);
382 return(url->svc ? 1 : 0);
392 " [filename] [-x arg [-x arg]...[-yyy]..] [ = text ] ]\n",
394 "[-x arg [-x arg]...[-yyy]..]\n",
397 " -x is an option requiring an argument, -y an option with no argument.\n",
398 " If the first command-line argument is the name of a file, interactive-\n",
399 " mode commands are executed from the file. The '=' argument tells Kermit\n",
400 " not to parse the remainder of the command line, but to make the words\n",
401 " following '=' available as \\%1, \\%2, ... \\%9. The command file \
403 " is executed before the command-line options.\n",
406 "If no action command is included, or -S is, then after the command line is\n",
407 "executed, Kermit issues its prompt and waits for you to type commands.\n",
409 "Operation by command-line options only.\n",
416 " [option-list] host[:port] [port]\n",
417 " The option-list consists of zero, one, or more of:\n",
418 " -8 Negotiate Telnet Binary in both directions\n",
419 " -a Require use of Telnet authentication\n",
420 " -d Turn on debug mode\n",
421 " -E No escape character\n",
422 " -K Refuse use of authentication; do not send username\n",
423 " -l user Set username and request Telnet authentication\n",
424 " -L Negotiate Telnet Binary Output only\n",
425 " -x Require Encryption\n",
426 " -D Disable forward-X\n",
427 " -T cert=file Use certificate in file\n",
428 " -T key=file Use private key in file\n",
429 " -T crlfile=file Use CRL in file\n",
430 " -T crldir=dir Use CRLs in directory\n",
431 " -T cipher=string Use only ciphers in string\n",
432 " -f Forward credentials to host\n",
433 " -k realm Set default Kerberos realm\n",
438 char *hlp3[] = { /* rlogin */
439 " [option-list] host[:port] [port]\n",
440 " The option-list consists of zero, one, or more of:\n",
441 " -d Turn on debug mode\n",
442 " -l user Set username\n",
447 char *hlp4[] = { /* ssh */
448 " [option-list] host[:port] [port]\n",
449 " The option-list consists of zero, one, or more of:\n",
450 " -d Turn on debug mode\n",
451 " -l user Set username\n",
455 /* Command-line option help lines. Update this when adding new options! */
457 char * opthlp[128]; /* Option help */
458 char * arghlp[128]; /* Argument for option */
459 int optact[128]; /* Action-option flag */
462 fatal2(msg1,msg2) char *msg1, *msg2; {
464 if (!msg1) msg1 = "";
465 if (!msg2) msg2 = "";
466 ckmakmsg(buf,256,"\"",msg1,"\" - ",msg2);
468 if (what == W_COMMAND)
479 cl_int(dummy) int dummy;
481 { /* Command-line interrupt handler */
487 extern int ftp_action, ftp_cmdlin;
490 xx_ftp(host, port) char * host, * port; {
494 extern char * ftp_logname;
498 if (port) if (!*port) port = NULL;
504 debug(F111,"ftp xx_ftp host",ftp_host,haveftpuid);
505 debug(F111,"ftp xx_ftp uidbuf 1",uidbuf,haveftpuid);
506 ftp_cmdlin = 1; /* 1 = FTP started from command line */
508 ftp_cmdlin++; /* 2 = same plus file transfer */
511 debug(F111,"ftp xx_ftp g_url.usr",g_url.usr,g_url.usr);
512 if (haveurl && g_url.usr) { /* Wed Oct 9 15:15:22 2002 */
513 if (!*(g_url.usr)) { /* Force username prompt if */
514 haveftpuid = 0; /* "ftp://:@host" given. */
516 makestr(&ftp_logname,NULL);
518 debug(F111,"ftp xx_ftp uidbuf 2",uidbuf,haveftpuid);
521 debug(F111,"ftp xx_ftp uidbuf 3",uidbuf,haveftpuid);
523 makestr(&ftp_logname,uidbuf);
524 debug(F111,"ftp_logname",ftp_logname,haveftpuid);
527 if ((p = ckstrchr(ftp_host,':')))
546 if (haveurl && g_url.svc)
547 use_tls = !ckstrcmp("ftps",g_url.svc,-1,0);
550 if (ftpopen(ftp_host,port,use_tls) < 1)
552 debug(F111,"ftp xx_ftp action",ckctoa((char)ftp_action),nfils);
554 switch (ftp_action) {
556 return(cmdlinget(stayflg));
559 return(cmdlinput(stayflg));
569 char * http_hlp[] = {
570 " -h This message.\n",
571 " -d Debug to debug.log.\n",
572 " -S Stay (issue command prompt when done).\n",
573 " -Y Do not execute Kermit initialization file.\n",
574 " -q Quiet (suppress most messages).\n",
575 " -u name Username.\n",
576 " -P password Password.\n",
577 " -g pathname Get remote pathname.\n",
578 " -p pathname Put remote pathname.\n",
579 " -H pathname Head remote pathname.\n",
580 " -l pathname Local path for -g, -p, and -H.\n",
582 " -z opt[=value] Security options...\n",
583 " cert=file Client certificate file\n",
584 " certsok Accept all certificates\n",
585 " key=file Client private key file\n",
587 " verify=n 0 = none, 1 = peer , 2 = certificate required\n",
598 static struct keytab httpztab[] = {
599 { "cert", HT_CERTFI, CM_ARG },
600 { "certsok", HT_OKCERT, 0 },
601 { "key", HT_KEY, CM_ARG },
602 { "secure", HT_SECURE, 0 },
603 { "verify", HT_VERIFY, CM_ARG },
606 static int nhttpztab = sizeof(httpztab) / sizeof(struct keytab) - 1;
616 conol(" [-x arg [-x arg]...[-yyy]..] ]\n");
620 if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
621 howcalled == I_AM_SSHSUB)
623 else if (howcalled == I_AM_TELNET)
625 else if (howcalled == I_AM_RLOGIN)
627 else if (howcalled == I_AM_SSH)
629 if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
630 howcalled == I_AM_SSHSUB) {
633 conoll("Complete listing of command-line options:");
635 for (c = 31; c < 128; c++) {
639 printf(" -%c <arg>%s\n",
641 (optact[c] ? " (action option)" : "")
643 printf(" %s\n",opthlp[c]);
644 printf(" Argument: %s\n\n",arghlp[c]);
645 } else { /* Option without arg */
646 printf(" -%c %s%s\n",
648 (optact[c]?" (action option)":"")
650 printf(" Argument: (none)\n\n");
654 printf("To prevent this message from scrolling, use '%s -h | more'.\n",
656 #endif /* OS2ORUNIX */
657 printf("For a list of extended options use '%s --help'.\n",
664 /* C M D L I N -- Get arguments from command line */
668 char x; /* Local general-purpose char */
676 cmarg = ""; /* Initialize globals */
682 signal(SIGINT,cl_int);
684 /* Here we handle different "Command Line Personalities" */
688 if (howcalled == I_AM_HTTP) { /* If I was called as HTTP... */
691 char * agent = "Kermit 95";
693 char * agent = "C-Kermit";
696 debug(F100,"http personality","",0);
702 type = lookup(urltab,g_url.svc,nurltab,NULL);
703 if (!(type == URL_HTTP || type == URL_HTTPS)) {
704 printf("?Internal Error: HTTP command line processing\n");
705 debug(F100,"Error: HTTP command line processing","",0);
710 x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc,
711 type == URL_HTTPS, rdns,128,NULL) == 0);
714 char asname[CKMAXPATH+1];
718 printf("Connected to %s [%s]\r\n",g_url.hos,rdns);
720 printf("Connected to %s\r\n",g_url.hos);
723 zstrip(g_url.pth,&lfile);
728 lfile = "index.html";
731 if (uq_file(NULL, /* K95 GUI: Put up file box. */
732 NULL, /* (not tested...) */
751 x = (http_close() == 0);
754 printf("?HTTP Connection failed.\r\n");
756 doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
761 char * host = NULL, * svc = NULL, * lpath = NULL;
762 char * user = NULL, * pswd = NULL, * path = NULL;
765 while (--xargc > 0) { /* Go through command line words */
767 debug(F111,"cmdlin http xargv",*xargv,xargc);
769 if (**xargv == '-') { /* Got an option */
771 x = *(*xargv+1); /* Get the option letter */
773 case 'd': /* Debug */
778 deblog = debopn("debug.log",0);
783 case 'Y': /* No initialization file */
784 break; /* (already done in prescan) */
785 case 'q': /* Quiet */
788 case 'u': /* Options that require arguments */
795 XFATAL("Invalid argument bundling");
798 if ((xargc < 1) || (**xargv == '-')) {
799 XFATAL("Missing argument");
809 if (http_action != HTTP_PUT)
813 http_action = HTTP_GET;
815 debug(F111,"cmdlin http GET",path,http_action);
818 http_action = HTTP_PUT;
822 http_action = HTTP_HED;
829 /* *xargv contains a value of the form tag=value */
830 /* we need to lookup the tag and save the value */
834 y = ckindex("=",p,0,0,1);
837 x = lookup(httpztab,p,nhttpztab,&z);
839 printf("?Invalid security option: \"%s\"\n",p);
841 printf("Security option: \"%s",p);
842 if (httpztab[z].flgs & CM_ARG) {
845 fatal("?Missing required value");
847 /* -z options w/args */
848 switch (httpztab[z].kwval) {
850 makestr(&ssl_rsa_cert_file,q);
853 ssl_certsok_flag = 1;
856 makestr(&ssl_rsa_key_file,q);
863 printf("?Bad number: %s\n",q);
864 ssl_verify_flag = atoi(q);
875 printf("Usage: %s host [ options... ]\n",xarg0);
877 doexit(GOOD_EXIT,-1);
879 } else { /* No dash - must be hostname */
883 if (svc) if (*svc == '-' || !*svc)
893 if (!*svc) svc = "http";
894 if (!host) XFATAL("No http host given");
896 /* Check action args before opening the connection */
898 if (http_action == HTTP_PUT) {
900 XFATAL("No local path for http PUT");
903 XFATAL("No remote path for http action");
905 /* Now it's OK to open the connection */
908 svc,!ckstrcmp("https",svc,-1,0),rdns,128,NULL
912 printf("?HTTP Connection failed.\r\n");
917 printf("Connected to %s [%s]\r\n",host,rdns);
919 printf("Connected to %s\r\n",host);
923 if (http_action != HTTP_PUT) { /* Supply default */
924 if (!lpath) { /* local path... */
929 lpath = "index.html";
933 char * p = (char *) malloc(strlen(path)+2);
934 if (!p) fatal("?Memory allocation error\n");
936 strcpy(&p[1],path); /* safe */
940 switch (http_action) {
942 x = http_get(agent,NULL,user,pswd,0,lpath,path,0);
946 x = http_put(agent,NULL,"text/HTML",
947 user,pswd,0,lpath,path,NULL,0);
951 x = http_head(agent,NULL,user,pswd,0,lpath,path,0);
954 debug(F101,"cmdline http result","",x);
955 x = (http_close() == 0);
956 if (pcpy) free(path);
957 doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
964 if (howcalled == I_AM_FTP) { /* If I was called as FTP... */
965 debug(F100,"ftp personality","",0);
972 while (--xargc > 0) { /* Go through command line words */
974 debug(F111,"cmdlin ftp xargv",*xargv,xargc);
975 if (**xargv == '-') { /* Got an option */
977 x = *(*xargv+1); /* Get the option letter */
980 if (what == W_COMMAND)
985 } else { /* No dash - must be hostname */
986 makestr(&ftp_host,*xargv);
989 if (port) if (*port == '-' || !*port)
996 debug(F110,"cmdlin ftp host",ftp_host,0);
997 debug(F110,"cmdlin ftp port",port,0);
1000 } /* if (haveurl) */
1005 xx = xx_ftp(ftp_host,port);
1006 if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
1009 xx = xx_ftp(ftp_host,port);
1010 if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
1012 if (*ftp_host == '=') { /* Skip directory lookup */
1013 xx = xx_ftp(&ftp_host[1],port);
1014 if (xx < 0 && (haveurl || ftp_cmdlin > 1))
1015 doexit(BAD_EXIT,-1);
1016 } else { /* Want lookup */
1018 nhcount = 0; /* Check network directory */
1019 debug(F101,"cmdlin nnetdir","",nnetdir);
1020 if (nnetdir > 0) /* If there is a directory... */
1021 lunet(ftp_host); /* Look up the name */
1022 else /* If no directory */
1023 nhcount = 0; /* we didn't find anything there */
1026 debug(F101,"cmdlin lunet nhcount","",nhcount);
1028 debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
1029 debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
1030 debug(F110,"cmdlin lunet nh_px[0][0]",
1036 xx = xx_ftp(ftp_host,port);
1037 if (xx < 0 && (haveurl || ftp_cmdlin > 1))
1038 doexit(BAD_EXIT,-1);
1040 for (i = 0; i < nhcount; i++) {
1041 if (ckstrcmp(nh_p2[i],"tcp/ip",6,0))
1043 makestr(&ftp_host,nh_p[i]);
1044 debug(F110,"cmdlin calling xx_ftp",ftp_host,0);
1046 printf("Trying %s...\n",ftp_host);
1047 if (xx_ftp(ftp_host,port) > -1)
1054 if (!ftpisconnected())
1055 doexit(BAD_EXIT,-1);
1062 if (howcalled == I_AM_TELNET) { /* If I was called as Telnet... */
1064 while (--xargc > 0) { /* Go through command line words */
1066 debug(F111,"cmdlin telnet xargv",*xargv,xargc);
1069 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1072 else if (**xargv == '/')
1075 else if (**xargv == '-') { /* Got an option (begins with dash) */
1077 x = *(*xargv+1); /* Get the option letter */
1078 debug(F111,"cmdlin telnet args 1",*xargv,xargc);
1080 debug(F101,"cmdlin telnet doarg","",xx);
1081 debug(F111,"cmdlin telnet args 2",*xargv,xargc);
1084 if (what == W_COMMAND)
1090 sleep(1); /* Give it a chance... */
1092 doexit(BAD_EXIT,1); /* Go handle option */
1095 } else { /* No dash must be hostname */
1096 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1097 debug(F110,"cmdlin telnet host",ttname,0);
1101 nhcount = 0; /* Check network directory */
1102 debug(F101,"cmdlin telnet nnetdir","",nnetdir);
1103 if (nnetdir > 0) /* If there is a directory... */
1104 lunet(*xargv); /* Look up the name */
1105 else /* If no directory */
1106 nhcount = 0; /* we didn't find anything there */
1109 debug(F101,"cmdlin telnet lunet nhcount","",nhcount);
1111 debug(F110,"cmdlin telnet lunet nh_p[0]",nh_p[0],0);
1112 debug(F110,"cmdlin telnet lunet nh_p2[0]",nh_p2[0],0);
1113 debug(F110,"cmdlin telnet lunet nh_px[0][0]",
1118 if (nhcount > 0 && nh_p2[0]) /* If network type specified */
1119 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
1121 if (nhcount == 1) { /* Still OK, so make substitution */
1122 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1123 debug(F110,"cmdlin telnet lunet substitution",ttname,0);
1128 if (--xargc > 0 && !haveurl) { /* Service from command line? */
1130 ckstrncat(ttname,":",TTNAMLEN+1);
1131 ckstrncat(ttname,*xargv,TTNAMLEN+1);
1132 debug(F110,"cmdlin telnet host2",ttname,0);
1136 else if (nhcount) { /* No - how about in net directory? */
1138 ckstrncat(ttname,":",TTNAMLEN+1);
1139 ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
1144 local = 1; /* Try to open the connection */
1147 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1148 XFATAL("can't open host connection");
1150 network = 1; /* It's open */
1153 #endif /* CKLOGDIAL */
1155 reliable = 1; /* It's reliable */
1156 xreliable = 1; /* ... */
1159 cflg = 1; /* Connect */
1160 stayflg = 1; /* Stay */
1161 tn_exit = 1; /* Telnet-like exit condition */
1163 exitonclose = 1; /* Exit when connection closes */
1166 if (nmac) { /* Any macros defined? */
1168 k = mlook(mactab,"on_open",nmac); /* Look this up */
1169 if (k >= 0) { /* If found, */
1170 if (dodo(k,ttname,0) > -1) /* set it up, */
1171 parser(1); /* and execute it */
1183 else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */
1184 while (--xargc > 0) { /* Go through command line words */
1186 debug(F111,"cmdlin rlogin xargv",*xargv,xargc);
1189 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1192 else if (**xargv == '/')
1195 else if (**xargv == '-') { /* Got an option (begins with dash) */
1197 x = *(*xargv+1); /* Get the option letter */
1198 debug(F111,"cmdlin rlogin args 1",*xargv,xargc);
1200 debug(F101,"cmdlin rlogin doarg","",xx);
1201 debug(F111,"cmdlin rlogin args 2",*xargv,xargc);
1204 if (what == W_COMMAND)
1210 sleep(1); /* Give it a chance... */
1212 doexit(BAD_EXIT,1); /* Go handle option */
1215 } else { /* No dash must be hostname */
1216 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1217 debug(F110,"cmdlin rlogin host",ttname,0);
1221 nhcount = 0; /* Check network directory */
1222 debug(F101,"cmdlin rlogin nnetdir","",nnetdir);
1223 if (nnetdir > 0) /* If there is a directory... */
1224 lunet(*xargv); /* Look up the name */
1225 else /* If no directory */
1226 nhcount = 0; /* we didn't find anything there */
1229 debug(F101,"cmdlin rlogin lunet nhcount","",nhcount);
1231 debug(F110,"cmdlin rlogin lunet nh_p[0]",nh_p[0],0);
1232 debug(F110,"cmdlin rlogin lunet nh_p2[0]",nh_p2[0],0);
1233 debug(F110,"cmdlin rlogin lunet nh_px[0][0]",
1238 if (nhcount > 0 && nh_p2[0]) /* If network type specified */
1239 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
1241 if (nhcount == 1) { /* Still OK, so make substitution */
1242 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1243 debug(F110,"cmdlin rlogin lunet substitution",ttname,0);
1248 if (!haveurl) { /* Service from command line? */
1249 ckstrncat(ttname,":login",TTNAMLEN+1);
1250 debug(F110,"cmdlin rlogin host2",ttname,0);
1252 local = 1; /* Try to open the connection */
1255 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1256 XFATAL("can't open host connection");
1258 network = 1; /* It's open */
1261 #endif /* CKLOGDIAL */
1263 reliable = 1; /* It's reliable */
1264 xreliable = 1; /* ... */
1267 cflg = 1; /* Connect */
1268 stayflg = 1; /* Stay */
1269 tn_exit = 1; /* Telnet-like exit condition */
1271 exitonclose = 1; /* Exit when connection closes */
1274 if (nmac) { /* Any macros defined? */
1276 k = mlook(mactab,"on_open",nmac); /* Look this up */
1277 if (k >= 0) { /* If found, */
1278 if (dodo(k,ttname,0) > -1) /* set it up, */
1279 parser(1); /* and execute it */
1289 #endif /* RLOGCODE */
1290 #endif /* TCPSOCKET */
1293 if (howcalled == I_AM_SSH) { /* If I was called as SSH... */
1294 extern char * ssh_hst, * ssh_cmd, * ssh_prt;
1295 debug(F100,"ssh personality","",0);
1298 makestr(&ssh_hst,g_url.hos);
1299 makestr(&ssh_prt,g_url.svc);
1300 ckstrncpy(ttname,ssh_hst,TTNAMLEN+1);
1301 ckstrncat(ttname,":",TTNAMLEN+1);
1302 ckstrncat(ttname,ssh_prt,TTNAMLEN+1);
1307 while (--xargc > 0) { /* Go through command line words */
1309 debug(F111,"cmdlin ssh xargv",*xargv,xargc);
1312 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1315 else if (**xargv == '/')
1318 /* Got an option (begins with dash) */
1319 else if (**xargv == '-') {
1321 x = *(*xargv+1); /* Get the option letter */
1322 debug(F111,"cmdlin args 1",*xargv,xargc);
1324 debug(F101,"cmdlin doarg","",xx);
1325 debug(F111,"cmdlin args 2",*xargv,xargc);
1328 if (what == W_COMMAND)
1334 sleep(1); /* Give it a chance... */
1336 doexit(BAD_EXIT,1); /* Go handle option */
1339 } else { /* No dash must be hostname */
1340 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
1341 makestr(&ssh_hst,ttname);
1342 debug(F110,"cmdlin ssh host",ttname,0);
1345 nhcount = 0; /* Check network directory */
1346 debug(F101,"cmdlin nnetdir","",nnetdir);
1347 if (nnetdir > 0) /* If there is a directory... */
1348 lunet(*xargv); /* Look up the name */
1349 else /* If no directory */
1350 nhcount = 0; /* we didn't find anything there */
1353 debug(F101,"cmdlin lunet nhcount","",nhcount);
1355 debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
1356 debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
1358 "cmdlin lunet nh_px[0][0]",nh_px[0][0],0);
1362 /* If network type specified */
1363 /* it must be TCP/IP */
1364 if (nhcount > 0 && nh_p2[0])
1365 if (ckstrcmp(nh_p2[0],"tcp/ip",6,0))
1367 if (nhcount == 1) { /* Still OK, so make substitution */
1368 ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
1369 makestr(&ssh_hst,ttname);
1370 debug(F110,"cmdlin lunet substitution",ttname,0);
1374 /* Service from command line? */
1375 if (--xargc > 0 && !haveurl) {
1377 ckstrncat(ttname,":",TTNAMLEN+1);
1378 ckstrncat(ttname,*xargv,TTNAMLEN+1);
1379 makestr(&ssh_prt,*xargv);
1380 debug(F110,"cmdlin telnet host2",ttname,0);
1383 /* Do not substitute net dir service for ssh port */
1386 /* No - how about in net directory? */
1389 ckstrncat(ttname,":",TTNAMLEN+1);
1390 ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
1391 makestr(&ssh_prt,nh_px[0][0]);
1397 #endif /* COMMENT */
1402 local = 1; /* Try to open the connection */
1405 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
1406 XFATAL("can't open host connection");
1408 network = 1; /* It's open */
1411 #endif /* CKLOGDIAL */
1413 reliable = 1; /* It's reliable */
1414 xreliable = 1; /* ... */
1417 cflg = 1; /* Connect */
1418 stayflg = 1; /* Stay */
1419 tn_exit = 1; /* Telnet-like exit condition */
1421 exitonclose = 1; /* Exit when connection closes */
1424 if (nmac) { /* Any macros defined? */
1426 k = mlook(mactab,"on_open",nmac); /* Look this up */
1427 if (k >= 0) { /* If found, */
1428 if (dodo(k,ttname,0) > -1) /* set it up, */
1429 parser(1); /* and execute it */
1436 #endif /* SSHBUILTIN */
1438 if (howcalled == I_AM_SSHSUB)
1442 From here down: We were called as "kermit" or "iksd".
1444 If we were started directly from a Kermit script file,
1445 the filename of the script is in argv[1], so skip past it.
1449 if (*xargv[1] != '-') {
1452 /* If we were started with a Kerbang script, the script */
1453 /* arguments were already picked up in prescan / cmdini() */
1454 /* and there is nothing here for us anyway. */
1455 if (!strcmp(xargv[1],"+"))
1457 #endif /* KERBANG */
1459 if (cfilef) { /* Command file found in prescan() */
1460 xargc -= n; /* Skip past it */
1463 debug(F101,"cmdlin cfilef set to 0","",cfilef);
1468 Regular Unix-style command line parser, mostly conforming with 'A Proposed
1469 Command Syntax Standard for Unix Systems', Hemenway & Armitage, Unix/World,
1472 while (--xargc > 0) { /* Go through command line words */
1474 debug(F111,"cmdlin xargv",*xargv,xargc);
1477 if (!strcmp(*xargv,"--")) /* getopt() conformance */
1480 else if (**xargv == '/')
1483 else if (**xargv == '-') { /* Got an option (begins with dash) */
1485 x = *(*xargv+1); /* Get the option letter */
1486 debug(F111,"cmdlin args 1",*xargv,xargc);
1488 debug(F101,"cmdlin doarg","",xx);
1489 debug(F111,"cmdlin args 2",*xargv,xargc);
1492 if (what == W_COMMAND)
1498 sleep(1); /* Give it a chance... */
1500 doexit(BAD_EXIT,1); /* Go handle option */
1503 } else if (!haveurl) { /* No dash where expected */
1507 k = ckstrncpy(xbuf,*xargv,40);
1516 "invalid command-line option, type \"",
1527 debug(F101,"cmdlin what","",what);
1529 debug(F101,"cmdlin action","",action);
1531 debug(F101,"cmdlin stdouf","",stdouf);
1537 if (!action && !cflg && !cnflg) {
1538 debug(F100,"cmdlin NOICP fatal no action","",0);
1539 XFATAL("?No actions specified on command line");
1542 if (inserver && what == 0) { /* Internet Kermit server checks */
1543 if (local || (action != 0 && action != 'x')) {
1545 printf("local\r\n");
1547 printf("action=%c\r\n",action);
1548 debug(F100,"cmdlin fatal 1","",0);
1549 XFATAL("No actions or connections allowed with -A");
1556 if ((action == 'c') || (cflg != 0)) {
1557 debug(F100,"cmdlin fatal 2","",0);
1558 XFATAL("-l or -j or -X required");
1561 #endif /* NOLOCAL */
1564 if ((action != 's') && (action != 'r') && (action != 'v')) {
1565 debug(F100,"cmdlin fatal 3","",0);
1566 XFATAL("-a without -s, -r, or -g");
1568 if (action == 'r' || action == 'v') {
1570 if (isdir(cmarg2)) { /* -a is a directory */
1571 if (!zchdir(cmarg2)) { /* try to change to it */
1572 debug(F100,"cmdlin fatal 4","",0);
1573 XFATAL("can't change to '-a' directory");
1576 #endif /* CK_TMPDIR */
1577 if (zchko(cmarg2) < 0) {
1578 debug(F100,"cmdlin fatal 5","",0);
1579 XFATAL("write access to -a file denied");
1583 if ((action == 'v') && (stdouf) && (!local)) {
1585 debug(F100,"cmdlin fatal 6","",0);
1586 XFATAL("unredirected -k can only be used in local mode");
1589 if ((action == 's') || (action == 'v') ||
1590 (action == 'r') || (action == 'x')) {
1598 if (quiet) displa = 0; /* No display if quiet requested */
1602 debug(F000,"cmdlin returns action","",action);
1604 debug(F101,"cmdlin returns action","",action);
1607 return(action); /* Then do any requested protocol */
1610 /* Extended argument parsing: --keyword[:value] (or =value) */
1613 XA_xxxx symbols are defined in ckuusr.h.
1614 If you add a new one, also remember to update doshow(),
1615 SHXOPT section, in ckuus5.c.
1617 struct keytab xargtab[] = {
1619 { "anonymous", XA_ANON, CM_ARG|CM_PRE },
1620 #endif /* CK_LOGIN */
1621 { "bannerfile", XA_BAFI, CM_ARG },
1622 { "cdfile", XA_CDFI, CM_ARG },
1623 { "cdmessage", XA_CDMS, CM_ARG },
1624 { "cdmsg", XA_CDMS, CM_ARG|CM_INV },
1626 { "changedim", XA_CHGD, CM_PRE },
1629 { "charset", XA_CSET, CM_ARG|CM_PRE },
1630 #endif /* NOCSETS */
1632 { "database", XA_DBAS, CM_ARG|CM_PRE },
1633 { "dbfile", XA_DBFI, CM_ARG|CM_PRE },
1636 { "facename", XA_FNAM, CM_ARG|CM_PRE|CM_INV },
1637 { "fontname", XA_FNAM, CM_ARG|CM_PRE },
1638 { "fontsize", XA_FSIZ, CM_ARG|CM_PRE },
1642 { "ftp", XA_FTP, CM_ARG },
1644 #endif /* COMMENT */
1647 { "height", XA_ROWS, CM_ARG|CM_PRE },
1649 #endif /* NOLOCAL */
1650 { "help", XA_HELP, 0 },
1652 { "helpfile", XA_HEFI, CM_ARG },
1655 { "initfile", XA_ANFI, CM_ARG|CM_PRE },
1656 #endif /* CK_LOGIN */
1658 { "lockdown", XA_LOCK, CM_PRE },
1660 { "maximize", XA_WMAX, CM_PRE },
1661 { "minimize", XA_WMIN, CM_PRE },
1662 { "nobars", XA_NOBAR, CM_PRE },
1664 { "noescape", XA_NOESCAPE, CM_PRE },
1666 { "nointerrupts",XA_NOIN, CM_PRE },
1668 { "nomenubar", XA_NOMN, CM_PRE },
1670 { "noperms", XA_NPRM, 0 },
1672 { "nopush", XA_NOPUSH, CM_PRE },
1675 { "noscroll", XA_NOSCROLL, CM_PRE },
1678 { "nostatusbar", XA_NOSB, CM_PRE },
1679 { "notoolbar", XA_NOTB, CM_PRE },
1682 { "password", XA_PASS, CM_ARG|CM_INV },
1683 #endif /* COMMENT */
1687 { "permissions", XA_PERM, CM_ARG|CM_PRE },
1688 { "perms", XA_PERM, CM_ARG|CM_PRE|CM_INV },
1689 #endif /* CK_PERM */
1692 { "privid", XA_PRIV, CM_ARG|CM_PRE },
1696 { "rcharset", XA_CSET, CM_ARG|CM_PRE|CM_INV },
1697 #endif /* NOCSETS */
1698 #endif /* NOLOCAL */
1700 { "root", XA_ROOT, CM_ARG|CM_PRE },
1703 { "root", XA_ROOT, CM_ARG|CM_PRE },
1707 { "scalefont", XA_SCALE, CM_PRE },
1711 { "ssh", XA_SSH, CM_ARG },
1712 #endif /* SSHBUILTIN */
1713 #endif /* COMMENT */
1715 { "syslog", XA_SYSL, CM_ARG|CM_PRE },
1716 #endif /* CKSYSLOG */
1720 { "telnet", XA_TEL, CM_ARG },
1722 #endif /* COMMENT */
1723 { "termtype", XA_TERM, CM_ARG|CM_PRE },
1724 #endif /* NOLOCAL */
1725 { "timeout", XA_TIMO, CM_ARG|CM_PRE },
1728 { "title", XA_TITL, CM_ARG },
1731 { "user", XA_USER, CM_ARG },
1733 #endif /* NOLOCAL */
1734 { "userfile", XA_USFI, CM_ARG|CM_PRE },
1735 { "version", XA_VERS, 0 },
1738 { "width", XA_COLS, CM_ARG|CM_PRE },
1740 #endif /* NOLOCAL */
1742 { "wtmpfile", XA_WTFI, CM_ARG|CM_PRE },
1743 { "wtmplog", XA_WTMP, CM_ARG|CM_PRE },
1745 #endif /* CK_LOGIN */
1746 { "xferfile", XA_IKFI, CM_ARG|CM_PRE },
1747 { "xferlog", XA_IKLG, CM_ARG|CM_PRE },
1750 { "xpos", XA_XPOS, CM_ARG|CM_PRE },
1751 { "ypos", XA_YPOS, CM_ARG|CM_PRE },
1753 #endif /* NOLOCAL */
1756 int nxargs = sizeof(xargtab)/sizeof(struct keytab) - 1;
1758 static struct keytab oktab[] = {
1777 static int noktab = sizeof(oktab)/sizeof(struct keytab);
1781 char * xopthlp[XA_MAX+1]; /* Extended option help */
1782 char * xarghlp[XA_MAX+1]; /* Extended argument for option */
1787 for (i = 0; i <= XA_MAX; i++) { /* Initialize all to null */
1791 for (i = 0; i < nxargs; i++) { /* Then for each defined keyword */
1792 j = xargtab[i].kwval; /* index by associated value */
1793 if (j < 0 || j > XA_MAX)
1797 case XA_ANON: /* "--anonymous" */
1798 xopthlp[j] = "--anonymous:{on,off} [IKSD only]";
1799 xarghlp[j] = "Whether to allow anonymous IKSD logins";
1803 xopthlp[j] = "--privid:{on,off} [IKSD only]";
1804 xarghlp[j] = "Whether to allow privileged IDs to login to IKSD";
1807 #endif /* CK_LOGIN */
1808 case XA_BAFI: /* "--bannerfile" */
1809 xopthlp[j] = "--bannerfile:<filename>";
1810 xarghlp[j] = "File to display upon startup or IKSD login";
1812 case XA_CDFI: /* "--cdfile" */
1813 xopthlp[j] = "--cdfile:<filename>";
1814 xarghlp[j] = "File to display when server changes directory";
1816 case XA_CDMS: /* "--cdmessage" */
1817 xopthlp[j] = "--cdmessage:{on,off}";
1818 xarghlp[j] = "Whether to display CD message file";
1820 case XA_HELP: /* "--help" */
1821 xopthlp[j] = "--help";
1822 xarghlp[j] = "Print this help text about extended options";
1824 case XA_HEFI: /* "--help" */
1825 xopthlp[j] = "--helpfile:<filename>";
1826 xarghlp[j] = "File containing custom info for HELP command";
1828 case XA_IKFI: /* "--xferfile" */
1829 xopthlp[j] = "--xferfile:<filename> [IKSD only]";
1830 xarghlp[j] = "Name of ftpd-like logfile.";
1832 case XA_IKLG: /* "--xferlog" */
1833 xopthlp[j] = "--xferlog:{on,off} [IKSD only]";
1834 xarghlp[j] = "Whether to keep an ftpd-like logfile.";
1837 case XA_ANFI: /* "--initfile" */
1838 xopthlp[j] = "--initfile:<filename> [IKSD only]";
1839 xarghlp[j] = "Initialization file for anonymous users.";
1842 case XA_PERM: /* "--permissions" */
1843 xopthlp[j] = "--permissions:<octalnum> [IKSD only]";
1844 xarghlp[j] = "Permissions for files uploaded by anonymous users.";
1846 #endif /* CK_PERM */
1848 case XA_ROOT: /* "--root" */
1849 xopthlp[j] = "--root:<directory> [IKSD only]";
1850 xarghlp[j] = "File-system root for anonymous users.";
1854 case XA_ROOT: /* "--root" */
1855 xopthlp[j] = "--root:<directory> [IKSD only]";
1856 xarghlp[j] = "File-system root for anonymous users.";
1860 #endif /* CK_LOGIN */
1862 case XA_SYSL: /* "--syslog" */
1863 xopthlp[j] = "--syslog:<digit> [IKSD only]";
1864 xarghlp[j] = "Syslog recording level, 0-6.";
1866 #endif /* CKSYSLOG */
1867 case XA_USFI: /* "--userfile" */
1868 xopthlp[j] = "--userfile:<filename> [IKSD only]";
1869 xarghlp[j] = "Forbidden user file.";
1872 case XA_WTFI: /* "--wtmpfile" */
1873 xopthlp[j] = "--wtmpfile:<filename> [IKSD only]";
1874 xarghlp[j] = "Name of wtmp logfile.";
1876 case XA_WTMP: /* "--wtmplog" */
1877 xopthlp[j] = "--wtmplog:{on,off} [IKSD only]";
1878 xarghlp[j] = "Whether to keep a wtmp logfile.";
1882 case XA_TIMO: /* "--timeout" */
1883 xopthlp[j] = "--timeout:<seconds> [IKSD only]";
1885 "How long to wait for login before closing the connection.";
1887 #endif /* CK_LOGIN */
1889 xopthlp[j] = "--nointerrupts";
1890 xarghlp[j] = "Disable keyboard interrupts.";
1894 xopthlp[j] = "--database:{on,off}";
1895 xarghlp[j] = "Enable/Disable IKSD database (IKSD only)";
1898 xopthlp[j] = "--dbfile:<filename>";
1899 xarghlp[j] = "Specify IKSD database file (IKSD only)";
1904 xopthlp[j] = "--noperms";
1905 xarghlp[j] = "Disable file-transfer Permissions attribute.";
1907 #endif /* CK_PERMS */
1910 xopthlp[j] = "--changedim";
1911 xarghlp[j] = "Change Dimension on Window Resize";
1913 xopthlp[j] = "--scalefont";
1914 xarghlp[j] = "Scale Font on Window Resize";
1916 xopthlp[j] = "--maximize";
1917 xarghlp[j] = "start K95G window maximized.";
1920 xopthlp[j] = "--minimize";
1921 xarghlp[j] = "start K95G window minimized.";
1924 xopthlp[j] = "--xpos:n";
1925 xarghlp[j] = "X-coordinate of window position (number).";
1928 xopthlp[j] = "--ypos:n";
1929 xarghlp[j] = "Y-coordinate of window position (number).";
1932 xopthlp[j] = "--fontname:s (or --facename:s)";
1933 xarghlp[j] = "Font/typeface name: string with _ replacing blank.";
1936 xopthlp[j] = "--fontsize:n";
1937 xarghlp[j] = "Font point size (number).";
1940 xopthlp[j] = "--nomenubar";
1941 xarghlp[j] = "No Menu Bar";
1944 xopthlp[j] = "--notoolbar";
1945 xarghlp[j] = "No Tool Bar";
1948 xopthlp[j] = "--nostatusbar";
1949 xarghlp[j] = "No Status Bar";
1952 xopthlp[j] = "--nobars";
1953 xarghlp[j] = "No Menu, Status, or Tool Bars";
1958 xopthlp[j] = "--nopush";
1959 xarghlp[j] = "Disable external command execution.";
1964 xopthlp[j] = "--lockdown";
1965 xarghlp[j] = "Enable all lockdown options.";
1968 xopthlp[j] = "--noscroll";
1969 xarghlp[j] = "Disable scrollback operations.";
1972 xopthlp[j] = "--noescape";
1973 xarghlp[j] = "Disable escape from connect mode.";
1976 xopthlp[j] = "--height:n";
1977 xarghlp[j] = "Screen height (number of rows).";
1980 xopthlp[j] = "--width:n";
1981 xarghlp[j] = "Screen width (number of columns).";
1984 xopthlp[j] = "--title:string";
1985 xarghlp[j] = "Window Title.";
1989 xopthlp[j] = "--rcharset:name";
1990 xarghlp[j] = "Name of remote terminal character set.";
1993 xopthlp[j] = "--termtype:name";
1995 xarghlp[j] = "Choose terminal emulation.";
1997 xarghlp[j] = "Choose terminal type.";
2001 xopthlp[j] = "--user:name";
2003 xarghlp[j] = "Username (for network login)";
2005 xarghlp[j] = "Username.";
2006 #endif /* NETCONN */
2015 for (i = 0; i < 128; i++) {
2019 case '#': /* K95 Startup Flags */
2020 opthlp[i] = "Kermit 95 Startup Flags";
2022 " 1 - turn off Win95 special fixes\n"\
2023 " 2 - do not load optional network dlls\n"\
2024 " 4 - do not load optional tapi dlls\n"\
2025 " 8 - do not load optional kerberos dlls\n"\
2026 " 16 - do not load optional zmodem dlls\n"\
2027 " 32 - use stdin for input instead of the console\n"\
2028 " 64 - use stdout for output instead of the console\n"\
2029 " 128 - do not terminate process in response to Session Logoff";
2032 case '0': /* In the middle */
2034 "100% transparent CONNECT mode for \"in-the-middle\" operation";
2039 opthlp[i] = "Connection is 8-bit clean";
2045 opthlp[i] = "Make a connection to an FTP server";
2046 arghlp[i] = "IP-address-or-hostname[:optional-TCP-port]";
2052 opthlp[i] = "Kermit is to be started as an Internet service";
2054 arghlp[i] = " socket handle of incoming connection";
2060 case 'B': opthlp[i] =
2061 "Kermit is running in Batch or Background (no controlling terminal)";
2065 opthlp[i] = "Interactive-mode Commands to be executed";
2066 arghlp[i] = "Commands separated by commas, list in doublequotes";
2070 opthlp[i] = "Delay before starting to send";
2071 arghlp[i] = "Number of seconds";
2074 opthlp[i] = "Exit automatically when connection closes";
2079 opthlp[i] = "Make a TCP connection";
2080 arghlp[i] = "Numeric file descriptor of open TCP connection";
2082 #endif /* TCPSOCKET */
2084 opthlp[i] = "GET from server, send to standard output";
2085 arghlp[i] = "Remote file specification";
2089 opthlp[i] = "Suppress program startup Herald and greeting";
2093 opthlp[i] = "Connection is reliable, streaming is allowed";
2098 opthlp[i] = "'Be like Telnet'";
2099 arghlp[i] = "IP hostname/address optionally followed by service";
2101 #endif /* TCPSOCKET */
2103 opthlp[i] = "Recursive directory descent for files in -s option";
2107 opthlp[i] = "My user name (for use with Telnet, Rlogin, etc)";
2108 arghlp[i] = "Username string";
2112 opthlp[i] = "NETBIOS adapter number";
2113 arghlp[i] = "Number";
2115 #endif /* NETBIOS */
2116 case 'O': /* Be a server for One command only */
2117 opthlp[i] = "Be a server for One command only";
2122 opthlp[i] = "Don't convert file (Path) names";
2126 opthlp[i] = "Quick (FAST) Kermit protocol settings";
2129 case 'R': /* Remote-Only */
2130 opthlp[i] = "Remote-only (makes IF REMOTE true)";
2133 case 'S': /* "Stay" - enter interactive */
2134 opthlp[i] = "Stay (enter command parser after action options)";
2137 case 'T': /* Text file transfer mode */
2138 opthlp[i] = "Transfer files in Text mode";
2142 case 'U': /* X.25 call user data */
2143 opthlp[i] = "X.25 call User data";
2144 arghlp[i] = "Call-user-data string";
2147 case 'V': /* No automatic filetype switching */
2148 opthlp[i] = "Disable automatic per-file text/binary switching";
2153 case 'W': /* Win32 Window Handle */
2158 #endif /* COMMENT */
2160 case 'X': /* SET HOST to X.25 address */
2161 opthlp[i] = "Make an X.25 connection";
2162 arghlp[i] = "X.25 or X.121 address";
2165 case 'Y': /* No initialization file */
2166 opthlp[i] = "Skip initialization file";
2170 case 'Z': /* SET HOST to X.25 file descriptor */
2171 opthlp[i] = "Make an X.25 connection";
2172 arghlp[i] = "Numeric file descriptor of open X.25 connection";
2175 case 'a': /* as-name */
2176 opthlp[i] = "As-name for file(s) in -s, -r, or -g";
2177 arghlp[i] = "As-name string (alternative filename)";
2179 case 'b': /* Set bits-per-second for serial */
2180 opthlp[i] = "Speed for serial device";
2181 arghlp[i] = "Numeric Bits per second";
2183 case 'c': /* Connect before */
2185 opthlp[i] = "CONNECT before transferring files";
2188 case 'd': /* DEBUG */
2189 opthlp[i] = "Create debug.log file (a second -d adds timestamps)";
2192 case 'e': /* Extended packet length */
2193 opthlp[i] = "Maximum length for incoming file-transfer packets";
2194 arghlp[i] = "Length in bytes";
2196 case 'f': /* finish */
2198 opthlp[i] = "Send Finish command to a Kermit server";
2203 opthlp[i] = "GET file(s) from a Kermit server";
2204 arghlp[i] = "Remote file specification";
2206 case 'h': /* help */
2210 "Print this message (pipe thru 'more' to prevent scrolling)";
2212 "Print this message";
2213 #endif /* OS2ORUNIX */
2216 case 'i': /* Treat files as binary */
2217 opthlp[i] ="Transfer files in binary mode";
2221 case 'j': /* SET HOST (TCP/IP socket) */
2222 opthlp[i] = "Make a TCP connection";
2224 "TCP host name/address and optional service name or number";
2226 #endif /* TCPSOCKET */
2227 case 'k': /* receive to stdout */
2229 opthlp[i] = "RECEIVE file(s) to standard output";
2232 case 'l': /* SET LINE */
2233 opthlp[i] = "Make connection on serial communications device";
2234 arghlp[i] = "Serial device name";
2236 case 'm': /* Modem type */
2237 opthlp[i] = "Modem type for use with -l device";
2238 arghlp[i] = "Modem name as in SET MODEM TYPE command";
2240 case 'n': /* connect after */
2242 opthlp[i] = "CONNECT after transferring files";
2246 case 'o': /* X.25 closed user group */
2247 opthlp[i] = "X.25 closed user group";
2248 arghlp[i] = "User group string";
2251 case 'p': /* SET PARITY */
2252 opthlp[i] = "Parity";
2253 arghlp[i] = "One of the following: even, odd, mark, none, space";
2255 case 'q': /* Quiet */
2256 opthlp[i] = "Quiet (suppress most messages)";
2259 case 'r': /* receive */
2261 opthlp[i] = "RECEIVE file(s)";
2264 case 's': /* send */
2266 opthlp[i] = "SEND file(s)";
2267 arghlp[i] = "One or more file specifications";
2269 case 't': /* Line turnaround handshake */
2270 opthlp[i] = "XON Turnaround character for half-duplex connections";
2274 case 'u': /* X.25 reverse charge call */
2275 opthlp[i] = "X.25 reverse charge call";
2279 case 'v': /* Vindow size */
2280 opthlp[i] = "Window size";
2281 arghlp[i] = "Number, 1 to 32";
2283 case 'w': /* Writeover */
2284 opthlp[i] = "Incoming files Write over existing files";
2287 case 'x': /* Server */
2289 opthlp[i] = "Be a Kermit SERVER";
2292 case 'y': /* Alternate init-file name */
2293 opthlp[i] = "Alternative initialization file";
2294 arghlp[i] = "File specification";
2296 case 'z': /* Not background */
2297 opthlp[i] = "Force foreground behavior";
2309 doxarg(s,pre) char ** s; int pre; {
2312 extern int ckxsyslog, ckxwtmp, ckxanon;
2317 extern int ckxperms;
2318 #endif /* CK_PERMS */
2319 extern char * anonfile, * userfile, * anonroot;
2320 #endif /* CK_LOGIN */
2322 extern char * wtmpfile;
2325 extern int srvcdmsg;
2326 extern char * cdmsgfile[], * cdmsgstr;
2327 char tmpbuf[CKMAXPATH+1];
2329 int i, x, y, z, havearg = 0;
2330 char buf[XARGBUFL], c, * p;
2335 c = *(*s + 1); /* Hyphen or Plus sign */
2338 for (i = 0; *p && i < XARGBUFL; i++) {
2340 if (buf[i] == '=' || buf[i] == ':') {
2344 } else if (buf[i] < ' ') {
2349 if (i > XARGBUFL - 1)
2353 x = lookup(xargtab,buf,nxargs,&z); /* Lookup the option keyword */
2355 if (x < 0) /* On any kind of error */
2356 return(-1); /* fail. */
2358 /* Handle prescan versus post-initialization file */
2360 if (((xargtab[z].flgs & CM_PRE) || (c == '+')) && !pre)
2362 else if (pre && !(xargtab[z].flgs & CM_PRE) && (c != '+'))
2365 /* Ensure that argument is given if and only if required */
2367 p = havearg ? *s + i + 3 : NULL;
2369 if ((xargtab[z].flgs & CM_ARG) && !havearg)
2371 else if ((!(xargtab[z].flgs & CM_ARG)) && havearg)
2374 switch (x) { /* OK to process this option... */
2376 case XA_SYSL: /* IKS: Syslog level */
2380 if (*p < '0' || *p > '9')
2382 y = y * 10 + (*p++ - '0');
2385 y = lookup(oktab,p,noktab,&z);
2386 if (y > 0) y = SYSLG_DF; /* Yes = default logging level */
2389 /* If specified on cc command line, user can't change it. */
2390 if (!inserver) /* Don't allow voluminous syslogging */
2391 if (y > SYSLG_FA) /* by ordinary users. */
2393 #endif /* SYSLOGLEVEL */
2394 if (y < 0) return(-1);
2398 deblog = debopn("debug.log",0);
2401 /* If specified on cc command line, user can't change it. */
2403 #endif /* SYSLOGLEVEL */
2405 /* printf("ckxsyslog=%d\n",ckxsyslog); */
2407 #endif /* CKSYSLOG */
2411 case XA_WTMP: /* IKS: wtmp log */
2412 y = lookup(oktab,p,noktab,&z);
2413 if (y < 0) return(-1);
2415 /* printf("ckxwtmp=%d\n",ckxwtmp); */
2418 case XA_WTFI: /* IKS: wtmp logfile */
2419 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2421 makestr(&wtmpfile,p);
2422 /* printf("wtmpfile=%s\n",wtmpfile); */
2426 case XA_ANON: /* IKS: Anonymous login allowed */
2427 y = lookup(oktab,p,noktab,&z);
2428 if (y < 0) return(-1);
2430 /* printf("ckxanon=%d\n",ckxanon); */
2434 case XA_PRIV: /* IKS: Priv'd login allowed */
2435 y = lookup(oktab,p,noktab,&z);
2436 if (y < 0) return(-1);
2438 /* printf("ckxpriv=%d\n",ckxpriv); */
2443 case XA_PERM: /* IKS: Anonymous Upload Permissions */
2446 if (*p < '0' || *p > '7')
2448 y = y * 8 + (*p++ - '0');
2451 /* printf("ckxperms=%04o\n",ckxperms); */
2453 #endif /* CK_PERMS */
2455 case XA_ANFI: /* Anonymous init file */
2457 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2459 makestr(&anonfile,p);
2460 /* printf("anonfile=%s\n",anonfile); */
2463 case XA_USFI: /* IKS: Forbidden user file */
2465 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2467 makestr(&userfile,p);
2468 /* printf("userfile=%s\n",userfile); */
2471 case XA_ROOT: /* IKS: Anonymous root */
2473 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2475 makestr(&anonroot,p);
2476 /* printf("anonroot=%s\n",anonroot); */
2478 #endif /* CK_LOGIN */
2480 case XA_CDFI: /* CD filename */
2482 /* Do NOT expand this one! */
2483 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2485 #endif /* COMMENT */
2486 makelist(p,cdmsgfile,16);
2487 makestr(&cdmsgstr,p);
2488 /* printf("cdmsgstr=%s\n",cdmsgstr); */
2491 case XA_CDMS: /* CD messages */
2492 y = lookup(oktab,p,noktab,&z);
2493 if (y < 0) return(-1);
2495 /* printf("srvcdmsg=%d\n",srvcdmsg); */
2499 case XA_IKLG: /* Transfer log on/off */
2500 y = lookup(oktab,p,noktab,&z);
2501 if (y < 0) return(-1);
2503 /* printf("xferlog=%d\n",xferlog); */
2506 case XA_IKFI: /* Transfer log file */
2508 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2510 makestr(&xferfile,p);
2512 /* printf("xferfile=%s\n",xferfile); */
2515 case XA_BAFI: /* IKS: banner (greeting) file */
2517 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2519 makestr(&bannerfile,p);
2520 /* printf("bannerfile=%s\n",bannerfile); */
2525 case XA_HELP: /* Help */
2526 /* printf("help\n"); */
2527 for (i = 0; i <= XA_MAX; i++)
2529 printf("%s\n %s\n\n",xopthlp[i],xarghlp[i]);
2530 if (stayflg || what == W_COMMAND)
2533 doexit(GOOD_EXIT,-1);
2537 case XA_HEFI: /* IKS: custom help file */
2539 if (zfnqfp(p,CKMAXPATH,tmpbuf))
2541 makestr(&helpfile,p);
2542 /* printf("helpfile=%s\n",helpfile); */
2550 logintimo = atoi(p);
2551 /* printf("logintimo=%d\n",p); */
2553 #endif /* CK_LOGIN */
2555 case XA_NOIN: /* No interrupts */
2564 extern char * dbdir, * dbfile;
2565 extern int dbenabled;
2567 if ((zz = zfnqfp(p,CKMAXPATH,tmpbuf))) {
2568 char *s, *s2 = NULL;
2569 makestr(&dbdir,zz->fpath);
2570 makestr(&dbfile,zz->fpath);
2571 for (s = dbdir; *s; s++) {
2576 debug(F110,"XA_DBFI dbdir",dbdir,0);
2577 debug(F110,"XA_DBFI dbfile",dbfile,0);
2583 extern int dbenabled;
2584 y = lookup(oktab,p,noktab,&z);
2585 if (y < 0) return(-1);
2592 extern char * ck_s_ver, * ck_s_xver;
2593 printf("%s",ck_s_ver);
2595 printf(" [%s]\n",ck_s_xver);
2597 if (stayflg || what == W_COMMAND)
2600 doexit(GOOD_EXIT,-1);
2605 extern int atlpri, atlpro, atgpri, atgpro;
2612 #endif /* CK_PERMS */
2617 kui_init.resizeMode = 1;
2620 kui_init.resizeMode = 2;
2623 kui_init.nCmdShow = SW_MAXIMIZE;
2626 kui_init.nCmdShow = SW_MINIMIZE;
2632 kui_init.pos_init++;
2633 kui_init.pos_x = atoi(p);
2639 kui_init.pos_init++;
2640 kui_init.pos_y = atoi(p);
2644 extern struct _kui_init kui_init;
2645 extern struct keytab * term_font;
2646 extern struct keytab * _term_font;
2647 extern int tt_font, ntermfont;
2650 BuildFontTable(&term_font, &_term_font, &ntermfont);
2651 if (!(term_font && _term_font && ntermfont > 0)) {
2652 printf("?Unable to construct Font Facename Table\n");
2655 x = lookup(term_font,p,ntermfont,&z);
2657 x = lookup(_term_font,p,ntermfont,&z);
2659 printf("?Invalid Font Facename: %s\n",p);
2664 kui_init.face_init++;
2665 makestr(&kui_init.facename,term_font[z].kwd);
2669 extern struct _kui_init kui_init;
2670 extern int tt_font_size;
2674 kui_init.font_init++;
2675 for ( q=p ; *q ; q++ ) {
2680 if (!*q || atoi(q) == 0)
2681 break; /* no halfpoint */
2684 printf("? Font sizes are treated in half-point increments\n");
2690 tt_font_size = kui_init.font_size = 2 * atoi(p) + halfpoint;
2694 kui_init.nomenubar = 1;
2697 kui_init.notoolbar = 1;
2700 kui_init.nostatusbar = 1;
2703 kui_init.nomenubar = 1;
2704 kui_init.notoolbar = 1;
2705 kui_init.nostatusbar = 1;
2722 kui_init.nomenubar = 1;
2723 kui_init.notoolbar = 1;
2724 kui_init.nostatusbar = 1;
2736 case XA_TERM: { /* Terminal type */
2737 extern struct keytab ttyptab[];
2740 extern char * tn_term;
2744 extern int tt_type, tt_type_mode;
2745 x = lookup(ttyptab,p,nttyp,&z);
2748 tt_type_mode = tt_type = x;
2751 makestr(&tn_term,p);
2755 case XA_CSET: { /* Remote Character Set */
2758 extern struct keytab txrtab[];
2760 x = lookup(txrtab,p,ntxrtab,&z);
2762 extern struct keytab ttcstab[];
2764 x = lookup(ttcstab,p,ntermc,&z);
2768 setremcharset(z,4 /* TT_GR_ALL (in ckuus7.c) */);
2771 #endif /* NOCSETS */
2774 case XA_ROWS: { /* Screen rows (height) */
2776 extern int row_init;
2783 if (!os2_settermheight(atoi(p)))
2786 #else /* Not OS/2 */
2791 case XA_COLS: { /* Screen columns (width) */
2793 extern int col_init;
2800 if (!os2_settermwidth(atoi(p)))
2803 #else /* Not OS/2 */
2814 #ifdef COMMENT /* TO BE FILLED IN ... */
2815 case XA_TEL: /* Make a Telnet connection */
2816 case XA_FTP: /* Make an FTP connection */
2817 case XA_SSH: /* Make an SSH connection */
2818 #endif /* COMMENT */
2821 case XA_USER: /* Username for login */
2826 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
2831 #endif /* NOLOCAL */
2863 #define IKS_NTDOM 22
2867 static struct keytab iksantab[] = {
2869 { "account", IKS_ACCT, 0 },
2871 { "initfile", IKS_ANFI, 0 },
2872 { "login", IKS_ANLG, 0 },
2874 { "root", IKS_ROOT, 0 },
2877 { "root", IKS_ROOT, 0 },
2882 static int niksantab = sizeof(iksantab) / sizeof(struct keytab) - 1;
2883 #endif /* CK_LOGIN */
2885 static struct keytab ikstab[] = {
2887 { "anonymous", IKS_ANON, 0 },
2888 #endif /* CK_LOGIN */
2889 { "bannerfile", IKS_BAFI, 0 },
2890 { "cdfile", IKS_CDFI, 0 },
2891 { "cdmessage", IKS_CDMS, 0 },
2892 { "cdmsg", IKS_CDMS, CM_INV },
2894 { "database", IKS_DBAS, 0 },
2895 { "dbfile", IKS_DBFI, 0 },
2899 { "default-domain", IKS_NTDOM, 0 },
2901 #endif /* CK_LOGIN */
2903 { "helpfile", IKS_HEFI, 0 },
2905 { "initfile", IKS_INIT, 0 },
2906 { "no-initfile", IKS_NOIN, 0 },
2909 { "permissions", IKS_PERM, 0 },
2910 { "perms", IKS_PERM, CM_INV },
2911 #endif /* CK_PERM */
2913 { "privid", IKS_PRIV, 0 },
2915 { "server-only", IKS_SRVR, 0 },
2917 { "syslog", IKS_SYSL, 0 },
2918 #endif /* CKSYSLOG */
2919 { "timeout", IKS_TIMO, 0 },
2920 { "userfile", IKS_USFI, 0 },
2922 { "wtmpfile", IKS_WTFI, 0 },
2923 { "wtmplog", IKS_WTMP, 0 },
2925 #endif /* CK_LOGIN */
2926 { "xferfile", IKS_IKFI, 0 },
2927 { "xferlog", IKS_IKLG, 0 }
2929 static int nikstab = sizeof(ikstab) / sizeof(struct keytab);
2930 #endif /* IKSDCONF */
2934 setiks() { /* SET IKS */
2937 extern int ckxsyslog, ckxwtmp, ckxanon;
2942 extern int ckxperms;
2943 #endif /* CK_PERMS */
2944 extern char * anonfile, * userfile, * anonroot;
2946 extern char * anonacct;
2949 extern char * iks_domain;
2951 #endif /* CK_LOGIN */
2953 extern char * wtmpfile;
2955 extern int srvcdmsg, success, iksdcf, rcflag, noinit, arg_x;
2956 extern char * cdmsgfile[], * cdmsgstr, *kermrc;
2957 extern xx_strp xxstring;
2960 char tmpbuf[CKMAXPATH+1];
2962 if ((y = cmkey(ikstab,nikstab,"","",xxstring)) < 0)
2966 if (y == IKS_ANON) {
2967 if ((y = cmkey(iksantab,niksantab,"","",xxstring)) < 0)
2970 #endif /* CK_LOGIN */
2974 case IKS_SYSL: /* IKS: Syslog level */
2975 if ((z = cmkey(oktab,noktab,"","",xxstring)) < 0)
2977 if ((x = cmcfm()) < 0) return(x);
2978 if (iksdcf) return(success = 0);
2980 /* If specified on cc command line, user can't change it. */
2981 if (!inserver) /* Don't allow voluminous syslogging */
2982 if (y > SYSLG_FA) /* by ordinary users. */
2984 #endif /* SYSLOGLEVEL */
2985 if (y < 0) return(-1);
2989 deblog = debopn("debug.log",0);
2992 /* If specified on cc command line, user can't change it. */
2994 #endif /* SYSLOGLEVEL */
2996 /* printf("ckxsyslog=%d\n",ckxsyslog); */
2998 #endif /* CKSYSLOG */
3004 "DOMAIN to be used for user authentication when none is specified",
3005 "", &s,xxstring)) < 0)
3007 if (iksdcf) return(success = 0);
3009 makestr(&iks_domain,s);
3014 if ((z = cmtxt("Name of local account to use for anonymous logins",
3015 "GUEST", &s,xxstring)) < 0)
3017 if (iksdcf) return(success = 0);
3019 makestr(&anonacct,s);
3020 } else if ( anonacct ) {
3027 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3029 if ((x = cmcfm()) < 0) return(x);
3030 if (iksdcf) return(success = 0);
3033 if (ckxanon && !anonacct)
3034 makestr(&anonacct,"GUEST");
3037 #endif /* CK_LOGIN */
3039 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3042 printf("?Wildcards not allowed\n");
3045 debug(F110,"bannerfile before zfnqfp()",s,0);
3046 if (zfnqfp(s,CKMAXPATH,tmpbuf)) {
3047 debug(F110,"bannerfile after zfnqfp()",tmpbuf,0);
3050 if ((x = cmcfm()) < 0) return(x);
3051 if (iksdcf) return(success = 0);
3053 makestr(&bannerfile,s);
3056 if ((z = cmtxt("list of cd message file names","READ.ME",
3059 if (iksdcf) return(success = 0);
3061 makelist(s,cdmsgfile,16);
3062 makestr(&cdmsgstr,s);
3066 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3068 if ((x = cmcfm()) < 0) return(x);
3069 if (iksdcf) return(success = 0);
3073 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3076 printf("?Wildcards not allowed\n");
3079 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3081 if ((x = cmcfm()) < 0) return(x);
3082 if (iksdcf) return(success = 0);
3084 makestr(&helpfile,s);
3087 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3090 printf("?Wildcards not allowed\n");
3093 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3095 if ((x = cmcfm()) < 0) return(x);
3096 if (iksdcf) return(success = 0);
3098 makestr(&anonfile,s);
3101 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3104 printf("?Wildcards not allowed\n");
3107 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3109 if ((x = cmcfm()) < 0) return(x);
3110 if (iksdcf) return(success = 0);
3112 makestr(&userfile,s);
3115 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3118 printf("?Wildcards not allowed\n");
3121 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3123 if ((x = cmcfm()) < 0) return(x);
3124 if (iksdcf) return(success = 0);
3126 makestr(&xferfile,s);
3131 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3133 if ((x = cmcfm()) < 0) return(x);
3134 if (iksdcf) return(success = 0);
3141 if ((z = cmtxt("Octal file permssion code","000",
3144 if (z < 0) return(z);
3145 if (iksdcf) return(success = 0);
3148 if (*s < '0' || *s > '7')
3150 y = y * 8 + (*s++ - '0');
3154 #endif /* CK_PERM */
3156 case IKS_PRIV: /* IKS: Priv'd login allowed */
3157 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3159 if ((x = cmcfm()) < 0) return(x);
3160 if (iksdcf) return(success = 0);
3165 case IKS_ROOT: /* IKS: Anonymous root */
3166 if ((z = cmdir("Name of disk and/or directory","",&s,
3172 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3176 if ((x = cmcfm()) < 0) return(x);
3177 if (iksdcf) return(success = 0);
3179 makestr(&anonroot,s);
3180 /* printf("anonroot=%s\n",anonroot); */
3184 z = cmnum("login timeout, seconds","0",10,&x,xxstring);
3185 if (z < 0) return(z);
3186 if (x < 0 || x > 7200) {
3187 printf("?Value must be between 0 and 7200\r\n");
3190 if ((z = cmcfm()) < 0) return(z);
3191 if (iksdcf) return(success = 0);
3196 case IKS_WTMP: /* IKS: wtmp log */
3197 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3199 if ((x = cmcfm()) < 0) return(x);
3200 if (iksdcf) return(success = 0);
3204 case IKS_WTFI: /* IKS: wtmp logfile */
3205 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3208 printf("?Wildcards not allowed\n");
3211 if (zfnqfp(s,CKMAXPATH,tmpbuf))
3213 if ((x = cmcfm()) < 0) return(x);
3214 if (iksdcf) return(success = 0);
3216 makestr(&wtmpfile,s);
3219 #endif /* CK_LOGIN */
3222 extern char * dbdir, * dbfile;
3223 extern int dbenabled;
3225 if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
3228 printf("?Wildcards not allowed\n");
3231 zz = zfnqfp(s,CKMAXPATH,tmpbuf);
3232 if ((x = cmcfm()) < 0) return(x);
3233 if (iksdcf) return(success = 0);
3235 makestr(&dbdir,zz->fpath);
3236 makestr(&dbfile,(char *)tmpbuf);
3239 return(success = 0);
3243 extern int dbenabled;
3244 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3246 if ((x = cmcfm()) < 0) return(x);
3247 if (iksdcf) return(success = 0);
3254 if ((z = cmtxt("Alternate init file specification","",
3257 if (z < 0) return(z);
3258 if (iksdcf) return(success = 0);
3259 ckstrncpy(kermrc,s,KERMRCL);
3260 rcflag = 1; /* Flag that this has been done */
3264 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3266 if ((x = cmcfm()) < 0) return(x);
3267 if (iksdcf) return(success = 0);
3272 if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
3274 if ((x = cmcfm()) < 0) return(x);
3275 if (iksdcf) return(success = 0);
3282 return(success = (inserver ? 1 : 0));
3283 #else /* IKSDCONF */
3284 if ((x = cmcfm()) < 0)
3286 return(success = 0);
3287 #endif /* IKSDCONF */
3292 /* D O A R G -- Do a command-line argument. */
3299 #endif /* CK_ANSIC */
3301 int i, n, y, z, xx; long zz; char *xp;
3304 extern char *line, *tmpbuf; /* Character buffers for anything */
3305 #endif /* NETCONN */
3308 /* Internet Kermit Server set some way besides -A... */
3313 xp = *xargv+1; /* Pointer for bundled args */
3314 debug(F111,"doarg entry",xp,xargc);
3316 debug(F000,"doarg arg","",x);
3317 switch (x) { /* Big switch on arg */
3320 case '-': /* Extended commands... */
3321 if (doxarg(xargv,0) < 0) {
3322 XFATAL("Extended option error");
3323 } /* Full thru... */
3324 case '+': /* Extended command for prescan() */
3329 XFATAL("Extended options not configured");
3333 case 'C': { /* Commands for parser */
3336 if ((xargc < 1) || (**xargv == '-')) {
3337 XFATAL("No commands given for -C");
3339 s = *xargv; /* Get the argument (must be quoted) */
3340 if (!*s) /* If empty quotes */
3341 s = NULL; /* ignore this option */
3343 makestr(&clcmds,s); /* Make pokeable copy */
3344 s = clcmds; /* Change tabs to spaces */
3346 if (*s == '\t') *s = ' ';
3355 case 'D': /* Delay */
3357 XFATAL("invalid argument bundling");
3360 if ((xargc < 1) || (**xargv == '-')) {
3361 XFATAL("missing delay value");
3363 z = atoi(*xargv); /* Convert to number */
3364 if (z > -1) /* If in range */
3365 ckdelay = z; /* set it */
3367 XFATAL("bad delay value");
3372 case 'E': /* Exit on close */
3375 #endif /* NETCONN */
3380 case 'S': /* "Stay" - enter interactive */
3381 stayflg = 1; /* command parser after executing */
3382 xfinish = 0; /* command-line actions. */
3386 case 'T': /* File transfer mode = text */
3388 xfermode = XMODE_M; /* Transfer mode manual */
3392 #endif /* PATTERNS */
3399 case 'A': { /* Internet server */
3400 /* Already done in prescan() */
3401 /* but implies 'x' && 'Q' */
3405 XFATAL("invalid argument bundling");
3408 /* Support for Pragma Systems Telnet/Terminal Servers */
3409 p = getenv("PRAGMASYS_INETD_SOCK");
3410 if (!(p && atoi(p) != 0)) {
3412 if (xargc < 1 || **xargv == '-') {
3413 XFATAL("missing socket handle");
3418 if (xargc < 1 || **xargv == '-') {
3419 XFATAL("missing socket handle");
3423 #ifdef NOICP /* If no Interactive Command Parser */
3424 action = 'x'; /* -A implies -x. */
3434 case 'Q': /* Quick (i.e. FAST) */
3439 case 'R': /* Remote-Only */
3440 break; /* This is handled in prescan(). */
3443 case 'x': /* server */
3444 case 'O': /* (for One command only) */
3446 XFATAL("conflicting actions");
3448 if (x == 'O') justone = 1;
3452 #endif /* NOSERVER */
3455 case 'f': /* finish */
3457 XFATAL("conflicting actions");
3459 action = setgen('F',"","","");
3463 case 'r': { /* receive */
3465 XFATAL("conflicting actions");
3472 case 'k': /* receive to stdout */
3474 XFATAL("conflicting actions");
3480 case 's': { /* send */
3483 nolinks = 0; /* Follow links by default */
3486 XFATAL("conflicting actions");
3489 XFATAL("invalid argument bundling after -s");
3491 nfils = 0; /* Initialize file counter */
3492 fil2snd = 0; /* Assume nothing to send */
3493 z = 0; /* Flag for stdin */
3494 cmlist = xargv + 1; /* Remember this pointer */
3495 while (++xargv, --xargc > 0) { /* Traverse the list */
3497 if (usepipes && protocol == PROTO_K && **xargv == '!') {
3500 debug(F110,"doarg pipesend",cmarg,0);
3505 #endif /* PIPESEND */
3506 if (**xargv == '-') { /* Check for sending stdin */
3507 if (strcmp(*xargv,"-") != 0) /* next option? */
3509 z++; /* "-" alone means send from stdin. */
3511 } else if (!strcmp(*xargv,".")) {
3516 #endif /* RECURSIVE */
3517 } else /* Check if file exists */
3518 if ((rc = zchki(*xargv)) > -1 || (rc == -2)) {
3521 nfils++; /* Bump file counter */
3522 } else if (iswild(*xargv) && nzxpand(*xargv,0) > 0) {
3523 /* or contains wildcard characters matching real files */
3528 xargc++, xargv--; /* Adjust argv/argc */
3529 if (!fil2snd && z == 0) {
3531 XFATAL("%CKERMIT-E-SEARCHFAIL, no files for -s");
3533 XFATAL("No files for -s");
3537 XFATAL("-s: too many -'s");
3539 if (z == 1 && fil2snd) {
3540 XFATAL("invalid mixture of filenames and '-' in -s");
3542 debug(F101,"doarg s nfils","",nfils);
3543 debug(F101,"doarg s z","",z);
3544 if (nfils == 0) { /* no file parameters were specified */
3545 if (is_a_tty(0)) { /* (used to be is_a_tty(1) - why?) */
3546 XFATAL("sending from terminal not allowed");
3549 debug(F101,"doarg s stdinf","",stdinf);
3550 debug(F111,"doarg",*xargv,nfils);
3556 case 'G': /* get to stdout */
3558 XFATAL("conflicting actions");
3561 XFATAL("invalid argument bundling after -g");
3564 if ((xargc == 0) || (**xargv == '-')) {
3565 XFATAL("missing filename for -g");
3567 if (x == 'G') stdouf = 1;
3574 case 'c': /* connect before */
3578 case 'n': /* connect after */
3581 #endif /* NOLOCAL */
3583 case 'h': /* help */
3586 if (stayflg || what == W_COMMAND)
3590 doexit(GOOD_EXIT,-1);
3593 case 'a': /* "as" */
3595 XFATAL("invalid argument bundling after -a");
3598 if ((xargc < 1) || (**xargv == '-')) {
3599 XFATAL("missing name in -a");
3602 debug(F111,"doarg a",cmarg2,xargc);
3607 case 'Y': /* No initialization file */
3611 case 'y': /* Alternate init-file name */
3614 XFATAL("invalid argument bundling after -y");
3618 XFATAL("missing filename in -y");
3620 /* strcpy(kermrc,*xargv); ... already done in prescan()... */
3625 case 'I': /* Assume we have an "Internet" */
3626 reliable = 1; /* or other reliable connection */
3630 /* I'm not so sure about this -- what about VMS? (next comment) */
3631 clearrq = 1; /* therefore the channel is clear */
3635 Since this can trigger full control-character unprefixing, we need to
3636 ensure that our terminal or pty driver is not doing Xon/Xoff; otherwise
3637 we can become deadlocked the first time we receive a file that contains
3646 case 'l': /* SET LINE */
3649 case 'X': /* SET HOST to X.25 address */
3651 case 'Z': /* SET HOST to X.25 file descriptor */
3656 case 'j': /* SET HOST (TCP/IP socket) */
3657 #endif /* TCPSOCKET */
3658 #endif /* NETCONN */
3660 if (x == 'j' || x == 'J' || x == 'X' || x == 'Z') {
3661 reliable = 1; /* or other reliable connection */
3668 XFATAL("invalid argument bundling after -l or -j");
3671 if ((xargc < 1) || (**xargv == '-')) {
3672 XFATAL("communication line device name missing");
3677 cflg = 1; /* Connect */
3678 stayflg = 1; /* Stay */
3679 tn_exit = 1; /* Telnet-like exit condition */
3682 #endif /* NETCONN */
3683 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
3684 local = (strcmp(ttname,CTTNAM) != 0);
3685 if (local && strcmp(ttname,"0") == 0)
3688 NOTE: We really do not need to call ttopen here, since it should be called
3689 again later, automatically, when we first try to condition the device via
3690 ttpkt or ttvt. Calling ttopen here has the bad side effect of making the
3691 order of the -b and -l options significant when the order of command-line
3692 options should not matter. However, the network cases immediately below
3693 complicate matters a bit, so we'll settle this in a future edit.
3696 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
3697 XFATAL("can't open device");
3701 #endif /* CKLOGDIAL */
3702 debug(F101,"doarg speed","",speed);
3703 cxtype = (mdmtyp > 0) ? CXT_MODEM : CXT_DIRECT;
3704 speed = ttgspd(); /* Get the speed. */
3705 setflow(); /* Do something about flow control. */
3708 if (nmac) { /* Any macros defined? */
3710 k = mlook(mactab,"on_open",nmac); /* Look this up */
3711 if (k >= 0) { /* If found, */
3712 if (dodo(k,ttname,0) > -1) /* set it up, */
3713 parser(1); /* and execute it */
3721 if (x == 'j' || x == 'J') { /* IP network host name */
3723 char * service = tmpbuf;
3724 if (xargc > 0) { /* Check if it's followed by */
3725 /* A service name or number */
3726 if (*(xargv+1) && *(*(xargv+1)) != '-') {
3728 ckstrncat(ttname,":",TTNAMLEN+1);
3729 ckstrncat(ttname,*xargv,TTNAMLEN+1);
3733 mdmtyp = -nettype; /* Perhaps already set in init file */
3734 telnetfd = 1; /* Or maybe an open file descriptor */
3735 ckstrncpy(line, ttname, LINBUFSIZ); /* Working copy */
3736 for (s = line; *s != NUL && *s != ':'; s++);
3739 ckstrncpy(service, s, TMPBUFSIZ);
3740 } else *service = NUL;
3744 /* Look up in network directory */
3746 if (*s == '=') { /* If number starts with = sign */
3748 while (*s == SP) /* and also any leading spaces */
3750 ckstrncpy(line,s,LINBUFSIZ); /* Do this again. */
3752 } else if (!isdigit(line[0])) {
3754 nnetdir will be greater than 0 if the init file has been processed and it
3755 contained a SET NETWORK DIRECTORY command.
3757 xx = 0; /* Initialize this */
3758 if (nnetdir > 0) /* If there is a directory... */
3759 xx = lunet(line); /* Look up the name */
3760 else /* If no directory */
3761 nhcount = 0; /* we didn't find anything there */
3762 if (xx < 0) { /* Lookup error: */
3765 "?Fatal network directory lookup error - ",
3775 /* Add service to line specification for ttopen() */
3776 if (*service) { /* There is a service specified */
3777 ckstrncat(line, ":",LINBUFSIZ);
3778 ckstrncat(line, service,LINBUFSIZ);
3779 ttnproto = NP_DEFAULT;
3781 ckstrncat(line, ":telnet",LINBUFSIZ);
3782 ttnproto = NP_TELNET;
3787 if ((nhcount > 1) && !quiet && !backgrd) {
3788 printf("%d entr%s found for \"%s\"%s\n",
3790 (nhcount == 1) ? "y" : "ies",
3792 (nhcount > 0) ? ":" : "."
3794 for (i = 0; i < nhcount; i++)
3795 printf("%3d. %s %-12s => %s\n",
3796 i+1, n_name, nh_p2[i], nh_p[i]
3807 for (i = 0; i < n; i++) {
3810 /* Copy the current entry to line */
3811 ckstrncpy(line,nh_p[i],LINBUFSIZ);
3812 /* Check to see if the network entry contains a service */
3813 for (s = line ; (*s != NUL) && (*s != ':'); s++)
3815 /* If directory does not have a service ... */
3816 /* and the user specified one */
3817 if (!*s && *service) {
3818 ckstrncat(line, ":",LINBUFSIZ);
3819 ckstrncat(line, service,LINBUFSIZ);
3821 if (lookup(netcmd,nh_p2[i],nnets,&z) > -1) {
3822 mdmtyp = 0 - netcmd[z].kwval;
3825 "Error - network type \"%s\" not supported\n",
3834 ckstrncpy(ttname, line,TTNAMLEN+1);
3835 cxtype = CXT_TCPIP; /* Set connection type */
3836 setflow(); /* Set appropriate flow control. */
3838 } else if (x == 'X') { /* X.25 address */
3841 } else if (x == 'Z') { /* Open X.25 file descriptor */
3847 } else if (x == 'X') { /* X.25 address */
3850 #endif /* STRATUSX25 */
3852 } else if (x == 'X') { /* X.25 address */
3857 } else if (x == 'X') { /* X.25 address */
3862 if (ttopen(ttname,&local,mdmtyp,0) < 0) {
3863 XFATAL("can't open host connection");
3868 #endif /* CKLOGDIAL */
3869 cxtype = CXT_X25; /* Set connection type */
3870 setflow(); /* Set appropriate flow control. */
3873 if (nmac) { /* Any macros defined? */
3875 k = mlook(mactab,"on_open",nmac); /* Look this up */
3876 if (k >= 0) { /* If found, */
3877 if (dodo(k,ttname,0) > -1) /* set it up, */
3878 parser(1); /* and execute it */
3883 #endif /* NETCONN */
3885 /* add more here -- decnet, etc... */
3890 case 'U': /* X.25 call user data */
3892 XFATAL("invalid argument bundling");
3895 if ((xargc < 1) || (**xargv == '-')) {
3896 XFATAL("missing call user data string");
3898 ckstrncpy(udata,*xargv,MAXCUDATA);
3899 if ((int)strlen(udata) <= MAXCUDATA) {
3902 XFATAL("Invalid call user data");
3906 case 'o': /* X.25 closed user group */
3908 XFATAL("invalid argument bundling");
3911 if ((xargc < 1) || (**xargv == '-')) {
3912 XFATAL("missing closed user group index");
3914 z = atoi(*xargv); /* Convert to number */
3915 if (z >= 0 && z <= 99) {
3918 XFATAL("Invalid closed user group index");
3922 case 'u': /* X.25 reverse charge call */
3926 #endif /* NOLOCAL */
3928 case 'b': /* Bits-per-second for serial device */
3930 XFATAL("invalid argument bundling");
3933 if ((xargc < 1) || (**xargv == '-')) {
3934 XFATAL("missing bps");
3936 zz = atol(*xargv); /* Convert to long int */
3939 if (ttsspd(i) > -1) /* Check and set it */
3940 #endif /* NOLOCAL */
3941 speed = ttgspd(); /* and read it back. */
3944 XFATAL("unsupported transmission rate");
3946 #endif /* NOLOCAL */
3951 case 'm': /* Modem type */
3953 XFATAL("invalid argument bundling after -m");
3956 if ((xargc < 1) || (**xargv == '-')) {
3957 XFATAL("modem type missing");
3959 y = lookup(mdmtab,*xargv,nmdm,&z);
3961 XFATAL("unknown modem type");
3964 usermdm = (y == dialudt) ? x : 0;
3971 case 'e': /* Extended packet length */
3973 XFATAL("invalid argument bundling after -e");
3976 if ((xargc < 1) || (**xargv == '-')) {
3977 XFATAL("missing length");
3979 z = atoi(*xargv); /* Convert to number */
3980 if (z > 10 && z <= maxrps) {
3982 if (z > 94) rpsiz = 94; /* Fallback if other Kermit can't */
3984 XFATAL("Unsupported packet length");
3988 case 'v': /* Vindow size */
3990 XFATAL("invalid argument bundling");
3993 if ((xargc < 1) || (**xargv == '-')) {
3994 XFATAL("missing or bad window size");
3996 z = atoi(*xargv); /* Convert to number */
3997 if (z < 32) { /* If in range */
3998 wslotr = z; /* set it */
3999 if (z > 1) swcapr = 1; /* Set capas bit if windowing */
4001 XFATAL("Unsupported packet length");
4006 case 'i': /* Treat files as binary */
4008 xfermode = XMODE_M; /* Transfer mode manual */
4012 #endif /* PATTERNS */
4016 case 'w': /* Writeover */
4022 case 'q': /* Quiet */
4027 case 'd': /* DEBUG */
4028 break; /* Handled in prescan() */
4031 case '0': { /* In the middle */
4032 extern int tt_escape, lscapr;
4033 tt_escape = 0; /* No escape character */
4034 flow = 0; /* No Xon/Xoff (what about hwfc?) */
4036 lscapr = 0; /* No locking shifts */
4040 extern int apcstatus; /* No APCs */
4041 apcstatus = APC_OFF;
4046 setautodl(0,0); /* No autodownload */
4047 #endif /* CK_AUTODL */
4048 #endif /* NOLOCAL */
4051 extern int tcsr, tcsl; /* No character-set translation */
4053 tcsl = tcsr; /* Make these equal */
4055 #endif /* NOCSETS */
4057 TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
4058 TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
4059 TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
4060 TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
4065 case '8': /* 8-bit clean */
4072 extern int xfermode;
4074 extern int patterns;
4075 patterns = 0; /* No patterns */
4076 #endif /* PATTERNS */
4077 xfermode = XMODE_M; /* Manual transfer mode */
4082 case 'p': /* SET PARITY */
4084 XFATAL("invalid argument bundling");
4087 if ((xargc < 1) || (**xargv == '-')) {
4088 XFATAL("missing parity");
4090 switch(x = **xargv) {
4094 case 's': parity = x; break;
4095 case 'n': parity = 0; break;
4096 default: { XFATAL("invalid parity"); }
4100 case 't': /* Line turnaround handshake */
4102 turnch = XON; /* XON is turnaround character */
4103 duplex = 1; /* Half duplex */
4104 flow = 0; /* No flow control */
4108 bgset = 1; /* Force background (batch) */
4112 case 'z': /* Force foreground */
4124 #endif /* RECURSIVE */
4128 case 'M': /* My User Name */
4130 XFATAL("invalid argument bundling");
4133 if ((xargc < 1) || (**xargv == '-')) {
4134 XFATAL("missing username");
4136 if ((int)strlen(*xargv) > 63) {
4137 XFATAL("username too long");
4143 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4150 case 'N': /* NetBios Adapter Number follows */
4152 XFATAL("invalid argument bundling after -N");
4155 if ((xargc < 1) || (**xargv == '-')) {
4156 XFATAL("missing NetBios Adapter number");
4158 if ((strlen(*xargv) != 1) ||
4159 (*xargv)[0] != 'X' &&
4160 (atoi(*xargv) < 0) &&
4161 (atoi(*xargv) > 9)) {
4162 XFATAL("Invalid NetBios Adapter - Adapters 0 to 9 are valid");
4165 #endif /* CK_NETBIOS */
4171 XFATAL("invalid argument bundling after -F");
4174 if ((xargc < 1) || (**xargv == '-')) {
4175 XFATAL("network file descriptor missing");
4177 ckstrncpy(ttname,*xargv,TTNAMLEN+1);
4183 #endif /* NETCONN */
4187 case 'P': /* OS/2 Presentation Manager */
4189 XFATAL("invalid argument bundling after -P");
4192 if ((xargc < 1) || (**xargv == '-')) {
4193 XFATAL("pipe data missing");
4199 case 'P': /* Filenames literal */
4203 #endif /* COMMENT */
4214 XFATAL("invalid argument bundling after -W");
4217 if ((xargc < 1)) { /* could be negative */
4218 XFATAL("Window handle missing");
4221 if ((xargc < 1) || (**xargv == '-')) {
4222 XFATAL("Kermit Instance missing");
4224 /* Action done in prescan */
4227 case '#': /* K95 stdio threads */
4228 xargv++, xargc--; /* Skip past argument */
4229 break; /* Action done in prescan */
4235 XFATAL("invalid argument bundling after -9");
4238 if ((xargc < 1) || (**xargv == '-')) {
4239 XFATAL("FTP server address missing");
4241 makestr(&ftp_host,*xargv);
4248 "invalid command-line option, type \"k95 -h\" for help"
4251 "invalid command-line option, type \"k2 -h\" for help"
4253 "invalid command-line option, type \"kermit -h\" for help"
4259 x = *++xp; /* See if options are bundled */
4265 /* D O T N A R G -- Do a telnet command-line argument. */
4272 #endif /* CK_ANSIC */
4276 xp = *xargv+1; /* Pointer for bundled args */
4277 debug(F111,"dotnarg entry",xp,xargc);
4279 debug(F000,"dotnarg arg","",x);
4280 switch (x) { /* Big switch on arg */
4283 case '-': /* Extended commands... */
4284 if (doxarg(xargv,0) < 0) {
4285 XFATAL("Extended option error");
4286 } /* Full thru... */
4287 case '+': /* Extended command for prescan() */
4292 XFATAL("Extended options not configured");
4293 #endif /* COMMENT */
4296 * -8 Negotiate Telnet Binary in both directions
4297 * -a Require use of Telnet authentication
4298 * -c Do not read the .telnetrc file
4299 * -d Turn on debug mode
4300 * -E No escape character
4301 * -K Refuse use of authentication; do not send username
4302 * -l user Set username and request Telnet authentication
4303 * -L Negotiate Telnet Binary Output only
4304 * -S tos Use the IP type-of-service tos
4305 * -x Require Encryption
4306 * -D Disable forward-X
4307 * -T cert=file Use certificate in file
4308 * -T key=file Use private key in file
4309 * -T crlfile=file Use CRL in file
4310 * -T crldir=dir Use CRLs in directory
4311 * -T cipher=string Use only ciphers in string
4312 * -X atype Disable use of atype authentication
4313 * -f Forward credentials to host
4314 * -k realm Set default realm
4317 case 'h': /* help */
4319 doexit(GOOD_EXIT,-1);
4322 case '8': /* Telnet Binary in both directions */
4323 TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = TN_NG_MU;
4324 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
4330 case 'a': /* Require Telnet Auth */
4331 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
4339 deblog = debopn("debug.log",0);
4344 case 'E': { /* No Escape character */
4345 extern int tt_escape;
4351 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_RF;
4355 case 'l': /* Set username and request telnet authentication */
4357 XFATAL("invalid argument bundling");
4360 if ((xargc < 1) || (**xargv == '-')) {
4361 XFATAL("missing username");
4363 if ((int)strlen(*xargv) > 63) {
4364 XFATAL("username too long");
4366 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4367 TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
4370 case 'L': /* Require BINARY mode outbound only */
4371 TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
4374 case 'x': /* Require Encryption */
4375 TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
4376 TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
4379 case 'D': /* Disable use of Forward X */
4380 TELOPT_DEF_C_U_MODE(TELOPT_FORWARD_X) = TN_NG_RF;
4383 case 'f': /* Forward credentials to host */
4385 #ifdef CK_AUTHENTICATION
4386 extern int forward_flag;
4394 extern char * krb5_d_realm, * krb4_d_realm;
4395 #endif /* CK_KERBEROS */
4397 XFATAL("invalid argument bundling");
4400 if ((xargc < 1) || (**xargv == '-')) {
4401 XFATAL("missing realm");
4404 if ((int)strlen(*xargv) > 63) {
4405 XFATAL("realm too long");
4407 makestr(&krb5_d_realm,*xargv);
4408 makestr(&krb4_d_realm,*xargv);
4409 #endif /* CK_KERBEROS */
4415 XFATAL("invalid argument bundling");
4418 if ((xargc < 1) || (**xargv == '-')) {
4419 XFATAL("missing cert=, key=, crlfile=, crldir=, or cipher=");
4422 if (!strncmp(*xargv,"cert=",5)) {
4423 extern char * ssl_rsa_cert_file;
4424 makestr(&ssl_rsa_cert_file,&(*xargv[5]));
4425 } else if ( !strncmp(*xargv,"key=",4) ) {
4426 extern char * ssl_rsa_key_file;
4427 makestr(&ssl_rsa_key_file,&(*xargv[4]));
4428 } else if ( !strncmp(*xargv,"crlfile=",8) ) {
4429 extern char * ssl_crl_file;
4430 makestr(&ssl_crl_file,&(*xargv[8]));
4431 } else if ( !strncmp(*xargv,"crldir=",7) ) {
4432 extern char * ssl_crl_dir;
4433 makestr(&ssl_crl_dir,&(*xargv[7]));
4434 } else if ( !strncmp(*xargv,"cipher=",7) ) {
4435 extern char * ssl_cipher_list;
4436 makestr(&ssl_cipher_list,&(*xargv[7]));
4438 XFATAL("invalid parameter");
4446 "invalid command-line option, type \"telnet -h\" for help"
4451 x = *++xp; /* See if options are bundled */
4459 /* D O R L G A R G -- Do a rlogin command-line argument. */
4466 #endif /* CK_ANSIC */
4470 xp = *xargv+1; /* Pointer for bundled args */
4471 debug(F111,"dorlgarg entry",xp,xargc);
4473 debug(F000,"dorlgarg arg","",x);
4474 switch (x) { /* Big switch on arg */
4477 case '-': /* Extended commands... */
4478 if (doxarg(xargv,0) < 0) {
4479 XFATAL("Extended option error");
4480 } /* Full thru... */
4481 case '+': /* Extended command for prescan() */
4486 XFATAL("Extended options not configured");
4487 #endif /* COMMENT */
4491 * -l user Set username
4494 case 'h': /* help */
4496 doexit(GOOD_EXIT,-1);
4504 deblog = debopn("debug.log",0);
4509 case 'l': /* Set username and request telnet authentication */
4511 XFATAL("invalid argument bundling");
4514 if ((xargc < 1) || (**xargv == '-')) {
4515 XFATAL("missing username");
4517 if ((int)strlen(*xargv) > 63) {
4518 XFATAL("username too long");
4520 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4525 "invalid command-line option, type \"rlogin -h\" for help"
4530 x = *++xp; /* See if options are bundled */
4534 #endif /* RLOGCODE */
4538 /* D O S S H A R G -- Do a ssh command-line argument. */
4545 #endif /* CK_ANSIC */
4549 xp = *xargv+1; /* Pointer for bundled args */
4550 debug(F111,"dossharg entry",xp,xargc);
4552 debug(F000,"dossharg arg","",x);
4553 switch (x) { /* Big switch on arg */
4556 case '-': /* Extended commands... */
4557 if (doxarg(xargv,0) < 0) {
4558 XFATAL("Extended option error");
4559 } /* Full thru... */
4560 case '+': /* Extended command for prescan() */
4562 #else /* COMMENTP */
4565 XFATAL("Extended options not configured");
4566 #endif /* COMMENT */
4570 * -l user Set username
4573 case 'h': /* help */
4575 doexit(GOOD_EXIT,-1);
4583 deblog = debopn("debug.log",0);
4588 case 'l': /* Set username and request telnet authentication */
4590 XFATAL("invalid argument bundling");
4593 if ((xargc < 1) || (**xargv == '-')) {
4594 XFATAL("missing username");
4596 if ((int)strlen(*xargv) > 63) {
4597 XFATAL("username too long");
4599 ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
4604 "invalid command-line option, type \"rlogin -h\" for help"
4609 x = *++xp; /* See if options are bundled */
4613 #endif /* SSHBUILTIN */
4615 #else /* No command-line interface... */
4621 XFATAL("Sorry, command-line options disabled.");