C-KERMIT (Part 6 of 10)

gregg at okstate.UUCP gregg at okstate.UUCP
Fri Mar 8 17:47:00 AEST 1985



echo x - ckcmd.h
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckcmd.h
X/*  C K C M D . H  --  Header file for cmd package  */
X
X/* Sizes of things */
X
X#define HLPLW  78			/* Width of ?-help line */
X#define HLPCW  19			/* Width of ?-help column */
X#define CMDBL  200			/* Command buffer length */
X#define HLPBL  100			/* Help string buffer length */
X#define ATMBL  100			/* Command atom buffer length*/
X
X/* Special characters */
X
X#define NUL  '\0'			/* Null */
X#define HT   '\t'			/* Horizontal Tab */
X#define NL   '\n'			/* Newline */
X#define FF   0014			/* Formfeed    (^L) */
X#define RDIS 0022			/* Redisplay   (^R) */
X#define LDEL 0025			/* Delete line (^U) */
X#define WDEL 0027			/* Delete word (^W) */
X#define ESC  0033			/* Escape */
X#define RUB  0177			/* Rubout */
X
X#ifndef BEL
X#define BEL  0007			/* Bell */
X#endif
X
X#ifndef BS
X#define BS   0010			/* Backspace */
X#endif
X
X#ifndef SP
X#define SP   0040			/* Space */
X#endif
X
X/* Keyword table flags */
X
X#define CM_INV 1			/* Invisible keyword */
X
X/* Keyword Table Template */
X
Xstruct keytab {				/* Keyword table */
X    char *kwd;				/* Pointer to keyword string */
X    int val;				/* Associated value */
X    int flgs;				/* Flags (as defined above) */
X};
!FUNKY!STUFF!
echo x - ckdebu.h
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckdebu.h
X/*  C K D E B U . H  */
X
X/*
X This file is included by all C-Kermit modules, including the modules
X that aren't specific to Kermit (like the command parser and the ck[xz]*
X modules.  It specifies format codes for debug(), tlog(), and similar
X functions, and includes any necessary typedefs.
X*/
X
X#define F000 0				/* Formats for debug() */
X
X#define F001 1
X#define F010 2
X#define F011 3
X#define F100 4
X#define F101 5
X#define F110 6
X#define F111 7
X
X/* Compiler dependencies */
X
X#ifdef PROVX1
Xtypedef char CHAR;
Xtypedef long LONG;
Xtypedef int void;
X#else
Xtypedef unsigned char CHAR;
Xtypedef unsigned long LONG;
X#endif
!FUNKY!STUFF!
echo x - ckermi.ann
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckermi.ann
X 5-Feb-85 16:10:21-EST,5392;000000000001
XMail-From: SY.FDC created at  5-Feb-85 16:09:41
XDate: Tue 5 Feb 85 16:09:41-EST
XFrom: Frank da Cruz <SY.FDC at CU20B.ARPA>
XSubject: Info-Kermit Digest V2 #1 -- New Unix Kermit
XTo: Info-Kermit-Members at CU20B.ARPA
Xcc: Info-Unix at BRL-TGR.ARPA
XReply-To: Info-Kermit at CU20B
XQueries-To: Info-Kermit-Request at CU20B
X
XInfo-Kermit Digest         Tue,  5 Feb 1985       Volume 2 : Number  1
X
X  ANNOUNCEMENTS -
X      New Unix Kermit Available for Testing
X
X----------------------------------------------------------------------
X
XMy apologies for the long delay since the last issue of the Info-Kermit
XDigest, which was Vol.1, No.46, dated 31 December 1984.  This first issue
Xof Volume 2 is to announce a test release of the new Unix Kermit.  In
Xsubsequent issues, I'll attempt to catch up on other overdue items.
X
XA new Kermit program has been written in C, initially for 4.2 Berkeley Unix.
XThe features of this program include:
X
X. Full implementation of the Kermit protocol, except for Attribute packets:
X  - Acts as server
X  - Talks to server
X  - All packet encoding and error checking options are provided
X  - File transfer interruption
X  - Filename collision avoidance
X  - Binary and text file transfer
X. Modular construction for easy portability to other systems
X. An interactive command parser as well as Unix-style command line arguments
X. Command and initialization files
X. Piped operation
X. Improved terminal connect, with optional logging
X. Logs for debugging, packets, and transactions
X. Communication with IBM mainframes
X
XSeveral items on the wish list were not done for lack of time.  They will
Xprobably be added in the future:
X
X. File attributes
X. Command macros
X. Login scripts
X. Raw file transmit
X
XThe new program is called "C-Kermit" because it is intended as a basis for
XKermit programs for any systems that have C compilers.  Its version number
Xis 4.0, to distinguish it from earlier releases of Unix Kermit, the most
Xrecent of which was 3.0.
X
XThis prerelease test version of the program runs only under Berkeley Unix 4.2.
XWe also intend to bring it to the following systems within the coming weeks:
X
X. DEC Pro-350 and Pro-380 with Venix (a Unix v7 derivative)
X. Amdahl UTS on IBM 370-series mainframes
X. Apple Macintosh (maybe)
X
XSupport for other systems will have to be added elsewhere.  The program is
Xbeing "pre-released" at this time for two reasons:
X
X1. It seems to be perfectly usable on Berkeley 4.2 systems, and is an
X   improvement over the previous version.
X
X2. The modular design may need some adjustment to accommodate certain systems.
X   Before a great deal of additional coding is done, it is highly desirable
X   to get the design and specification of the system-dependent modules stable.
X
XTherefore, please take the files, read the documentation, try running the
Xprogram on your Berkeley Unix system if you have one, and send comments or bug
Xreports to me as soon as you can.  If you have a Unix system that is not
XBerkeley Unix, or a non-Unix system with a C compiler, please take a look at
Xthe system-dependent modules to see how they could be adapted to your system;
Xagain, if you have any suggestions or criticisms of the design, please let me
Xknow.  I'm particularly interested in issues of portability.  After a round or
Xtwo of this, perhaps the design can be agreed upon, and then those who would
Xlike to contribute support for Version 6, System III, System V, Xenix, PC/IX,
Xetc etc, can do so without fear of running into other people's changes for
Xother systems.  Before attempting to adapt C-Kermit to a new system, please
Xlet me know so I can tell you whether someone else is already at work on the
Xsame thing, and perhaps put you in touch.
X
XThe files are on CU20B as KER:CK*.*, available via anonymous FTP.  The file
XCKERMI.DOC provides user-level documentation as well as a description of the
Xprogram organization and hints for adapting it to new systems.  Within several
Xdays the files should also be available on BITNET via KERMSRV (to get started
Xwith KERMSRV, type SMSG RSCS MSG CUVMA KERMSRV HELP), and to Unix systems via
XUUCP from Oklahoma State University, Stillwater, OK.
X
XHere's how to UUCP to OK State:
X
XYou need to set up "okstate" as a site in your "L.sys" UUCP dialing file
Xusing the information listed below.  You can then issue the following 
Xcommand on your system:
X
X	uucp okstate\!/u/kermit/ck\* /usr/spool/uucppublic
X
X   (this example will retrieve the new Unix version of Kermit)
X
XThe "/usr/spool/uucppublic" is chosen as the destination on your system since
Xthe destination must be WIDE OPEN (drwxrwxrwx) to everyone.  You should
Xnot remove files from your uucppublic until the entire transfer is complete
Xincluding any redials that are necessary.  If you do remove some files
Xour system may retransmit them, resulting in a higher phone bill for you. 
X
X-- UUCP Login information --
X
XSite Name    :  okstate
XPhone number :  (405) 624-6953  (one line only)
XLogin name   :  uucpker
XPassword     :  thefrog
XHours        :  10:00pm - 10:00am central time (7 day per week)
XProblem      :  okstate!uucp-support  (UUCP)
X  reports    :  uucp-support%okstate at csnet-relay  (ARPA)
X
XThe phone number is for 300/1200 baud (bell compatible).
X
X------------------------------
X
XEnd of Info-Kermit Digest
X*************************
X-------
XFrom columbia!SY.FDC at CU20B.DECNET  Wed Mar  6 22:17:55 1985
XReceived: by cucca.UUCP (4.12/4.7)
X	id AA24373; Wed, 6 Mar 85 22:17:55 est
XReceived: from CU20B.ARPA by columbia.arpa; Wed, 6 Mar 85 21:44:26 est
XDate: Wed 6 Mar 85 21:53:20-EST
XFrom: Frank da Cruz <columbia!SY.FDC at CU20B.DECNET>
XSubject: Info-Kermit Digest V2 #9, C-Kermit Release #2
XTo: Info-Kermit at CU20B.DECNET, Info-Micro at BRL-VGR.ARPA, Info-Unix at BRL.ARPA
XReply-To: Info-Kermit at CU20B
XQueries-To: Info-Kermit-Request at CU20B
X
XInfo-Kermit Digest         Wed,  6 Mar 1985       Volume 2 : Number  9
X
X               Second Pre-Release of C-Kermit for Unix
X
X----------------------------------------------------------------------
X
XDate: Wed 6 Mar 85 21:43:12-EST
XFrom: Frank da Cruz <SY.FDC at CU20B>
XSubject: Second Pre-Release of C-Kermit for Unix
XTo: Info-Kermit at CU20B
X
XThis is to announce the second "pre-release" of C-Kermit.  The first
Xpre-release (version 4.0) occurred a month ago; the program included
Xsupport only for Berkeley Unix.  This new release (4.2) includes support
Xfor:
X
X. 4.x Berkeley Unix (VAX, SUN)
X. Generic AT&T System III, System V
X. Microsoft Xenix for the PC/AT
X. Interactive on the PC/XT (PC/IX) and other systems
X. DEC Professional 3xx with Venix 1.0
X. NCR Tower
X
XAll reported bugs have been fixed (or at least fixes have been
Xattempted), and many of the restrictions lifted.  "Dial" and "script"
Xcommands have been added, along with code to support modem control and
Xdialers, uucp line locking, and the like.  The program itself has been
Xsomewhat reorganized to be more adaptable to small environments: the
Xlarger modules have been split; long character strings have been
Xshortened.
X
XMost of the new work was done by Herm Fischer of Litton Data Systems, Van
XNuys CA (HFISCHER at USC-ISIB), and there were also contributions from many
Xothers in the form of bug reports and/or fixes.  NCR Tower support came
Xfrom John Bray at Auburn University.  The new makefile (distributed as
XCKERMI.MAK) embodies procedures for building all the different versions.
X
XSince the program now runs on a variety computers, large and small, it
Xwould seem relatively safe to begin adding support for other systems
Xwithout fear that the program will have to be completely reorganized
X(again).  The only systems supported by C-Kermit so far are Unix systems;
Xrather than create a separate ckx and ckz module for each such system
X(since these systems tend to differ in small places, but still have much
Xin common), conditional compilation was used within these modules.  If
XC-Kermit is to be adapted to non-Unix systems, then a full replacement of
Xthe ckx and/or ckz modules is probably indicated.  This is what we will
Xprobably do in bringing the program up on the Macintosh.
X
XThe files are available via anonymous FTP from Internet host CU20B
X(Internet number 192.5.43.128) as KER:CK*.*.  They will appear at
Xokstate (for uucp'ing) and on KERMSRV (BITnet) shortly.  If you plan to
Xadapt this program to a new system, be sure to let me know quickly so I
Xcan prevent duplication of effort and can put people with similar
Xinterests in touch with each other.
X
X------------------------------
X
XEnd of Info-Kermit Digest
X*************************
X-------
!FUNKY!STUFF!
echo x - ckermi.h
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckermi.h
X/* ckermit.h -- Symbol and macro definitions for C-Kermit */
X
X#include <stdio.h>
X#include <ctype.h>
X#include "ckdebu.h"
X
X/* Mnemonics for ASCII characters */
X
X#define SOH	   001	    	/* ASCII Start of header */
X#define BEL        007		/* ASCII Bell (Beep) */
X#define BS         010		/* ASCII Backspace */
X#define CR         015		/* ASCII Carriage Return */
X#define XON	   021	    	/* ASCII XON */
X#define SP	   040		/* ASCII Space */
X#define DEL	   0177		/* ASCII Delete (Rubout) */
X
X/* Kermit parameters and defaults */
X
X#define MAXPACK	   94		/* Maximum packet size */
X#define RBUFL	   200 	    	/* Receive buffer length */
X#define CTLQ	   '#'		/* Control char prefix I will use */
X#define MYEBQ	   '&'		/* 8th-Bit prefix char I will use */
X#define MYRPTQ	   '~'		/* Repeat count prefix I will use */
X
X#define MAXTRY	    10	  	/* Times to retry a packet */
X#define MYPADN	    0	  	/* How many padding chars I need */
X#define MYPADC	    '\0'  	/* Which padding character I need */
X
X#define DMYTIM	    7	  	/* Default timeout interval to use. */
X#define URTIME	    10	  	/* Timeout interval to be used on me. */
X
X#define DEFTRN	    0           /* Default line turnaround handshake */
X#define DEFPAR	    0           /* Default parity */
X#define MYEOL	    CR          /* End-Of-Line character I need on packets. */
X
X#define DRPSIZ	    90	        /* Default incoming packet size. */
X#define DSPSIZ	    90	        /* Default outbound packet size. */
X
X#define DDELAY      5		/* Default delay. */
X#define DSPEED	    9600 	/* Default line speed. */
X
X/* Files */
X
X#define ZCTERM      0	    	/* Console terminal */
X#define ZSTDIO      1		/* Standard input/output */
X#define ZIFILE	    2		/* Current input file */
X#define ZOFILE      3	    	/* Current output file */
X#define ZDFILE      4	    	/* Current debugging log file */
X#define ZTFILE      5	    	/* Current transaction log file */
X#define ZPFILE      6	    	/* Current packet log file */
X#define ZSFILE      7		/* Current session log file */
X#define ZNFILS      8	    	/* How many defined file numbers */
X
X/* Macros */
X
X#define tochar(ch)  ((ch) + SP )	/* Number to character */
X#define unchar(ch)  ((ch) - SP )	/* Character to number */
X#define ctl(ch)     ((ch) ^ 64 )	/* Controllify/Uncontrollify */
X#define unpar(ch)   ((ch) & 127)	/* Clear parity bit */
!FUNKY!STUFF!
echo x - ckermi.hlp
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckermi.hlp
XThe files ck*.* comprise C-Kermit.
X
Xck*.c are the C language source files.
Xck*.h are the header files.
Xckprot.w is the "wart" source for the protocol state table.
X
Xckermi.mss is the Scribe text formatter source for the Kermit User Guide
Xchapter on C-Kermit for Unix.
X
Xckermi.doc is the plain-text documentation output from Scribe.
X
Xckermi.mak is the makefile.  It should be renamed to "makefile".  Use the
Xmakefile to build C-Kermit for your Unix system, giving the appropriate
Xcommand line argument to "make", e.g.
X
Xmake bsd	(for Berkeley Unix)
Xmake pcix	(for PC/IX)
Xmake provx1	(for Pro-350 with Venix 1.0)
X
Xetc.  The make file produces a runnable program called "wermit".  You should
Xtest it thoroughly before renaming it to "kermit".
!FUNKY!STUFF!
echo x - ckermi.mak
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckermi.mak
X# Makefile to build C-Kermit for Berkeley, Microsoft, Interactive, 
X#		and ATT Unix 
X# for Berkeley Unix 4.x, "make bsd"
X# for Microsoft xenix (/286, pc/at, etc) "make xenix"
X# for Interactive on pc/xt "make pcix"
X# for Interactive on other host "make is3"
X# for Bell generic III/V "make sys3"
X# for Pro-3xx Venix 1.0 "make provx1"
X# for NCR Tower 1632, "make tower1"
X
XLNKFLAGS=
X
Xmake: 
X	@echo 'Make what?  You must tell which system to make C-Kermit for.'
X
Xwermit: ckmain.o ckcmd.o ckuser.o ckusr2.o ckusr3.o ckprot.o ckfns.o ckfns2.o \
X		 ckconu.o ckxunx.o ckzunx.o ckdial.o cklogi.o makefile
X	cc $(LNKFLAGS) -o wermit ckmain.o ckxunx.o ckzunx.o ckfns.o ckfns2.o \
X		 ckprot.o ckcmd.o ckusr2.o ckusr3.o ckuser.o ckconu.o \
X		 ckdial.o cklogi.o
X
Xckmain.o: ckmain.c ckermi.h
X
Xckuser.o: ckuser.c ckcmd.h ckermi.h ckuser.h
X
Xckusr2.o: ckusr2.c ckcmd.h ckermi.h ckuser.h
X
Xckusr3.o: ckusr3.c ckcmd.h ckermi.h ckuser.h
X
Xckcmd.o: ckcmd.c ckcmd.h ckdebu.h
X
Xckprot.o: ckprot.w wart ckermi.h
X	wart ckprot.w ckprot.c ; cc $(CFLAGS) -c ckprot.c
X
Xckfns.o: ckfns.c ckermi.h ckdebu.h
X
Xckfns2.o: ckfns.c ckermi.h ckdebu.h
X
Xckzunx.o: ckzunx.c ckermi.h ckdebu.h
X
Xckxunx.o: ckxunx.c ckdebu.h
X
Xckconu.o: ckconu.c ckermi.h
X
Xwart: ckwart.o
X	cc $(LNKFLAGS) -o wart ckwart.o
X
Xckwart.o: ckwart.c
X
Xckdial.o: ckdial.c
X
Xcklogi.o: cklogi.c
X
X#Berkeley Unix
Xbsd:
X	make wermit "CFLAGS= -DBSD4"
X
X#Microsoft "Xenix/286" e.g., as sold by IBM for PC/AT
Xxenix:
X	make wermit "CFLAGS= -DXENIX -DUXIII -F3000 -i" "LNKFLAGS = -F3000 -i"
X
X#PC/IX, Interactive Corp System III port for IBM PC/XT as sold by IBM
Xpcix:
X	make wermit "CFLAGS= -DPCIX -DUXIII -DISIII -Dsdata=sdatax -O -i" \
X		"LNKFLAGS = -i"
X
X#interactive corp system III port --
Xis3:
X	make wermit "CFLAGS = -DISIII -DUXIII -Ddata=datax -O -i" \
X		"LNKFLAGS = -i"
X
X#plain old Bell System III or System V without strange things
Xsys3:
X	make wermit "CFLAGS = -DUXIII -i -O" "LNKFLAGS = -i"
X
X#DEC Pro-3xx with Venix 1.0
Xprovx1:
X	make wart "CFLAGS= " "LNKFLAGS= "
X	make wermit "CFLAGS = -DPROVX1 -md780" \
X		"LNKFLAGS= -u _sleep -lc -md780"
X
X#NCR Tower 1632, OS 1.02
Xtower1:
X	make wermit "CFLAGS = -DTOWER1"
X
!FUNKY!STUFF!
echo x - ckprot.w
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckprot.w
Xchar *protv = "C-Kermit Protocol Module 4.2(015), 5 Mar 85"; /* -*-C-*- */
X
X/* C K P R O T  -- C-Kermit Protocol Module, in Wart preprocessor notation. */
X
X/* Authors: Jeff Damens, Bill Catchings, Frank da Cruz (Columbia University) */
X
X#include "ckermi.h"
X/*
X Note -- This file may also be preprocessed by the Unix Lex program, but 
X you must indent the above #include statement before using Lex, and then
X restore it to the left margin in the resulting C program before compilation.
X Also, the invocation of the "wart()" function below must be replaced by an
X invocation  of the "yylex()" function.  It might also be necessary to remove
X comments in the %%...%% section.
X*/
X
X
X/* State definitions for Wart (or Lex) */
X
X%states ipkt rfile rdata ssinit ssdata sseof sseot serve generic get rgen
X
X
X/* External C-Kermit variable declarations */
X
X  extern char sstate, *versio, *srvtxt, *cmarg, *cmarg2;
X  extern char data[], filnam[], srvcmd[], ttname[], *srvptr;
X  extern int pktnum, timint, nfils, image, hcflg, xflg, speed, flow, mdmtyp;
X  extern int prvpkt, cxseen, czseen, server, local, displa, bctu, bctr, quiet;
X  extern int putsrv(), puttrm(), putfil(), errpkt();
X  extern char *DIRCMD, *DELCMD, *TYPCMD, *SPACMD, *SPACM2, *WHOCMD;
X
X
X/* Local variables */
X
X  static char vstate = 0;  		/* Saved State   */
X  static char vcmd = 0;    		/* Saved Command */
X  static int x;				/* General-purpose integer */
X
X
X/* Macros - Note, BEGIN is predefined by Wart (and Lex) */
X
X#define SERVE  tinit(); BEGIN serve
X#define RESUME if (server) { SERVE; } else return
X
X%%
X/* Protocol entry points, one for each start state (sstate) */
X
Xs { tinit();	    	    	    	/* Do Send command */
X    if (sinit()) BEGIN ssinit;
X       else RESUME; }
X
Xv { tinit(); BEGIN get; }                                       /* Receive */
Xr { tinit(); vstate = get;  vcmd = 0;   sipkt(); BEGIN ipkt; }	/* Get */
Xc { tinit(); vstate = rgen; vcmd = 'C'; sipkt(); BEGIN ipkt; }	/* Host */
Xg { tinit(); vstate = rgen; vcmd = 'G'; sipkt(); BEGIN ipkt; }	/* Generic */
X
Xx { SERVE; }	    	    	    	/* Be a Server */
X
X/* Dynamic states: <current-states>input-character { action } */
X
X<rgen,get,serve>S { rinit(data); bctu = bctr; BEGIN rfile; } /* Send-Init */
X
X<ipkt>Y  { spar(data);			/* Get ack for I-packet */
X    	   if (vcmd) { scmd(vcmd,cmarg); vcmd = 0; }
X    	   if (vstate == get) srinit();
X	   BEGIN vstate; }
X
X<ipkt>E  { if (vcmd) scmd(vcmd,cmarg);	/* Get E for I-packet (ignore) */
X    	   vcmd = 0; if (vstate == get) srinit();
X	   BEGIN vstate; }
X
X<serve>R { srvptr = srvcmd; decode(data,putsrv); /* Get Receive-Init */
X	   cmarg = srvcmd;  nfils = -1;
X    	   if (sinit()) BEGIN ssinit; else { SERVE; } }
X
X<serve>I { spar(data); rpar(data); ack1(data);	 /* Get Init Parameters */
X	   pktnum = 0; prvpkt = -1; }
X
X<serve>G { srvptr = srvcmd; decode(data,putsrv); /* Get & decode command. */
X	   putsrv('\0'); putsrv('\0');
X	   sstate = srvcmd[0]; BEGIN generic; }
X
X<serve>C { srvptr = srvcmd;		    	 /* Get command for shell */
X	   decode(data,putsrv); putsrv('\0');
X	   if (syscmd("",srvcmd)) BEGIN ssinit;
X	   else { errpkt("Can't do shell command"); SERVE; } }
X
X<serve>. { errpkt("Unimplemented server function"); SERVE; } /* Other */
X
X<generic>C { if (!cwd(srvcmd+1)) errpkt("Can't change directory"); /* CWD */
X    	     SERVE; }
X
X<generic>D { if (syscmd(DIRCMD,srvcmd+2)) BEGIN ssinit;	/* Directory */
X    	     else { errpkt("Can't list directory"); SERVE; } }
X
X<generic>E { if (syscmd(DELCMD,srvcmd+2)) BEGIN ssinit;	/* Erase */
X    	     else { errpkt("Can't remove file"); SERVE; } }
X
X<generic>F { ack(); return(0); }    	/* Finish */
X<generic>L { ack(); ttres(); return(kill(0,9)); } /* Bye, but no guarantee! */
X
X<generic>H { if (sndhlp()) BEGIN ssinit;
X    	     else { errpkt("Can't send help"); SERVE; } }
X
X<generic>T { if (syscmd(TYPCMD,srvcmd+2)) BEGIN ssinit;
X    	     else { errpkt("Can't type file"); SERVE; } }
X
X<generic>U { x = *(srvcmd+1);			/* Disk Usage query */
X    	     x = ((x == '\0') || (x == unchar(0)));
X	     x = (x ? syscmd(SPACMD,"") : syscmd(SPACM2,srvcmd+2));
X    	     if (x) BEGIN ssinit; else { errpkt("Can't check space"); SERVE; }}
X
X<generic>W { if (syscmd(WHOCMD,srvcmd+2)) BEGIN ssinit;
X    	     else { errpkt("Can't do who command"); SERVE; } }
X
X<generic>. { errpkt("Unimplemented generic server function"); SERVE; }
X
X/* Dynamic states, cont'd */
X
X
X<rgen>Y { decode(data,puttrm); RESUME; }    /* Got reply in ACK data */
X
X<rgen,rfile>F { if (rcvfil()) { ack(); BEGIN rdata; }	/* A file is coming */
X		else { errpkt("Can't open file"); RESUME; } }
X
X<rgen,rfile>X { opent(); ack(); BEGIN rdata; }	/* Screen data is coming */
X
X<rfile>B { ack(); reot(); RESUME; }	/* Got End Of Transmission */
X
X<rdata>D { if (cxseen) ack1("X");	/* Got data. */
X    	   else if (czseen) ack1("Z");
X	   else ack();
X	   decode(data,putfil); }
X
X<rdata>Z { ack(); reof(); BEGIN rfile; }    /* Got End Of File */
X
X<ssinit,ssdata,sseof,sseot>N { resend(); }  /* Got a NAK, resend. */
X
X<ssinit>Y {  int x; char *s;		/* Got ACK to Send-Init */
X    	     spar(data);
X    	     bctu = bctr;
X	     if (xflg) { x = sxpack(); s = "Can't execute command"; }
X	    	  else { x = sfile(); s = "Can't open file"; }
X	     if (x) BEGIN ssdata; else { errpkt(s); RESUME; }
X          }	    
X
X<ssdata>Y { if (canned(data) || !sdata()) { /* Got ACK to data */
X		clsif(); seof();
X		BEGIN sseof; } }
X
X<sseof>Y { if (gnfile() > 0) {		/* Got ACK to EOF, get next file */
X		if (sfile()) BEGIN ssdata;
X		else { errpkt("Can't open file") ; RESUME; }
X	   } else {			/* If no next file, EOT */
X		seot();
X		BEGIN sseot; } }
X
X<sseot>Y { RESUME; }			/* Got ACK to EOT */
X
XE { ermsg(data);			/* Error packet, issue message */
X    x = quiet; quiet = 1;		/* Close files silently */
X    clsif(); clsof();
X    quiet = x; RESUME; }
X
X. { nack(); }				/* Anything else, send NAK */
X%%
X
X/*  P R O T O  --  Protocol entry function  */
X
Xproto() {
X
X    extern int sigint();
X    int x;
X
X    conint(sigint);			/* Enable console interrupts */
X
X/* Set up the communication line for file transfer. */
X
X    if (local && (speed < 0)) {
X	screen(2,0l,"Sorry, you must 'set speed' first");
X	return;
X    }
X    if (ttopen(ttname,local,mdmtyp) < 0) {
X	screen(2,0l,"Can't open line");
X	return;
X    }
X    x = (local) ? speed : -1;
X    if (ttpkt(x,flow) < 0) {		/* Put line in packet mode, */
X	screen(2,0l,"Can't condition line"); /* setting speed, flow control */
X	return;
X    }
X    if (sstate == 'x') {		/* If entering server mode, */
X	server = 1;			/* set flag, */
X	if (!quiet) {
X	    if (!local)			/* and issue appropriate message. */
X	    	conol(srvtxt);
X	    else {
X	    	conol("Entering server mode on ");
X		conoll(ttname);
X	    }
X	}
X    } else server = 0;
X    sleep(1);
X
X/*
X The 'wart()' function is generated by the wart program.  It gets a
X character from the input() routine and then based on that character and
X the current state, selects the appropriate action, according to the state
X table above, which is transformed by the wart program into a big case
X statement.  The function is active for one transaction.
X*/
X
X    wart();				/* Enter the state table switcher. */
X    
X    if (server) {			/* Back from packet protocol. */
X	server = 0;
X    	if (!quiet)  			/* Give appropriate message */
X	    conoll("C-Kermit server done");
X    } else
X    	screen(BEL,0l,"");		/* Or beep */
X}
!FUNKY!STUFF!
echo x - ckuser.h
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckuser.h
X/*  C K U S E R . H  --  Symbol definitions for C-Kermit ckus*.c modules  */
X
X
X/* Values associated with top-level commands, must be 0 or greater. */
X
X#define XXBYE   0	/* BYE */
X#define XXCLE   1	/* CLEAR */
X#define XXCLO   2	/* CLOSE */
X#define XXCON   3	/* CONNECT */
X#define XXCPY   4	/* COPY */
X#define XXCWD   5	/* CWD (Change Working Directory) */
X#define XXDEF	6	/* DEFINE (a command macro) */
X#define XXDEL   7	/* (Local) DELETE */
X#define XXDIR   8	/* (Local) DIRECTORY */
X#define XXDIS   9	/* DISCONNECT */
X#define XXECH  10	/* ECHO */
X#define XXEXI  11	/* EXIT */
X#define XXFIN  12	/* FINISH */
X#define XXGET  13	/* GET */
X#define XXHLP  14	/* HELP */
X#define XXINP  15	/* INPUT */
X#define XXLOC  16	/* LOCAL */
X#define XXLOG  17	/* LOG */
X#define XXMAI  18	/* MAIL */
X#define XXMOU  19	/* (Local) MOUNT */
X#define XXMSG  20	/* (Local) MESSAGE */
X#define XXOUT  21	/* OUTPUT */
X#define XXPAU  22	/* PAUSE */
X#define XXPRI  23	/* (Local) PRINT */
X#define XXQUI  24	/* QUIT */
X#define XXREC  25	/* RECEIVE */
X#define XXREM  26	/* REMOTE */
X#define XXREN  27	/* (Local) RENAME */
X#define XXSEN  28	/* SEND */
X#define XXSER  29   	/* SERVER */
X#define XXSET  30	/* SET */
X#define XXSHE  31	/* Command for SHELL */
X#define XXSHO  32	/* SHOW */
X#define XXSPA  33	/* (Local) SPACE */
X#define XXSTA  34	/* STATISTICS */
X#define XXSUB  35	/* (Local) SUBMIT */
X#define XXTAK  36	/* TAKE */
X#define XXTRA  37	/* TRANSMIT */
X#define XXTYP  38	/* (Local) TYPE */
X#define XXWHO  39	/* (Local) WHO */
X#define XXDIAL 40	/* (Local) dial */
X#define XXLOGI 41	/* (Local) logon */
X
X/* SET parameters */
X
X#define XYBREA  0	/* BREAK simulation */
X#define XYCHKT  1	/* Block check type */
X#define XYDEBU  2	/* Debugging */
X#define XYDELA  3	/* Delay */
X#define XYDUPL  4	/* Duplex */
X#define XYEOL   5	/* End-Of-Line (packet terminator) */
X#define XYESC   6	/* Escape character */
X#define XYFILE  7	/* File Parameters */
X#define   XYFILN 0  	/*  Naming  */
X#define   XYFILT 1  	/*  Type    */
X#define   XYFILW 2      /*  Warning */
X#define   XYFILD 3      /*  ...     */
X/* empty space to add something */
X#define XYFLOW  9	/* Flow Control */
X#define XYHAND 10	/* Handshake */
X#define XYIFD  11	/* Incomplete File Disposition */
X#define XYIMAG 12	/* "Image Mode" */
X#define XYINPU 13	/* INPUT command parameters */
X#define XYLEN  14	/* Maximum packet length to send */
X#define XYLINE 15	/* Communication line to use */
X#define XYLOG  16	/* Log file */
X#define XYMARK 17	/* Start of Packet mark */
X#define XYNPAD 18	/* Amount of padding */
X#define XYPADC 19	/* Pad character */
X#define XYPARI 20	/* Parity */
X#define XYPAUS 21	/* Interpacket pause */
X#define XYPROM 22	/* Program prompt string */
X#define XYQBIN 23	/* 8th-bit prefix */
X#define XYQCTL 24	/* Control character prefix */
X#define XYREPT 25	/* Repeat count prefix */
X#define XYRETR 26	/* Retry limit */
X#define XYSPEE 27	/* Line speed (baud rate) */
X#define XYTACH 28	/* Character to be doubled */
X#define XYTIMO 29	/* Timeout interval */
X#define XYMODM 30	/* Modem type */
X
X/* REMOTE command symbols */
X
X#define XZCPY  0	/* Copy */
X#define XZCWD  1	/* Change Working Directory */
X#define XZDEL  2	/* Delete */
X#define XZDIR  3	/* Directory */
X#define XZHLP  4	/* Help */
X#define XZHOS  5	/* Host */
X#define XZKER  6	/* Kermit */
X#define XZLGI  7	/* Login */
X#define XZLGO  8	/* Logout */
X#define XZMAI  9	/* Mail */
X#define XZMOU 10	/* Mount */
X#define XZMSG 11	/* Message */
X#define XZPRI 12	/* Print */
X#define XZREN 13	/* Rename */
X#define XZSET 14	/* Set */
X#define XZSPA 15	/* Space */
X#define XZSUB 16	/* Submit */
X#define XZTYP 17	/* Type */
X#define XZWHO 18	/* Who */
X
X/* Symbols for logs */
X
X#define LOGD 0	    	/* Debugging */
X#define LOGP 1          /* Packets */
X#define LOGS 2          /* Session */
X#define LOGT 3          /* Transaction */
!FUNKY!STUFF!
echo x - ckwart.doc
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckwart.doc
XWART
X
XWart is a program that implements a small subset of the Unix 'lex'
Xlexical analyzer generator.  Unlike lex, wart may be distributed without
Xrequirement for a Unix license.  Wart was written at the Columbia University
XCenter of Computing Activities to facilitate development of Unix Kermit.
X
XWart is intended for production of state table switchers.  It allows a
Xset of states to be defined, along with a function for getting input.  The
Xperforms actions and switches states based on the current state and the
Xinput.
X
XThe following short program demonstrates some of the capabilities and
Xlimitations of Wart.  The program accepts from the command line a binary
Xnumber, preceded by an optional minus sign, and optionally containing a
Xfractional part.  It prints the decimal equivalent.
X
X#include <stdio.h>
X
Xint state, s = 1, m = 0, d;
Xfloat f;
Xchar *b;
X
X%states sign mantissa fraction		    /* Declare wart states */
X
X%%					    /* Begin state table */
X<sign>-      { s = -1; BEGIN mantissa; }    /* Look for sign */
X<sign>0      { m = 0;  BEGIN mantissa; }    /* Got digit, start mantissa */
X<sign>1      { m = 1;  BEGIN mantissa; }
X<sign>.      { fatal("bad input"); }	    /* Detect bad format */
X<mantissa>0  { m *= 2; }		    /* Accumulate mantissa */
X<mantissa>1  { m = 2 * m + 1; }
X<mantissa>$  { printf("%d\n", s * m); return; }
X<mantissa>.  { f = 0.0; d = 1; BEGIN fraction; }    /* Start fraction */
X<fraction>0  { d *= 2; }		    	    /* Accumulate fraction */
X<fraction>1  { d *= 2; f += 1.0 / d; }
X<fraction>$  { printf("%f\n", s * (m + f) ); return; }
X<fraction>.  { fatal("bad input"); }
X%%
X
Xinput() {				    /* Define input() function */
X    int x;
X    return(((x = *b++) == '\0') ? '$' : x );
X}
X
Xfatal(s) char *s; {			    /* Error exit */
X    fprintf(stderr,"fatal - %s\n",s);
X    exit(1);
X}
X
Xmain(argc,argv) int argc; char **argv; {    /* Main program */
X    if (argc < 1) exit(1);
X    b = *++argv;
X    state = sign;			    /* Initialize state */
X    wart();				    /* Invoke state switcher */
X    exit(0);				    /* Done */
X}
X
XThe wart program accepts as input a C program containing lines that start
Xwith "%" or sections delimited by "%%".  The directive "%states" declares
Xthe program's states.  The section enclosed by "%%" markers is the state
Xtable, with entries of the form
X
X  <state>X { action }
X
Xwhich read as "if in state <state> with input X perform { action }"
X
XThe optional <state> field tells the current state or state the program must
Xbe in to perform the indicated action.  If no state is specified, then it
Xmeans the action will be performed regardless of the current state.  If more
Xthan one state is specifed, then the action will be performed in any of the
Xlisted states.  Multiple states are separated by commas.
X
XThe required input field consists of a single literal character.  When in
Xthe indicated state, if the input is the specified character, then the
Xassociated action will be performed.  The character '.' matches any input
Xcharacter.  No pattern matching or range notation is provided.  The input
Xcharacter is obtained from the input() function, which you must define.  It
Xshould be alphanumeric, or else one of the characters ".% -$@" (quotes not
Xincluded).  Note that the program above recognize the binary point '.'
Xthrough a ruse.
X
XThe action is a series of zero or more C language statements, enclosed in
Xcurly braces.
X
XThe BEGIN macro is defined simply to be "state = ", as in lex.
X
XThe wart() function is generated by the wart program based on the state
Xdeclarations and the state transition table.  It loops through calls to
Xinput(), using the result to index into a big case statement it has created
Xfrom the state table.
X
XWart is invoked as follows:
X
X	wart
X
XInput from stdin, output to stdout
X
X	wart fn1
X
XInput from fn1, output to stdout
X
X	wart fn1 fn2
X
XInput from fn1, output to fn2.  Example:  wart a.w a.c
X
XWart programs have the conventional filetype '.w'.
!FUNKY!STUFF!
echo x - ckwho.txt
sed '1,$s/^X//' <<\!FUNKY!STUFF! > ckwho.txt
X(18 Feb 85)
X
XThe following people have tentatively volunteered to supply support in
XC-Kermit 4.0 for the following systems:
X
X
XWhat                             Who
X
XDEC Pro-350/380, Venix           SY.FDC at CU20B (Frank da Cruz)
X
XIBM 370-series, Ahmdah UTS       SY.FDC at CU20B (Frank da Cruz)
X
XApple Macintosh                  SY.WBC3 at CU20B (Bill Catchings)
X
XMasscomp RTU 2.2                 sob at RICE (Stan Barber)
X
XCoherent                         vortex!lauren at RAND-UNIX (Lauren Weinstein) 
X
XCallan UniStar 300 with
X Unisoft 68000 System V Unix     EBM at MIT-XX (Eliot Moss)
X
XATT 3Bx, System V                Chris at COLUMBIA-20 (Chris Maio)
X
XIBM PC, etc, PC/IX               HFISCHER at USC-ECLB (Herm Fischer)
X
XIBM PC, etc, Xenix               HFISCHER at USC-ECLB (Herm Fischer)
X
XVAX,PDP-11 with IS3, Interactive
X Systems version of System III   HFISCHER at USC-ECLB (Herm Fischer)
X
XOs9                              BLARSON at USC-ECL (Bob Larson)
X
XVersion 7                        vasoll%okstate.csnet at CSNET-RELAY (Mark Vasoll)
X
X4.2 UUCP Line Locking            hipl!tony at NYU-CMCL2 (Tony Movshon)
X
XHP9000 Series 200 (HP9836)
X with HP-UX System III           b-davis at utah-cs (Brad Davis)
X
XCP/M (Small C or BDS C)          bdale at cmu-cs-g (Bdale Garbee)
X
XHoneywell GCOS3/8                Carlin%HIS-PHOENIX-MULTICS at MIT-MULTICS
X
X68000 Xenix                      ED at MIT-MC (Ed Schwalenberg)
X
XVAX, 2.0 BSD                     nsc!jon at DECWRL (Jon Ryshpan)
X
XCP/M-86, De Smet C               nsc!jon at DECWRL (Jon Ryshpan)
X
XLogin scripts, raw upload        poulton%hplabs.csnet at CSNET-RELAY (Ken Poulton)
X
XApple II, Aztec C                Saline at MIT-MULTICS (Steven Saline)
!FUNKY!STUFF!



More information about the Comp.sources.unix mailing list