Annotation of coherent/e/bin/cku179/ckcmai.c, revision 1.1

1.1     ! root        1: char *versio = "C-Kermit 5A(179) BETA, 8 Feb 92"; /* Version herald. */
        !             2: long vernum =            501179L;
        !             3: /*
        !             4:  String and numeric version numbers, keep these two in sync!
        !             5:  Second digit of vernum: 0 = A, 1 = B, etc.
        !             6: */
        !             7: 
        !             8: #ifndef VERWHO
        !             9: /* Change verwho in following line, or with -DVERWHO=x in makefile CFLAGS. */
        !            10: #define VERWHO 0
        !            11: #endif /* VERWHO */
        !            12: int verwho = VERWHO; /* Who produced this version, 0 = Columbia University */
        !            13: /*
        !            14:  IMPORTANT: If you are working on your own private version of C-Kermit, please
        !            15:  include some special notation, like your site name or your initials, in the
        !            16:  "versio" string, e.g. "5A(159)-XXX", and use a nonzero code for the "verwho"
        !            17:  variable (e.g. in the USA use your zip code).  Unless we stick to this
        !            18:  discipline, divergent copies of C-Kermit will begin to appear that are
        !            19:  intistinguishable from each other, which is a big support issue.  Also, if
        !            20:  you have edited C-Kermit and made copies available to others, please add
        !            21:  appropriate text to the BUG command (ckuus6.c, function dobug()).
        !            22: */
        !            23: #define CKCMAI
        !            24: 
        !            25: /*  C K C M A I  --  C-Kermit Main program  */
        !            26: 
        !            27: /*
        !            28:  Author: Frank da Cruz ([email protected], [email protected]),
        !            29:  Columbia University Center for Computing Activities.
        !            30:  First released January 1985.
        !            31:  Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New 
        !            32:  York.  Permission is granted to any individual or institution to use, copy, or
        !            33:  redistribute this software as long as it is not sold for profit, provided this
        !            34:  copyright notice is retained. 
        !            35: */
        !            36: /*
        !            37:  The Kermit file transfer protocol was developed at the Columbia University
        !            38:  Center for Computing Activities (CUCCA).  It is named after Kermit the Frog,
        !            39:  star of the television series THE MUPPET SHOW; the name is used by permission
        !            40:  of Henson Associates, Inc.  "Kermit" is also Celtic for "free".
        !            41: */
        !            42: /*
        !            43:  Thanks to at least the following people for their contributions to this 
        !            44:  program over the years, and apologies to anybody I missed:
        !            45: 
        !            46:    Chris Adie, Edinburgh U, Scotland (OS/2 support)
        !            47:    Larry Afrin, Clemson U
        !            48:    Barry Archer, U of Missouri
        !            49:    Robert Andersson, Oslo, Norway
        !            50:    Chris Armstrong, Brookhaven National Lab (OS/2)
        !            51:    William Bader, Moravian College
        !            52:    Fuat Baran, CUCCA
        !            53:    Stan Barber, Rice U
        !            54:    Jim Barbour, U of Colorado
        !            55:    Nelson Beebe, U of Utah
        !            56:    Karl Berry, UMB
        !            57:    Charles Brooks, EDN
        !            58:    Mike Brown, Purdue U
        !            59:    Mark Buda, DEC (VAX/VMS)
        !            60:    Bjorn Carlsson, Stockholm University Computer Center QZ
        !            61:    Bill Catchings, formerly of CUCCA
        !            62:    Bob Cattani, Columbia U CS Dept
        !            63:    John Chandler, Harvard U / Smithsonian Astronomical Observatory
        !            64:    John L. Chmielewski, AT&T, Lisle, IL
        !            65:    Howard Chu, U of Michigan
        !            66:    Bill Coalson, McDonnell Douglas
        !            67:    Bertie Coopersmith, London, UK
        !            68:    Alan Crosswell, CUCCA
        !            69:    Jeff Damens, formerly of CUCCA
        !            70:    Mark Davies, Bath U, UK
        !            71:    Joe R. Doupnik, Utah State U
        !            72:    S. Dezawa, Fujifilm, Japan
        !            73:    Frank Dreano (Honeywell)
        !            74:    Kristoffer Eriksson, Peridot Konsult AB, Oerebro, Sweden
        !            75:    John R. Evans, IRS, Kansas City
        !            76:    Glenn Everhart, RCA Labs
        !            77:    Herm Fischer, Encino, CA (extensive contributions to version 4.0)
        !            78:    Carl Fongheiser, CWRU
        !            79:    Marcello Frutig, Catholic University, Sao Paulo, Brazil (X.25 support)
        !            80:    Hirofumi Fujii, Japan Nat'l Lab for High Energy Physics, Tokyo (Kanji)
        !            81:    Andy Fyfe, Caltech
        !            82:    Christine M. Gianone, CUCCA
        !            83:    John Gilmore, UC Berkeley
        !            84:    German Goldszmidt, IBM
        !            85:    Chris Green, Essex U, UK
        !            86:    Yekta Gursel, MIT
        !            87:    Jim Guyton, Rand Corp
        !            88:    Stan Hanks, Rice U.
        !            89:    Ken Harrenstein, SRI
        !            90:    James Harvey, Indiana/Purdue U (VMS)
        !            91:    Rob Healey, [email protected]
        !            92:    Chuck Hedrick, Rutgers U
        !            93:    Ron Heiby, Technical Systems Division, Motorola Computer Group
        !            94:    Steve Hemminger, Tektronix
        !            95:    Christian Hemsing, RWTH Aachen, Germany (OS-9)
        !            96:    Andrew Herbert, Monash Univ, Australia
        !            97:    Mike Hickey, ITI
        !            98:    Randy Huntziger, National Library of Medicine
        !            99:    Larry Jacobs, Transarc
        !           100:    Mark B. Johnson, Apple Computer
        !           101:    Peter Jones, U of Quebec Montreal
        !           102:    Phil Julian, SAS Institute
        !           103:    Marion Kananson, [email protected]
        !           104:    Sergey Kartashoff, Institute of..., Moscow, USSR
        !           105:    Howie Kaye, CUCCA
        !           106:    Rob Kedoin, Linotype Co, Hauppauge, NY (OS/2)
        !           107:    Terry Kennedy, St Peter's College, Jersey City, NJ (VAX/VMS, 2.11 BSD)
        !           108:    Douglas Kingston, morgan.com
        !           109:    Tom Kloos, Sequent Computer Systems
        !           110:    Jim Knutson, U of Texas at Austin
        !           111:    Thomas Krueger, UWM
        !           112:    Bo Kullmar, Central Bank of Sweden, Kista
        !           113:    John Kunze, UC Berkeley
        !           114:    Bob Larson, USC (OS-9)
        !           115:    Bert Laverman, Groningen U, Netherlands
        !           116:    David Lawyer, UC Irvine
        !           117:    S.O. Lidie, Lehigh U
        !           118:    Tor Lillqvist, Helsinki University, Finland
        !           119:    Kevin Lowey, U of Saskatchewan (OS/2)
        !           120:    David MacKenzie, Environmental Defense Fund, University of Maryland
        !           121:    John Mackin, University of Sidney, Australia
        !           122:    Martin Maclaren, Bath U, UK
        !           123:    Chris Maio, Columbia U CS Dept
        !           124:    Fulvio Marino, Olivetti, Ivrea, Italy
        !           125:    Peter Mauzey, AT&T
        !           126:    Tye McQueen, Utah State U
        !           127:    Hellmuth Michaelis
        !           128:    Leslie Mikesell, American Farm Bureau
        !           129:    Martin Minow, DEC (VAX/VMS)
        !           130:    Ray Moody, Purdue U
        !           131:    Bruce J Moore (Atari ST)
        !           132:    Steve Morley, Convex
        !           133:    Tony Movshon, NYU
        !           134:    Dan Murphy, ???
        !           135:    Gary Mussar,
        !           136:    Jim Noble, Planning Research Corporation (Macintosh)
        !           137:    Ian O'Brien, Bath U, UK
        !           138:    Paul Placeway, Ohio State U (Macintosh & more)
        !           139:    Piet W. Plomp, ICCE, Groningen University, Netherlands
        !           140:    Ken Poulton, HP Labs
        !           141:    Manfred Prange, Oakland U
        !           142:    Frank Prindle, NADC
        !           143:    Anton Rang
        !           144:    Scott Ribe
        !           145:    Alan Robiette, Oxford University, UK
        !           146:    Michel Robitaille, U of Montreal (Mac)
        !           147:    Kai Uwe Rommel, Technische Universitaet Muenchen (OS/2)
        !           148:    Larry Rosenman (Amiga)
        !           149:    Jay Rouman, U of Michigan
        !           150:    Jack Rouse, SAS Institute (Data General and/or Apollo)
        !           151:    Stew Rubenstein, Harvard U (VAX/VMS)
        !           152:    Eric Schnoebelen, Convex
        !           153:    Benn Schreiber, DEC
        !           154:    Dan Schullman, DEC (modems, DIAL command, etc)
        !           155:    John Schultz, 3M
        !           156:    Steven Schultz, Contel (PDP-11)
        !           157:    Gordon Scott, Micro Focus, Newbury UK
        !           158:    Gisbert W. Selke, WIdO, Bonn, Germany
        !           159:    David Sizeland, U of London Medical School
        !           160:    Bradley Smith, UCLA
        !           161:    Richard Smith, Cal State
        !           162:    Ryan Stanisfer
        !           163:    Peter Svanberg, Royal Techn. HS, Sweden
        !           164:    Andy Tanenbaum, Vrije U, Amsterdam, Netherlands
        !           165:    Markku Toijala, Helsinki U of Technology
        !           166:    Rick Troxel, NIH
        !           167:    Warren Tucker, Tridom Corp, Mountain Park, GA
        !           168:    Dave Tweten, AMES-NAS
        !           169:    Walter Underwood, Ford Aerospace
        !           170:    Pieter Van Der Linden, Centre Mondial, Paris
        !           171:    Ge van Geldorp, Netherlands
        !           172:    Fred van Kempen, MINIX User Group, Voorhout, Netherlands
        !           173:    Wayne Van Pelt, GE/CRD
        !           174:    Mark Vasoll, Oklahoma State U (V7 UNIX)
        !           175:    Paul Vixie (DEC)
        !           176:    Roger Wallace, Raytheon
        !           177:    Stephen Walton, Calif State U, Northridge (Amiga)
        !           178:    Jamie Watson, Switzerland (RS/6000)
        !           179:    Rick Watson, U of Texas (Macintosh)
        !           180:    Lauren Weinstein
        !           181:    Joachim Wiesel, U of Karlsruhe
        !           182:    Michael Williams, UCLA
        !           183:    Patrick Wolfe, Kuck & Associates, Inc.
        !           184:    Gregg Wonderly, Oklahoma State U (V7 UNIX)
        !           185:    Farrell Woods, Concurrent (formerly Masscomp)
        !           186:    Dave Woolley, CAP Communication Systems, London
        !           187:    Jack Woolley, SCT Corp
        !           188:    Ken Yap, U of Rochester
        !           189:    John Zeeff, Ann Arbor, MI
        !           190: */
        !           191: /*
        !           192:   ckcsym.h is used for for defining symbols that normally would be defined
        !           193:   using -D or -d on the cc command line, for use with compilers that don't
        !           194:   support this feature.
        !           195: */
        !           196: #include "ckcsym.h"
        !           197: #include "ckcasc.h"                    /* ASCII character symbols */
        !           198: #include "ckcdeb.h"                    /* Debug & other symbols */
        !           199: #include "ckcker.h"                    /* Kermit symbols */
        !           200: #include "ckcnet.h"                    /* Network symbols */
        !           201: #ifndef NOSPL
        !           202: #include "ckuusr.h"
        !           203: #endif /* NOSPL */
        !           204: 
        !           205: #ifndef NOSERVER
        !           206: /* Text message definitions.. each should be 256 chars long, or less. */
        !           207: #ifdef MAC
        !           208: char *hlptxt = "\r\
        !           209: Mac Kermit Server Commands:\r\
        !           210: \r\
        !           211:     BYE\r\
        !           212:     FINISH\r\
        !           213:     GET filespec\r\
        !           214:     REMOTE CD directory\r\
        !           215:     REMOTE HELP\r\
        !           216:     SEND filespec\r\
        !           217: \r\0";
        !           218: #else
        !           219: #ifdef AMIGA
        !           220: char *hlptxt = "C-Kermit Server Commands:\n\
        !           221: \n\
        !           222: GET filespec, SEND filespec, FINISH, BYE, REMOTE HELP\n\
        !           223: \n\0";
        !           224: #else
        !           225: #ifdef OS2
        !           226: char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
        !           227: \n\
        !           228: GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\n\
        !           229: SEND files REMOTE SPACE [dir]  REMOTE HOST command\n\
        !           230: FINISH     REMOTE DELETE files REMOTE TYPE files\n\
        !           231: BYE        REMOTE HELP         REMOTE SET parameter value\n\
        !           232: \n\0";
        !           233: #else
        !           234: #ifdef MINIX
        !           235: char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
        !           236: GET SEND BYE FINISH REMOTE: CD DEL DIR HELP HOST SET SPACE TYPE WHO\n\0";
        !           237: #else
        !           238: #ifdef VMS
        !           239: char *hlptxt = "C-Kermit Server REMOTE Commands:\r\n\
        !           240: \r\n\
        !           241: GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\r\n\
        !           242: SEND files REMOTE SPACE [dir]  REMOTE HOST command\r\n\
        !           243: MAIL files REMOTE DELETE files REMOTE WHO [user]\r\n\
        !           244: BYE        REMOTE PRINT files  REMOTE TYPE files\r\n\
        !           245: FINISH     REMOTE HELP         REMOTE SET parameter value\r\n\
        !           246: \0";
        !           247: #else
        !           248: char *hlptxt = "C-Kermit Server REMOTE Commands:\n\
        !           249: \n\
        !           250: GET files  REMOTE CD [dir]     REMOTE DIRECTORY [files]\n\
        !           251: SEND files REMOTE SPACE [dir]  REMOTE HOST command\n\
        !           252: MAIL files REMOTE DELETE files REMOTE WHO [user]\n\
        !           253: BYE        REMOTE PRINT files  REMOTE TYPE files\n\
        !           254: FINISH     REMOTE HELP         REMOTE SET parameter value\n\
        !           255: \n\0";
        !           256: #endif
        !           257: #endif
        !           258: #endif
        !           259: #endif
        !           260: #endif
        !           261: 
        !           262: #ifdef MINIX
        !           263: char *srvtxt = "\r\n\
        !           264: Entering server mode.\r\n\
        !           265: \n\0";
        !           266: #else
        !           267: #ifdef OSK
        !           268: char *srvtxt = "\r\l\
        !           269: C-Kermit server starting.  Return to your local machine by typing\r\l\
        !           270: its escape sequence for closing the connection, and issue further\r\l\
        !           271: commands from there.  To shut down the C-Kermit server, issue the\r\l\
        !           272: BYE command to logout, or the FINISH command and then reconnect.\r\l\
        !           273: \l\0";
        !           274: #else
        !           275: char *srvtxt = "\r\n\
        !           276: C-Kermit server starting.  Return to your local machine by typing\r\n\
        !           277: its escape sequence for closing the connection, and issue further\r\n\
        !           278: commands from there.  To shut down the C-Kermit server, issue the\r\n\
        !           279: BYE command to logout, or the FINISH command and then reconnect.\r\n\
        !           280: \r\n\0";
        !           281: #endif
        !           282: #endif
        !           283: #else
        !           284: char *srvtxt = "";
        !           285: #endif /* NOSERVER */
        !           286: 
        !           287: /* Declarations for Send-Init Parameters */
        !           288: 
        !           289: int spsiz = DSPSIZ,                     /* Current packet size to send */
        !           290:     spmax = DSPSIZ,            /* (PWP) Biggest packet size we can send */
        !           291:                                 /* (see rcalcpsz()) */
        !           292:     spsizr = DSPSIZ,                   /* Send-packet size requested */
        !           293:     spsizf = 0,                         /* Flag to override what you ask for */
        !           294:     rpsiz = DRPSIZ,                     /* Biggest we want to receive */
        !           295:     urpsiz = DRPSIZ,                   /* User-requested rpsiz */
        !           296:     maxrps = MAXRP,                    /* Maximum incoming long packet size */
        !           297:     maxsps = MAXSP,                    /* Maximum outbound l.p. size */
        !           298:     maxtry = MAXTRY,                   /* Maximum retries per packet */
        !           299:     wslots = 1,                                /* Window size in use */
        !           300:     wslotr = 1,                                /* Window size requested */
        !           301:     wslotn = 1,                                /* Window size negotiated */
        !           302:     timeouts = 0,                      /* For statistics reporting */
        !           303:     spackets = 0,                      /*  ... */
        !           304:     rpackets = 0,                      /*  ... */
        !           305:     retrans = 0,                       /*  ... */
        !           306:     crunched = 0,                      /*  ... */
        !           307:     wmax = 0,                          /*  ... */
        !           308:     timint = DMYTIM,                    /* Timeout interval I use */
        !           309:     srvtim = DSRVTIM,                  /* Server command wait timeout */
        !           310:     srvdis = 0,                                /* Server file xfer display */
        !           311:     pkttim = DMYTIM,                   /* Normal packet wait timeout */
        !           312:     rtimo = URTIME,                     /* Timeout I want you to use */
        !           313:     timef = 0,                          /* Flag to override what you ask */
        !           314:     npad = MYPADN,                      /* How much padding to send */
        !           315:     mypadn = MYPADN,                    /* How much padding to ask for */
        !           316:     bctr = 1,                           /* Block check type requested */
        !           317:     bctu = 1,                           /* Block check type used */
        !           318:     ebq =  MYEBQ,                       /* 8th bit prefix */
        !           319:     ebqflg = 0,                         /* 8th-bit quoting flag */
        !           320:     rqf = -1,                          /* Flag used in 8bq negotiation */
        !           321:     rq = 0,                            /* Received 8bq bid */
        !           322:     sq = 'Y',                          /* Sent 8bq bid */
        !           323:     rpt = 0,                            /* Repeat count */
        !           324:     rptq = MYRPTQ,                      /* Repeat prefix */
        !           325:     rptflg = 0;                         /* Repeat processing flag */
        !           326: 
        !           327: int capas = 9,                         /* Position of Capabilities */
        !           328:     atcapb = 8,                                /* Attribute capability */
        !           329:     atcapr = 1,                                /*  requested */
        !           330:     atcapu = 0,                                /*  used */
        !           331:     swcapb = 4,                                /* Sliding Window capability */
        !           332:     swcapr = 1,                                /*  requested (allowed) */
        !           333:     swcapu = 0,                                /*  used */
        !           334:     lpcapb = 2,                                /* Long Packet capability */
        !           335:     lpcapr = 1,                                /*  requested */
        !           336:     lpcapu = 0,                                /*  used */
        !           337:     lscapb = 32,                       /* Locking Shift capability */
        !           338:     lscapr = 1,                                /*  requested by default */
        !           339:     lscapu = 0;                                /*  used */
        !           340: 
        !           341: /* Flags for whether to use particular attributes */
        !           342: 
        !           343: int atenci = 1,                                /* Encoding in */
        !           344:     atenco = 1,                                /* Encoding out */
        !           345:     atdati = 1,                                /* Date in */
        !           346:     atdato = 1,                                /* Date out */
        !           347:     atdisi = 1,                                /* Disposition in/out */
        !           348:     atdiso = 1,
        !           349:     atleni = 1,                                /* Length in/out (both kinds) */
        !           350:     atleno = 1,
        !           351:     atblki = 1,                                /* Blocksize in/out */
        !           352:     atblko = 1,
        !           353:     attypi = 1,                                /* File type in/out */
        !           354:     attypo = 1,
        !           355:     atsidi = 1,                                /* System ID in/out */
        !           356:     atsido = 1,
        !           357:     atsysi = 1,                               /* System-dependent parameters in/out */
        !           358:     atsyso = 1;
        !           359: 
        !           360: CHAR padch = MYPADC,                    /* Padding character to send */
        !           361:     mypadc = MYPADC,                    /* Padding character to ask for */
        !           362:     seol = MYEOL,                       /* End-Of-Line character to send */
        !           363:     eol = MYEOL,                        /* End-Of-Line character to look for */
        !           364:     ctlq = CTLQ,                        /* Control prefix in incoming data */
        !           365:     myctlq = CTLQ;                      /* Outbound control character prefix */
        !           366: 
        !           367: struct zattr iattr;                    /* Incoming file attributes */
        !           368: 
        !           369: /* File related variables, mainly for the benefit of VAX/VMS */
        !           370: 
        !           371: int fblksiz = DBLKSIZ;         /* File blocksize */
        !           372: int frecl = DLRECL;            /* File record length */
        !           373: int frecfm = XYFF_S;           /* File record format (default = stream) */
        !           374: int forg = XYFO_S;             /* File organization (sequential) */
        !           375: int fcctrl = XYFP_N;           /* File carriage control (ctrl chars) */
        !           376: 
        !           377: #ifdef VMS
        !           378: /* VMS labeled file options */
        !           379: int lf_opts = LBL_NAM;
        !           380: #else
        !           381: int lf_opts = 0;
        !           382: #endif /* VMS */
        !           383: 
        !           384: /* Packet-related variables */
        !           385: 
        !           386: int pktnum = 0,                         /* Current packet number */
        !           387:     sndtyp = 0,                                /* Type of packet just sent */
        !           388:     rsn,                               /* Received packet sequence number */
        !           389:     rln,                               /* Received packet length */
        !           390:     size,                               /* Current size of output pkt data */
        !           391:     osize,                              /* Previous output packet data size */
        !           392:     maxsize,                            /* Max size for building data field */
        !           393:     spktl = 0,                         /* Length packet being sent */
        !           394:     rprintf,                           /* REMOTE PRINT flag */
        !           395:     rmailf;                            /* MAIL flag */
        !           396: 
        !           397: CHAR
        !           398: #ifdef NO_MORE  /* Buffers used before sliding windows... */
        !           399:     sndpkt[MAXSP+100],                 /* Entire packet being sent */
        !           400:     recpkt[MAXRP+200],                 /* Packet most recently received */
        !           401:     data[MAXSP+4],                     /* Packet data buffer */
        !           402: #endif
        !           403: #ifdef DYNAMIC
        !           404:     *srvcmd = (CHAR *)0,               /* Where to decode server command */
        !           405: #else
        !           406:     srvcmd[MAXRP+4],                    /* Where to decode server command */
        !           407: #endif
        !           408:     padbuf[95],                                /* Buffer for send-padding */
        !           409:     *recpkt,
        !           410:     *rdatap,                           /* Pointer to received packet data */
        !           411:     *data = (CHAR *)0,                 /* Pointer to send-packet data */
        !           412:     *srvptr,                            /* Pointer to srvcmd */
        !           413:     mystch = SOH,                       /* Outbound packet-start character */
        !           414:     stchr = SOH;                        /* Incoming packet-start character */
        !           415: 
        !           416: /* File-related variables */
        !           417: 
        !           418: char filnam[257];                       /* Name of current file. */
        !           419: char cmdfil[80];                       /* Application file name. */
        !           420: 
        !           421: int nfils = 0;                         /* Number of files in file group */
        !           422: long fsize;                             /* Size of current file */
        !           423: int wildxpand = 0;                     /* Who expands wildcards */
        !           424: int clfils = 0;                                /* Flag for command-line files */
        !           425: int stayflg = 0;                       /* Flag for "stay", i.e. "-S" */
        !           426: 
        !           427: /* Communication line variables */
        !           428: 
        !           429: char ttname[50];                        /* Name of communication line. */
        !           430: 
        !           431: #ifdef MAC
        !           432: int connected = 0;                     /* true if connected */
        !           433: int startconnected;                    /* initial state of connected */
        !           434: #endif /* MAC */
        !           435: 
        !           436: long speed = -1L;                      /* Line speed */
        !           437: int mdmspd = 1;                                /* Modem changes speed flag */
        !           438: 
        !           439: #ifndef NODIAL
        !           440: int dialhng = 1;                       /* Whether to hangup before dialing */
        !           441: int dialtmo = 0;                       /* Secs to wait for call to complete */
        !           442: int dialksp = 0;                       /* Kermit spoof in modem */
        !           443: int dialdpy = 0;                       /* Dial display */
        !           444: int dialmnp = 0;                       /* Dial MNP-negotiation enabled */
        !           445: char *dialini = (char *) 0;            /* User-spec'd dialer init string */
        !           446: #endif /* NODIAL */
        !           447: 
        !           448: int parity,                             /* Parity specified, 0,'e','o',etc */
        !           449:     autopar = 0,                       /* Automatic parity change flag */
        !           450:     sosi = 0,                          /* Shift-In/Out flag */
        !           451:     flow,                               /* Flow control */
        !           452:     turn = 0,                           /* Line turnaround handshake flag */
        !           453:     turnch = XON,                       /* Line turnaround character */
        !           454:     duplex = 0,                         /* Duplex, full by default */
        !           455:     escape = DFESC,                    /* Escape character for connect */
        !           456:     delay = DDELAY,                     /* Initial delay before sending */
        !           457:     tnlm = 0,                          /* Terminal newline mode */
        !           458:     mdmtyp = 0;                         /* Modem type (initially none)  */
        !           459: 
        !           460: /* Networks for SET HOST */
        !           461: 
        !           462: #define MYHOSTL 100
        !           463:     char myhost[MYHOSTL];              /* Local host name */
        !           464:     int network = 0;                   /* Network vs tty connection */
        !           465:     int nettype = NET_TCPB;            /* Assume TCP/IP (BSD sockets) */
        !           466: 
        !           467: #ifdef SUNX25
        !           468:     extern initpad();
        !           469:     int revcall = 0;            /* X.25 reverse call not selected */
        !           470:     int closgr  = -1;          /* X.25 closed user group not selected */
        !           471:     int cudata = 0;            /* X.25 call user data not specified */
        !           472:     char udata[MAXCUDATA];     /* X.25 call user data */
        !           473: #endif /* SUNX25 */
        !           474: 
        !           475: /* Other recent additions */
        !           476: 
        !           477:     int tlevel = -1;                   /* Take-file command level */
        !           478: #ifndef NOSPL
        !           479:     extern int maclvl;                 /* Macro invocation level */
        !           480: #endif /* NOSPL */
        !           481:     int carrier = CAR_AUT;             /* Pay attention to carrier signal */
        !           482:     int cdtimo = 0;                    /* Carrier wait timeout */
        !           483:     int xitsta = GOOD_EXIT;            /* Program exit status */
        !           484: #ifdef VMS                             /* Default filename collision action */
        !           485:     int fncact = XYFX_X;               /* REPLACE for VAX/VMS */
        !           486: #else
        !           487:     int fncact = XYFX_B;               /* BACKUP for everybody else */
        !           488: #endif /* VMS */
        !           489:     int bgset = -1;                    /* BACKGROUND mode set explicitly */
        !           490: #ifdef UNIX
        !           491:     int suspend = DFSUSP;              /* Whether SUSPEND command, etc, */
        !           492: #else                                  /* is to be allowed. */
        !           493:     int suspend = 0;
        !           494: #endif /* UNIX */
        !           495: 
        !           496: /* Statistics variables */
        !           497: 
        !           498: long filcnt,                    /* Number of files in transaction */
        !           499:     flci,                       /* Characters from line, current file */
        !           500:     flco,                       /* Chars to line, current file  */
        !           501:     tlci,                       /* Chars from line in transaction */
        !           502:     tlco,                       /* Chars to line in transaction */
        !           503:     ffc,                        /* Chars to/from current file */
        !           504:     tfc,                        /* Chars to/from files in transaction */
        !           505:     rptn;                      /* Repeated characters compressed */
        !           506: 
        !           507: int tsecs;                      /* Seconds for transaction */
        !           508: 
        !           509: /* Flags */
        !           510: 
        !           511: int deblog = 0,                         /* Flag for debug logging */
        !           512:     debses = 0,                                /* Flag for DEBUG SESSION */
        !           513:     pktlog = 0,                         /* Flag for packet logging */
        !           514:     seslog = 0,                         /* Session logging */
        !           515:     tralog = 0,                         /* Transaction logging */
        !           516:     displa = 0,                         /* File transfer display on/off */
        !           517:     stdouf = 0,                         /* Flag for output to stdout */
        !           518:     stdinf = 0,                                /* Flag for input from stdin */
        !           519:     xflg   = 0,                         /* Flag for X instead of F packet */
        !           520:     hcflg  = 0,                         /* Doing Host command */
        !           521:     fncnv  = 1,                         /* Flag for file name conversion */
        !           522:     binary = 0,                         /* Flag for binary file */
        !           523:     savmod = 0,                         /* Saved file mode (whole session) */
        !           524:     bsave  = 0,                                /* Saved file mode (per file) */
        !           525:     bsavef = 0,                                /* Flag if bsave was used. */
        !           526:     cmask  = 0177,                     /* Connect byte mask */
        !           527:     fmask  = 0377,                     /* File byte mask */
        !           528:     warn   = 0,                         /* Flag for file warning */
        !           529:     quiet  = 0,                         /* Be quiet during file transfer */
        !           530:     local  = 0,                         /* Flag for external tty vs stdout */
        !           531:     server = 0,                         /* Flag for being a server */
        !           532:     cflg   = 0,                                /* Connect before transaction */
        !           533:     cnflg  = 0,                         /* Connect after transaction */
        !           534:     cxseen = 0,                         /* Flag for cancelling a file */
        !           535:     czseen = 0,                         /* Flag for cancelling file group */
        !           536:     discard = 0,                       /* Flag for file to be discarded */
        !           537:     keep = 0,                           /* Keep incomplete files */
        !           538:     unkcs = 1,                         /* Keep file w/unknown character set */
        !           539:     nakstate = 0,                      /* In a state where we can send NAKs */
        !           540:     dblchar = -1;                      /* Character to double when sending */
        !           541: 
        !           542: /* Variables passed from command parser to protocol module */
        !           543: 
        !           544: #ifndef NOSPL
        !           545: _PROTOTYP( int parser, (int) );         /* The parser itself */
        !           546: char *clcmds = NULL;                   /* Pointer to command-line commands */
        !           547: #endif /* NOSPL */
        !           548: 
        !           549: CHAR sstate  = (CHAR) 0;                /* Starting state for automaton */
        !           550: CHAR zstate  = (CHAR) 0;               /* For remembering sstate */
        !           551: char *cmarg  = "";                      /* Pointer to command data */
        !           552: char *cmarg2 = "";                      /* Pointer to 2nd command data */
        !           553: char **cmlist;                          /* Pointer to file list in argv */
        !           554: 
        !           555: /* Flags for the ENABLE and DISABLE commands */
        !           556: 
        !           557: int en_cwd = 1;                                /* CD/CWD */
        !           558: int en_del = 1;                                /* DELETE */
        !           559: int en_dir = 1;                                /* DIRECTORY */
        !           560: int en_fin = 1;                                /* FINISH/BYE */
        !           561: int en_get = 1;                                /* GET */
        !           562: #ifndef NOPUSH
        !           563: int en_hos = 1;                                /* HOST enabled */
        !           564: #else
        !           565: int en_hos = 0;                                /* HOST disabled */
        !           566: #endif /* NOPUSH */
        !           567: int en_sen = 1;                                /* SEND */
        !           568: int en_set = 1;                                /* SET */
        !           569: int en_spa = 1;                                /* SPACE */
        !           570: int en_typ = 1;                                /* TYPE */
        !           571: int en_who = 1;                                /* WHO */
        !           572: int en_bye = 1;                                /* BYE */
        !           573: 
        !           574: /* Miscellaneous */
        !           575: 
        !           576: char **xargv;                           /* Global copies of argv */
        !           577: int  xargc;                             /* and argc  */
        !           578: int xargs;                             /* an immutable copy of argc */
        !           579: char *xarg0;                           /* and of argv[0] */
        !           580: 
        !           581: extern char *dftty;                     /* Default tty name from ck?tio.c */
        !           582: extern int dfloc;                       /* Default location: remote/local */
        !           583: extern int dfprty;                      /* Default parity */
        !           584: extern int dfflow;                      /* Default flow control */
        !           585: 
        !           586: /*
        !           587:   Buffered file input and output buffers.  See getpkt() in ckcfns.c
        !           588:   and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).
        !           589: */
        !           590: #ifndef DYNAMIC
        !           591: /* Now we allocate them dynamically, see getiobs() below. */
        !           592: char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];
        !           593: #endif
        !           594: char *zinptr, *zoutptr;
        !           595: int zincnt, zoutcnt;
        !           596: 
        !           597: _PROTOTYP( int getiobs, (void) );
        !           598: 
        !           599: /*  M A I N  --  C-Kermit main program  */
        !           600: 
        !           601: #ifndef NOCCTRAP
        !           602: #include <setjmp.h>
        !           603: extern jmp_buf cmjbuf;
        !           604: #ifdef GEMDOS                          /* Special for Atari ST */
        !           605:     cc_clean();
        !           606: #endif /* GEMDOS */
        !           607: #endif /* NOCCTRAP */
        !           608: 
        !           609: #ifdef aegis
        !           610: /* On the Apollo, intercept main to insert a cleanup handler */
        !           611: int
        !           612: ckcmai(argc,argv) int argc; char **argv;
        !           613: #else
        !           614: #ifdef MAC
        !           615: int main (void)
        !           616: #else
        !           617: int
        !           618: main(argc,argv) int argc; char **argv;
        !           619: #endif /* MAC */
        !           620: #endif /* aegis */
        !           621: {
        !           622: 
        !           623: /* Do some initialization */
        !           624: 
        !           625:     if (sysinit() < 0)                 /* System-dependent initialization. */
        !           626:       fatal("Can't initialize!");
        !           627:     connoi();                          /* Console interrupts off */
        !           628: #ifndef MAC
        !           629:     xargc = xargs = argc;              /* Make global copies of argc */
        !           630:     xargv = argv;                       /* ...and argv. */
        !           631:     xarg0 = argv[0];
        !           632: #endif /* MAC */
        !           633:     sstate = 0;                         /* No default start state. */
        !           634: #ifdef DYNAMIC
        !           635:     if (getiobs() < 0) 
        !           636:       fatal("Can't allocate i/o buffers!");
        !           637: #endif /* DYNAMIC */
        !           638:     ckhost(myhost,MYHOSTL);            /* Name of local host */
        !           639:     strcpy(ttname,dftty);               /* Set up default tty name. */
        !           640:     local = dfloc;                      /* And whether it's local or remote. */
        !           641:     parity = dfprty;                    /* Set initial parity, */
        !           642:     flow = dfflow;                      /* and flow control. */
        !           643: 
        !           644: #ifndef COHERENT
        !           645:     if (local) if (ttopen(ttname,&local,0,0) < 0) { /* If default tty line */
        !           646:        printf("%s: Can't open device\n",ttname);   /* is external, open it */
        !           647:        local = 0;                                  /* now... */
        !           648:        strcpy(ttname,CTTNAM);
        !           649:     }
        !           650: #endif
        !           651: 
        !           652:     speed = ttgspd();                  /* Get transmission speed. */
        !           653: 
        !           654: #ifdef SUNX25
        !           655:     initpad();                          /* Initialize X.25 PAD */
        !           656: #endif /* SUNX25 */
        !           657: 
        !           658:     if (inibufs(SBSIZ,RBSIZ) < 0)      /* Allocate packet buffers */
        !           659:       fatal("Can't allocate packet buffers!");
        !           660: 
        !           661: #ifndef NOICP
        !           662: 
        !           663: #ifdef MAC
        !           664:     cmdini();
        !           665: #else /* Not MAC */
        !           666: /* Attempt to take ini file before doing command line */
        !           667: 
        !           668:     *cmdfil = '\0';                    /* Assume no command file. */
        !           669:     prescan();                         /* But first check for -y option */
        !           670: 
        !           671: #ifndef NOCCTRAP
        !           672:     setint();                          /* Set up interrupts */
        !           673:     if (setjmp(cmjbuf)) {              /* Control-C trap returns to here. */
        !           674:        doexit(GOOD_EXIT,-1);           /* Exit with good status. */
        !           675:     } else {
        !           676: #endif /* NOCCTRAP */
        !           677:        cmdini();                       /* Sets tlevel */
        !           678:        while (tlevel > -1) {           /* Execute init file. */
        !           679:            sstate = parser(0);         /* Loop getting commands. */
        !           680:            if (sstate) proto();        /* Enter protocol if requested. */
        !           681:        }
        !           682: #ifndef NOCCTRAP
        !           683:     }
        !           684: #endif /* NOCCTRAP */
        !           685: 
        !           686: /*
        !           687:   In UNIX there are two ways to invoke Kermit with a cmdfile:
        !           688:   (1) From the kermit command line, e.g. "kermit cmdfile [ options... ]"
        !           689:       argv[0] = "kermit"
        !           690:       argv[1] = "cmdfile"
        !           691:   (2) By executing a cmdfile whose first line is like "#!/path/kermit"
        !           692:       argv[0] = "/path/kermit" (sometimes just "kermit")
        !           693:       argv[1] = "/path/cmdfile"
        !           694: */
        !           695:     if (argc > 1) {
        !           696:        if (*argv[1] != '-') {
        !           697:            if (zchki(argv[1]) > 0) {
        !           698:                strcpy(cmdfil,argv[1]);
        !           699:            }
        !           700:        }
        !           701:     }
        !           702:     if (*cmdfil) {                     /* If we got one, */
        !           703:        dotake(cmdfil);                 /* execute it */
        !           704:        while (tlevel > -1) {           /* until it runs out. */
        !           705:            sstate = parser(1);         /* Loop getting commands. */
        !           706:            if (sstate) proto();        /* Enter protocol if requested. */
        !           707:        }
        !           708:     }
        !           709:     *cmdfil = '\0';
        !           710: #endif /* MAC */
        !           711: #endif /* NOICP */
        !           712: 
        !           713: #ifndef NOCMDL
        !           714: /* Look for a UNIX-style command line... */
        !           715: 
        !           716:     if (argc > 1) {                     /* Command line arguments? */
        !           717:         sstate = cmdlin();              /* Yes, parse. */
        !           718:        zstate = sstate;                /* Remember sstate around protocol */
        !           719:        if (cflg) conect();             /* Connect first if requested */
        !           720:         if (sstate) {
        !           721:            if (displa) concb((char)escape); /* (for console "interrupts") */
        !           722: #ifndef NOCCTRAP
        !           723:            setint();                   /* Set up interrupts */
        !           724:            if (setjmp(cmjbuf)) {       /* Control-C trap returns to here. */
        !           725: #ifdef GEMDOS
        !           726:                cc_clean();
        !           727: #endif /* GEMDOS */
        !           728:                if (cnflg) conect();    /* connect again if requested, */
        !           729:            } else {
        !           730: #endif /* NOCCTRAP */
        !           731:                proto();                /* Take any requested action, then */
        !           732:                if (!quiet)             /* put cursor back at left margin, */
        !           733:                  conoll("");
        !           734:                if (cnflg) conect();    /* connect if requested, */
        !           735: #ifndef NOCCTRAP
        !           736:            }
        !           737: #endif /* NOCCTRAP */
        !           738:        }
        !           739: /*
        !           740:   If interactive commands were given on the command line (using the
        !           741:   -C "command, command, ..." option), assign them to a macro called
        !           742:   "cl_commands", then execute the macro and leave it defined for
        !           743:   subsequent re-execution if desired.
        !           744: */
        !           745: #ifndef NOSPL
        !           746:        if (clcmds) {                   /* Check for -C commands */
        !           747:            int x;
        !           748:            x = addmac("cl_commands",clcmds); /* Put macro in table */
        !           749:            if (x > -1) {               /* If successful, */
        !           750:                dodo(x,NULL);           /* set up for macro execution */
        !           751:                while (maclvl > -1) {   /* Loop getting macro commands. */
        !           752:                    sstate = parser(1);
        !           753:                    if (sstate) proto(); /* Enter protocol if requested. */
        !           754:                }
        !           755:            }
        !           756:        }
        !           757: #endif /* NOSPL */
        !           758: #ifndef NOICP
        !           759: /*
        !           760:   If a command-line action argument was given and -S ("stay") was not given,
        !           761:   exit now.
        !           762: */
        !           763:        if ((cflg || cnflg || zstate) && !stayflg)
        !           764: #endif /* NOICP */
        !           765:          doexit(GOOD_EXIT,xitsta); /* exit with good status */
        !           766:     }
        !           767: #endif /* NOCMDL */
        !           768: 
        !           769: #ifdef NOICP                           /* No interactive command parser */
        !           770:     else {
        !           771: #ifndef NOCMDL
        !           772:        usage();                        /* Command-line-only version */
        !           773:        doexit(BAD_EXIT,-1);
        !           774: #else                                  /* Neither one! */
        !           775:        doexit(BAD_EXIT,-1);
        !           776: #endif /* NOCMDL */
        !           777:     }
        !           778: #else /* not NOICP */
        !           779: /*
        !           780:   If no action requested on command line, or if -S ("stay") was included,
        !           781:   enter the interactive command parser.
        !           782: */
        !           783:     herald();                          /* Display program herald. */
        !           784: 
        !           785: #ifndef NOCCTRAP                       /* If not no Control-C trap */
        !           786: ccagain:
        !           787:     if (setjmp(cmjbuf)) {              /* Control-C trap returns to here. */
        !           788: #ifdef GEMDOS
        !           789:        cc_clean();
        !           790: #endif /* GEMDOS */
        !           791:        fixcmd();                       /* Pop command stacks, etc. */
        !           792:        debug(F100,"ckcmai got interrupt","",0);
        !           793:        goto ccagain;                   /* set up trap again. */
        !           794:     } else {
        !           795:        debug(F100,"ckcmai setting interrupt trap","",0);
        !           796:        setint();                       /* Set up command interrupt traps */
        !           797:     }
        !           798: #else /* NOCCTRAP */
        !           799:     setint();                          /* Set up command interrupt traps */
        !           800: #endif /* NOCCTRAP */
        !           801: 
        !           802: #ifdef MAC
        !           803:     while (1) {
        !           804:        extern char *lfiles;            /* fake pointer cast */
        !           805: 
        !           806:        if (connected) {
        !           807:            debug(F100, "main: calling macparser", "", 0);
        !           808:            sstate = newparser(1, 1, 0L);
        !           809: 
        !           810:            /* ignore null command state */
        !           811:            if (sstate == 'n')
        !           812:                sstate = '\0';
        !           813: 
        !           814:            if (sstate)
        !           815:                proto();
        !           816:        }
        !           817:        else {
        !           818:            /*
        !           819:             * process take files the finder gave us.
        !           820:             */
        !           821:            if ((tlevel == -1) && lfiles)
        !           822:                startlfile();
        !           823: 
        !           824:            debug(F100, "main: calling parser", "", 0);
        !           825:            sstate = parser(0);
        !           826:            if (sstate == 'c')          /* if MAC connect */
        !           827:                sstate = 0;
        !           828:            if (sstate)
        !           829:                proto();
        !           830:        }
        !           831:     }
        !           832: #else /* Not MAC */
        !           833: 
        !           834: /*
        !           835:   Running from an application file, or a command filename was
        !           836:   specified on the command line.
        !           837: */
        !           838:     if (*cmdfil) dotake(cmdfil);       /* Command file spec'd on cmd line */
        !           839:     while(1) {                         /* Loop getting commands. */
        !           840:        sstate = parser(0);
        !           841:         if (sstate) proto();            /* Enter protocol if requested. */
        !           842:     }
        !           843: #endif /* MAC */
        !           844: #endif /* NOICP */
        !           845: }
        !           846: 
        !           847: #ifdef DYNAMIC
        !           848: /* Allocate file i/o buffers */
        !           849: 
        !           850: char *zinbuffer, *zoutbuffer;
        !           851: 
        !           852: int
        !           853: getiobs() {
        !           854:     zinbuffer = (char *)malloc(INBUFSIZE);
        !           855:     if (!zinbuffer) return(-1);
        !           856:     zoutbuffer = (char *)malloc(OBUFSIZE);
        !           857:     if (!zoutbuffer) return(-1);    
        !           858:     debug(F100,"getiobs ok","",0);
        !           859:     return(0);
        !           860: }
        !           861: #endif /* DYNAMIC */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.