1 #define EDITDATE "20 Aug 2011" /* Last edit date dd mmm yyyy */
2 #define EDITNDATE "20110820" /* Keep them in sync */
3 /* Sat Aug 20 17:20:17 2011 */
5 /* ckcmai.c - Main program for C-Kermit plus some miscellaneous functions */
8 ckcsym.h is used for for defining symbols that normally would be defined
9 using -D or -d on the cc command line, for use with compilers that don't
10 support this feature. Must come before any tests for preprocessor symbols.
14 Consolidated program C-Kermit version information for all platforms
15 (but for UNIX also see ckuver.h). See makever() below for how they are used.
17 #ifdef COMMENT /* Uncomment this for real K95 version */
18 #ifndef OS2 /* OS2 actually means Kermit 95. */
19 #ifndef BETATEST /* It's because Kermit 95 started */
20 #define BETATEST /* out as C-Kermit for OS/2. */
33 char * ck_cryear = "2011"; /* C-Kermit copyright year */
35 #ifndef MAC /* MAC = Kermit for MAC OS 6, 7, ... */
37 Note: initialize ck_s_test to "" if this is not a test version.
38 Use (*ck_s_test != '\0') to decide whether to print test-related messages.
42 #ifndef OS2 /* UNIX, VMS, etc... (i.e. C-Kermit) */
43 char *ck_s_test = ""; /* "Dev","Alpha","Beta","RC", or "" */
44 char *ck_s_tver = ""; /* Test version number or "" */
46 char *ck_s_test = ""; /* (i.e. K95) */
50 char *ck_s_test = ""; /* Development */
54 char *ck_s_test = "Pre-Alpha"; /* Mac Kermit is always a test... */
55 char *ck_s_tver = ""; /* (pre Mac OS X 10, that is!) */
58 #ifdef BETADATE /* Date of this version or edit */
59 char *ck_s_date = __DATE__; /* Compilation date */
61 char *ck_s_date = EDITDATE; /* See top */
64 char *buildid = EDITNDATE; /* See top */
67 static char sccsid[] = "@(#)C-Kermit 9.0.302";
71 The C-Kermit Version number is major.minor.edit (integers).
72 Major version always goes up.
73 Minor version is historical, hasn't been used since C-Kermit 7.1.
74 Edit is sequential, always goes up, but there can be gaps.
75 For example there might be many edits between releases.
76 If the major goes to 10, some version-number-based feature tests
77 could fail. It might be better to use the minor version field
81 char *ck_s_ver = "9.0.302"; /* C-Kermit version string */
82 long ck_l_ver = 900302L; /* C-Kermit version number */
85 char *ck_s_xver = "3.0.0"; /* Product-specific version string */
86 long ck_l_xver = 3000L; /* Product-specific version number */
89 char *ck_s_xver = "0.995"; /* Product-specific version string */
90 long ck_l_xver = 995L; /* Product-specific version number */
92 char *ck_s_xver = ""; /* Don't touch these... */
93 long ck_l_xver = 0L; /* they are computed at runtime */
100 char *ck_s_name = "IKS-NT";
102 char *ck_s_name = "IKS-OS/2";
105 char *ck_s_name = "Kermit 95"; /* Program name */
106 #endif /* IKSDONLY */
109 char *ck_s_name = "Mac Kermit";
111 char *ck_s_name = "C-Kermit";
115 char *ck_s_who = ""; /* Where customized, "" = not. */
116 char *ck_patch = ""; /* Patch info, if any. */
119 char versiox[CKVERLEN]; /* Version string buffer */
120 char *versio = versiox; /* These are filled in at */
121 long vernum, xvernum; /* runtime from above. */
125 #include "ckcasc.h" /* ASCII character symbols */
126 #include "ckcdeb.h" /* Debug & other symbols */
128 char * myname = NULL; /* The name I am called by */
130 char * exedir = NULL; /* Directory I was executed from */
132 char * myhome = NULL; /* Home directory override */
134 /* C K C M A I -- C-Kermit Main program */
137 Author: Frank da Cruz (fdc@columbia.edu),
138 Columbia University in the city of New York,
139 Computer Center / Center for Computing Activities / Information Technology.
140 I am no longer at Columbia U as of 1 July 2011, but the email address
141 should still work. The Kermit website http://kermit.columbia.edu should
142 still be available and under my control, as well as the Kermit FTP site,
143 ftp://kermit.columbia.edu/kermit/.
148 char *copyright[] = {
151 "Copyright (C) 1985, %s, Trustees of Columbia University, NYC.",
152 "All rights reserved.",
155 "Copyright (C) 1985, %s,",
156 " The Trustees of Columbia University in the City of New York.",
157 " All rights reserved.",
159 "Redistribution and use in source and binary forms, with or without",
160 "modification, are permitted provided that the following conditions",
163 " + Redistributions of source code must retain the above copyright",
164 " notice, this list of conditions and the following disclaimer.",
166 " + Redistributions in binary form must reproduce the above copyright",
167 " notice, this list of conditions and the following disclaimer in",
168 " the documentation and/or other materials provided with the",
171 " + Neither the name of Columbia University nor the names of its",
172 " contributors may be used to endorse or promote products derived",
173 " from this software without specific prior written permission.",
175 "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS",
176 "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT",
177 "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR",
178 "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT",
179 "HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,",
180 "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT",
181 "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,",
182 "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY",
183 "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT",
184 "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE",
185 "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
189 "Portions Copyright (C) 2002-2005, Secure Endpoints Inc, New York NY USA.",
190 "Portions Copyright (C) 1995, Oy Online Solutions Ltd., Jyvaskyla, Finland.",
193 #ifdef CK_AUTHENTICATION
194 "Portions Copyright (C) 1990, Massachusetts Institute of Technology.",
196 "Portions Copyright (C) 1991, 1993 Regents of the University of California.",
197 "Portions Copyright (C) 1991, 1992, 1993, 1994, 1995 by AT&T.",
198 "Portions Copyright (C) 1995, 1997, Eric Young <eay@cryptosoft.com>.",
199 #endif /* CK_ENCRYPTION */
201 "Portions Copyright (C) 1997, Stanford University.",
203 #endif /* CK_AUTHENTICATION */
207 "For further information, visit the Kermit Project website:",
208 "http://www.columbia.edu/kermit/ .",
212 /* Windows IKSD copyright used to be separate */
213 char *wiksdcpr = (char *) copyright;
219 "Using C-Kermit" by Frank da Cruz and Christine M. Gianone,
220 Digital Press / Butterworth-Heinemann, Woburn MA, USA.
221 Second edition (1997), ISBN 1-55558-164-1.
222 Order from Digital Press: +1 (800) 366-2665
223 Or from Columbia University: +1 (212) 854-3703
227 "Kermit 95" by Christine M. Gianone and Frank da Cruz,
228 Manning Publications, Greenwich CT, USA (1998) - Online.
232 The Kermit file transfer protocol was developed at the Columbia University
233 Center for Computing Activities (CUCCA), which was since renamed to Columbia
234 University Academic Information Systems (AcIS) and after that Columbia
235 University Information Technology (CUIT). Kermit is named after Kermit the
236 Frog, star of the television series THE MUPPET SHOW; the name is used by
237 permission of Henson Associates, Inc.
239 Thanks to at least the following people for their contributions to this
240 program over the years, and apologies to anyone who was inadvertantly
243 Chris Adie, Edinburgh U, Scotland (OS/2)
244 Robert Adsett, University of Waterloo, Canada
245 Larry Afrin, Clemson U
246 Russ Allbery, Stanford U
247 Jeffrey Altman, Columbia University
248 Greg Andrews, Telebit Corp
249 Barry Archer, U of Missouri
250 Robert Andersson, International Systems A/S, Oslo, Norway
251 Chris Armstrong, Brookhaven National Lab (OS/2)
252 William Bader, Software Consulting Services, Nazareth, PA
253 Fuat Baran, Columbia U
255 Jim Barbour, U of Colorado
256 Donn Baumgartner, Dell
257 Ian Beckwith, Debian Project
258 Nelson Beebe, U of Utah
259 Gerry Belanger, Cognitronics
262 Dean W Bettinger, SUNY
264 Peter Binderup, Denmark
265 David Bolen, Advanced Networks and Services, Inc.
267 Marc Boucher, U of Montreal
272 Jack Bryans, California State U at Long Beach
274 Fernando Cabral, Padrao iX, Brasilia
275 Bjorn Carlsson, Stockholm University Computer Centre QZ, Sweden
276 Bill Catchings, (formerly of) Columbia U
277 Bob Cattani, Columbia U CS Dept
278 Davide Cervone, Rochester U
279 Seth Chaiklin, Denmark
280 John Chandler, Harvard U / Smithsonian Astronomical Observatory
282 Andrew A Chernov, RELCOM Team, Moscow
283 John L Chmielewski, AT&T, Lisle, IL
284 Howard Chu, U of Michigan
285 Bill Coalson, McDonnell Douglas
286 Bertie Coopersmith, London
288 Chet Creider, U of Western Ontario
289 Alan Crosswell, Columbia U
290 Jeff Damens, (formerly of) Columbia U
291 Mark Davies, Bath U, UK
292 Sin-itirou Dezawa, Fujifilm, Japan
293 Joe R. Doupnik, Utah State U
294 Frank Dreano, Honeywell
295 John Dunlap, U of Washington
296 Alex Dupuy, SMART.COM
297 David Dyck, John Fluke Mfg Co.
298 Stefaan A. Eeckels, Eurokom, Luxembourg
300 Paul Eggert, Twin Sun, Inc., El Segundo, CA
302 Peter Eichhorn, Assyst International
303 Kristoffer Eriksson, Peridot Konsult AB, Oerebro, Sweden
304 John R. Evans, IRS, Kansas City
305 Glenn Everhart, RCA Labs
306 Charlie Finan, Cray Research
307 Herm Fischer, Encino, CA (extensive contributions to version 4.0)
308 Carl Fongheiser, CWRU
309 Mike Freeman, Bonneville Power Authority
311 Marcello Frutig, Catholic University, Sao Paulo, Brazil (X.25 support)
312 Hirofumi Fujii, Japan Nat'l Lab for High Energy Physics, Tokyo (Kanji)
313 Chuck Fuller, Westinghouse Corporate Computer Services
315 Christine M. Gianone, Columbia U
316 John Gilmore, UC Berkeley
317 Madhusudan Giyyarpuram, HP
318 Rainer Glaschick, Siemens AG, Paderborn
320 German Goldszmidt, IBM
322 Alistair Gorman, New Zealand
323 Richard Gration, ADFA, Australia
324 Chris Green, Essex U, UK
325 Alan Grieg, Dundee Tech, Scotland
327 Jim Guyton, Rand Corp
331 Marion Hakanson, ORST
333 John Hamilston, Iowa State U
334 Simon Hania, Netherlands
337 Eugenia Harris, Data General (AOS/VS)
338 David Harrison, Kingston Warren Corp
339 Lucas Hart, Oregon State University
340 James Harvey, Indiana/Purdue U (VMS)
342 Chuck Hedrick, Rutgers U
343 Ron Heiby, Technical Systems Division, Motorola Computer Group
344 Steve Hemminger, Tektronix
345 Christian Hemsing, RWTH Aachen, Germany (OS-9)
346 Randolph Herber, US DOE,
347 Andrew Herbert, Monash Univ, Australia
348 Marcus Herbert, Germany
350 Dan Hildebrand, QNX Software Systems Inc, Kanata, ON (QNX)
352 Stephan Hoffman-Emden
353 Sven Holmstrom, ABB Utilities AB, Sweden
354 Bill Homer, Cray Research
355 Ray Hunter, The Wollongong Group
356 Randy Huntziger, National Library of Medicine
357 Larry Jacobs, Transarc
358 Steve Jenkins, Lancaster University, UK
359 Dave Johnson, Gradient Technologies
360 Mark B Johnson, Apple Computer
361 Jyke Jokinen, Tampere University of Technology, Finland (QNX)
364 Peter Jones, U of Quebec Montreal
365 Phil Julian, SAS Institute
366 Peter Kabal, U of Quebec
367 Mic Kaczmarczik, U of Texas at Austin
368 Sergey Kartashoff, Inst. of Precise Mechanics & Computer Equipment, Moscow
369 Howie Kaye, Columbia U
370 Rob Kedoin, Linotype Co, Hauppauge, NY (OS/2)
373 Terry Kennedy, St Peter's College, Jersey City, NJ (VMS and more)
374 "Carlo Kid", Technical University of Delft, Netherlands
376 Paul Kimoto, Cornell U
377 Douglas Kingston, morgan.com
378 Lawrence Kirby, Wiltshire, UK
379 Tom Kloos, Sequent Computer Systems
381 Jim Knutson, U of Texas at Austin
383 Scott Kramer, SRI International, Menlo Park, CA
384 John Kraynack, US Postal Service
385 David Kricker, Encore Computer
387 Bo Kullmar, ABC Klubben, Stockholm, and Central Bank of Sweden, Kista
388 R. Brad Kummer, AT&T Bell Labs, Atlanta, GA
389 John Kunze, UC Berkeley
390 David Lane, BSSI / BellSouth (Stratus VOS, X.25)
391 Bob Larson, USC (OS-9)
392 Bert Laverman, Groningen U, Netherlands
394 David Lawyer, UC Irvine
396 David LeVine, National Semiconductor Corporation
397 Daniel S. Lewart, UIUC
399 Tor Lillqvist, Helsinki U, Finland
400 David-Michael Lincke, U of St Gallen, Switzerland
401 Robert Lipe (for SCO makefile entries & advice)
403 Mike Long, Analog Devices, Norwood MA
404 Kevin Lowey, U of Saskatchewan (OS/2)
405 Andy Lowry, Columbia U
406 James Lummel, Caprica Telecomputing Resources (QNX)
408 David MacKenzie, Environmental Defense Fund, U of Maryland
409 John Mackin, University of Sidney, Australia
410 Martin Maclaren, Bath U, UK
411 Chris Maio, Columbia U CS Dept
412 Montserrat Mane, HP, Grenoble, France
413 Fulvio Marino, Olivetti, Ivrea, Italy
414 Arthur Marsh, dircsa.org.au
415 Peter Mauzey, Lucent Technologies
416 Tye McQueen, Utah State U
418 Hellmuth Michaelis, Hanseatischer Computerservice GmbH, Hamburg, Germany
419 Leslie Mikesell, American Farm Bureau
420 Todd Miller, Courtesan Consulting
422 Martin Minow, DEC (VMS)
423 Pawan Misra, Bellcore
424 Ken Mizialko, IBM, Manassas, VA
425 Wolfgang Moeller, DECUS Germany
427 Bruce J Moore, Allen-Bradley Co, Highland Heights, OH (Atari ST)
429 Peter Mossel, Columbia U
431 Lou Muccioli, Swanson Analysis Systems
433 Neal P. Murphy, Harsof Systems, Wonder Lake IL
436 Jack Nelson, U of Pittsburgh
437 Jim Noble, Planning Research Corporation (Macintosh)
438 Ian O'Brien, Bath U, UK
441 Thomas Pinkl, Health Business Systems Inc.
442 Michael Pins, Iowa Computer Aided Engineering Network
443 Andre' Pirard, University of Liege, Belgium
444 Paul Placeway, Ohio State U
445 Piet W. Plomp, ICCE, Groningen University, Netherlands
447 Manfred Prange, Oakland U
448 Christopher Pratt, APV Baker, UK
450 Tony Querubin, U of Hawaii
455 Alan Robiette, Oxford University, UK
456 Michel Robitaille, U of Montreal (Mac)
457 Huw Rogers, Schweizerische Kreditanstalt, Zuerich
458 Nigel Roles, Cambridge, England
459 Kai Uwe Rommel, Technische Universitaet Muenchen (OS/2)
460 Larry Rosenman (Amiga)
461 Jay Rouman, U of Michigan
462 Jack Rouse, SAS Institute (Data General and/or Apollo)
463 Stew Rubenstein, Harvard U (VMS)
464 Gerhard Rueckle, FH Darmstadt, Fb. E/Automatisierungstechnik
466 Bill Schilit, Columbia U
467 Ulli Schlueter, RWTH Aachen, Germany (OS-9, etc)
468 Michael Schmidt, U of Paderborn, Germany
469 Eric Schnoebelen, Convex
471 Dan Schullman, DEC (modems, DIAL command, etc)
473 Steven Schultz, Contel (PDP-11)
475 APPP Scorer, Leeds Polytechnic, UK
476 Gordon Scott, Micro Focus, Newbury UK
477 Gisbert W. Selke, WIdO, Bonn, Germany
479 David Singer, IBM Almaden Research Labs
480 David Sizeland, U of London Medical School
481 Fridrik Skulason, Iceland
485 Fred Smith, Merk / Computrition
486 Richard S Smith, Cal State
488 Bertil Stenstroem, Stockholm University Computer Centre (QZ), Sweden
489 James Sturdevant, CAP GEMENI AMERICA, Minneapolis
490 Peter Svanberg, Royal Techn. HS, Sweden
491 James R. Swenson, Accu-Weather, Inc.
492 Ted T'so, MIT (Linux)
493 Andy Tanenbaum, Vrije U, Amsterdam, Netherlands
494 Seth Theriault, Columbia U
496 Markku Toijala, Helsinki U of Technology
497 Teemu Torma, Helsinki U of Technology
498 Linus Torvalds, Helsinki
500 Warren Tucker, Tridom Corp, Mountain Park, GA
501 Dave Tweten, AMES-NAS
503 Walter Underwood, Ford Aerospace
504 Pieter Van Der Linden, Centre Mondial, Paris
505 Ge van Geldorp, Netherlands
506 Fred van Kempen, MINIX User Group, Voorhout, Netherlands
507 Wayne Van Pelt, GE/CRD
508 Mark Vasoll, Oklahoma State U (V7 UNIX)
509 Konstantin Vinogradov, ICSTI, Moscow
511 Bernie Volz, Process Software
512 Eduard Vopicka, Prague University of Economics, Czech Republic
515 Roger Wallace, Raytheon
516 Stephen Walton, Calif State U, Northridge (Amiga)
517 Jamie Watson, Adasoft, Switzerland (AIX)
518 Rick Watson, U of Texas (Macintosh)
519 Eric Weaver, Columbia U
520 Scott Weikart (Association for Progressive Communications)
521 Robert Weiner, Programming Plus, New York City
522 Lauren Weinstein, Vortex Technlogy
523 David Wexelblat, AT&T
524 Clark Wierda, Illuminati Online
525 Joachim Wiesel, U of Karlsruhe
526 Lon Willett, U of Utah
527 Michael Williams, UCLA
528 Nate Williams, U of Montana
530 Joellen Windsor, U of Arizona
531 Patrick Wolfe, Kuck & Associates, Inc.
532 Gregg Wonderly, Oklahoma State U (V7 UNIX)
533 Farrell Woods, Concurrent (formerly Masscomp)
534 Dave Woolley, CAP Communication Systems, London
535 Jack Woolley, SCT Corp
537 Ken Yap, formerly of U of Rochester
538 John Zeeff, Ann Arbor, MI
541 #include "ckcker.h" /* Kermit symbols */
542 #include "ckcnet.h" /* Network symbols */
553 #define INCL_VIO /* Needed for ckocon.h */
565 /* Text message definitions.. each should be 256 chars long, or less. */
567 char *srvtxt = "\r\n\
568 Entering server mode.\r\n\0";
572 It seems there was a large installation that was using C-Kermit 5A(165)
573 or thereabouts, which had deployed thousands of MS-DOS Kermit scripts in
574 scattered locations that looked for strings in the old server message,
575 which changed in 5A(183), August 1992.
577 char *srvtxt = "\r\n\
578 C-Kermit server starting. Return to your local machine by typing\r\n\
579 its escape sequence for closing the connection, and issue further\r\n\
580 commands from there. To shut down the C-Kermit server, issue the\r\n\
581 FINISH or BYE command and then reconnect.\n\
585 char *srvtxt = "\r\012\
586 Entering server mode. If your local Kermit software is menu driven, use\r\012\
587 the menus to send commands to the server. Otherwise, enter the escape\r\012\
588 sequence to return to your local Kermit prompt and issue commands from\r\012\
589 there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\012\
590 other available services. Use BYE or FINISH to end server mode.\r\012\0";
591 #else /* UNIX, VMS, AOS/VS, and all others */
592 char *srvtxt = "\r\n\
593 Entering server mode. If your local Kermit software is menu driven, use\r\n\
594 the menus to send commands to the server. Otherwise, enter the escape\r\n\
595 sequence to return to your local Kermit prompt and issue commands from\r\n\
596 there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\n\
597 other available services. Use BYE or FINISH to end server mode.\r\n\0";
601 #else /* server mode disabled */
603 #endif /* NOSERVER */
605 int initflg = 0; /* sysinit() has executed... */
606 int howcalled = I_AM_KERMIT; /* How I was called */
608 int quitting = 0; /* I'm in the act of quitting */
611 char * iksdconf = IKSDCONF; /* IKSD configuration file */
612 int iksdcf = 0; /* Has IKSD c.f. been processed? */
613 #endif /* IKSDCONF */
615 int srvcdmsg = 0; /* [Server] CD message */
616 char * cdmsgfile[8] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
617 char * cdmsgstr = NULL;
618 char * ckcdpath = NULL;
620 #ifdef NLCHAR /* Text-file line terminator */
626 int fblksiz = DBLKSIZ; /* File blocksize */
627 int frecl = DLRECL; /* File record length */
628 int frecfm = XYFF_S; /* File record format (default = stream) */
629 int forg = XYFO_S; /* File organization (sequential) */
630 int fcctrl = XYFP_N; /* File carriage control (ctrl chars) */
631 int filecase = FILECASE; /* Case matters in filenames */
632 int stathack = 1; /* Fast directory lookups by default */
634 char uidbuf[UIDBUFLEN] = { NUL, NUL }; /* User ID buffer */
635 int cfilef = 0; /* Application ("kerbang") file flag */
636 char cmdfil[CKMAXPATH + 1] = { NUL, NUL }; /* Application file name */
637 int haveurl = 0; /* URL given on command line */
640 /* Multi-protocol support */
642 struct ck_p ptab[NPROTOS] = { /* Initialize the Kermit part ... */
644 DRPSIZ, /* Receive packet size */
645 DSPSIZ, /* Send packet size */
646 0, /* Send-packet-size-set flag */
647 DFWSIZ, /* Window size */
650 PX_CAU, /* Control char unprefixing... */
653 #endif /* NEWDEFAULTS */
655 #ifdef VMS /* Default filename collision action */
656 XYFX_X, /* REPLACE for VAX/VMS */
658 XYFX_B, /* BACKUP for everybody else */
661 #ifdef OS2 /* Flag for file name conversion */
662 XYFN_L, /* Literal for OS2 */
664 XYFN_C, /* Converted for others */
667 PATH_OFF, /* Send pathnames OFF */
668 PATH_AUTO, /* Receive pathnames AUTO */
669 NULL, /* Host receive initiation string (binary) */
670 NULL, /* Host receive initiation string (text) */
671 NULL, /* Host server string */
672 NULL, /* External protocol send command (binary) */
673 NULL, /* External protocol send command (text) */
674 NULL, /* External protocol receive command (bin) */
675 NULL } /* External protocol receive command (txt) */
678 {"XMODEM", 128,128,-1,-1, 1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
679 {"XMODEM-CRC",128,128,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
680 {"YMODEM", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
681 {"YMODEM-g", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
682 {"ZMODEM", -1, -1,-1,-1,PX_WIL,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
683 {"Other", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
687 /* Declarations for Send-Init Parameters */
689 int spsiz = DSPSIZ, /* Current packet size to send */
690 spmax = DSPSIZ, /* Biggest packet size we can send */
691 lastspmax = DSPSIZ, /* Send-packet size last used */
692 spsizr = DSPSIZ, /* Send-packet size requested */
693 spsizf = 0, /* Flag to override size negotiation */
694 rpsiz = DRPSIZ, /* Biggest we want to receive */
695 urpsiz = DRPSIZ, /* User-requested receive pkt size */
696 maxrps = MAXRP, /* Maximum incoming long packet size */
697 maxsps = MAXSP, /* Maximum outbound l.p. size */
698 maxtry = MAXTRY, /* Maximum retries per packet */
699 wslots = 1, /* Window size currently in use */
700 wslotr = DFWSIZ, /* Window size from SET WINDOW */
701 wslotn = 1, /* Window size negotiated in S-pkt */
702 timeouts = 0, /* For statistics reporting */
703 spackets = 0, /* ... */
704 rpackets = 0, /* ... */
705 retrans = 0, /* ... */
706 crunched = 0, /* ... */
709 srvidl = 0, /* Server idle timeout */
710 srvdis = 1, /* Server file xfer display */
711 srvtim = DSRVTIM, /* Server command wait timeout */
712 srvping = 1, /* Server keepalive */
714 timint is the timeout interval I use when waiting for a packet.
715 pkttim is the SET RECEIVE TIMEOUT value, sent to the other Kermit.
716 rtimo is the SET SEND TIMEOUT value. rtimo is the initial value of
717 timint. timint is changed by the value in the incoming negotiation
718 packet unless a SET SEND TIMEOUT command was given.
720 timint = DMYTIM, /* Timeout interval I use */
721 pkttim = URTIME, /* Timeout I want you to use */
722 rtimo = DMYTIM, /* Normal packet wait timeout */
723 timef = 0, /* Flag to override what you ask */
725 rttflg = 1, /* Use dynamic round-trip timers */
727 rttflg = 0, /* Use fixed timer */
728 #endif /* CK_TIMERS */
729 mintime = 1, /* Minimum timeout */
730 maxtime = 0, /* Maximum timeout */
732 npad = MYPADN, /* How much padding to send */
733 mypadn = MYPADN, /* How much padding to ask for */
734 bctr = DFBCT, /* Block check type requested */
735 bctu = 1, /* Block check type used */
736 bctl = 1, /* Block check length */
737 bctf = 0, /* Block check type 3 forced on all */
738 c_save = -1, /* Block check saving and restoring */
739 ss_save = -1, /* Slow-start saving and restoring */
740 ebq = MYEBQ, /* 8th bit prefix */
741 ebqflg = 0, /* 8th-bit quoting flag */
742 rqf = -1, /* Flag used in 8bq negotiation */
743 rq = 0, /* Received 8bq bid */
744 sq = 'Y', /* Sent 8bq bid */
745 rpt = 0, /* Repeat count */
746 rptq = MYRPTQ, /* Repeat prefix */
747 rptflg = 0, /* Repeat processing flag */
748 rptena = 1, /* Repeat processing enabled */
749 xfrcan = 1, /* Transfer cancellation enabled */
750 xfrint = 1, /* Transfer interruption enabled */
751 xfrchr = 3, /* Transfer cancel char = Ctrl-C */
752 xfrnum = 3, /* Need three of them by default */
754 char * xfrmsg = NULL; /* Message for f.t. display screen */
758 int xfrxla = 0; /* Character-set translation */
760 int xfrxla = 1; /* enabled or disabled */
763 int havelfs = 0; /* Large file support available */
766 int epktflg = 0; /* E-PACKET command active */
768 int capas = 9, /* Position of Capabilities */
769 lpcapb = 2, /* Long Packet capability */
770 lpcapr = 1, /* requested */
771 lpcapu = 0, /* used */
772 swcapb = 4, /* Sliding Window capability */
773 swcapr = 1, /* requested (allowed) */
774 swcapu = 0, /* used */
775 atcapb = 8, /* Attribute capability */
776 atcapr = 1, /* requested */
777 atcapu = 0, /* used */
778 rscapb = 16, /* RESEND capability */
779 rscapr = 1, /* requested by default */
780 rscapu = 0, /* used */
781 lscapb = 32, /* Locking Shift capability */
782 lscapr = 1, /* requested by default */
783 lscapu = 0; /* used */
785 /* Flags for whether to use particular attributes */
787 int atenci = 1, /* Encoding in */
788 atenco = 1, /* Encoding out */
789 atdati = 1, /* Date in */
790 atdato = 1, /* Date out */
791 atdisi = 1, /* Disposition in/out */
793 atleni = 1, /* Length in/out (both kinds) */
795 atblki = 1, /* Blocksize in/out */
797 attypi = 1, /* File type in/out */
799 atsidi = 1, /* System ID in/out */
801 atsysi = 1, /* System-dependent parameters in/out */
804 int dispos = 0; /* Disposition */
811 #endif /* CK_PERMS */
813 int atfrmi = 1, /* Record Format in/out */
817 int atcrei = 1, /* Creator ID in/out */
819 atacti = 1, /* Account in/out */
823 int sprmlen = -1; /* Send/Receive protocol parameter */
824 int rprmlen = -1; /* string length limits */
825 int sendipkts = 1; /* Send I packets */
827 CHAR padch = MYPADC, /* Padding character to send */
828 mypadc = MYPADC, /* Padding character to ask for */
829 seol = MYEOL, /* End-Of-Line character to send */
830 eol = MYEOL, /* End-Of-Line character to look for */
831 ctlq = CTLQ, /* Control prefix in incoming data */
832 myctlq = CTLQ, /* Outbound control character prefix */
833 myrptq = MYRPTQ; /* Repeat prefix I want to use */
835 int rptmin = 3; /* Repeat-count minimum */
837 int usepipes = 0, /* Used for xfer to/from pipes */
840 char * filefile = NULL; /* File containing list of filenames */
841 /* CD message filename list */
843 char whoareu[16] = { NUL, NUL }; /* System ID of other Kermit */
844 int sysindex = -1; /* and index to its system ID struct */
846 int wearealike = 0; /* 2 Kermits have compatible sysids */
847 char * cksysid = /* My system ID */
882 #endif /* datageneral */
891 int oopts = -1; /* O-Packet Options */
892 int omode = -1; /* O-Packet Transfer Mode */
893 int oname = -1; /* O-Packet Filename Options */
894 int opath = -1; /* O-Packet Pathname Options */
896 struct zattr iattr; /* Incoming file attributes */
899 /* VMS labeled file default options - name only. */
900 int lf_opts = LBL_NAM;
903 /* OS/2 labeled file default options, all attributes but archived. */
904 unsigned long int lf_opts = LBL_EXT|LBL_HID|LBL_RO|LBL_SYS;
910 /* Packet-related variables */
912 int pktnum = 0, /* Current packet number */
913 sndtyp = 0, /* Type of packet just sent */
914 rcvtyp = 0, /* Type of packet just received */
915 rsn, /* Received packet sequence number */
916 rln, /* Received packet length */
917 size, /* Current size of output pkt data */
918 osize, /* Previous output packet data size */
919 maxsize, /* Max size for building data field */
920 spktl = 0, /* Length packet being sent */
921 rpktl = 0, /* Length of packet just received */
922 pktpaus = 0, /* Interpacket pause interval, msec */
923 rprintf, /* REMOTE PRINT flag */
924 rmailf, /* MAIL flag */
925 xferstat = -1, /* Status of last transaction */
926 filestatus = 0; /* Status of last file transfer */
928 CHAR pktmsgbuf[PKTMSGLEN+1];
929 CHAR *epktmsg = pktmsgbuf;
932 int srvcmdlen = MAXRP; /* srvcmd buffer length */
935 int srvcmdlen = MAXRP;
947 *srvcmd = (CHAR *)0, /* Where to decode server command */
953 padbuf[96], /* Buffer for send-padding */
955 *rdatap, /* Pointer to received packet data */
956 *data = (CHAR *)0, /* Pointer to send-packet data */
957 *srvptr, /* Pointer to srvcmd */
958 mystch = SOH, /* Outbound packet-start character */
959 stchr = SOH; /* Incoming packet-start character */
961 /* File-related variables */
963 #ifndef NOMSEND /* Multiple SEND */
964 struct filelist * filehead = NULL; /* SEND list */
965 struct filelist * filetail = NULL;
966 struct filelist * filenext = NULL;
970 char filnam[CKMAXPATH + 1]; /* Name of current file. */
971 char ofilnam[CKMAXPATH + 1]; /* Original name. */
973 int pipesend = 0; /* Nonzero if sending from pipe */
975 char * sndfilter = NULL; /* Send and receive filters */
976 char * rcvfilter = NULL;
977 #endif /* PIPESEND */
979 char ** sndarray = NULL; /* SEND /ARRAY pointer and range */
981 int sndxlo = -1, sndxhi = -1, sndxin = -1;
986 int ngetpath = 0; /* GET search path */
988 char * getpath[MAXGETPATH];
989 char * x_user = NULL; /* Server login information */
990 char * x_passwd = NULL;
991 char * x_acct = NULL;
992 #endif /* NOSERVER */
994 int x_login = 0; /* Login required */
995 int x_logged = 0; /* User is logged in */
997 extern int timelimit;
1000 int logintimo = 300; /* Login timeout */
1001 char * userfile = NULL; /* Forbidden user file */
1002 #endif /* CK_LOGIN */
1004 char * anonfile = NULL; /* Anonymous login init file */
1005 char * anonroot = NULL; /* Anonymous file-system root */
1006 int iks_timo = 300; /* 5 minutes idle timo */
1007 int iks_retry = 3; /* 3 attempts at login */
1011 extern VOID zsyslog();
1012 extern int ckxlogging, ckxsyslog;
1013 #endif /* CKSYSLOG */
1015 CK_OFF_T fsize = (CK_OFF_T)0, /* Size of current file */
1016 sendstart = (CK_OFF_T)0, /* SEND start position */
1017 calibrate = (CK_OFF_T)0; /* Nonzero if calibration run */
1019 int nzxopts = 0; /* Options for nzxpand() */
1020 int nfils = 0; /* Number of files in file group */
1021 int wildena = 1; /* Wildcard expansion enabled */
1023 int wildxpand = 0; /* Who expands wildcards, 0=Kermit.. */
1026 int wildxpand = 1; /* 1=Shell. */
1027 #endif /* STRATUS */
1030 int matchdot = 0; /* Whether to match dot files */
1033 #endif /* UNIXOROSK */
1034 int matchfifo = 0; /* Whether to match FIFO "files" */
1035 int clfils = 0; /* Flag for command-line files */
1036 int stayflg = 0; /* Flag for "stay", i.e. "-S" */
1037 int xfinish = 0; /* Flag for FINISH = EXIT */
1038 long ztusec = -1L; /* Used with ztime() */
1039 long ztmsec = -1L; /* Ditto */
1041 /* Communication device / connection variables */
1043 char ttname[TTNAMLEN+1]; /* Name of communication device */
1046 int connected = 0; /* True if connected */
1047 int startconnected; /* initial state of connected */
1050 long speed = -1L; /* Communication device speed */
1051 int wasclosed = 0; /* Connection was just closed */
1052 int whyclosed = WC_REMO; /* why it was closed */
1053 int qnxportlock = 0; /* QNX port locking on/off */
1057 #endif /* CLSONDISC */
1059 int cxflow[CXT_MAX+1]; /* See initflow() */
1062 char * floname[] = { /* Flow control names */
1063 "none", "xon/xoff", "rts/cts", "dtr/cd", "etx/ack", "string",
1064 "xxx1", "xxx2", "dtr/cts", "keep", "auto"
1066 int nfloname = (sizeof(floname) / sizeof(char *));
1068 char * cxname[] = { /* Connection type names */
1069 "remote", "direct-serial", "modem", "tcp/ip", "x.25", "decnet",
1070 "lat", "netbios", "named-pipe", "ssh", "pipe"
1072 int ncxname = (sizeof(cxname) / sizeof(char *));
1075 int parity = DEFPAR, /* Parity specified, 0,'e','o',etc */
1076 hwparity = 0, /* Hardware parity for serial port */
1077 stopbits = -1, /* Stop bits for serial port */
1078 clsondisc = CLSONDISC, /* Serial port close on disconnect */
1079 autopar = 0, /* Automatic parity change flag */
1080 sosi = 0, /* Shift-In/Out flag */
1081 flow = 0, /* Flow control (see initflow()) */
1082 autoflow = 1, /* Automatic flow control */
1083 turn = 0, /* Line turnaround handshake flag */
1084 turnch = XON, /* Line turnaround character */
1085 duplex = 0, /* Duplex, full by default */
1086 escape = DFESC, /* Escape character for connect */
1087 ckdelay = DDELAY, /* Initial delay before sending */
1088 tnlm = 0; /* Terminal newline mode */
1090 /* Networks for SET HOST */
1093 #define MYHOSTL 1024
1096 #endif /* BIGBUFOK */
1098 char myhost[MYHOSTL]; /* Local host name */
1099 int network = 0; /* Network vs serial connection */
1100 int inserver = 0; /* Running as an Internet server */
1101 int isguest = 0; /* User is anonymous */
1102 char * clienthost = NULL; /* Peer host name or address */
1103 int tcp_incoming = 0; /* Incoming TCP connection? */
1107 int nettype = NET_TCPB; /* Default network type */
1110 int nettype = NET_SX25;
1113 int nettype = NET_IX25;
1116 int nettype = NET_HX25;
1119 int nettype = NET_VX25;
1122 int nettype = NET_DEC;
1125 int nettype = NET_SLAT;
1127 int nettype = NET_NONE;
1128 #endif /* SUPERLAT */
1130 #endif /* STRATUSX25 */
1134 #endif /* TCPSOCKET */
1136 int nettype = NET_NONE;
1137 #endif /* NETCONN */
1140 int revcall = 0; /* X.25 reverse call not selected */
1141 int closgr = -1; /* X.25 closed user group */
1142 int cudata = 0; /* X.25 call user data not specified */
1143 char udata[MAXCUDATA]; /* X.25 call user data */
1147 I was unable to find any pre-defined MAX values for x25 addresses - the
1148 addresses that I've seen have been around 10-12 characters 32 is probably
1149 enough, 64 is hopefully safe for everyone.
1151 x25addr_t local_nua = {'\0'}; /* local x.25 address */
1152 x25addr_t remote_nua = {'\0'}; /* remote x.25 address */
1153 char x25name[32] = {'\0'}; /* x25 device name, sx25a0 or sx25a1 */
1154 char x25dev[64] = "/dev/x25pkt"; /* x25 device in /dev */
1155 int x25port = 0; /* port used for X.25 - AIX only */
1160 This condition is unrelated to the above IBMX25 condition.
1161 IBM X.25 doesn't have PAD support.
1163 CHAR padparms[MAXPADPARMS+1]; /* X.3 parameters */
1169 int isinterrupted = 0; /* Used in exception handling */
1170 int what = W_INIT; /* What I am doing */
1171 int lastxfer = 0; /* Last transfer (send or receive) */
1173 extern int mdmtyp; /* Modem (/network) type */
1176 extern int StartedFromDialer;
1178 extern int TlsIndex;
1181 unsigned long ESPToRestore; /* Ditto */
1186 int os2pm = 0; /* OS/2 Presentation Manager flag */
1189 /* Terminal screen size, if known, -1 means unknown. */
1194 int tt_rows[VNUM] = {24,24,25,1}; /* Rows (height) */
1195 int tt_cols[VNUM] = {80,80,80,80}; /* Columns (width) */
1196 int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */
1198 int tt_rows[VNUM] = {-1,24,25,1}; /* Rows (height) */
1199 int tt_cols[VNUM] = {-1,80,80,80}; /* Columns (width) */
1200 int cmd_rows = -1, cmd_cols = -1; /* Command/console screen dimensions */
1202 int k95stdio = 0; /* Stdio threads */
1203 int tt_bell = XYB_AUD | XYB_SYS; /* BELL AUDIBLE (system sounds) */
1205 int tt_rows = -1; /* Rows (height) */
1206 int tt_cols = -1; /* Columns (width) */
1207 int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */
1208 int tt_bell = XYB_AUD; /* BELL ON */
1211 int tt_print = 0; /* Transparent print disabled */
1212 int tt_escape = 1; /* Escaping back is enabled */
1213 int tt_scroll = 1; /* Scrolling operations are enabled */
1215 int tn_exit = 0; /* Exit on disconnect */
1217 int exitonclose = 0; /* Exit on close */
1218 int exithangup = 1; /* Hangup on exit */
1219 int haveline = 0; /* SET LINE or SET HOST in effect */
1220 int tlevel = -1; /* Take-file command level */
1221 int hints = 1; /* Whether to give hints */
1224 int remonly = 1; /* Remote-mode-only advisory (-R) */
1225 int nolocal = 1; /* Remote-only strictly enforced */
1229 int cx_status = 0; /* CONNECT return status */
1230 #endif /* NOLOCAL */
1233 extern int cmdlvl; /* Command level */
1234 extern int maclvl; /* Macro invocation level */
1237 int protocol = PROTO_K; /* File transfer protocol = Kermit */
1240 int prefixing = PX_CAU;
1242 int prefixing = PX_ALL;
1243 #endif /* NEWDEFAULTS */
1245 extern short ctlp[]; /* Control-prefix table */
1247 int carrier = CAR_AUT; /* Pay attention to carrier signal */
1248 int cdtimo = 0; /* Carrier wait timeout */
1249 int xitsta = GOOD_EXIT; /* Program exit status */
1251 #ifdef VMS /* Default filename collision action */
1252 int fncact = XYFX_X; /* REPLACE for VMS */
1254 int fncact = XYFX_B; /* BACKUP for everybody else */
1257 int fncsav = -1; /* For saving & restoring the above */
1258 int bgset = -1; /* BACKGROUND mode set explicitly */
1260 int cmdint = 1; /* Interrupts are allowed */
1262 int xsuspend = DFSUSP; /* Whether SUSPEND command, etc, */
1263 #else /* is to be allowed. */
1267 /* Statistics variables */
1270 flci, /* Characters from line, current file */
1271 flco, /* Chars to line, current file */
1272 tlci, /* Chars from line in transaction */
1273 tlco, /* Chars to line in transaction */
1274 ffc, /* Chars to/from current file */
1275 tfc; /* Chars to/from files in transaction */
1277 long filcnt, /* Number of files in transaction */
1278 filrej, /* Number of files rejected in transaction */
1279 cps = 0L, /* Chars/sec last transfer */
1280 peakcps = 0L, /* Peak chars/sec last transfer */
1281 ccu, /* Control chars unprefixed in transaction */
1282 ccp, /* Control chars prefixed in transaction */
1283 rptn; /* Repeated characters compressed */
1285 int tsecs = 0; /* Seconds for transaction */
1286 int fsecs = 0; /* Per-file timer */
1290 fpfsecs = 0.0, /* Floating point per-file timer */
1291 fptsecs = 0.0; /* and per-transaction timer */
1292 #endif /* GFTIMER */
1296 int deblog = 0, /* Debug log is open */
1297 debok = 1, /* Debug log is not disabled */
1298 debxlen = 54, /* Default length for debug strings */
1299 debses = 0, /* Flag for DEBUG SESSION */
1300 debtim = 0, /* Include timestamp in debug log */
1301 debmsg = 0, /* Debug messages on/off */
1302 pktlog = 0, /* Flag for packet logging */
1303 seslog = 0, /* Session logging */
1304 dialog = 0, /* DIAL logging */
1305 tralog = 0, /* Transaction logging */
1306 tlogfmt = 1, /* Transaction log format (verbose) */
1307 tlogsep = (int)',', /* Transaction log field separator */
1308 displa = 0, /* File transfer display on/off */
1309 stdouf = 0, /* Flag for output to stdout */
1310 stdinf = 0, /* Flag for input from stdin */
1311 xflg = 0, /* Flag for X instead of F packet */
1312 hcflg = 0, /* Doing Host command */
1313 dest = DEST_D, /* Destination for packet data */
1314 zchkod = 0, /* zchko() should work for dirs too? */
1315 zchkid = 0, /* zchki() should work for dirs too? */
1317 /* If you change this, also see struct ptab above... */
1319 #ifdef OS2 /* Flag for file name conversion */
1320 fncnv = XYFN_L, /* Default is Literal in OS/2, */
1321 f_save = XYFN_L, /* (saved copy of same) */
1323 fncnv = XYFN_C, /* elsewhere Convert them */
1324 f_save = XYFN_C, /* (ditto) */
1327 fnspath = PATH_OFF, /* Send file path */
1328 fnrpath = PATH_AUTO, /* Receive file path */
1329 fackpath = 1, /* Send back path in ACK to F */
1330 binary = XYFT_B, /* Default file transfer mode */
1331 b_save = XYFT_B, /* Saved file mode */
1332 eofmethod = 0, /* EOF detection method (length) */
1335 cursor_save = -1, /* Cursor state */
1338 xfermode = XMODE_A, /* Transfer mode, manual or auto */
1339 xfiletype = -1, /* Transfer only text (or binary) */
1340 recursive = 0, /* Recursive directory traversal */
1341 nolinks = 2, /* Don't follow symbolic links */
1342 skipbup = 0, /* Skip backup files when sending */
1343 sendmode = SM_SEND, /* Which type of SEND operation */
1344 slostart = 1, /* Slow start (grow packet lengths) */
1345 cmask = 0377, /* CONNECT (terminal) byte mask */
1346 fmask = 0377, /* File byte mask */
1347 ckwarn = 0, /* Flag for file warning */
1348 quiet = 0, /* Be quiet during file transfer */
1349 local = 0, /* 1 = local mode, 0 = remote mode */
1350 cxtype = CXT_REMOTE, /* Connection type */
1351 server = 0, /* Flag for I Am Server */
1352 query = 0, /* Flag for Query active */
1353 justone = 0, /* Server should do Just One command */
1354 urserver = 0, /* Flag for You Are Server */
1355 bye_active = 0, /* Flag for BYE command active */
1356 diractive = 0, /* Flag for DIRECTORY command active */
1357 cdactive = 0, /* Flag for CD command active */
1358 cflg = 0, /* Connect before transaction */
1359 cnflg = 0, /* Connect after transaction */
1360 cxseen = 0, /* Flag for cancelling a file */
1361 czseen = 0, /* Flag for cancelling file group */
1362 fatalio = 0, /* Flag for fatal i/o error */
1363 discard = 0, /* Flag for file to be discarded */
1364 keep = SET_AUTO, /* Keep incomplete files = AUTO */
1365 unkcs = 1, /* Keep file w/unknown character set */
1367 filepeek = 0, /* Inspection of files */
1373 #endif /* datageneral */
1375 nakstate = 0, /* In a state where we can send NAKs */
1376 dblchar = -1, /* Character to double when sending */
1377 moving = 0, /* MOVE = send, then delete */
1378 reliable = SET_AUTO, /* Nonzero if transport is reliable */
1381 urclear = 0, /* Nonzero for clear channel to you */
1382 clearrq = SET_AUTO, /* SET CLEARCHANEL value */
1384 streaming = 0, /* Nonzero if streaming is active */
1385 streamok = 0, /* Nonzero if streaming negotiated */
1386 streamrq = SET_AUTO, /* SET STREAMING value */
1387 streamed = -1; /* Whether we streamed last time */
1389 char * snd_move = NULL; /* Move file after sending it */
1390 char * snd_rename = NULL; /* Rename file after sending it */
1391 char * rcv_move = NULL; /* Move file after receiving it */
1392 char * rcv_rename = NULL; /* Rename file after receiving it */
1394 char * g_snd_move = NULL;
1395 char * g_snd_rename = NULL;
1396 char * g_rcv_move = NULL;
1397 char * g_rcv_rename = NULL;
1400 char *tt_trigger[TRIGGERS] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
1401 CHAR *tt_trmatch[TRIGGERS] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
1402 char *triggerval = NULL;
1403 #endif /* CK_TRIGGER */
1405 int ckxlogging = 0; /* Flag for syslogging active */
1406 int ikdbopen = 0; /* Flag for IKSD database active */
1407 int dbinited = 0; /* Flag for IKSDB record init'd */
1409 int ckxsyslog = 0; /* Logging level 0 */
1412 int ckxsyslog = SYSLOGLEVEL; /* Logging level specified */
1414 int ckxsyslog = SYSLG_DF; /* Default logging level */
1415 #endif /* SYSLOGLEVEL */
1416 #endif /* CKSYSLOG */
1420 _PROTOTYP( VOID iniopthlp, (void) ); /* Command-line help initializer */
1424 _PROTOTYP( VOID getexedir, (void) );
1425 _PROTOTYP( int putnothing, (char) );
1428 _PROTOTYP( VOID doiksdinit, (void) );
1429 _PROTOTYP( VOID iksdinit, (void) );
1430 _PROTOTYP( VOID doiklog, (void) );
1431 _PROTOTYP( int dbinit, (void) );
1434 /* Variables passed from command parser to protocol module */
1439 _PROTOTYP( VOID apconect, (void) );
1446 char *clcmds = NULL; /* Pointer to command-line commands */
1450 extern MACRO *macrotab;
1451 #endif /* NOSETKEY */
1454 int nopush = 0; /* PUSH enabled */
1456 int nopush = 1; /* PUSH disabled */
1459 CHAR sstate = (CHAR) 0; /* Starting state for automaton */
1460 CHAR zstate = (CHAR) 0; /* For remembering sstate */
1461 char * printername = NULL; /* NULL if printer not redirected */
1462 int printpipe = 0; /* For SET PRINTER */
1466 char *cmarg = ""; /* Pointer to command data */
1467 char *cmarg2 = ""; /* Pointer to 2nd command data */
1468 char **cmlist; /* Pointer to file list in argv */
1470 #ifdef CK_AUTODL /* Autodownload */
1471 int autodl = 1; /* Enabled by default */
1473 int autodl = 0; /* (or if not implemented). */
1474 #endif /* CK_AUTODL */
1475 int adl_err = 1; /* 1 = stop on error */
1477 int adl_ask = 1; /* 1 = file dialog on autodownload */
1479 int adl_ask = 0; /* 0 = no file dialog */
1481 #ifdef OS2 /* AUTODOWNLOAD parameters */
1482 int adl_kmode = ADL_PACK, /* Match Packet to signal download */
1483 adl_zmode = ADL_PACK;
1484 char * adl_kstr = NULL; /* KERMIT Download String */
1485 char * adl_zstr = NULL; /* ZMODEM Download String */
1488 int remfile = 0, rempipe = 0, remappd = 0; /* REMOTE output redirection */
1489 char * remdest = NULL;
1495 1 = enabled in local mode
1496 2 = enabled in remote mode
1497 3 = enabled in both local and remote modes
1498 only as initial (default) values.
1500 int en_xit = 2; /* EXIT */
1501 int en_cwd = 3; /* CD/CWD */
1502 int en_cpy = 3; /* COPY */
1503 int en_del = 2; /* DELETE */
1504 int en_mkd = 3; /* MKDIR */
1505 int en_rmd = 2; /* RMDIR */
1506 int en_dir = 3; /* DIRECTORY */
1507 int en_fin = 3; /* FINISH */
1508 int en_get = 3; /* GET */
1510 int en_hos = 2; /* HOST enabled */
1512 int en_hos = 0; /* HOST disabled */
1514 int en_ren = 3; /* RENAME */
1515 int en_sen = 3; /* SEND */
1516 int en_set = 3; /* SET */
1517 int en_spa = 3; /* SPACE */
1518 int en_typ = 3; /* TYPE */
1519 int en_who = 3; /* WHO */
1521 /* Data General AOS/VS can't do this */
1522 int en_bye = 0; /* BYE */
1524 int en_bye = 2; /* PCs in local mode... */
1525 #endif /* datageneral */
1526 int en_asg = 3; /* ASSIGN */
1527 int en_que = 3; /* QUERY */
1528 int en_ret = 2; /* RETRIEVE */
1529 int en_mai = 3; /* MAIL */
1530 int en_pri = 3; /* PRINT */
1531 int en_ena = 3; /* ENABLE */
1533 int en_xit = 0, en_cwd = 0, en_cpy = 0, en_del = 0, en_mkd = 0, en_rmd = 0,
1534 en_dir = 0, en_fin = 0, en_get = 0, en_hos = 0, en_ren = 0, en_sen = 0,
1535 en_set = 0, en_spa = 0, en_typ = 0, en_who = 0, en_bye = 0, en_asg = 0,
1536 en_que = 0, en_ret = 0, en_mai = 0, en_pri = 0, en_ena = 0;
1537 #endif /* NOSERVER */
1542 char **xargv; /* Global copies of argv */
1543 int xargc; /* and argc */
1544 int xargs; /* an immutable copy of argc */
1545 char *xarg0; /* and of argv[0] */
1546 char *pipedata; /* Pointer to -P (pipe) data */
1548 extern char *dftty; /* Default tty name from ck?tio.c */
1549 extern int dfloc; /* Default location: remote/local */
1550 extern int dfprty; /* Default parity */
1551 extern int dfflow; /* Default flow control */
1557 Buffered file input and output buffers. See getpkt() in ckcfns.c
1558 and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).
1561 /* Now we allocate them dynamically, see getiobs() below. */
1562 char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];
1563 #endif /* DYNAMIC */
1564 char *zinptr, *zoutptr;
1565 int zincnt, zoutcnt;
1566 int zobufsize = OBUFSIZE;
1572 #endif /* SESLIMIT */
1574 #ifdef CK_AUTHENTICATION
1576 #endif /* CK_AUTHENTICATION */
1578 _PROTOTYP( int getiobs, (VOID) );
1580 /* M A I N -- C-Kermit main program */
1588 #ifdef GEMDOS /* Special for Atari ST */
1589 cc_clean(); /* This can't be right? */
1591 #endif /* NOCCTRAP */
1594 /* Info associated with a system ID */
1596 struct sysdata sysidlist[] = { /* Add others as needed... */
1597 { "0", "anonymous", 0, NUL, 0, 0, 0 },
1598 { "A1", "Apple II", 0, NUL, 0, 0, 3 }, /* fix this */
1599 { "A3", "Macintosh", 1, ':', 0, 2, 1 },
1600 { "D7", "VMS", 0, ']', 1, 0, 0 },
1601 { "DA", "RSTS/E", 0, ']', 1, 0, 3 }, /* (i think...) */
1602 { "DB", "RT11", 0, NUL, 1, 0, 3 }, /* (maybe...) */
1603 { "F3", "AOS/VS", 1, ':', 0, 0, 2 },
1604 { "I1", "VM/CMS", 0, NUL, 0, 0, 0 },
1605 { "I2", "MVS/TSO", 0, NUL, 0, 0, 0 },
1606 { "I4", "MUSIC", 0, NUL, 0, 0, 0 },
1607 { "I7", "CICS", 0, NUL, 0, 0, 0 },
1608 { "I9", "MVS/ROSCOE", 0, NUL, 0, 0, 0 },
1609 { "K2", "Atari ST", 1, '\\', 1, 0, 3 },
1610 { "L3", "Amiga", 1, '/', 1, 0, 2 },
1611 { "MV", "Stratus VOS", 1, '>', 0, 1, 0 },
1612 { "N3", "Apollo Aegis", 1, '/', 0, 3, 2 },
1613 { "U1", "UNIX", 1, '/', 0, 3, 2 },
1614 { "U8", "MS-DOS", 1, '\\', 1, 0, 3 },
1615 { "UD", "OS-9", 1, '/', 0, 3, 2 },
1616 { "UN", "Windows-32", 1, '\\', 1, 2, 3 },
1617 { "UO", "OS/2", 1, '\\', 1, 2, 3 }
1619 static int nxxsysids = (sizeof(sysidlist) / sizeof(struct sysdata));
1621 /* Given a Kermit system ID code, return the associated name string */
1622 /* and some properties of the filenames... */
1625 getsysid(s) char * s; { /* Get system-type name */
1628 for (i = 0; i < nxxsysids; i++)
1629 if (!strcmp(sysidlist[i].sid_code,s))
1630 return(sysidlist[i].sid_name);
1635 getsysix(s) char *s; { /* Get system-type index */
1638 for (i = 0; i < nxxsysids; i++)
1639 if (!strcmp(sysidlist[i].sid_code,s))
1645 /* Tell if a pathname is absolute (versus relative) */
1646 /* This should be parceled out to each of the ck*fio.c modules... */
1647 /* VMS isabsolute() is now in ckvfio.c. */
1650 isabsolute(path) char * path; {
1657 x = (int) strlen(path);
1658 debug(F111,"isabsolute",path,x);
1666 #else /* def UNIX */
1668 if (*path == '/' || *path == '\\')
1670 else if (isalpha(*path) && x > 2)
1671 if (*(path+1) == ':' && (*(path +2) == '/' || *(path+2) == '\\'))
1681 #else /* def AMIGA */
1693 #else /* def datageneral */
1695 rc = 0; /* Fill in later... */
1698 rc = 0; /* Fill in later... */
1699 #else /* def STRATUS */
1701 if (*path == '/' || *path == '\\')
1703 else if (isalpha(*path) && x > 1)
1704 if (*(path+1) == ':')
1707 #endif /* STRATUS */
1709 #endif /* datageneral */
1714 debug(F101,"isabsolute rc","",rc);
1717 #endif /* ndef VMS */
1719 /* See if I have direct access to the keyboard */
1722 is_a_tty(n) int n; {
1750 extern char * sndexcept[], * rcvexcept[];
1752 for (i = 0; i < NSNDEXCEPT; i++) {
1753 sndexcept[i] = NULL;
1754 rcvexcept[i] = NULL;
1759 /* Initialize flow control table */
1762 initflow() { /* Default values for flow control */
1763 #ifdef VMS /* for each kind of connection. */
1764 /* The VMS telnet terminal driver treats "none" as request to lose chars */
1765 cxflow[CXT_REMOTE] = FLO_XONX; /* Remote mode... */
1768 /* Ditto for HP-UX */
1769 cxflow[CXT_REMOTE] = FLO_XONX; /* Remote mode... */
1771 /* The temptation is to make this one FLO_KEEP but don't!!! */
1772 /* It totally wrecks binary-file transfer when coming in via Telnet. */
1773 /* In UNIX at least... */
1774 cxflow[CXT_REMOTE] = FLO_NONE;
1779 cxflow[CXT_DIRECT] = FLO_XONX; /* Direct serial connections... */
1781 cxflow[CXT_DIRECT] = FLO_NONE;
1785 cxflow[CXT_MODEM] = FLO_RTSC; /* Modem connections... */
1788 cxflow[CXT_MODEM] = FLO_XONX;
1790 cxflow[CXT_MODEM] = FLO_NONE;
1792 #endif /* CK_RTSCTS */
1795 cxflow[CXT_TCPIP] = FLO_XONX; /* TCP/IP connections... */
1797 cxflow[CXT_TCPIP] = FLO_NONE;
1800 cxflow[CXT_SSH] = FLO_NONE;
1801 cxflow[CXT_X25] = FLO_NONE; /* Other kinds of networks... */
1802 cxflow[CXT_DECNET] = FLO_XONX;
1803 cxflow[CXT_LAT] = FLO_XONX;
1804 cxflow[CXT_NETBIOS] = FLO_NONE;
1805 cxflow[CXT_NPIPE] = FLO_NONE;
1806 cxflow[CXT_PIPE] = FLO_NONE;
1807 flow = cxflow[cxtype]; /* Initial flow setting. */
1808 debug(F101,"initflow","",flow);
1812 /* Initialize file transfer protocols */
1815 initproto(y, upbstr, uptstr, srvstr, sndbstr, sndtstr, rcvbstr, rcvtstr)
1817 char * upbstr, * uptstr, * srvstr, * sndbstr, * sndtstr, * rcvbstr,
1821 if (upbstr) /* Convert null strings */
1822 if (!*upbstr) /* to null pointers */
1825 if (uptstr) /* Convert null strings */
1826 if (!*uptstr) /* to null pointers */
1849 protocol = y; /* Set protocol */
1851 if (ptab[protocol].rpktlen > -1)
1852 urpsiz = ptab[protocol].rpktlen;
1853 if (ptab[protocol].spktflg > -1)
1854 spsizf = ptab[protocol].spktflg;
1855 if (ptab[protocol].spktlen > -1) {
1856 spsiz = ptab[protocol].spktlen;
1857 debug(F101,"initproto spsiz","",spsiz);
1859 spsizr = spmax = spsiz;
1860 debug(F101,"initproto spsizr","",spsizr);
1863 if (ptab[protocol].winsize > -1)
1864 wslotr = ptab[protocol].winsize;
1865 if (ptab[protocol].prefix > -1)
1866 prefixing = ptab[protocol].prefix;
1867 if (ptab[protocol].fnca > -1)
1868 fncact = ptab[protocol].fnca;
1869 if (ptab[protocol].fncn > -1)
1870 fncnv = ptab[protocol].fncn;
1871 if (ptab[protocol].fnsp > -1)
1872 fnspath = ptab[protocol].fnsp;
1873 if (ptab[protocol].fnrp > -1)
1874 fnrpath = ptab[protocol].fnrp;
1876 makestr(&(ptab[protocol].h_b_init),upbstr);
1877 makestr(&(ptab[protocol].h_t_init),uptstr);
1878 makestr(&(ptab[protocol].h_x_init),srvstr);
1879 makestr(&(ptab[protocol].p_b_scmd),sndbstr);
1880 makestr(&(ptab[protocol].p_t_scmd),sndtstr);
1881 makestr(&(ptab[protocol].p_b_rcmd),rcvbstr);
1882 makestr(&(ptab[protocol].p_t_rcmd),rcvtstr);
1889 docmdline(void * threadinfo)
1890 #else /* CK_ANSIC */
1891 docmdline(threadinfo) VOID * threadinfo;
1892 #endif /* CK_ANSIC */
1896 if (threadinfo) { /* Thread local storage... */
1897 TlsSetValue(TlsIndex,threadinfo);
1898 debug( F100, "docmdline called with threadinfo block", "", 0 );
1900 debug( F100, "docmdline threadinfo is NULL","",0);
1909 #endif /* CK_LOGIN */
1910 proto(); /* Take any requested action, then */
1911 if (!quiet) /* put cursor back at left margin, */
1914 if (cnflg) { /* Re-connect if requested */
1920 #endif /* NOLOCAL */
1923 ckThreadEnd(threadinfo);
1932 || inserver /* Internet server */
1936 extern int fdispla; /* File-transfer display format */
1937 extern char * ikprompt; /* IKSD prompt */
1942 x_login = 1; /* Login required */
1943 x_logged = 0; /* Not logged in yet */
1944 cmsetp(ikprompt); /* Set up IKSD's prompt */
1946 en_mai = 0; /* MAIL is disabled */
1947 en_who = 0; /* REMOTE WHO is disabled */
1948 en_hos = 0; /* REMOTE HOST is disabled */
1949 en_pri = 0; /* PRINT is disabled */
1950 #endif /* NOSERVER */
1952 x_login = 0; /* Login not required */
1953 x_logged = 1; /* Already logged in */
1955 #endif /* CK_LOGIN */
1957 nolocal = 1; /* SET LINE/HOST not allowed */
1958 fdispla = XYFD_N; /* No file-transfer display */
1960 clienthost = ckgetpeer(); /* Get client's hostname */
1961 debug(F110,"ikslogin clienthost",clienthost,0);
1962 #endif /* NETCONN */
1963 ztime(&s); /* Get current date and time */
1966 #ifdef CK_AUTHENTICATION
1968 x_logged = ck_tn_auth_valid(); /* Did Telnet Auth succeed? */
1969 debug(F111,"ikslogin","x_logged",x_logged);
1972 /* On Windows 9x, we do not have the ability in */
1973 /* zvuser() at present to determine if the name */
1974 /* approved in a Kerberos principal is really a */
1975 /* an account in the Windows Access Control List */
1976 if (isWin95() && x_logged == AUTH_VALID
1977 && (ck_tn_authenticated() != AUTHTYPE_NTLM)
1979 && (ck_tn_authenticated() != AUTHTYPE_SRP)
1982 auth_finished(AUTH_USER);
1983 x_logged = AUTH_USER;
1984 printf("WARNING:\r\n");
1986 " The Telnet authentication method used cannot provide for automated\r\n");
1988 " login to Windows 95 or Windows 98. A password must be entered\r\n");
1990 " locally to validate your userid. Telnet authentication (and encryption)\r\n"
1993 " can be used to validate the host (and protect the privacy of your password.)\
1999 if (x_logged == AUTH_VALID) {
2001 if ((ssl_active_flag || tls_active_flag) &&
2002 (!TELOPT_U(TELOPT_AUTHENTICATION) ||
2003 ck_tn_authenticated() == AUTHTYPE_NULL ||
2004 ck_tn_authenticated() == AUTHTYPE_AUTO)
2007 if (tls_is_krb5(0)) {
2008 printf("Authenticated using Kerberos 5\r\n");
2010 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2011 extern char szUserNameAuthenticated[];
2012 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2014 szUserNameAuthenticated
2017 #endif /* CKSYSLOG */
2019 #endif /* SSL_KRB5 */
2021 printf("Authenticated using X.509 certificate\r\n");
2023 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2024 extern char szUserNameAuthenticated[];
2025 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2026 "X.509 certificate",
2027 szUserNameAuthenticated
2030 #endif /* CKSYSLOG */
2035 printf("Authenticated using %s\r\n",
2036 AUTHTYPE_NAME(ck_tn_authenticated()));
2038 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2039 extern char szUserNameAuthenticated[];
2040 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2041 AUTHTYPE_NAME(ck_tn_authenticated()),
2042 szUserNameAuthenticated
2045 #endif /* CKSYSLOG */
2048 if (zvpass("") == 0)
2050 } else if (x_logged == AUTH_USER && !strcmp(uidbuf,"anonymous")) {
2051 extern char szUserNameAuthenticated[];
2053 debug(F110,"szUserNameAuthenticated",
2054 szUserNameAuthenticated,0);
2055 if (zvpass(szUserNameAuthenticated) == 0) {
2056 /* Anonymous login failed. Force a username prompt. */
2061 if ((ssl_active_flag || tls_active_flag) &&
2062 (!TELOPT_U(TELOPT_AUTHENTICATION) ||
2063 ck_tn_authenticated() == AUTHTYPE_NULL ||
2064 ck_tn_authenticated() == AUTHTYPE_AUTO)) {
2065 printf("Authenticated using X.509 certificate\r\n");
2067 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2068 extern char szUserNameAuthenticated[];
2069 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2070 "X.509 certificate",
2071 szUserNameAuthenticated
2074 #endif /* CKSYSLOG */
2078 printf("Authenticated using %s\r\n",
2079 AUTHTYPE_NAME(ck_tn_authenticated())
2082 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2083 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2084 AUTHTYPE_NAME(ck_tn_authenticated()),
2085 szUserNameAuthenticated
2088 #endif /* CKSYSLOG */
2093 if (ckxsyslog >= SYSLG_LI && ckxlogging &&
2094 x_logged == AUTH_USER) {
2095 extern char szUserNameAuthenticated[];
2096 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2097 AUTHTYPE_NAME(ck_tn_authenticated()),
2098 szUserNameAuthenticated
2101 #endif /* CKSYSLOG */
2103 if (!strcmp("(unknown)",uidbuf)
2105 || !stricmp("administrator",uidbuf)
2107 || !strcmp("root",uidbuf)
2110 || !strcmp("root",uidbuf)
2113 || !strcmp("root",uidbuf)
2122 #endif /* CK_AUTHENTICATION */
2123 #endif /* CK_LOGIN */
2127 printf("\r\nInternet Kermit Service ready at %s%s\r\n",s,versio);
2130 printf("\r\nC-Kermit ready at %s%s\r\n",s,versio);
2132 printf("%s\r\n", myhost);
2139 extern int arg_x; /* Flag for '-x' on command line */
2141 extern struct mtab *mactab; /* For ON_LOGIN macro. */
2145 debug(F110,"MAIN clienthost",clienthost,0);
2146 srvidl = timelimit = logintimo; /* For interactive login */
2147 rtimer(); /* Reset timer */
2148 for (i = 0; i < iks_retry && !x_logged; i++) { /* Count retries */
2149 if (gtimer() > logintimo)
2152 tn_wait("login loop");
2155 debug(F101,"MAIN LOGIN try","",i);
2156 what = W_NOTHING; /* Because proto() changes this */
2159 debug(F111,"MAIN LOGIN",
2160 "TELOPT_SB(TELOPT_KERMIT).kermit.me_start",
2161 TELOPT_SB(TELOPT_KERMIT).kermit.me_start
2163 /* Kermit server negotiated */
2164 if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {
2165 debug(F101,"IKSD starting in server mode","",0);
2166 arg_x = 1; /* Enter server mode */
2169 justone = 1; /* Execute one command at a time. */
2170 #endif /* IKSDPOPBACK */
2171 proto(); /* Enter protocol if requested. */
2175 if (x_logged) /* Logged in */
2177 } else { /* Not in client/server mode */
2178 #endif /* IKS_OPTION */
2179 debug(F101,"IKSD starting with Username prompt","",0);
2180 x_logged = ckxlogin((CHAR *)uidbuf,NULL,NULL,1);
2181 if (sstate) { /* Received a packet at prompt */
2183 justone = 1; /* Go handle it */
2184 #endif /* IKSDPOPBACK */
2187 if (!x_logged) { /* In case we are at the prompt... */
2188 printf("Access denied.\n");
2189 uidbuf[0] = '\0'; /* Forget the name if we have one */
2193 #endif /* IKS_OPTION */
2195 srvidl = timelimit = iks_timo; /* Reset command timelimit */
2196 debug(F101,"MAIN LOGIN","",x_logged);
2197 if (!x_logged) { /* Logins failed. */
2198 if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
2199 errpkt((CHAR *)"Login Timeout");
2203 what = W_NOTHING; /* Stay in known state */
2206 en_pri = 0; /* No printing for anonymous users */
2207 en_mai = 0; /* No email for anonymous users */
2208 en_mkd = 0; /* Or directory creation */
2209 en_rmd = 0; /* Or directory removal */
2210 en_ena = 0; /* Or ENABLing DISABLEd items */
2212 #endif /* NOSERVER */
2216 If a macro named "on_login" is defined, execute it. Also remove it from the
2217 macro table so the user cannot see what it does. Execute it as part of the
2220 if (nmac) { /* Any macros defined? */
2222 char * cmd = "on_login"; /* MSVC 2.x compiler error */
2223 k = mlook(mactab,cmd,nmac); /* Look up "on_login" */
2224 if (k >= 0) { /* If found, */
2228 #endif /* IKSDCONF */
2229 if (dodo(k,"",0) > -1) /* set it up, */
2230 parser(1); /* execute it */
2233 #endif /* IKSDCONF */
2234 delmac(cmd,1); /* and delete it */
2238 } /* if (inserver) */
2239 #else /* CK_LOGIN */
2241 srvidl = timelimit = iks_timo; /* Set idle limits for IKS */
2242 #endif /* CK_LOGIN */
2248 failcmdline(void * foo)
2249 #else /* CK_ANSIC */
2250 failcmdline(foo) VOID * foo;
2251 #endif /* CK_ANSIC */
2257 if (cnflg) doconect(0,0); /* connect again if requested. */
2260 #endif /* NOLOCAL */
2267 dotakeini(void * threadinfo) /* Execute init file. */
2268 #else /* CK_ANSIC */
2269 dotakeini(threadinfo) VOID * threadinfo; /* Execute init file. */
2270 #endif /* CK_ANSIC */
2274 if (threadinfo) { /* Thread local storage... */
2275 TlsSetValue(TlsIndex,threadinfo);
2276 debug(F100, "dotakeini called with threadinfo block","", 0);
2278 debug(F100, "dotakeini - threadinfo is NULL", "", 0);
2287 #endif /* CK_LOGIN */
2288 cmdini(); /* Sets tlevel */
2290 debug(F111,"dotakeini","inserver",inserver);
2291 debug(F111,"dotakeini","sstelnet",sstelnet);
2294 /* Wrong place for this... */
2297 dofast(); /* By now FAST defaults should be OK */
2298 #endif /* CK_FAST */
2300 #endif /* COMMENT */
2302 doinit(); /* Now do the initialization file */
2303 debug(F101,"main executing init file","",tlevel);
2304 while (tlevel > -1) {
2305 sstate = (CHAR) parser(1); /* Execute one command at a time. */
2306 if (sstate) proto(); /* Enter protocol if requested. */
2311 debug(F101,"main exits init file","",tlevel);
2314 ckThreadEnd(threadinfo);
2321 failtakeini(void * threadinfo)
2322 #else /* CK_ANSIC */
2323 failtakeini(threadinfo) VOID * threadinfo;
2324 #endif /* CK_ANSIC */
2327 cc_clean(); /* Atari: Clean up after ^C-trap. */
2331 conoll("Interrupted during initialization or \
2332 command-line processing.");
2333 conoll("C-Kermit quitting...");
2335 doexit(BAD_EXIT,-1); /* Exit with bad status. */
2340 doicp(void * threadinfo)
2341 #else /* CK_ANSIC */
2342 doicp(threadinfo) VOID * threadinfo;
2343 #endif /* CK_ANSIC */
2347 if (threadinfo) { /* Thread local storage... */
2348 if (!TlsSetValue(TlsIndex,threadinfo))
2349 debug(F101,"doicp TlsSetValue failed","",GetLastError());
2350 debug(F101, "doicp a threadinfo block - TlsIndex", "", TlsIndex);
2352 debug(F100, "doicp received a null threadinfo", "", 0);
2362 #endif /* CK_LOGIN */
2365 extern char *lfiles; /* Fake pointer cast */
2368 debug(F100, "doicp: calling macparser", "", 0);
2369 sstate = newparser(1, 1, 0L);
2371 /* ignore null command state */
2379 * process take files the finder gave us.
2381 if ((tlevel == -1) && lfiles)
2384 debug(F100, "doicp: calling parser", "", 0);
2385 sstate = (CHAR) parser(0);
2386 if (sstate == 'c') /* if MAC connect */
2396 If interactive commands were given on the command line (using the
2397 -C "command, command, ..." option), assign them to a macro called
2398 "cl_commands", then execute the macro and leave it defined for
2399 subsequent re-execution if desired.
2401 if (clcmds) { /* Check for -C commands */
2403 x = addmac("cl_commands",clcmds); /* Put macro in table */
2404 if (x > -1) { /* If successful, */
2405 dodo(x,NULL,CF_CMDL); /* set up for macro execution */
2406 while (maclvl > -1) { /* Loop getting macro commands. */
2407 sstate = (CHAR) parser(1);
2408 if (sstate) proto(); /* Enter protocol if requested. */
2414 debug(F100,"doicp calling herald","",0);
2418 while(1) { /* Loop getting commands. */
2419 sstate = (CHAR) parser(0);
2420 if (sstate) proto(); /* Enter protocol if requested. */
2426 ckThreadEnd(threadinfo);
2433 failicp(void * threadinfo)
2434 #else /* CK_ANSIC */
2435 failicp(threadinfo) VOID * threadinfo;
2436 #endif /* CK_ANSIC */
2441 fixcmd(); /* Pop command stacks, etc. */
2443 debug(F100,"ckcmai got interrupt","",0);
2450 docmdfile(void * threadinfo) /* Execute application file */
2451 #else /* CK_ANSIC */
2452 docmdfile(threadinfo) VOID * threadinfo;
2453 #endif /* CK_ANSIC */
2456 concb((char)escape);
2458 if (threadinfo) { /* Thread local storage... */
2459 TlsSetValue(TlsIndex,threadinfo);
2460 debug(F100, "docmdfile called with threadinfo block","", 0);
2461 } else debug(F100, "docmdfile - threadinfo is NULL", "", 0);
2470 #endif /* CK_LOGIN */
2471 debug(F110,"main cmdfil",cmdfil,0);
2473 addmac("\\%0",cmdfil);
2475 dotake(cmdfil); /* Set up the command file */
2476 if (tlevel > -1) /* Remember we did this */
2478 while (tlevel > -1) { /* Execute it until it runs out. */
2479 sstate = parser(1); /* Loop getting commands. */
2480 if (sstate) proto(); /* Enter protocol if requested. */
2487 ckThreadEnd(threadinfo);
2494 failcmdfile(void * threadinfo)
2495 #else /* CK_ANSIC */
2496 failcmdfile(threadinfo) VOID * threadinfo;
2497 #endif /* CK_ANSIC */
2500 cc_clean(); /* Atari: Clean up after ^C-trap. */
2504 conoll("Interrupted during initialization or \
2505 command-line processing.");
2506 conoll("C-Kermit quitting...");
2508 doexit(BAD_EXIT,-1); /* Exit with bad status. */
2514 setprefix(z) int z; { /* Initial control-char prefixing */
2519 ptab[protocol].prefix = prefixing;
2520 debug(F101,"setprefix","",prefixing);
2522 case PX_ALL: /* All */
2524 /* Don't let Clear-Channel be dependent on prefixing */
2525 clearrq = 0; /* Turn off clearchannel, fall thru */
2526 #endif /* COMMENT */
2527 case PX_NON: /* None */
2528 val = (z == PX_ALL) ? 1 : 0;
2534 #endif /* UNPREFIXZERO */
2537 for (i = 127; i < 160; i++) ctlp[i] = val;
2538 ctlp[(unsigned)255] = val;
2539 if (z == PX_NON) { /* These are never safe */
2540 if (network) { /* Assume network = telnet or rlogin */
2541 ctlp[CR] = 1; /* Prefix CR because of NVT rules */
2542 ctlp[XON] = ctlp[XOFF] = 1; /* Because of Telnet server */
2543 ctlp[127] = ctlp[255] = 1; /* Telnet IAC */
2544 ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit packet start */
2546 ctlp[CR] = ctlp[255] = ctlp[mystch] = ctlp[mystch+128] = 1;
2547 if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
2548 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
2553 case PX_CAU: /* Cautious or Minimal */
2555 /* Don't let CLEAR-CHANNEL be dependent on Prefixing */
2556 clearrq = 0; /* Turn off clearchannel */
2557 #endif /* COMMENT */
2558 case PX_WIL: /* Minimal ("wild") */
2559 ctlp[0] = 1; /* Does not include 0 */
2560 for (i = 1; i < 32; i++)
2562 for (i = 127; i < 160; i++)
2564 ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit start of packet */
2566 ctlp[seol] = ctlp[seol+128] = 1; /* Kermit end */
2567 ctlp[13] = ctlp[141] = 1; /* In case of TELNET (NVT rules) */
2568 ctlp[(unsigned)255] = 1; /* Ditto */
2570 /* ^D, ^J, ^M, or ^U followed by tilde trigger Rlogin escape */
2572 ctlp[4] = ctlp[4+128] = 1; /* In case of RLOGIN */
2573 ctlp[10] = ctlp[10+128] = 1; /* In case of RLOGIN */
2574 ctlp[21] = ctlp[21+128] = 1; /* In case of RLOGIN */
2576 if (flow == FLO_XONX || /* Xon/Xoff forces prefixing these */
2577 prefixing == PX_CAU || /* So does CAUTIOUS */
2578 network) /* Networks too... */
2579 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
2580 if (prefixing == PX_CAU) { /* Cautious - add some more */
2583 #endif /* UNPREFIXZERO */
2584 ctlp[3] = ctlp[16] = 1; /* ^C, DLE */
2585 ctlp[14] = ctlp[15] = 1; /* SO/SI */
2586 ctlp[24] = ctlp[25] = 1; /* VMS might need these */
2587 ctlp[26] = ctlp[26+128] = 1; /* UNIX suspend */
2588 ctlp[28] = ctlp[29] = ctlp[30] = 1; /* Assorted esc chars */
2589 ctlp[131] = ctlp[141] = ctlp[144] = 1; /* and 8-bit versions */
2590 ctlp[(unsigned)255] = ctlp[156] = ctlp[157] = ctlp[158] = 1;
2594 #endif /* CK_SPEED */
2599 makever() { /* Make version string from pieces */
2604 ck_s_xver = ck_s_ver; /* Fill in C-Kermit version number */
2605 ck_l_xver = ck_l_ver; /* for UNIX, VMS, etc. */
2608 x = strlen(ck_s_name);
2609 y = strlen(ck_s_xver);
2610 if (y + x + 1 < CKVERLEN) {
2611 ckmakmsg(versio,CKVERLEN,ck_s_name," ",ck_s_xver,NULL);
2613 ckstrncpy(versio,"C-Kermit",CKVERLEN);
2618 s = " OPEN SOURCE:"; /* C-Kermit 9.0 and later */
2620 if (CKVERLEN < x + y + 1)
2622 ckstrncat(versio,s,CKVERLEN);
2626 y = strlen(ck_s_who);
2627 if (CKVERLEN < x + y + 1)
2629 ckstrncat(versio,"-",CKVERLEN);
2630 ckstrncat(versio,ck_s_who,CKVERLEN);
2633 y = strlen(ck_s_test);
2634 if (y > 0 && y + x + 1 < CKVERLEN) {
2635 ckstrncat(versio," ",CKVERLEN);
2636 ckstrncat(versio,ck_s_test,CKVERLEN);
2638 y = strlen(ck_s_tver);
2639 if (y > 0 && y + x + 1 < CKVERLEN) {
2640 ckstrncat(versio,".",CKVERLEN);
2641 ckstrncat(versio,ck_s_tver,CKVERLEN);
2645 y = strlen(ck_s_date);
2646 if (y > 0 && y + x + 2 < CKVERLEN) {
2647 ckstrncat(versio,", ",CKVERLEN);
2648 ckstrncat(versio,ck_s_date,CKVERLEN);
2651 xvernum = ck_l_xver;
2652 debug(F110,"Kermit version",versio,0);
2655 union ck_short shortbytes; /* For determining byte order */
2656 int byteorder = 0; /* 0 = Big Endian; 1 = Little Endian */
2658 /* NOTE: MUST BE 0 or 1 - nothing else */
2661 #define SCRIPTLEN 10240
2671 extern int ttnproto;
2672 extern struct urldata g_url;
2675 /* NOTE: debug() doesn't work yet - must use printf's */
2676 printf("URL: %s\n",g_url.sav ? g_url.sav : "(none)");
2677 printf("Type: %s\n",g_url.svc ? g_url.svc : "(none)");
2678 printf("User: %s\n",g_url.usr ? g_url.usr : "(none)");
2679 printf("Pass: %s\n",g_url.psw ? g_url.psw : "(none)");
2680 printf("Host: %s\n",g_url.hos ? g_url.hos : "(none)");
2681 /* printf("Port: %s\n",g_url.por ? g_url.por : "(none)"); */
2682 printf("Path: %s\n",g_url.pth ? g_url.pth : "(none)");
2683 #endif /* COMMENT */
2685 if (!ckstrcmp(g_url.svc,"iksd",-1,0) ||
2686 !ckstrcmp(g_url.svc,"kermit",-1,0)) {
2687 extern char pwbuf[];
2694 printf("?Incomplete IKSD URL\n");
2698 makestr(&g_url.usr,"anonymous");
2700 char * tmpbuf = NULL;
2701 if (!(tmpbuf = (char *)malloc(1024)))
2702 fatal("dourl: out of memory");
2703 if (!ckstrcmp(g_url.usr,"anonymous",-1,0)) {
2704 ckmakmsg(tmpbuf,1024,uidbuf,"@",myhost,NULL);
2705 makestr(&g_url.psw,tmpbuf);
2707 readpass(" Password:",tmpbuf,1024);
2708 makestr(&g_url.psw,tmpbuf);
2713 ttnproto = NP_TELNET;
2717 ckstrncpy(uidbuf,g_url.usr,UIDBUFLEN);
2719 ckstrncpy(pwbuf,g_url.psw,PWBUFL);
2729 g_url.por ? g_url.por : port,
2732 rc = ttopen(ttname,&local,mdmtyp,0);
2738 #endif /* CKLOGDIAL */
2740 printf("?Connection failed: %s\n",g_url.sav);
2743 /* Also need to check here for secure authentication already done */
2749 char * script = NULL;
2750 if (!(script = (char *)malloc(SCRIPTLEN)))
2751 fatal("dourl: out of memory");
2752 if (!g_url.pth) { /* Write the appropriate script */
2754 ckmakxmsg(script,SCRIPTLEN,
2755 "if not eq {\\v(authstate)} {user} ",
2756 "if not eq {\\v(authstate)} {valid} { ",
2757 "remote login ", /* No path */
2758 g_url.usr, /* Just log in and CONNECT */
2761 ", if fail exit 1 {IKSD login failed} }",
2763 NULL,NULL,NULL,NULL);
2764 /* printf("CLCMDS 1: %s\n",script); */
2766 /* does the path specify a file or a directory? */
2767 int len = strlen(g_url.pth);
2768 if (ISDIRSEP(g_url.pth[len-1])) {
2769 ckmakxmsg(script,SCRIPTLEN, /* Directory name given */
2770 "if not eq {\\v(authstate)} {user} \
2771 if not eq {\\v(authstate)} {valid} { remote login ",
2775 ", if fail exit 1 {IKSD login failed} }",
2776 ", set macro error on",
2777 ", set xfer displ brief",
2778 ", set xfer bell off",
2781 ", lineout directory",
2784 /* printf("CLCMDS 2: %s\n",script); */
2786 ckmakxmsg(script,SCRIPTLEN, /* Path given, try to GET */
2787 "if not eq {\\v(authstate)} {user} \
2788 if not eq {\\v(authstate)} {valid} { remote login ",
2792 ", if fail exit 1 {IKSD login failed} }",
2793 ", set xfer displ brief",
2794 ", set xfer bell off",
2797 ", .rc := \\v(status)",
2798 ", if open connection bye",
2801 /* printf("CLCMDS 2: %s\n",script); */
2804 clcmds = script; /* Make this our -C cmdline macro */
2805 /* printf("HAVEURL=%d\n",haveurl); */
2809 if (ckstrcmp(g_url.svc,"telnet",-1,0) &&
2811 ckstrcmp(g_url.svc,"ssh",-1,0) &&
2812 #endif /* SSHBUILTIN */
2813 ckstrcmp(g_url.svc,"ftp",-1,0)) {
2814 printf("?Sorry, %s URLs not supported\n",
2815 g_url.svc ? g_url.svc : "");
2821 #endif /* NETCONN */
2827 If you get complaints about "main: return type is not blah",
2828 define MAINTYPE on the CC command line, e.g. "CFLAGS=-DMAINTYPE=blah"
2829 (where "blah" is int, long, or whatever).
2831 If the complaint is "Attempt to return a value from a function of type void"
2832 then add -DMAINISVOID.
2836 #define MAINTYPE int
2837 #endif /* MAINISVOID */
2838 #endif /* MAINTYPE */
2842 #define MAINTYPE void
2843 #endif /* MAINTYPE */
2844 #endif /* MAINISVOID */
2847 /* On the Apollo, intercept main to insert a cleanup handler */
2849 ckcmai(argc,argv) int argc; char **argv;
2851 #ifdef MAC /* Macintosh */
2855 #ifdef __GNUC__ /* GCC compiler */
2857 main(argc,argv) int argc; char **argv;
2859 #ifdef __DECC /* DEC Alpha with DEC C compiler */
2862 main(argc,argv) int argc; char **argv;
2863 #else /* DEC C compiler, not Alpha */
2866 main(argc,argv) int argc; char **argv;
2867 #endif /* __ALPHA */
2869 #ifdef STRATUS /* Stratus VOS */
2871 main(argc,argv) int argc; char **argv;
2877 Main( int argc, char ** argv )
2881 main(argc,argv) int argc; char **argv;
2884 MAINTYPE /* All others... */
2885 main(argc,argv) int argc; char **argv;
2887 #endif /* STRATUS */
2889 #endif /* __GNUC__ */
2899 #endif /* NOSETKEY */
2902 short *pfha = 016000000036; /* Get around LANG_RT problem */
2903 *pfha = (short) 0; /* No user protection fault handler */
2904 #endif /* datageneral */
2906 int unbuf = 0; /* nonzero for unbuffered stdout */
2908 /* setbuf has to be called on the file descriptor before it is used */
2911 #ifdef NONOSETBUF /* Unbuffered console i/o */
2912 unbuf++; /* as a compile-time option */
2913 #endif /* NONOSETBUF */
2914 if (!unbuf) { /* Or as a command-line selection */
2915 int i, n; /* We have to pre-pre-scan for */
2916 char * s; /* this one. */
2917 for (i = 1; i < argc; i++) {
2919 if (!s) n = 0; else n = (int)strlen(s);
2921 if (!ckstrcmp("--unbuffered",s,n,0)) {
2929 setbuf(stdout,NULL);
2932 /* Do some initialization */
2936 /* Get some RMS default settings. */
2938 #endif /* def __DECC */
2939 #endif /* def VMS */
2942 xargc = xargs = argc; /* Make global copies of argc */
2943 xargv = argv; /* ...and argv. */
2948 zstrip(argv[0],&p); /* Get name we were invoked with */
2950 if (!ckstrcmp(myname,"telnet",-1,0)) howcalled = I_AM_TELNET;
2952 else if (!ckstrcmp(myname,"ktelnet",-1,0)) howcalled = I_AM_TELNET;
2953 #endif /* CK_KERBEROS */
2954 else if (!ckstrcmp(myname,"rlogin",-1,0)) howcalled = I_AM_RLOGIN;
2955 else if (!ckstrcmp(myname,"iksd",-1,0)) howcalled = I_AM_IKSD;
2957 else if (!ckstrcmp(myname,"ftp",-1,0)) howcalled = I_AM_FTP;
2960 else if (!ckstrcmp(myname,"http",-1,0)) howcalled = I_AM_HTTP;
2963 else if (!ckstrcmp(myname,"telnet.exe",-1,0)) howcalled = I_AM_TELNET;
2965 else if (!ckstrcmp(myname,"ssh",-1,0)) howcalled = I_AM_SSH;
2966 else if (!ckstrcmp(myname,"ssh.exe",-1,0)) howcalled = I_AM_SSH;
2967 #endif /* SSHBUILTIN */
2969 else if (!ckstrcmp(myname,"ktelnet.exe",-1,0)) howcalled = I_AM_TELNET;
2970 #endif /* CK_KERBEROS */
2971 else if (!ckstrcmp(myname,"rlogin.exe",-1,0)) howcalled = I_AM_RLOGIN;
2973 else if (!ckstrcmp(myname,"iksdnt",-1,0)) howcalled = I_AM_IKSD;
2974 else if (!ckstrcmp(myname,"iksdnt.exe",-1,0)) howcalled = I_AM_IKSD;
2977 else if (!ckstrcmp(myname,"ftp.exe",-1,0)) howcalled = I_AM_FTP;
2980 else if (!ckstrcmp(myname,"http.exe",-1,0)) howcalled = I_AM_HTTP;
2983 else if (!ckstrcmp(myname,"kermit-sshsub",-1,0)) howcalled = I_AM_SSHSUB;
2986 cmdini(); /* Must come before prescan */
2987 debug(F100,"main cmdini() done","",0);
2989 prescan(0); /* Pre-Check for debugging, etc */
2991 debug(F101,"MAIN feol","",feol);
2992 makever(); /* Put together version strings */
2993 #ifndef NOSETKEY /* Allocate & initialize the keymap */
2994 /* This code has been moved to before sysinit() for K95G */
2995 if (!(keymap = (KEY *) malloc(sizeof(KEY)*KMSIZE)))
2996 fatal("main: no memory for keymap");
2997 if (!(macrotab = (MACRO *) malloc(sizeof(MACRO)*KMSIZE)))
2998 fatal("main: no memory for macrotab");
2999 for (i = 0; i < KMSIZE; i++) {
3000 keymap[i] = (KEY) i;
3003 #endif /* NOSETKEY */
3005 shortbytes.x_short = 0xABCD; /* Get Endianness */
3006 if (shortbytes.x_char[0] == 0xCD) { /* 0 = Big Endian */
3007 byteorder = 1; /* 1 = Little Endian */
3008 bigendian = 0; /* (for clarity in programming) */
3010 byteorder = 0; /* Big Endian */
3013 if (sizeof(CK_OFF_T) == 8) /* Large files and ints? */
3016 if (sysinit() < 0) /* System-dependent initialization. */
3017 fatal("Can't initialize!");
3019 initflg = 1; /* Remember we did. */
3020 debug(F111,"ckcmai myname",myname,howcalled);
3023 getexedir(); /* Compute exedir variable */
3029 If built with -DSYSLOGLEVEL on cc command line, this means we always
3030 do syslogging at the indicated level.
3032 zsyslog(); /* Open syslog */
3033 #else /* SYSLOGLEVEL */
3036 zsyslog(); /* Open syslog */
3038 #endif /* SYSLOGLEVEL */
3039 #endif /* CKSYSLOG */
3042 ini_kerb(); /* Initialize Kerberos data */
3043 #endif /* CK_KERBEROS */
3048 tn_set_modes(); /* Init Telnet Option tables */
3051 #ifdef CK_TTGWSIZ /* Initialize screen dimensions */
3055 if (ttgwsiz() > 0) {
3056 if (tt_rows > 0 && tt_cols > 0) {
3062 #endif /* CK_TTGWSIZ */
3067 SOCKSinit(argv[0]); /* Internet relay package... */
3068 #endif /* CK_SOCKS */
3069 #endif /* TCPSOCKET */
3072 initflow(); /* Initialize flow-control table */
3076 initfloat(); /* Deduce floating-point precision */
3077 #endif /* CKFLOAT */
3081 initxlist(); /* Init exception lists */
3083 #ifdef CK_XYZ /* Initialize protocols... */
3085 #ifdef XYZ_INTERNAL /* XYZMODEM are internal ... */
3088 /* Can't do this for XMODEM because if filename contains a "C" etc... */
3089 initproto(PROTO_X, "rx %s","rx %s", NULL, NULL, NULL, NULL, NULL);
3090 initproto(PROTO_XC,"rc %s","rc %s", NULL, NULL, NULL, NULL, NULL);
3092 initproto(PROTO_X, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3093 initproto(PROTO_XC,NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3094 #endif /* COMMENT */
3095 initproto(PROTO_Y, "rb","rb", NULL, NULL, NULL, NULL, NULL);
3096 initproto(PROTO_G, "rb","rb", NULL, NULL, NULL, NULL, NULL);
3097 initproto(PROTO_Z, "rz","rz", NULL, NULL, NULL, NULL, NULL);
3098 initproto(PROTO_K,"kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3099 /* Kermit Must be last */
3101 #else /* XYZMODEM are external protocols ... */
3103 /* s1 s2 s3 s4 s5 s6 s7 */
3104 initproto(PROTO_X, "rx %s","rx %s",NULL,"sx %s","sx -a %s","rx %s", "rx %s");
3105 initproto(PROTO_XC,"rc %s","rc %s",NULL,"sx %s","sx -a %s","rc %s", "rc %s");
3106 initproto(PROTO_Y, "rb", "rb", NULL,"sb %s","sb -a %s","rb", "rb" );
3107 initproto(PROTO_G, "rb", "rb", NULL,"sb %s","sb -a %s","rb", "rb" );
3108 initproto(PROTO_Z, "rz", "rz", NULL,"sz %s","sz -a %s","rz", "rz" );
3109 initproto(PROTO_K, "kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3110 /* Kermit must be last */
3112 #endif /* XYZ_INTERNAL */
3114 #else /* No XYZMODEM support */
3116 initproto(PROTO_K,"kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3121 connoi(); /* Console interrupts off */
3125 /* Initialize Kermit and Zmodem Auto-Download Strings */
3126 adl_kstr = strdup("KERMIT READY TO SEND...");
3127 adl_zstr = strdup("rz\r");
3131 initpat(); /* Initialize filename patterns */
3132 #endif /* PATTERNS */
3136 initcsets(); /* Initialize character sets */
3137 #endif /* NOCSETS */
3141 makestr(&cdmsgstr,DFCDMSG);
3142 makelist(cdmsgstr,cdmsgfile,8); /* Initialize CD message filenames */
3143 #endif /* DFCDMSG */
3146 sstate = 0; /* No default start state. */
3149 fatal("Can't allocate i/o buffers!");
3150 #endif /* DYNAMIC */
3155 char stackdata[256];
3156 unsigned int c = 1234, n;
3157 /* try to make a random unsigned int to feed srand() */
3159 /* time.h and MultiNet do not get along */
3163 /* Referenced before set... DELIBERATELY */
3164 for (n = 0; n < sizeof(stackdata); n++) /* IGNORE WARNING */
3165 c += stackdata[n]; /* DELIBERATELY USED BEFORE SET */
3166 srand((unsigned int)c);
3168 #endif /* NORANDOM */
3171 ckhost(myhost,MYHOSTL); /* Name of local host */
3172 debug(F110,"main ckhost",myhost,0);
3176 ckstrncpy(ttname,dftty,TTNAMLEN); /* Set up default tty name. */
3177 local = nolocal ? 0 : dfloc; /* And whether it's local or remote. */
3178 parity = dfprty; /* Set initial parity, */
3180 myindex = getsysix(cksysid); /* System index */
3182 if (local) if (ttopen(ttname,&local,0,0) < 0) {
3184 conol("Can't open device: ");
3188 ckstrncpy(ttname,CTTNAM,TTNAMLEN);
3190 setflow(); /* Set appropriate flow control */
3191 speed = ttgspd(); /* Get transmission speed. */
3196 #ifdef ANYX25 /* All X.25 implementations */
3197 #ifndef IBMX25 /* except IBM have PAD support */
3198 initpad(); /* Initialize X.25 PAD */
3203 if (inibufs(SBSIZ,RBSIZ) < 0) /* Allocate packet buffers */
3204 fatal("Can't allocate packet buffers!");
3206 setprefix(prefixing); /* Set up control char prefixing */
3207 #endif /* NOCKSPEED */
3217 extern int ckxech, ttnet, ttnproto, cmdmsk;
3219 extern int tcp_sendbuf;
3222 extern int tcp_recvbuf;
3225 extern int tcp_keepalive;
3228 extern int tcp_linger, tcp_linger_tmo;
3229 #endif /* SO_LINGER */
3231 extern int tcp_dontroute;
3232 #endif /* SO_DONTROUTE */
3234 extern int tcp_nodelay;
3235 #endif /* TCP_NODELAY */
3237 extern int iklogopen;
3243 fatal("Internet Kermit Service cannot be started at a terminal.");
3246 reliable = xreliable = SET_ON; /* IKSD has reliable connection */
3248 flow = 0; /* No flow control needed */
3250 bgset = 0; /* Not in background */
3251 nopush = 1; /* No external processes */
3252 parity = 0; /* 8 bits ... */
3253 cmdmsk = 0xff; /* all the way */
3257 if (inserver) { /* If IKSD */
3258 doiksdinit(); /* Execute IKSD configuration file */
3260 parser(1); /* (Ignore any file-xfer commands) */
3261 iksdcf = 1; /* IKSD c.f. has been processed */
3263 if (!iklogopen) (VOID) doiklog(); /* Open Kermit-specific log */
3267 setbuf(stdout,NULL); /* Don't buffer the output */
3268 ckstrncpy(ttname,"0",TTNAMLEN); /* not "/dev/tty"... */
3270 local = 0; /* We are in remote mode */
3271 ckxech = 1; /* We will echo */
3273 nettype = NET_TCPB; /* So ttopen() treats the connection */
3274 mdmtyp = -nettype; /* as a network */
3276 debug(F100,"main about to call ttopen() inserver","",0);
3277 if (ttopen(ttname,&local,mdmtyp,0) < 0) { /* Open comm channel */
3278 fatal("can't initialize i/o");
3282 network = 1; /* Does use networking code */
3284 network = 0; /* Does not use networking code */
3286 ttmdm = -1; /* Does not use a modem */
3287 sstelnet = 1; /* Do server-side Telnet negotations */
3288 debug(F111,"MAIN","sstelnet",sstelnet);
3289 ttnet = NET_TCPB; /* Network type is TCP sockets */
3290 ttnproto = NP_TELNET; /* Netword protocol is Telnet */
3292 dbinit(); /* Initialize database record */
3295 #ifdef CK_AUTHENTICATION
3296 /* Before initializating Telnet/Rlogin negotiations, init Kerberos */
3297 ck_auth_init(ckgetpeer(),"","",0);
3298 #endif /* CK_AUTHENTICATION */
3302 x = socket_ioctl(0,FIONBIO,&on);
3303 debug(F101,"main FIONBIO","",x);
3304 #endif /* NON_BLOCK_IO */
3307 x = setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on));
3308 debug(F101,"main SO_OOBINLINE","",x);
3309 #endif /* SO_OOBINLINE */
3315 no_delay(0,tcp_nodelay);
3316 #endif /* TCP_NODELAY */
3318 keepalive(0,tcp_keepalive);
3319 #endif /* SO_KEEPALIVE */
3321 ck_linger(0,tcp_linger, tcp_linger_tmo);
3322 #endif /* SO_LINGER */
3324 dontroute(0,tcp_dontroute);
3325 #endif /* SO_DONTROUTE */
3327 sendbuf(0,tcp_sendbuf);
3328 #endif /* SO_SNDBUF */
3330 recvbuf(0,tcp_recvbuf);
3331 #endif /* SO_RCVBUF */
3332 #endif /* SOL_SOCKET */
3333 #endif /* datageneral */
3334 #endif /* NOTCPOPTS */
3337 if (ck_ssleay_is_installed()) {
3338 if (!ssl_tn_init(SSL_SERVER)) {
3339 if (bio_err != NULL) {
3340 BIO_printf(bio_err,"do_ssleay_init() failed\r\n");
3341 ERR_print_errors(bio_err);
3344 fprintf(stderr,"do_ssleay_init() failed\r\n");
3345 ERR_print_errors_fp(stderr);
3356 /* otherwise we will continue to accept the connection */
3357 /* without SSL or TLS support unless required. */
3358 if ( TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) != TN_NG_MU )
3359 TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = TN_NG_RF;
3360 if ( TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) != TN_NG_MU )
3361 TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = TN_NG_RF;
3362 if ( TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) != TN_NG_MU )
3363 TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = TN_NG_RF;
3364 if ( TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) != TN_NG_MU )
3365 TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = TN_NG_RF;
3367 if ( ck_ssl_incoming(0) < 0 ) {
3375 tn_ini(); /* Start Telnet negotiation now */
3379 debug(F101,"main argc after prescan()","",argc);
3381 /* Now process any relevant environment variables */
3384 getdialenv(); /* Dialing */
3386 ndinit(); /* Initialize network directory info */
3387 getnetenv(); /* Network directories */
3388 #endif /* NETCONN */
3393 dofast(); /* By now FAST defaults should be OK */
3394 #endif /* CK_FAST */
3398 ikslogin(); /* IKSD Login and other stuff */
3407 if (howcalled == I_AM_SSHSUB) {
3408 reliable = 1; /* We say the connection is reliable */
3409 xreliable = 1; /* And that we said it was */
3410 setreliable = 1; /* And pretend the "user" did too */
3411 xfinish = 1; /* For REMOTE HELP response */
3412 mdmtyp = 0; /* For ttopen() */
3413 ckstrncpy(ttname,"0",TTNAMLEN+1); /* Use file descriptor 0 */
3414 local = 0; /* And force remote mode */
3415 ttopen(ttname,&local,mdmtyp,0); /* Open the "connection" */
3416 sstate = 'x'; /* Initial state is Server */
3417 proto(); /* Enter protocol */
3418 doexit(GOOD_EXIT,xitsta); /* Exit when done */
3420 debug(F111,"howcalled",myname,howcalled);
3424 #else /* NOCCTRAP */
3425 debug(F100,"main about to cc_execute","",0);
3427 cc_execute( ckjaddr(cmjbuf), dotakeini, failtakeini );
3428 #endif /* NOCCTRAP */
3430 debug(F111,"main 2 cfilef",cmdfil,cfilef);
3431 if (cmdfil[0]) { /* If we got one (see prescan())... */
3433 docmdfile(0); /* execute it. */
3434 #else /* NOCCTRAP */
3436 cc_execute( ckjaddr(cmjbuf), docmdfile, failcmdfile );
3437 #endif /* NOCCTRAP */
3439 #ifndef OS2 /* Preserve name so we can delete it */
3440 *cmdfil = '\0'; /* Done, nullify the file name */
3445 /* Look for a UNIX-style command line... */
3449 debug(F101,"main argc","",argc);
3451 iniopthlp(); /* Initialize cmdline arg help */
3456 #endif /* COMMENT */
3457 argc > 1) { /* Command line arguments? */
3458 sstate = (CHAR) cmdlin(); /* Yes, parse. */
3461 if (haveurl) { /* Was a URL given? */
3462 dourl(); /* if so, do it. */
3465 #endif /* NETCONN */
3467 zstate = sstate; /* Remember sstate around protocol */
3468 debug(F101,"main zstate","",zstate);
3472 if (cflg) { /* Connect first if requested */
3478 #endif /* NOLOCAL */
3483 if (displa) concb((char)escape); /* (for console "interrupts") */
3484 #endif /* NOLOCAL */
3487 #else /* NOCCTRAP */
3489 cc_execute( ckjaddr(cmjbuf), docmdline, failcmdline );
3490 #endif /* NOCCTRAP */
3496 If a command-line action argument was given and -S ("stay") was not given,
3499 if ((cflg || cnflg || zstate) && !stayflg)
3501 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3507 if ((cflg || cnflg) && tn_exit && ttchk() < 0)
3508 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3509 #endif /* NETCONN */
3510 if (exitonclose && !network &&
3511 (carrier != CAR_OFF && (ttgmdm() & BM_DCD) == 0))
3512 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3513 if (exitonclose && network && ttchk() < 0)
3514 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3517 #endif /* NOLOCAL */
3521 #ifdef NOICP /* No interactive command parser */
3525 /* Command-line-only version */
3526 fatal("?No command-line options given - type 'kermit -h' for help");
3528 #else /* Neither one! */
3531 proto(); /* So go into server mode */
3532 doexit(GOOD_EXIT,xitsta); /* exit with good status */
3535 #else /* not NOICP */
3537 If no action requested on command line, or if -S ("stay") was included,
3538 enter the interactive command parser.
3541 herald(); /* Display program herald. */
3544 debug(F100,"main NOCCTRAP setting interrupt trap","",0);
3545 setint(); /* Set up command interrupt traps */
3547 #else /* NOCCTRAP */
3549 debug(F100,"main setting interrupt trap","",0);
3550 setint(); /* Set up command interrupt traps */
3551 if (!cc_execute(ckjaddr(cmjbuf), doicp, failicp))
3554 #endif /* NOCCTRAP */
3558 #endif /* MAINISVOID */
3562 /* Allocate file i/o buffers */
3564 char *zinbuffer = NULL, *zoutbuffer = NULL;
3568 zinbuffer = (char *)malloc(INBUFSIZE);
3569 if (!zinbuffer) return(-1);
3570 zoutbuffer = (char *)malloc(zobufsize);
3571 debug(F101,"zoutbuffer malloc","",zobufsize);
3572 if (!zoutbuffer) return(-1);
3573 debug(F100,"getiobs ok","",0);
3576 #endif /* DYNAMIC */