home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
pub
/
wkermit
/
lcklink.c
< prev
next >
Wrap
C/C++ Source or Header
|
2020-01-01
|
10KB
|
277 lines
char *versio = "PC-DOS C-Kermit, file transfer module, 4LC(001) 27 July 85.\n\
Jan A. van der Eijk, NUS Corporation, 26 June 85.";
/* C K C L I N K -- Main driver program for linking to user program */
/*
Authors: Frank da Cruz, Bill Catchings, Jeff Damens;
Columbia University Center for Computing Activities, 1984-85.
Copyright (C) 1985, Trustees of Columbia University in the City of New York.
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided this
copyright notice is retained.
*/
/*
The Kermit file transfer protocol was developed at Columbia University.
It is named after Kermit the Frog, star of the television series THE
MUPPET SHOW; the name is used by permission of Henson Associates, Inc.
"Kermit" is also Celtic for "free".
*/
/*
Thanks to Herm Fischer of Encino, CA, for extensive contributions to
version 4, and to the following people for their contributions over the years:
Larry Afrin, Clemson U
Charles Brooks, EDN
Bob Cattani & Chris Maio, Columbia CS Dept
Alan Crosswell, CUCCA
Carl Fongheiser, CWRU
Yekta Gursel, MIT
Jim Guyton, Rand Corp
Stan Hanks, Rice U.
Ken Harrenstein, SRI
Steve Hemminger, Tektronix
Randy Huntziger, NLM
Martin Minow, DEC
Tony Movshon, NYU
Ken Poulton, HP Labs
Frank Prindle, NADC
Stew Rubenstein, Harvard
Dan Schullman, DEC
Bradley Smith, UCLA
Dave Tweten, AMES-NAS
Walter Underwood, Ford Aerospace
Pieter Van Der Linden, Centre Mondial (Paris)
Mark Vasoll & Gregg Wonderly, Oklahoma State University
Lauren Weinstein, Vortex
and many others.
*/
#include "lckerm.h"
#include "lckdeb.h"
#include "asiports.h" /* JAV, NUS use for Greenleaf COM libs */
#include "stdios.h" /* JAV, NUS special Greenleaf and Lattice header *
/* Declarations for Send-Init Parameters */
int spsiz = DSPSIZ, /* Biggest packet size we can send */
rpsiz = DRPSIZ, /* Biggest we want to receive */
timint = DMYTIM, /* Timeout interval I use */
rtimo = URTIME, /* Timeout I want you to use */
timef = 0, /* Flag to override what you ask */
npad = MYPADN, /* How much padding to send */
mypadn = MYPADN, /* How much padding to ask for */
chklen = 1, /* Length of block check */
bctr = 3, /* Block check type requested */
bctu = 1, /* Block check type used */
ebq = MYEBQ, /* 8th bit prefix */
ebqflg = 0, /* 8th-bit quoting flag */
rpt = 0, /* Repeat count */
rptq = MYRPTQ, /* Repeat prefix */
rptflg = 0, /* Repeat processing flag */
capas = MYCAPA; /* Capabilities */
char padch = MYPADC, /* Padding character to send */
mypadc = MYPADC, /* Padding character to ask for */
seol = MYEOL, /* End-Of-Line character to send */
eol = MYEOL, /* End-Of-Line character to look for */
ctlq = CTLQ, /* Control prefix in incoming data */
myctlq = CTLQ; /* Outbound control character prefix */
wndmax = 31; /* Maximum window size for table */
wndsiz = 31; /* Window size I want */
/* Packet-related variables */
int pktnum = 0, /* Current packet number */
prvpkt = -1, /* Previous packet number */
sndtyp, /* Type of packet just sent */
size, /* Current size of output pkt data */
osize, /* Previous output packet data size */
maxsize, /* Max size for building data field */
spktl; /* Length packet being sent */
char sndpkt[MAXPACK*2], /* Entire packet being sent */
recpkt[RBUFL+2], /* Packet most recently received */
data[MAXPACK+4], /* Packet data buffer */
srvcmd[MAXPACK*2], /* Where to decode server command */
*srvptr, /* Pointer to above */
mystch = SOH, /* Outbound packet-start character */
stchr = SOH; /* Incoming packet-start character */
/* File-related variables */
char filnam[50]; /* Name of current file. */
char fildat[20]; /* File creation date */
int nfils; /* Number of files in file group */
long fsize; /* Size of current file */
/* Communication line variables */
char ttname[50]; /* Name of communication line. */
int parity, /* Parity specified, 0,'e','o',etc */
flow, /* Flow control, 1 = xon/xoff */
speed = 1200, /* Line speed */
turn = 0, /* Line turnaround handshake flag */
turnch = XON, /* Line turnaround character */
duplex = 0, /* Duplex, full by default */
escape = 034, /* Escape character for connect */
delay = DDELAY, /* Initial delay before sending */
cdetect = FALSE, /* Carrier detect not required */
mdmtyp = 0; /* Modem type (initially none) */
/* Statistics variables */
long filcnt, /* Number of files in transaction */
flci, /* Characters from line, current file */
flco, /* Chars to line, current file */
tlci, /* Chars from line in transaction */
tlco, /* Chars to line in transaction */
ffc, /* Chars to/from current file */
tfc; /* Chars to/from files in transaction */
/* Flags */
int deblog = 0, /* Flag for debug logging */
pktlog = 0, /* Flag for packet logging */
seslog = 0, /* Session logging */
tralog = 0, /* Transaction logging */
displa = 0, /* File transfer display on/off */
stdouf = 0, /* Flag for output to stdout */
xflg = 0, /* Flag for X instead of F packet */
hcflg = 0, /* Doing Host command */
fncnv = 1, /* Flag for file name conversion */
binary = 1, /* Flag for binary file */
warn = 1, /* Flag for file warning */
quiet = 0, /* Be quiet during file transfer */
local = 0, /* Flag for external tty vs stdout */
server = 0, /* Flag for being a server */
cnflg = 0, /* Connect after transaction */
cxseen = 0, /* Flag for cancelling a file */
czseen = 0; /* Flag for cancelling file group */
filatr = 0; /* Flag for sending file attributes */
nxtcas = 1; /* Flag for sending next attribute */
capflg = 0; /* Which capas are supported */
sldwnd = 0; /* Flag for sliding window support */
window = 0; /* Flag for windowing state */
/* Variables passed from command parser to protocol module */
char parser(); /* The parser itself */
char sstate = 0; /* Starting state for automaton */
char *cmarg = ""; /* Pointer to command data */
char *cmarg2 = ""; /* Pointer to 2nd command data */
char **cmlist; /* Pointer to file list in argv */
/* Miscellaneous */
char **xargv; /* Global copies of argv */
int xargc; /* and argc */
extern char *dftty; /* Default tty name from ckx???.c */
extern int dfloc; /* Default location: remote/local */
extern int dfprty; /* Default parity */
extern int dfflow; /* Default flow control */
/* K L I N K -- C-Kermit main program */
klink() {
char *strcpy();
/* Do some initialization */
sstate = 0; /* No default start state. */
strcpy(ttname,dftty); /* Set up default tty name. */
local = dfloc; /* And whether it's local or remote. */
parity = dfprty; /* Set initial parity, */
flow = dfflow; /* and flow control. */
sstate = kinit(); /* Setup and intialize */
if (sstate) {
proto(); /* Take any requested action */
doexit(GOOD_EXIT); /* and then exit with status 0. */
}
}
/* K I N I T -- routine to initialize variable if kermit is linked to other
programs, returns action to take */
char kinit() {
cmarg = ""; /* Initialize. */
cmarg2 = "";
action = cflg = 0;
strcpy(ttname,???????) /* com port name COM1 or COM2 */
z = ??????? /* set baud rate */
if (chkspd(z) > -1) speed = z; /* Check it */
else fatal("unsupported baud rate");
cdetect = ???? /* CD required 0 or 1 */
binary = ???? /* set filetype 0 or 1 */
warn = ????? /* file overwrite 0 or 1 */
quiet = ????? /* be quit 0 or 1 */
parity = ?????? /* set parity e, m, n, s, or o */
debopn("debug.log"); /* To open debug log */
/* Only valid if compiled with */
/* DEBUG 1 */
z = ???????? /* set window size */
if ( z > MYWND || z < 0 ) /* Check it */
fatal("invalid window size");
else wndmax = z;
duplex = ???????? /* Set duplex 0 or 1 */
if ( duplex )
turn = 1; /* Line turnaround handshake */
turnch = XON; /* XON is turnaround character */
duplex = 1; /* Half duplex */
flow = 0; /* No flow control */
wndmax = 0; /* No windowing for half duplex */
}
/* If receiving a file */
action = 'v';
cmarg2 = ?????????; /* Optional filename */
/* Else if sending a file */
action = 's';
/* if sending multiple files */
nfils = ?? /* Initialize file counter,to */
/* number of file in list */
cmlist = ???????? /* point cmlist to list of files */
/* else if sending wild card name */
nfils = -1; /* Incase protocol has to expand */
cmarg = ?????; /* wildcards, point cmarg */
/* to variable containing wildcard */
/* else if sending one file as another file */
nfils = 1;
cmlist = ??????; /* pointer to filename to send */
cmarg2 = ??????; /* pointer to filename to send as */
return(action);