Annotation of 43BSD/contrib/kermit/ckcmai.c, revision 1.1.1.1

1.1       root        1: char *versio = "C-Kermit, 4C(057) 31 Jul 85";
                      2: 
                      3: /*  C K C M A I  --  C-Kermit Main program  */
                      4: 
                      5: /*
                      6:  Authors: Frank da Cruz, Bill Catchings, Jeff Damens;
                      7:  Columbia University Center for Computing Activities, 1984-85.
                      8:  Copyright (C) 1985, Trustees of Columbia University in the City of New York.
                      9:  Permission is granted to any individual or institution to use, copy, or
                     10:  redistribute this software so long as it is not sold for profit, provided this
                     11:  copyright notice is retained. 
                     12: */
                     13: /*
                     14:  The Kermit file transfer protocol was developed at Columbia University.
                     15:  It is named after Kermit the Frog, star of the television series THE
                     16:  MUPPET SHOW; the name is used by permission of Henson Associates, Inc.
                     17:  "Kermit" is also Celtic for "free".
                     18: */
                     19: /*
                     20:  Thanks to Herm Fischer of Encino CA for extensive contributions to version 4,
                     21:  and to the following people for their contributions over the years:
                     22: 
                     23:    Larry Afrin, Clemson U
                     24:    Charles Brooks, EDN
                     25:    Bob Cattani, Columbia CS Dept
                     26:    Alan Crosswell, CUCCA
                     27:    Carl Fongheiser, CWRU
                     28:    Yekta Gursel, MIT
                     29:    Jim Guyton, Rand Corp
                     30:    Stan Hanks, Rice U.
                     31:    Ken Harrenstein, SRI
                     32:    Steve Hemminger, Tektronix
                     33:    Randy Huntziger, NLM
                     34:    Chris Maio, Columbia CS Dept
                     35:    Martin Minow, DEC
                     36:    Tony Movshon, NYU
                     37:    Ken Poulton, HP Labs
                     38:    Frank Prindle, NADC
                     39:    Stew Rubenstein, Harvard
                     40:    Dan Schullman, DEC
                     41:    Bradley Smith, UCLA
                     42:    Dave Tweten, AMES-NAS
                     43:    Walter Underwood, Ford Aerospace
                     44:    Pieter Van Der Linden, Centre Mondial (Paris)
                     45:    Mark Vasoll & Gregg Wonderly, Oklahoma State University
                     46:    Lauren Weinstein, Vortex
                     47: 
                     48:  and many others.
                     49: */
                     50: 
                     51: #include "ckcker.h"
                     52: #include "ckcdeb.h"
                     53: 
                     54: /* Text message definitions.. each should be 256 chars long, or less. */
                     55: #ifdef MAC
                     56: char *hlptxt = "C-Kermit Server Commands:\n\
                     57: \n\
                     58: GET filespec, SEND filespec, FINISH, REMOTE HELP\n\
                     59: \n\0";
                     60: #else
                     61: char *hlptxt = "C-Kermit Server Commands Supported:\n\
                     62: \n\
                     63: GET filespec   REMOTE CWD [directory]          REMOTE SPACE [directory]\n\
                     64: SEND filespec  REMOTE DIRECTORY [filespec]     REMOTE HOST command\n\
                     65: FINISH         REMOTE DELETE filespec          REMOTE WHO [user]\n\
                     66: REMOTE HELP    REMOTE TYPE filespec            BYE\n\
                     67: \n\0";
                     68: #endif
                     69: char *srvtxt = "\r\n\
                     70: C-Kermit server starting.  Return to your local machine by typing\r\n\
                     71: its escape sequence for closing the connection, and issue further\r\n\
                     72: commands from there.  To shut down the C-Kermit server, issue the\r\n\
                     73: FINISH or BYE command and then reconnect.\n\
                     74: \r\n\0";
                     75: 
                     76: /* Declarations for Send-Init Parameters */
                     77: 
                     78: int spsiz = DSPSIZ,                    /* Biggest packet size we can send */
                     79:     spsizf = 0,                                /* Flag to override what you ask for */
                     80:     rpsiz = DRPSIZ,                    /* Biggest we want to receive */
                     81:     timint = DMYTIM,                   /* Timeout interval I use */
                     82:     rtimo = URTIME,                    /* Timeout I want you to use */
                     83:     timef = 0,                         /* Flag to override what you ask */
                     84:     npad = MYPADN,                     /* How much padding to send */
                     85:     mypadn = MYPADN,                   /* How much padding to ask for */
                     86:     chklen = 1,                                /* Length of block check */
                     87:     bctr = 1,                          /* Block check type requested */
                     88:     bctu = 1,                          /* Block check type used */
                     89:     ebq =  MYEBQ,                      /* 8th bit prefix */
                     90:     ebqflg = 0,                                /* 8th-bit quoting flag */
                     91:     rpt = 0,                           /* Repeat count */
                     92:     rptq = MYRPTQ,                     /* Repeat prefix */
                     93:     rptflg = 0,                                /* Repeat processing flag */
                     94:     capas = 0;                         /* Capabilities */
                     95: 
                     96: CHAR padch = MYPADC,                   /* Padding character to send */
                     97:     mypadc = MYPADC,                   /* Padding character to ask for */
                     98:     seol = MYEOL,                      /* End-Of-Line character to send */
                     99:     eol = MYEOL,                       /* End-Of-Line character to look for */
                    100:     ctlq = CTLQ,                       /* Control prefix in incoming data */
                    101:     myctlq = CTLQ;                     /* Outbound control character prefix */
                    102: 
                    103: 
                    104: /* Packet-related variables */
                    105: 
                    106: int pktnum = 0,                                /* Current packet number */
                    107:     prvpkt = -1,                       /* Previous packet number */
                    108:     sndtyp,                            /* Type of packet just sent */
                    109:     size,                              /* Current size of output pkt data */
                    110:     osize,                             /* Previous output packet data size */
                    111:     maxsize,                           /* Max size for building data field */
                    112:     spktl;                             /* Length packet being sent */
                    113: 
                    114: CHAR sndpkt[MAXPACK*2],                /* Entire packet being sent */
                    115:     recpkt[RBUFL],                     /* Packet most recently received */
                    116:     data[MAXPACK+4],                           /* Packet data buffer */
                    117:     srvcmd[MAXPACK*2],                 /* Where to decode server command */
                    118:     *srvptr,                           /* Pointer to above */
                    119:     mystch = SOH,                      /* Outbound packet-start character */
                    120:     stchr = SOH;                       /* Incoming packet-start character */
                    121: 
                    122: /* File-related variables */
                    123: 
                    124: CHAR filnam[50];                       /* Name of current file. */
                    125: 
                    126: int nfils;                             /* Number of files in file group */
                    127: long fsize;                            /* Size of current file */
                    128: 
                    129: /* Communication line variables */
                    130: 
                    131: CHAR ttname[50];                       /* Name of communication line. */
                    132: 
                    133: int parity,                            /* Parity specified, 0,'e','o',etc */
                    134:     flow,                              /* Flow control, 1 = xon/xoff */
                    135:     speed = -1,                                /* Line speed */
                    136:     turn = 0,                          /* Line turnaround handshake flag */
                    137:     turnch = XON,                      /* Line turnaround character */
                    138:     duplex = 0,                                /* Duplex, full by default */
                    139:     escape = 034,                      /* Escape character for connect */
                    140:     delay = DDELAY,                    /* Initial delay before sending */
                    141:     mdmtyp = 0;                                /* Modem type (initially none)  */
                    142: 
                    143: 
                    144: /* Statistics variables */
                    145: 
                    146: long filcnt,                   /* Number of files in transaction */
                    147:     flci,                      /* Characters from line, current file */
                    148:     flco,                      /* Chars to line, current file  */
                    149:     tlci,                      /* Chars from line in transaction */
                    150:     tlco,                      /* Chars to line in transaction */
                    151:     ffc,                       /* Chars to/from current file */
                    152:     tfc;                       /* Chars to/from files in transaction */
                    153: 
                    154: int tsecs;                     /* Seconds for transaction */
                    155: 
                    156: /* Flags */
                    157: 
                    158: int deblog = 0,                                /* Flag for debug logging */
                    159:     pktlog = 0,                                /* Flag for packet logging */
                    160:     seslog = 0,                                /* Session logging */
                    161:     tralog = 0,                                /* Transaction logging */
                    162:     displa = 0,                                /* File transfer display on/off */
                    163:     stdouf = 0,                                /* Flag for output to stdout */
                    164:     xflg   = 0,                                /* Flag for X instead of F packet */
                    165:     hcflg  = 0,                                /* Doing Host command */
                    166:     fncnv  = 1,                                /* Flag for file name conversion */
                    167:     binary = 0,                                /* Flag for binary file */
                    168:     savmod = 0,                                /* Saved file mode */
                    169:     warn   = 0,                                /* Flag for file warning */
                    170:     quiet  = 0,                                /* Be quiet during file transfer */
                    171:     local  = 0,                                /* Flag for external tty vs stdout */
                    172:     server = 0,                                /* Flag for being a server */
                    173:     cnflg  = 0,                                /* Connect after transaction */
                    174:     cxseen = 0,                                /* Flag for cancelling a file */
                    175:     czseen = 0,                        /* Flag for cancelling file group */
                    176:     keep = 0;                          /* Keep incomplete files */
                    177: 
                    178: /* Variables passed from command parser to protocol module */
                    179: 
                    180: char parser();                         /* The parser itself */
                    181: char sstate  = 0;                      /* Starting state for automaton */
                    182: char *cmarg  = "";                     /* Pointer to command data */
                    183: char *cmarg2 = "";                     /* Pointer to 2nd command data */
                    184: char **cmlist;                         /* Pointer to file list in argv */
                    185: 
                    186: /* Miscellaneous */
                    187: 
                    188: char **xargv;                          /* Global copies of argv */
                    189: int  xargc;                            /* and argc  */
                    190: 
                    191: extern char *dftty;                    /* Default tty name from ckx???.c */
                    192: extern int dfloc;                      /* Default location: remote/local */
                    193: extern int dfprty;                     /* Default parity */
                    194: extern int dfflow;                     /* Default flow control */
                    195: 
                    196: /*  M A I N  --  C-Kermit main program  */
                    197: 
                    198: main(argc,argv) int argc; char **argv; {
                    199: 
                    200:     char *strcpy();
                    201: 
                    202: /* Do some initialization */
                    203: 
                    204:     xargc = argc;                      /* Make global copies of argc */
                    205:     xargv = argv;                      /* ...and argv. */
                    206:     sstate = 0;                                /* No default start state. */
                    207:     strcpy(ttname,dftty);              /* Set up default tty name. */
                    208:     local = dfloc;                     /* And whether it's local or remote. */
                    209:     parity = dfprty;                   /* Set initial parity, */
                    210:     flow = dfflow;                     /* and flow control. */
                    211:     sysinit();                         /* And any system-dependent things. */
                    212:     
                    213: /* Look for a UNIX-style command line... */
                    214: 
                    215:     if (argc > 1) {                    /* Command line arguments? */
                    216:        sstate = cmdlin();              /* Yes, parse. */
                    217:        if (sstate) {
                    218:            proto();                    /* Take any requested action, then */
                    219:            if (!quiet) conoll("");     /* put cursor back at left margin, */
                    220:            if (cnflg) conect();        /* connect if requested, */
                    221:            doexit(GOOD_EXIT);          /* and then exit with status 0. */
                    222:        }
                    223:     }  
                    224:     
                    225: /* If no action requested on command line, enter interactive parser */
                    226: 
                    227:     cmdini();                          /* Initialize command parser */
                    228:     while(sstate = parser()) {         /* Loop getting commands. */
                    229:        if (sstate) proto();            /* Enter protocol if requested. */
                    230:     }
                    231: }

unix.superglobalmegacorp.com

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