home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc190.zip / ckcmai.c < prev    next >
C/C++ Source or Header  |  1994-10-21  |  44KB  |  1,225 lines

  1. /*
  2.   ckcsym.h is used for for defining symbols that normally would be defined
  3.   using -D or -d on the cc command line, for use with compilers that don't
  4.   support this feature.  Must be before any tests for preprocessor symbols.
  5. */
  6. #include "ckcsym.h"
  7.  
  8. #ifndef MAC
  9. char *versio = "C-Kermit 5A(190), 4 Oct 94"; /* Version herald. */
  10. #else
  11. /*
  12.   For Macintosh, also remember to change the Mac-specific version in ckmkr2.r.
  13. */
  14. char *versio = "Mac Kermit 0.991(190) Pre-ALPHA, 4 Oct 94";
  15. #endif /* MAC */
  16. long vernum = 501190L;
  17. /*
  18.   String and numeric version numbers, keep these three in sync!
  19.   First digit of vermum = major version, i.e. 5.
  20.   Second 2 digits of vernum: 00 = no minor version, 01 = A, 02 = B, etc.
  21.   Last three digits are edit number. 
  22. */
  23. #ifndef VERWHO
  24. /* Change verwho in following line, or with -DVERWHO=x in makefile CFLAGS. */
  25. #define VERWHO 0
  26. #endif /* VERWHO */
  27. int verwho = VERWHO; /* Who produced this version, 0 = Columbia University */
  28. /*
  29.   IMPORTANT: If you are working on your own private version of C-Kermit, please
  30.   include some special notation, like your site name or your initials, in the
  31.   "versio" string, e.g. "5A(190)-XXX", and use a nonzero code for the "verwho"
  32.   variable (e.g. in the USA use your zip code).  Unless we stick to this
  33.   discipline, divergent copies of C-Kermit will begin to appear that are
  34.   intistinguishable from each other, which is a big support issue.  Also, if
  35.   you have edited C-Kermit and made copies available to others, please add
  36.   appropriate text to the BUG command (ckuus6.c, function dobug()).
  37. */
  38. #define CKCMAI
  39.  
  40. /*  C K C M A I  --  C-Kermit Main program  */
  41.  
  42. /*
  43.   Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),
  44.   Columbia University Academic Information Systems, New York City.
  45.  
  46. COPYRIGHT NOTICE:
  47. */
  48.  
  49. char *copyright[] = {
  50.  
  51. "Copyright (C) 1985, 1994, Trustees of Columbia University in the City of New",
  52. "York.  The C-Kermit software may not be, in whole or in part, licensed or",
  53. "sold for profit as a software product itself, nor may it be included in or",
  54. "distributed with commercial products or otherwise distributed by commercial",
  55. "concerns to their clients or customers without written permission of the",
  56. "Office of Kermit Development and Distribution, Columbia University.  This",
  57. "copyright notice must not be removed, altered, or obscured.",
  58. " ",
  59. "For further information, contact the Office of Kermit Development and",
  60. "Distribution, Columbia University, 612 West 115th Street, New York, NY 10025",
  61. "USA; phone +1 212 854-3703, fax +1 212 663-8202, email kermit@columbia.edu.",
  62. ""};
  63.  
  64. /*
  65.  
  66. DOCUMENTATION:
  67.  
  68.   "Using C-Kermit" by Frank da Cruz and Christine M. Gianone,
  69.   Digital Press, Burlington, MA, USA.
  70.   Order Number: EY-J896E-DP
  71.   Digital Press ISBN: 1-55558-108-0
  72.   Prentice Hall ISBN: 0-13-037490-3
  73.   Order from DECdirect: +1 800 344-4825 (USA only)
  74.   Or from Columbia University: +1 212 854-3703
  75.  
  76. DISCLAIMER:
  77.  
  78.   The C-Kermit software is provided in source code form by Kermit Development
  79.   and Distribution, Columbia University.  The software is provided "as is;" no
  80.   other warranty is provided, express or implied, including without
  81.   limitations, any implied warranty of merchantability or implied warranty of
  82.   fitness for a particular purpose.
  83.  
  84.   Neither Columbia University nor any of the contributors to the C-Kermit
  85.   development effort, including, but not limited to, AT&T, Digital Equipment
  86.   Corporation, Data General Corporation, or International Business Machines
  87.   Corporation, warrant C-Kermit software or documentation in any way.  In
  88.   addition, neither the authors of any Kermit programs, publications or
  89.   documentation, nor Columbia University nor any contributing institutions or
  90.   individuals acknowledge any liability resulting from program or
  91.   documentation errors.
  92.  
  93. ACKNOWLEDGMENTS:
  94.  
  95.   The Kermit file transfer protocol was developed at the Columbia University
  96.   Center for Computing Activities (CUCCA), which was since renamed to Columbia
  97.   University Academic Information Systems (AcIS).  Kermit is named after
  98.   Kermit the Frog, star of the television series THE MUPPET SHOW; the name is
  99.   used by permission of Henson Associates, Inc.
  100.  
  101.   Thanks to at least the following people for their contributions to this
  102.   program over the years, and apologies to anybody I missed:
  103.  
  104.    Chris Adie, Edinburgh U, Scotland (OS/2 support)
  105.    Robert Adsett, University of Waterloo, Canada
  106.    Larry Afrin, Clemson U
  107.    Jeffrey Altman, Altmania Productions and Seer Technologies (OS/2)
  108.    Greg Andrews, Telebit Corp
  109.    Barry Archer, U of Missouri
  110.    Robert Andersson, International Systems A/S, Oslo, Norway
  111.    Chris Armstrong, Brookhaven National Lab (OS/2)
  112.    William Bader, Software Consulting Services, Nazareth, PA
  113.    Fuat Baran, Columbia U AcIS
  114.    Stan Barber, Rice U
  115.    Jim Barbour, U of Colorado
  116.    Donn Baumgartner, Dell
  117.    Nelson Beebe, U of Utah
  118.    Karl Berry, UMB
  119.    Mark Berryman, SAIC
  120.    Dean W Bettinger, SUNY
  121.    Gary Bilkus
  122.    Marc Boucher, U of Montreal
  123.    Charles Brooks, EDN
  124.    Bob Brown
  125.    Mike Brown, Purdue U
  126.    Jack Bryans, California State U at Long Beach
  127.    Mark Buda, DEC (VAX/VMS)
  128.    Fernando Cabral, Padrao IX, Brasilia, Brazil
  129.    Bjorn Carlsson, Stockholm University Computer Centre QZ, Sweden
  130.    Bill Catchings, formerly of AcIS (then CUCCA)
  131.    Bob Cattani, Columbia U CS Dept
  132.    Davide Cervone, Rochester University
  133.    Seth Chaiklin, Denmark
  134.    John Chandler, Harvard U / Smithsonian Astronomical Observatory
  135.    Bernard Chen, UCLA
  136.    John L Chmielewski, AT&T, Lisle, IL
  137.    Howard Chu, U of Michigan
  138.    Bill Coalson, McDonnell Douglas
  139.    Bertie Coopersmith, London, UK
  140.    Chet Creider, University of Western Ontario, Canada
  141.    Alan Crosswell, Columbia U AcIS
  142.    Jeff Damens, formerly of AcIS
  143.    Mark Davies, Bath U, UK
  144.    Sin-itirou Dezawa, Fujifilm, Japan
  145.    Joe R. Doupnik, Utah State U
  146.    Frank Dreano (Honeywell)
  147.    John Dunlap, University of Washington
  148.    Alex Dupuy, SMART.COM
  149.    David Dyck, John Fluke Mfg Co.
  150.    Stefaan A. Eeckels, Eurokom, Luxembourg
  151.    Paul Eggert, Twin Sun, Inc., El Segundo, CA
  152.    Bernie Eiben, DEC
  153.    Kristoffer Eriksson, Peridot Konsult AB, Oerebro, Sweden
  154.    John R. Evans, IRS, Kansas City
  155.    Glenn Everhart, RCA Labs
  156.    Charlie Finan, Cray Research
  157.    Herm Fischer, Encino, CA (extensive contributions to version 4.0)
  158.    Carl Fongheiser, CWRU
  159.    Marcello Frutig, Catholic University, Sao Paulo, Brazil (X.25 support)
  160.    Hirofumi Fujii, Japan Nat'l Lab for High Energy Physics, Tokyo (Kanji)
  161.    Chuck Fuller, Westinghouse Corporate Computer Services
  162.    Andy Fyfe, Caltech
  163.    Christine M. Gianone, Columbia U AcIS
  164.    John Gilmore, UC Berkeley
  165.    Madhusudan Giyyarpuram, HP
  166.    William H. Glass
  167.    German Goldszmidt, IBM
  168.    Chuck Goodhart, NASA
  169.    Alistair Gorman, New Zealand
  170.    Richard Gration, ADFA, Australia
  171.    Chris Green, Essex U, UK
  172.    Alan Grieg, Dundee Tech, Scotland, UK
  173.    Yekta Gursel, MIT
  174.    Jim Guyton, Rand Corp
  175.    Michael Haertel
  176.    Bob Hain, UMN
  177.    Marion Hakanson, ORST
  178.    John Hamilston, Iowa State U
  179.    Simon Hania, Netherlands
  180.    Stan Hanks, Rice U.
  181.    Ken Harrenstein, SRI
  182.    Eugenia Harris, Data General (AOS/VS)
  183.    David Harrison, Kingston Warren Corp
  184.    James Harvey, Indiana/Purdue U (VMS)
  185.    Rob Healey
  186.    Chuck Hedrick, Rutgers U
  187.    Ron Heiby, Technical Systems Division, Motorola Computer Group
  188.    Steve Hemminger, Tektronix
  189.    Christian Hemsing, RWTH Aachen, Germany (OS-9)
  190.    Andrew Herbert, Monash Univ, Australia
  191.    Mike Hickey, ITI
  192.    Dan Hildebrand, QNX Software Systems Inc, Kanata, ON (QNX)
  193.    R E Hill
  194.    Bill Homer, Cray Research
  195.    Ray Hunter, The Wollongong Group
  196.    Randy Huntziger, National Library of Medicine
  197.    Larry Jacobs, Transarc
  198.    Steve Jenkins, Lancaster University, UK
  199.    Dave Johnson, Gradient Technologies
  200.    Mark B Johnson, Apple Computer
  201.    Jyke Jokinen, Tampere University of Technology, Finland (QNX)
  202.    Eric F Jones, AT&T
  203.    Luke Jones, AT&T
  204.    Peter Jones, U of Quebec Montreal
  205.    Phil Julian, SAS Institute
  206.    Peter Kabal, U of Quebec
  207.    Mic Kaczmarczik, U of Texas at Austin
  208.    Sergey Kartashoff, Inst. of Precise Mechanics & Computer Equipment, Moscow
  209.    Howie Kaye, Columbia U AcIS
  210.    Rob Kedoin, Linotype Co, Hauppauge, NY (OS/2)
  211.    Mark Kennedy, IBM
  212.    Terry Kennedy, St Peter's College, Jersey City, NJ (VMS and more)
  213.    Carlo Kid, Technical University of Delft, Netherlands
  214.    Douglas Kingston, morgan.com
  215.    Lawrence Kirby, Wiltshire, UK
  216.    Tom Kloos, Sequent Computer Systems
  217.    Jim Knutson, U of Texas at Austin
  218.    John T. Kohl <jtk@kolvir.blrc.ma.us> (BSDI)
  219.    Scott Kramer, SRI International, Menlo Park, CA
  220.    David Kricker, Encore Computer
  221.    Thomas Krueger, UWM
  222.    Bo Kullmar, ABC Klubben, Stockholm, and Central Bank of Sweden, Kista
  223.    R. Brad Kummer, AT&T Bell Labs, Atlanta, GA
  224.    John Kunze, UC Berkeley
  225.    David Lane, BSSI / BellSouth (Stratus VOS, X.25)
  226.    Bob Larson, USC (OS-9)
  227.    Bert Laverman, Groningen U, Netherlands
  228.    Steve Layton
  229.    David Lawyer, UC Irvine
  230.    David LeVine, National Semiconductor Corporation
  231.    Daniel S. Lewart, UIUC
  232.    S.O. Lidie, Lehigh U
  233.    Tor Lillqvist, Helsinki University, Finland
  234.    Dean Long
  235.    Mike Long, Analog Devices, Norwood MA
  236.    Kevin Lowey, U of Saskatchewan (OS/2)
  237.    Andy Lowry, Columbia University
  238.    James Lummel, Caprica Telecomputing Resources (QNX)
  239.    David MacKenzie, Environmental Defense Fund, University of Maryland
  240.    John Mackin, University of Sidney, Australia
  241.    Martin Maclaren, Bath U, UK
  242.    Chris Maio, Columbia U CS Dept
  243.    Motserrat Mane, HP, Grenoble, France
  244.    Fulvio Marino, Olivetti, Ivrea, Italy
  245.    Peter Mauzey, AT&T
  246.    Tye McQueen, Utah State U
  247.    Ted Medin
  248.    Hellmuth Michaelis, Hanseatischer Computerservice GmbH, Hamburg, Germany
  249.    Leslie Mikesell, American Farm Bureau
  250.    Martin Minow, DEC (VAX/VMS)
  251.    Pawan Mistra, Bellcore
  252.    Ken Mizialko, IBM, Manassas, VA
  253.    Ray Moody, Purdue U
  254.    Bruce J Moore, Allen-Bradley Co, Highland Heights, OH (Atari ST)
  255.    Steve Morley, Convex
  256.    Peter Mossel, Columbia University
  257.    Tony Movshon, NYU
  258.    Lou Muccioli, Swanson Analysis Systems
  259.    Dan Murphy
  260.    Gary Mussar
  261.    John Nall, FSU
  262.    Jack Nelson, University of Pittsburgh
  263.    Jim Noble, Planning Research Corporation (Macintosh)
  264.    Ian O'Brien, Bath U, UK
  265.    John Owens
  266.    Michael Pins, Iowa Computer Aided Engineering Network
  267.    Andre' Pirard, University of Liege, Belgium
  268.    Paul Placeway, Ohio State U (Macintosh & more)
  269.    Piet W. Plomp, ICCE, Groningen University, Netherlands
  270.    Ken Poulton, HP Labs
  271.    Manfred Prange, Oakland U
  272.    Christopher Pratt, APV Baker, UK
  273.    Frank Prindle, NADC
  274.    Tony Querubin, U of Hawaii
  275.    Anton Rang
  276.    Scott Ribe
  277.    Alan Robiette, Oxford University, UK
  278.    Michel Robitaille, U of Montreal (Mac)
  279.    Kai Uwe Rommel, Technische Universitaet Muenchen (OS/2)
  280.    Larry Rosenman (Amiga)
  281.    Jay Rouman, U of Michigan
  282.    Jack Rouse, SAS Institute (Data General and/or Apollo)
  283.    Stew Rubenstein, Harvard U (VAX/VMS)
  284.    Bill Schilit, Columbia University
  285.    Michael Schmidt, U of Paderborn, Germany
  286.    Eric Schnoebelen, Convex
  287.    Benn Schreiber, DEC
  288.    Dan Schullman, DEC (modems, DIAL command, etc)
  289.    John Schultz, 3M
  290.    Steven Schultz, Contel (PDP-11)
  291.    APPP Scorer, Leeds Polytechnic, UK
  292.    Gordon Scott, Micro Focus, Newbury UK
  293.    Gisbert W. Selke, WIdO, Bonn, Germany
  294.    David Sizeland, U of London Medical School
  295.    Fridrik Skulason, Iceland
  296.    Rick Sladkey (Linux)
  297.    Dave Slate
  298.    Bradley Smith, UCLA
  299.    Fred Smith, Merk
  300.    Richard S Smith, Cal State
  301.    Ryan Stanisfer, UNT
  302.    Bertil Stenstroem, Stockholm University Computer Centre (QZ), Sweden
  303.    James Sturdevant, CAP GEMENI AMERICA, Minneapolis
  304.    Peter Svanberg, Royal Techn. HS, Sweden
  305.    James R. Swenson, Accu-Weather, Inc.
  306.    Andy Tanenbaum, Vrije U, Amsterdam, Netherlands
  307.    Markku Toijala, Helsinki U of Technology
  308.    Teemu Torma, Helsinki U of Technology
  309.    Linus Torvalds, Helsinki, Finland (Linux)
  310.    Rick Troxel, NIH
  311.    Warren Tucker, Tridom Corp, Mountain Park, GA
  312.    Dave Tweten, AMES-NAS
  313.    G Uddeborg, Sweden
  314.    Walter Underwood, Ford Aerospace
  315.    Pieter Van Der Linden, Centre Mondial, Paris
  316.    Ge van Geldorp, Netherlands
  317.    Fred van Kempen, MINIX User Group, Voorhout, Netherlands
  318.    Wayne Van Pelt, GE/CRD
  319.    Mark Vasoll, Oklahoma State U (V7 UNIX)
  320.    Konstantin Vinogradov, ICSTI, Moscow
  321.    Paul Vixie, DEC
  322.    Bernie Volz, Process Software
  323.    Eduard Vopicka, Prague University of Economics, Czech Republic
  324.    Dimitri Vulis, CUNY
  325.    Roger Wallace, Raytheon
  326.    Stephen Walton, Calif State U, Northridge (Amiga)
  327.    Jamie Watson, Adasoft, Switzerland (RS/6000)
  328.    Rick Watson, U of Texas (Macintosh)
  329.    Robert Weiner, Programming Plus, New York City
  330.    Lauren Weinstein, Vortex Technlogy
  331.    David Wexelblat, AT&T
  332.    Joachim Wiesel, U of Karlsruhe
  333.    Lon Willett, U of Utah
  334.    Michael Williams, UCLA
  335.    Nate Williams, U of Montana
  336.    David Wilson
  337.    Patrick Wolfe, Kuck & Associates, Inc.
  338.    Gregg Wonderly, Oklahoma State U (V7 UNIX)
  339.    Farrell Woods, Concurrent (formerly Masscomp)
  340.    Dave Woolley, CAP Communication Systems, London
  341.    Jack Woolley, SCT Corp
  342.    Frank Wortner
  343.    Ken Yap, formerly of U of Rochester
  344.    John Zeeff, Ann Arbor, MI
  345. */
  346. #include "ckcasc.h"            /* ASCII character symbols */
  347. #include "ckcdeb.h"            /* Debug & other symbols */
  348. #include "ckcker.h"            /* Kermit symbols */
  349. #include "ckcnet.h"            /* Network symbols */
  350. #ifndef NOSPL
  351. #include "ckuusr.h"
  352. #endif /* NOSPL */
  353.  
  354. #ifndef NOSERVER
  355. /* Text message definitions.. each should be 256 chars long, or less. */
  356. #ifdef MAC
  357. char *hlptxt = "\r\
  358. Mac Kermit Server Commands:\r\
  359. \r\
  360.     BYE\r\
  361.     FINISH\r\
  362.     GET filespec\r\
  363.     REMOTE CD directory\r\
  364.     REMOTE HELP\r\
  365.     SEND filespec\r\
  366. \r\0";
  367. #else
  368. #ifdef AMIGA
  369. char *hlptxt = "C-Kermit Server Commands:\n\
  370. \n\
  371. GET filespec, SEND filespec, FINISH, BYE, REMOTE HELP\n\
  372. \n\0";
  373. #else
  374. #ifdef OS2
  375. char *hlptxt = "C-Kermit Server REMOTE Commands:\r\n\
  376. \r\n\
  377. GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\r\n\
  378. SEND files REMOTE SPACE [dir]  REMOTE HOST command\r\n\
  379. FINISH     REMOTE DELETE files REMOTE TYPE files\r\n\
  380. BYE        REMOTE HELP         REMOTE SET parameter value\r\n\
  381.                                REMOTE QUERY type variable\r\n\
  382.                                REMOTE ASSIGN variable value\r\n\
  383. \r\n\0";
  384. #else
  385. #ifdef MINIX
  386. char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
  387. GET SEND BYE FINISH REMOTE: CD DEL DIR HELP HOST SET SPACE TYPE WHO\n\0";
  388. #else
  389. #ifdef VMS
  390. char *hlptxt = "C-Kermit Server REMOTE Commands:\r\n\
  391. \r\n\
  392. GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\r\n\
  393. SEND files REMOTE SPACE [dir]  REMOTE HOST command\r\n\
  394. MAIL files REMOTE DELETE files REMOTE WHO [user]\r\n\
  395. BYE        REMOTE PRINT files  REMOTE TYPE files\r\n\
  396. FINISH     REMOTE HELP         REMOTE SET parameter value\r\n\
  397.                                REMOTE QUERY type variable\r\n\
  398.                                REMOTE ASSIGN variable value\r\n\
  399. \0";
  400. #else
  401. #ifdef datageneral
  402. char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
  403. \n\
  404. GET files  REMOTE CD [dir]     REMOTE DIRECTORY [filespec]\n\
  405. SEND files REMOTE SPACE [dir]  REMOTE HOST command\n\
  406. BYE        REMOTE TYPE file    REMOTE DELETE files\n\
  407. FINISH     REMOTE WHO          REMOTE SET\n\
  408.                                REMOTE QUERY type variable\n\
  409.                                REMOTE ASSIGN variable value\n\
  410. \0";
  411. #else
  412. #ifdef NOSPL
  413. char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
  414. \n\
  415. GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\n\
  416. SEND files REMOTE SPACE [dir]  REMOTE HOST command\n\
  417. MAIL files REMOTE DELETE files REMOTE WHO [user]\n\
  418. BYE        REMOTE PRINT files  REMOTE TYPE files\n\
  419. FINISH     REMOTE HELP         REMOTE SET parameter value\n\
  420. \n\0";
  421. #else
  422. char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
  423. \n\
  424. GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\n\
  425. SEND files REMOTE SPACE [dir]  REMOTE HOST command\n\
  426. MAIL files REMOTE DELETE files REMOTE WHO [user]\n\
  427. BYE        REMOTE PRINT files  REMOTE TYPE files\n\
  428. FINISH     REMOTE HELP         REMOTE SET parameter value\n\
  429.                                REMOTE QUERY type variable\n\
  430.                                REMOTE ASSIGN variable value\n\
  431. \n\0";
  432. #endif /* NOSPL */
  433. #endif /* datageneral */
  434. #endif /* VMS */
  435. #endif /* MINIX */
  436. #endif /* OS2 */
  437. #endif /* AMIGA */
  438. #endif /* MAC */
  439.  
  440. #ifdef MINIX
  441. char *srvtxt = "\r\n\
  442. Entering server mode.\r\n\0";
  443. #else
  444. #ifdef OLDMSG
  445. /*
  446.   It seems there was a large installation that was using C-Kermit 5A(165)
  447.   or thereabouts, which had deployed thousands of MS-DOS Kermit scripts in
  448.   scattered locations that looked for strings in the old server message,
  449.   which changed in 5A(183), August 1992.
  450. */
  451. char *srvtxt = "\r\n\
  452. C-Kermit server starting.  Return to your local machine by typing\r\n\
  453. its escape sequence for closing the connection, and issue further\r\n\
  454. commands from there.  To shut down the C-Kermit server, issue the\r\n\
  455. FINISH or BYE command and then reconnect.\n\
  456. \r\n\0";
  457. #else
  458. #ifdef OSK
  459. char *srvtxt = "\r\l\
  460. Entering server mode.  If your local Kermit software is menu driven, use\r\l\
  461. the menus to send commands to the server.  Otherwise, enter the escape\r\l\
  462. sequence to return to your local Kermit prompt and issue commands from\r\l\
  463. there.  Use SEND and GET for file transfer.  Use REMOTE HELP for a list of\r\l\
  464. other available services.  Use BYE or FINISH to end server mode.\r\l\0";
  465. #else /* UNIX, VMS, AOS/VS, and all others */
  466. char *srvtxt = "\r\n\
  467. Entering server mode.  If your local Kermit software is menu driven, use\r\n\
  468. the menus to send commands to the server.  Otherwise, enter the escape\r\n\
  469. sequence to return to your local Kermit prompt and issue commands from\r\n\
  470. there.  Use SEND and GET for file transfer.  Use REMOTE HELP for a list of\r\n\
  471. other available services.  Use BYE or FINISH to end server mode.\r\n\0";
  472. #endif /* OSK */
  473. #endif /* OLDMSG */
  474. #endif /* MINIX */
  475. #else  /* server mode disabled */
  476. char *hlptxt = "";
  477. char *srvtxt = "";
  478. #endif /* NOSERVER */
  479.  
  480. /* Declarations for Send-Init Parameters */
  481.  
  482. int spsiz = DSPSIZ,                     /* Current packet size to send */
  483.     spmax = DSPSIZ,            /* Biggest packet size we can send */
  484.     spsizr = DSPSIZ,            /* Send-packet size requested */
  485.     spsizf = 0,                         /* Flag to override size negotiation */
  486.     rpsiz = DRPSIZ,                     /* Biggest we want to receive */
  487.     urpsiz = DRPSIZ,            /* User-requested receive pkt size */
  488.     maxrps = MAXRP,            /* Maximum incoming long packet size */
  489.     maxsps = MAXSP,            /* Maximum outbound l.p. size */
  490.     maxtry = MAXTRY,            /* Maximum retries per packet */
  491.     wslots = 1,                /* Window size currently in use */
  492.     wslotr = 1,                /* Window size from SET WINDOW */
  493.     wslotn = 1,                /* Window size negotiated in S-pkt */
  494.     timeouts = 0,            /* For statistics reporting */
  495.     spackets = 0,            /*  ... */
  496.     rpackets = 0,            /*  ... */
  497.     retrans = 0,            /*  ... */
  498.     crunched = 0,            /*  ... */
  499.     wmax = 0,                /*  ... */
  500.     wcur = 0,                /*  ... */
  501.     srvdis = 0,                /* Server file xfer display */
  502.     srvtim = DSRVTIM,            /* Server command wait timeout */
  503. /*
  504.   timint is the timeout interval I use when waiting for a packet.
  505.   pkttim is the SET RECEIVE TIMEOUT value, sent to the other Kermit.
  506.   rtimo is the SET SEND TIMEOUT value.  rtimo is the initial value of
  507.   timint.  timint is changed by the value in the incoming negotiation
  508.   packet unless a SET SEND TIMEOUT command was given.
  509. */
  510.     timint = DMYTIM,                    /* Timeout interval I use */
  511.     pkttim = URTIME,            /* Timeout I want you to use */
  512.     rtimo = DMYTIM,            /* Normal packet wait timeout */
  513.     timef = 0,                          /* Flag to override what you ask */
  514.     npad = MYPADN,                      /* How much padding to send */
  515.     mypadn = MYPADN,                    /* How much padding to ask for */
  516.     bctr = 1,                           /* Block check type requested */
  517.     bctu = 1,                           /* Block check type used */
  518.     bctl = 1,                /* Block check length */
  519.     ebq =  MYEBQ,                       /* 8th bit prefix */
  520.     ebqflg = 0,                         /* 8th-bit quoting flag */
  521.     rqf = -1,                /* Flag used in 8bq negotiation */
  522.     rq = 0,                /* Received 8bq bid */
  523.     sq = 'Y',                /* Sent 8bq bid */
  524.     rpt = 0,                            /* Repeat count */
  525.     rptq = MYRPTQ,                      /* Repeat prefix */
  526.     rptflg = 0,                         /* Repeat processing flag */
  527.     rptena = 1,                /* Repeat processing enabled */
  528.     xfrcan = 1,                /* Transfer cancellation enabled */
  529.     xfrchr = 3,                /* Transfer cancel char = Ctrl-C */
  530.     xfrnum = 3;                /* Need three of them. */
  531.  
  532. int epktflg = 0;            /* E-PACKET command active */
  533.  
  534. int capas = 9,                /* Position of Capabilities */
  535.     lpcapb = 2,                /* Long Packet capability */
  536.     lpcapr = 1,                /*  requested */
  537.     lpcapu = 0,                /*  used */
  538.     swcapb = 4,                /* Sliding Window capability */
  539.     swcapr = 1,                /*  requested (allowed) */
  540.     swcapu = 0,                /*  used */
  541.     atcapb = 8,                /* Attribute capability */
  542.     atcapr = 1,                /*  requested */
  543.     atcapu = 0,                /*  used */
  544.     rscapb = 16,            /* RESEND capability */
  545.     rscapr = 1,                /*  requested by default */
  546.     rscapu = 0,                /*  used */
  547.     lscapb = 32,            /* Locking Shift capability */
  548.     lscapr = 1,                /*  requested by default */
  549.     lscapu = 0;                /*  used */
  550.  
  551. /* Flags for whether to use particular attributes */
  552.  
  553. int atenci = 1,                /* Encoding in */
  554.     atenco = 1,                /* Encoding out */
  555.     atdati = 1,                /* Date in */
  556.     atdato = 1,                /* Date out */
  557.     atdisi = 1,                /* Disposition in/out */
  558.     atdiso = 1,
  559.     atleni = 1,                /* Length in/out (both kinds) */
  560.     atleno = 1,
  561.     atblki = 1,                /* Blocksize in/out */
  562.     atblko = 1,
  563.     attypi = 1,                /* File type in/out */
  564.     attypo = 1,
  565.     atsidi = 1,                /* System ID in/out */
  566.     atsido = 1,
  567.     atsysi = 1,                   /* System-dependent parameters in/out */
  568.     atsyso = 1;
  569.  
  570. #ifdef STRATUS
  571. int atfrmi = 1,                /* Format in/out */
  572.     atfrmo = 1,
  573.     atcrei = 1,                /* Creator ID in/out */
  574.     atcreo = 1,
  575.     atacti = 1,                /* Account in/out */
  576.     atacto = 1;
  577. #endif /* STRATUS */
  578.  
  579. CHAR padch = MYPADC,                    /* Padding character to send */
  580.     mypadc = MYPADC,                    /* Padding character to ask for */
  581.     seol = MYEOL,                       /* End-Of-Line character to send */
  582.     eol = MYEOL,                        /* End-Of-Line character to look for */
  583.     ctlq = CTLQ,                        /* Control prefix in incoming data */
  584.     myctlq = CTLQ,                      /* Outbound control character prefix */
  585.     myrptq = MYRPTQ;            /* Repeat prefix I want to use */
  586.  
  587. int rptmin = 3;                /* Repeat-count minimum */
  588.  
  589. struct zattr iattr;            /* Incoming file attributes */
  590.  
  591. /* File related variables, mainly for the benefit of (Open)VMS */
  592.  
  593. int fblksiz = DBLKSIZ;        /* File blocksize */
  594. int frecl = DLRECL;        /* File record length */
  595. int frecfm = XYFF_S;        /* File record format (default = stream) */
  596. int forg = XYFO_S;        /* File organization (sequential) */
  597. int fcctrl = XYFP_N;        /* File carriage control (ctrl chars) */
  598.  
  599. #ifdef VMS
  600. /* VMS labeled file default options - name only. */
  601. int lf_opts = LBL_NAM;
  602. #else
  603. #ifdef OS2
  604. /* OS/2 labeled file default options, all attributes but archived. */
  605. unsigned long int lf_opts = LBL_EXT|LBL_HID|LBL_RO|LBL_SYS;
  606. #else
  607. int lf_opts = 0;
  608. #endif /* OS2 */
  609. #endif /* VMS */
  610.  
  611. /* Packet-related variables */
  612.  
  613. int pktnum = 0,                         /* Current packet number */
  614.     sndtyp = 0,                /* Type of packet just sent */
  615.     rcvtyp = 0,                /* Type of packet just received */
  616.     rsn,                /* Received packet sequence number */
  617.     rln,                /* Received packet length */
  618.     size,                               /* Current size of output pkt data */
  619.     osize,                              /* Previous output packet data size */
  620.     maxsize,                            /* Max size for building data field */
  621.     spktl = 0,                /* Length packet being sent */
  622.     rpktl = 0,                /* Length of packet just received */
  623.     pktpaus = 0,            /* Interpacket pause interval, msec */
  624.     rprintf,                /* REMOTE PRINT flag */
  625.     rmailf;                /* MAIL flag */
  626.  
  627.  
  628. CHAR
  629. #ifdef pdp11
  630.     srvcmd[MAXRP+4],
  631. #else
  632. #ifdef DYNAMIC
  633.     *srvcmd = (CHAR *)0,        /* Where to decode server command */
  634.     *pktmsg = (CHAR *)0,        /* Packet error message */
  635. #else
  636.     srvcmd[MAXRP+4],
  637.     pktmsg[81],
  638. #endif /* DYNAMIC */
  639. #endif /* pdp11 */
  640.     padbuf[96],                /* Buffer for send-padding */
  641.     *recpkt,
  642.     *rdatap,                /* Pointer to received packet data */
  643.     *data = (CHAR *)0,            /* Pointer to send-packet data */
  644.     *srvptr,                            /* Pointer to srvcmd */
  645.     mystch = SOH,                       /* Outbound packet-start character */
  646.     stchr = SOH;                        /* Incoming packet-start character */
  647.  
  648. /* File-related variables */
  649.  
  650. char filnam[257];                       /* Name of current file. */
  651. char cmdfil[80];            /* Application file name. */
  652. int cfilef = 0;                /* Application file flag. */
  653.  
  654. int nfils = 0;                /* Number of files in file group */
  655. long fsize;                             /* Size of current file */
  656. int wildxpand = 0;            /* Who expands wildcards */
  657. int clfils = 0;                /* Flag for command-line files */
  658. int stayflg = 0;            /* Flag for "stay", i.e. "-S" */
  659.  
  660. /* Communication line variables */
  661.  
  662. char ttname[80];                        /* Name of communication line. */
  663.  
  664. #ifdef MAC
  665. int connected = 0;            /* true if connected */
  666. int startconnected;            /* initial state of connected */
  667. #endif /* MAC */
  668.  
  669. long speed = -1L;            /* Line speed */
  670.  
  671. int parity = DEFPAR,            /* Parity specified, 0,'e','o',etc */
  672.     autopar = 0,            /* Automatic parity change flag */
  673.     sosi = 0,                /* Shift-In/Out flag */
  674.     flow,                               /* Flow control */
  675.     turn = 0,                           /* Line turnaround handshake flag */
  676.     turnch = XON,                       /* Line turnaround character */
  677.     duplex = 0,                         /* Duplex, full by default */
  678.     escape = DFESC,            /* Escape character for connect */
  679.     delay = DDELAY,                     /* Initial delay before sending */
  680.     tnlm = 0,                /* Terminal newline mode */
  681.     mdmtyp = 0;                         /* Modem type (initially none)  */
  682.  
  683. /* Networks for SET HOST */
  684.  
  685. #define MYHOSTL 100
  686.     char myhost[MYHOSTL];        /* Local host name */
  687.     int network = 0;            /* Network vs serial connection */
  688.  
  689. #ifdef NETCONN
  690. #ifdef TCPSOCKET
  691.     int nettype = NET_TCPB;        /* Assume TCP/IP (BSD sockets) */
  692. #else
  693. #ifdef SUNX25
  694.     int nettype = NET_SX25;
  695. #else
  696. #ifdef STRATUSX25
  697.     int nettype = NET_VX25;
  698. #else
  699. #ifdef DECNET
  700.     int nettype = NET_DEC;
  701. #else
  702.     int nettype = NET_NONE;
  703. #endif /* DECNET */
  704. #endif /* STRATUSX25 */
  705. #endif /* SUNX25 */
  706. #endif /* TCPSOCKET */
  707. #else
  708.     int nettype = NET_NONE;
  709. #endif /* NETCONN */
  710.  
  711. #ifdef ANYX25
  712.     int revcall = 0;            /* X.25 reverse call not selected */
  713.     int closgr  = -1;        /* X.25 closed user group not selected */
  714.     int cudata = 0;        /* X.25 call user data not specified */
  715.     char udata[MAXCUDATA];    /* X.25 call user data */
  716. #endif /* ANYX25 */
  717.  
  718. /* Other items */
  719.  
  720. #ifdef OS2PM
  721.     int os2pm = 0;            /* OS/2 Presentation Manager flag */
  722. #endif /* OS2PM */
  723.  
  724. /* Terminal screen size, if known, -1 means unknown. */
  725.     int tt_rows = -1;            /* Rows (height) */
  726.     int tt_cols = -1;            /* Columns (width) */
  727.  
  728.     int tlevel = -1;            /* Take-file command level */
  729. #ifdef NOLOCAL
  730.     int remonly = 1;            /* Remote-mode-only advisory (-R) */
  731. #else
  732.     int remonly = 0;
  733. #endif /* NOLOCAL */
  734.  
  735. #ifndef NOSPL
  736.     extern int cmdlvl;            /* Command level */
  737.     extern int maclvl;            /* Macro invocation level */
  738. #endif /* NOSPL */
  739.  
  740.     int carrier = CAR_AUT;        /* Pay attention to carrier signal */
  741.     int cdtimo = 0;            /* Carrier wait timeout */
  742.     int xitsta = GOOD_EXIT;        /* Program exit status */
  743. #ifdef VMS                /* Default filename collision action */
  744.     int fncact = XYFX_X;        /* REPLACE for VAX/VMS */
  745. #else
  746.     int fncact = XYFX_B;        /* BACKUP for everybody else */
  747. #endif /* VMS */
  748.     int fncsav = -1;            /* For saving & restoring the above */
  749.     int bgset = -1;            /* BACKGROUND mode set explicitly */
  750. #ifdef UNIX
  751.     int suspend = DFSUSP;        /* Whether SUSPEND command, etc, */
  752. #else                    /* is to be allowed. */
  753.     int suspend = 0;
  754. #endif /* UNIX */
  755.  
  756. /* Statistics variables */
  757.  
  758. long filcnt,                    /* Number of files in transaction */
  759.     filrej,            /* Number of files rejected in transaction */
  760.     flci,                       /* Characters from line, current file */
  761.     flco,                       /* Chars to line, current file  */
  762.     tlci,                       /* Chars from line in transaction */
  763.     tlco,                       /* Chars to line in transaction */
  764.     ffc,                        /* Chars to/from current file */
  765.     tfc,                        /* Chars to/from files in transaction */
  766.     rptn;            /* Repeated characters compressed */
  767.  
  768. int tsecs = 0;                  /* Seconds for transaction */
  769. int fsecs = 0;            /* Per-file timer */
  770.  
  771. /* Flags */
  772.  
  773. int deblog = 0,                         /* Flag for debug logging */
  774.     debses = 0,                /* Flag for DEBUG SESSION */
  775.     pktlog = 0,                         /* Flag for packet logging */
  776.     seslog = 0,                         /* Session logging */
  777.     tralog = 0,                         /* Transaction logging */
  778.     displa = 0,                         /* File transfer display on/off */
  779.     stdouf = 0,                         /* Flag for output to stdout */
  780.     stdinf = 0,                /* Flag for input from stdin */
  781.     xflg   = 0,                         /* Flag for X instead of F packet */
  782.     hcflg  = 0,                         /* Doing Host command */
  783.     fncnv  = 1,                         /* Flag for file name conversion */
  784.     fnspath = 0,            /* Send-file path stripping */
  785.     fnrpath = 0,            /* Receive-file path stripping */
  786.     binary = XYFT_T,            /* File transfer mode */
  787.     sendmode = SM_SEND,            /* Which type of SEND operation */
  788.     savmod = 0,                         /* Saved file mode (whole session) */
  789.     bsave  = 0,                /* Saved file mode (per file) */
  790.     bsavef = 0,                /* Flag if bsave was used. */
  791.     cmask  = 0177,            /* Connect byte mask */
  792.     fmask  = 0377,            /* File byte mask */
  793.     warn   = 0,                         /* Flag for file warning */
  794.     quiet  = 0,                         /* Be quiet during file transfer */
  795.     local  = 0,                         /* 1 = local mode, 0 = remote mode */
  796.     server = 0,                         /* Flag for being a server */
  797.     cflg   = 0,                /* Connect before transaction */
  798.     cnflg  = 0,                         /* Connect after transaction */
  799.     cxseen = 0,                         /* Flag for cancelling a file */
  800.     czseen = 0,                         /* Flag for cancelling file group */
  801.     discard = 0,            /* Flag for file to be discarded */
  802.     keep = 1,                           /* Keep incomplete files */
  803.     unkcs = 1,                /* Keep file w/unknown character set */
  804.     nakstate = 0,            /* In a state where we can send NAKs */
  805.     dblchar = -1;            /* Character to double when sending */
  806.  
  807. long sendstart = 0L;            /* SEND start position */
  808.  
  809. /* Variables passed from command parser to protocol module */
  810.  
  811. #ifndef NOSPL
  812. #ifndef NOICP
  813. _PROTOTYP( int parser, (int) );         /* The parser itself */
  814. #endif /* NOICP */
  815. #endif /* NOSPL */
  816. char *clcmds = NULL;            /* Pointer to command-line commands */
  817.  
  818. CHAR sstate  = (CHAR) 0;                /* Starting state for automaton */
  819. CHAR zstate  = (CHAR) 0;        /* For remembering sstate */
  820. char *cmarg  = "";                      /* Pointer to command data */
  821. char *cmarg2 = "";                      /* Pointer to 2nd command data */
  822. char **cmlist;                          /* Pointer to file list in argv */
  823.  
  824. /* Flags for the ENABLE and DISABLE commands */
  825.  
  826. int en_cwd = 1;                /* CD/CWD */
  827. int en_del = 1;                /* DELETE */
  828. int en_dir = 1;                /* DIRECTORY */
  829. int en_fin = 1;                /* FINISH/BYE */
  830. int en_get = 1;                /* GET */
  831. #ifndef NOPUSH
  832. int en_hos = 1;                /* HOST enabled */
  833. #else
  834. int en_hos = 0;                /* HOST disabled */
  835. #endif /* NOPUSH */
  836. int en_sen = 1;                /* SEND */
  837. int en_set = 1;                /* SET */
  838. int en_spa = 1;                /* SPACE */
  839. int en_typ = 1;                /* TYPE */
  840. int en_who = 1;                /* WHO */
  841. #ifdef datageneral
  842. /* Data General AOS/VS can't do this */
  843. int en_bye = 0;                /* BYE */
  844. #else
  845. int en_bye = 1;                /* BYE */
  846. #endif /* datageneral */
  847. int en_asg = 1;                /* ASSIGN */
  848. int en_que = 1;                /* QUERY */
  849.  
  850. /* Miscellaneous */
  851.  
  852. char **xargv;                           /* Global copies of argv */
  853. int  xargc;                             /* and argc  */
  854. int xargs;                /* an immutable copy of argc */
  855. char *xarg0;                /* and of argv[0] */
  856.  
  857. extern char *dftty;                     /* Default tty name from ck?tio.c */
  858. extern int dfloc;                       /* Default location: remote/local */
  859. extern int dfprty;                      /* Default parity */
  860. extern int dfflow;                      /* Default flow control */
  861.  
  862. /*
  863.   Buffered file input and output buffers.  See getpkt() in ckcfns.c
  864.   and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).
  865. */
  866. #ifndef DYNAMIC
  867. /* Now we allocate them dynamically, see getiobs() below. */
  868. char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];
  869. #endif
  870. char *zinptr, *zoutptr;
  871. int zincnt, zoutcnt;
  872.  
  873. _PROTOTYP( int getiobs, (void) );
  874.  
  875. /*  M A I N  --  C-Kermit main program  */
  876.  
  877. #ifndef NOCCTRAP
  878. #include <setjmp.h>
  879. #ifdef CK_POSIX_SIG            /* POSIX signal handling */
  880. extern sigjmp_buf cmjbuf;
  881. #else
  882. extern jmp_buf cmjbuf;
  883. #endif /* CK_POSIX_SIG */
  884. #ifdef GEMDOS                /* Special for Atari ST */
  885.     cc_clean();
  886. #endif /* GEMDOS */
  887. #endif /* NOCCTRAP */
  888.  
  889. #ifdef aegis
  890. /* On the Apollo, intercept main to insert a cleanup handler */
  891. int
  892. ckcmai(argc,argv) int argc; char **argv;
  893. #else
  894. #ifdef MAC                /* Macintosh */
  895. int
  896. main (void)
  897. #else
  898. #ifdef VMSGCC                /* (Open)VMS with GCC compiler */
  899. int
  900. main(argc,argv) int argc; char **argv;
  901. #else
  902. #ifdef __DECC                /* Alpha AXP with DEC C compiler */
  903. #ifdef __ALPHA
  904. int
  905. main(argc,argv) int argc; char **argv;
  906. #else                    /* DEC C compiler, not Alpha AXP */
  907. VOID
  908. main(argc,argv) int argc; char **argv;
  909. #endif    /* __ALPHA */
  910. #else
  911. #ifdef STRATUS                /* Stratus VOS */
  912. /* ANSI main returns int, and VOS compiler complains if not so. */
  913. int
  914. main(argc,argv) int argc; char **argv;
  915. #else                    /* All others */
  916. VOID
  917. main(argc,argv) int argc; char **argv;
  918. #endif /* STRATUS */
  919. #endif /* __DECC */
  920. #endif /* VMSGCC */
  921. #endif /* MAC */
  922. #endif /* aegis */
  923. { /* main */
  924. #ifdef datageneral
  925. short *pfha = 016000000036;             /* Get around LANG_RT problem -- */
  926. *pfha = (short) 0;                      /* No user protection fault handler */
  927. #endif /* datageneral */
  928.   
  929. /* Do some initialization */
  930.  
  931. #ifndef MAC
  932.     xargc = xargs = argc;        /* Make global copies of argc */
  933.     xargv = argv;                       /* ...and argv. */
  934.     xarg0 = argv[0];
  935. #ifndef NOICP
  936.     prescan(0);                /* Check for debugging */
  937. #endif /* NOICP */
  938. #endif /* MAC */
  939.  
  940.     if (sysinit() < 0)            /* System-dependent initialization. */
  941.       fatal("Can't initialize!");
  942.  
  943. #ifdef TCPSOCKET
  944. #ifdef CK_SOCKS
  945.       SOCKSinit(argv[0]);        /* Internet relay package... */
  946. #endif /* CK_SOCKS */
  947. #endif /* TCPSOCKET */
  948.  
  949.     connoi();                /* Console interrupts off */
  950.     sstate = 0;                         /* No default start state. */
  951. #ifdef DYNAMIC
  952.     if (getiobs() < 0)
  953.       fatal("Can't allocate i/o buffers!");
  954. #endif /* DYNAMIC */
  955.     ckhost(myhost,MYHOSTL);        /* Name of local host */
  956.     strcpy(ttname,dftty);               /* Set up default tty name. */
  957.     local = dfloc;                      /* And whether it's local or remote. */
  958.     parity = dfprty;                    /* Set initial parity, */
  959.     flow = dfflow;                      /* and flow control. */
  960.     if (local) if (ttopen(ttname,&local,0,0) < 0) { /* If default tty line */
  961. #ifndef OS2
  962.     conol("Can't open device: ");
  963.     conoll(ttname);
  964. #endif /* OS2 */
  965.     local = 0;                        /* now... */
  966.     strcpy(ttname,CTTNAM);
  967.     }
  968.     speed = ttgspd();            /* Get transmission speed. */
  969.  
  970. #ifdef ANYX25
  971.     initpad();                          /* Initialize X.25 PAD */
  972. #endif /* ANYX25 */
  973.  
  974.     if (inibufs(SBSIZ,RBSIZ) < 0)    /* Allocate packet buffers */
  975.       fatal("Can't allocate packet buffers!");
  976.  
  977. #ifndef NOICP
  978. #ifdef MAC
  979.     cmdini();
  980. #else /* Not MAC */
  981.  
  982. /* Attempt to take ini file before doing command line */
  983.  
  984.     *cmdfil = '\0';            /* Assume no command file. */
  985.     prescan(1);                /* But first check for -y option */
  986.     debug(F101,"main argc after prescan()","",argc);
  987.  
  988. #ifndef NOCCTRAP
  989.     setint();                /* Set up interrupts */
  990.     if (
  991. #ifdef CK_POSIX_SIG
  992.     sigsetjmp(cmjbuf,1)
  993. #else
  994.     setjmp(cmjbuf)
  995. #endif /* CK_POSIX_SIG */
  996.     ) {                /* Control-C trap returns to here. */
  997. #ifdef GEMDOS
  998.     cc_clean();            /* Atari: Clean up after ^C-trap. */
  999. #endif /* GEMDOS */
  1000.     conoll("Interrupt during initialization or command-line processing.");
  1001.     conoll("C-Kermit quitting...");
  1002.     doexit(BAD_EXIT,-1);        /* Exit with bad status. */
  1003.     } else {
  1004. #endif /* NOCCTRAP */
  1005.     cmdini();            /* Sets tlevel */
  1006.     while (tlevel > -1) {        /* Execute init file. */
  1007.         debug(F101,"main executing init file","",tlevel);
  1008.         sstate = parser(0);        /* Loop getting commands. */
  1009.         if (sstate) proto();    /* Enter protocol if requested. */
  1010.         debug(F101,"main exits init file","",tlevel);
  1011.     }
  1012. #ifndef NOCCTRAP
  1013.     }
  1014. #endif /* NOCCTRAP */
  1015.  
  1016. /*
  1017.   In UNIX there are two ways to invoke Kermit with a cmdfile:
  1018.   (1) From the kermit command line, e.g. "kermit cmdfile [ options... ]"
  1019.       argv[0] = "kermit"
  1020.       argv[1] = "cmdfile"
  1021.   (2) By executing a cmdfile whose first line is like "#!/path/kermit"
  1022.       argv[0] = "/path/kermit" (sometimes just "kermit")
  1023.       argv[1] = "/path/cmdfile"
  1024. */
  1025.     debug(F101,"main cmdfil check","",argc);
  1026.     if (argc > 1) {
  1027.     if (*argv[1] != '-') {
  1028.         debug(F110,"main argv[1]",argv[1],0);
  1029.         if (zchki(argv[1]) > 0) {
  1030.         strcpy(cmdfil,argv[1]);
  1031.         }
  1032.     }
  1033.     }
  1034.     if (*cmdfil) {            /* If we got one, */
  1035.     debug(F110,"main cmdfil",cmdfil,0);
  1036.     cfilef = 1;            /* remember we did this, */
  1037.     dotake(cmdfil);            /* execute it */
  1038.     while (tlevel > -1) {        /* until it runs out. */
  1039.         sstate = parser(1);        /* Loop getting commands. */
  1040.         if (sstate) proto();    /* Enter protocol if requested. */
  1041.     }
  1042.     }
  1043.     *cmdfil = '\0';            /* Done, nullify the file name */
  1044. #endif /* MAC */
  1045. #endif /* NOICP */
  1046.  
  1047. #ifndef NOCMDL
  1048. /* Look for a UNIX-style command line... */
  1049.  
  1050.     debug(F101,"main argc","",argc);
  1051.     if (argc > 1) {                     /* Command line arguments? */
  1052.         sstate = cmdlin();              /* Yes, parse. */
  1053.     zstate = sstate;        /* Remember sstate around protocol */
  1054. #ifndef NOLOCAL
  1055.     if (cflg) conect();        /* Connect first if requested */
  1056. #endif /* NOLOCAL */
  1057.         if (sstate) {
  1058. #ifndef NOLOCAL
  1059.         if (displa) concb((char)escape); /* (for console "interrupts") */
  1060. #endif /* NOLOCAL */
  1061. #ifndef NOCCTRAP
  1062.         setint();            /* Set up interrupts */
  1063.         if (
  1064. #ifdef CK_POSIX_SIG
  1065.         sigsetjmp(cmjbuf,1)
  1066. #else
  1067.         setjmp(cmjbuf)
  1068. #endif /* CK_POSIX_SIG */
  1069.         ) {            /* Control-C trap returns to here. */
  1070. #ifdef GEMDOS
  1071.         cc_clean();
  1072. #endif /* GEMDOS */
  1073. #ifndef NOLOCAL
  1074.         if (cnflg) conect();    /* connect again if requested, */
  1075. #endif /* NOLOCAL */
  1076.         } else {
  1077. #endif /* NOCCTRAP */
  1078.         proto();        /* Take any requested action, then */
  1079.         if (!quiet)        /* put cursor back at left margin, */
  1080.           conoll("");
  1081. #ifndef NOLOCAL
  1082.         if (cnflg) conect();    /* connect if requested, */
  1083. #endif /* NOLOCAL */
  1084. #ifndef NOCCTRAP
  1085.         }
  1086. #endif /* NOCCTRAP */
  1087.     }
  1088. #ifndef NOICP
  1089. /*
  1090.   If a command-line action argument was given and -S ("stay") was not given,
  1091.   exit now.
  1092. */
  1093.     if ((cflg || cnflg || zstate) && !stayflg)
  1094. #endif /* NOICP */
  1095.       doexit(GOOD_EXIT,xitsta); /* exit with good status */
  1096.     }
  1097. #endif /* NOCMDL */
  1098.  
  1099. #ifdef NOICP                /* No interactive command parser */
  1100.     else {
  1101. #ifndef NOCMDL
  1102.     /* Command-line-only version */
  1103.     fatal("invalid command-line option, type 'kermit -h' for help");
  1104. #else                    /* Neither one! */
  1105.         sstate = 'x';
  1106.         proto();                        /* So go into server mode */
  1107.         doexit(GOOD_EXIT,xitsta);       /* exit with good status */
  1108. #endif /* NOCMDL */
  1109.     }
  1110. #else /* not NOICP */
  1111. /*
  1112.   If no action requested on command line, or if -S ("stay") was included,
  1113.   enter the interactive command parser.
  1114. */
  1115.     if (!clcmds)
  1116.       herald();                /* Display program herald. */
  1117.  
  1118. #ifndef NOCCTRAP            /* If not no Control-C trap */
  1119. ccagain:
  1120.     if (
  1121. #ifdef CK_POSIX_SIG
  1122.     sigsetjmp(cmjbuf,1)
  1123. #else
  1124.     setjmp(cmjbuf)
  1125. #endif /* CK_POSIX_SIG */
  1126.     ) {                /* Control-C trap returns to here. */
  1127. #ifdef GEMDOS
  1128.     cc_clean();
  1129. #endif /* GEMDOS */
  1130.     fixcmd();            /* Pop command stacks, etc. */
  1131.     clcmds = NULL;
  1132.     debug(F100,"ckcmai got interrupt","",0);
  1133.     goto ccagain;            /* set up trap again. */
  1134.     } else {
  1135.     debug(F100,"ckcmai setting interrupt trap","",0);
  1136.     setint();            /* Set up command interrupt traps */
  1137.     }
  1138. #else /* NOCCTRAP */
  1139.     setint();                /* Set up command interrupt traps */
  1140. #endif /* NOCCTRAP */
  1141.  
  1142. #ifdef MAC
  1143.     while (1) {
  1144.     extern char *lfiles;        /* Fake pointer cast */
  1145.  
  1146.     if (connected) {
  1147.         debug(F100, "main: calling macparser", "", 0);
  1148.         sstate = newparser(1, 1, 0L);
  1149.  
  1150.         /* ignore null command state */
  1151.         if (sstate == 'n')
  1152.         sstate = '\0';
  1153.  
  1154.         if (sstate)
  1155.         proto();
  1156.     }
  1157.     else {
  1158.         /*
  1159.          * process take files the finder gave us.
  1160.          */
  1161.         if ((tlevel == -1) && lfiles)
  1162.         startlfile();
  1163.  
  1164.         debug(F100, "main: calling parser", "", 0);
  1165.         sstate = parser(0);
  1166.         if (sstate == 'c')        /* if MAC connect */
  1167.         sstate = 0;
  1168.         if (sstate)
  1169.         proto();
  1170.     }
  1171.     }
  1172. #else /* Not MAC */
  1173.  
  1174. #ifndef NOSPL
  1175. /*
  1176.   If interactive commands were given on the command line (using the
  1177.   -C "command, command, ..." option), assign them to a macro called
  1178.   "cl_commands", then execute the macro and leave it defined for
  1179.   subsequent re-execution if desired.
  1180. */
  1181.     if (clcmds) {            /* Check for -C commands */
  1182.     int x;
  1183.     x = addmac("cl_commands",clcmds); /* Put macro in table */
  1184.     if (x > -1) {            /* If successful, */
  1185.         dodo(x,NULL);        /* set up for macro execution */
  1186.         while (maclvl > -1) {    /* Loop getting macro commands. */
  1187.         sstate = parser(1);
  1188.         if (sstate) proto();    /* Enter protocol if requested. */
  1189.         }
  1190.     }
  1191.     herald();
  1192.     }
  1193. #endif /* NOSPL */
  1194. /*
  1195.   Running from an application file, or a command filename was
  1196.   specified on the command line.
  1197. */
  1198.     if (*cmdfil) {
  1199.     cfilef = 1;            /* remember we did this, */
  1200.     dotake(cmdfil);            /* Command file spec'd on cmd line */
  1201.     }
  1202.     while(1) {                /* Loop getting commands. */
  1203.     sstate = parser(0);
  1204.         if (sstate) proto();            /* Enter protocol if requested. */
  1205.     }
  1206. #endif /* MAC */
  1207. #endif /* NOICP */
  1208. }
  1209.  
  1210. #ifdef DYNAMIC
  1211. /* Allocate file i/o buffers */
  1212.  
  1213. char *zinbuffer, *zoutbuffer;
  1214.  
  1215. int
  1216. getiobs() {
  1217.     zinbuffer = (char *)malloc(INBUFSIZE);
  1218.     if (!zinbuffer) return(-1);
  1219.     zoutbuffer = (char *)malloc(OBUFSIZE);
  1220.     if (!zoutbuffer) return(-1);
  1221.     debug(F100,"getiobs ok","",0);
  1222.     return(0);
  1223. }
  1224. #endif /* DYNAMIC */
  1225.