1 #define EDITDATE "10 Apr 2004" /* Update these with each edit */
2 #define EDITNDATE "20040410" /* Keep them in sync */
3 /* Sat Apr 10 12:05:49 2004 */
6 ckcsym.h is used for for defining symbols that normally would be defined
7 using -D or -d on the cc command line, for use with compilers that don't
8 support this feature. Must be before any tests for preprocessor symbols.
12 Consolidated program version information (for UNIX also see ckuver.h).
13 See makever() below for how they are used.
15 /* #ifdef COMMENT */ /* Uncomment this for test version */
21 /* #endif */ /* COMMENT */
33 Note: initialize ck_s_test to "" if this is not a test version.
34 Use (*ck_s_test != '\0') to decide whether to print test-related messages.
37 #ifndef OS2 /* UNIX, VMS, etc... (i.e. C-Kermit) */
38 char *ck_s_test = ""; /* "Dev","Alpha","Beta","RC", or "" */
39 char *ck_s_tver = ""; /* Test version number or "" */
41 char *ck_s_test = ""; /* (i.e. K95) */
45 char *ck_s_test = ""; /* Development */
49 char *ck_s_test = "Pre-Alpha"; /* Mac Kermit is always a test... */
53 #ifdef BETADATE /* Date of this version or edit */
54 char *ck_s_date = __DATE__; /* Compilation date */
56 char *ck_s_date = EDITDATE; /* See top */
59 char *buildid = EDITNDATE; /* See top */
62 static char sccsid[] = "@(#)C-Kermit 8.0.211";
65 char *ck_s_ver = "8.0.211"; /* C-Kermit version string */
66 long ck_l_ver = 800211L; /* C-Kermit version number */
69 char *ck_s_xver = "2.2.0"; /* Product-specific version string */
70 long ck_l_xver = 2200L; /* Product-specific version number */
73 char *ck_s_xver = "0.995"; /* Product-specific version string */
74 long ck_l_xver = 995L; /* Product-specific version number */
76 char *ck_s_xver = ""; /* Don't touch these... */
77 long ck_l_xver = 0L; /* they are computed at runtime */
84 char *ck_s_name = "IKS-NT";
86 char *ck_s_name = "IKS-OS/2";
89 char *ck_s_name = "Kermit 95"; /* Program name */
93 char *ck_s_name = "Mac Kermit";
95 char *ck_s_name = "C-Kermit";
99 char *ck_s_who = ""; /* Where customized, "" = not. */
100 char *ck_patch = ""; /* Patch info, if any. */
103 char versiox[CKVERLEN]; /* Version string buffer */
104 char *versio = versiox; /* These are filled in at */
105 long vernum, xvernum; /* runtime from above. */
109 #include "ckcasc.h" /* ASCII character symbols */
110 #include "ckcdeb.h" /* Debug & other symbols */
112 char * myname = NULL; /* The name I am called by */
114 char * exedir = NULL; /* Directory I was executed from */
116 char * myhome = NULL; /* Home directory override */
118 /* C K C M A I -- C-Kermit Main program */
121 Author: Frank da Cruz (fdc@columbia.edu),
122 Columbia University Academic Information Systems, New York City.
129 "Windows Internet Kermit Service Daemon (WIKSD):",
130 "Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New",
131 "York. All rights reserved.",
135 " The WIKSD software may be obtained directly, in binary form only, from",
136 " the Kermit Project at Columbia University by any individual for his or",
137 " her OWN USE, and by any company or other organization for its own",
138 " INTERNAL DISTRIBUTION and use, including installation on servers that",
139 " are accessed by customers or clients, WITHOUT EXPLICIT LICENSE. All",
140 " other forms of redistribution must be licensed from the Kermit Project",
141 " at Columbia University. These permissions apply only to the nonsecure",
142 " version of WIKSD.",
146 " THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE",
147 " TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK AS TO ITS",
148 " FITNESS FOR ANY PURPOSE, AND WITHOUT WARRANTY BY THE TRUSTEES OF",
149 " COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK OF ANY KIND, EITHER",
150 " EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED",
151 " WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.",
152 " THE TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK SHALL NOT",
153 " BE LIABLE FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL,",
154 " OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OR IN",
155 " CONNECTION WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS",
156 " HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU SHALL",
157 " INDEMNIFY AND HOLD HARMLESS THE TRUSTEES OF COLUMBIA UNIVERSITY IN",
158 " THE CITY OF NEW YORK, ITS EMPLOYEES AND AGENTS FROM AND AGAINST ANY",
159 " AND ALL CLAIMS, DEMANDS, LOSS, DAMAGE OR EXPENSE (INCLUDING",
160 " ATTORNEYS' FEES) ARISING OUT OF YOUR USE OF THIS SOFTWARE.",
162 "The above copyright notice, permissions notice, and disclaimer may not be",
163 "removed, altered, or obscured and shall be included in all copies of the",
164 "WIKSD software. The Trustees of Columbia University in the City of",
165 "New York reserve the right to revoke this permission if any of the terms",
166 "of use set forth above are breached.",
168 "For further information, contact the Kermit Project, Columbia University,",
169 "612 West 115th Street, New York NY 10025-7799, USA; Phone +1 (212) 854 3703,",
170 "Fax +1 (212) 662 6442, kermit@columbia.edu, http://www.columbia.edu/kermit/",
175 char *copyright[] = {
178 "Copyright (C) 1985, 2004, Trustees of Columbia University, NYC.",
179 "All rights reserved.",
183 "Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New",
184 "York. All rights reserved. This software is furnished under license",
185 "and may not be reproduced without license to do so. This copyright notice",
186 "must not be removed, altered, or obscured.",
188 " THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE",
189 " TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK AS TO ITS",
190 " FITNESS FOR ANY PURPOSE, AND WITHOUT WARRANTY BY THE TRUSTEES OF",
191 " COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK OF ANY KIND, EITHER",
192 " EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED",
193 " WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.",
194 " THE TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK SHALL NOT",
195 " BE LIABLE FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL,",
196 " OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OR IN",
197 " CONNECTION WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS",
198 " HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU SHALL",
199 " INDEMNIFY AND HOLD HARMLESS THE TRUSTEES OF COLUMBIA UNIVERSITY IN",
200 " THE CITY OF NEW YORK, ITS EMPLOYEES AND AGENTS FROM AND AGAINST ANY",
201 " AND ALL CLAIMS, DEMANDS, LOSS, DAMAGE OR EXPENSE (INCLUDING",
202 " ATTORNEYS' FEES) ARISING OUT OF YOUR USE OF THIS SOFTWARE.",
205 "Copyright (C) 1985, 2004,",
206 " The Trustees of Columbia University in the City of New York.",
207 " All rights reserved.",
211 "The C-Kermit software may be obtained directly from the Kermit Project at",
212 "Columbia University (or from any source explicitly licensed by the Kermit",
213 "Project or implicitly licensed by Clause (A) below) by any individual for",
214 "his or her OWN USE, and by any company or other organization for its own",
215 "INTERNAL DISTRIBUTION and use, including installation on servers that are",
216 "accessed by customers or clients, WITHOUT EXPLICIT LICENSE.",
218 "Conditions for REDISTRIBUTION are as follows:",
220 "(A) The C-Kermit software, in source and/or binary form, may be",
221 " included WITHOUT EXPLICIT LICENSE in distributions of OPERATING",
222 " SYSTEMS that have OSI (Open Source Initiative, www.opensource.org)",
223 " approved licenses, even if non-Open-Source applications (but not",
224 " operating systems) are included in the same distribution. Such",
225 " distributions include, but are not limited to, CD-ROM, FTP site,",
226 " Web site, or preinstalled software on a new GENERAL-PURPOSE",
227 " computer, as long as the primary character of the distribution is",
228 " an Open Source operating system with accompanying utilities. The",
229 " C-Kermit source code may not be changed without the consent of the",
230 " Kermit Project, which will not be unreasonably withheld (this is",
231 " simply a matter of keeping a consistent and supportable code base).",
233 "(B) Inclusion of C-Kermit software in whole or in part, in any form, in",
234 " or with any product not covered by Clause (A), or its distribution",
235 " by any commercial enterprise to its actual or potential customers",
236 " or clients except as in Clause (A), requires a license from the",
237 " Kermit Project, Columbia University; contact kermit@columbia.edu.",
239 "The name of Columbia University may not be used to endorse or promote",
240 "products derived from or including the C-Kermit software without specific",
241 "prior written permission.",
245 " THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE",
246 " TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK AS TO ITS",
247 " FITNESS FOR ANY PURPOSE, AND WITHOUT WARRANTY BY THE TRUSTEES OF",
248 " COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK OF ANY KIND, EITHER",
249 " EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED",
250 " WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.",
251 " THE TRUSTEES OF COLUMBIA UNIVERSITY IN THE CITY OF NEW YORK SHALL NOT",
252 " BE LIABLE FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL,",
253 " OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR",
254 " IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS",
255 " HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU SHALL",
256 " INDEMNIFY AND HOLD HARMLESS THE TRUSTEES OF COLUMBIA UNIVERSITY IN",
257 " THE CITY OF NEW YORK, ITS EMPLOYEES AND AGENTS FROM AND AGAINST ANY",
258 " AND ALL CLAIMS, DEMANDS, LOSS, DAMAGE OR EXPENSE (INCLUDING",
259 " ATTORNEYS' FEES) ARISING OUT OF YOUR USE OF THIS SOFTWARE.",
261 "The above copyright notice, permissions notice, and disclaimer may not be",
262 "removed, altered, or obscured and shall be included in all copies of the",
263 "C-Kermit software. The Trustees of Columbia University in the City of",
264 "New York reserve the right to revoke this permission if any of the terms",
265 "of use set forth above are breached.",
270 "Portions Copyright (C) 1995, Oy Online Solutions Ltd., Jyvaskyla, Finland.",
273 #ifdef CK_AUTHENTICATION
274 "Portions Copyright (C) 1990, Massachusetts Institute of Technology.",
276 "Portions Copyright (C) 1991, 1993 Regents of the University of California.",
277 "Portions Copyright (C) 1991, 1992, 1993, 1994, 1995 by AT&T.",
278 "Portions Copyright (C) 1995, 1997, Eric Young <eay@cryptosoft.com>.",
279 #endif /* CK_ENCRYPTION */
281 "Portions Copyright (C) 1997, Stanford University.",
283 #endif /* CK_AUTHENTICATION */
287 "For further information, contact the Kermit Project, Columbia University,",
288 "612 West 115th Street, New York NY 10025-7799, USA; phone +1 (212) 854 3703,",
289 "fax +1 (212) 663 8202 or +1 (212) 662 6442, email kermit@columbia.edu,",
290 "Web http://www.columbia.edu/kermit/ or http://www.kermit-project.org/.",
297 "Using C-Kermit" by Frank da Cruz and Christine M. Gianone,
298 Digital Press / Butterworth-Heinemann, Woburn MA, USA.
299 Second edition (1997), ISBN 1-55558-164-1.
300 Order from Digital Press: +1 (800) 366-2665
301 Or from Columbia University: +1 (212) 854-3703
305 "Kermit 95" by Christine M. Gianone and Frank da Cruz,
306 Manning Publications, Greenwich CT, USA (1998) - Online.
310 The Kermit file transfer protocol was developed at the Columbia University
311 Center for Computing Activities (CUCCA), which was since renamed to Columbia
312 University Academic Information Systems (AcIS). Kermit is named after
313 Kermit the Frog, star of the television series THE MUPPET SHOW; the name is
314 used by permission of Henson Associates, Inc.
316 Thanks to at least the following people for their contributions to this
317 program over the years, and apologies to anyone who was inadvertantly
320 Chris Adie, Edinburgh U, Scotland (OS/2)
321 Robert Adsett, University of Waterloo, Canada
322 Larry Afrin, Clemson U
323 Russ Allbery, Stanford U
324 Jeffrey Altman, Columbia University
325 Greg Andrews, Telebit Corp
326 Barry Archer, U of Missouri
327 Robert Andersson, International Systems A/S, Oslo, Norway
328 Chris Armstrong, Brookhaven National Lab (OS/2)
329 William Bader, Software Consulting Services, Nazareth, PA
330 Fuat Baran, Columbia U
332 Jim Barbour, U of Colorado
333 Donn Baumgartner, Dell
334 Nelson Beebe, U of Utah
335 Gerry Belanger, Cognitronics
338 Dean W Bettinger, SUNY
340 Peter Binderup, Denmark
341 David Bolen, Advanced Networks and Services, Inc.
342 Marc Boucher, U of Montreal
346 Jack Bryans, California State U at Long Beach
348 Fernando Cabral, Padrao iX, Brasilia
349 Bjorn Carlsson, Stockholm University Computer Centre QZ, Sweden
350 Bill Catchings, (formerly of) Columbia U
351 Bob Cattani, Columbia U CS Dept
352 Davide Cervone, Rochester U
353 Seth Chaiklin, Denmark
354 John Chandler, Harvard U / Smithsonian Astronomical Observatory
356 Andrew A Chernov, RELCOM Team, Moscow
357 John L Chmielewski, AT&T, Lisle, IL
358 Howard Chu, U of Michigan
359 Bill Coalson, McDonnell Douglas
360 Bertie Coopersmith, London
361 Chet Creider, U of Western Ontario
362 Alan Crosswell, Columbia U
363 Jeff Damens, (formerly of) Columbia U
364 Mark Davies, Bath U, UK
365 Sin-itirou Dezawa, Fujifilm, Japan
366 Joe R. Doupnik, Utah State U
367 Frank Dreano, Honeywell
368 John Dunlap, U of Washington
369 Alex Dupuy, SMART.COM
370 David Dyck, John Fluke Mfg Co.
371 Stefaan A. Eeckels, Eurokom, Luxembourg
373 Paul Eggert, Twin Sun, Inc., El Segundo, CA
375 Peter Eichhorn, Assyst International
376 Kristoffer Eriksson, Peridot Konsult AB, Oerebro, Sweden
377 John R. Evans, IRS, Kansas City
378 Glenn Everhart, RCA Labs
379 Charlie Finan, Cray Research
380 Herm Fischer, Encino, CA (extensive contributions to version 4.0)
381 Carl Fongheiser, CWRU
382 Mike Freeman, Bonneville Power Authority
383 Marcello Frutig, Catholic University, Sao Paulo, Brazil (X.25 support)
384 Hirofumi Fujii, Japan Nat'l Lab for High Energy Physics, Tokyo (Kanji)
385 Chuck Fuller, Westinghouse Corporate Computer Services
387 Christine M. Gianone, Columbia U
388 John Gilmore, UC Berkeley
389 Madhusudan Giyyarpuram, HP
390 Rainer Glaschick, Siemens AG, Paderborn
392 German Goldszmidt, IBM
394 Alistair Gorman, New Zealand
395 Richard Gration, ADFA, Australia
396 Chris Green, Essex U, UK
397 Alan Grieg, Dundee Tech, Scotland
399 Jim Guyton, Rand Corp
403 Marion Hakanson, ORST
405 John Hamilston, Iowa State U
406 Simon Hania, Netherlands
409 Eugenia Harris, Data General (AOS/VS)
410 David Harrison, Kingston Warren Corp
411 Lucas Hart, Oregon State University
412 James Harvey, Indiana/Purdue U (VMS)
414 Chuck Hedrick, Rutgers U
415 Ron Heiby, Technical Systems Division, Motorola Computer Group
416 Steve Hemminger, Tektronix
417 Christian Hemsing, RWTH Aachen, Germany (OS-9)
418 Randolph Herber, US DOE,
419 Andrew Herbert, Monash Univ, Australia
420 Marcus Herbert, Germany
422 Dan Hildebrand, QNX Software Systems Inc, Kanata, ON (QNX)
424 Stephan Hoffman-Emden
425 Sven Holmstrom, ABB Utilities AB, Sweden
426 Bill Homer, Cray Research
427 Ray Hunter, The Wollongong Group
428 Randy Huntziger, National Library of Medicine
429 Larry Jacobs, Transarc
430 Steve Jenkins, Lancaster University, UK
431 Dave Johnson, Gradient Technologies
432 Mark B Johnson, Apple Computer
433 Jyke Jokinen, Tampere University of Technology, Finland (QNX)
436 Peter Jones, U of Quebec Montreal
437 Phil Julian, SAS Institute
438 Peter Kabal, U of Quebec
439 Mic Kaczmarczik, U of Texas at Austin
440 Sergey Kartashoff, Inst. of Precise Mechanics & Computer Equipment, Moscow
441 Howie Kaye, Columbia U
442 Rob Kedoin, Linotype Co, Hauppauge, NY (OS/2)
445 Terry Kennedy, St Peter's College, Jersey City, NJ (VMS and more)
446 "Carlo Kid", Technical University of Delft, Netherlands
448 Paul Kimoto, Cornell U
449 Douglas Kingston, morgan.com
450 Lawrence Kirby, Wiltshire, UK
451 Tom Kloos, Sequent Computer Systems
452 Jim Knutson, U of Texas at Austin
454 Scott Kramer, SRI International, Menlo Park, CA
455 John Kraynack, US Postal Service
456 David Kricker, Encore Computer
458 Bo Kullmar, ABC Klubben, Stockholm, and Central Bank of Sweden, Kista
459 R. Brad Kummer, AT&T Bell Labs, Atlanta, GA
460 John Kunze, UC Berkeley
461 David Lane, BSSI / BellSouth (Stratus VOS, X.25)
462 Bob Larson, USC (OS-9)
463 Bert Laverman, Groningen U, Netherlands
465 David Lawyer, UC Irvine
466 David LeVine, National Semiconductor Corporation
467 Daniel S. Lewart, UIUC
469 Tor Lillqvist, Helsinki U, Finland
470 David-Michael Lincke, U of St Gallen, Switzerland
471 Robert Lipe (for SCO makefile entries & advice)
473 Mike Long, Analog Devices, Norwood MA
474 Kevin Lowey, U of Saskatchewan (OS/2)
475 Andy Lowry, Columbia U
476 James Lummel, Caprica Telecomputing Resources (QNX)
477 David MacKenzie, Environmental Defense Fund, U of Maryland
478 John Mackin, University of Sidney, Australia
479 Martin Maclaren, Bath U, UK
480 Chris Maio, Columbia U CS Dept
481 Montserrat Mane, HP, Grenoble, France
482 Fulvio Marino, Olivetti, Ivrea, Italy
483 Arthur Marsh, dircsa.org.au
484 Peter Mauzey, Lucent Technologies
485 Tye McQueen, Utah State U
487 Hellmuth Michaelis, Hanseatischer Computerservice GmbH, Hamburg, Germany
488 Leslie Mikesell, American Farm Bureau
489 Todd Miller, Courtesan Consulting
490 Martin Minow, DEC (VMS)
491 Pawan Misra, Bellcore
492 Ken Mizialko, IBM, Manassas, VA
493 Wolfgang Moeller, DECUS Germany
495 Bruce J Moore, Allen-Bradley Co, Highland Heights, OH (Atari ST)
497 Peter Mossel, Columbia U
499 Lou Muccioli, Swanson Analysis Systems
501 Neal P. Murphy, Harsof Systems, Wonder Lake IL
504 Jack Nelson, U of Pittsburgh
505 Jim Noble, Planning Research Corporation (Macintosh)
506 Ian O'Brien, Bath U, UK
509 Thomas Pinkl, Health Business Systems Inc.
510 Michael Pins, Iowa Computer Aided Engineering Network
511 Andre' Pirard, University of Liege, Belgium
512 Paul Placeway, Ohio State U
513 Piet W. Plomp, ICCE, Groningen University, Netherlands
515 Manfred Prange, Oakland U
516 Christopher Pratt, APV Baker, UK
518 Tony Querubin, U of Hawaii
522 Alan Robiette, Oxford University, UK
523 Michel Robitaille, U of Montreal (Mac)
524 Huw Rogers, Schweizerische Kreditanstalt, Zuerich
525 Nigel Roles, Cambridge, England
526 Kai Uwe Rommel, Technische Universitaet Muenchen (OS/2)
527 Larry Rosenman (Amiga)
528 Jay Rouman, U of Michigan
529 Jack Rouse, SAS Institute (Data General and/or Apollo)
530 Stew Rubenstein, Harvard U (VMS)
531 Gerhard Rueckle, FH Darmstadt, Fb. E/Automatisierungstechnik
533 Bill Schilit, Columbia U
534 Ulli Schlueter, RWTH Aachen, Germany (OS-9, etc)
535 Michael Schmidt, U of Paderborn, Germany
536 Eric Schnoebelen, Convex
538 Dan Schullman, DEC (modems, DIAL command, etc)
540 Steven Schultz, Contel (PDP-11)
541 APPP Scorer, Leeds Polytechnic, UK
542 Gordon Scott, Micro Focus, Newbury UK
543 Gisbert W. Selke, WIdO, Bonn, Germany
544 David Singer, IBM Almaden Research Labs
545 David Sizeland, U of London Medical School
546 Fridrik Skulason, Iceland
550 Fred Smith, Merk / Computrition
551 Richard S Smith, Cal State
553 Bertil Stenstroem, Stockholm University Computer Centre (QZ), Sweden
554 James Sturdevant, CAP GEMENI AMERICA, Minneapolis
555 Peter Svanberg, Royal Techn. HS, Sweden
556 James R. Swenson, Accu-Weather, Inc.
557 Ted T'so, MIT (Linux)
558 Andy Tanenbaum, Vrije U, Amsterdam, Netherlands
560 Markku Toijala, Helsinki U of Technology
561 Teemu Torma, Helsinki U of Technology
562 Linus Torvalds, Helsinki
564 Warren Tucker, Tridom Corp, Mountain Park, GA
565 Dave Tweten, AMES-NAS
567 Walter Underwood, Ford Aerospace
568 Pieter Van Der Linden, Centre Mondial, Paris
569 Ge van Geldorp, Netherlands
570 Fred van Kempen, MINIX User Group, Voorhout, Netherlands
571 Wayne Van Pelt, GE/CRD
572 Mark Vasoll, Oklahoma State U (V7 UNIX)
573 Konstantin Vinogradov, ICSTI, Moscow
575 Bernie Volz, Process Software
576 Eduard Vopicka, Prague University of Economics, Czech Republic
578 Roger Wallace, Raytheon
579 Stephen Walton, Calif State U, Northridge (Amiga)
580 Jamie Watson, Adasoft, Switzerland (AIX)
581 Rick Watson, U of Texas (Macintosh)
582 Scott Weikart (Association for Progressive Communications)
583 Robert Weiner, Programming Plus, New York City
584 Lauren Weinstein, Vortex Technlogy
585 David Wexelblat, AT&T
586 Clark Wierda, Illuminati Online
587 Joachim Wiesel, U of Karlsruhe
588 Lon Willett, U of Utah
589 Michael Williams, UCLA
590 Nate Williams, U of Montana
592 Joellen Windsor, U of Arizona
593 Patrick Wolfe, Kuck & Associates, Inc.
594 Gregg Wonderly, Oklahoma State U (V7 UNIX)
595 Farrell Woods, Concurrent (formerly Masscomp)
596 Dave Woolley, CAP Communication Systems, London
597 Jack Woolley, SCT Corp
599 Ken Yap, formerly of U of Rochester
600 John Zeeff, Ann Arbor, MI
603 #include "ckcker.h" /* Kermit symbols */
604 #include "ckcnet.h" /* Network symbols */
615 #define INCL_VIO /* Needed for ckocon.h */
627 /* Text message definitions.. each should be 256 chars long, or less. */
629 char *srvtxt = "\r\n\
630 Entering server mode.\r\n\0";
634 It seems there was a large installation that was using C-Kermit 5A(165)
635 or thereabouts, which had deployed thousands of MS-DOS Kermit scripts in
636 scattered locations that looked for strings in the old server message,
637 which changed in 5A(183), August 1992.
639 char *srvtxt = "\r\n\
640 C-Kermit server starting. Return to your local machine by typing\r\n\
641 its escape sequence for closing the connection, and issue further\r\n\
642 commands from there. To shut down the C-Kermit server, issue the\r\n\
643 FINISH or BYE command and then reconnect.\n\
647 char *srvtxt = "\r\012\
648 Entering server mode. If your local Kermit software is menu driven, use\r\012\
649 the menus to send commands to the server. Otherwise, enter the escape\r\012\
650 sequence to return to your local Kermit prompt and issue commands from\r\012\
651 there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\012\
652 other available services. Use BYE or FINISH to end server mode.\r\012\0";
653 #else /* UNIX, VMS, AOS/VS, and all others */
654 char *srvtxt = "\r\n\
655 Entering server mode. If your local Kermit software is menu driven, use\r\n\
656 the menus to send commands to the server. Otherwise, enter the escape\r\n\
657 sequence to return to your local Kermit prompt and issue commands from\r\n\
658 there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\n\
659 other available services. Use BYE or FINISH to end server mode.\r\n\0";
663 #else /* server mode disabled */
665 #endif /* NOSERVER */
667 int initflg = 0; /* sysinit() has executed... */
668 int howcalled = I_AM_KERMIT; /* How I was called */
670 int quitting = 0; /* I'm in the act of quitting */
673 char * iksdconf = IKSDCONF; /* IKSD configuration file */
674 int iksdcf = 0; /* Has IKSD c.f. been processed? */
675 #endif /* IKSDCONF */
677 int srvcdmsg = 0; /* [Server] CD message */
678 char * cdmsgfile[8] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
679 char * cdmsgstr = NULL;
680 char * ckcdpath = NULL;
682 #ifdef NLCHAR /* Text-file line terminator */
688 int fblksiz = DBLKSIZ; /* File blocksize */
689 int frecl = DLRECL; /* File record length */
690 int frecfm = XYFF_S; /* File record format (default = stream) */
691 int forg = XYFO_S; /* File organization (sequential) */
692 int fcctrl = XYFP_N; /* File carriage control (ctrl chars) */
693 int filecase = FILECASE; /* Case matters in filenames */
694 int stathack = 1; /* Fast directory lookups by default */
696 char uidbuf[UIDBUFLEN] = { NUL, NUL }; /* User ID buffer */
697 int cfilef = 0; /* Application ("kerbang") file flag */
698 char cmdfil[CKMAXPATH + 1] = { NUL, NUL }; /* Application file name */
699 int haveurl = 0; /* URL given on command line */
702 /* Multi-protocol support */
704 struct ck_p ptab[NPROTOS] = { /* Initialize the Kermit part ... */
706 DRPSIZ, /* Receive packet size */
707 DSPSIZ, /* Send packet size */
708 0, /* Send-packet-size-set flag */
709 DFWSIZ, /* Window size */
712 PX_CAU, /* Control char unprefixing... */
715 #endif /* NEWDEFAULTS */
717 #ifdef VMS /* Default filename collision action */
718 XYFX_X, /* REPLACE for VAX/VMS */
720 XYFX_B, /* BACKUP for everybody else */
723 #ifdef OS2 /* Flag for file name conversion */
724 XYFN_L, /* Literal for OS2 */
726 XYFN_C, /* Converted for others */
729 PATH_OFF, /* Send pathnames OFF */
730 PATH_AUTO, /* Receive pathnames AUTO */
731 NULL, /* Host receive initiation string (binary) */
732 NULL, /* Host receive initiation string (text) */
733 NULL, /* Host server string */
734 NULL, /* External protocol send command (binary) */
735 NULL, /* External protocol send command (text) */
736 NULL, /* External protocol receive command (bin) */
737 NULL } /* External protocol receive command (txt) */
740 {"XMODEM", 128,128,-1,-1, 1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
741 {"XMODEM-CRC",128,128,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
742 {"YMODEM", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
743 {"YMODEM-g", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
744 {"ZMODEM", -1, -1,-1,-1,PX_WIL,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
745 {"Other", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
749 /* Declarations for Send-Init Parameters */
751 int spsiz = DSPSIZ, /* Current packet size to send */
752 spmax = DSPSIZ, /* Biggest packet size we can send */
753 lastspmax = DSPSIZ, /* Send-packet size last used */
754 spsizr = DSPSIZ, /* Send-packet size requested */
755 spsizf = 0, /* Flag to override size negotiation */
756 rpsiz = DRPSIZ, /* Biggest we want to receive */
757 urpsiz = DRPSIZ, /* User-requested receive pkt size */
758 maxrps = MAXRP, /* Maximum incoming long packet size */
759 maxsps = MAXSP, /* Maximum outbound l.p. size */
760 maxtry = MAXTRY, /* Maximum retries per packet */
761 wslots = 1, /* Window size currently in use */
762 wslotr = DFWSIZ, /* Window size from SET WINDOW */
763 wslotn = 1, /* Window size negotiated in S-pkt */
764 timeouts = 0, /* For statistics reporting */
765 spackets = 0, /* ... */
766 rpackets = 0, /* ... */
767 retrans = 0, /* ... */
768 crunched = 0, /* ... */
771 srvidl = 0, /* Server idle timeout */
772 srvdis = 1, /* Server file xfer display */
773 srvtim = DSRVTIM, /* Server command wait timeout */
774 srvping = 1, /* Server keepalive */
776 timint is the timeout interval I use when waiting for a packet.
777 pkttim is the SET RECEIVE TIMEOUT value, sent to the other Kermit.
778 rtimo is the SET SEND TIMEOUT value. rtimo is the initial value of
779 timint. timint is changed by the value in the incoming negotiation
780 packet unless a SET SEND TIMEOUT command was given.
782 timint = DMYTIM, /* Timeout interval I use */
783 pkttim = URTIME, /* Timeout I want you to use */
784 rtimo = DMYTIM, /* Normal packet wait timeout */
785 timef = 0, /* Flag to override what you ask */
787 rttflg = 1, /* Use dynamic round-trip timers */
789 rttflg = 0, /* Use fixed timer */
790 #endif /* CK_TIMERS */
791 mintime = 1, /* Minimum timeout */
792 maxtime = 0, /* Maximum timeout */
794 npad = MYPADN, /* How much padding to send */
795 mypadn = MYPADN, /* How much padding to ask for */
796 bctr = DFBCT, /* Block check type requested */
797 bctu = 1, /* Block check type used */
798 bctl = 1, /* Block check length */
799 c_save = -1, /* Block check saving and restoring */
800 ss_save = -1, /* Slow-start saving and restoring */
801 ebq = MYEBQ, /* 8th bit prefix */
802 ebqflg = 0, /* 8th-bit quoting flag */
803 rqf = -1, /* Flag used in 8bq negotiation */
804 rq = 0, /* Received 8bq bid */
805 sq = 'Y', /* Sent 8bq bid */
806 rpt = 0, /* Repeat count */
807 rptq = MYRPTQ, /* Repeat prefix */
808 rptflg = 0, /* Repeat processing flag */
809 rptena = 1, /* Repeat processing enabled */
810 xfrcan = 1, /* Transfer cancellation enabled */
811 xfrint = 1, /* Transfer interruption enabled */
812 xfrchr = 3, /* Transfer cancel char = Ctrl-C */
813 xfrnum = 3, /* Need three of them by default */
815 char * xfrmsg = NULL; /* Message for f.t. display screen */
819 int xfrxla = 0; /* Character-set translation */
821 int xfrxla = 1; /* enabled or disabled */
825 int epktflg = 0; /* E-PACKET command active */
827 int capas = 9, /* Position of Capabilities */
828 lpcapb = 2, /* Long Packet capability */
829 lpcapr = 1, /* requested */
830 lpcapu = 0, /* used */
831 swcapb = 4, /* Sliding Window capability */
832 swcapr = 1, /* requested (allowed) */
833 swcapu = 0, /* used */
834 atcapb = 8, /* Attribute capability */
835 atcapr = 1, /* requested */
836 atcapu = 0, /* used */
837 rscapb = 16, /* RESEND capability */
838 rscapr = 1, /* requested by default */
839 rscapu = 0, /* used */
840 lscapb = 32, /* Locking Shift capability */
841 lscapr = 1, /* requested by default */
842 lscapu = 0; /* used */
844 /* Flags for whether to use particular attributes */
846 int atenci = 1, /* Encoding in */
847 atenco = 1, /* Encoding out */
848 atdati = 1, /* Date in */
849 atdato = 1, /* Date out */
850 atdisi = 1, /* Disposition in/out */
852 atleni = 1, /* Length in/out (both kinds) */
854 atblki = 1, /* Blocksize in/out */
856 attypi = 1, /* File type in/out */
858 atsidi = 1, /* System ID in/out */
860 atsysi = 1, /* System-dependent parameters in/out */
863 int dispos = 0; /* Disposition */
870 #endif /* CK_PERMS */
872 int atfrmi = 1, /* Record Format in/out */
876 int atcrei = 1, /* Creator ID in/out */
878 atacti = 1, /* Account in/out */
882 int sprmlen = -1; /* Send/Receive protocol parameter */
883 int rprmlen = -1; /* string length limits */
884 int sendipkts = 1; /* Send I packets */
886 CHAR padch = MYPADC, /* Padding character to send */
887 mypadc = MYPADC, /* Padding character to ask for */
888 seol = MYEOL, /* End-Of-Line character to send */
889 eol = MYEOL, /* End-Of-Line character to look for */
890 ctlq = CTLQ, /* Control prefix in incoming data */
891 myctlq = CTLQ, /* Outbound control character prefix */
892 myrptq = MYRPTQ; /* Repeat prefix I want to use */
894 int rptmin = 3; /* Repeat-count minimum */
896 int usepipes = 0, /* Used for xfer to/from pipes */
899 char * filefile = NULL; /* File containing list of filenames */
900 /* CD message filename list */
902 char whoareu[16] = { NUL, NUL }; /* System ID of other Kermit */
903 int sysindex = -1; /* and index to its system ID struct */
905 int wearealike = 0; /* 2 Kermits have compatible sysids */
906 char * cksysid = /* My system ID */
941 #endif /* datageneral */
950 int oopts = -1; /* O-Packet Options */
951 int omode = -1; /* O-Packet Transfer Mode */
952 int oname = -1; /* O-Packet Filename Options */
953 int opath = -1; /* O-Packet Pathname Options */
955 struct zattr iattr; /* Incoming file attributes */
958 /* VMS labeled file default options - name only. */
959 int lf_opts = LBL_NAM;
962 /* OS/2 labeled file default options, all attributes but archived. */
963 unsigned long int lf_opts = LBL_EXT|LBL_HID|LBL_RO|LBL_SYS;
969 /* Packet-related variables */
971 int pktnum = 0, /* Current packet number */
972 sndtyp = 0, /* Type of packet just sent */
973 rcvtyp = 0, /* Type of packet just received */
974 rsn, /* Received packet sequence number */
975 rln, /* Received packet length */
976 size, /* Current size of output pkt data */
977 osize, /* Previous output packet data size */
978 maxsize, /* Max size for building data field */
979 spktl = 0, /* Length packet being sent */
980 rpktl = 0, /* Length of packet just received */
981 pktpaus = 0, /* Interpacket pause interval, msec */
982 rprintf, /* REMOTE PRINT flag */
983 rmailf, /* MAIL flag */
984 xferstat = -1, /* Status of last transaction */
985 filestatus = 0; /* Status of last file transfer */
987 CHAR pktmsgbuf[PKTMSGLEN+1];
988 CHAR *epktmsg = pktmsgbuf;
991 int srvcmdlen = MAXRP; /* srvcmd buffer length */
994 int srvcmdlen = MAXRP;
1003 *srvcmd = srvcmdbuf,
1006 *srvcmd = (CHAR *)0, /* Where to decode server command */
1009 *srvcmd = srvcmdbuf,
1010 #endif /* DYNAMIC */
1012 padbuf[96], /* Buffer for send-padding */
1014 *rdatap, /* Pointer to received packet data */
1015 *data = (CHAR *)0, /* Pointer to send-packet data */
1016 *srvptr, /* Pointer to srvcmd */
1017 mystch = SOH, /* Outbound packet-start character */
1018 stchr = SOH; /* Incoming packet-start character */
1020 /* File-related variables */
1022 #ifndef NOMSEND /* Multiple SEND */
1023 struct filelist * filehead = NULL; /* SEND list */
1024 struct filelist * filetail = NULL;
1025 struct filelist * filenext = NULL;
1027 #endif /* NOMSEND */
1029 char filnam[CKMAXPATH + 1]; /* Name of current file. */
1030 char ofilnam[CKMAXPATH + 1]; /* Original name. */
1032 int pipesend = 0; /* Nonzero if sending from pipe */
1034 char * sndfilter = NULL; /* Send and receive filters */
1035 char * rcvfilter = NULL;
1036 #endif /* PIPESEND */
1038 char ** sndarray = NULL; /* SEND /ARRAY pointer and range */
1040 int sndxlo = -1, sndxhi = -1, sndxin = -1;
1045 int ngetpath = 0; /* GET search path */
1046 int fromgetpath = 0;
1047 char * getpath[MAXGETPATH];
1048 char * x_user = NULL; /* Server login information */
1049 char * x_passwd = NULL;
1050 char * x_acct = NULL;
1051 #endif /* NOSERVER */
1053 int x_login = 0; /* Login required */
1054 int x_logged = 0; /* User is logged in */
1056 extern int timelimit;
1059 int logintimo = 300; /* Login timeout */
1060 char * userfile = NULL; /* Forbidden user file */
1061 #endif /* CK_LOGIN */
1063 char * anonfile = NULL; /* Anonymous login init file */
1064 char * anonroot = NULL; /* Anonymous file-system root */
1065 int iks_timo = 300; /* 5 minutes idle timo */
1066 int iks_retry = 3; /* 3 attempts at login */
1070 extern VOID zsyslog();
1071 extern int ckxlogging, ckxsyslog;
1072 #endif /* CKSYSLOG */
1074 int nzxopts = 0; /* Options for nzxpand() */
1075 int nfils = 0; /* Number of files in file group */
1076 long fsize = 0L; /* Size of current file */
1078 int wildxpand = 0; /* Who expands wildcards */
1082 #endif /* STRATUS */
1085 int matchdot = 0; /* Whether to match dot files */
1088 #endif /* UNIXOROSK */
1089 int matchfifo = 0; /* Whether to match FIFO "files" */
1090 int clfils = 0; /* Flag for command-line files */
1091 int stayflg = 0; /* Flag for "stay", i.e. "-S" */
1092 int xfinish = 0; /* Flag for FINISH = EXIT */
1093 long ztusec = -1L; /* Used with ztime() */
1094 long ztmsec = -1L; /* Ditto */
1096 /* Communication device / connection variables */
1098 char ttname[TTNAMLEN+1]; /* Name of communication device */
1101 int connected = 0; /* True if connected */
1102 int startconnected; /* initial state of connected */
1105 long speed = -1L; /* Communication device speed */
1106 int wasclosed = 0; /* Connection was just closed */
1107 int whyclosed = WC_REMO; /* why it was closed */
1108 int qnxportlock = 0; /* QNX port locking on/off */
1112 #endif /* CLSONDISC */
1114 int cxflow[CXT_MAX+1]; /* See initflow() */
1117 char * floname[] = { /* Flow control names */
1118 "none", "xon/xoff", "rts/cts", "dtr/cd", "etx/ack", "string",
1119 "xxx1", "xxx2", "dtr/cts", "keep", "auto"
1121 int nfloname = (sizeof(floname) / sizeof(char *));
1123 char * cxname[] = { /* Connection type names */
1124 "remote", "direct-serial", "modem", "tcp/ip", "x.25", "decnet",
1125 "lat", "netbios", "named-pipe", "ssh", "pipe"
1127 int ncxname = (sizeof(cxname) / sizeof(char *));
1130 int parity = DEFPAR, /* Parity specified, 0,'e','o',etc */
1131 hwparity = 0, /* Hardware parity for serial port */
1132 stopbits = -1, /* Stop bits for serial port */
1133 clsondisc = CLSONDISC, /* Serial port close on disconnect */
1134 autopar = 0, /* Automatic parity change flag */
1135 sosi = 0, /* Shift-In/Out flag */
1136 flow = 0, /* Flow control (see initflow()) */
1137 autoflow = 1, /* Automatic flow control */
1138 turn = 0, /* Line turnaround handshake flag */
1139 turnch = XON, /* Line turnaround character */
1140 duplex = 0, /* Duplex, full by default */
1141 escape = DFESC, /* Escape character for connect */
1142 ckdelay = DDELAY, /* Initial delay before sending */
1143 tnlm = 0; /* Terminal newline mode */
1145 /* Networks for SET HOST */
1148 #define MYHOSTL 1024
1151 #endif /* BIGBUFOK */
1153 char myhost[MYHOSTL]; /* Local host name */
1154 int network = 0; /* Network vs serial connection */
1155 int inserver = 0; /* Running as an Internet server */
1156 int isguest = 0; /* User is anonymous */
1157 char * clienthost = NULL; /* Peer host name or address */
1158 int tcp_incoming = 0; /* Incoming TCP connection? */
1162 int nettype = NET_TCPB; /* Default network type */
1165 int nettype = NET_SX25;
1168 int nettype = NET_IX25;
1171 int nettype = NET_HX25;
1174 int nettype = NET_VX25;
1177 int nettype = NET_DEC;
1180 int nettype = NET_SLAT;
1182 int nettype = NET_NONE;
1183 #endif /* SUPERLAT */
1185 #endif /* STRATUSX25 */
1189 #endif /* TCPSOCKET */
1191 int nettype = NET_NONE;
1192 #endif /* NETCONN */
1195 int revcall = 0; /* X.25 reverse call not selected */
1196 int closgr = -1; /* X.25 closed user group */
1197 int cudata = 0; /* X.25 call user data not specified */
1198 char udata[MAXCUDATA]; /* X.25 call user data */
1202 I was unable to find any pre-defined MAX values for x25 addresses - the
1203 addresses that I've seen have been around 10-12 characters 32 is probably
1204 enough, 64 is hopefully safe for everyone.
1206 x25addr_t local_nua = {'\0'}; /* local x.25 address */
1207 x25addr_t remote_nua = {'\0'}; /* remote x.25 address */
1208 char x25name[32] = {'\0'}; /* x25 device name, sx25a0 or sx25a1 */
1209 char x25dev[64] = "/dev/x25pkt"; /* x25 device in /dev */
1210 int x25port = 0; /* port used for X.25 - AIX only */
1215 This condition is unrelated to the above IBMX25 condition.
1216 IBM X.25 doesn't have PAD support.
1218 CHAR padparms[MAXPADPARMS+1]; /* X.3 parameters */
1224 int isinterrupted = 0; /* Used in exception handling */
1225 int what = W_INIT; /* What I am doing */
1226 int lastxfer = 0; /* Last transfer (send or receive) */
1228 extern int mdmtyp; /* Modem (/network) type */
1231 extern int StartedFromDialer;
1233 extern int TlsIndex;
1236 unsigned long ESPToRestore; /* Ditto */
1241 int os2pm = 0; /* OS/2 Presentation Manager flag */
1244 /* Terminal screen size, if known, -1 means unknown. */
1249 int tt_rows[VNUM] = {24,24,25,1}; /* Rows (height) */
1250 int tt_cols[VNUM] = {80,80,80,80}; /* Columns (width) */
1251 int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */
1253 int tt_rows[VNUM] = {-1,24,25,1}; /* Rows (height) */
1254 int tt_cols[VNUM] = {-1,80,80,80}; /* Columns (width) */
1255 int cmd_rows = -1, cmd_cols = -1; /* Command/console screen dimensions */
1257 int k95stdio = 0; /* Stdio threads */
1258 int tt_bell = XYB_AUD | XYB_SYS; /* BELL AUDIBLE (system sounds) */
1260 int tt_rows = -1; /* Rows (height) */
1261 int tt_cols = -1; /* Columns (width) */
1262 int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */
1263 int tt_bell = XYB_AUD; /* BELL ON */
1266 int tt_print = 0; /* Transparent print disabled */
1267 int tt_escape = 1; /* Escaping back is enabled */
1268 int tt_scroll = 1; /* Scrolling operations are enabled */
1270 int tn_exit = 0; /* Exit on disconnect */
1272 int exitonclose = 0; /* Exit on close */
1273 int exithangup = 1; /* Hangup on exit */
1274 int haveline = 0; /* SET LINE or SET HOST in effect */
1275 int tlevel = -1; /* Take-file command level */
1276 int hints = 1; /* Whether to give hints */
1279 int remonly = 1; /* Remote-mode-only advisory (-R) */
1280 int nolocal = 1; /* Remote-only strictly enforced */
1284 int cx_status = 0; /* CONNECT return status */
1285 #endif /* NOLOCAL */
1288 extern int cmdlvl; /* Command level */
1289 extern int maclvl; /* Macro invocation level */
1292 int protocol = PROTO_K; /* File transfer protocol = Kermit */
1295 int prefixing = PX_CAU;
1297 int prefixing = PX_ALL;
1298 #endif /* NEWDEFAULTS */
1300 extern short ctlp[]; /* Control-prefix table */
1302 int carrier = CAR_AUT; /* Pay attention to carrier signal */
1303 int cdtimo = 0; /* Carrier wait timeout */
1304 int xitsta = GOOD_EXIT; /* Program exit status */
1306 #ifdef VMS /* Default filename collision action */
1307 int fncact = XYFX_X; /* REPLACE for VMS */
1309 int fncact = XYFX_B; /* BACKUP for everybody else */
1312 int fncsav = -1; /* For saving & restoring the above */
1313 int bgset = -1; /* BACKGROUND mode set explicitly */
1315 int cmdint = 1; /* Interrupts are allowed */
1317 int xsuspend = DFSUSP; /* Whether SUSPEND command, etc, */
1318 #else /* is to be allowed. */
1322 /* Statistics variables */
1324 long filcnt, /* Number of files in transaction */
1325 filrej, /* Number of files rejected in transaction */
1326 flci, /* Characters from line, current file */
1327 flco, /* Chars to line, current file */
1328 tlci, /* Chars from line in transaction */
1329 tlco, /* Chars to line in transaction */
1330 ffc, /* Chars to/from current file */
1331 tfc, /* Chars to/from files in transaction */
1332 cps = 0L, /* Chars/sec last transfer */
1333 peakcps = 0L, /* Peak chars/sec last transfer */
1334 ccu, /* Control chars unprefixed in transaction */
1335 ccp, /* Control chars prefixed in transaction */
1336 rptn; /* Repeated characters compressed */
1338 int tsecs = 0; /* Seconds for transaction */
1339 int fsecs = 0; /* Per-file timer */
1343 fpfsecs = 0.0, /* Floating point per-file timer */
1344 fptsecs = 0.0; /* and per-transaction timer */
1345 #endif /* GFTIMER */
1349 int deblog = 0, /* Debug log is open */
1350 debok = 1, /* Debug log is not disabled */
1351 debxlen = 54, /* Default length for debug strings */
1352 debses = 0, /* Flag for DEBUG SESSION */
1353 debtim = 0, /* Include timestamp in debug log */
1354 pktlog = 0, /* Flag for packet logging */
1355 seslog = 0, /* Session logging */
1356 dialog = 0, /* DIAL logging */
1357 tralog = 0, /* Transaction logging */
1358 tlogfmt = 1, /* Transaction log format (verbose) */
1359 tlogsep = (int)',', /* Transaction log field separator */
1360 displa = 0, /* File transfer display on/off */
1361 stdouf = 0, /* Flag for output to stdout */
1362 stdinf = 0, /* Flag for input from stdin */
1363 xflg = 0, /* Flag for X instead of F packet */
1364 hcflg = 0, /* Doing Host command */
1365 dest = DEST_D, /* Destination for packet data */
1366 zchkod = 0, /* zchko() should work for dirs too? */
1367 zchkid = 0, /* zchki() should work for dirs too? */
1369 /* If you change this, also see struct ptab above... */
1371 #ifdef OS2 /* Flag for file name conversion */
1372 fncnv = XYFN_L, /* Default is Literal in OS/2, */
1373 f_save = XYFN_L, /* (saved copy of same) */
1375 fncnv = XYFN_C, /* elsewhere Convert them */
1376 f_save = XYFN_C, /* (ditto) */
1379 fnspath = PATH_OFF, /* Send file path */
1380 fnrpath = PATH_AUTO, /* Receive file path */
1381 fackpath = 1, /* Send back path in ACK to F */
1382 binary = XYFT_B, /* Default file transfer mode */
1383 b_save = XYFT_B, /* Saved file mode */
1384 eofmethod = 0, /* EOF detection method (length) */
1387 cursor_save = -1, /* Cursor state */
1390 xfermode = XMODE_A, /* Transfer mode, manual or auto */
1391 xfiletype = -1, /* Transfer only text (or binary) */
1392 recursive = 0, /* Recursive directory traversal */
1393 nolinks = 2, /* Don't follow symbolic links */
1394 skipbup = 0, /* Skip backup files when sending */
1395 sendmode = SM_SEND, /* Which type of SEND operation */
1396 slostart = 1, /* Slow start (grow packet lengths) */
1397 cmask = 0377, /* CONNECT (terminal) byte mask */
1398 fmask = 0377, /* File byte mask */
1399 ckwarn = 0, /* Flag for file warning */
1400 quiet = 0, /* Be quiet during file transfer */
1401 local = 0, /* 1 = local mode, 0 = remote mode */
1402 cxtype = CXT_REMOTE, /* Connection type */
1403 server = 0, /* Flag for I Am Server */
1404 query = 0, /* Flag for Query active */
1405 justone = 0, /* Server should do Just One command */
1406 urserver = 0, /* Flag for You Are Server */
1407 bye_active = 0, /* Flag for BYE command active */
1408 diractive = 0, /* Flag for DIRECTORY command active */
1409 cdactive = 0, /* Flag for CD command active */
1410 cflg = 0, /* Connect before transaction */
1411 cnflg = 0, /* Connect after transaction */
1412 cxseen = 0, /* Flag for cancelling a file */
1413 czseen = 0, /* Flag for cancelling file group */
1414 fatalio = 0, /* Flag for fatal i/o error */
1415 discard = 0, /* Flag for file to be discarded */
1416 keep = SET_AUTO, /* Keep incomplete files = AUTO */
1417 unkcs = 1, /* Keep file w/unknown character set */
1419 filepeek = 0, /* Inspection of files */
1425 #endif /* datageneral */
1427 nakstate = 0, /* In a state where we can send NAKs */
1428 dblchar = -1, /* Character to double when sending */
1429 moving = 0, /* MOVE = send, then delete */
1430 reliable = SET_AUTO, /* Nonzero if transport is reliable */
1433 urclear = 0, /* Nonzero for clear channel to you */
1434 clearrq = SET_AUTO, /* SET CLEARCHANEL value */
1436 streaming = 0, /* Nonzero if streaming is active */
1437 streamok = 0, /* Nonzero if streaming negotiated */
1438 streamrq = SET_AUTO, /* SET STREAMING value */
1439 streamed = -1; /* Whether we streamed last time */
1441 char * snd_move = NULL; /* Move file after sending it */
1442 char * snd_rename = NULL; /* Rename file after sending it */
1443 char * rcv_move = NULL; /* Move file after receiving it */
1444 char * rcv_rename = NULL; /* Rename file after receiving it */
1446 char * g_snd_move = NULL;
1447 char * g_snd_rename = NULL;
1448 char * g_rcv_move = NULL;
1449 char * g_rcv_rename = NULL;
1451 long sendstart = 0L; /* SEND start position */
1452 long calibrate = 0L; /* Nonzero if calibration run */
1455 char *tt_trigger[TRIGGERS] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
1456 CHAR *tt_trmatch[TRIGGERS] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
1457 char *triggerval = NULL;
1458 #endif /* CK_TRIGGER */
1460 int ckxlogging = 0; /* Flag for syslogging active */
1461 int ikdbopen = 0; /* Flag for IKSD database active */
1462 int dbinited = 0; /* Flag for IKSDB record init'd */
1464 int ckxsyslog = 0; /* Logging level 0 */
1467 int ckxsyslog = SYSLOGLEVEL; /* Logging level specified */
1469 int ckxsyslog = SYSLG_DF; /* Default logging level */
1470 #endif /* SYSLOGLEVEL */
1471 #endif /* CKSYSLOG */
1475 _PROTOTYP( VOID iniopthlp, (void) ); /* Command-line help initializer */
1479 _PROTOTYP( VOID getexedir, (void) );
1480 _PROTOTYP( int putnothing, (char) );
1483 _PROTOTYP( VOID doiksdinit, (void) );
1484 _PROTOTYP( VOID iksdinit, (void) );
1485 _PROTOTYP( VOID doiklog, (void) );
1486 _PROTOTYP( int dbinit, (void) );
1489 /* Variables passed from command parser to protocol module */
1494 _PROTOTYP( VOID apconect, (void) );
1501 char *clcmds = NULL; /* Pointer to command-line commands */
1505 extern MACRO *macrotab;
1506 #endif /* NOSETKEY */
1509 int nopush = 0; /* PUSH enabled */
1511 int nopush = 1; /* PUSH disabled */
1514 CHAR sstate = (CHAR) 0; /* Starting state for automaton */
1515 CHAR zstate = (CHAR) 0; /* For remembering sstate */
1516 char * printername = NULL; /* NULL if printer not redirected */
1517 int printpipe = 0; /* For SET PRINTER */
1521 char *cmarg = ""; /* Pointer to command data */
1522 char *cmarg2 = ""; /* Pointer to 2nd command data */
1523 char **cmlist; /* Pointer to file list in argv */
1525 #ifdef CK_AUTODL /* Autodownload */
1526 int autodl = 1; /* Enabled by default */
1528 int autodl = 0; /* (or if not implemented). */
1529 #endif /* CK_AUTODL */
1530 int adl_err = 1; /* 1 = stop on error */
1532 int adl_ask = 1; /* 1 = file dialog on autodownload */
1534 int adl_ask = 0; /* 0 = no file dialog */
1536 #ifdef OS2 /* AUTODOWNLOAD parameters */
1537 int adl_kmode = ADL_PACK, /* Match Packet to signal download */
1538 adl_zmode = ADL_PACK;
1539 char * adl_kstr = NULL; /* KERMIT Download String */
1540 char * adl_zstr = NULL; /* ZMODEM Download String */
1543 int remfile = 0, rempipe = 0, remappd = 0; /* REMOTE output redirection */
1544 char * remdest = NULL;
1550 1 = enabled in local mode
1551 2 = enabled in remote mode
1552 3 = enabled in both local and remote modes
1553 only as initial (default) values.
1555 int en_xit = 2; /* EXIT */
1556 int en_cwd = 3; /* CD/CWD */
1557 int en_cpy = 3; /* COPY */
1558 int en_del = 2; /* DELETE */
1559 int en_mkd = 3; /* MKDIR */
1560 int en_rmd = 2; /* RMDIR */
1561 int en_dir = 3; /* DIRECTORY */
1562 int en_fin = 3; /* FINISH */
1563 int en_get = 3; /* GET */
1565 int en_hos = 2; /* HOST enabled */
1567 int en_hos = 0; /* HOST disabled */
1569 int en_ren = 3; /* RENAME */
1570 int en_sen = 3; /* SEND */
1571 int en_set = 3; /* SET */
1572 int en_spa = 3; /* SPACE */
1573 int en_typ = 3; /* TYPE */
1574 int en_who = 3; /* WHO */
1576 /* Data General AOS/VS can't do this */
1577 int en_bye = 0; /* BYE */
1579 int en_bye = 2; /* PCs in local mode... */
1580 #endif /* datageneral */
1581 int en_asg = 3; /* ASSIGN */
1582 int en_que = 3; /* QUERY */
1583 int en_ret = 2; /* RETRIEVE */
1584 int en_mai = 3; /* MAIL */
1585 int en_pri = 3; /* PRINT */
1586 int en_ena = 3; /* ENABLE */
1588 int en_xit = 0, en_cwd = 0, en_cpy = 0, en_del = 0, en_mkd = 0, en_rmd = 0,
1589 en_dir = 0, en_fin = 0, en_get = 0, en_hos = 0, en_ren = 0, en_sen = 0,
1590 en_set = 0, en_spa = 0, en_typ = 0, en_who = 0, en_bye = 0, en_asg = 0,
1591 en_que = 0, en_ret = 0, en_mai = 0, en_pri = 0, en_ena = 0;
1592 #endif /* NOSERVER */
1597 char **xargv; /* Global copies of argv */
1598 int xargc; /* and argc */
1599 int xargs; /* an immutable copy of argc */
1600 char *xarg0; /* and of argv[0] */
1601 char *pipedata; /* Pointer to -P (pipe) data */
1603 extern char *dftty; /* Default tty name from ck?tio.c */
1604 extern int dfloc; /* Default location: remote/local */
1605 extern int dfprty; /* Default parity */
1606 extern int dfflow; /* Default flow control */
1612 Buffered file input and output buffers. See getpkt() in ckcfns.c
1613 and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).
1616 /* Now we allocate them dynamically, see getiobs() below. */
1617 char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];
1618 #endif /* DYNAMIC */
1619 char *zinptr, *zoutptr;
1620 int zincnt, zoutcnt;
1621 int zobufsize = OBUFSIZE;
1627 #endif /* SESLIMIT */
1629 #ifdef CK_AUTHENTICATION
1631 #endif /* CK_AUTHENTICATION */
1633 _PROTOTYP( int getiobs, (VOID) );
1635 /* M A I N -- C-Kermit main program */
1643 #ifdef GEMDOS /* Special for Atari ST */
1644 cc_clean(); /* This can't be right? */
1646 #endif /* NOCCTRAP */
1649 /* Info associated with a system ID */
1651 struct sysdata sysidlist[] = { /* Add others as needed... */
1652 { "0", "anonymous", 0, NUL, 0, 0, 0 },
1653 { "A1", "Apple II", 0, NUL, 0, 0, 3 }, /* fix this */
1654 { "A3", "Macintosh", 1, ':', 0, 2, 1 },
1655 { "D7", "VMS", 0, ']', 1, 0, 0 },
1656 { "DA", "RSTS/E", 0, ']', 1, 0, 3 }, /* (i think...) */
1657 { "DB", "RT11", 0, NUL, 1, 0, 3 }, /* (maybe...) */
1658 { "F3", "AOS/VS", 1, ':', 0, 0, 2 },
1659 { "I1", "VM/CMS", 0, NUL, 0, 0, 0 },
1660 { "I2", "MVS/TSO", 0, NUL, 0, 0, 0 },
1661 { "I4", "MUSIC", 0, NUL, 0, 0, 0 },
1662 { "I7", "CICS", 0, NUL, 0, 0, 0 },
1663 { "I9", "MVS/ROSCOE", 0, NUL, 0, 0, 0 },
1664 { "K2", "Atari ST", 1, '\\', 1, 0, 3 },
1665 { "L3", "Amiga", 1, '/', 1, 0, 2 },
1666 { "MV", "Stratus VOS", 1, '>', 0, 1, 0 },
1667 { "N3", "Apollo Aegis", 1, '/', 0, 3, 2 },
1668 { "U1", "UNIX", 1, '/', 0, 3, 2 },
1669 { "U8", "MS-DOS", 1, '\\', 1, 0, 3 },
1670 { "UD", "OS-9", 1, '/', 0, 3, 2 },
1671 { "UN", "Windows-32", 1, '\\', 1, 2, 3 },
1672 { "UO", "OS/2", 1, '\\', 1, 2, 3 }
1674 static int nxxsysids = (sizeof(sysidlist) / sizeof(struct sysdata));
1676 /* Given a Kermit system ID code, return the associated name string */
1677 /* and some properties of the filenames... */
1680 getsysid(s) char * s; { /* Get system-type name */
1683 for (i = 0; i < nxxsysids; i++)
1684 if (!strcmp(sysidlist[i].sid_code,s))
1685 return(sysidlist[i].sid_name);
1690 getsysix(s) char *s; { /* Get system-type index */
1693 for (i = 0; i < nxxsysids; i++)
1694 if (!strcmp(sysidlist[i].sid_code,s))
1700 /* Tell if a pathname is absolute (versus relative) */
1701 /* This should be parceled out to each of the ck*fio.c modules... */
1703 isabsolute(path) char * path; {
1710 x = (int) strlen(path);
1711 debug(F111,"isabsolute",path,x);
1714 x = ckindex("[",path,0,0,0); /* 1-based */
1716 x = ckindex("<",path,0,0,0);
1717 debug(F111,"isabsolute left bracket",path,x);
1719 x = ckindex(":",path,-1,1,1);
1721 debug(F111,"isabsolute logical",path,x);
1724 if (path[x] != '.') /* 0-based */
1736 if (*path == '/' || *path == '\\')
1738 else if (isalpha(*path) && x > 2)
1739 if (*(path+1) == ':' && (*(path +2) == '/' || *(path+2) == '\\'))
1763 rc = 0; /* Fill in later... */
1766 rc = 0; /* Fill in later... */
1769 if (*path == '/' || *path == '\\')
1771 else if (isalpha(*path) && x > 1)
1772 if (*(path+1) == ':')
1775 #endif /* STRATUS */
1777 #endif /* datageneral */
1783 debug(F101,"isabsolute rc","",rc);
1787 /* See if I have direct access to the keyboard */
1790 is_a_tty(n) int n; {
1818 extern char * sndexcept[], * rcvexcept[];
1820 for (i = 0; i < NSNDEXCEPT; i++) {
1821 sndexcept[i] = NULL;
1822 rcvexcept[i] = NULL;
1827 /* Initialize flow control table */
1830 initflow() { /* Default values for flow control */
1831 #ifdef VMS /* for each kind of connection. */
1832 /* The VMS telnet terminal driver treats "none" as request to lose chars */
1833 cxflow[CXT_REMOTE] = FLO_XONX; /* Remote mode... */
1836 /* Ditto for HP-UX */
1837 cxflow[CXT_REMOTE] = FLO_XONX; /* Remote mode... */
1839 /* The temptation is to make this one FLO_KEEP but don't!!! */
1840 /* It totally wrecks binary-file transfer when coming in via Telnet. */
1841 /* In UNIX at least... */
1842 cxflow[CXT_REMOTE] = FLO_NONE;
1847 cxflow[CXT_DIRECT] = FLO_XONX; /* Direct serial connections... */
1849 cxflow[CXT_DIRECT] = FLO_NONE;
1853 cxflow[CXT_MODEM] = FLO_RTSC; /* Modem connections... */
1856 cxflow[CXT_MODEM] = FLO_XONX;
1858 cxflow[CXT_MODEM] = FLO_NONE;
1860 #endif /* CK_RTSCTS */
1863 cxflow[CXT_TCPIP] = FLO_XONX; /* TCP/IP connections... */
1865 cxflow[CXT_TCPIP] = FLO_NONE;
1868 cxflow[CXT_SSH] = FLO_NONE;
1869 cxflow[CXT_X25] = FLO_NONE; /* Other kinds of networks... */
1870 cxflow[CXT_DECNET] = FLO_XONX;
1871 cxflow[CXT_LAT] = FLO_XONX;
1872 cxflow[CXT_NETBIOS] = FLO_NONE;
1873 cxflow[CXT_NPIPE] = FLO_NONE;
1874 cxflow[CXT_PIPE] = FLO_NONE;
1875 flow = cxflow[cxtype]; /* Initial flow setting. */
1876 debug(F101,"initflow","",flow);
1880 /* Initialize file transfer protocols */
1883 initproto(y, upbstr, uptstr, srvstr, sndbstr, sndtstr, rcvbstr, rcvtstr)
1885 char * upbstr, * uptstr, * srvstr, * sndbstr, * sndtstr, * rcvbstr,
1889 if (upbstr) /* Convert null strings */
1890 if (!*upbstr) /* to null pointers */
1893 if (uptstr) /* Convert null strings */
1894 if (!*uptstr) /* to null pointers */
1917 protocol = y; /* Set protocol */
1919 if (ptab[protocol].rpktlen > -1)
1920 urpsiz = ptab[protocol].rpktlen;
1921 if (ptab[protocol].spktflg > -1)
1922 spsizf = ptab[protocol].spktflg;
1923 if (ptab[protocol].spktlen > -1) {
1924 spsiz = ptab[protocol].spktlen;
1925 debug(F101,"initproto spsiz","",spsiz);
1927 spsizr = spmax = spsiz;
1928 debug(F101,"initproto spsizr","",spsizr);
1931 if (ptab[protocol].winsize > -1)
1932 wslotr = ptab[protocol].winsize;
1933 if (ptab[protocol].prefix > -1)
1934 prefixing = ptab[protocol].prefix;
1935 if (ptab[protocol].fnca > -1)
1936 fncact = ptab[protocol].fnca;
1937 if (ptab[protocol].fncn > -1)
1938 fncnv = ptab[protocol].fncn;
1939 if (ptab[protocol].fnsp > -1)
1940 fnspath = ptab[protocol].fnsp;
1941 if (ptab[protocol].fnrp > -1)
1942 fnrpath = ptab[protocol].fnrp;
1944 makestr(&(ptab[protocol].h_b_init),upbstr);
1945 makestr(&(ptab[protocol].h_t_init),uptstr);
1946 makestr(&(ptab[protocol].h_x_init),srvstr);
1947 makestr(&(ptab[protocol].p_b_scmd),sndbstr);
1948 makestr(&(ptab[protocol].p_t_scmd),sndtstr);
1949 makestr(&(ptab[protocol].p_b_rcmd),rcvbstr);
1950 makestr(&(ptab[protocol].p_t_rcmd),rcvtstr);
1957 docmdline(void * threadinfo)
1958 #else /* CK_ANSIC */
1959 docmdline(threadinfo) VOID * threadinfo;
1960 #endif /* CK_ANSIC */
1964 if (threadinfo) { /* Thread local storage... */
1965 TlsSetValue(TlsIndex,threadinfo);
1966 debug( F100, "docmdline called with threadinfo block", "", 0 );
1968 debug( F100, "docmdline threadinfo is NULL","",0);
1977 #endif /* CK_LOGIN */
1978 proto(); /* Take any requested action, then */
1979 if (!quiet) /* put cursor back at left margin, */
1982 if (cnflg) { /* Re-connect if requested */
1988 #endif /* NOLOCAL */
1991 ckThreadEnd(threadinfo);
2000 || inserver /* Internet server */
2004 extern int fdispla; /* File-transfer display format */
2005 extern char * ikprompt; /* IKSD prompt */
2010 x_login = 1; /* Login required */
2011 x_logged = 0; /* Not logged in yet */
2012 cmsetp(ikprompt); /* Set up IKSD's prompt */
2014 en_mai = 0; /* MAIL is disabled */
2015 en_who = 0; /* REMOTE WHO is disabled */
2016 en_hos = 0; /* REMOTE HOST is disabled */
2017 en_pri = 0; /* PRINT is disabled */
2018 #endif /* NOSERVER */
2020 x_login = 0; /* Login not required */
2021 x_logged = 1; /* Already logged in */
2023 #endif /* CK_LOGIN */
2025 nolocal = 1; /* SET LINE/HOST not allowed */
2026 fdispla = XYFD_N; /* No file-transfer display */
2028 clienthost = ckgetpeer(); /* Get client's hostname */
2029 debug(F110,"ikslogin clienthost",clienthost,0);
2030 #endif /* NETCONN */
2031 ztime(&s); /* Get current date and time */
2034 #ifdef CK_AUTHENTICATION
2036 x_logged = ck_tn_auth_valid(); /* Did Telnet Auth succeed? */
2037 debug(F111,"ikslogin","x_logged",x_logged);
2040 /* On Windows 9x, we do not have the ability in */
2041 /* zvuser() at present to determine if the name */
2042 /* approved in a Kerberos principal is really a */
2043 /* an account in the Windows Access Control List */
2044 if (isWin95() && x_logged == AUTH_VALID
2045 && (ck_tn_authenticated() != AUTHTYPE_NTLM)
2047 && (ck_tn_authenticated() != AUTHTYPE_SRP)
2050 auth_finished(AUTH_USER);
2051 x_logged = AUTH_USER;
2052 printf("WARNING:\r\n");
2054 " The Telnet authentication method used cannot provide for automated\r\n");
2056 " login to Windows 95 or Windows 98. A password must be entered\r\n");
2058 " locally to validate your userid. Telnet authentication (and encryption)\r\n"
2061 " can be used to validate the host (and protect the privacy of your password.)\
2067 if (x_logged == AUTH_VALID) {
2069 if ((ssl_active_flag || tls_active_flag) &&
2070 (!TELOPT_U(TELOPT_AUTHENTICATION) ||
2071 ck_tn_authenticated() == AUTHTYPE_NULL ||
2072 ck_tn_authenticated() == AUTHTYPE_AUTO)
2075 if (tls_is_krb5(0)) {
2076 printf("Authenticated using Kerberos 5\r\n");
2078 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2079 extern char szUserNameAuthenticated[];
2080 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2082 szUserNameAuthenticated
2085 #endif /* CKSYSLOG */
2087 #endif /* SSL_KRB5 */
2089 printf("Authenticated using X.509 certificate\r\n");
2091 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2092 extern char szUserNameAuthenticated[];
2093 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2094 "X.509 certificate",
2095 szUserNameAuthenticated
2098 #endif /* CKSYSLOG */
2103 printf("Authenticated using %s\r\n",
2104 AUTHTYPE_NAME(ck_tn_authenticated()));
2106 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2107 extern char szUserNameAuthenticated[];
2108 cksyslog(SYSLG_LI, 1, "AUTH_VALID",
2109 AUTHTYPE_NAME(ck_tn_authenticated()),
2110 szUserNameAuthenticated
2113 #endif /* CKSYSLOG */
2116 if (zvpass("") == 0)
2118 } else if (x_logged == AUTH_USER && !strcmp(uidbuf,"anonymous")) {
2119 extern char szUserNameAuthenticated[];
2121 debug(F110,"szUserNameAuthenticated",
2122 szUserNameAuthenticated,0);
2123 if (zvpass(szUserNameAuthenticated) == 0) {
2124 /* Anonymous login failed. Force a username prompt. */
2129 if ((ssl_active_flag || tls_active_flag) &&
2130 (!TELOPT_U(TELOPT_AUTHENTICATION) ||
2131 ck_tn_authenticated() == AUTHTYPE_NULL ||
2132 ck_tn_authenticated() == AUTHTYPE_AUTO)) {
2133 printf("Authenticated using X.509 certificate\r\n");
2135 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2136 extern char szUserNameAuthenticated[];
2137 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2138 "X.509 certificate",
2139 szUserNameAuthenticated
2142 #endif /* CKSYSLOG */
2146 printf("Authenticated using %s\r\n",
2147 AUTHTYPE_NAME(ck_tn_authenticated())
2150 if (ckxsyslog >= SYSLG_LI && ckxlogging) {
2151 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2152 AUTHTYPE_NAME(ck_tn_authenticated()),
2153 szUserNameAuthenticated
2156 #endif /* CKSYSLOG */
2161 if (ckxsyslog >= SYSLG_LI && ckxlogging &&
2162 x_logged == AUTH_USER) {
2163 extern char szUserNameAuthenticated[];
2164 cksyslog(SYSLG_LI, 1, "AUTH_USER",
2165 AUTHTYPE_NAME(ck_tn_authenticated()),
2166 szUserNameAuthenticated
2169 #endif /* CKSYSLOG */
2171 if (!strcmp("(unknown)",uidbuf)
2173 || !stricmp("administrator",uidbuf)
2175 || !strcmp("root",uidbuf)
2178 || !strcmp("root",uidbuf)
2181 || !strcmp("root",uidbuf)
2190 #endif /* CK_AUTHENTICATION */
2191 #endif /* CK_LOGIN */
2195 printf("\r\nInternet Kermit Service ready at %s%s\r\n",s,versio);
2198 printf("\r\nC-Kermit ready at %s%s\r\n",s,versio);
2200 printf("%s\r\n", myhost);
2207 extern int arg_x; /* Flag for '-x' on command line */
2209 extern struct mtab *mactab; /* For ON_LOGIN macro. */
2213 debug(F110,"MAIN clienthost",clienthost,0);
2214 srvidl = timelimit = logintimo; /* For interactive login */
2215 rtimer(); /* Reset timer */
2216 for (i = 0; i < iks_retry && !x_logged; i++) { /* Count retries */
2217 if (gtimer() > logintimo)
2220 tn_wait("login loop");
2223 debug(F101,"MAIN LOGIN try","",i);
2224 what = W_NOTHING; /* Because proto() changes this */
2227 debug(F111,"MAIN LOGIN",
2228 "TELOPT_SB(TELOPT_KERMIT).kermit.me_start",
2229 TELOPT_SB(TELOPT_KERMIT).kermit.me_start
2231 /* Kermit server negotiated */
2232 if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {
2233 debug(F101,"IKSD starting in server mode","",0);
2234 arg_x = 1; /* Enter server mode */
2237 justone = 1; /* Execute one command at a time. */
2238 #endif /* IKSDPOPBACK */
2239 proto(); /* Enter protocol if requested. */
2243 if (x_logged) /* Logged in */
2245 } else { /* Not in client/server mode */
2246 #endif /* IKS_OPTION */
2247 debug(F101,"IKSD starting with Username prompt","",0);
2248 x_logged = ckxlogin((CHAR *)uidbuf,NULL,NULL,1);
2249 if (sstate) { /* Received a packet at prompt */
2251 justone = 1; /* Go handle it */
2252 #endif /* IKSDPOPBACK */
2255 if (!x_logged) { /* In case we are at the prompt... */
2256 printf("Access denied.\n");
2257 uidbuf[0] = '\0'; /* Forget the name if we have one */
2261 #endif /* IKS_OPTION */
2263 srvidl = timelimit = iks_timo; /* Reset command timelimit */
2264 debug(F101,"MAIN LOGIN","",x_logged);
2265 if (!x_logged) { /* Logins failed. */
2266 if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
2267 errpkt((CHAR *)"Login Timeout");
2271 what = W_NOTHING; /* Stay in known state */
2274 en_pri = 0; /* No printing for anonymous users */
2275 en_mai = 0; /* No email for anonymous users */
2276 en_mkd = 0; /* Or directory creation */
2277 en_rmd = 0; /* Or directory removal */
2278 en_ena = 0; /* Or ENABLing DISABLEd items */
2280 #endif /* NOSERVER */
2284 If a macro named "on_login" is defined, execute it. Also remove it from the
2285 macro table so the user cannot see what it does. Execute it as part of the
2288 if (nmac) { /* Any macros defined? */
2290 char * cmd = "on_login"; /* MSVC 2.x compiler error */
2291 k = mlook(mactab,cmd,nmac); /* Look up "on_exit" */
2292 if (k >= 0) { /* If found, */
2296 #endif /* IKSDCONF */
2297 if (dodo(k,"",0) > -1) /* set it up, */
2298 parser(1); /* execute it */
2301 #endif /* IKSDCONF */
2302 delmac(cmd,1); /* and delete it */
2306 } /* if (inserver) */
2307 #else /* CK_LOGIN */
2309 srvidl = timelimit = iks_timo; /* Set idle limits for IKS */
2310 #endif /* CK_LOGIN */
2316 failcmdline(void * foo)
2317 #else /* CK_ANSIC */
2318 failcmdline(foo) VOID * foo;
2319 #endif /* CK_ANSIC */
2325 if (cnflg) doconect(0,0); /* connect again if requested. */
2328 #endif /* NOLOCAL */
2335 dotakeini(void * threadinfo) /* Execute init file. */
2336 #else /* CK_ANSIC */
2337 dotakeini(threadinfo) VOID * threadinfo; /* Execute init file. */
2338 #endif /* CK_ANSIC */
2342 if (threadinfo) { /* Thread local storage... */
2343 TlsSetValue(TlsIndex,threadinfo);
2344 debug(F100, "dotakeini called with threadinfo block","", 0);
2346 debug(F100, "dotakeini - threadinfo is NULL", "", 0);
2355 #endif /* CK_LOGIN */
2356 cmdini(); /* Sets tlevel */
2358 debug(F111,"dotakeini","inserver",inserver);
2359 debug(F111,"dotakeini","sstelnet",sstelnet);
2362 /* Wrong place for this... */
2365 dofast(); /* By now FAST defaults should be OK */
2366 #endif /* CK_FAST */
2368 #endif /* COMMENT */
2370 doinit(); /* Now do the initialization file */
2371 debug(F101,"main executing init file","",tlevel);
2372 while (tlevel > -1) {
2373 sstate = (CHAR) parser(1); /* Execute one command at a time. */
2374 if (sstate) proto(); /* Enter protocol if requested. */
2379 debug(F101,"main exits init file","",tlevel);
2382 ckThreadEnd(threadinfo);
2389 failtakeini(void * threadinfo)
2390 #else /* CK_ANSIC */
2391 failtakeini(threadinfo) VOID * threadinfo;
2392 #endif /* CK_ANSIC */
2395 cc_clean(); /* Atari: Clean up after ^C-trap. */
2398 conoll("Interrupt during initialization or command-line processing.");
2399 conoll("C-Kermit quitting...");
2401 doexit(BAD_EXIT,-1); /* Exit with bad status. */
2406 doicp(void * threadinfo)
2407 #else /* CK_ANSIC */
2408 doicp(threadinfo) VOID * threadinfo;
2409 #endif /* CK_ANSIC */
2413 if (threadinfo) { /* Thread local storage... */
2414 if (!TlsSetValue(TlsIndex,threadinfo))
2415 debug(F101,"doicp TlsSetValue failed","",GetLastError());
2416 debug(F101, "doicp a threadinfo block - TlsIndex", "", TlsIndex);
2418 debug(F100, "doicp received a null threadinfo", "", 0);
2428 #endif /* CK_LOGIN */
2431 extern char *lfiles; /* Fake pointer cast */
2434 debug(F100, "doicp: calling macparser", "", 0);
2435 sstate = newparser(1, 1, 0L);
2437 /* ignore null command state */
2445 * process take files the finder gave us.
2447 if ((tlevel == -1) && lfiles)
2450 debug(F100, "doicp: calling parser", "", 0);
2451 sstate = (CHAR) parser(0);
2452 if (sstate == 'c') /* if MAC connect */
2462 If interactive commands were given on the command line (using the
2463 -C "command, command, ..." option), assign them to a macro called
2464 "cl_commands", then execute the macro and leave it defined for
2465 subsequent re-execution if desired.
2467 if (clcmds) { /* Check for -C commands */
2469 x = addmac("cl_commands",clcmds); /* Put macro in table */
2470 if (x > -1) { /* If successful, */
2471 dodo(x,NULL,CF_CMDL); /* set up for macro execution */
2472 while (maclvl > -1) { /* Loop getting macro commands. */
2473 sstate = (CHAR) parser(1);
2474 if (sstate) proto(); /* Enter protocol if requested. */
2480 debug(F100,"doicp calling herald","",0);
2484 while(1) { /* Loop getting commands. */
2485 sstate = (CHAR) parser(0);
2486 if (sstate) proto(); /* Enter protocol if requested. */
2492 ckThreadEnd(threadinfo);
2499 failicp(void * threadinfo)
2500 #else /* CK_ANSIC */
2501 failicp(threadinfo) VOID * threadinfo;
2502 #endif /* CK_ANSIC */
2507 fixcmd(); /* Pop command stacks, etc. */
2509 debug(F100,"ckcmai got interrupt","",0);
2516 docmdfile(void * threadinfo) /* Execute application file */
2517 #else /* CK_ANSIC */
2518 docmdfile(threadinfo) VOID * threadinfo;
2519 #endif /* CK_ANSIC */
2522 concb((char)escape);
2524 if (threadinfo) { /* Thread local storage... */
2525 TlsSetValue(TlsIndex,threadinfo);
2526 debug(F100, "docmdfile called with threadinfo block","", 0);
2527 } else debug(F100, "docmdfile - threadinfo is NULL", "", 0);
2536 #endif /* CK_LOGIN */
2537 debug(F110,"main cmdfil",cmdfil,0);
2539 addmac("\\%0",cmdfil);
2541 dotake(cmdfil); /* execute it */
2542 while (tlevel > -1) { /* until it runs out. */
2543 sstate = parser(1); /* Loop getting commands. */
2544 if (sstate) proto(); /* Enter protocol if requested. */
2549 cfilef = 1; /* Remember we did this */
2552 ckThreadEnd(threadinfo);
2559 failcmdfile(void * threadinfo)
2560 #else /* CK_ANSIC */
2561 failcmdfile(threadinfo) VOID * threadinfo;
2562 #endif /* CK_ANSIC */
2565 cc_clean(); /* Atari: Clean up after ^C-trap. */
2568 conoll("Interrupt during initialization or command-line processing.");
2569 conoll("C-Kermit quitting...");
2571 doexit(BAD_EXIT,-1); /* Exit with bad status. */
2577 setprefix(z) int z; { /* Initial control-char prefixing */
2582 ptab[protocol].prefix = prefixing;
2583 debug(F101,"setprefix","",prefixing);
2585 case PX_ALL: /* All */
2587 /* Don't let Clear-Channel be dependent on prefixing */
2588 clearrq = 0; /* Turn off clearchannel, fall thru */
2589 #endif /* COMMENT */
2590 case PX_NON: /* None */
2591 val = (z == PX_ALL) ? 1 : 0;
2597 #endif /* UNPREFIXZERO */
2600 for (i = 127; i < 160; i++) ctlp[i] = val;
2601 ctlp[(unsigned)255] = val;
2602 if (z == PX_NON) { /* These are never safe */
2603 if (network) { /* Assume network = telnet or rlogin */
2604 ctlp[CR] = 1; /* Prefix CR because of NVT rules */
2605 ctlp[XON] = ctlp[XOFF] = 1; /* Because of Telnet server */
2606 ctlp[127] = ctlp[255] = 1; /* Telnet IAC */
2607 ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit packet start */
2609 ctlp[CR] = ctlp[255] = ctlp[mystch] = ctlp[mystch+128] = 1;
2610 if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
2611 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
2616 case PX_CAU: /* Cautious or Minimal */
2618 /* Don't let CLEAR-CHANNEL be dependent on Prefixing */
2619 clearrq = 0; /* Turn off clearchannel */
2620 #endif /* COMMENT */
2621 case PX_WIL: /* Minimal ("wild") */
2622 ctlp[0] = 1; /* Does not include 0 */
2623 for (i = 1; i < 32; i++)
2625 for (i = 127; i < 160; i++)
2627 ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit start of packet */
2629 ctlp[seol] = ctlp[seol+128] = 1; /* Kermit end */
2630 ctlp[13] = ctlp[141] = 1; /* In case of TELNET (NVT rules) */
2631 ctlp[(unsigned)255] = 1; /* Ditto */
2633 /* ^D, ^J, ^M, or ^U followed by tilde trigger Rlogin escape */
2635 ctlp[4] = ctlp[4+128] = 1; /* In case of RLOGIN */
2636 ctlp[10] = ctlp[10+128] = 1; /* In case of RLOGIN */
2637 ctlp[21] = ctlp[21+128] = 1; /* In case of RLOGIN */
2639 if (flow == FLO_XONX || /* Xon/Xoff forces prefixing these */
2640 prefixing == PX_CAU || /* So does CAUTIOUS */
2641 network) /* Networks too... */
2642 ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
2643 if (prefixing == PX_CAU) { /* Cautious - add some more */
2646 #endif /* UNPREFIXZERO */
2647 ctlp[3] = ctlp[16] = 1; /* ^C, DLE */
2648 ctlp[14] = ctlp[15] = 1; /* SO/SI */
2649 ctlp[24] = ctlp[25] = 1; /* VMS might need these */
2650 ctlp[26] = ctlp[26+128] = 1; /* UNIX suspend */
2651 ctlp[28] = ctlp[29] = ctlp[30] = 1; /* Assorted esc chars */
2652 ctlp[131] = ctlp[141] = ctlp[144] = 1; /* and 8-bit versions */
2653 ctlp[(unsigned)255] = ctlp[156] = ctlp[157] = ctlp[158] = 1;
2657 #endif /* CK_SPEED */
2662 makever() { /* Make version string from pieces */
2666 ck_s_xver = ck_s_ver; /* Fill in C-Kermit version number */
2667 ck_l_xver = ck_l_ver; /* for UNIX, VMS, etc. */
2670 x = strlen(ck_s_name);
2671 y = strlen(ck_s_xver);
2672 if (y + x + 1 < CKVERLEN) {
2673 ckmakmsg(versio,CKVERLEN,ck_s_name," ",ck_s_xver,NULL);
2675 ckstrncpy(versio,"C-Kermit",CKVERLEN);
2680 y = strlen(ck_s_who);
2681 if (CKVERLEN < x + y + 1)
2683 ckstrncat(versio,"-",CKVERLEN);
2684 ckstrncat(versio,ck_s_who,CKVERLEN);
2687 y = strlen(ck_s_test);
2688 if (y > 0 && y + x + 1 < CKVERLEN) {
2689 ckstrncat(versio," ",CKVERLEN);
2690 ckstrncat(versio,ck_s_test,CKVERLEN);
2692 y = strlen(ck_s_tver);
2693 if (y > 0 && y + x + 1 < CKVERLEN) {
2694 ckstrncat(versio,".",CKVERLEN);
2695 ckstrncat(versio,ck_s_tver,CKVERLEN);
2699 y = strlen(ck_s_date);
2700 if (y > 0 && y + x + 2 < CKVERLEN) {
2701 ckstrncat(versio,", ",CKVERLEN);
2702 ckstrncat(versio,ck_s_date,CKVERLEN);
2705 xvernum = ck_l_xver;
2706 debug(F110,"Kermit version",versio,0);
2709 union ck_short shortbytes; /* For determining byte order */
2710 int byteorder = 0; /* 0 = Big Endian; 1 = Little Endian */
2712 /* NOTE: MUST BE 0 or 1 - nothing else */
2715 #define SCRIPTLEN 10240
2725 extern int ttnproto;
2726 extern struct urldata g_url;
2729 /* NOTE: debug() doesn't work yet - must use printf's */
2730 printf("URL: %s\n",g_url.sav ? g_url.sav : "(none)");
2731 printf("Type: %s\n",g_url.svc ? g_url.svc : "(none)");
2732 printf("User: %s\n",g_url.usr ? g_url.usr : "(none)");
2733 printf("Pass: %s\n",g_url.psw ? g_url.psw : "(none)");
2734 printf("Host: %s\n",g_url.hos ? g_url.hos : "(none)");
2735 /* printf("Port: %s\n",g_url.por ? g_url.por : "(none)"); */
2736 printf("Path: %s\n",g_url.pth ? g_url.pth : "(none)");
2737 #endif /* COMMENT */
2739 if (!ckstrcmp(g_url.svc,"iksd",-1,0) ||
2740 !ckstrcmp(g_url.svc,"kermit",-1,0)) {
2741 extern char pwbuf[];
2748 printf("?Incomplete IKSD URL\n");
2752 makestr(&g_url.usr,"anonymous");
2754 char * tmpbuf = NULL;
2755 if (!(tmpbuf = (char *)malloc(1024)))
2756 fatal("dourl: out of memory");
2757 if (!ckstrcmp(g_url.usr,"anonymous",-1,0)) {
2758 ckmakmsg(tmpbuf,1024,uidbuf,"@",myhost,NULL);
2759 makestr(&g_url.psw,tmpbuf);
2761 readpass(" Password:",tmpbuf,1024);
2762 makestr(&g_url.psw,tmpbuf);
2767 ttnproto = NP_TELNET;
2771 ckstrncpy(uidbuf,g_url.usr,UIDBUFLEN);
2773 ckstrncpy(pwbuf,g_url.psw,PWBUFL);
2783 g_url.por ? g_url.por : port,
2786 rc = ttopen(ttname,&local,mdmtyp,0);
2792 #endif /* CKLOGDIAL */
2794 printf("?Connection failed: %s\n",g_url.sav);
2797 /* Also need to check here for secure authentication already done */
2803 char * script = NULL;
2804 if (!(script = (char *)malloc(SCRIPTLEN)))
2805 fatal("dourl: out of memory");
2806 if (!g_url.pth) { /* Write the appropriate script */
2808 ckmakxmsg(script,SCRIPTLEN,
2809 "if not eq {\\v(authstate)} {user} ",
2810 "if not eq {\\v(authstate)} {valid} { ",
2811 "remote login ", /* No path */
2812 g_url.usr, /* Just log in and CONNECT */
2815 ", if fail exit 1 {IKSD login failed} }",
2817 NULL,NULL,NULL,NULL);
2818 /* printf("CLCMDS 1: %s\n",script); */
2820 /* does the path specify a file or a directory? */
2821 int len = strlen(g_url.pth);
2822 if (ISDIRSEP(g_url.pth[len-1])) {
2823 ckmakxmsg(script,SCRIPTLEN, /* Directory name given */
2824 "if not eq {\\v(authstate)} {user} \
2825 if not eq {\\v(authstate)} {valid} { remote login ",
2829 ", if fail exit 1 {IKSD login failed} }",
2830 ", set macro error on",
2831 ", set xfer displ brief",
2832 ", set xfer bell off",
2835 ", lineout directory",
2838 /* printf("CLCMDS 2: %s\n",script); */
2840 ckmakxmsg(script,SCRIPTLEN, /* Path given, try to GET */
2841 "if not eq {\\v(authstate)} {user} \
2842 if not eq {\\v(authstate)} {valid} { remote login ",
2846 ", if fail exit 1 {IKSD login failed} }",
2847 ", set xfer displ brief",
2848 ", set xfer bell off",
2851 ", .rc := \\v(status)",
2852 ", if open connection bye",
2855 /* printf("CLCMDS 2: %s\n",script); */
2858 clcmds = script; /* Make this our -C cmdline macro */
2859 /* printf("HAVEURL=%d\n",haveurl); */
2863 if (ckstrcmp(g_url.svc,"telnet",-1,0) &&
2865 ckstrcmp(g_url.svc,"ssh",-1,0) &&
2866 #endif /* SSHBUILTIN */
2867 ckstrcmp(g_url.svc,"ftp",-1,0)) {
2868 printf("?Sorry, %s URLs not supported\n",
2869 g_url.svc ? g_url.svc : "");
2875 #endif /* NETCONN */
2881 If you get complaints about "main: return type is not blah",
2882 define MAINTYPE on the CC command line, e.g. "CFLAGS=-DMAINTYPE=blah"
2883 (where "blah" is int, long, or whatever).
2885 If the complaint is "Attempt to return a value from a function of type void"
2886 then add -DMAINISVOID.
2890 #define MAINTYPE int
2891 #endif /* MAINISVOID */
2892 #endif /* MAINTYPE */
2896 #define MAINTYPE void
2897 #endif /* MAINTYPE */
2898 #endif /* MAINISVOID */
2901 /* On the Apollo, intercept main to insert a cleanup handler */
2903 ckcmai(argc,argv) int argc; char **argv;
2905 #ifdef MAC /* Macintosh */
2909 #ifdef __GNUC__ /* GCC compiler */
2911 main(argc,argv) int argc; char **argv;
2913 #ifdef __DECC /* DEC Alpha with DEC C compiler */
2916 main(argc,argv) int argc; char **argv;
2917 #else /* DEC C compiler, not Alpha */
2920 main(argc,argv) int argc; char **argv;
2921 #endif /* __ALPHA */
2923 #ifdef STRATUS /* Stratus VOS */
2925 main(argc,argv) int argc; char **argv;
2931 Main( int argc, char ** argv )
2935 main(argc,argv) int argc; char **argv;
2938 MAINTYPE /* All others... */
2939 main(argc,argv) int argc; char **argv;
2941 #endif /* STRATUS */
2943 #endif /* __GNUC__ */
2953 #endif /* NOSETKEY */
2956 short *pfha = 016000000036; /* Get around LANG_RT problem */
2957 *pfha = (short) 0; /* No user protection fault handler */
2958 #endif /* datageneral */
2960 /* Do some initialization */
2963 xargc = xargs = argc; /* Make global copies of argc */
2964 xargv = argv; /* ...and argv. */
2969 zstrip(argv[0],&p); /* Get name we were invoked with */
2971 if (!ckstrcmp(myname,"telnet",-1,0)) howcalled = I_AM_TELNET;
2973 else if (!ckstrcmp(myname,"ktelnet",-1,0)) howcalled = I_AM_TELNET;
2974 #endif /* CK_KERBEROS */
2975 else if (!ckstrcmp(myname,"rlogin",-1,0)) howcalled = I_AM_RLOGIN;
2976 else if (!ckstrcmp(myname,"iksd",-1,0)) howcalled = I_AM_IKSD;
2978 else if (!ckstrcmp(myname,"ftp",-1,0)) howcalled = I_AM_FTP;
2981 else if (!ckstrcmp(myname,"http",-1,0)) howcalled = I_AM_HTTP;
2984 else if (!ckstrcmp(myname,"telnet.exe",-1,0)) howcalled = I_AM_TELNET;
2986 else if (!ckstrcmp(myname,"ssh",-1,0)) howcalled = I_AM_SSH;
2987 else if (!ckstrcmp(myname,"ssh.exe",-1,0)) howcalled = I_AM_SSH;
2988 #endif /* SSHBUILTIN */
2990 else if (!ckstrcmp(myname,"ktelnet.exe",-1,0)) howcalled = I_AM_TELNET;
2991 #endif /* CK_KERBEROS */
2992 else if (!ckstrcmp(myname,"rlogin.exe",-1,0)) howcalled = I_AM_RLOGIN;
2994 else if (!ckstrcmp(myname,"iksdnt",-1,0)) howcalled = I_AM_IKSD;
2995 else if (!ckstrcmp(myname,"iksdnt.exe",-1,0)) howcalled = I_AM_IKSD;
2998 else if (!ckstrcmp(myname,"ftp.exe",-1,0)) howcalled = I_AM_FTP;
3001 else if (!ckstrcmp(myname,"http.exe",-1,0)) howcalled = I_AM_HTTP;
3004 else if (!ckstrcmp(myname,"kermit-sshsub",-1,0)) howcalled = I_AM_SSHSUB;
3007 cmdini(); /* Must come before prescan */
3008 debug(F100,"main cmdini() done","",0);
3010 prescan(0); /* Pre-Check for debugging, etc */
3012 debug(F101,"MAIN feol","",feol);
3013 makever(); /* Put together version strings */
3014 #ifndef NOSETKEY /* Allocate & initialize the keymap */
3015 /* This code has been moved to before sysinit() for K95G */
3016 if (!(keymap = (KEY *) malloc(sizeof(KEY)*KMSIZE)))
3017 fatal("main: no memory for keymap");
3018 if (!(macrotab = (MACRO *) malloc(sizeof(MACRO)*KMSIZE)))
3019 fatal("main: no memory for macrotab");
3020 for (i = 0; i < KMSIZE; i++) {
3021 keymap[i] = (KEY) i;
3024 #endif /* NOSETKEY */
3026 shortbytes.x_short = 0xABCD; /* Get Endianness */
3027 if (shortbytes.x_char[0] == 0xCD) { /* 0 = Big Endian */
3028 byteorder = 1; /* 1 = Little Endian */
3029 bigendian = 0; /* (for clarity in programming) */
3031 byteorder = 0; /* Big Endian */
3034 if (sysinit() < 0) /* System-dependent initialization. */
3035 fatal("Can't initialize!");
3037 initflg = 1; /* Remember we did. */
3038 debug(F111,"ckcmai myname",myname,howcalled);
3041 getexedir(); /* Compute exedir variable */
3047 If built with -DSYSLOGLEVEL on cc command line, this means we always
3048 do syslogging at the indicated level.
3050 zsyslog(); /* Open syslog */
3051 #else /* SYSLOGLEVEL */
3054 zsyslog(); /* Open syslog */
3056 #endif /* SYSLOGLEVEL */
3057 #endif /* CKSYSLOG */
3060 ini_kerb(); /* Initialize Kerberos data */
3061 #endif /* CK_KERBEROS */
3066 tn_set_modes(); /* Init Telnet Option tables */
3069 #ifdef CK_TTGWSIZ /* Initialize screen dimensions */
3073 if (ttgwsiz() > 0) {
3074 if (tt_rows > 0 && tt_cols > 0) {
3080 #endif /* CK_TTGWSIZ */
3085 SOCKSinit(argv[0]); /* Internet relay package... */
3086 #endif /* CK_SOCKS */
3087 #endif /* TCPSOCKET */
3090 initflow(); /* Initialize flow-control table */
3094 initfloat(); /* Deduce floating-point precision */
3095 #endif /* CKFLOAT */
3099 initxlist(); /* Init exception lists */
3101 #ifdef CK_XYZ /* Initialize protocols... */
3103 #ifdef XYZ_INTERNAL /* XYZMODEM are internal ... */
3106 /* Can't do this for XMODEM because if filename contains a "C" etc... */
3107 initproto(PROTO_X, "rx %s","rx %s", NULL, NULL, NULL, NULL, NULL);
3108 initproto(PROTO_XC,"rc %s","rc %s", NULL, NULL, NULL, NULL, NULL);
3110 initproto(PROTO_X, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3111 initproto(PROTO_XC,NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3112 #endif /* COMMENT */
3113 initproto(PROTO_Y, "rb","rb", NULL, NULL, NULL, NULL, NULL);
3114 initproto(PROTO_G, "rb","rb", NULL, NULL, NULL, NULL, NULL);
3115 initproto(PROTO_Z, "rz","rz", NULL, NULL, NULL, NULL, NULL);
3116 initproto(PROTO_K,"kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3117 /* Kermit Must be last */
3119 #else /* XYZMODEM are external protocols ... */
3121 /* s1 s2 s3 s4 s5 s6 s7 */
3122 initproto(PROTO_X, "rx %s","rx %s",NULL,"sx %s","sx -a %s","rx %s", "rx %s");
3123 initproto(PROTO_XC,"rc %s","rc %s",NULL,"sx %s","sx -a %s","rc %s", "rc %s");
3124 initproto(PROTO_Y, "rb", "rb", NULL,"sb %s","sb -a %s","rb", "rb" );
3125 initproto(PROTO_G, "rb", "rb", NULL,"sb %s","sb -a %s","rb", "rb" );
3126 initproto(PROTO_Z, "rz", "rz", NULL,"sz %s","sz -a %s","rz", "rz" );
3127 initproto(PROTO_K, "kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3128 /* Kermit must be last */
3130 #endif /* XYZ_INTERNAL */
3132 #else /* No XYZMODEM support */
3134 initproto(PROTO_K,"kermit -ir","kermit -r","kermit -x",NULL,NULL,NULL,NULL);
3139 connoi(); /* Console interrupts off */
3143 /* Initialize Kermit and Zmodem Auto-Download Strings */
3144 adl_kstr = strdup("KERMIT READY TO SEND...");
3145 adl_zstr = strdup("rz\r");
3149 initpat(); /* Initialize filename patterns */
3150 #endif /* PATTERNS */
3154 initcsets(); /* Initialize character sets */
3155 #endif /* NOCSETS */
3159 makestr(&cdmsgstr,DFCDMSG);
3160 makelist(cdmsgstr,cdmsgfile,8); /* Initialize CD message filenames */
3161 #endif /* DFCDMSG */
3164 sstate = 0; /* No default start state. */
3167 fatal("Can't allocate i/o buffers!");
3168 #endif /* DYNAMIC */
3173 char stackdata[256];
3174 unsigned int c = 1234, n;
3175 /* try to make a random unsigned int to feed srand() */
3177 /* time.h and MultiNet do not get along */
3181 /* Referenced before set... DELIBERATELY */
3182 for (n = 0; n < sizeof(stackdata); n++) /* IGNORE WARNING */
3183 c += stackdata[n]; /* DELIBERATELY USED BEFORE SET */
3184 srand((unsigned int)c);
3186 #endif /* NORANDOM */
3189 ckhost(myhost,MYHOSTL); /* Name of local host */
3190 debug(F110,"main ckhost",myhost,0);
3194 ckstrncpy(ttname,dftty,TTNAMLEN); /* Set up default tty name. */
3195 local = nolocal ? 0 : dfloc; /* And whether it's local or remote. */
3196 parity = dfprty; /* Set initial parity, */
3198 myindex = getsysix(cksysid); /* System index */
3200 if (local) if (ttopen(ttname,&local,0,0) < 0) {
3202 conol("Can't open device: ");
3206 ckstrncpy(ttname,CTTNAM,TTNAMLEN);
3208 setflow(); /* Set appropriate flow control */
3209 speed = ttgspd(); /* Get transmission speed. */
3214 #ifdef ANYX25 /* All X.25 implementations */
3215 #ifndef IBMX25 /* except IBM have PAD support */
3216 initpad(); /* Initialize X.25 PAD */
3221 if (inibufs(SBSIZ,RBSIZ) < 0) /* Allocate packet buffers */
3222 fatal("Can't allocate packet buffers!");
3224 setprefix(prefixing); /* Set up control char prefixing */
3225 #endif /* NOCKSPEED */
3235 extern int ckxech, ttnet, ttnproto, cmdmsk;
3237 extern int tcp_sendbuf;
3240 extern int tcp_recvbuf;
3243 extern int tcp_keepalive;
3246 extern int tcp_linger, tcp_linger_tmo;
3247 #endif /* SO_LINGER */
3249 extern int tcp_dontroute;
3250 #endif /* SO_DONTROUTE */
3252 extern int tcp_nodelay;
3253 #endif /* TCP_NODELAY */
3255 extern int iklogopen;
3261 fatal("Internet Kermit Service cannot be started at a terminal.");
3264 reliable = xreliable = SET_ON; /* IKSD has reliable connection */
3266 flow = 0; /* No flow control needed */
3268 bgset = 0; /* Not in background */
3269 nopush = 1; /* No external processes */
3270 parity = 0; /* 8 bits ... */
3271 cmdmsk = 0xff; /* all the way */
3275 if (inserver) { /* If IKSD */
3276 doiksdinit(); /* Execute IKSD configuration file */
3278 parser(1); /* (Ignore any file-xfer commands) */
3279 iksdcf = 1; /* IKSD c.f. has been processed */
3281 if (!iklogopen) (VOID) doiklog(); /* Open Kermit-specific log */
3285 setbuf(stdout,NULL); /* Don't buffer the output */
3286 ckstrncpy(ttname,"0",TTNAMLEN); /* not "/dev/tty"... */
3288 local = 0; /* We are in remote mode */
3289 ckxech = 1; /* We will echo */
3291 nettype = NET_TCPB; /* So ttopen() treats the connection */
3292 mdmtyp = -nettype; /* as a network */
3294 debug(F100,"main about to call ttopen() inserver","",0);
3295 if (ttopen(ttname,&local,mdmtyp,0) < 0) { /* Open comm channel */
3296 fatal("can't initialize i/o");
3300 network = 1; /* Does use networking code */
3302 network = 0; /* Does not use networking code */
3304 ttmdm = -1; /* Does not use a modem */
3305 sstelnet = 1; /* Do server-side Telnet negotations */
3306 debug(F111,"MAIN","sstelnet",sstelnet);
3307 ttnet = NET_TCPB; /* Network type is TCP sockets */
3308 ttnproto = NP_TELNET; /* Netword protocol is Telnet */
3310 dbinit(); /* Initialize database record */
3313 #ifdef CK_AUTHENTICATION
3314 /* Before initializating Telnet/Rlogin negotiations, init Kerberos */
3315 ck_auth_init(ckgetpeer(),"","",0);
3316 #endif /* CK_AUTHENTICATION */
3320 x = socket_ioctl(0,FIONBIO,&on);
3321 debug(F101,"main FIONBIO","",x);
3322 #endif /* NON_BLOCK_IO */
3325 x = setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on));
3326 debug(F101,"main SO_OOBINLINE","",x);
3327 #endif /* SO_OOBINLINE */
3333 no_delay(0,tcp_nodelay);
3334 #endif /* TCP_NODELAY */
3336 keepalive(0,tcp_keepalive);
3337 #endif /* SO_KEEPALIVE */
3339 ck_linger(0,tcp_linger, tcp_linger_tmo);
3340 #endif /* SO_LINGER */
3342 dontroute(0,tcp_dontroute);
3343 #endif /* SO_DONTROUTE */
3345 sendbuf(0,tcp_sendbuf);
3346 #endif /* SO_SNDBUF */
3348 recvbuf(0,tcp_recvbuf);
3349 #endif /* SO_RCVBUF */
3350 #endif /* SOL_SOCKET */
3351 #endif /* datageneral */
3352 #endif /* NOTCPOPTS */
3355 if (ck_ssleay_is_installed()) {
3356 if (!ssl_tn_init(SSL_SERVER)) {
3357 if (bio_err != NULL) {
3358 BIO_printf(bio_err,"do_ssleay_init() failed\r\n");
3359 ERR_print_errors(bio_err);
3362 fprintf(stderr,"do_ssleay_init() failed\r\n");
3363 ERR_print_errors_fp(stderr);
3372 /* otherwise we will continue to accept the connection */
3373 /* without SSL or TLS support unless required. */
3374 if ( TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) != TN_NG_MU )
3375 TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = TN_NG_RF;
3376 if ( TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) != TN_NG_MU )
3377 TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = TN_NG_RF;
3378 if ( TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) != TN_NG_MU )
3379 TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = TN_NG_RF;
3380 if ( TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) != TN_NG_MU )
3381 TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = TN_NG_RF;
3383 if ( ck_ssl_incoming(0) < 0 ) {
3391 tn_ini(); /* Start Telnet negotiation now */
3395 debug(F101,"main argc after prescan()","",argc);
3397 /* Now process any relevant environment variables */
3400 getdialenv(); /* Dialing */
3402 ndinit(); /* Initialize network directory info */
3403 getnetenv(); /* Network directories */
3404 #endif /* NETCONN */
3409 dofast(); /* By now FAST defaults should be OK */
3410 #endif /* CK_FAST */
3414 ikslogin(); /* IKSD Login and other stuff */
3423 if (howcalled == I_AM_SSHSUB) {
3424 reliable = 1; /* We say the connection is reliable */
3425 xreliable = 1; /* And that we said it was */
3426 setreliable = 1; /* And pretend the "user" did too */
3427 xfinish = 1; /* For REMOTE HELP response */
3428 mdmtyp = 0; /* For ttopen() */
3429 ckstrncpy(ttname,"0",TTNAMLEN+1); /* Use file descriptor 0 */
3430 local = 0; /* And force remote mode */
3431 ttopen(ttname,&local,mdmtyp,0); /* Open the "connection" */
3432 sstate = 'x'; /* Initial state is Server */
3433 proto(); /* Enter protocol */
3434 doexit(GOOD_EXIT,xitsta); /* Exit when done */
3436 debug(F111,"howcalled",myname,howcalled);
3440 #else /* NOCCTRAP */
3441 debug(F100,"main about to cc_execute","",0);
3443 cc_execute( ckjaddr(cmjbuf), dotakeini, failtakeini );
3444 #endif /* NOCCTRAP */
3446 debug(F111,"main 2 cfilef",cmdfil,cfilef);
3447 if (cmdfil[0]) { /* If we got one (see prescan())... */
3449 docmdfile(0); /* execute it. */
3450 #else /* NOCCTRAP */
3452 cc_execute( ckjaddr(cmjbuf), docmdfile, failcmdfile );
3453 #endif /* NOCCTRAP */
3455 #ifndef OS2 /* Preserve name so we can delete it */
3456 *cmdfil = '\0'; /* Done, nullify the file name */
3461 /* Look for a UNIX-style command line... */
3465 debug(F101,"main argc","",argc);
3467 iniopthlp(); /* Initialize cmdline arg help */
3472 #endif /* COMMENT */
3473 argc > 1) { /* Command line arguments? */
3474 sstate = (CHAR) cmdlin(); /* Yes, parse. */
3477 if (haveurl) { /* Was a URL given? */
3478 dourl(); /* if so, do it. */
3481 #endif /* NETCONN */
3483 zstate = sstate; /* Remember sstate around protocol */
3484 debug(F101,"main zstate","",zstate);
3488 if (cflg) { /* Connect first if requested */
3494 #endif /* NOLOCAL */
3499 if (displa) concb((char)escape); /* (for console "interrupts") */
3500 #endif /* NOLOCAL */
3503 #else /* NOCCTRAP */
3505 cc_execute( ckjaddr(cmjbuf), docmdline, failcmdline );
3506 #endif /* NOCCTRAP */
3512 If a command-line action argument was given and -S ("stay") was not given,
3515 if ((cflg || cnflg || zstate) && !stayflg)
3517 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3523 if ((cflg || cnflg) && tn_exit && ttchk() < 0)
3524 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3525 #endif /* NETCONN */
3526 if (exitonclose && !network &&
3527 (carrier != CAR_OFF && (ttgmdm() & BM_DCD) == 0))
3528 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3529 if (exitonclose && network && ttchk() < 0)
3530 doexit(GOOD_EXIT,xitsta); /* Exit with good status */
3533 #endif /* NOLOCAL */
3537 #ifdef NOICP /* No interactive command parser */
3541 /* Command-line-only version */
3542 fatal("?No command-line options given - type 'kermit -h' for help");
3544 #else /* Neither one! */
3547 proto(); /* So go into server mode */
3548 doexit(GOOD_EXIT,xitsta); /* exit with good status */
3551 #else /* not NOICP */
3553 If no action requested on command line, or if -S ("stay") was included,
3554 enter the interactive command parser.
3557 herald(); /* Display program herald. */
3560 debug(F100,"main NOCCTRAP setting interrupt trap","",0);
3561 setint(); /* Set up command interrupt traps */
3563 #else /* NOCCTRAP */
3565 debug(F100,"main setting interrupt trap","",0);
3566 setint(); /* Set up command interrupt traps */
3567 if (!cc_execute(ckjaddr(cmjbuf), doicp, failicp))
3570 #endif /* NOCCTRAP */
3574 #endif /* MAINISVOID */
3578 /* Allocate file i/o buffers */
3580 char *zinbuffer = NULL, *zoutbuffer = NULL;
3584 zinbuffer = (char *)malloc(INBUFSIZE);
3585 if (!zinbuffer) return(-1);
3586 zoutbuffer = (char *)malloc(zobufsize);
3587 debug(F101,"zoutbuffer malloc","",zobufsize);
3588 if (!zoutbuffer) return(-1);
3589 debug(F100,"getiobs ok","",0);
3592 #endif /* DYNAMIC */