Thread View: mod.amiga.sources
1 messages
1 total messages
Started by doc
Tue, 23 Sep 1986 14:57
VT100 Terminal Emulator (V2.1 DBW 860915) Part 1 of 2
Author: doc
Date: Tue, 23 Sep 1986 14:57
Date: Tue, 23 Sep 1986 14:57
2488 lines
76664 bytes
76664 bytes
Reply-To: wecker%cookie.DEC@decwrl.DEC.COM (DAVE TANSTAAFL WECKER)
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# readme
# vt100.doc
# makefile
# vt100.h
# vt100.c
# kermit.c
# This archive created: Sun Sep 14 22:42:20 1986
echo shar: extracting readme
sed 's/^XX//' << \SHAR_EOF > readme
XXThis archive contains a vt100 emulator with KERMIT and XMODEM file transfer
XXprotocols by Dave Wecker (V2.1 DBW 860915).
XX
XXThanks:
XX-------
XX A large part of this release is due to Steve Drew and Tony Sumrall
XX (lots of contributed code). Thanks for all of your efforts!!
XX
XXReleases:
XX---------
XX v2.1 860915 DBW - new features (see README)
XX v2.0 860823 DBW - Major rewrite
XX v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
XX v1.0 860712 DBW - First version released
XX
XXUsage:
XX------
XX Please read VT100.DOC for usage information and examples.
XX
XXRelease Notes:
XX--------------
XXv2.1 860915 DBW - new features / bug fixes
XX
XX - Now identifies as a VT100 (including the response to <esc>Z)
XX
XX - Cursor color now gets read in as hex (instead of decimal)
XX
XX - REPORTMOUSE taken out of definitions (not needed)
XX
XX - XON/XOFF now being handled by the device driver instead of me
XX
XX - Literal escape characters have been replaced with \033
XX
XX - At init time the user can now specify the input BUFFER size
XX (typically between 512 and 2048 bytes) depending on baud rate
XX
XX - Script files are now case insensitive for commands
XX
XX - XMODEM now turns off the driver XON/XOFF during transfers
XX
XX - Graphic rendition now done by the OS instead of me.
XX
XX - Initialization files are now searched for in S: instead of C:
XX
XX - Forward GOTO bug fixed in the script package.
XX
XX - Keypad can now be used in both numeric and application mode
XX
XX - General purpose cleanup() routine added for all exits.
XX
XX - Utility menu added (sendbreak, hangup, change directory).
XX NOTE: hangup is not implemented yet.
XX
XX - Full wild card support in file transfers (see vt100.doc).
XX
XX - Kermit cleaned up with better filename handling (from host).
XX
XX - Script now has CD (changed directory) and SB (send break) commands
XX
XX - Added Parity and Wordsize choices in VT100.H, VT100.INIT, menu
XX and scripts. (Generates parity from a table).
XX
XX - Added 8th bit quoting in KERMIT when using 7 bit words (ODD or
XX EVEN parity).
XX
XX - Break time can be set from VT100.H, VT100.INIT or a script file.
XX
XX - Transfer mode (image or CRLF) can now be set from a script file.
XX
XX - Control characters in escape sequences now act like a true VT100.
XX
XX - F10 now works from init files.
XX
XX - Right (or Left) AMIGA with period (".") sends a BREAK to the host
XX from the keyboard.
XX
XX - XMODEM status kept down to one line for a file transfer.
XX
XXv2.0 860823 DBW - Major rewrite:
XX
XX - Emulator now compiles under either MANX or LATTICE by defining
XX the appropriate compiler type in VT100.H.
XX
XX - Sped up code to an effective baud rate of (about) 8k. This means
XX that clear text at 4800 baud should be no problem.
XX
XX - Added XON/XOFF generation so that characters should not get lost
XX any more at 9600 baud (when receiving clear text).
XX
XX - Got rid of all command line switches and environment variables.
XX Instead upon invocation the program searches first for any file
XX named on the command line, then looks for VT100.INIT in the
XX current directory and finally searches for C:VT100.INIT.
XX
XX All parameters can be set in the init file, and a sample VT100.INIT
XX is provided in VT100.DOC that shows all possible options.
XX
XX - All parameters that are set by VT100.INIT are defined in VT100.H
XX (variables starting with "p_"). This allows you to compile your
XX own defaults into the code.
XX
XX - You can now set the number of lines (for all you EMACS freaks :-).
XX On an interlaced screen this gives you upto a 48 line terminal.
XX
XX - WORKBENCH colors are NEVER touched.
XX
XX - In an attempt to keep the size down, the color palette menu item
XX has been removed (current). Code is about 36K in size with a
XX run time image (using workbench screen) of about 88k.
XX
XX - Many bugs fixed including reverse scrolling with descenders,
XX reverse video at end of line, clearing with scrolling regions,
XX ... and 20 or more others.
XX
XX - File capture now no longer sends the filename to the host.
XX
XX - BOLD (<esc>[1m) has now been added by using an additional color
XX when you specify a depth of 2 (instead of 1) bitplane.
XX
XX - UNDERLINE (<esc>[4m) has now been added.
XX
XX - The handling of remote (host) escape sequences has been completly
XX re-written (thanks to Dawn Banks for all the work).
XX
XX - Function keys (and shifted function keys) can now be bound to
XX arbitrary strings (Jim Ravan gets his macros). See VT100.DOC
XX for details.
XX
XX - Cursor has no been reduced to the size of a normal character for
XX easier readability.
XX
XX - XMODEM has been improved (by Steve Drew) to use a timer device
XX (for timeouts) and to abort immediately if the user types <ESC>.
XX
XX - KERMIT has been completely re-written and appears to work fine,
XX thanks to the efforts of Steve Drew. Items include:
XX
XX - supports multi-file transfer in both send and receive modes
XX - works with binary files (tried with VAX/vms and VAX/unix)
XX - now has Get file for use with server (receiving files)
XX - Kermit BYE item will send server bye command.
XX - A final filename of dollar sign ("$") will send a BYE
XX to the host KERMIT server.
XX - status bar shows pkt type, pkt no., total retransmissions,
XX filename, total bytes xfered and status which can be:
XX SEND - sending this file
XX RECV - receiving this file
XX ABORT - user hit escape to abort transfer..
XX TMOUT - did not receive characters before timeout
XX ERROR - some other error detected.
XX DONE - transfer complete
XX - now uses timer.device to determine if timeout occurrs.
XX - will cleanly abort when user hits <ESC> if in send mode
XX tells host to discard the partial file.
XX
XX - New menu item allows script file support. Module written by
XX Steve Drew. See VT100.DOC for details.
XX
XXKnown problems:
XX---------------
XX
XX - none yet (need to hear what still doesn't work right).
XX
XXYet to be done (possibly.. not promising anything):
XX---------------------------------------------------
XX
XX - Add sending/receiving of entire volumes (with data compression).
XX Maybe use LZW compression.
XX
XX - Add BOO file transfer mode for encoding/decoding binary
XX files into clear text.
XX
XXInstallation:
XX-------------
XX The files in this archive may be extracted by the bourne shell
XX (/bin/sh) or the shar program using the "unshar switch (-u)",
XX contact me if you need a copy of this version of shar.
XX
XXFiles:
XX------
XX README - this file
XX
XX vt100.doc - documentation for the terminal emulator
XX
XX makefile - make file for the emulator (under MANX AZTEC-C)
XX
XX vt100.h - include file used by all other modules
XX
XX window.c - manager for window and keyboard
XX
XX vt100.c - main module, handles menus
XX
XX remote.c - handle remote characters (vt100 emulation)
XX
XX kermit.c - kermit protocol (to transfer text files on VMS
XX select the CRLF option on the transfer mode menu,
XX otherwise use image mode).
XX
XX init.c - startup code
XX
XX xmodem.c - xmodem protocol that understands AMIGA binary and
XX text file formats (automatically).
XX
XX script.c - script control package
XX
XXContact:
XX--------
XXPlease send bugs/comments/suggestions to:
XX
XX Dave Wecker at ENET: COOKIE::WECKER
XX ARPA: wecker%cookie.dec.com@decwrl.dec.com
XX USENET: {decvax|decwrl}!cookie.dec.com!wecker
XX SNAIL: Dave Wecker
XX 115 Palm Springs Drive
XX Colorado Springs, CO 80908
SHAR_EOF
if test 7269 -ne "`wc -c readme`"
then
echo shar: error transmitting readme '(should have been 7269 characters)'
fi
echo shar: extracting vt100.doc
sed 's/^XX//' << \SHAR_EOF > vt100.doc
XXThis is the documentation file for the VT100 terminal emulator by Dave
XXWecker (V2.1 DBW 860915). Comments/suggestions/bugs/problems/praise should
XXbe sent to:
XX
XX Dave Wecker at ENET: COOKIE::WECKER
XX ARPA: wecker%cookie.dec.com@decwrl.dec.com
XX USENET: {decvax|decwrl}!cookie.dec.com!wecker
XX SNAIL: Dave Wecker
XX 115 Palm Springs Drive
XX Colorado Springs, CO 80908
XX
XXMulti-file transfer, the new version of KERMIT and script support were
XXcontributed by Steve Drew (Aug 20 1986). If you wish to thank Steve
XXdirectly he can be contacted through:
XX
XX Steve Drew at ENET: CGFSV1::DREW
XX ARPA: drew%cfgsv1.dec.com@decwrl.dec.com
XX USENET: decvax!decwrl!cgfsv1.dec.com!drew
XX
XXProgram startup:
XX----------------
XX 1> vt100 [initfile]
XX
XX - At startup, the program will search for an initialization
XX file to execute. It will first look for "initfile", then
XX VT100.INIT (in the current directory) and finally
XX S:VT100.INIT. The format for the init file is described
XX later in this document.
XX
XX - The init file controls the setting of initial defaults
XX and screen and macro definitions.
XX
XX - If none of the files (listed above) are found, the
XX built-in defaults (defined in VT100.H as variables,
XX beginning with "p_") are used.
XX
XX - All commands are either menu or script based. Scripts
XX are described below.
XX
XXMenus:
XX------
XXFile - file transfers
XX Ascii Capture - Begin/end a script of the current session
XX Ascii Send - Type a file to the host
XX Xmodem Receive - Receive a file using XMODEM protocol
XX Xmodem Send - Send a file using XMODEM protocol
XX Kermit Get - Receive files from a host KERMIT SERVER
XX Kermit Receive - Receive files from a host KERMIT
XX Kermit Send - Send files to a host KERMIT [SERVER]
XX Kermit Bye - Terminate a host KERMIT SERVER
XXBaudRate - Set the terminal baud rate
XX 300, 1200, 2400, 4800, 9600
XXXfer Mode - Transfer mode for KERMIT
XX image - Send files verbatim (for UNIX hosts or
XX binary files)
XX CR LF - Send CR LF as line terminator and strip
XX CR on received files (VMS text).
XXScript - Script commands
XX Execute file - Start up an asynchronous script file
XX Abort Execution - Terminate a script file
XXUtility - Utility commands
XX Send Break - send a break to the host
XX Hang Up - close line (not implemented yet)
XX Change Dir - change the local directory (for transfers)
XX No Parity - do not use parity
XX Even Parity - use even parity (7 bit data)
XX Odd Parity - use odd paroty (7 bit data)
XX 8bit Word Size - 8bit transfers (no parity)
XX 7bit Word Size - 7bit transfers (parity allowed)
XX
XXKeypad mapping (in application mode):
XX-------------------------------------
XX
XX AMIGA VT100 comments
XX ------- ------- ---------------------------
XX 0-9 == 0-9
XX . == .
XX ENTER == ENTER (basically, flip the bottom
XX - == , 2 keys up to get a VT100)
XX HELP == - (only free key around)
XX f1-f4 == PF1-PF4 (or any rebinding you do)
XX arrows == arrows
XX
XXNote: Right (or Left) AMIGA key in conjunction with a period (".") will
XX send a break to the host.
XX
XXInitialization file example:
XX----------------------------
XXHere is a (hopefully) self-explanatory VT100.INIT file with all options
XXused:
XX
XX#######################################################################
XX#
XX# VT100 sample initialization file
XX# v2.1 860915 DBW - Dave Wecker standard defaults
XX#
XX# Hash mark at the beginning of a line denotes a comment.
XX# White space (space(s) or tab(s)) delimit fields.
XX# Case ignored except for function key bindings.
XX#
XX# All items in this file overide variables of the same name in VT100.H
XX# (all variables in vt100.h have a "p_" prepended to them)
XX#
XX##########################################################################
XX#
XXBAUD 2400 # Anything after required fields is ignored
XXSCREEN WORKBENCH # may be CUSTOM or WORKBENCH
XXINTERLACE OFF # ON for CUSTOM or interlaced workbench
XXDEPTH 2 # number of bit planes to use (1 or 2)
XXFOREGROUND 840 # Colors are only used on the custom screen
XXBACKGROUND 000 # Colors are in hex RGB from 000 to FFF
XXBOLD c00 # Color for bold highlighting (in custom)
XXCURSOR 888 # Color for cursor (in custom screen)
XXLINES 24 # normal <= 24 interlaced <= 48
XXMODE IMAGE # IMAGE or CRLF (for KERMIT transfers)
XXBUFFER 512 # 512 <= Input buffer size <= 2048
XXWORDSIZE 8 # 7 or 8 bits (7 bits when using parity)
XXPARITY NONE # NONE, ODD or EVEN (with 7 bit wordsize)
XXBREAK 750000 # Length for break key in microseconds
XX#
XX# Function bindings (strings to type when any of F1 through F10 are pressed)
XX# f<num> = function key
XX# F<num> = shifted function key
XX#
XX# The string specified must be delimited and uses one special character:
XX# ^ = control next character
XX# ^^ = up arrow
XX#
XX# Sample control characters:
XX# ^[ = escape ^M = carriage return
XX# ^J = line feed ^L = form feed
XX#
XX# Examples of bindings:
XX#
XXf1 "^[OP" # f1-f4 = PF1 - PF4 on a VT100
XXf2 "^[OQ"
XXf3 "^[OR"
XXf4 "^[OS"
XXf6 "MAIL^M" # Reads my mail (note embedded <CR>)
XXf7 "NOTE^M" # Reads conferences
XXF1 "$2400!" # dials the phone to work
XXF2 "$bbs1!" # dials the phone to billboard 1
XXF3 "$bbs2!" # dials the phone to billboard 2
XXF4 "$bbs3!" # dials the phone to billboard 3
XX#
XXexit # all done (clean way to end file)
XX
XXMulti file Xfers:
XX-----------------
XXThe VT100 emulator now supports multiple file transfers. This is specified
XXby using a comma (",") between file names when using XMODEM or KERMIT.
XX(NOTE: host XMODEM's normally CANNOT support multiple file transfers).
XX
XXWhen specifying a file name to recieve by default the directory path is
XXstripped of the filename when sent to the host but is kept for the local
XXfile spec. eg:
XX
XX receive file: ram:file.txt,df1:newfile.bin,$
XX
XXwill ask the server for file.txt and put it in ram:, and get newfile.bin
XXand put it on df1: (see explanation of "$" below). If you do a single file
XXtransfer you will get another prompt for the remote name e.g.:
XX
XX receive file: ram:file.txt
XX remote file name[file.txt] userdisk1:wantfile.txt
XX
XXThe same rules apply to sending multiple files therefore if you are
XXdoing multi file transfers make sure the host server is connected to the
XXdesired directory.
XX
XXIn addition KERMIT now supports wildcards (* = any number of characters,
XX? = any single character). Examples:
XX
XX send: *.c,*.h,*.doc
XX get: *.c,*.h,$
XX
XXKERMIT receive is now smart enough to use the host filename so no filename
XXneeds to be specified on the AMIGA's side.
XX
XXScript file operation:
XX----------------------
XXThe script file can be invoked by selecting 'execute file' from the script
XXmenu. At any time you can abort the script file by selecting
XX'Abort Execution'.
XX
XXDuring the time script file is running the terminal emulation is still
XXactive and you may type simulataneous to the script file. This may be desired
XXif your script file is WAITing for a string or is DELAYing for a period of
XXtime etc.
XX
XXScript file Commands (case insensitive):
XX------------------------------------------------------------
XX# Commented line
XX Format:
XX # comment may not be on same line as a command.
XX Example:
XX # this is a comment
XX------------------------------------------------------------
XXASCII_SEND Send an ascii file to the host.
XX Format:
XX (same format as CAPTURE)
XX------------------------------------------------------------
XXBAUD Set baud rate
XX Format:
XX BAUD rate Sets the baud rate for send/receive
XX Example:
XX BAUD 2400 Sets the baud rate at 2400 baud
XX------------------------------------------------------------
XXBT Set the break time (for an SB command)
XX Format:
XX BT value Value is in micro-seconds
XX Example:
XX BT 750000
XX------------------------------------------------------------
XXCAPTURE To start/stop ascii file capture.
XX Format:
XX CAPTURE file Start ascii capturing
XX CAPTURE End ascii capturing
XX Example:
XX CAPTURE foo.bar Starts capture of file foo.bar
XX CAPTURE Ends ascii capture of file foo.bar
XX------------------------------------------------------------
XXCD To change the local directory
XX Format:
XX CD newdir set a new directory for file transfers
XX Example:
XX CD DF1:foo/bar set the directory as specified
XX------------------------------------------------------------
XXDELAY Suspends script file for a specified time
XX Format:
XX DELAY n Suspends execution for n seconds
XX Example:
XX DELAY 2 Suspends for 2 seconds
XX------------------------------------------------------------
XXEXIT Ends execution of the script file.
XX Format:
XX EXIT
XX------------------------------------------------------------
XXGOTO Jumps to a different part of the script file.
XX Format:
XX GOTO label Jumps to a line beginning with label:
XX Jumps may be forward or backward.
XX Example:
XX FOO: Sets up a label
XX GOTO FOO Jumps to FOO
XX------------------------------------------------------------
XXKB Send a BYE packet to a host KERMIT server (shut down server).
XX Format:
XX KB
XX------------------------------------------------------------
XXKG Gets files from host. (which is running as a server).
XX Format:
XX (same format as KS)
XX------------------------------------------------------------
XXKR Receives a file from kermit host (not running as server)
XX Format:
XX (same format as KS)
XX------------------------------------------------------------
XXKS Sends files via kermit to the host.
XX Format:
XX KS file Send one file
XX KS file1,file2,... Send multiple files
XX KS file1,file2,...,$ Send multiple files and shut down server
XX Example:
XX KS foo.bar sends foo.bar (note no quoting is used)
XX KS foo1,foo2,foo3 sends three files
XX KS foo1,foo2,foo3,$ sends three files and shuts down server
XX------------------------------------------------------------
XXON Peforms a command every time a string is received
XX Format:
XX ON "string" cmd Execute cmd when string is received. Only
XX one ON string may be installed at a time.
XX
XX If cmd is a GOTO and we were previously
XX WAITing for a string the WAIT is aborted and
XX execution resumes at the new label.
XX
XX If cmd is not SEND and we were previously
XX DELAYing, then the DELAY is aborted and the
XX cmd is executed, followed by the next command
XX after the DELAY.
XX
XX If cmd is a SEND and we were previously
XX DELAYing, then the DELAY is continued.
XX Example:
XX ON "LOSS CARRIER" GOTO RESTART
XX If modem drops carrier, try to redial
XX ON "--more--" SEND " "
XX Send a space every time --more-- is received
XX------------------------------------------------------------
XXPARITY Sets the parity
XX Format:
XX PARITY type Set the parity type
XX Example:
XX PARITY NONE no parity
XX PARITY ODD odd parity
XX PARITY EVEN even parity
XX------------------------------------------------------------
XXSEND Sends a string or character to the host.
XX Format:
XX SEND "string" Sends a string to the host. Beginning and
XX ending double quotes (") are required. A
XX vertical bar may be used to send a <CR>.
XX SEND chr Sends a single character.
XX SEND ^chr Sends a single control character. The chr
XX must be an upper case letter.
XX Example:
XX SEND "mail" Send the string mail
XX SEND "dir|" Send the string dir followed by a <CR>
XX SEND a Send the letter a
XX SEND ^C Send a control C
XX------------------------------------------------------------
XXSB Sends a break character to the host
XX Format:
XX SB Note that any pending character to send
XX Example: is aborted by this call
XX SB
XX------------------------------------------------------------
XXTM Set a transfer mode for KERMIT to use
XX Format:
XX TM type type of transfers to perform
XX Example:
XX TM IMAGE image mode transfers
XX TM CRLF <CR><LF> text transfers (VMS Kermit).
XX------------------------------------------------------------
XXWAIT Suspends the script file until a certain string is received.
XX Format:
XX WAIT "string" Same rules for string as SEND
XX WAIT Enter an endless wait. Usually used after
XX some "ON" commands have been set up. Can
XX still aborted via the script menu.
XX Example:
XX WAIT "User:" Waits for the string User:
XX WAIT Waits forever
XX------------------------------------------------------------
XXWORD Sets the transmit/receive word length (in bits)
XX Format:
XX WORD length
XX Example:
XX WORD 7 7 bit words (used with parity)
XX WORD 8 8 bit words (no parity)
XX------------------------------------------------------------
XXXR Receives a file via XMODEM.
XX Format:
XX (same format as KS)
XX------------------------------------------------------------
XXXS Sends a file via XMODEM.
XX Format:
XX (same format as KS)
XX------------------------------------------------------------
XX
XX
XXScript file example:
XX--------------------
XX#
XX# Script to upload the terminal emulator sources to my host system
XX# v1.0 860823 DBW
XX# v2.1 860915 DBW
XX#
XX# Make sure that we have all the parameters we want
XX#
XX BAUD 2400
XX PARITY NONE
XX WORD 8
XX TM CRLF
XX BT 750000
XX SB
XX#
XX# First get the modem's attention:
XX#
XXStart:
XX DELAY 1
XX ON "Ready" GOTO Dial
XX SEND ^B
XX DELAY 2
XX GOTO Start
XX#
XX# Now dial the 2400 baud line to work:
XX#
XXDial:
XX ON "Attached" GOTO Login
XX SEND "$2400!"
XX DELAY 30
XX GOTO Start
XX#
XX# We got attached, so keep hitting return until the Gandalf terminal
XX# handler wakes up:
XX#
XXLogin:
XX ON "enter" GOTO Gandalf
XX DELAY 1
XX SEND "|"
XX GOTO Login
XX#
XX# Now connect from the Gandalf to the terminal server (ts1):
XX# (when it asks for a password I need to type the password manually here)
XX#
XXGandalf:
XX DELAY 2
XX SEND "ts1|"
XX WAIT "class start"
XX#
XX# Keep sending <CR>'s until the LAT prompts for a username:
XX#
XXWaitLat:
XX DELAY 2
XX ON "username>" GOTO Lat
XX SEND "|"
XX GOTO WaitLat
XX#
XX# Tell the LAT that it's me, and connect to the "cookie cluster" (my host
XX# systems). Tell the cluster my user name.
XX# (when it asks for a password I need to type the password manually here)
XX#
XXLat:
XX SEND "wecker|"
XX DELAY 1
XX SEND "connect cookie|"
XX WAIT "Username:"
XX SEND "WECKER|"
XX WAIT "at home"
XX SEND "||"
XX#
XX# Got through all the LOGIN garbage, so let's do some work.
XX#
XX WAIT "$ "
XX#
XX# Get into the right directory and no broadcast mode
XX#
XX CD df1:vt100_source
XX SEND "set term/nobroad|"
XX SEND "set default [wecker.amiga.vt100]|"
XX WAIT "$ "
XX#
XX# Send the readme file for the terminal emulator via XMODEM:
XX#
XX SEND "xmodem -r readme|"
XX DELAY 3
XX XS readme
XX WAIT "$ "
XX#
XX# Send the other terminal emulator files via KERMIT:
XX#
XX DELAY 1
XX SEND "kermit server|"
XX DELAY 3
XX KS vt100.doc,makefile,vt100.h,*.c,$
XX WAIT "$ "
XX#
XX# We popped out of server mode, so we're done
XX#
XX EXIT
XX
SHAR_EOF
if test 14422 -ne "`wc -c vt100.doc`"
then
echo shar: error transmitting vt100.doc '(should have been 14422 characters)'
fi
echo shar: extracting makefile
sed 's/^XX//' << \SHAR_EOF > makefile
XX######################################################################
XX#
XX# Makefile to build vt100 terminal emulator
XX#
XX# v2.1 860915 DBW - new features (see README)
XX# 860823 DBW - Integrated and rewrote lots of code
XX# v2.0 860809 DBW - Major release.. LOTS of changes
XX# v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
XX# v1.0 860712 DBW - First version released
XX#
XX######################################################################
XX
XXOBJS = vt100.o init.o window.o xmodem.o remote.o \
XX kermit.o script.o expand.o
XX
XX#INCL = vt100.h
XXINCL =
XX
XXvt100 : $(OBJS)
XX ln -w -v -o vt100 $(OBJS) -lc
XX
XXvt100.o : vt100.c $(INCL)
XX cc -b +Hvt100.syms vt100.c
XX
XXinit.o : init.c $(INCL)
XX cc -b +Ivt100.syms init.c
XX
XXwindow.o : window.c $(INCL)
XX cc -b +Ivt100.syms window.c
XX
XXxmodem.o : xmodem.c $(INCL)
XX cc -b +Ivt100.syms xmodem.c
XX
XXremote.o : remote.c $(INCL)
XX cc -b +Ivt100.syms remote.c
XX
XXkermit.o : kermit.c $(INCL)
XX cc -b +Ivt100.syms kermit.c
XX
XXscript.o : script.c $(INCL)
XX cc -b +Ivt100.syms script.c
XX
XXexpand.o : expand.c $(INCL)
XX cc -b +Ivt100.syms expand.c
XX
XX
SHAR_EOF
if test 1060 -ne "`wc -c makefile`"
then
echo shar: error transmitting makefile '(should have been 1060 characters)'
fi
echo shar: extracting vt100.h
sed 's/^XX//' << \SHAR_EOF > vt100.h
XX/*********************************************************************
XX * a terminal program that has ascii and xmodem transfer capability
XX *
XX * v2.1 860915 DBW - new features (see README)
XX * 860823 DBW - Integrated and rewrote lots of code
XX * v2.0 860809 DBW - Major release.. LOTS of changes
XX * v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
XX * v1.0 860712 DBW - First version released
XX *
XX * use esc to abort xmodem transfer
XX *
XX * written by Michael Mounier
XX * new version by Dave Wecker 860621
XX ************************************************************************/
XX
XX/* define the compiler type here */
XX#define LATTICE 0
XX#define MANX 1
XX
XX/* compiler diretives to fetch the necessary header files */
XX#include <exec/types.h>
XX#include <exec/exec.h>
XX#include <intuition/intuition.h>
XX#include <intuition/intuitionbase.h>
XX#include <graphics/gfxbase.h>
XX#include <graphics/gfx.h>
XX#include <graphics/text.h>
XX#include <graphics/regions.h>
XX#include <graphics/copper.h>
XX#include <graphics/gels.h>
XX#include <devices/serial.h>
XX#include <devices/keymap.h>
XX#include <hardware/blit.h>
XX#include <stdio.h>
XX#include <ctype.h>
XX#include <libraries/dos.h>
XX#include <libraries/dosextens.h>
XX#include <devices/timer.h>
XX
XX#if MANX
XX#include <functions.h>
XX#undef NULL
XX#define NULL ((void *)0)
XX#endif
XX
XX#define INTUITION_REV 1L
XX#define GRAPHICS_REV 1L
XX
XX/* things for xmodem send and recieve */
XX#define GOODREAD 0
XX#define TIMEOUT 1
XX#define USERABORT 2
XX#define SECSIZ 0x80
XX#define TTIME_SHORT 5 /* number of seconds for short timeout */
XX#define TTIME_LONG 50 /* number of seconds for long timeout */
XX#define TTIME_KERMIT 10 /* number of seconds for KERMIT timeout */
XX#define BufSize 0x200 /* Text buffer for XMODEM */
XX#define ERRORMAX 10 /* Max errors before abort */
XX#define RETRYMAX 10 /* Maximum retrys before abort */
XX#define SOH 1 /* Start of sector char */
XX#define EOT 4 /* end of transmission char */
XX#define ACK 6 /* acknowledge sector transmission */
XX#define NAK 21 /* error in transmission detected */
XX
XX#define FILEMAX 8 /* number of file menu items */
XX#define RSMAX 5 /* speed menu items */
XX#define XFMAX 2 /* transfer mode items */
XX#define SCRIPTMAX 2 /* script menu items */
XX#define UTILMAX 8 /* utility menu */
XX#define MAXMENU 5 /* total number of menu entries */
XX
XX#define FSF_REVERSE 256 /* fake font style to flag INVERSVID mode */
XX
XX/* things for script support */
XX
XX#define GOTOLABEL 1
XX#define NEXTCOMMAND 0
XX#define ONCOMMAND 2
XX
XX#define WAIT_TIMER 2
XX#define WAIT_STRING 1
XX
XXextern struct MsgPort *CreatePort();
XXextern char *malloc(),*strcpy(),*fgets();
XXextern long ftell();
XX
XX#ifdef MODULE_MAIN
XXchar bufr[BufSize];
XXint fd, timeout = FALSE, ttime;
XXint multi = FALSE, server;
XXlong bytes_xferred;
XXchar MyDir[60];
XXstruct IntuitionBase *IntuitionBase;
XXstruct GfxBase *GfxBase;
XX
XXstruct NewScreen NewScreen = {
XX 0L,197L,640L,205L,1L, /* left, top, width, height, depth */
XX 0,1,HIRES, /* DetailPen, BlockPen, ViewModes */
XX CUSTOMSCREEN,NULL, /* Type, Font */
XX (UBYTE *)"VT100 Terminal Screen", /* Title */
XX NULL,NULL }; /* Gadgets, Bitmap */
XX
XXstruct NewWindow NewWindow = {
XX 0,3L,640L,200L, /* left, top, width, height */
XX 0,1, /* detailpen, blockpen */
XX MENUPICK | CLOSEWINDOW | RAWKEY | NEWSIZE,
XX SMART_REFRESH | ACTIVATE | BORDERLESS |
XX WINDOWCLOSE | WINDOWDEPTH | WINDOWDRAG, /* Flags */
XX NULL,NULL, /* FirstGadget, CheckMark */
XX (UBYTE *)
XX "VT100 Terminal Window ",
XX NULL, /* set screen after open screen */
XX NULL, /* bitmap */
XX 640L, 200L, 640L, 200L,/* minw, minh, maxw, maxh */
XX CUSTOMSCREEN /* Type */
XX};
XX
XXstruct Screen *myscreen; /* ptr to applications screen */
XXstruct Window *mywindow; /* ptr to applications window */
XXstruct ViewPort *myviewport;
XXstruct IntuiMessage *NewMessage; /* msg structure for GetMsg() */
XXstruct Preferences *Prefs; /* preferences from GetPrefs() */
XX
XXstruct MenuItem FileItem[FILEMAX];
XXstruct IntuiText FileText[FILEMAX];
XXstruct MenuItem RSItem[RSMAX];
XXstruct IntuiText RSText[RSMAX];
XXstruct MenuItem XFItem[XFMAX];
XXstruct IntuiText XFText[XFMAX];
XXstruct MenuItem ScriptItem[SCRIPTMAX];
XXstruct IntuiText ScriptText[SCRIPTMAX];
XXstruct MenuItem UtilItem[UTILMAX];
XXstruct IntuiText UtilText[UTILMAX];
XXstruct Menu menu[MAXMENU];
XXstruct IOExtSer *Read_Request;
XXchar *rs_in;
XXstruct IOExtSer *Write_Request;
XXchar rs_out[2];
XXstruct timerequest Timer;
XXstruct MsgPort *Timer_Port = NULL;
XXstruct timerequest Script_Timer;
XXstruct MsgPort *Script_Timer_Port = NULL;
XXint want_message;
XXint x,y,curmode,keyapp;
XXint MINX = 0;
XXint MAXX = 632;
XXint MINY = 14;
XXint MAXY = 198;
XXint top = 14;
XXint bot = 198;
XXint savx = 0;
XXint savy = 14;
XXint savmode = 0;
XXint nlmode = 0;
XXint alt = 0;
XXint savalt = 0;
XXint a[2] = { 0, 0 };
XXint sa[2] = { 0, 0 };
XXint inesc = -1;
XXint inctrl = -1;
XXint private = 0;
XXint badseq = 0;
XXchar *blanks = " ";
XXint maxcol = 79;
XX
XX/*************************** defaults ***********************************/
XXint p_baud = 2400; /* baud rate */
XXint p_screen = 0; /* 0 = WORKBENCH, 1 = CUSTOM */
XXint p_interlace = 0; /* 0 = no interlace, 1 = interlace */
XXint p_depth = 2; /* number of bit planes (1 or 2) */
XXint p_foreground = 0x840; /* default foreground RGB color */
XXint p_background = 0x000; /* default background RGB color */
XXint p_bold = 0xa00; /* default BOLD RGB color */
XXint p_cursor = 0x00d; /* default Cursor RGB color */
XXint p_lines = 24; /* number of lines on the screen */
XXint p_mode = 0; /* 0 = image, 1 = CRLF (for kermit) */
XXint p_buffer = 512; /* read buffer size (>= 512 bytes) */
XXint p_parity = -1; /* -1 = none, 0 = even , 1 = odd */
XXint p_wordsize = 8; /* data bits per word */
XXlong p_break = 750000; /* break time (in micro seconds) */
XXchar *p_f[10] = { /* function key defaults */
XX "\033OP","\033OQ","\033OR","\033OS",
XX "f5","f6","f7","f8","f9","f10" };
XX
XXchar *p_F[10] = { /* shifted function key defaults */
XX "F1","F2","F3","F4","F5",
XX "F6","F7","F8","F9","F10"};
XX
XX/* for script file */
XXint script_on;
XXint script_wait;
XXvoid setserword(), setserpar(), setserbaud(), setparams(),
XX handle_menupick();
XX
XX#else /* not MODULE_MAIN */
XX
XXextern int multi; /* flags multi file transfers */
XXextern int server;
XXextern int want_message;
XXextern char bufr[BufSize];
XXextern int fd, timeout, ttime;
XXextern long bytes_xferred;
XXextern char MyDir[60];
XX
XXextern struct IntuitionBase *IntuitionBase;
XXextern struct GfxBase *GfxBase;
XX
XXextern struct NewScreen NewScreen;
XXextern struct NewWindow NewWindow;
XXextern struct Screen *myscreen;
XXextern struct Window *mywindow;
XXextern struct ViewPort *myviewport;
XXextern struct IntuiMessage *NewMessage;
XXextern struct Preferences *Prefs;
XXextern struct MenuItem FileItem[FILEMAX];
XXextern struct IntuiText FileText[FILEMAX];
XXextern struct MenuItem RSItem[RSMAX];
XXextern struct IntuiText RSText[RSMAX];
XXextern struct MenuItem XFItem[XFMAX];
XXextern struct IntuiText XFText[XFMAX];
XXextern struct MenuItem ScriptItem[SCRIPTMAX];
XXextern struct IntuiText ScriptText[SCRIPTMAX];
XXextern struct MenuItem UtilItem[UTILMAX];
XXextern struct IntuiText UtilText[UTILMAX];
XXextern struct Menu menu[MAXMENU];
XXextern struct timerequest Timer, Script_Timer;
XXextern struct MsgPort *Timer_Port, *Script_Timer_Port;
XXextern struct IOExtSer *Read_Request;
XXextern char *rs_in;
XXextern struct IOExtSer *Write_Request;
XXextern char rs_out[2];
XXextern int x,y,curmode,keyapp;
XXextern int MINX,MAXX,MINY,MAXY,top,bot,savx,savy;
XXextern int savmode,nlmode,alt,savalt,a[2],sa[2];
XXextern int inesc,inctrl,private,badseq,maxcol;
XXextern char *blanks;
XXextern int p_baud,p_screen,p_interlace,p_depth,p_buffer;
XXextern int p_foreground,p_background,p_bold,p_cursor,p_lines,p_mode;
XXextern int p_wordsize,p_parity;
XXextern long p_break;
XXextern char *p_f[10],*p_F[10];
XXextern int script_on;
XXextern int script_wait;
XX
XXextern int do_send(),do_capture(),cleanup();
XXextern void setserword(), setserpar(), setserbaud(), setparams(),
XX handle_menupick();
XX
XX#endif /* not MODULE_MAIN */
XX
XX#ifndef MODULE_INIT
XXextern void InitDefaults(),InitDevs(),InitFileItems(),InitRSItems(),
XX InitXFItems(),InitScriptItems(),InitUtilItems(),InitMenu();
XX#endif
XX
XX#ifndef MODULE_WINDOW
XXextern void filename(),emits(),emit(),emitbatch(),cursoroff(),cursoron();
XXextern int toasc();
XX#endif
XX
XX#ifndef MODULE_XMODEM
XXextern void sendchar(),sendstring(),sendbreak();
XXextern int readchar(),XMODEM_Read_File(),XMODEM_Send_File();
XX#endif
XX
XX#ifndef MODULE_REMOTE
XXextern void doremote(),doindex();
XX#endif
XX
XX#ifndef MODULE_KERMIT
XXextern int doksend(),dokreceive(), multi_xfer(), saybye();
XX#endif
XX
XX#ifndef MODULE_SCRIPT
XXextern int script_start(), chk_script(), exit_script(), do_script_cmd();
XX#endif
XX
XX#ifndef MODULE_EXPAND
XXextern char **expand();
XXextern int set_dir(), free_expand();
XX#endif
XX
SHAR_EOF
if test 9148 -ne "`wc -c vt100.h`"
then
echo shar: error transmitting vt100.h '(should have been 9148 characters)'
fi
echo shar: extracting vt100.c
sed 's/^XX//' << \SHAR_EOF > vt100.c
XX/************************************************************************
XX * vt100 terminal emulator with xmodem transfer capability
XX *
XX * v2.1 860915 DBW - new features (see README)
XX * 860901 ACS - Added Parity and Word Length and support code
XX * 860823 DBW - Integrated and rewrote lots of code
XX * v2.0 860809 DBW - Major rewrite
XX * v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
XX * v1.0 860712 DBW - First version released
XX *
XX * use <esc> to abort xmodem or kermit transfers
XX *
XX * written by Michael Mounier
XX * new version by Dave Wecker
XX ************************************************************************/
XX
XX/* all includes defines and globals */
XX#define MODULE_MAIN 1
XX#include "vt100.h"
XX
XX/******************************************************/
XX/* Main Program */
XX/* */
XX/* This is the main body of the program. */
XX/******************************************************/
XX
XXchar lookahead[80];
XXFILE *tranr = NULL;
XXFILE *trans = NULL;
XXint capture,send;
XXchar name[80];
XXstruct MsgPort *mySerPort;
XX
XXmain(argc,argv)
XXint argc;
XXchar **argv;
XX {
XX ULONG class;
XX unsigned int code,menunum,itemnum;
XX int KeepGoing,i,j,la,dola,actual;
XX char c;
XX
XX InitDefaults(argc,argv);
XX InitDevs();
XX InitFileItems();
XX InitRSItems();
XX InitXFItems();
XX InitScriptItems();
XX InitUtilItems();
XX InitMenu();
XX SetMenuStrip(mywindow,&menu[0]);
XX
XX MyDir[0] = '\000';
XX KeepGoing = TRUE;
XX capture = FALSE;
XX send = FALSE;
XX maxcol = MAXX / 8;
XX la = 0;
XX x = MINX ;
XX y = MINY;
XX curmode = FS_NORMAL;
XX keyapp = 0;
XX script_on = FALSE;
XX script_wait= TRUE;
XX SetAPen(mywindow->RPort,1L);
XX cursoron();
XX cursoroff();
XX emit(12);
XX mySerPort = Read_Request->IOSer.io_Message.mn_ReplyPort;
XX SendIO(Read_Request);
XX
XX while( KeepGoing )
XX {
XX /* wait for window message or serial port message */
XX cursoron();
XX if (script_wait) /* if script ready dont wait here */
XX Wait(
XX (1L << mySerPort->mp_SigBit) |
XX (1L << mywindow->UserPort->mp_SigBit) |
XX (1L << Script_Timer_Port->mp_SigBit));
XX cursoroff();
XX
XX /* do ascii file send */
XX if (send)
XX {
XX if ((c=getc(trans)) != EOF) {
XX if (c == '\n') c = '\r';
XX sendchar(c);
XX }
XX else {
XX fclose(trans);
XX emits("\nFile Sent\n");
XX send=FALSE;
XX }
XX }
XX
XX /* see if there are any characters from the host */
XX if (CheckIO(Read_Request)) {
XX WaitIO(Read_Request);
XX c = rs_in[0] & 0x7F;
XX doremote(c);
XX if (script_on) chk_script(c);
XX if (capture && c != 10) {
XX if (c == 13) c = 10;
XX putc(c , tranr);
XX }
XX Read_Request->IOSer.io_Command = SDCMD_QUERY;
XX DoIO(Read_Request);
XX Read_Request->IOSer.io_Command = CMD_READ;
XX actual = (int)Read_Request->IOSer.io_Actual;
XX if (actual > 0) {
XX if (inesc < 0 &&
XX inctrl < 0 &&
XX a[alt] == 0 &&
XX capture == FALSE) dola = 1;
XX else dola = 0;
XX Read_Request->IOSer.io_Length =
XX Read_Request->IOSer.io_Actual;
XX DoIO(Read_Request);
XX Read_Request->IOSer.io_Length = 1;
XX
XX for (i = 0; i < actual; i++) {
XX c=rs_in[i] & 0x7f;
XX if (script_on) chk_script(c);
XX
XX if (dola == 1) {
XX if (c >= ' ' && c <= '~' && la < 80)
XX lookahead[la++] = c;
XX else {
XX if (la > 0) {
XX emitbatch(la,lookahead);
XX la = 0;
XX }
XX doremote(c);
XX dola = 0;
XX }
XX }
XX else {
XX doremote(c);
XX if (inesc < 0 &&
XX inctrl < 0 &&
XX a[alt] == 0 &&
XX capture == FALSE) dola = 1;
XX if (capture && c != 10) {
XX if (c == 13) c = 10;
XX putc(c , tranr);
XX }
XX }
XX }
XX
XX /* dump anything left in the lookahead buffer */
XX if (la > 0) {
XX emitbatch(la,lookahead);
XX la = 0;
XX }
XX }
XX SendIO(Read_Request);
XX }
XX
XX while((NewMessage =
XX (struct IntuiMessage *)GetMsg(mywindow->UserPort))
XX != FALSE) {
XX class = NewMessage->Class;
XX code = NewMessage->Code;
XX ReplyMsg( NewMessage );
XX switch( class )
XX {
XX case CLOSEWINDOW:
XX KeepGoing = FALSE;
XX break;
XX
XX case RAWKEY:
XX c = toasc(code,0);
XX break;
XX
XX case NEWSIZE:
XX emit(12);
XX break;
XX
XX case MENUPICK:
XX handle_menupick(class,code);
XX break;
XX } /* end of switch (class) */
XX } /* end of while ( newmessage )*/
XX
XX if (!script_wait ||
XX (CheckIO(&Script_Timer) && script_wait == WAIT_TIMER))
XX do_script_cmd(NEXTCOMMAND);
XX } /* end while ( keepgoing ) */
XX
XX /* It must be time to quit, so we have to clean
XX * up and exit.
XX */
XX
XX cleanup("",0);
XX
XX } /* end of main */
XX
XX/* cleanup code */
XX
XXcleanup(reason, fault)
XXchar *reason;
XXint fault;
XX {
XX switch(fault) {
XX case 0: /* quitting close everything */
XX ClearMenuStrip( mywindow );
XX CloseDevice(&Timer);
XX
XX case 7: /* error opening timer */
XX DeletePort(Timer_Port);
XX CloseDevice(&Script_Timer);
XX DeletePort(Script_Timer_Port);
XX
XX case 6: /* error opening write device */
XX DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
XX FreeMem(Write_Request,(long)sizeof(*Write_Request));
XX CloseDevice(Read_Request);
XX
XX case 5: /* error opening read device */
XX DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
XX FreeMem(Read_Request,(long)sizeof(*Read_Request));
XX CloseWindow( mywindow );
XX
XX case 4: /* error opening window */
XX if (p_screen != 0) CloseScreen( myscreen );
XX
XX case 3: /* error opening screen */
XX case 2: /* error opening graphics library */
XX case 1: /* error opening intuition */
XX default:
XX if (*reason) puts (reason);
XX }
XX exit(fault);
XX }
XX
XXdo_capture(file)
XXchar *file;
XX {
XX if (capture == TRUE)
XX {
XX capture=FALSE;
XX fclose(tranr);
XX emits("\nEnd File Capture\n");
XX }
XX else
XX {
XX if (file == NULL) {
XX emits("\nAscii Capture:");
XX filename(name);
XX }
XX else strcpy(name, file);
XX if ((tranr=fopen(name,"w")) == 0) {
XX capture=FALSE;
XX emits("\nError Opening File\n");
XX return(FALSE);
XX }
XX capture=TRUE;
XX }
XX }
XX
XXdo_send(file)
XXchar *file;
XX {
XX if (send == TRUE)
XX {
XX send=FALSE;
XX fclose(trans);
XX emits("\nFile Send Cancelled\n");
XX }
XX else
XX {
XX if (file == NULL) {
XX emits("\nAscii Send:");
XX filename(name);
XX }
XX else strcpy(name, file);
XX if ((trans=fopen(name,"r")) == 0) {
XX send=FALSE;
XX emits("\nError Opening File\n");
XX return(FALSE);
XX }
XX send=TRUE;
XX }
XX }
XX
XXvoid setserword(size, redomenu)
XXint size;
XXLONG redomenu;
XX {
XX AbortIO(Read_Request);
XX Read_Request->io_ReadLen = Read_Request->io_WriteLen =
XX Write_Request->io_ReadLen = Write_Request->io_WriteLen = size;
XX setparams();
XX p_wordsize = size;
XX
XX if(!redomenu)
XX return;
XX
XX ClearMenuStrip( mywindow ); /* Remove old menu */
XX InitUtilItems(); /* Re-do the Word Length items */
XX SetMenuStrip(mywindow,&menu[0]); /* Re-display the menu */
XX }
XX
XXvoid setserpar(par, redomenu)
XXint par;
XXLONG redomenu;
XX {
XX AbortIO(Read_Request);
XX if(par < 0) /* No parity */
XX Read_Request->io_SerFlags &= ~(SERF_PARTY_ON | SERF_PARTY_ODD);
XX else if(par == 0) { /* Even parity */
XX Read_Request->io_SerFlags |= SERF_PARTY_ON;
XX Read_Request->io_SerFlags &= ~SERF_PARTY_ODD;
XX }
XX else /* Odd parity */
XX Read_Request->io_SerFlags |= SERF_PARTY_ON | SERF_PARTY_ODD;
XX Write_Request->io_SerFlags = Read_Request->io_SerFlags;
XX setparams();
XX p_parity = (par > 0 ? 1 : (par == 0 ? 0 : -1));
XX
XX if(!redomenu)
XX return;
XX
XX ClearMenuStrip( mywindow ); /* Remove old menu */
XX InitUtilItems(); /* Re-do the Parity items */
XX SetMenuStrip(mywindow,&menu[0]); /* Re-display the menu */
XX }
XX
XXvoid setserbaud(baud, redomenu)
XXint baud;
XXLONG redomenu;
XX {
XX AbortIO(Read_Request);
XX Write_Request->io_Baud = Read_Request->io_Baud = baud;
XX setparams();
XX p_baud = baud;
XX
XX if(!redomenu)
XX return;
XX
XX ClearMenuStrip( mywindow ); /* Remove old menu */
XX InitRSItems(); /* Re-do the Baud rate items */
XX SetMenuStrip(mywindow,&menu[0]); /* Re-display the menu */
XX }
XX
XXvoid setparams()
XX {
XX Read_Request->IOSer.io_Command =
XX Write_Request->IOSer.io_Command =
XX SDCMD_SETPARAMS;
XX DoIO(Read_Request); DoIO(Write_Request);
XX Read_Request->IOSer.io_Command = CMD_READ;
XX SendIO(Read_Request);
XX Write_Request->IOSer.io_Command = CMD_WRITE;
XX }
XX
XXvoid handle_menupick(class, code)
XXULONG class;
XXunsigned int code;
XX {
XX unsigned int menunum, itemnum;
XX
XX if (code == MENUNULL) return;
XX
XX menunum = MENUNUM( code );
XX itemnum = ITEMNUM( code );
XX switch( menunum ) {
XX case 0:
XX switch( itemnum ) {
XX case 0:
XX do_capture(NULL);
XX break;
XX
XX case 1:
XX do_send(NULL);
XX break;
XX
XX case 2:
XX if (p_parity >= 0 || p_wordsize != 8) {
XX emits("\nParity/word length settings prevent this\n");
XX break;
XX }
XX emits("\nXmodem Receive:");
XX filename(name);
XX multi_xfer(name,XMODEM_Read_File,0);
XX break;
XX
XX case 3:
XX if (p_parity >= 0 || p_wordsize != 8) {
XX emits("\nParity/word length settings prevent this\n");
XX break;
XX }
XX emits("\nXmodem Send:");
XX filename(name);
XX multi_xfer(name,XMODEM_Send_File,1);
XX break;
XX
XX case 4:
XX server = TRUE;
XX emits("\nKermit GET remote file(s):");
XX filename(name);
XX multi_xfer(name,dokreceive,0);
XX break;
XX
XX case 5:
XX multi_xfer("",dokreceive,0);
XX break;
XX
XX case 6:
XX server = TRUE;
XX emits("\nKermit Send local name:");
XX filename(name);
XX multi_xfer(name,doksend,1);
XX break;
XX
XX case 7:
XX saybye();
XX break;
XX }
XX break;
XX
XX case 1:
XX switch( itemnum ) {
XX case 0:
XX setserbaud(300, FALSE);
XX break;
XX
XX case 1:
XX setserbaud(1200, FALSE);
XX break;
XX
XX case 2:
XX setserbaud(2400, FALSE);
XX break;
XX
XX case 3:
XX setserbaud(4800, FALSE);
XX break;
XX
XX case 4:
XX setserbaud(9600, FALSE);
XX break;
XX }
XX break;
XX
XX case 2:
XX p_mode = itemnum;
XX break;
XX
XX case 3:
XX if (!itemnum && !script_on) {
XX emits("Script file name: ");
XX filename(name);
XX script_start(name);
XX }
XX if (itemnum && script_on) exit_script();
XX break;
XX
XX case 4:
XX switch( itemnum ) {
XX case 0:
XX sendbreak();
XX break;
XX
XX case 1:
XX /* add hangup code here */
XX break;
XX
XX case 2:
XX emits("\nDirectory [");
XX emits(MyDir);
XX emits("]: ");
XX filename(name);
XX set_dir(name);
XX break;
XX
XX case 3: /* No Parity */
XX setserpar(-1, FALSE);
XX break;
XX
XX case 4: /* Even parity */
XX setserpar(0, FALSE);
XX break;
XX
XX case 5: /* Odd parity */
XX setserpar(1, FALSE);
XX break;
XX
XX case 6: /* 8 bit words */
XX if (p_parity >= 0) /* Even (0) or odd (1) parity? */
XX setserpar(-1, TRUE); /* Yup - Set no parity */
XX setserword(8, FALSE); /* Set requested word length */
XX break;
XX
XX case 7: /* 7 bit words */
XX setserword(7, FALSE); /* Always OK to set 7 bit words */
XX break;
XX }
XX break;
XX } /* end of switch ( menunum ) */
XX
XX if (p_parity >= 0 && p_wordsize != 7)
XX setserword(7, TRUE); /* Set 7-bit words if we have parity. */
XX }
SHAR_EOF
if test 11336 -ne "`wc -c vt100.c`"
then
echo shar: error transmitting vt100.c '(should have been 11336 characters)'
fi
echo shar: extracting kermit.c
sed 's/^XX//' << \SHAR_EOF > kermit.c
XX/*************************************************************
XX * vt100 terminal emulator - KERMIT protocol support
XX * v2.1 860915 DBW - new features (see README)
XX * 860901 ACS - Added eight bit quoting
XX * 860830 Steve Drew Wild card support, error recovery, bugs.
XX * 860823 DBW - Integrated and rewrote lots of code
XX * 860811 Steve Drew multi filexfer, bugs, status line ect..
XX * v2.0 860809 DBW - Major rewrite
XX * v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
XX * v1.0 860712 DBW - First version released
XX *
XX *************************************************************/
XX
XX#define MODULE_KERMIT 1
XX#include "vt100.h"
XX
XX#define CONVERTNAME TRUE /* convert file name to lower case for receive */
XX#define MAXPACKSIZ 94 /* Maximum msgpkt size */
XX#define CR 13 /* ASCII Carriage Return */
XX#define LF 10 /* ASCII line feed */
XX#define SP 32 /* ASCII space */
XX#define DEL 127 /* Delete (rubout) */
XX
XX#define MAXTRY 5 /* Times to retry a msgpkt */
XX#define MYQUOTE '#' /* Quote character I will use */
XX#define MYRPTQ '~' /* Repeat quote character */
XX#define MYEBQ '&' /* 8th bit prefix character */
XX#define MYPAD 0 /* Number of padding characters I will need */
XX#define MYPCHAR 0 /* Padding character I need (NULL) */
XX#define MYEOL '\n' /* End-Of-Line character I need */
XX
XX#define tochar(ch) ((ch) + ' ')
XX#define unchar(ch) ((ch) - ' ')
XX#define ctl(ch) ((ch) ^ 64 )
XX
XX/* Global Variables */
XX
XXint
XX size, /* Size of present data */
XX osize, /* Size of last data entry */
XX rpsiz, /* Maximum receive msgpkt size */
XX spsiz, /* Maximum send msgpkt size */
XX timint, /* Time interval to wait */
XX pad, /* How much padding to send */
XX n, /* Packet number */
XX tp, /* total packets */
XX numtry, /* Times this msgpkt retried */
XX retry, /* total retries */
XX oldtry, /* Times previous msgpkt retried */
XX sendabort, /* flag for aborting send file */
XX rptflg, /* are we doing repeat quoting */
XX ebqflg, /* are we doing 8th bit quoting */
XX notfirst, /* is this the first file received */
XX first, /* is this the first time in a file */
XX rpt, /* current repeat count */
XX next, /* what is the next character */
XX t; /* current character */
XXlong
XX totbytes; /* total bytes xfered on this file */
XX
XXchar
XX state, /* Present state of the automaton */
XX padchar, /* Padding character to send */
XX eol, /* End-Of-Line character to send */
XX quote, /* Quote character in incoming data */
XX rptq, /* Quote character for repeats */
XX ebq, /* Quote character for 8th bit quoting */
XX ackpkt[MAXPACKSIZ+20], /* ACK/NAK packet buffer */
XX msgpkt[MAXPACKSIZ+20], /* Message Packet buffer */
XX filnam[40]; /* remote file name */
XX snum[10];
XX
XXvoid encode(), decode(), rpar(), spar();
XX
XXFILE *fp; /* file for send/receive */
XX
XXchar *
XXgetfname(name) /* returns pointer to start of file name from file spec */
XXchar *name;
XX {
XX int l;
XX
XX l = strlen(name);
XX while(l && name[l] != '/' && name[l] != ':') l--;
XX if (name[l] == '/' || name[l] == ':') l++;
XX return(name += l);
XX }
XX
XXdoksend(file,more)
XXchar *file;
XXint more;
XX {
XX int amount, c, wild;
XX char *p, **list = NULL;
XX
XX if (!strcmp(file,"$")) { saybye(); return(2); }
XX want_message = FALSE; /* tell readchar no error msgs */
XX p = file;
XX while(*p && *p != '*' && *p != '?') p++;
XX if (*p) {
XX wild = TRUE;
XX list = expand(file, &amount);
XX if (list == NULL) emits("No wild card match\n");
XX }
XX else {
XX wild = FALSE;
XX amount = 1;
XX }
XX for (c = 0; c < amount; c++) {
XX if (wild == TRUE) p = list[c];
XX else p = file;
XX strcpy(filnam,getfname(p));
XX ttime = TTIME_KERMIT;
XX tp = retry = n = numtry = 0; totbytes = 0L;
XX statusline();
XX if ((fp = fopen(p,"r")) == NULL) {
XX emits("ERROR");
XX emits("\nVT100 - Kermit - Cannot open send file: ");
XX emits(p);
XX curmode = FS_NORMAL;
XX continue;
XX }
XX emits("SEND");
XX ClearBuffer();
XX if (sendsw()) { x = 600; emits("DONE"); }
XX fclose(fp);
XX curmode = FS_NORMAL;
XX }
XX free_expand(list);
XX return TRUE;
XX }
XX
XXdokreceive(file,more)
XXchar *file;
XXint more;
XX {
XX int retval;
XX
XX ttime = TTIME_KERMIT;
XX if (!strcmp(file,"$")) { saybye(); return(2); }
XX strcpy(filnam, file);
XX statusline();
XX if (server) emits("GET ");
XX else emits("RECV");
XX tp = retry = n = numtry = notfirst = 0; totbytes = 0L;
XX want_message = FALSE; /* tell readchar no error msgs status bar instead */
XX ClearBuffer();
XX retval = recsw();
XX curmode = FS_NORMAL;
XX return(retval);
XX }
XX
XXsendsw()
XX {
XX char sinit(), sfile(), sdata(), seof(), sbreak();
XX sendabort = 0;
XX state = 'S';
XX while(TRUE) {
XX switch(state) {
XX case 'S': state = sinit(); break;
XX case 'F': state = sfile(); break;
XX case 'D': state = sdata(); break;
XX case 'Z': state = seof(); break;
XX case 'B': state = sbreak(); break;
XX case 'C': if (sendabort) return FALSE;
XX else return TRUE;
XX case 'E': x = 600; /* host sent us error packet */
XX emits("ERROR"); /* so print the error and abort */
XX print_host_err(ackpkt);
XX return(FALSE);
XX case 'A': x = 600;
XX if (timeout == USERABORT) {
XX timeout = GOODREAD;
XX n = (n+1)%64;
XX sendabort = 1;
XX emits("ABORT");
XX strcpy(msgpkt, "D");
XX state = 'Z';
XX break;
XX }
XX if (timeout == TIMEOUT) emits("TMOUT");
XX else { /* protocol error dectected by us */
XX emits("ERROR");
XX print_our_err();
XX }
XX return(FALSE);
XX default: return(FALSE);
XX }
XX }
XX }
XX
XXchar sinit()
XX {
XX int num, len;
XX
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX spar(msgpkt);
XX
XX spack('S',n,9,msgpkt);
XX switch(rpack(&len,&num,ackpkt)) {
XX case 'N': return(state);
XX case 'Y': if (n != num) return(state);
XX rpar(ackpkt);
XX if (eol == 0) eol = '\n';
XX if (quote == 0) quote = MYQUOTE;
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('F');
XX case 'E': return('E');
XX case FALSE:if (timeout == USERABORT) state = 'A';
XX return(state);
XX default: return('A');
XX }
XX }
XX
XXchar sfile()
XX {
XX int num, len;
XX
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX spack('F',n,strlen(filnam),filnam);
XX switch(rpack(&len,&num,ackpkt)) {
XX case 'N':
XX num = (--num<0 ? 63:num);
XX if (n != num) return(state);
XX case 'Y':
XX if (n != num) return(state);
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX first = 1;
XX size = getpkt();
XX return('D');
XX case 'E':
XX return('E');
XX case FALSE: if (timeout == USERABORT) state = 'A';
XX return(state);
XX default:
XX return('A');
XX }
XX }
XX
XXchar sdata()
XX {
XX int num, len;
XX
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX spack('D',n,size,msgpkt);
XX switch(rpack(&len,&num,ackpkt)) {
XX case 'N':
XX num = (--num<0 ? 63:num);
XX if (n != num) return(state);
XX case 'Y':
XX if (n != num) return(state);
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX if ((size = getpkt()) == 0) return('Z');
XX return('D');
XX case 'E':
XX return('E');
XX case FALSE: if (timeout == USERABORT) state = 'A';
XX return(state);
XX default:
XX return('A');
XX }
XX }
XX
XXchar seof()
XX {
XX int num, len;
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX/* if (timeout == USERABORT) { /* tell host to discard file */
XX/* timeout = GOODREAD;
XX spack('Z',n,1,"D");
XX }
XX else */ spack('Z',n,sendabort,msgpkt);
XX switch(rpack(&len,&num,ackpkt)) {
XX case 'N':
XX num = (--num<0 ? 63:num);
XX if (n != num) return(state);
XX case 'Y':
XX if (n != num) return(state);
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('B');
XX case 'E':
XX return('E');
XX case FALSE: return(state);
XX default:
XX return('A');
XX }
XX }
XX
XXchar sbreak()
XX {
XX int num, len;
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX spack('B',n,0,msgpkt);
XX switch (rpack(&len,&num,ackpkt)) {
XX case 'N':
XX num = (--num<0 ? 63:num);
XX if (n != num) return(state);
XX case 'Y':
XX if (n != num) return(state);
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('C');
XX case 'E':
XX return('E');
XX case FALSE: return(state);
XX default: return ('A');
XX }
XX }
XX
XX/* timeout equals USERABORT so lets end the file and quit */
XX/* when host receives 'Z' packet with "D" in data field he */
XX/* should discard the file. */
XX/*
XXsabort()
XX {
XX emits("ABORT");
XX n = (n+1)%64;
XX retry--;
XX state = 'Z';
XX while (state == 'Z') state = seof();
XX while (state == 'B') state = sbreak();
XX return(FALSE);
XX }
XX*/
XX
XX
XXrecsw()
XX {
XX char rinit(), rfile(), rdata();
XX
XX state = 'R';
XX
XX while(TRUE) {
XX switch(state) {
XX case 'R': state = rinit(); break;
XX case 'Z':
XX case 'F': state = rfile(); break;
XX case 'D': state = rdata(); break;
XX case 'C': return(TRUE);
XX case 'E':
XX case 'A': x = 600;
XX if (timeout == USERABORT){/* easy way to cleanly abort
XX should really send and ACK
XX with "X" in data field and
XX wait for host to abort but
XX not all kermits support
XX this feature. */
XX emits("ABORT"); /* send an error packet back */
XX spack('E',n,12,"User aborted");
XX }
XX else if (timeout == TIMEOUT) { /* we timed out waiting */
XX /* will we need to spack here ?*/
XX emits("TMOUT");
XX }
XX else emits("ERROR"); /* must be 'E' from host or we
XX detected a protocol error */
XX
XX if (state == 'E') print_host_err(msgpkt);
XX
XX else if (timeout == GOODREAD) /* tell host why */
XX print_our_err();
XX /* will this kill all files ?*/
XX do {
XX ttime = 2;
XX readchar();
XX } while (timeout == GOODREAD);
XX fclose(fp);
XX sendstring("\r");
XX return(FALSE);
XX default: return(FALSE);
XX }
XX }
XX }
XX
XX
XX
XXchar rinit()
XX {
XX int len, num;
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX if (server) spack('R',n,strlen(filnam),filnam);
XX else spack('N',n,0,0);
XX switch(rpack(&len,&num,msgpkt)) {
XX case 'S':
XX rpar(msgpkt);
XX spar(msgpkt);
XX spack('Y',n,9,msgpkt);
XX oldtry = numtry;
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('F');
XX case 'E':
XX return('E');
XX case FALSE:
XX if (timeout == USERABORT) return('A');
XX spack('N',n,0,0);
XX return(state);
XX default:
XX return('A');
XX }
XX }
XX
XXchar rfile()
XX {
XX int num, len;
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX switch(rpack(&len,&num,msgpkt)) {
XX case 'S':
XX if (oldtry++ > MAXTRY) return('A');
XX if (num == ((n==0) ? 63:n-1)) {
XX spar(msgpkt);
XX spack('Y',num,9,msgpkt);
XX numtry = 0;
XX return(state);
XX }
XX else return('A');
XX case 'Z':
XX if (oldtry++ > MAXTRY) return('A');
XX if (num == ((n==0) ? 63:n-1)) {
XX spack('Y',num,0,0);
XX numtry = 0;
XX return(state);
XX }
XX else return('A');
XX case 'F':
XX if (num != n) return('A');
XX strcpy(filnam,msgpkt);
XX if (CONVERTNAME) {
XX char *p;
XX p = &filnam[0];
XX while (*p) { *p = tolower(*p); p++; }
XX }
XX if (notfirst) {
XX curmode = FS_NORMAL;
XX totbytes = 0L;
XX statusline();
XX emits("RECV");
XX }
XX else { /* is the first file so emit actual file name from host */
XX x = 48; emits(" ");
XX x = 48; emits(filnam);
XX notfirst++;
XX }
XX if ((fp = fopen(filnam,"w")) == NULL) {
XX strcpy(msgpkt,"VT100 - Kermit - Unable to create file: ");
XX strcat(msgpkt,filnam);
XX spack('E',n,strlen(msgpkt),msgpkt); /* let host know */
XX x = 600; emits("ERROR");
XX emits("\n");
XX emits(msgpkt); /* let user know */
XX return ('\0'); /* abort everything */
XX }
XX spack('Y',n,0,0);
XX oldtry = numtry;
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('D');
XX case 'B': /* totaly done server sending no more */
XX if (num != n) return ('A');
XX spack('Y',n,0,0);
XX retry--;
XX return('C');
XX case 'E':
XX return('E');
XX case FALSE:
XX if (timeout == USERABORT) return('A');
XX spack('N',n,0,0);
XX return(state);
XX default:
XX return ('A');
XX }
XX }
XX
XXchar rdata()
XX {
XX int num, len;
XX retry++;
XX if (numtry++ > MAXTRY) return('A');
XX
XX switch(rpack(&len,&num,msgpkt)) {
XX case 'D':
XX if (num != n) {
XX if (oldtry++ > MAXTRY) return('A');
XX if (num == ((n==0) ? 63:n-1)) {
XX spack('Y',num,6,msgpkt);
XX numtry = 0;
XX return(state);
XX }
XX else return('A');
XX }
XX decode();
XX spack('Y',n,0,0);
XX oldtry = numtry;
XX numtry = 0;
XX retry--;
XX n = (n+1)%64;
XX return('D');
XX case 'Z':
XX if (num != n) return('A');
XX spack('Y',n,0,0);
XX n = (n+1)%64;
XX retry--;
XX x = 600;
XX emits("DONE");
XX fclose(fp);
XX return('Z');
XX case 'F':
XX if (oldtry++ > MAXTRY) return('A');
XX if (num == ((n==0) ? 63:n-1)) {
XX spack('Y',num,0,0);
XX numtry = 0;
XX return(state);
XX }
XX case 'E':
XX return('E');
XX case FALSE:
XX if (timeout == USERABORT) return('A');
XX spack('N',n,0,0);
XX return(state);
XX default:
XX return('A');
XX }
XX }
XX
XX
XXspack(type,num,len,data)
XXchar type, *data;
XXint num, len;
XX {
XX int i;
XX char chksum, buffer[100];
XX register char *bufp;
XX
XX dostats(type);
XX bufp = buffer;
XX ClearBuffer();
XX for (i=1; i<=pad; i++) sendchar(padchar);
XX
XX *bufp++ = SOH;
XX *bufp++ = tochar(len+3);
XX chksum = tochar(len+3);
XX *bufp++ = tochar(num);
XX chksum += tochar(num);
XX *bufp++ = type;
XX chksum += type;
XX
XX for (i=0; i<len; i++) {
XX *bufp++ = data[i];
XX chksum += data[i];
XX }
XX chksum = (((chksum&0300) >> 6)+chksum)&077;
XX *bufp++ = tochar(chksum);
XX *bufp++ = '\r';
XX *bufp++ = '\n';
XX *bufp = 0;
XX sendstring(buffer);
XX }
XX
XXrpack(len,num,data)
XXint *len, *num;
XXchar *data;
XX {
XX int i, done;
XX char type, cchksum, rchksum;
XX char t = '\0';
XX
XX do {
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX } while (t != SOH);
XX
XX done = FALSE;
XX while (!done) {
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX if (t == SOH) continue;
XX cchksum = t;
XX *len = unchar(t)-3;
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX if (t == SOH) continue;
XX cchksum = cchksum + t;
XX *num = unchar(t);
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX if (t == SOH) continue;
XX cchksum = cchksum + t;
XX type = t;
XX for (i=0; i<*len; i++) {
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX if (t == SOH) continue;
XX cchksum = cchksum + t;
XX data[i] = t;
XX }
XX data[*len] = 0;
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX rchksum = unchar(t);
XX t = readchar();
XX if (timeout != GOODREAD) return(FALSE);
XX if (t == SOH) continue;
XX done = TRUE;
XX }
XX dostats(type);
XX cchksum = (((cchksum&0300) >> 6)+cchksum)&077;
XX if (cchksum != rchksum) return(FALSE);
XX return((int)type);
XX }
XX
XXgetpkt() {
XX int i,eof;
XX
XX static char leftover[10] = { '\0', '\0', '\0', '\0', '\0',
XX '\0', '\0', '\0', '\0', '\0' };
XX
XX if (first == 1) {
XX first = 0;
XX *leftover = '\0';
XX t = getc(fp);
XX if (t == EOF) {
XX first = 1;
XX return(size = 0);
XX }
XX totbytes++;
XX }
XX else if (first == -1) {
XX first = 1;
XX return(size = 0);
XX }
XX for (size = 0; (msgpkt[size] = leftover[size]) != '\0'; size++) ;
XX *leftover = '\0';
XX rpt = 0;
XX eof = 0;
XX while (!eof) {
XX next = getc(fp);
XX if (next == EOF) {
XX first = -1;
XX eof = 1;
XX }
XX else totbytes++;
XX osize = size;
XX encode(t);
XX t = next;
XX if (size == spsiz-3) return(size);
XX if (size > spsiz-3) {
XX for (i = 0; (leftover[i] = msgpkt[osize+i]) != '\0'; i++) ;
XX size = osize;
XX msgpkt[size] = '\0';
XX return(size);
XX }
XX }
XX return(size);
XX }
XX
XXvoid encode(a)
XXchar a;
XX {
XX int a7,b8;
XX
XX if (p_mode == 1 && a == '\n') {
XX rpt = 0;
XX msgpkt[size++] = quote;
XX msgpkt[size++] = ctl('\r');
XX if (size <= spsiz-3) osize = size;
XX msgpkt[size++] = quote;
XX msgpkt[size++] = ctl('\n');
XX msgpkt[size] = '\0';
XX return;
XX }
XX if (rptflg) {
XX if (a == next && (first == 0)) {
XX if (++rpt < 94) return;
XX else if (rpt == 94) {
XX msgpkt[size++] = rptq;
XX msgpkt[size++] = tochar(rpt);
XX rpt = 0;
XX }
XX }
XX else if (rpt == 1) {
XX rpt = 0;
XX encode(a);
XX if (size <= spsiz-3) osize = size;
XX rpt = 0;
XX encode(a);
XX return;
XX }
XX else if (rpt > 1) {
XX msgpkt[size++] = rptq;
XX msgpkt[size++] = tochar(++rpt);
XX rpt = 0;
XX }
XX }
XX a7 = a & 0177;
XX b8 = a & 0200;
XX
XX if (ebqflg && b8) { /* Do 8th bit prefix if necessary. */
XX msgpkt[size++] = ebq;
XX a = a7;
XX }
XX
XX if ((a7 < SP) || (a7==DEL)) {
XX msgpkt[size++] = quote;
XX a = ctl(a);
XX }
XX if (a7 == quote) msgpkt[size++] = quote;
XX if ((rptflg) && (a7 == rptq)) msgpkt[size++] = quote;
XX
XX if ((ebqflg) && (a7 == ebq)) /* Prefix the 8th bit prefix */
XX msgpkt[size++] = quote; /* if doing 8th-bit prefixes */
XX
XX msgpkt[size++] = a;
XX msgpkt[size] = '\0';
XX }
XX
XXvoid decode()
XX {
XX USHORT a, a7, b8;
XX char *buf;
XX
XX buf = msgpkt;
XX rpt = 0;
XX
XX while ((a = *buf++) != '\0') {
XX if (rptflg) {
XX if (a == rptq) {
XX rpt = unchar(*buf++);
XX a = *buf++;
XX }
XX }
XX b8 = 0;
XX if (ebqflg) { /* 8th-bit prefixing? */
XX if (a == ebq) { /* Yes, got an 8th-bit prefix? */
XX b8 = 0200; /* Yes, remember this, */
XX a = *buf++; /* and get the prefixed character. */
XX }
XX }
XX if (a == quote) {
XX a = *buf++;
XX a7 = a & 0177;
XX if ((a7 >= 0100 && a7 <= 0137) || a7 == '?') a = ctl(a);
XX }
XX a |= b8;
XX if (rpt == 0) rpt = 1;
XX if (p_mode == 1 && a == '\r') continue;
XX totbytes += rpt;
XX for (; rpt > 0; rpt--) putc(a, fp);
XX }
XX return;
XX }
XX
XXvoid spar(data)
XXchar data[];
XX {
XX data[0] = tochar(MAXPACKSIZ);
XX data[1] = tochar(TTIME_KERMIT);
XX data[2] = tochar(MYPAD);
XX data[3] = ctl(MYPCHAR);
XX data[4] = tochar(MYEOL);
XX data[5] = MYQUOTE;
XX if ((p_parity >= 0) || ebqflg) { /* 8-bit quoting... */
XX data[6] = MYEBQ; /* If parity or flag on, send &. */
XX if ((ebq > 0040 && ebq < 0100) || /* If flag off, then turn it on */
XX (ebq > 0140 && ebq < 0177) || /* if other side has asked us to */
XX (ebq == 'Y')) ebqflg = 1;
XX }
XX else /* Normally, */
XX data[6] = 'Y'; /* just say we're willing. */
XX data[7] = '1';
XX data[8] = MYRPTQ;
XX data[9] = '\0';
XX }
XX
XXvoid rpar(data)
XXchar data[];
XX {
XX spsiz = unchar(data[0]);
XX ttime = unchar(data[1]);
XX pad = unchar(data[2]);
XX padchar = ctl(data[3]);
XX eol = unchar(data[4]);
XX quote = data[5];
XX rptflg = 0;
XX ebqflg = 0;
XX if (data[6] == 0) return;
XX ebq = data[6];
XX if ((ebq > 040 && ebq < 0100) || (ebq > 0140 && ebq < 0177)) ebqflg = 1;
XX else if (((p_parity >= 0) || ebqflg) && (ebq == 'Y')) {
XX ebqflg = 1;
XX ebq = '&';
XX }
XX else ebqflg = 0;
XX if (data[7] == 0) return;
XX if (data[8] == 0) return;
XX rptq = data[8];
XX rptflg = ((rptq > 040 && rptq < 0100) || (rptq > 0140 && rptq < 0177));
XX }
XX
XXsaybye()
XX {
XX int len,num;
XX spack('G',n,1,"F"); /* shut down server no more files */
XX rpack(&len,&num,ackpkt);
XX }
XX
XXprint_our_err()
XX {
XX if (retry > MAXTRY || oldtry > MAXTRY)
XX strcpy(msgpkt,"VT100 - Kermit - Too many retries for packet");
XX else
XX strcpy(msgpkt,"VT100 - Kermit - Protocol Error");
XX spack('E',n,strlen(msgpkt));
XX emits("\n");
XX emits(msgpkt);
XX }
XX
XXprint_host_err(msg)
XX char *msg;
XX {
XX curmode = FS_NORMAL;
XX emits("\n");
XX emits("Host Error: ");
XX curmode = FSF_BOLD;
XX emits(msg);
XX }
XX
XXstatusline()
XX {
XX emits ("\nFile: Pckt: Pckt No: Retrn: Bytes: Stat: ");
XX x = 48;
XX curmode = FSF_BOLD;
XX emits (filnam);
XX x = 600;
XX return(0);
XX }
XX
XXdostats(type)
XXchar type;
XX {
XX if (type != 'Y' && type != 'N' && type != 'G') {
XX x = 224;
XX emit(type);
XX x = 312;
XX sprintf(snum,"%4d",n+(tp * 64));
XX emits(snum);
XX if (n==63) tp++;
XX x = 408;
XX sprintf(snum,"%2d",retry-1);
XX emits(snum);
XX x = 488;
XX sprintf(snum,"%6ld",(long)totbytes);
XX emits(snum);
XX }
XX }
XX
XX/* allow for multi file xfers separated by commas under kermit and XMODEM */
XX
XXmulti_xfer(name,mode,do_send)
XXchar *name;
XXint (*mode)();
XXint do_send;
XX {
XX int done = 0;
XX int status;
XX char *p;
XX
XX p = name;
XX while(*p == ' ') p++;
XX while(*p && *p != ',' && *p != ' ') p++;
XX if (*p == '\0') done = TRUE;
XX else multi = 1;
XX *p = '\0';
XX
XX status = ((*mode)(name, multi));
XX if (status == TRUE && want_message) {
XX if (do_send) emits("Sent File: ");
XX else emits("Received File: ");
XX emits(name);
XX emits("\n");
XX }
XX else if (status == FALSE && want_message)
XX {
XX close(fd);
XX if (do_send) emits("Send Failed: ");
XX else emits("Receive Failed: ");
XX emits(name);
XX emits("\n");
XX }
XX if (!done && timeout != USERABORT) multi_xfer(++p, mode, do_send);
XX else emits("\n");
XX server = 0;
XX multi = 0;
XX }
XX
XXClearBuffer()
XX {
XX AbortIO(Read_Request);
XX Read_Request->IOSer.io_Command = CMD_CLEAR;
XX DoIO(Read_Request);
XX Read_Request->IOSer.io_Command = CMD_READ;
XX SendIO(Read_Request);
XX }
XX
SHAR_EOF
if test 23863 -ne "`wc -c kermit.c`"
then
echo shar: error transmitting kermit.c '(should have been 23863 characters)'
fi
# End of shell archive
exit 0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads